From 6e07ee3535cfd5211e923f5a2b248763086c8815 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 20 May 2019 15:03:58 +0300 Subject: [PATCH 001/735] Add parsing room spec from static file --- Cargo.lock | 13 +++++++++++++ Cargo.toml | 1 + room_spec.yml | 32 ++++++++++++++++++++++++++++++++ src/api/control/element.rs | 36 ++++++++++++++++++++++++++++++++++++ src/api/control/member.rs | 28 ++++++++++++++++++++++++++++ src/api/control/mod.rs | 29 +++++++++++++++++++++++++++++ src/api/control/room.rs | 20 ++++++++++++++++++++ src/main.rs | 5 ++++- 8 files changed, 163 insertions(+), 1 deletion(-) create mode 100644 room_spec.yml create mode 100644 src/api/control/element.rs create mode 100644 src/api/control/room.rs diff --git a/Cargo.lock b/Cargo.lock index 2cd956f60..1fa31d9a6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -855,6 +855,7 @@ dependencies = [ "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", "serde-humantime 0.1.1 (git+https://github.com/tailhook/serde-humantime?branch=serde_wrapper)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_yaml 0.8.9 (registry+https://github.com/rust-lang/crates.io-index)", "serial_test 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "serial_test_derive 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "slog 2.4.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1480,6 +1481,17 @@ dependencies = [ "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "serde_yaml" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "dtoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "yaml-rust 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "serial_test" version = "0.2.0" @@ -2516,6 +2528,7 @@ dependencies = [ "checksum serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)" = "5a23aa71d4a4d43fdbfaac00eff68ba8a06a51759a89ac3304323e800c4dd40d" "checksum serde_test 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)" = "110b3dbdf8607ec493c22d5d947753282f3bae73c0f56d322af1e8c78e4c23d5" "checksum serde_urlencoded 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "642dd69105886af2efd227f75a520ec9b44a820d65bc133a9131f7d229fd165a" +"checksum serde_yaml 0.8.9 (registry+https://github.com/rust-lang/crates.io-index)" = "38b08a9a90e5260fe01c6480ec7c811606df6d3a660415808c3c3fa8ed95b582" "checksum serial_test 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "50bfbc39343545618d97869d77f38ed43e48dd77432717dbc7ed39d797f3ecbe" "checksum serial_test_derive 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "89dd85be2e2ad75b041c9df2892ac078fa6e0b90024028b2b9fb4125b7530f01" "checksum sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d" diff --git a/Cargo.toml b/Cargo.toml index 64473d7b2..3b2896e56 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,6 +33,7 @@ medea-client-api-proto = { path = "proto/client-api", features = ['medea'] } newtype_derive = "0.1" serde = { version = "1.0", features = ['derive'] } serde_json = "1.0" +serde_yaml = "0.8.9" slog = "2.4" slog-envlogger = "2.1" slog-stdlog = "3.0" diff --git a/room_spec.yml b/room_spec.yml new file mode 100644 index 000000000..59acdc939 --- /dev/null +++ b/room_spec.yml @@ -0,0 +1,32 @@ +kind: Room +id: video-call-2 +spec: + pipeline: + # Here we're defining a member who initiates video call. + caller: + kind: Member + spec: + pipeline: + # Media element which is able to receive media data from client via WebRTC. + publish: + kind: WebRtcPublishEndpoint + spec: + # Actually, it receives not media data, but ICE candidates only. + p2p: Always + # Media element which is able to play media data for client via WebRTC. + play: + kind: WebRtcPlayEndpoint + # spec: + # src: "local://video-call-2/responder/publish" + responder: + kind: Member + spec: + pipeline: + publish: + kind: WebRtcPublishEndpoint + spec: + p2p: Always + play: + kind: WebRtcPlayEndpoint + # spec: + # src: "local://video-call-2/caller/publish" diff --git a/src/api/control/element.rs b/src/api/control/element.rs new file mode 100644 index 000000000..babeb61fd --- /dev/null +++ b/src/api/control/element.rs @@ -0,0 +1,36 @@ +//! Element definitions and implementations. + +use serde::{Serialize, Deserialize}; + +#[derive(Serialize, Deserialize, Debug)] +#[serde(tag = "kind")] + +/// Media element for send media data. +pub enum PublishElement { + /// Media element which is able to send media data to another client via WebRTC. + WebRtcPublishEndpoint{ + spec: WebRtcPublishEndpoint, + }, +} + +#[derive(Serialize, Deserialize, Debug)] +#[serde(tag = "kind")] +/// Media element for receive media data. +pub enum PlayElement { + /// Media element which is able to play media data for client via WebRTC. + WebRtcPlayEndpoint +} + +#[derive(Serialize, Deserialize, Debug)] +/// Peer-to-peer mode of [`WebRtcPublishEndpoint`]. +pub enum P2pMode { + /// Always connect peer-to-peer. + Always, +} + +#[derive(Serialize, Deserialize, Debug)] +/// Media element which is able to play media data for client via WebRTC. +pub struct WebRtcPublishEndpoint { + /// Peer-to-peer mode. + p2p: P2pMode, +} diff --git a/src/api/control/member.rs b/src/api/control/member.rs index 880e666aa..0edc26a2a 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -1,5 +1,9 @@ //! Member definitions and implementations. +use serde::{Serialize, Deserialize}; + +use super::element::{PublishElement, PlayElement}; + /// ID of [`Member`]. pub type Id = u64; @@ -12,3 +16,27 @@ pub struct Member { /// Credentials to authorize [`Member`] with. pub credentials: String, } + +#[derive(Serialize, Deserialize, Debug)] +#[serde(tag = "kind")] +/// `caller` or `responder` kind in [`Room`] pipeline. +pub enum MemberKind { + Member { + spec: MemberSpec, + }, +} + +#[derive(Serialize, Deserialize, Debug)] +/// Spec of member in [`Room`] pipeline. +pub struct MemberSpec { + pub pipeline: MemberPipeline, +} + +#[derive(Serialize, Deserialize, Debug)] +/// Pipeline of [`Member`] +pub struct MemberPipeline { + /// Publish pipeline of [`Member`] + pub publish: PublishElement, + /// Play pipeline of [`Member`] + pub play: PlayElement, +} diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index db3c38fcd..7fd2d2105 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -1,5 +1,34 @@ //! Implementation of Control API. mod member; +mod room; +mod element; + +use std::{ + fs::File, + io::Read as _, +}; +use failure::Error; +use serde::{Serialize, Deserialize}; + +use self::room::RoomSpec; pub use self::member::{Id as MemberId, Member}; + +#[derive(Serialize, Deserialize, Debug)] +#[serde(tag = "kind")] +pub enum ControlRoot { + Room { + id: String, + spec: RoomSpec, + }, +} + +pub fn load_from_file(path: &str) -> Result { + let mut file = File::open(path)?; + let mut buf = String::new(); + file.read_to_string(&mut buf)?; + let parsed: ControlRoot = serde_yaml::from_str(&buf)?; + + Ok(parsed) +} diff --git a/src/api/control/room.rs b/src/api/control/room.rs new file mode 100644 index 000000000..13db474c0 --- /dev/null +++ b/src/api/control/room.rs @@ -0,0 +1,20 @@ +//! Room definitions and implementations. + +use serde::{Serialize, Deserialize}; + +use super::member::MemberKind; + +#[derive(Serialize, Deserialize, Debug)] +/// Spec of [`Room`] +pub struct RoomSpec { + pipeline: RoomPipeline, +} + +#[derive(Serialize, Deserialize, Debug)] +/// [`Room`] pipeline. +pub struct RoomPipeline { + /// Caller [`Member`] spec + caller: MemberKind, + /// Responder [`Member`] spec + responder: MemberKind, +} diff --git a/src/main.rs b/src/main.rs index aab1c2a74..a3afede34 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,7 +13,7 @@ use dotenv::dotenv; use log::prelude::*; use crate::{ - api::{client::server, control::Member}, + api::{client::server, control::Member, control::load_from_file}, conf::Conf, media::create_peers, signalling::{Room, RoomsRepository}, @@ -29,6 +29,9 @@ fn main() { let config = Conf::parse().unwrap(); + let control_room = load_from_file("room_spec.yml").unwrap(); + info!("{:?}", control_room); + info!("{:?}", config); let members = hashmap! { From cbe3dc34dadc563782dc30bd47d724d8a69fec49 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 20 May 2019 15:21:47 +0300 Subject: [PATCH 002/735] Refactor --- src/api/control/element.rs | 1 - src/api/control/member.rs | 4 ++-- src/api/control/room.rs | 6 +++--- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/api/control/element.rs b/src/api/control/element.rs index babeb61fd..e5c26a813 100644 --- a/src/api/control/element.rs +++ b/src/api/control/element.rs @@ -4,7 +4,6 @@ use serde::{Serialize, Deserialize}; #[derive(Serialize, Deserialize, Debug)] #[serde(tag = "kind")] - /// Media element for send media data. pub enum PublishElement { /// Media element which is able to send media data to another client via WebRTC. diff --git a/src/api/control/member.rs b/src/api/control/member.rs index 0edc26a2a..7147df2be 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -19,8 +19,8 @@ pub struct Member { #[derive(Serialize, Deserialize, Debug)] #[serde(tag = "kind")] -/// `caller` or `responder` kind in [`Room`] pipeline. -pub enum MemberKind { +/// Entity for member requests. +pub enum MemberRequest { Member { spec: MemberSpec, }, diff --git a/src/api/control/room.rs b/src/api/control/room.rs index 13db474c0..ae56df9a6 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -2,7 +2,7 @@ use serde::{Serialize, Deserialize}; -use super::member::MemberKind; +use super::member::MemberRequest; #[derive(Serialize, Deserialize, Debug)] /// Spec of [`Room`] @@ -14,7 +14,7 @@ pub struct RoomSpec { /// [`Room`] pipeline. pub struct RoomPipeline { /// Caller [`Member`] spec - caller: MemberKind, + caller: MemberRequest, /// Responder [`Member`] spec - responder: MemberKind, + responder: MemberRequest, } From 0f31a02852cb3afc40462b49055b9547af912c1f Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 20 May 2019 17:27:29 +0300 Subject: [PATCH 003/735] Add dummy control api --- room_spec.yml | 2 +- src/api/client/server.rs | 36 +++++++++++++++++++--------- src/api/control/control_room_repo.rs | 31 ++++++++++++++++++++++++ src/api/control/element.rs | 19 +++++++-------- src/api/control/member.rs | 16 ++++++------- src/api/control/mod.rs | 33 ++++++++++++++----------- src/api/control/room.rs | 6 ++--- src/main.rs | 36 +++++++++++++++++++--------- src/signalling/mod.rs | 6 +---- src/signalling/room_repo.rs | 31 ------------------------ 10 files changed, 121 insertions(+), 95 deletions(-) create mode 100644 src/api/control/control_room_repo.rs delete mode 100644 src/signalling/room_repo.rs diff --git a/room_spec.yml b/room_spec.yml index 59acdc939..793055cfa 100644 --- a/room_spec.yml +++ b/room_spec.yml @@ -1,5 +1,5 @@ kind: Room -id: video-call-2 +id: 1 spec: pipeline: # Here we're defining a member who initiates video call. diff --git a/src/api/client/server.rs b/src/api/client/server.rs index 604976eb7..2946af5c4 100644 --- a/src/api/client/server.rs +++ b/src/api/client/server.rs @@ -6,6 +6,7 @@ use actix_web::{ }; use futures::{future, Future as _}; use serde::Deserialize; +use std::sync::Arc; use crate::{ api::{ @@ -13,11 +14,11 @@ use crate::{ rpc_connection::{AuthorizationError, Authorize}, session::WsSession, }, - control::MemberId, + control::{control_room_repo::ControlRoomRepository, MemberId}, }, conf::{Conf, Rpc}, log::prelude::*, - signalling::{RoomId, RoomsRepository}, + signalling::RoomId, }; /// Parameters of new WebSocket connection creation HTTP request. @@ -44,6 +45,7 @@ fn ws_index( match state.rooms.get(info.room_id) { Some(room) => room + .client_room .send(Authorize { member_id: info.member_id, credentials: info.credentials.clone(), @@ -54,7 +56,7 @@ fn ws_index( &r.drop_state(), WsSession::new( info.member_id, - room, + room.client_room, state.config.idle_timeout, ), ), @@ -73,14 +75,14 @@ fn ws_index( /// Context for [`App`] which holds all the necessary dependencies. pub struct Context { /// Repository of all currently existing [`Room`]s in application. - pub rooms: RoomsRepository, + pub rooms: Arc, /// Settings of application. pub config: Rpc, } /// Starts HTTP server for handling WebSocket connections of Client API. -pub fn run(rooms: RoomsRepository, config: Conf) { +pub fn run(rooms: Arc, config: Conf) { let server_addr = config.server.get_bind_addr(); server::new(move || { @@ -116,25 +118,37 @@ mod test { }; use super::*; + use crate::api::control::{ControlRoom, RoomRequest}; /// Creates [`RoomsRepository`] for tests filled with a single [`Room`]. - fn room(conf: Rpc) -> RoomsRepository { + fn room(conf: Rpc) -> ControlRoomRepository { let members = hashmap! { 1 => Member{id: 1, credentials: "caller_credentials".into()}, 2 => Member{id: 2, credentials: "responder_credentials".into()}, }; - let room = Arbiter::start(move |_| { - Room::new(1, members, create_peers(1, 2), conf.reconnect_timeout) + let (id, room_spec) = + match crate::api::control::load_from_file("room_spec.yml").unwrap() + { + RoomRequest::Room { id, spec } => (id, spec), + }; + let client_room = Arbiter::start(move |_| { + Room::new(id, members, create_peers(1, 2), conf.reconnect_timeout) }); - let rooms = hashmap! {1 => room}; - RoomsRepository::new(rooms) + let room = ControlRoom { + client_room, + spec: room_spec, + }; + let rooms = hashmap! { + 1 => room + }; + ControlRoomRepository::new(rooms) } /// Creates test WebSocket server of Client API which can handle requests. fn ws_server(conf: Conf) -> test::TestServer { test::TestServer::with_factory(move || { App::with_state(Context { - rooms: room(conf.rpc.clone()), + rooms: Arc::new(room(conf.rpc.clone())), config: conf.rpc.clone(), }) .resource("/ws/{room_id}/{member_id}/{credentials}", |r| { diff --git a/src/api/control/control_room_repo.rs b/src/api/control/control_room_repo.rs new file mode 100644 index 000000000..258f76d0a --- /dev/null +++ b/src/api/control/control_room_repo.rs @@ -0,0 +1,31 @@ +use super::ControlRoom; + +use crate::signalling::RoomId; + +use hashbrown::HashMap; +use std::sync::{Arc, Mutex}; + +#[derive(Clone)] +pub struct ControlRoomRepository { + // TODO: Use crossbeam's concurrent hashmap when its done. + // [Tracking](https://github.com/crossbeam-rs/rfcs/issues/32). + rooms: Arc>>, +} + +impl ControlRoomRepository { + pub fn new(rooms: HashMap) -> Self { + Self { + rooms: Arc::new(Mutex::new(rooms)), + } + } + + pub fn get(&self, id: RoomId) -> Option { + let rooms = self.rooms.lock().unwrap(); + rooms.get(&id).cloned() + } + + pub fn add(&mut self, room_id: RoomId, room: ControlRoom) { + let mut rooms = self.rooms.lock().unwrap(); + rooms.insert(room_id, room); + } +} diff --git a/src/api/control/element.rs b/src/api/control/element.rs index e5c26a813..a3e31f4f9 100644 --- a/src/api/control/element.rs +++ b/src/api/control/element.rs @@ -1,33 +1,32 @@ //! Element definitions and implementations. -use serde::{Serialize, Deserialize}; +use serde::{Deserialize, Serialize}; -#[derive(Serialize, Deserialize, Debug)] +#[derive(Serialize, Deserialize, Debug, Clone)] #[serde(tag = "kind")] /// Media element for send media data. pub enum PublishElement { - /// Media element which is able to send media data to another client via WebRTC. - WebRtcPublishEndpoint{ - spec: WebRtcPublishEndpoint, - }, + /// Media element which is able to send media data to another client via + /// WebRTC. + WebRtcPublishEndpoint { spec: WebRtcPublishEndpoint }, } -#[derive(Serialize, Deserialize, Debug)] +#[derive(Serialize, Deserialize, Debug, Clone)] #[serde(tag = "kind")] /// Media element for receive media data. pub enum PlayElement { /// Media element which is able to play media data for client via WebRTC. - WebRtcPlayEndpoint + WebRtcPlayEndpoint, } -#[derive(Serialize, Deserialize, Debug)] +#[derive(Serialize, Deserialize, Debug, Clone)] /// Peer-to-peer mode of [`WebRtcPublishEndpoint`]. pub enum P2pMode { /// Always connect peer-to-peer. Always, } -#[derive(Serialize, Deserialize, Debug)] +#[derive(Serialize, Deserialize, Debug, Clone)] /// Media element which is able to play media data for client via WebRTC. pub struct WebRtcPublishEndpoint { /// Peer-to-peer mode. diff --git a/src/api/control/member.rs b/src/api/control/member.rs index 7147df2be..41b8192c9 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -1,14 +1,14 @@ //! Member definitions and implementations. -use serde::{Serialize, Deserialize}; +use serde::{Deserialize, Serialize}; -use super::element::{PublishElement, PlayElement}; +use super::element::{PlayElement, PublishElement}; /// ID of [`Member`]. pub type Id = u64; /// Media server user with its ID and credentials. -#[derive(Clone, Debug)] +#[derive(Debug, Clone)] pub struct Member { /// ID of [`Member`]. pub id: Id, @@ -17,22 +17,20 @@ pub struct Member { pub credentials: String, } -#[derive(Serialize, Deserialize, Debug)] +#[derive(Serialize, Deserialize, Debug, Clone)] #[serde(tag = "kind")] /// Entity for member requests. pub enum MemberRequest { - Member { - spec: MemberSpec, - }, + Member { spec: MemberSpec }, } -#[derive(Serialize, Deserialize, Debug)] +#[derive(Serialize, Deserialize, Debug, Clone)] /// Spec of member in [`Room`] pipeline. pub struct MemberSpec { pub pipeline: MemberPipeline, } -#[derive(Serialize, Deserialize, Debug)] +#[derive(Serialize, Deserialize, Debug, Clone)] /// Pipeline of [`Member`] pub struct MemberPipeline { /// Publish pipeline of [`Member`] diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index 7fd2d2105..68c42f6bf 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -1,34 +1,39 @@ //! Implementation of Control API. +pub mod control_room_repo; + +mod element; mod member; mod room; -mod element; -use std::{ - fs::File, - io::Read as _, -}; +use actix::Addr; use failure::Error; -use serde::{Serialize, Deserialize}; +use serde::{Deserialize, Serialize}; +use std::{fs::File, io::Read as _}; + +use crate::signalling::{Room, RoomId}; use self::room::RoomSpec; pub use self::member::{Id as MemberId, Member}; -#[derive(Serialize, Deserialize, Debug)] +#[derive(Serialize, Deserialize, Debug, Clone)] #[serde(tag = "kind")] -pub enum ControlRoot { - Room { - id: String, - spec: RoomSpec, - }, +pub enum RoomRequest { + Room { id: RoomId, spec: RoomSpec }, } -pub fn load_from_file(path: &str) -> Result { +pub fn load_from_file(path: &str) -> Result { let mut file = File::open(path)?; let mut buf = String::new(); file.read_to_string(&mut buf)?; - let parsed: ControlRoot = serde_yaml::from_str(&buf)?; + let parsed: RoomRequest = serde_yaml::from_str(&buf)?; Ok(parsed) } + +#[derive(Clone)] +pub struct ControlRoom { + pub client_room: Addr, + pub spec: RoomSpec, +} diff --git a/src/api/control/room.rs b/src/api/control/room.rs index ae56df9a6..24c5b6ddb 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -1,16 +1,16 @@ //! Room definitions and implementations. -use serde::{Serialize, Deserialize}; +use serde::{Deserialize, Serialize}; use super::member::MemberRequest; -#[derive(Serialize, Deserialize, Debug)] +#[derive(Serialize, Deserialize, Debug, Clone)] /// Spec of [`Room`] pub struct RoomSpec { pipeline: RoomPipeline, } -#[derive(Serialize, Deserialize, Debug)] +#[derive(Serialize, Deserialize, Debug, Clone)] /// [`Room`] pipeline. pub struct RoomPipeline { /// Caller [`Member`] spec diff --git a/src/main.rs b/src/main.rs index a3afede34..0638dfc63 100644 --- a/src/main.rs +++ b/src/main.rs @@ -11,12 +11,20 @@ pub mod signalling; use actix::prelude::*; use dotenv::dotenv; use log::prelude::*; +use std::sync::Arc; use crate::{ - api::{client::server, control::Member, control::load_from_file}, + api::{ + client::server, + control::Member, + control::{ + control_room_repo::ControlRoomRepository, load_from_file, + ControlRoom, RoomRequest, + }, + }, conf::Conf, media::create_peers, - signalling::{Room, RoomsRepository}, + signalling::Room, }; fn main() { @@ -28,10 +36,6 @@ fn main() { let sys = System::new("medea"); let config = Conf::parse().unwrap(); - - let control_room = load_from_file("room_spec.yml").unwrap(); - info!("{:?}", control_room); - info!("{:?}", config); let members = hashmap! { @@ -39,11 +43,21 @@ fn main() { 2 => Member{id: 2, credentials: "responder_credentials".to_owned()}, }; let peers = create_peers(1, 2); - let room = Room::new(1, members, peers, config.rpc.reconnect_timeout); - let room = Arbiter::start(move |_| room); - let rooms = hashmap! {1 => room}; - let rooms_repo = RoomsRepository::new(rooms); + let (id, room_spec) = match load_from_file("room_spec.yml").unwrap() { + RoomRequest::Room { id, spec } => (id, spec), + }; + let client_room = + Room::new(id, members, peers, config.rpc.reconnect_timeout); + let client_room = Arbiter::start(move |_| client_room); + + let control_room = ControlRoom { + client_room, + spec: room_spec, + }; + let rooms = hashmap! {id => control_room}; + + let room_repo = Arc::new(ControlRoomRepository::new(rooms)); - server::run(rooms_repo, config); + server::run(Arc::clone(&room_repo), config); let _ = sys.run(); } diff --git a/src/signalling/mod.rs b/src/signalling/mod.rs index ddf76119c..56a86f041 100644 --- a/src/signalling/mod.rs +++ b/src/signalling/mod.rs @@ -1,9 +1,5 @@ pub mod participants; pub mod peers; pub mod room; -pub mod room_repo; -pub use self::{ - room::{Id as RoomId, Room}, - room_repo::RoomsRepository, -}; +pub use self::room::{Id as RoomId, Room}; diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs deleted file mode 100644 index f0df8ead4..000000000 --- a/src/signalling/room_repo.rs +++ /dev/null @@ -1,31 +0,0 @@ -//! Repository that stores [`Room`]s addresses. - -use actix::Addr; -use hashbrown::HashMap; - -use std::sync::{Arc, Mutex}; - -use crate::signalling::{Room, RoomId}; - -/// Repository that stores [`Room`]s addresses. -#[derive(Clone, Default)] -pub struct RoomsRepository { - // TODO: Use crossbeam's concurrent hashmap when its done. - // [Tracking](https://github.com/crossbeam-rs/rfcs/issues/32). - rooms: Arc>>>, -} - -impl RoomsRepository { - /// Creates new [`Room`]s repository with passed-in [`Room`]s. - pub fn new(rooms: HashMap>) -> Self { - Self { - rooms: Arc::new(Mutex::new(rooms)), - } - } - - /// Returns [`Room`] by its ID. - pub fn get(&self, id: RoomId) -> Option> { - let rooms = self.rooms.lock().unwrap(); - rooms.get(&id).cloned() - } -} From cda5c0025eae6e92ee625bf76354c5cee4e0f2be Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 20 May 2019 18:06:00 +0300 Subject: [PATCH 004/735] Delete useless Arc --- src/api/client/server.rs | 7 +++---- src/main.rs | 5 ++--- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/api/client/server.rs b/src/api/client/server.rs index 2946af5c4..0f47602c2 100644 --- a/src/api/client/server.rs +++ b/src/api/client/server.rs @@ -6,7 +6,6 @@ use actix_web::{ }; use futures::{future, Future as _}; use serde::Deserialize; -use std::sync::Arc; use crate::{ api::{ @@ -75,14 +74,14 @@ fn ws_index( /// Context for [`App`] which holds all the necessary dependencies. pub struct Context { /// Repository of all currently existing [`Room`]s in application. - pub rooms: Arc, + pub rooms: ControlRoomRepository, /// Settings of application. pub config: Rpc, } /// Starts HTTP server for handling WebSocket connections of Client API. -pub fn run(rooms: Arc, config: Conf) { +pub fn run(rooms: ControlRoomRepository, config: Conf) { let server_addr = config.server.get_bind_addr(); server::new(move || { @@ -148,7 +147,7 @@ mod test { fn ws_server(conf: Conf) -> test::TestServer { test::TestServer::with_factory(move || { App::with_state(Context { - rooms: Arc::new(room(conf.rpc.clone())), + rooms: room(conf.rpc.clone()), config: conf.rpc.clone(), }) .resource("/ws/{room_id}/{member_id}/{credentials}", |r| { diff --git a/src/main.rs b/src/main.rs index 0638dfc63..b56723d19 100644 --- a/src/main.rs +++ b/src/main.rs @@ -11,7 +11,6 @@ pub mod signalling; use actix::prelude::*; use dotenv::dotenv; use log::prelude::*; -use std::sync::Arc; use crate::{ api::{ @@ -56,8 +55,8 @@ fn main() { }; let rooms = hashmap! {id => control_room}; - let room_repo = Arc::new(ControlRoomRepository::new(rooms)); + let room_repo = ControlRoomRepository::new(rooms); - server::run(Arc::clone(&room_repo), config); + server::run(room_repo.clone(), config); let _ = sys.run(); } From 11fa2cafe6e5c6b69895a087976f7462de878fea Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 20 May 2019 18:12:43 +0300 Subject: [PATCH 005/735] Refactor --- src/api/client/server.rs | 11 ++++++----- src/api/control/mod.rs | 2 -- src/api/mod.rs | 1 + .../{control/control_room_repo.rs => room_repo.rs} | 6 +++--- src/main.rs | 12 +++++++----- 5 files changed, 17 insertions(+), 15 deletions(-) rename src/api/{control/control_room_repo.rs => room_repo.rs} (89%) diff --git a/src/api/client/server.rs b/src/api/client/server.rs index 0f47602c2..57ba4df27 100644 --- a/src/api/client/server.rs +++ b/src/api/client/server.rs @@ -13,7 +13,8 @@ use crate::{ rpc_connection::{AuthorizationError, Authorize}, session::WsSession, }, - control::{control_room_repo::ControlRoomRepository, MemberId}, + control::{MemberId}, + room_repo::RoomRepository, }, conf::{Conf, Rpc}, log::prelude::*, @@ -74,14 +75,14 @@ fn ws_index( /// Context for [`App`] which holds all the necessary dependencies. pub struct Context { /// Repository of all currently existing [`Room`]s in application. - pub rooms: ControlRoomRepository, + pub rooms: RoomRepository, /// Settings of application. pub config: Rpc, } /// Starts HTTP server for handling WebSocket connections of Client API. -pub fn run(rooms: ControlRoomRepository, config: Conf) { +pub fn run(rooms: RoomRepository, config: Conf) { let server_addr = config.server.get_bind_addr(); server::new(move || { @@ -120,7 +121,7 @@ mod test { use crate::api::control::{ControlRoom, RoomRequest}; /// Creates [`RoomsRepository`] for tests filled with a single [`Room`]. - fn room(conf: Rpc) -> ControlRoomRepository { + fn room(conf: Rpc) -> RoomRepository { let members = hashmap! { 1 => Member{id: 1, credentials: "caller_credentials".into()}, 2 => Member{id: 2, credentials: "responder_credentials".into()}, @@ -140,7 +141,7 @@ mod test { let rooms = hashmap! { 1 => room }; - ControlRoomRepository::new(rooms) + RoomRepository::new(rooms) } /// Creates test WebSocket server of Client API which can handle requests. diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index 68c42f6bf..513e028e8 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -1,7 +1,5 @@ //! Implementation of Control API. -pub mod control_room_repo; - mod element; mod member; mod room; diff --git a/src/api/mod.rs b/src/api/mod.rs index 1c66e73e5..ef98e501f 100644 --- a/src/api/mod.rs +++ b/src/api/mod.rs @@ -2,3 +2,4 @@ pub mod client; pub mod control; +pub mod room_repo; diff --git a/src/api/control/control_room_repo.rs b/src/api/room_repo.rs similarity index 89% rename from src/api/control/control_room_repo.rs rename to src/api/room_repo.rs index 258f76d0a..9d33eda6e 100644 --- a/src/api/control/control_room_repo.rs +++ b/src/api/room_repo.rs @@ -1,4 +1,4 @@ -use super::ControlRoom; +use super::control::ControlRoom; use crate::signalling::RoomId; @@ -6,13 +6,13 @@ use hashbrown::HashMap; use std::sync::{Arc, Mutex}; #[derive(Clone)] -pub struct ControlRoomRepository { +pub struct RoomRepository { // TODO: Use crossbeam's concurrent hashmap when its done. // [Tracking](https://github.com/crossbeam-rs/rfcs/issues/32). rooms: Arc>>, } -impl ControlRoomRepository { +impl RoomRepository { pub fn new(rooms: HashMap) -> Self { Self { rooms: Arc::new(Mutex::new(rooms)), diff --git a/src/main.rs b/src/main.rs index b56723d19..14826cb5e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -17,9 +17,10 @@ use crate::{ client::server, control::Member, control::{ - control_room_repo::ControlRoomRepository, load_from_file, + load_from_file, ControlRoom, RoomRequest, }, + room_repo::RoomRepository, }, conf::Conf, media::create_peers, @@ -37,14 +38,15 @@ fn main() { let config = Conf::parse().unwrap(); info!("{:?}", config); + let (id, room_spec) = match load_from_file("room_spec.yml").unwrap() { + RoomRequest::Room { id, spec } => (id, spec), + }; + let members = hashmap! { 1 => Member{id: 1, credentials: "caller_credentials".to_owned()}, 2 => Member{id: 2, credentials: "responder_credentials".to_owned()}, }; let peers = create_peers(1, 2); - let (id, room_spec) = match load_from_file("room_spec.yml").unwrap() { - RoomRequest::Room { id, spec } => (id, spec), - }; let client_room = Room::new(id, members, peers, config.rpc.reconnect_timeout); let client_room = Arbiter::start(move |_| client_room); @@ -55,7 +57,7 @@ fn main() { }; let rooms = hashmap! {id => control_room}; - let room_repo = ControlRoomRepository::new(rooms); + let room_repo = RoomRepository::new(rooms); server::run(room_repo.clone(), config); let _ = sys.run(); From 619ede6893b57559feb0cbcb985c75de21325120 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 20 May 2019 18:25:08 +0300 Subject: [PATCH 006/735] Refactor --- src/api/client/server.rs | 4 ++-- src/api/control/mod.rs | 14 +++++--------- src/api/room_repo.rs | 15 +++++++++++---- src/main.rs | 7 ++----- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/api/client/server.rs b/src/api/client/server.rs index 57ba4df27..c79dc1be1 100644 --- a/src/api/client/server.rs +++ b/src/api/client/server.rs @@ -13,7 +13,7 @@ use crate::{ rpc_connection::{AuthorizationError, Authorize}, session::WsSession, }, - control::{MemberId}, + control::MemberId, room_repo::RoomRepository, }, conf::{Conf, Rpc}, @@ -118,7 +118,7 @@ mod test { }; use super::*; - use crate::api::control::{ControlRoom, RoomRequest}; + use crate::api::{control::RoomRequest, room_repo::ControlRoom}; /// Creates [`RoomsRepository`] for tests filled with a single [`Room`]. fn room(conf: Rpc) -> RoomRepository { diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index 513e028e8..12cdf143f 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -2,14 +2,14 @@ mod element; mod member; -mod room; -use actix::Addr; +pub mod room; + use failure::Error; use serde::{Deserialize, Serialize}; use std::{fs::File, io::Read as _}; -use crate::signalling::{Room, RoomId}; +use crate::signalling::RoomId; use self::room::RoomSpec; @@ -17,10 +17,12 @@ pub use self::member::{Id as MemberId, Member}; #[derive(Serialize, Deserialize, Debug, Clone)] #[serde(tag = "kind")] +/// Entity for creating new Room. pub enum RoomRequest { Room { id: RoomId, spec: RoomSpec }, } +/// Load [`RoomRequest`] from file with YAML format. pub fn load_from_file(path: &str) -> Result { let mut file = File::open(path)?; let mut buf = String::new(); @@ -29,9 +31,3 @@ pub fn load_from_file(path: &str) -> Result { Ok(parsed) } - -#[derive(Clone)] -pub struct ControlRoom { - pub client_room: Addr, - pub spec: RoomSpec, -} diff --git a/src/api/room_repo.rs b/src/api/room_repo.rs index 9d33eda6e..dfa8dfb9f 100644 --- a/src/api/room_repo.rs +++ b/src/api/room_repo.rs @@ -1,9 +1,16 @@ -use super::control::ControlRoom; - -use crate::signalling::RoomId; - use hashbrown::HashMap; use std::sync::{Arc, Mutex}; +use actix::Addr; + +use crate::signalling::{Room, RoomId}; + +use super::control::room::RoomSpec; + +#[derive(Clone)] +pub struct ControlRoom { + pub client_room: Addr, + pub spec: RoomSpec, +} #[derive(Clone)] pub struct RoomRepository { diff --git a/src/main.rs b/src/main.rs index 14826cb5e..6d929a04b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -16,11 +16,8 @@ use crate::{ api::{ client::server, control::Member, - control::{ - load_from_file, - ControlRoom, RoomRequest, - }, - room_repo::RoomRepository, + control::{load_from_file, RoomRequest}, + room_repo::{ControlRoom, RoomRepository}, }, conf::Conf, media::create_peers, From 6dc3c086e3fabdbbbefcc8f3a5896ce0e9fb65eb Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 20 May 2019 18:44:08 +0300 Subject: [PATCH 007/735] Make play and publish pipeline's fields optional --- src/api/control/member.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/api/control/member.rs b/src/api/control/member.rs index 41b8192c9..db3f684a6 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -34,7 +34,7 @@ pub struct MemberSpec { /// Pipeline of [`Member`] pub struct MemberPipeline { /// Publish pipeline of [`Member`] - pub publish: PublishElement, + pub publish: Option, /// Play pipeline of [`Member`] - pub play: PlayElement, + pub play: Option, } From dff6d97c27f1ae05cab47865dee5e1139f664637 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 20 May 2019 18:56:29 +0300 Subject: [PATCH 008/735] Make fields public --- src/api/control/element.rs | 2 +- src/api/control/room.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/api/control/element.rs b/src/api/control/element.rs index a3e31f4f9..f73dde3f4 100644 --- a/src/api/control/element.rs +++ b/src/api/control/element.rs @@ -30,5 +30,5 @@ pub enum P2pMode { /// Media element which is able to play media data for client via WebRTC. pub struct WebRtcPublishEndpoint { /// Peer-to-peer mode. - p2p: P2pMode, + pub p2p: P2pMode, } diff --git a/src/api/control/room.rs b/src/api/control/room.rs index 24c5b6ddb..fbb241298 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -7,14 +7,14 @@ use super::member::MemberRequest; #[derive(Serialize, Deserialize, Debug, Clone)] /// Spec of [`Room`] pub struct RoomSpec { - pipeline: RoomPipeline, + pub pipeline: RoomPipeline, } #[derive(Serialize, Deserialize, Debug, Clone)] /// [`Room`] pipeline. pub struct RoomPipeline { /// Caller [`Member`] spec - caller: MemberRequest, + pub caller: MemberRequest, /// Responder [`Member`] spec - responder: MemberRequest, + pub responder: MemberRequest, } From df70f17524bc8f94748c7aaad02dce2d468f1e36 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 20 May 2019 19:03:55 +0300 Subject: [PATCH 009/735] Fix doc --- src/api/control/member.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/api/control/member.rs b/src/api/control/member.rs index db3f684a6..94995bb44 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -33,8 +33,8 @@ pub struct MemberSpec { #[derive(Serialize, Deserialize, Debug, Clone)] /// Pipeline of [`Member`] pub struct MemberPipeline { - /// Publish pipeline of [`Member`] + /// Publish element of [`Member`]. pub publish: Option, - /// Play pipeline of [`Member`] + /// Play element of [`Member`]. pub play: Option, } From f17a56312a935b3c870b1f1e39bbb5f61c821b63 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 21 May 2019 17:38:13 +0300 Subject: [PATCH 010/735] Make pipeline ids dynamic --- room_spec.yml | 8 ++++---- src/api/control/element.rs | 19 +++++++------------ src/api/control/member.rs | 14 +++----------- src/api/control/room.rs | 13 +++---------- src/main.rs | 2 ++ 5 files changed, 19 insertions(+), 37 deletions(-) diff --git a/room_spec.yml b/room_spec.yml index 793055cfa..810b13f49 100644 --- a/room_spec.yml +++ b/room_spec.yml @@ -16,8 +16,8 @@ spec: # Media element which is able to play media data for client via WebRTC. play: kind: WebRtcPlayEndpoint - # spec: - # src: "local://video-call-2/responder/publish" + spec: + src: "local://video-call-2/responder/publish" responder: kind: Member spec: @@ -28,5 +28,5 @@ spec: p2p: Always play: kind: WebRtcPlayEndpoint - # spec: - # src: "local://video-call-2/caller/publish" + spec: + src: "local://video-call-2/caller/publish" diff --git a/src/api/control/element.rs b/src/api/control/element.rs index f73dde3f4..7b6f72984 100644 --- a/src/api/control/element.rs +++ b/src/api/control/element.rs @@ -4,19 +4,9 @@ use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize, Debug, Clone)] #[serde(tag = "kind")] -/// Media element for send media data. -pub enum PublishElement { - /// Media element which is able to send media data to another client via - /// WebRTC. +pub enum Element { WebRtcPublishEndpoint { spec: WebRtcPublishEndpoint }, -} - -#[derive(Serialize, Deserialize, Debug, Clone)] -#[serde(tag = "kind")] -/// Media element for receive media data. -pub enum PlayElement { - /// Media element which is able to play media data for client via WebRTC. - WebRtcPlayEndpoint, + WebRtcPlayEndpoint { spec: WebRtcPlayEndpoint}, } #[derive(Serialize, Deserialize, Debug, Clone)] @@ -32,3 +22,8 @@ pub struct WebRtcPublishEndpoint { /// Peer-to-peer mode. pub p2p: P2pMode, } + +#[derive(Serialize, Deserialize, Debug, Clone)] +pub struct WebRtcPlayEndpoint { + pub src: String, +} diff --git a/src/api/control/member.rs b/src/api/control/member.rs index 94995bb44..07f388819 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -2,7 +2,8 @@ use serde::{Deserialize, Serialize}; -use super::element::{PlayElement, PublishElement}; +use super::element::Element; +use std::collections::HashMap; /// ID of [`Member`]. pub type Id = u64; @@ -27,14 +28,5 @@ pub enum MemberRequest { #[derive(Serialize, Deserialize, Debug, Clone)] /// Spec of member in [`Room`] pipeline. pub struct MemberSpec { - pub pipeline: MemberPipeline, -} - -#[derive(Serialize, Deserialize, Debug, Clone)] -/// Pipeline of [`Member`] -pub struct MemberPipeline { - /// Publish element of [`Member`]. - pub publish: Option, - /// Play element of [`Member`]. - pub play: Option, + pub pipeline: HashMap, } diff --git a/src/api/control/room.rs b/src/api/control/room.rs index fbb241298..03e8132e2 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -4,17 +4,10 @@ use serde::{Deserialize, Serialize}; use super::member::MemberRequest; +use std::collections::HashMap; + #[derive(Serialize, Deserialize, Debug, Clone)] /// Spec of [`Room`] pub struct RoomSpec { - pub pipeline: RoomPipeline, -} - -#[derive(Serialize, Deserialize, Debug, Clone)] -/// [`Room`] pipeline. -pub struct RoomPipeline { - /// Caller [`Member`] spec - pub caller: MemberRequest, - /// Responder [`Member`] spec - pub responder: MemberRequest, + pub pipeline: HashMap, } diff --git a/src/main.rs b/src/main.rs index 6d929a04b..dd4c7729e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -39,6 +39,8 @@ fn main() { RoomRequest::Room { id, spec } => (id, spec), }; + println!("{:#?}", room_spec); + let members = hashmap! { 1 => Member{id: 1, credentials: "caller_credentials".to_owned()}, 2 => Member{id: 2, credentials: "responder_credentials".to_owned()}, From 522a058f9b843113c0a13e585db61b5c7d682df8 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 21 May 2019 18:35:26 +0300 Subject: [PATCH 011/735] Add local uri parser --- src/api/control/element.rs | 96 +++++++++++++++++++++++++++++++++++--- src/api/control/member.rs | 7 +-- src/api/control/mod.rs | 4 +- src/api/control/room.rs | 4 +- src/api/room_repo.rs | 2 +- 5 files changed, 98 insertions(+), 15 deletions(-) diff --git a/src/api/control/element.rs b/src/api/control/element.rs index 7b6f72984..29936adb4 100644 --- a/src/api/control/element.rs +++ b/src/api/control/element.rs @@ -1,29 +1,111 @@ //! Element definitions and implementations. -use serde::{Deserialize, Serialize}; +use serde::{ + de::{self, Deserializer, Error, Visitor}, + Deserialize, +}; +use std::fmt; -#[derive(Serialize, Deserialize, Debug, Clone)] +#[derive(Deserialize, Debug, Clone)] #[serde(tag = "kind")] pub enum Element { WebRtcPublishEndpoint { spec: WebRtcPublishEndpoint }, - WebRtcPlayEndpoint { spec: WebRtcPlayEndpoint}, + WebRtcPlayEndpoint { spec: WebRtcPlayEndpoint }, } -#[derive(Serialize, Deserialize, Debug, Clone)] +#[derive(Deserialize, Debug, Clone)] /// Peer-to-peer mode of [`WebRtcPublishEndpoint`]. pub enum P2pMode { /// Always connect peer-to-peer. Always, } -#[derive(Serialize, Deserialize, Debug, Clone)] +#[derive(Deserialize, Debug, Clone)] /// Media element which is able to play media data for client via WebRTC. pub struct WebRtcPublishEndpoint { /// Peer-to-peer mode. pub p2p: P2pMode, } -#[derive(Serialize, Deserialize, Debug, Clone)] +#[derive(Deserialize, Debug, Clone)] pub struct WebRtcPlayEndpoint { - pub src: String, + pub src: LocalUri, +} + +#[derive(Debug, Clone)] +pub struct LocalUri { + pub room_id: String, + pub member_id: String, + pub pipeline_id: String, +} + +impl<'de> Deserialize<'de> for LocalUri { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct LocalUriVisitor; + + impl<'de> Visitor<'de> for LocalUriVisitor { + type Value = LocalUri; + + fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str( + "Uri in format local://room_id/member_id/pipeline_id", + ) + } + + // TODO: Return error with information about place where this error + // happened. + fn visit_str(self, value: &str) -> Result + where + E: de::Error, + { + let protocol_name: String = value.chars().take(8).collect(); + if protocol_name != "local://" { + return Err(Error::custom( + "Expected local uri in format \ + local://room_id/member_id/pipeline_id!", + )); + } + + let uri_body = value.chars().skip(8).collect::(); + let mut uri_body_splitted: Vec<&str> = + uri_body.rsplit('/').collect(); + let uri_body_splitted_len = uri_body_splitted.len(); + if uri_body_splitted_len != 3 { + let error_msg = if uri_body_splitted_len == 0 { + "Missing room_id, member_id, pipeline_id" + } else if uri_body_splitted_len == 1 { + "Missing member_id, pipeline_id" + } else if uri_body_splitted_len == 2 { + "Missing pipeline_id" + } else { + "Too many params" + }; + return Err(Error::custom(error_msg)); + } + let room_id = uri_body_splitted.pop().unwrap().to_string(); + if room_id.is_empty() { + return Err(Error::custom("room_id is empty!")); + } + let member_id = uri_body_splitted.pop().unwrap().to_string(); + if member_id.is_empty() { + return Err(Error::custom("member_id is empty!")); + } + let pipeline_id = uri_body_splitted.pop().unwrap().to_string(); + if pipeline_id.is_empty() { + return Err(Error::custom("pipeline_id is empty!")); + } + + Ok(LocalUri { + room_id, + member_id, + pipeline_id, + }) + } + } + + deserializer.deserialize_identifier(LocalUriVisitor) + } } diff --git a/src/api/control/member.rs b/src/api/control/member.rs index 07f388819..f0cb4f85f 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -1,8 +1,9 @@ //! Member definitions and implementations. -use serde::{Deserialize, Serialize}; +use serde::Deserialize; use super::element::Element; + use std::collections::HashMap; /// ID of [`Member`]. @@ -18,14 +19,14 @@ pub struct Member { pub credentials: String, } -#[derive(Serialize, Deserialize, Debug, Clone)] +#[derive(Deserialize, Debug, Clone)] #[serde(tag = "kind")] /// Entity for member requests. pub enum MemberRequest { Member { spec: MemberSpec }, } -#[derive(Serialize, Deserialize, Debug, Clone)] +#[derive(Deserialize, Debug, Clone)] /// Spec of member in [`Room`] pipeline. pub struct MemberSpec { pub pipeline: HashMap, diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index 12cdf143f..412a62a62 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -6,7 +6,7 @@ mod member; pub mod room; use failure::Error; -use serde::{Deserialize, Serialize}; +use serde::Deserialize; use std::{fs::File, io::Read as _}; use crate::signalling::RoomId; @@ -15,7 +15,7 @@ use self::room::RoomSpec; pub use self::member::{Id as MemberId, Member}; -#[derive(Serialize, Deserialize, Debug, Clone)] +#[derive(Deserialize, Debug, Clone)] #[serde(tag = "kind")] /// Entity for creating new Room. pub enum RoomRequest { diff --git a/src/api/control/room.rs b/src/api/control/room.rs index 03e8132e2..b141f4417 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -1,12 +1,12 @@ //! Room definitions and implementations. -use serde::{Deserialize, Serialize}; +use serde::Deserialize; use super::member::MemberRequest; use std::collections::HashMap; -#[derive(Serialize, Deserialize, Debug, Clone)] +#[derive(Deserialize, Debug, Clone)] /// Spec of [`Room`] pub struct RoomSpec { pub pipeline: HashMap, diff --git a/src/api/room_repo.rs b/src/api/room_repo.rs index dfa8dfb9f..6d7201f2a 100644 --- a/src/api/room_repo.rs +++ b/src/api/room_repo.rs @@ -1,6 +1,6 @@ +use actix::Addr; use hashbrown::HashMap; use std::sync::{Arc, Mutex}; -use actix::Addr; use crate::signalling::{Room, RoomId}; From 5186c37e81b06d8332b07f13532af3f443e02010 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 22 May 2019 14:23:36 +0300 Subject: [PATCH 012/735] Very ugly room creating implementation --- jason/e2e-demo/js/index.js | 7 +- src/api/client/server.rs | 42 +++++------- src/api/control/member.rs | 2 + src/api/control/mod.rs | 4 +- src/api/control/room.rs | 3 + src/main.rs | 28 +++----- src/signalling/mod.rs | 1 + src/signalling/participants.rs | 34 ++++++++++ src/signalling/room.rs | 117 +++++++++++++++++++++++++++++++-- src/signalling/room_repo.rs | 31 +++++++++ 10 files changed, 212 insertions(+), 57 deletions(-) create mode 100644 src/signalling/room_repo.rs diff --git a/jason/e2e-demo/js/index.js b/jason/e2e-demo/js/index.js index 33c315fc2..fa9f28d33 100644 --- a/jason/e2e-demo/js/index.js +++ b/jason/e2e-demo/js/index.js @@ -4,13 +4,14 @@ async function f() { let caller = new rust.Jason(); // let caller_room_handle = await caller.join_room("ws://localhost:8080/ws/1/1/caller_credentials"); - caller.join_room("ws://localhost:8080/ws/1/1/caller_credentials"); - + caller.join_room("ws://localhost:8080/ws/1/0/0-credentials"); + caller.join_room("ws://localhost:8080/ws/1/1/1-credentials"); + // caller.join_room("ws://localhost:8080/ws/1/2/responder_credentials"); // let responder = new rust.Jason(); // let responder_room_handler = await responder.join_room("ws://localhost:8080/ws/1/2/responder_credentials"); - caller.dispose(); + // caller.dispose(); // responder.dispose(); } diff --git a/src/api/client/server.rs b/src/api/client/server.rs index c79dc1be1..ec387d28e 100644 --- a/src/api/client/server.rs +++ b/src/api/client/server.rs @@ -14,11 +14,10 @@ use crate::{ session::WsSession, }, control::MemberId, - room_repo::RoomRepository, }, conf::{Conf, Rpc}, log::prelude::*, - signalling::RoomId, + signalling::{RoomId, room_repo::RoomsRepository}, }; /// Parameters of new WebSocket connection creation HTTP request. @@ -45,7 +44,6 @@ fn ws_index( match state.rooms.get(info.room_id) { Some(room) => room - .client_room .send(Authorize { member_id: info.member_id, credentials: info.credentials.clone(), @@ -56,7 +54,7 @@ fn ws_index( &r.drop_state(), WsSession::new( info.member_id, - room.client_room, + room, state.config.idle_timeout, ), ), @@ -75,14 +73,14 @@ fn ws_index( /// Context for [`App`] which holds all the necessary dependencies. pub struct Context { /// Repository of all currently existing [`Room`]s in application. - pub rooms: RoomRepository, + pub rooms: RoomsRepository, /// Settings of application. pub config: Rpc, } /// Starts HTTP server for handling WebSocket connections of Client API. -pub fn run(rooms: RoomRepository, config: Conf) { +pub fn run(rooms: RoomsRepository, config: Conf) { let server_addr = config.server.get_bind_addr(); server::new(move || { @@ -121,27 +119,19 @@ mod test { use crate::api::{control::RoomRequest, room_repo::ControlRoom}; /// Creates [`RoomsRepository`] for tests filled with a single [`Room`]. - fn room(conf: Rpc) -> RoomRepository { - let members = hashmap! { - 1 => Member{id: 1, credentials: "caller_credentials".into()}, - 2 => Member{id: 2, credentials: "responder_credentials".into()}, - }; - let (id, room_spec) = - match crate::api::control::load_from_file("room_spec.yml").unwrap() - { - RoomRequest::Room { id, spec } => (id, spec), - }; - let client_room = Arbiter::start(move |_| { - Room::new(id, members, create_peers(1, 2), conf.reconnect_timeout) - }); - let room = ControlRoom { - client_room, - spec: room_spec, - }; - let rooms = hashmap! { - 1 => room + fn room(conf: Rpc) -> RoomsRepository { + let room_spec = crate::api::control::load_from_file("room_spec.yml").unwrap(); + + println!("{:#?}", room_spec); + + let client_room = Room::new(room_spec, config.rpc.reconnect_timeout); + let room_id = client_room.get_id(); + let client_room = Arbiter::start(move |_| client_room); + let room_hash_map = hashmap! { + room_id => client_room, }; - RoomRepository::new(rooms) + + RoomsRepository::new(room_hash_map) } /// Creates test WebSocket server of Client API which can handle requests. diff --git a/src/api/control/member.rs b/src/api/control/member.rs index f0cb4f85f..29f202932 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -17,6 +17,8 @@ pub struct Member { /// Credentials to authorize [`Member`] with. pub credentials: String, + + pub spec: MemberSpec, } #[derive(Deserialize, Debug, Clone)] diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index 412a62a62..d0ba1abbb 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -1,7 +1,7 @@ //! Implementation of Control API. -mod element; -mod member; +pub mod element; +pub mod member; pub mod room; diff --git a/src/api/control/room.rs b/src/api/control/room.rs index b141f4417..77a132059 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -5,6 +5,9 @@ use serde::Deserialize; use super::member::MemberRequest; use std::collections::HashMap; +use crate::api::control::MemberId; +use crate::api::control::member::MemberSpec; +use crate::api::control::element::Element; #[derive(Deserialize, Debug, Clone)] /// Spec of [`Room`] diff --git a/src/main.rs b/src/main.rs index dd4c7729e..f00c7b6e0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -17,12 +17,12 @@ use crate::{ client::server, control::Member, control::{load_from_file, RoomRequest}, - room_repo::{ControlRoom, RoomRepository}, }, conf::Conf, media::create_peers, - signalling::Room, + signalling::{Room, room_repo::RoomsRepository}, }; +use hashbrown::HashMap; fn main() { dotenv().ok(); @@ -35,29 +35,19 @@ fn main() { let config = Conf::parse().unwrap(); info!("{:?}", config); - let (id, room_spec) = match load_from_file("room_spec.yml").unwrap() { - RoomRequest::Room { id, spec } => (id, spec), - }; + let room_spec = load_from_file("room_spec.yml").unwrap(); println!("{:#?}", room_spec); - let members = hashmap! { - 1 => Member{id: 1, credentials: "caller_credentials".to_owned()}, - 2 => Member{id: 2, credentials: "responder_credentials".to_owned()}, - }; - let peers = create_peers(1, 2); - let client_room = - Room::new(id, members, peers, config.rpc.reconnect_timeout); + let client_room = Room::new(room_spec, config.rpc.reconnect_timeout); + let room_id = client_room.get_id(); let client_room = Arbiter::start(move |_| client_room); - - let control_room = ControlRoom { - client_room, - spec: room_spec, + let room_hash_map = hashmap! { + room_id => client_room, }; - let rooms = hashmap! {id => control_room}; - let room_repo = RoomRepository::new(rooms); + let room_repo = RoomsRepository::new(room_hash_map); - server::run(room_repo.clone(), config); + server::run(room_repo, config); let _ = sys.run(); } diff --git a/src/signalling/mod.rs b/src/signalling/mod.rs index 56a86f041..5adae3080 100644 --- a/src/signalling/mod.rs +++ b/src/signalling/mod.rs @@ -1,5 +1,6 @@ pub mod participants; pub mod peers; pub mod room; +pub mod room_repo; pub use self::room::{Id as RoomId, Room}; diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 3f0294028..d012945f5 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -26,6 +26,8 @@ use crate::{ Room, }, }; +use crate::api::control::element::Element; +use crate::signalling::room::{ConnectPeers, CreatePeer}; /// Participant is [`Member`] with [`RpcConnection`]. [`ParticipantService`] /// stores [`Members`] and associated [`RpcConnection`]s, handles @@ -48,11 +50,14 @@ pub struct ParticipantService { /// If [`RpcConnection`] is lost, [`Room`] waits for connection_timeout /// before dropping it irrevocably in case it gets reestablished. drop_connection_tasks: HashMap, + + control_signalling_members: HashMap, } impl ParticipantService { pub fn new( members: HashMap, + control_signalling_members: HashMap, reconnect_timeout: Duration, ) -> Self { Self { @@ -60,6 +65,7 @@ impl ParticipantService { connections: HashMap::new(), reconnect_timeout, drop_connection_tasks: HashMap::new(), + control_signalling_members, } } @@ -153,6 +159,7 @@ impl ParticipantService { member_id: MemberId, con: Box, ) { + use std::convert::TryFrom; // lookup previous member connection if let Some(mut connection) = self.connections.remove(&member_id) { debug!("Closing old RpcConnection for member {}", member_id); @@ -165,6 +172,33 @@ impl ParticipantService { } ctx.spawn(wrap_future(connection.close())); } else { + let connected_member_pipeline = self.members.get(&member_id).unwrap(); + connected_member_pipeline.spec.pipeline.iter() + .filter_map(|(connected_element_id, connected_element)| match connected_element { + Element::WebRtcPlayEndpoint { spec } => Some(spec), + _ => None + }) + .for_each(|connected_play_endpoint| { + match self.control_signalling_members.get(&connected_play_endpoint.src.member_id) { + // connected_play_endpoint, connected_signalling_id, responder_signalling_id, connected_member_pipeline + + // AVAILABLE: connected_member_pipeline, connected_signalling_id, connected_signalling_id + // NEED: responder_pipeline + // responder_pipeline = self.members.get(&responder_signalling_id).unwrap() + + + + Some(responder_signalling_id) => { + ctx.notify(CreatePeer { + first_member_pipeline: self.members.get(&member_id).unwrap().spec.pipeline.clone(), + second_member_pipeline: self.members.get(&responder_signalling_id).unwrap().spec.pipeline.clone(), + first_signalling_id: member_id, + second_signallind_id: *responder_signalling_id, + }); + }, + None => () + }; + }); self.connections.insert(member_id, con); } } diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 01dfcf63d..01bfc6036 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -8,7 +8,7 @@ use actix::{ use failure::Fail; use futures::future; use hashbrown::HashMap; -use medea_client_api_proto::{Command, Event, IceCandidate}; +use medea_client_api_proto::{Command, Event, IceCandidate, MediaType, AudioSettings, VideoSettings}; use std::time::Duration; @@ -18,7 +18,7 @@ use crate::{ AuthorizationError, Authorize, CommandMessage, RpcConnectionClosed, RpcConnectionEstablished, }, - control::{Member, MemberId}, + control::{Member, MemberId, member::MemberRequest}, }, log::prelude::*, media::{ @@ -27,6 +27,13 @@ use crate::{ }, signalling::{participants::ParticipantService, peers::PeerRepository}, }; +use crate::api::control::member::MemberSpec; +use crate::api::control::room::RoomSpec; +use crate::api::control::RoomRequest; +use crate::signalling::RoomId; +use crate::api::control::element::Element; +use crate::media::MediaTrack; +use std::sync::Arc; /// ID of [`Room`]. pub type Id = u64; @@ -65,23 +72,71 @@ pub struct Room { /// [`Peer`]s of [`Member`]s in this [`Room`]. peers: PeerRepository, + + spec: RoomSpec, + + // TODO: rename +// control_signalling_members: HashMap, +// sdf: HashMap>, } impl Room { /// Create new instance of [`Room`]. pub fn new( - id: Id, - members: HashMap, - peers: HashMap, +// id: Id, +// members: HashMap, +// peers: HashMap, + spec: RoomRequest, reconnect_timeout: Duration, ) -> Self { + let (id, spec) = match spec { + RoomRequest::Room { id, spec } => (id, spec), + }; + // TODO: Rewrite it only with iterator + let mut members = HashMap::new(); + let mut control_signalling_members = HashMap::new(); // TODO: rename + spec.pipeline.iter() + .enumerate() + .for_each(|(i, (control_id, value))| { + let id = i as u64; + if let MemberRequest::Member { spec } = value { + let member = Member { + id, + spec: spec.clone(), + credentials: format!("{}-credentials", i), + }; + control_signalling_members.insert(control_id.clone(), id); + members.insert(id, member); + } + }); + debug!("Created room with {:?} users.", members); + +// let mut room_spec = HashMap::new(); +// spec.pipeline.iter() +// .for_each(|(member_id, spec)| { +// let spec = match spec { +// MemberRequest::Member { spec } => spec.pipeline +// }; +//// let +//// spec.pipeline +// room_spec.insert(member_id.clone(), spec); +// }); + + + Self { id, - peers: PeerRepository::from(peers), - participants: ParticipantService::new(members, reconnect_timeout), + peers: PeerRepository::from(HashMap::new()), + participants: ParticipantService::new(members, control_signalling_members, reconnect_timeout), + spec, +// control_signalling_members } } + pub fn get_id(&self) -> RoomId { + self.id + } + /// Sends [`Event::PeerCreated`] to one of specified [`Peer`]s based on /// which of them has any outbound tracks. That [`Peer`] state will be /// changed to [`WaitLocalSdp`] state. Both provided peers must be in @@ -285,6 +340,54 @@ impl Handler for Room { } } + +//pub struct CreatePeer(MemberId, MemberSpec); + +use std::collections::HashMap as StdHashMap; + +#[derive(Debug, Message)] +#[rtype(result = "Result<(), ()>")] +pub struct CreatePeer { + pub first_member_pipeline: StdHashMap, + pub second_member_pipeline: StdHashMap, + pub first_signalling_id: MemberId, + pub second_signallind_id: MemberId, +} + +impl Handler for Room { + type Result = Result<(), ()>; + + fn handle( + &mut self, + msg: CreatePeer, + ctx: &mut Self::Context, + ) -> Self::Result { + debug!("Created peer member {} with member {}", msg.first_signalling_id, msg.second_signallind_id); + + + // TODO: Make dynamic + let first_peer_id = 1; + let second_peer_id = 2; + + let mut first_peer = Peer::new(first_peer_id, msg.first_signalling_id, second_peer_id, msg.second_signallind_id); + let mut second_peer = Peer::new(second_peer_id, msg.second_signallind_id, first_peer_id, msg.first_signalling_id); + + let track_audio = + Arc::new(MediaTrack::new(1, MediaType::Audio(AudioSettings {}))); + let track_video = + Arc::new(MediaTrack::new(2, MediaType::Video(VideoSettings {}))); + first_peer.add_sender(track_audio.clone()); + first_peer.add_sender(track_video.clone()); + second_peer.add_receiver(track_audio); + second_peer.add_receiver(track_video); + + self.peers.add_peer(first_peer_id, first_peer); + self.peers.add_peer(second_peer_id, second_peer); + + Ok(()) + } +} + impl Handler for Room { type Result = ActFuture<(), ()>; diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs new file mode 100644 index 000000000..f0df8ead4 --- /dev/null +++ b/src/signalling/room_repo.rs @@ -0,0 +1,31 @@ +//! Repository that stores [`Room`]s addresses. + +use actix::Addr; +use hashbrown::HashMap; + +use std::sync::{Arc, Mutex}; + +use crate::signalling::{Room, RoomId}; + +/// Repository that stores [`Room`]s addresses. +#[derive(Clone, Default)] +pub struct RoomsRepository { + // TODO: Use crossbeam's concurrent hashmap when its done. + // [Tracking](https://github.com/crossbeam-rs/rfcs/issues/32). + rooms: Arc>>>, +} + +impl RoomsRepository { + /// Creates new [`Room`]s repository with passed-in [`Room`]s. + pub fn new(rooms: HashMap>) -> Self { + Self { + rooms: Arc::new(Mutex::new(rooms)), + } + } + + /// Returns [`Room`] by its ID. + pub fn get(&self, id: RoomId) -> Option> { + let rooms = self.rooms.lock().unwrap(); + rooms.get(&id).cloned() + } +} From 535f28b989d645fcc4993e16eb2143e021b5469c Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 22 May 2019 18:15:22 +0300 Subject: [PATCH 013/735] Add dynamic peer creation --- jason/e2e-demo/js/index.js | 5 ++ room_spec_with_3_members.yml | 57 ++++++++++++++++ src/api/client/server.rs | 5 +- src/api/control/member.rs | 2 + src/api/control/room.rs | 6 +- src/main.rs | 2 +- src/media/peer.rs | 1 + src/signalling/participants.rs | 120 +++++++++++++++++++++++++++------ src/signalling/room.rs | 97 +++++++++++++------------- 9 files changed, 223 insertions(+), 72 deletions(-) create mode 100644 room_spec_with_3_members.yml diff --git a/jason/e2e-demo/js/index.js b/jason/e2e-demo/js/index.js index fa9f28d33..146b7704d 100644 --- a/jason/e2e-demo/js/index.js +++ b/jason/e2e-demo/js/index.js @@ -6,6 +6,11 @@ async function f() { // let caller_room_handle = await caller.join_room("ws://localhost:8080/ws/1/1/caller_credentials"); caller.join_room("ws://localhost:8080/ws/1/0/0-credentials"); caller.join_room("ws://localhost:8080/ws/1/1/1-credentials"); + + // Use this for testing with 3 members. + // caller.join_room("ws://localhost:8080/ws/1/2/2-credentials"); + + // caller.join_room("ws://localhost:8080/ws/1/2/responder_credentials"); // let responder = new rust.Jason(); diff --git a/room_spec_with_3_members.yml b/room_spec_with_3_members.yml new file mode 100644 index 000000000..396962e2c --- /dev/null +++ b/room_spec_with_3_members.yml @@ -0,0 +1,57 @@ +kind: Room +id: 1 +spec: + pipeline: + # Here we're defining a member who initiates video call. + caller: + kind: Member + spec: + pipeline: + # Media element which is able to receive media data from client via WebRTC. + publish: + kind: WebRtcPublishEndpoint + spec: + # Actually, it receives not media data, but ICE candidates only. + p2p: Always + # Media element which is able to play media data for client via WebRTC. + play: + kind: WebRtcPlayEndpoint + spec: + src: "local://video-call-2/responder/publish" + play2: + kind: WebRtcPlayEndpoint + spec: + src: "local://video-call-2/responder2/publish" + responder: + kind: Member + spec: + pipeline: + publish: + kind: WebRtcPublishEndpoint + spec: + p2p: Always + play1: + kind: WebRtcPlayEndpoint + spec: + src: "local://video-call-2/caller/publish" + play2: + kind: WebRtcPlayEndpoint + spec: + src: "local://video-call-2/responder2/publish" + + responder2: + kind: Member + spec: + pipeline: + publish: + kind: WebRtcPublishEndpoint + spec: + p2p: Always + play1: + kind: WebRtcPlayEndpoint + spec: + src: "local://video-call-2/caller/publish" + play2: + kind: WebRtcPlayEndpoint + spec: + src: "local://video-call-2/responder/publish" diff --git a/src/api/client/server.rs b/src/api/client/server.rs index ec387d28e..032112b73 100644 --- a/src/api/client/server.rs +++ b/src/api/client/server.rs @@ -17,7 +17,7 @@ use crate::{ }, conf::{Conf, Rpc}, log::prelude::*, - signalling::{RoomId, room_repo::RoomsRepository}, + signalling::{room_repo::RoomsRepository, RoomId}, }; /// Parameters of new WebSocket connection creation HTTP request. @@ -120,7 +120,8 @@ mod test { /// Creates [`RoomsRepository`] for tests filled with a single [`Room`]. fn room(conf: Rpc) -> RoomsRepository { - let room_spec = crate::api::control::load_from_file("room_spec.yml").unwrap(); + let room_spec = + crate::api::control::load_from_file("room_spec.yml").unwrap(); println!("{:#?}", room_spec); diff --git a/src/api/control/member.rs b/src/api/control/member.rs index 29f202932..76fb1775a 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -19,6 +19,8 @@ pub struct Member { pub credentials: String, pub spec: MemberSpec, + + pub control_id: String, } #[derive(Deserialize, Debug, Clone)] diff --git a/src/api/control/room.rs b/src/api/control/room.rs index 77a132059..57015e2c2 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -4,10 +4,10 @@ use serde::Deserialize; use super::member::MemberRequest; -use std::collections::HashMap; -use crate::api::control::MemberId; -use crate::api::control::member::MemberSpec; use crate::api::control::element::Element; +use crate::api::control::member::MemberSpec; +use crate::api::control::MemberId; +use std::collections::HashMap; #[derive(Deserialize, Debug, Clone)] /// Spec of [`Room`] diff --git a/src/main.rs b/src/main.rs index f00c7b6e0..da0ce133d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -20,7 +20,7 @@ use crate::{ }, conf::Conf, media::create_peers, - signalling::{Room, room_repo::RoomsRepository}, + signalling::{room_repo::RoomsRepository, Room}, }; use hashbrown::HashMap; diff --git a/src/media/peer.rs b/src/media/peer.rs index cca9b76d4..6d71d683a 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -352,6 +352,7 @@ impl Peer { } } +// TODO: remove it pub fn create_peers( caller: MemberId, responder: MemberId, diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index d012945f5..f3c63d26e 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -12,6 +12,8 @@ use futures::{ use hashbrown::HashMap; use medea_client_api_proto::Event; +use crate::api::control::element::Element; +use crate::signalling::room::{ConnectPeers, CreatePeer}; use crate::{ api::{ client::rpc_connection::{ @@ -26,8 +28,6 @@ use crate::{ Room, }, }; -use crate::api::control::element::Element; -use crate::signalling::room::{ConnectPeers, CreatePeer}; /// Participant is [`Member`] with [`RpcConnection`]. [`ParticipantService`] /// stores [`Members`] and associated [`RpcConnection`]s, handles @@ -52,6 +52,8 @@ pub struct ParticipantService { drop_connection_tasks: HashMap, control_signalling_members: HashMap, + + responder_awaiting_connection: HashMap>, } impl ParticipantService { @@ -66,6 +68,7 @@ impl ParticipantService { reconnect_timeout, drop_connection_tasks: HashMap::new(), control_signalling_members, + responder_awaiting_connection: HashMap::new(), } } @@ -172,33 +175,108 @@ impl ParticipantService { } ctx.spawn(wrap_future(connection.close())); } else { - let connected_member_pipeline = self.members.get(&member_id).unwrap(); - connected_member_pipeline.spec.pipeline.iter() - .filter_map(|(connected_element_id, connected_element)| match connected_element { - Element::WebRtcPlayEndpoint { spec } => Some(spec), - _ => None + // TODO: Think about deletion + debug!("Connected member: {}", member_id); + debug!( + "Current awaiters: {:?}", + self.responder_awaiting_connection + ); + + // TODO: Very need serious refactor + let connected_member_pipeline = + self.members.get(&member_id).unwrap().clone(); + connected_member_pipeline + .spec + .pipeline + .iter() + .filter_map(|(connected_element_id, connected_element)| { + match connected_element { + Element::WebRtcPlayEndpoint { spec } => Some(spec), + _ => None, + } }) + .cloned() .for_each(|connected_play_endpoint| { - match self.control_signalling_members.get(&connected_play_endpoint.src.member_id) { - // connected_play_endpoint, connected_signalling_id, responder_signalling_id, connected_member_pipeline - - // AVAILABLE: connected_member_pipeline, connected_signalling_id, connected_signalling_id - // NEED: responder_pipeline - // responder_pipeline = self.members.get(&responder_signalling_id).unwrap() - + let responder_signalling_id = self + .control_signalling_members + .get(&connected_play_endpoint.src.member_id) + .unwrap(); + let is_responder_connected = + self.connections.get(responder_signalling_id).is_some(); + let this_name = self + .members + .get(&member_id) + .unwrap() + .control_id + .clone(); - Some(responder_signalling_id) => { + if let Some(awaiters) = + self.responder_awaiting_connection.get(&this_name) + { + awaiters.iter().for_each(|a| { ctx.notify(CreatePeer { - first_member_pipeline: self.members.get(&member_id).unwrap().spec.pipeline.clone(), - second_member_pipeline: self.members.get(&responder_signalling_id).unwrap().spec.pipeline.clone(), - first_signalling_id: member_id, - second_signallind_id: *responder_signalling_id, + first_member_pipeline: self + .members + .get(a) + .unwrap() + .spec + .pipeline + .clone(), + second_member_pipeline: self + .members + .get(&member_id) + .unwrap() + .spec + .pipeline + .clone(), + second_signalling_id: member_id, + first_signalling_id: *a, }); - }, - None => () + }); + self.responder_awaiting_connection.remove(&this_name); }; + + if is_responder_connected { + ctx.notify(CreatePeer { + first_member_pipeline: self + .members + .get(&member_id) + .unwrap() + .spec + .pipeline + .clone(), + second_member_pipeline: self + .members + .get(&responder_signalling_id) + .unwrap() + .spec + .pipeline + .clone(), + first_signalling_id: member_id, + second_signalling_id: *responder_signalling_id, + }); + } else { + match self + .responder_awaiting_connection + .get_mut(&connected_play_endpoint.src.member_id) + { + Some(awaiter) => { + awaiter.push(member_id); + } + None => { + self.responder_awaiting_connection.insert( + connected_play_endpoint + .src + .member_id + .clone(), + vec![member_id], + ); + } + } + } }); + self.connections.insert(member_id, con); } } diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 01bfc6036..cdbe1c8c4 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -8,17 +8,25 @@ use actix::{ use failure::Fail; use futures::future; use hashbrown::HashMap; -use medea_client_api_proto::{Command, Event, IceCandidate, MediaType, AudioSettings, VideoSettings}; +use medea_client_api_proto::{ + AudioSettings, Command, Event, IceCandidate, MediaType, VideoSettings, +}; use std::time::Duration; +use crate::api::control::element::Element; +use crate::api::control::member::MemberSpec; +use crate::api::control::room::RoomSpec; +use crate::api::control::RoomRequest; +use crate::media::MediaTrack; +use crate::signalling::RoomId; use crate::{ api::{ client::rpc_connection::{ AuthorizationError, Authorize, CommandMessage, RpcConnectionClosed, RpcConnectionEstablished, }, - control::{Member, MemberId, member::MemberRequest}, + control::{member::MemberRequest, Member, MemberId}, }, log::prelude::*, media::{ @@ -27,12 +35,6 @@ use crate::{ }, signalling::{participants::ParticipantService, peers::PeerRepository}, }; -use crate::api::control::member::MemberSpec; -use crate::api::control::room::RoomSpec; -use crate::api::control::RoomRequest; -use crate::signalling::RoomId; -use crate::api::control::element::Element; -use crate::media::MediaTrack; use std::sync::Arc; /// ID of [`Room`]. @@ -73,19 +75,18 @@ pub struct Room { /// [`Peer`]s of [`Member`]s in this [`Room`]. peers: PeerRepository, + // TODO: Add docs spec: RoomSpec, - // TODO: rename -// control_signalling_members: HashMap, -// sdf: HashMap>, + peers_count: u64, } impl Room { /// Create new instance of [`Room`]. pub fn new( -// id: Id, -// members: HashMap, -// peers: HashMap, + // id: Id, + // members: HashMap, + // peers: HashMap, spec: RoomRequest, reconnect_timeout: Duration, ) -> Self { @@ -95,41 +96,34 @@ impl Room { // TODO: Rewrite it only with iterator let mut members = HashMap::new(); let mut control_signalling_members = HashMap::new(); // TODO: rename - spec.pipeline.iter() - .enumerate() - .for_each(|(i, (control_id, value))| { + spec.pipeline.iter().enumerate().for_each( + |(i, (control_id, value))| { let id = i as u64; if let MemberRequest::Member { spec } = value { let member = Member { id, spec: spec.clone(), credentials: format!("{}-credentials", i), + control_id: control_id.clone(), }; control_signalling_members.insert(control_id.clone(), id); members.insert(id, member); } - }); + }, + ); debug!("Created room with {:?} users.", members); -// let mut room_spec = HashMap::new(); -// spec.pipeline.iter() -// .for_each(|(member_id, spec)| { -// let spec = match spec { -// MemberRequest::Member { spec } => spec.pipeline -// }; -//// let -//// spec.pipeline -// room_spec.insert(member_id.clone(), spec); -// }); - - - Self { id, peers: PeerRepository::from(HashMap::new()), - participants: ParticipantService::new(members, control_signalling_members, reconnect_timeout), + participants: ParticipantService::new( + members, + control_signalling_members, + reconnect_timeout, + ), spec, -// control_signalling_members + // control_signalling_members + peers_count: 0, } } @@ -340,9 +334,6 @@ impl Handler for Room { } } - -//pub struct CreatePeer(MemberId, MemberSpec); - use std::collections::HashMap as StdHashMap; #[derive(Debug, Message)] @@ -351,7 +342,7 @@ pub struct CreatePeer { pub first_member_pipeline: StdHashMap, pub second_member_pipeline: StdHashMap, pub first_signalling_id: MemberId, - pub second_signallind_id: MemberId, + pub second_signalling_id: MemberId, } impl Handler for Room { @@ -362,15 +353,30 @@ impl Handler for Room { msg: CreatePeer, ctx: &mut Self::Context, ) -> Self::Result { - debug!("Created peer member {} with member {}", msg.first_signalling_id, msg.second_signallind_id); - - - // TODO: Make dynamic - let first_peer_id = 1; - let second_peer_id = 2; + // TODO: Think about usefulness + debug!( + "Created peer member {} with member {}", + msg.first_signalling_id, msg.second_signalling_id + ); - let mut first_peer = Peer::new(first_peer_id, msg.first_signalling_id, second_peer_id, msg.second_signallind_id); - let mut second_peer = Peer::new(second_peer_id, msg.second_signallind_id, first_peer_id, msg.first_signalling_id); + // TODO: Maybe need another implementation of dynamic peer ids? + let first_peer_id = self.peers_count; + self.peers_count += 1; + let second_peer_id = self.peers_count; + self.peers_count += 1; + + let mut first_peer = Peer::new( + first_peer_id, + msg.first_signalling_id, + second_peer_id, + msg.second_signalling_id, + ); + let mut second_peer = Peer::new( + second_peer_id, + msg.second_signalling_id, + first_peer_id, + msg.first_signalling_id, + ); let track_audio = Arc::new(MediaTrack::new(1, MediaType::Audio(AudioSettings {}))); @@ -527,6 +533,7 @@ mod test { use super::*; + // TODO: Fix this fn start_room() -> Addr { let members = hashmap! { 1 => Member{id: 1, credentials: "caller_credentials".to_owned()}, From 23ee595cfbc3d8e2cf3afd5390d2f287ae2e16e2 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 23 May 2019 14:30:48 +0300 Subject: [PATCH 014/735] Total rewrite spec parsing --- src/api/client/server.rs | 3 +- src/api/control/element.rs | 35 +++++++++--- src/api/control/member.rs | 43 ++++++++++----- src/api/control/mod.rs | 47 +++++++++++----- src/api/control/pipeline.rs | 12 +++++ src/api/control/room.rs | 39 ++++++++++---- src/api/mod.rs | 1 - src/api/room_repo.rs | 38 ------------- src/main.rs | 6 +-- src/signalling/participants.rs | 97 ++-------------------------------- src/signalling/room.rs | 38 ++++++------- 11 files changed, 159 insertions(+), 200 deletions(-) create mode 100644 src/api/control/pipeline.rs delete mode 100644 src/api/room_repo.rs diff --git a/src/api/client/server.rs b/src/api/client/server.rs index 032112b73..f4b879809 100644 --- a/src/api/client/server.rs +++ b/src/api/client/server.rs @@ -116,13 +116,14 @@ mod test { }; use super::*; - use crate::api::{control::RoomRequest, room_repo::ControlRoom}; + use crate::api::control::RoomRequest; /// Creates [`RoomsRepository`] for tests filled with a single [`Room`]. fn room(conf: Rpc) -> RoomsRepository { let room_spec = crate::api::control::load_from_file("room_spec.yml").unwrap(); + // TODO: remove this println!("{:#?}", room_spec); let client_room = Room::new(room_spec, config.rpc.reconnect_timeout); diff --git a/src/api/control/element.rs b/src/api/control/element.rs index 29936adb4..cc0afdc50 100644 --- a/src/api/control/element.rs +++ b/src/api/control/element.rs @@ -1,16 +1,33 @@ -//! Element definitions and implementations. +use super::{Entity, TryFromEntityError}; use serde::{ de::{self, Deserializer, Error, Visitor}, Deserialize, }; -use std::fmt; +use std::{ + convert::TryFrom, + fmt, +}; -#[derive(Deserialize, Debug, Clone)] -#[serde(tag = "kind")] +#[derive(Debug)] pub enum Element { - WebRtcPublishEndpoint { spec: WebRtcPublishEndpoint }, - WebRtcPlayEndpoint { spec: WebRtcPlayEndpoint }, + WebRtcPublishEndpoint(WebRtcPublishEndpoint), + WebRtcPlayEndpoint(WebRtcPlayEndpoint), +} +impl TryFrom for Element { + type Error = TryFromEntityError; + + fn try_from(from: Entity) -> Result { + match from { + Entity::WebRtcPlayEndpoint { spec } => { + Ok(Element::WebRtcPlayEndpoint(spec)) + } + Entity::WebRtcPublishEndpoint { spec } => { + Ok(Element::WebRtcPublishEndpoint(spec)) + } + _ => Err(TryFromEntityError::NotElement), + } + } } #[derive(Deserialize, Debug, Clone)] @@ -33,12 +50,18 @@ pub struct WebRtcPlayEndpoint { } #[derive(Debug, Clone)] +/// Special uri with pattern "local://{room_id}/{member_id}/{pipeline_id} pub struct LocalUri { + /// ID of [`Room`] + // TODO: Why this field never used??? pub room_id: String, + /// ID of [`Member`] pub member_id: String, + /// Control ID of [`Element`] pub pipeline_id: String, } +// TODO: Write unit tests? impl<'de> Deserialize<'de> for LocalUri { fn deserialize(deserializer: D) -> Result where diff --git a/src/api/control/member.rs b/src/api/control/member.rs index 76fb1775a..42e11220d 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -1,12 +1,18 @@ //! Member definitions and implementations. use serde::Deserialize; +use std::{ + collections::HashMap, + convert::TryFrom, +}; + +use super::{ + element::Element, + pipeline::Pipeline, + Entity, + TryFromEntityError, +}; -use super::element::Element; - -use std::collections::HashMap; - -/// ID of [`Member`]. pub type Id = u64; /// Media server user with its ID and credentials. @@ -23,15 +29,24 @@ pub struct Member { pub control_id: String, } -#[derive(Deserialize, Debug, Clone)] -#[serde(tag = "kind")] -/// Entity for member requests. -pub enum MemberRequest { - Member { spec: MemberSpec }, +#[derive(Clone, Debug)] +pub struct MemberSpec(pub Pipeline); +impl MemberSpec { + pub fn get_element( + &self, + id: &str, + ) -> Option> { + Some(Element::try_from(self.0.pipeline.get(id).cloned()?)) + } } -#[derive(Deserialize, Debug, Clone)] -/// Spec of member in [`Room`] pipeline. -pub struct MemberSpec { - pub pipeline: HashMap, +impl TryFrom for MemberSpec { + type Error = TryFromEntityError; + + fn try_from(from: Entity) -> Result { + match from { + Entity::Member { spec } => Ok(MemberSpec(spec)), + _ => Err(TryFromEntityError::NotMember), + } + } } diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index d0ba1abbb..ce7a64502 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -2,32 +2,53 @@ pub mod element; pub mod member; - pub mod room; +mod pipeline; + use failure::Error; use serde::Deserialize; -use std::{fs::File, io::Read as _}; - -use crate::signalling::RoomId; - -use self::room::RoomSpec; +use std::{ + fs::File, + io::Read as _, + convert::TryFrom as _, +}; +use failure::Fail; + +use self::{ + element::{WebRtcPlayEndpoint, WebRtcPublishEndpoint}, + pipeline::Pipeline, + room::RoomSpec, +}; pub use self::member::{Id as MemberId, Member}; -#[derive(Deserialize, Debug, Clone)] +#[derive(Debug, Fail)] +pub enum TryFromEntityError { + #[fail(display = "This entity is not Element")] + NotElement, + #[fail(display = "This entity is not Room")] + NotRoom, + #[fail(display = "This entity is not Member")] + NotMember, +} + +#[derive(Clone, Deserialize, Debug)] #[serde(tag = "kind")] -/// Entity for creating new Room. -pub enum RoomRequest { - Room { id: RoomId, spec: RoomSpec }, +pub enum Entity { + Room { id: u64, spec: Pipeline }, + Member { spec: Pipeline }, + WebRtcPublishEndpoint { spec: WebRtcPublishEndpoint }, + WebRtcPlayEndpoint { spec: WebRtcPlayEndpoint }, } /// Load [`RoomRequest`] from file with YAML format. -pub fn load_from_file(path: &str) -> Result { +pub fn load_from_file(path: &str) -> Result { let mut file = File::open(path)?; let mut buf = String::new(); file.read_to_string(&mut buf)?; - let parsed: RoomRequest = serde_yaml::from_str(&buf)?; + let parsed: Entity = serde_yaml::from_str(&buf)?; + let room = RoomSpec::try_from(parsed)?; - Ok(parsed) + Ok(room) } diff --git a/src/api/control/pipeline.rs b/src/api/control/pipeline.rs new file mode 100644 index 000000000..aecdeae84 --- /dev/null +++ b/src/api/control/pipeline.rs @@ -0,0 +1,12 @@ +use crate::api::control::Entity; + +use serde::Deserialize; +use std::{ + collections::HashMap, + convert::TryFrom as _, +}; + +#[derive(Clone, Deserialize, Debug)] +pub struct Pipeline { + pub pipeline: HashMap, +} diff --git a/src/api/control/room.rs b/src/api/control/room.rs index 57015e2c2..002dc530c 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -1,16 +1,37 @@ //! Room definitions and implementations. -use serde::Deserialize; +use std::convert::TryFrom; -use super::member::MemberRequest; +use super::{ + Entity, + TryFromEntityError, + member::MemberSpec, + pipeline::Pipeline, +}; -use crate::api::control::element::Element; -use crate::api::control::member::MemberSpec; -use crate::api::control::MemberId; -use std::collections::HashMap; +use crate::signalling::RoomId; -#[derive(Deserialize, Debug, Clone)] -/// Spec of [`Room`] +#[derive(Clone, Debug)] pub struct RoomSpec { - pub pipeline: HashMap, + pub id: RoomId, + pub spec: Pipeline, +} +impl RoomSpec { + pub fn get_member( + &self, + id: &str, + ) -> Option> { + Some(MemberSpec::try_from(self.spec.pipeline.get(id).cloned()?)) + } +} + +impl TryFrom for RoomSpec { + type Error = TryFromEntityError; + + fn try_from(from: Entity) -> Result { + match from { + Entity::Room { id, spec } => Ok(RoomSpec { id, spec }), + _ => Err(TryFromEntityError::NotRoom), + } + } } diff --git a/src/api/mod.rs b/src/api/mod.rs index ef98e501f..1c66e73e5 100644 --- a/src/api/mod.rs +++ b/src/api/mod.rs @@ -2,4 +2,3 @@ pub mod client; pub mod control; -pub mod room_repo; diff --git a/src/api/room_repo.rs b/src/api/room_repo.rs deleted file mode 100644 index 6d7201f2a..000000000 --- a/src/api/room_repo.rs +++ /dev/null @@ -1,38 +0,0 @@ -use actix::Addr; -use hashbrown::HashMap; -use std::sync::{Arc, Mutex}; - -use crate::signalling::{Room, RoomId}; - -use super::control::room::RoomSpec; - -#[derive(Clone)] -pub struct ControlRoom { - pub client_room: Addr, - pub spec: RoomSpec, -} - -#[derive(Clone)] -pub struct RoomRepository { - // TODO: Use crossbeam's concurrent hashmap when its done. - // [Tracking](https://github.com/crossbeam-rs/rfcs/issues/32). - rooms: Arc>>, -} - -impl RoomRepository { - pub fn new(rooms: HashMap) -> Self { - Self { - rooms: Arc::new(Mutex::new(rooms)), - } - } - - pub fn get(&self, id: RoomId) -> Option { - let rooms = self.rooms.lock().unwrap(); - rooms.get(&id).cloned() - } - - pub fn add(&mut self, room_id: RoomId, room: ControlRoom) { - let mut rooms = self.rooms.lock().unwrap(); - rooms.insert(room_id, room); - } -} diff --git a/src/main.rs b/src/main.rs index da0ce133d..cada59e22 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,11 +13,7 @@ use dotenv::dotenv; use log::prelude::*; use crate::{ - api::{ - client::server, - control::Member, - control::{load_from_file, RoomRequest}, - }, + api::{client::server, control::load_from_file, control::Member}, conf::Conf, media::create_peers, signalling::{room_repo::RoomsRepository, Room}, diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index f3c63d26e..2b994736d 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -51,8 +51,10 @@ pub struct ParticipantService { /// before dropping it irrevocably in case it gets reestablished. drop_connection_tasks: HashMap, + // TODO: Need rename control_signalling_members: HashMap, + // TODO: Need rename responder_awaiting_connection: HashMap>, } @@ -182,100 +184,7 @@ impl ParticipantService { self.responder_awaiting_connection ); - // TODO: Very need serious refactor - let connected_member_pipeline = - self.members.get(&member_id).unwrap().clone(); - connected_member_pipeline - .spec - .pipeline - .iter() - .filter_map(|(connected_element_id, connected_element)| { - match connected_element { - Element::WebRtcPlayEndpoint { spec } => Some(spec), - _ => None, - } - }) - .cloned() - .for_each(|connected_play_endpoint| { - let responder_signalling_id = self - .control_signalling_members - .get(&connected_play_endpoint.src.member_id) - .unwrap(); - let is_responder_connected = - self.connections.get(responder_signalling_id).is_some(); - - let this_name = self - .members - .get(&member_id) - .unwrap() - .control_id - .clone(); - - if let Some(awaiters) = - self.responder_awaiting_connection.get(&this_name) - { - awaiters.iter().for_each(|a| { - ctx.notify(CreatePeer { - first_member_pipeline: self - .members - .get(a) - .unwrap() - .spec - .pipeline - .clone(), - second_member_pipeline: self - .members - .get(&member_id) - .unwrap() - .spec - .pipeline - .clone(), - second_signalling_id: member_id, - first_signalling_id: *a, - }); - }); - self.responder_awaiting_connection.remove(&this_name); - }; - - if is_responder_connected { - ctx.notify(CreatePeer { - first_member_pipeline: self - .members - .get(&member_id) - .unwrap() - .spec - .pipeline - .clone(), - second_member_pipeline: self - .members - .get(&responder_signalling_id) - .unwrap() - .spec - .pipeline - .clone(), - first_signalling_id: member_id, - second_signalling_id: *responder_signalling_id, - }); - } else { - match self - .responder_awaiting_connection - .get_mut(&connected_play_endpoint.src.member_id) - { - Some(awaiter) => { - awaiter.push(member_id); - } - None => { - self.responder_awaiting_connection.insert( - connected_play_endpoint - .src - .member_id - .clone(), - vec![member_id], - ); - } - } - } - }); + // TODO: Rewrite Peer connection self.connections.insert(member_id, con); } diff --git a/src/signalling/room.rs b/src/signalling/room.rs index cdbe1c8c4..92f7e12b1 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -17,7 +17,6 @@ use std::time::Duration; use crate::api::control::element::Element; use crate::api::control::member::MemberSpec; use crate::api::control::room::RoomSpec; -use crate::api::control::RoomRequest; use crate::media::MediaTrack; use crate::signalling::RoomId; use crate::{ @@ -26,7 +25,7 @@ use crate::{ AuthorizationError, Authorize, CommandMessage, RpcConnectionClosed, RpcConnectionEstablished, }, - control::{member::MemberRequest, Member, MemberId}, + control::{Member, MemberId}, }, log::prelude::*, media::{ @@ -35,6 +34,7 @@ use crate::{ }, signalling::{participants::ParticipantService, peers::PeerRepository}, }; +use std::convert::TryFrom; use std::sync::Arc; /// ID of [`Room`]. @@ -87,41 +87,38 @@ impl Room { // id: Id, // members: HashMap, // peers: HashMap, - spec: RoomRequest, + room: RoomSpec, reconnect_timeout: Duration, ) -> Self { - let (id, spec) = match spec { - RoomRequest::Room { id, spec } => (id, spec), - }; // TODO: Rewrite it only with iterator let mut members = HashMap::new(); let mut control_signalling_members = HashMap::new(); // TODO: rename - spec.pipeline.iter().enumerate().for_each( + room.spec.pipeline.iter().enumerate().for_each( |(i, (control_id, value))| { let id = i as u64; - if let MemberRequest::Member { spec } = value { - let member = Member { - id, - spec: spec.clone(), - credentials: format!("{}-credentials", i), - control_id: control_id.clone(), - }; - control_signalling_members.insert(control_id.clone(), id); - members.insert(id, member); - } + let member_spec = MemberSpec::try_from(value.clone()).unwrap(); + + control_signalling_members.insert(control_id.clone(), id); + let member = Member { + id, + spec: member_spec, + credentials: format!("{}-credentials", i), + control_id: control_id.clone(), + }; + members.insert(id, member); }, ); debug!("Created room with {:?} users.", members); Self { - id, + id: room.id, peers: PeerRepository::from(HashMap::new()), participants: ParticipantService::new( members, control_signalling_members, reconnect_timeout, ), - spec, + spec: room, // control_signalling_members peers_count: 0, } @@ -371,6 +368,7 @@ impl Handler for Room { second_peer_id, msg.second_signalling_id, ); + let mut second_peer = Peer::new( second_peer_id, msg.second_signalling_id, @@ -390,6 +388,8 @@ impl Handler for Room { self.peers.add_peer(first_peer_id, first_peer); self.peers.add_peer(second_peer_id, second_peer); + println!("Peers: {:#?}", self.peers); + Ok(()) } } From 09fb95a2306296e49fbef83e73e661e3fa9d56ff Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 23 May 2019 15:52:02 +0300 Subject: [PATCH 015/735] Total rewrite peer creation --- src/api/control/element.rs | 5 +- src/api/control/member.rs | 27 ++++++---- src/api/control/mod.rs | 8 +-- src/api/control/pipeline.rs | 5 +- src/api/control/room.rs | 5 +- src/signalling/participants.rs | 53 +++++++++++++++---- src/signalling/room.rs | 93 ++++++++++++++++++++++++---------- 7 files changed, 129 insertions(+), 67 deletions(-) diff --git a/src/api/control/element.rs b/src/api/control/element.rs index cc0afdc50..ae2793821 100644 --- a/src/api/control/element.rs +++ b/src/api/control/element.rs @@ -4,10 +4,7 @@ use serde::{ de::{self, Deserializer, Error, Visitor}, Deserialize, }; -use std::{ - convert::TryFrom, - fmt, -}; +use std::{convert::TryFrom, fmt}; #[derive(Debug)] pub enum Element { diff --git a/src/api/control/member.rs b/src/api/control/member.rs index 42e11220d..706c9bf96 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -1,17 +1,10 @@ //! Member definitions and implementations. use serde::Deserialize; -use std::{ - collections::HashMap, - convert::TryFrom, -}; - -use super::{ - element::Element, - pipeline::Pipeline, - Entity, - TryFromEntityError, -}; +use std::{collections::HashMap, convert::TryFrom}; + +use super::{element::Element, pipeline::Pipeline, Entity, TryFromEntityError}; +use crate::api::control::element::WebRtcPlayEndpoint; pub type Id = u64; @@ -38,6 +31,18 @@ impl MemberSpec { ) -> Option> { Some(Element::try_from(self.0.pipeline.get(id).cloned()?)) } + + pub fn get_play_endpoints(&self) -> Vec { + self.0 + .pipeline + .iter() + .filter_map(|(name, e)| match e { + Entity::WebRtcPlayEndpoint { spec } => Some(spec), + _ => None, + }) + .cloned() + .collect() + } } impl TryFrom for MemberSpec { diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index ce7a64502..456ff5733 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -7,13 +7,9 @@ pub mod room; mod pipeline; use failure::Error; -use serde::Deserialize; -use std::{ - fs::File, - io::Read as _, - convert::TryFrom as _, -}; use failure::Fail; +use serde::Deserialize; +use std::{convert::TryFrom as _, fs::File, io::Read as _}; use self::{ element::{WebRtcPlayEndpoint, WebRtcPublishEndpoint}, diff --git a/src/api/control/pipeline.rs b/src/api/control/pipeline.rs index aecdeae84..08984f795 100644 --- a/src/api/control/pipeline.rs +++ b/src/api/control/pipeline.rs @@ -1,10 +1,7 @@ use crate::api::control::Entity; use serde::Deserialize; -use std::{ - collections::HashMap, - convert::TryFrom as _, -}; +use std::{collections::HashMap, convert::TryFrom as _}; #[derive(Clone, Deserialize, Debug)] pub struct Pipeline { diff --git a/src/api/control/room.rs b/src/api/control/room.rs index 002dc530c..f621b17aa 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -3,10 +3,7 @@ use std::convert::TryFrom; use super::{ - Entity, - TryFromEntityError, - member::MemberSpec, - pipeline::Pipeline, + member::MemberSpec, pipeline::Pipeline, Entity, TryFromEntityError, }; use crate::signalling::RoomId; diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 2b994736d..bf9de6aa5 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -53,9 +53,6 @@ pub struct ParticipantService { // TODO: Need rename control_signalling_members: HashMap, - - // TODO: Need rename - responder_awaiting_connection: HashMap>, } impl ParticipantService { @@ -70,7 +67,6 @@ impl ParticipantService { reconnect_timeout, drop_connection_tasks: HashMap::new(), control_signalling_members, - responder_awaiting_connection: HashMap::new(), } } @@ -177,14 +173,51 @@ impl ParticipantService { } ctx.spawn(wrap_future(connection.close())); } else { - // TODO: Think about deletion debug!("Connected member: {}", member_id); - debug!( - "Current awaiters: {:?}", - self.responder_awaiting_connection - ); - // TODO: Rewrite Peer connection + let connected_member = self.members.get(&member_id).unwrap(); + let connected_member_play_endpoints = + connected_member.spec.get_play_endpoints(); + for connected_member_endpoint in connected_member_play_endpoints { + let responder_member_control_id = + connected_member_endpoint.src.member_id; + let responder_member_signalling_id = match self + .control_signalling_members + .get(&responder_member_control_id) + { + Some(r) => r, + None => { + warn!( + "Member with control id '{}' not found! Probably \ + this is error in spec.", + responder_member_control_id + ); + continue; + } + }; + + let is_responder_connected = self + .connections + .get(&responder_member_signalling_id) + .is_some(); + if is_responder_connected { + ctx.notify(CreatePeer { + caller_signalling_id: *responder_member_signalling_id, + caller_spec: self + .members + .get(&responder_member_signalling_id) + .unwrap() + .spec + .clone(), + responder_signalling_id: connected_member.id, + responder_spec: connected_member.spec.clone(), + caller_control_id: responder_member_control_id, + responder_control_id: connected_member + .control_id + .clone(), + }); + } + } self.connections.insert(member_id, con); } diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 92f7e12b1..c3da9d323 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -335,11 +335,14 @@ use std::collections::HashMap as StdHashMap; #[derive(Debug, Message)] #[rtype(result = "Result<(), ()>")] +// TODO: maybe fewer fields??? pub struct CreatePeer { - pub first_member_pipeline: StdHashMap, - pub second_member_pipeline: StdHashMap, - pub first_signalling_id: MemberId, - pub second_signalling_id: MemberId, + pub caller_signalling_id: MemberId, + pub responder_signalling_id: MemberId, + pub caller_spec: MemberSpec, + pub responder_spec: MemberSpec, + pub caller_control_id: String, + pub responder_control_id: String, } impl Handler for Room { @@ -353,41 +356,75 @@ impl Handler for Room { // TODO: Think about usefulness debug!( "Created peer member {} with member {}", - msg.first_signalling_id, msg.second_signalling_id + msg.caller_signalling_id, msg.responder_signalling_id ); // TODO: Maybe need another implementation of dynamic peer ids? - let first_peer_id = self.peers_count; + let caller_peer_id = self.peers_count; self.peers_count += 1; - let second_peer_id = self.peers_count; + let responder_peer_id = self.peers_count; self.peers_count += 1; - let mut first_peer = Peer::new( - first_peer_id, - msg.first_signalling_id, - second_peer_id, - msg.second_signalling_id, + let mut caller_peer = Peer::new( + caller_peer_id, + msg.caller_signalling_id, + responder_peer_id, + msg.responder_signalling_id, ); - - let mut second_peer = Peer::new( - second_peer_id, - msg.second_signalling_id, - first_peer_id, - msg.first_signalling_id, + let mut responder_peer = Peer::new( + responder_peer_id, + msg.responder_signalling_id, + caller_peer_id, + msg.caller_signalling_id, ); - let track_audio = - Arc::new(MediaTrack::new(1, MediaType::Audio(AudioSettings {}))); - let track_video = - Arc::new(MediaTrack::new(2, MediaType::Video(VideoSettings {}))); - first_peer.add_sender(track_audio.clone()); - first_peer.add_sender(track_video.clone()); - second_peer.add_receiver(track_audio); - second_peer.add_receiver(track_video); + let mut last_track_id = 0; + + // TODO: remove boilerplate + for endpoint in msg.caller_spec.get_play_endpoints().into_iter() { + if endpoint.src.member_id == msg.responder_control_id { + last_track_id += 1; + let track_audio = Arc::new(MediaTrack::new( + last_track_id, + MediaType::Audio(AudioSettings {}), + )); + last_track_id += 1; + let track_video = Arc::new(MediaTrack::new( + last_track_id, + MediaType::Video(VideoSettings {}), + )); + + responder_peer.add_sender(track_audio.clone()); + responder_peer.add_sender(track_video.clone()); + caller_peer.add_receiver(track_audio); + caller_peer.add_receiver(track_video); + } + } + + for endpoint in msg.responder_spec.get_play_endpoints().into_iter() { + if endpoint.src.member_id == msg.caller_control_id { + last_track_id += 1; + let track_audio = Arc::new(MediaTrack::new( + last_track_id, + MediaType::Audio(AudioSettings {}), + )); + last_track_id += 1; + let track_video = Arc::new(MediaTrack::new( + last_track_id, + MediaType::Video(VideoSettings {}), + )); + + caller_peer.add_sender(track_audio.clone()); + caller_peer.add_sender(track_video.clone()); + responder_peer.add_receiver(track_audio); + responder_peer.add_receiver(track_video); + } + } - self.peers.add_peer(first_peer_id, first_peer); - self.peers.add_peer(second_peer_id, second_peer); + self.peers.add_peer(caller_peer_id, caller_peer); + self.peers.add_peer(responder_peer_id, responder_peer); + // TODO: remove this println!("Peers: {:#?}", self.peers); Ok(()) From 97279ba39d7b44405cda449d1c3c950707424f86 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 23 May 2019 16:36:33 +0300 Subject: [PATCH 016/735] Fix cargo warnings --- src/api/control/member.rs | 5 ++--- src/api/control/pipeline.rs | 2 +- src/main.rs | 4 +--- src/signalling/participants.rs | 5 +---- src/signalling/room.rs | 5 +---- 5 files changed, 6 insertions(+), 15 deletions(-) diff --git a/src/api/control/member.rs b/src/api/control/member.rs index 706c9bf96..42b8b28ad 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -1,7 +1,6 @@ //! Member definitions and implementations. -use serde::Deserialize; -use std::{collections::HashMap, convert::TryFrom}; +use std::convert::TryFrom; use super::{element::Element, pipeline::Pipeline, Entity, TryFromEntityError}; use crate::api::control::element::WebRtcPlayEndpoint; @@ -36,7 +35,7 @@ impl MemberSpec { self.0 .pipeline .iter() - .filter_map(|(name, e)| match e { + .filter_map(|(_name, e)| match e { Entity::WebRtcPlayEndpoint { spec } => Some(spec), _ => None, }) diff --git a/src/api/control/pipeline.rs b/src/api/control/pipeline.rs index 08984f795..98d69127c 100644 --- a/src/api/control/pipeline.rs +++ b/src/api/control/pipeline.rs @@ -1,7 +1,7 @@ use crate::api::control::Entity; use serde::Deserialize; -use std::{collections::HashMap, convert::TryFrom as _}; +use std::collections::HashMap; #[derive(Clone, Deserialize, Debug)] pub struct Pipeline { diff --git a/src/main.rs b/src/main.rs index cada59e22..346946cbd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,12 +13,10 @@ use dotenv::dotenv; use log::prelude::*; use crate::{ - api::{client::server, control::load_from_file, control::Member}, + api::{client::server, control::load_from_file}, conf::Conf, - media::create_peers, signalling::{room_repo::RoomsRepository, Room}, }; -use hashbrown::HashMap; fn main() { dotenv().ok(); diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index bf9de6aa5..bd190538c 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -12,8 +12,6 @@ use futures::{ use hashbrown::HashMap; use medea_client_api_proto::Event; -use crate::api::control::element::Element; -use crate::signalling::room::{ConnectPeers, CreatePeer}; use crate::{ api::{ client::rpc_connection::{ @@ -24,7 +22,7 @@ use crate::{ }, log::prelude::*, signalling::{ - room::{CloseRoom, RoomError}, + room::{CloseRoom, RoomError, CreatePeer}, Room, }, }; @@ -160,7 +158,6 @@ impl ParticipantService { member_id: MemberId, con: Box, ) { - use std::convert::TryFrom; // lookup previous member connection if let Some(mut connection) = self.connections.remove(&member_id) { debug!("Closing old RpcConnection for member {}", member_id); diff --git a/src/signalling/room.rs b/src/signalling/room.rs index c3da9d323..ec5e2a5ec 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -14,7 +14,6 @@ use medea_client_api_proto::{ use std::time::Duration; -use crate::api::control::element::Element; use crate::api::control::member::MemberSpec; use crate::api::control::room::RoomSpec; use crate::media::MediaTrack; @@ -331,8 +330,6 @@ impl Handler for Room { } } -use std::collections::HashMap as StdHashMap; - #[derive(Debug, Message)] #[rtype(result = "Result<(), ()>")] // TODO: maybe fewer fields??? @@ -351,7 +348,7 @@ impl Handler for Room { fn handle( &mut self, msg: CreatePeer, - ctx: &mut Self::Context, + _ctx: &mut Self::Context, ) -> Self::Result { // TODO: Think about usefulness debug!( From fb25abad5ef34d0a8f8397df5786cdaac19ca80b Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 23 May 2019 17:56:31 +0300 Subject: [PATCH 017/735] Remove old connecting of peers and fix tests --- room_spec_test.yml | 24 ++++++++++++++ src/api/client/server.rs | 15 ++++----- src/signalling/room.rs | 70 ++++++++++++++++++++-------------------- 3 files changed, 65 insertions(+), 44 deletions(-) create mode 100644 room_spec_test.yml diff --git a/room_spec_test.yml b/room_spec_test.yml new file mode 100644 index 000000000..544f523ee --- /dev/null +++ b/room_spec_test.yml @@ -0,0 +1,24 @@ +kind: Room +id: 1 +spec: + pipeline: + # Here we're defining a member who initiates video call. + caller: + kind: Member + spec: + pipeline: + # Media element which is able to receive media data from client via WebRTC. + publish: + kind: WebRtcPublishEndpoint + spec: + # Actually, it receives not media data, but ICE candidates only. + p2p: Always + # Media element which is able to play media data for client via WebRTC. + responder: + kind: Member + spec: + pipeline: + play: + kind: WebRtcPlayEndpoint + spec: + src: "local://video-call-1/caller/publish" diff --git a/src/api/client/server.rs b/src/api/client/server.rs index f4b879809..069a61c17 100644 --- a/src/api/client/server.rs +++ b/src/api/client/server.rs @@ -116,17 +116,14 @@ mod test { }; use super::*; - use crate::api::control::RoomRequest; + use crate::api::control::room::RoomSpec; + use crate::api::control::load_from_file; /// Creates [`RoomsRepository`] for tests filled with a single [`Room`]. fn room(conf: Rpc) -> RoomsRepository { - let room_spec = - crate::api::control::load_from_file("room_spec.yml").unwrap(); + let room_spec = load_from_file("room_spec_test.yml").unwrap(); - // TODO: remove this - println!("{:#?}", room_spec); - - let client_room = Room::new(room_spec, config.rpc.reconnect_timeout); + let client_room = Room::new(room_spec, conf.reconnect_timeout); let room_id = client_room.get_id(); let client_room = Arbiter::start(move |_| client_room); let room_hash_map = hashmap! { @@ -153,7 +150,7 @@ mod test { fn responses_with_pong() { let mut server = ws_server(Conf::default()); let (read, mut write) = - server.ws_at("/ws/1/1/caller_credentials").unwrap(); + server.ws_at("/ws/1/1/1-credentials").unwrap(); write.text(r#"{"ping":33}"#); let (item, _) = server.execute(read.into_future()).unwrap(); @@ -172,7 +169,7 @@ mod test { let mut server = ws_server(conf.clone()); let (read, mut write) = - server.ws_at("/ws/1/1/caller_credentials").unwrap(); + server.ws_at("/ws/1/1/1-credentials").unwrap(); write.text(r#"{"ping":33}"#); let (item, read) = server.execute(read.into_future()).unwrap(); diff --git a/src/signalling/room.rs b/src/signalling/room.rs index ec5e2a5ec..be8780637 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -83,9 +83,6 @@ pub struct Room { impl Room { /// Create new instance of [`Room`]. pub fn new( - // id: Id, - // members: HashMap, - // peers: HashMap, room: RoomSpec, reconnect_timeout: Duration, ) -> Self { @@ -94,14 +91,14 @@ impl Room { let mut control_signalling_members = HashMap::new(); // TODO: rename room.spec.pipeline.iter().enumerate().for_each( |(i, (control_id, value))| { - let id = i as u64; + let id = (i as u64) + 1; let member_spec = MemberSpec::try_from(value.clone()).unwrap(); control_signalling_members.insert(control_id.clone(), id); let member = Member { id, spec: member_spec, - credentials: format!("{}-credentials", i), + credentials: format!("{}-credentials", id), control_id: control_id.clone(), }; members.insert(id, member); @@ -307,6 +304,7 @@ impl Handler for Room { msg: ConnectPeers, ctx: &mut Self::Context, ) -> Self::Result { +// println!("sdfsdaf"); match self.send_peer_created(msg.0, msg.1) { Ok(res) => { Box::new(res.map_err(|err, _, ctx: &mut Context| { @@ -348,7 +346,7 @@ impl Handler for Room { fn handle( &mut self, msg: CreatePeer, - _ctx: &mut Self::Context, + ctx: &mut Self::Context, ) -> Self::Result { // TODO: Think about usefulness debug!( @@ -357,10 +355,10 @@ impl Handler for Room { ); // TODO: Maybe need another implementation of dynamic peer ids? + self.peers_count += 1; let caller_peer_id = self.peers_count; self.peers_count += 1; let responder_peer_id = self.peers_count; - self.peers_count += 1; let mut caller_peer = Peer::new( caller_peer_id, @@ -421,8 +419,13 @@ impl Handler for Room { self.peers.add_peer(caller_peer_id, caller_peer); self.peers.add_peer(responder_peer_id, responder_peer); + ctx.notify(ConnectPeers( + caller_peer_id, + responder_peer_id, + )); + // TODO: remove this - println!("Peers: {:#?}", self.peers); +// println!("Peers: {:#?}", self.peers); Ok(()) } @@ -493,24 +496,25 @@ impl Handler for Room { msg.connection, ); + // TODO: Remove this // get connected member Peers - self.peers - .get_peers_by_member_id(msg.member_id) - .into_iter() - .for_each(|peer| { - // only New peers should be connected - if let PeerStateMachine::New(peer) = peer { - if self - .participants - .member_has_connection(peer.partner_member_id()) - { - ctx.notify(ConnectPeers( - peer.id(), - peer.partner_peer_id(), - )); - } - } - }); +// self.peers +// .get_peers_by_member_id(msg.member_id) +// .into_iter() +// .for_each(|peer| { +// // only New peers should be connected +// if let PeerStateMachine::New(peer) = peer { +// if self +// .participants +// .member_has_connection(peer.partner_member_id()) +// { +// ctx.notify(ConnectPeers( +// peer.id(), +// peer.partner_peer_id(), +// )); +// } +// } +// }); Box::new(wrap_future(future::ok(()))) } @@ -564,18 +568,14 @@ mod test { use crate::api::client::rpc_connection::test::TestConnection; use crate::media::create_peers; + use crate::api::control; use super::*; - // TODO: Fix this fn start_room() -> Addr { - let members = hashmap! { - 1 => Member{id: 1, credentials: "caller_credentials".to_owned()}, - 2 => Member{id: 2, credentials: "responder_credentials".to_owned()}, - }; - Arbiter::start(move |_| { - Room::new(1, members, create_peers(1, 2), Duration::from_secs(10)) - }) + let room_spec = control::load_from_file("room_spec_test.yml").unwrap(); + let client_room = Room::new(room_spec, Duration::from_secs(10)); + Arbiter::start(move |_| client_room) } #[test] @@ -592,13 +592,13 @@ mod test { let stopped_clone = stopped.clone(); Arbiter::start(move |_| TestConnection { events: caller_events_clone, - member_id: 1, + member_id: 2, room: room_clone, stopped: stopped_clone, }); Arbiter::start(move |_| TestConnection { events: responder_events_clone, - member_id: 2, + member_id: 1, room, stopped, }); From 74f5fa0da6d3f101298402393613f8a5dde641b1 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 23 May 2019 18:52:33 +0300 Subject: [PATCH 018/735] Fix race connections bug --- jason/e2e-demo/js/index.js | 2 +- src/signalling/participants.rs | 43 ++++++++++++++++++++++++++++++++++ src/signalling/room.rs | 10 +++++--- 3 files changed, 51 insertions(+), 4 deletions(-) diff --git a/jason/e2e-demo/js/index.js b/jason/e2e-demo/js/index.js index 146b7704d..fefe8fa1f 100644 --- a/jason/e2e-demo/js/index.js +++ b/jason/e2e-demo/js/index.js @@ -4,8 +4,8 @@ async function f() { let caller = new rust.Jason(); // let caller_room_handle = await caller.join_room("ws://localhost:8080/ws/1/1/caller_credentials"); - caller.join_room("ws://localhost:8080/ws/1/0/0-credentials"); caller.join_room("ws://localhost:8080/ws/1/1/1-credentials"); + caller.join_room("ws://localhost:8080/ws/1/2/2-credentials"); // Use this for testing with 3 members. // caller.join_room("ws://localhost:8080/ws/1/2/2-credentials"); diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index bd190538c..ac65b050a 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -26,6 +26,7 @@ use crate::{ Room, }, }; +use crate::api::control::member::MemberSpec; /// Participant is [`Member`] with [`RpcConnection`]. [`ParticipantService`] /// stores [`Members`] and associated [`RpcConnection`]s, handles @@ -51,6 +52,15 @@ pub struct ParticipantService { // TODO: Need rename control_signalling_members: HashMap, + + members_awaiting_connection: HashMap, +} + +#[derive(Debug)] +struct NewPeer { + signalling_id: u64, + spec: MemberSpec, + control_id: String, } impl ParticipantService { @@ -65,6 +75,7 @@ impl ParticipantService { reconnect_timeout, drop_connection_tasks: HashMap::new(), control_signalling_members, + members_awaiting_connection: HashMap::new(), } } @@ -172,10 +183,35 @@ impl ParticipantService { } else { debug!("Connected member: {}", member_id); + // TODO: + // 1) Create function for that + // 2) Simplify + // 3) Reduce `clone()`s + let connected_member = self.members.get(&member_id).unwrap(); let connected_member_play_endpoints = connected_member.spec.get_play_endpoints(); + + let mut added_member = None; + if let Some(awaiter) = self.members_awaiting_connection.get_mut(&member_id) { + added_member = Some(awaiter.control_id.clone()); + ctx.notify(CreatePeer { + caller_control_id: connected_member.control_id.clone(), + caller_signalling_id: connected_member.id, + caller_spec: connected_member.spec.clone(), + responder_spec: awaiter.spec.clone(), + responder_control_id: awaiter.control_id.clone(), + responder_signalling_id: awaiter.signalling_id, + }); + self.members_awaiting_connection.remove(&member_id); + } + for connected_member_endpoint in connected_member_play_endpoints { + if let Some(ref c) = added_member { + if connected_member_endpoint.src.member_id.as_str() == c.as_str() { + continue; + } + } let responder_member_control_id = connected_member_endpoint.src.member_id; let responder_member_signalling_id = match self @@ -197,6 +233,11 @@ impl ParticipantService { .connections .get(&responder_member_signalling_id) .is_some(); + let responder_new_peer = NewPeer { + signalling_id: connected_member.id, + spec: connected_member.spec.clone(), + control_id: connected_member.control_id.clone(), + }; if is_responder_connected { ctx.notify(CreatePeer { caller_signalling_id: *responder_member_signalling_id, @@ -213,6 +254,8 @@ impl ParticipantService { .control_id .clone(), }); + } else { + self.members_awaiting_connection.insert(*responder_member_signalling_id, responder_new_peer); } } diff --git a/src/signalling/room.rs b/src/signalling/room.rs index be8780637..a7b6f3a8a 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -349,7 +349,7 @@ impl Handler for Room { ctx: &mut Self::Context, ) -> Self::Result { // TODO: Think about usefulness - debug!( + println!( "Created peer member {} with member {}", msg.caller_signalling_id, msg.responder_signalling_id ); @@ -578,6 +578,10 @@ mod test { Arbiter::start(move |_| client_room) } + // TODO: Fix this test. + // This test sometimes fails due to racing connections. + // When the second user connects first, and the first user + // follows him, their events are swapped. #[test] fn start_signaling() { let stopped = Arc::new(AtomicUsize::new(0)); @@ -592,13 +596,13 @@ mod test { let stopped_clone = stopped.clone(); Arbiter::start(move |_| TestConnection { events: caller_events_clone, - member_id: 2, + member_id: 1, room: room_clone, stopped: stopped_clone, }); Arbiter::start(move |_| TestConnection { events: responder_events_clone, - member_id: 1, + member_id: 2, room, stopped, }); From 737a0c66592c5cd5d59a52c3e15b2707c76d5320 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 23 May 2019 18:58:03 +0300 Subject: [PATCH 019/735] Fix test warnings --- src/api/client/server.rs | 7 ++----- src/main.rs | 2 +- src/signalling/room.rs | 4 +--- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/api/client/server.rs b/src/api/client/server.rs index 069a61c17..140222d19 100644 --- a/src/api/client/server.rs +++ b/src/api/client/server.rs @@ -109,19 +109,16 @@ mod test { use futures::Stream; use crate::{ - api::control::Member, conf::{Conf, Server}, - media::create_peers, signalling::Room, }; use super::*; - use crate::api::control::room::RoomSpec; - use crate::api::control::load_from_file; + use crate::api::control; /// Creates [`RoomsRepository`] for tests filled with a single [`Room`]. fn room(conf: Rpc) -> RoomsRepository { - let room_spec = load_from_file("room_spec_test.yml").unwrap(); + let room_spec = control::load_from_file("room_spec_test.yml").unwrap(); let client_room = Room::new(room_spec, conf.reconnect_timeout); let room_id = client_room.get_id(); diff --git a/src/main.rs b/src/main.rs index 346946cbd..4f3de18dd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -31,7 +31,7 @@ fn main() { let room_spec = load_from_file("room_spec.yml").unwrap(); - println!("{:#?}", room_spec); +// println!("{:#?}", room_spec); let client_room = Room::new(room_spec, config.rpc.reconnect_timeout); let room_id = client_room.get_id(); diff --git a/src/signalling/room.rs b/src/signalling/room.rs index a7b6f3a8a..2cf606b25 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -304,7 +304,6 @@ impl Handler for Room { msg: ConnectPeers, ctx: &mut Self::Context, ) -> Self::Result { -// println!("sdfsdaf"); match self.send_peer_created(msg.0, msg.1) { Ok(res) => { Box::new(res.map_err(|err, _, ctx: &mut Context| { @@ -349,7 +348,7 @@ impl Handler for Room { ctx: &mut Self::Context, ) -> Self::Result { // TODO: Think about usefulness - println!( + info!( "Created peer member {} with member {}", msg.caller_signalling_id, msg.responder_signalling_id ); @@ -567,7 +566,6 @@ mod test { }; use crate::api::client::rpc_connection::test::TestConnection; - use crate::media::create_peers; use crate::api::control; use super::*; From dbcd96489aa7a6b2c4b0da5b3d0272a82f6b86a5 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 23 May 2019 19:59:13 +0300 Subject: [PATCH 020/735] Refactor --- src/signalling/participants.rs | 59 +++++++++++++++++----------------- src/signalling/room.rs | 33 ++++++++++--------- 2 files changed, 48 insertions(+), 44 deletions(-) diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index ac65b050a..7e26ba7ce 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -22,11 +22,10 @@ use crate::{ }, log::prelude::*, signalling::{ - room::{CloseRoom, RoomError, CreatePeer}, + room::{CloseRoom, RoomError, CreatePeer, NewPeer}, Room, }, }; -use crate::api::control::member::MemberSpec; /// Participant is [`Member`] with [`RpcConnection`]. [`ParticipantService`] /// stores [`Members`] and associated [`RpcConnection`]s, handles @@ -56,12 +55,6 @@ pub struct ParticipantService { members_awaiting_connection: HashMap, } -#[derive(Debug)] -struct NewPeer { - signalling_id: u64, - spec: MemberSpec, - control_id: String, -} impl ParticipantService { pub fn new( @@ -192,20 +185,29 @@ impl ParticipantService { let connected_member_play_endpoints = connected_member.spec.get_play_endpoints(); + // connect_awaiters let mut added_member = None; if let Some(awaiter) = self.members_awaiting_connection.get_mut(&member_id) { added_member = Some(awaiter.control_id.clone()); + let connected_new_peer = NewPeer { + control_id: connected_member.control_id.clone(), + signalling_id: connected_member.id, + spec: connected_member.spec.clone(), + }; + let awaiter_new_peer = NewPeer { + spec: awaiter.spec.clone(), + control_id: awaiter.control_id.clone(), + signalling_id: awaiter.signalling_id, + }; + ctx.notify(CreatePeer { - caller_control_id: connected_member.control_id.clone(), - caller_signalling_id: connected_member.id, - caller_spec: connected_member.spec.clone(), - responder_spec: awaiter.spec.clone(), - responder_control_id: awaiter.control_id.clone(), - responder_signalling_id: awaiter.signalling_id, + caller: connected_new_peer, + responder: awaiter_new_peer, }); self.members_awaiting_connection.remove(&member_id); } + // connect_existing_play_endpoints for connected_member_endpoint in connected_member_play_endpoints { if let Some(ref c) = added_member { if connected_member_endpoint.src.member_id.as_str() == c.as_str() { @@ -233,29 +235,28 @@ impl ParticipantService { .connections .get(&responder_member_signalling_id) .is_some(); - let responder_new_peer = NewPeer { + let connected_new_peer = NewPeer { signalling_id: connected_member.id, spec: connected_member.spec.clone(), control_id: connected_member.control_id.clone(), }; + let responder_new_peer = NewPeer { + signalling_id: *responder_member_signalling_id, + spec: self + .members + .get(&responder_member_signalling_id) + .unwrap() + .spec + .clone(), + control_id: responder_member_control_id, + }; if is_responder_connected { ctx.notify(CreatePeer { - caller_signalling_id: *responder_member_signalling_id, - caller_spec: self - .members - .get(&responder_member_signalling_id) - .unwrap() - .spec - .clone(), - responder_signalling_id: connected_member.id, - responder_spec: connected_member.spec.clone(), - caller_control_id: responder_member_control_id, - responder_control_id: connected_member - .control_id - .clone(), + caller: responder_new_peer, + responder: connected_new_peer, }); } else { - self.members_awaiting_connection.insert(*responder_member_signalling_id, responder_new_peer); + self.members_awaiting_connection.insert(*responder_member_signalling_id, connected_new_peer); } } diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 2cf606b25..2b12573c7 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -327,16 +327,19 @@ impl Handler for Room { } } +#[derive(Debug)] +pub struct NewPeer { + pub signalling_id: u64, + pub spec: MemberSpec, + pub control_id: String, +} + #[derive(Debug, Message)] #[rtype(result = "Result<(), ()>")] // TODO: maybe fewer fields??? pub struct CreatePeer { - pub caller_signalling_id: MemberId, - pub responder_signalling_id: MemberId, - pub caller_spec: MemberSpec, - pub responder_spec: MemberSpec, - pub caller_control_id: String, - pub responder_control_id: String, + pub caller: NewPeer, + pub responder: NewPeer, } impl Handler for Room { @@ -350,7 +353,7 @@ impl Handler for Room { // TODO: Think about usefulness info!( "Created peer member {} with member {}", - msg.caller_signalling_id, msg.responder_signalling_id + msg.caller.signalling_id, msg.responder.signalling_id ); // TODO: Maybe need another implementation of dynamic peer ids? @@ -361,22 +364,22 @@ impl Handler for Room { let mut caller_peer = Peer::new( caller_peer_id, - msg.caller_signalling_id, + msg.caller.signalling_id, responder_peer_id, - msg.responder_signalling_id, + msg.responder.signalling_id, ); let mut responder_peer = Peer::new( responder_peer_id, - msg.responder_signalling_id, + msg.responder.signalling_id, caller_peer_id, - msg.caller_signalling_id, + msg.caller.signalling_id, ); let mut last_track_id = 0; // TODO: remove boilerplate - for endpoint in msg.caller_spec.get_play_endpoints().into_iter() { - if endpoint.src.member_id == msg.responder_control_id { + for endpoint in msg.caller.spec.get_play_endpoints().into_iter() { + if endpoint.src.member_id == msg.responder.control_id { last_track_id += 1; let track_audio = Arc::new(MediaTrack::new( last_track_id, @@ -395,8 +398,8 @@ impl Handler for Room { } } - for endpoint in msg.responder_spec.get_play_endpoints().into_iter() { - if endpoint.src.member_id == msg.caller_control_id { + for endpoint in msg.responder.spec.get_play_endpoints().into_iter() { + if endpoint.src.member_id == msg.caller.control_id { last_track_id += 1; let track_audio = Arc::new(MediaTrack::new( last_track_id, From 508578a99403cb15b2659183e73b9fc015967ae5 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 24 May 2019 13:04:07 +0300 Subject: [PATCH 021/735] Refactor --- src/api/client/server.rs | 6 +- src/api/control/member.rs | 25 +++++++- src/main.rs | 4 +- src/media/peer.rs | 32 ++++++++++ src/signalling/participants.rs | 16 +++-- src/signalling/peers.rs | 85 +++++++++++++++++++++++++- src/signalling/room.rs | 107 ++++----------------------------- 7 files changed, 167 insertions(+), 108 deletions(-) diff --git a/src/api/client/server.rs b/src/api/client/server.rs index 140222d19..a8e71feeb 100644 --- a/src/api/client/server.rs +++ b/src/api/client/server.rs @@ -146,8 +146,7 @@ mod test { #[test] fn responses_with_pong() { let mut server = ws_server(Conf::default()); - let (read, mut write) = - server.ws_at("/ws/1/1/1-credentials").unwrap(); + let (read, mut write) = server.ws_at("/ws/1/1/1-credentials").unwrap(); write.text(r#"{"ping":33}"#); let (item, _) = server.execute(read.into_future()).unwrap(); @@ -165,8 +164,7 @@ mod test { }; let mut server = ws_server(conf.clone()); - let (read, mut write) = - server.ws_at("/ws/1/1/1-credentials").unwrap(); + let (read, mut write) = server.ws_at("/ws/1/1/1-credentials").unwrap(); write.text(r#"{"ping":33}"#); let (item, read) = server.execute(read.into_future()).unwrap(); diff --git a/src/api/control/member.rs b/src/api/control/member.rs index 42b8b28ad..3d909329a 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -3,7 +3,7 @@ use std::convert::TryFrom; use super::{element::Element, pipeline::Pipeline, Entity, TryFromEntityError}; -use crate::api::control::element::WebRtcPlayEndpoint; +use crate::api::control::element::{WebRtcPlayEndpoint, WebRtcPublishEndpoint}; pub type Id = u64; @@ -42,6 +42,29 @@ impl MemberSpec { .cloned() .collect() } + + pub fn get_play_endpoint_by_src( + &self, + src: &str, + ) -> Vec { + self.get_play_endpoints() + .iter() + .filter(|endpoint| endpoint.src.member_id == src) + .cloned() + .collect() + } + + pub fn get_publish_endpoints(&self) -> Vec { + self.0 + .pipeline + .iter() + .filter_map(|(_name, e)| match e { + Entity::WebRtcPublishEndpoint { spec } => Some(spec), + _ => None, + }) + .cloned() + .collect() + } } impl TryFrom for MemberSpec { diff --git a/src/main.rs b/src/main.rs index 4f3de18dd..aca8e6b60 100644 --- a/src/main.rs +++ b/src/main.rs @@ -29,9 +29,9 @@ fn main() { let config = Conf::parse().unwrap(); info!("{:?}", config); - let room_spec = load_from_file("room_spec.yml").unwrap(); + let room_spec = load_from_file("room_spec_test.yml").unwrap(); -// println!("{:#?}", room_spec); + // println!("{:#?}", room_spec); let client_room = Room::new(room_spec, config.rpc.reconnect_timeout); let room_id = client_room.get_id(); diff --git a/src/media/peer.rs b/src/media/peer.rs index 6d71d683a..26de5f040 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -11,6 +11,7 @@ use medea_client_api_proto::{ use std::{convert::TryFrom, fmt::Display, sync::Arc}; +use crate::api::control::element::WebRtcPublishEndpoint; use crate::{ api::control::MemberId, media::{MediaTrack, TrackId}, @@ -254,6 +255,15 @@ impl Peer { }) } + pub fn get_senders(&self) -> Vec> { + self.context + .senders + .iter() + .map(|(key, value)| value) + .cloned() + .collect() + } + pub fn is_sender(&self) -> bool { !self.context.senders.is_empty() } @@ -283,6 +293,28 @@ impl Peer { } } + pub fn add_publish_endpoints( + &mut self, + endpoints: Vec, + last_track_id: &mut u64, + ) { + for endpoint in endpoints.into_iter() { + *last_track_id += 1; + let track_audio = Arc::new(MediaTrack::new( + *last_track_id, + MediaType::Audio(AudioSettings {}), + )); + *last_track_id += 1; + let track_video = Arc::new(MediaTrack::new( + *last_track_id, + MediaType::Video(VideoSettings {}), + )); + + self.add_sender(track_audio); + self.add_sender(track_video); + } + } + /// Transition new [`Peer`] into state of waiting for local description. pub fn start(self) -> Peer { Peer { diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 7e26ba7ce..e2abbab04 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -22,7 +22,7 @@ use crate::{ }, log::prelude::*, signalling::{ - room::{CloseRoom, RoomError, CreatePeer, NewPeer}, + room::{CloseRoom, CreatePeer, NewPeer, RoomError}, Room, }, }; @@ -55,7 +55,6 @@ pub struct ParticipantService { members_awaiting_connection: HashMap, } - impl ParticipantService { pub fn new( members: HashMap, @@ -187,7 +186,9 @@ impl ParticipantService { // connect_awaiters let mut added_member = None; - if let Some(awaiter) = self.members_awaiting_connection.get_mut(&member_id) { + if let Some(awaiter) = + self.members_awaiting_connection.get_mut(&member_id) + { added_member = Some(awaiter.control_id.clone()); let connected_new_peer = NewPeer { control_id: connected_member.control_id.clone(), @@ -210,7 +211,9 @@ impl ParticipantService { // connect_existing_play_endpoints for connected_member_endpoint in connected_member_play_endpoints { if let Some(ref c) = added_member { - if connected_member_endpoint.src.member_id.as_str() == c.as_str() { + if connected_member_endpoint.src.member_id.as_str() + == c.as_str() + { continue; } } @@ -256,7 +259,10 @@ impl ParticipantService { responder: connected_new_peer, }); } else { - self.members_awaiting_connection.insert(*responder_member_signalling_id, connected_new_peer); + self.members_awaiting_connection.insert( + *responder_member_signalling_id, + connected_new_peer, + ); } } diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index 710de7909..24a133563 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -4,16 +4,24 @@ use hashbrown::HashMap; use std::convert::{TryFrom, TryInto}; +use crate::api::control::Member; +use crate::media::MediaTrack; +use crate::signalling::room::NewPeer; use crate::{ api::control::MemberId, media::{Peer, PeerId, PeerStateMachine}, signalling::room::RoomError, }; +use medea_client_api_proto::{AudioSettings, MediaType, VideoSettings}; +use std::sync::Arc; #[derive(Debug)] pub struct PeerRepository { /// [`Peer`]s of [`Member`]s in this [`Room`]. peers: HashMap, + waiting_members: HashMap, + peers_count: u64, + last_track_id: u64, } impl PeerRepository { @@ -32,6 +40,76 @@ impl PeerRepository { .ok_or_else(|| RoomError::PeerNotFound(peer_id)) } + pub fn add_waiter_member(&mut self, id: MemberId, peer: NewPeer) { + self.waiting_members.insert(id, peer); + } + + pub fn get_waiting_member_peer(&self, id: MemberId) -> Option { + self.waiting_members.get(&id).cloned() + } + + pub fn connect_waiting_member(&self, member: &Member) { + // TODO + } + + pub fn create_peers( + &mut self, + caller: NewPeer, + responder: NewPeer, + ) -> (u64, u64) { + self.peers_count += 1; + let caller_peer_id = self.peers_count; + self.peers_count += 1; + let responder_peer_id = self.peers_count; + + let mut caller_peer = Peer::new( + caller_peer_id, + caller.signalling_id, + responder_peer_id, + responder.signalling_id, + ); + let mut responder_peer = Peer::new( + responder_peer_id, + responder.signalling_id, + caller_peer_id, + caller.signalling_id, + ); + + caller_peer.add_publish_endpoints( + caller.spec.get_publish_endpoints(), + &mut self.last_track_id, + ); + for endpoint in caller.spec.get_play_endpoints().into_iter() { + if responder.control_id == endpoint.src.member_id { + responder_peer + .get_senders() + .into_iter() + .for_each(|s| caller_peer.add_receiver(s)); + } + } + + responder_peer.add_publish_endpoints( + responder.spec.get_publish_endpoints(), + &mut self.last_track_id, + ); + for endpoint in responder.spec.get_play_endpoints().into_iter() { + if caller.control_id == endpoint.src.member_id { + caller_peer + .get_senders() + .into_iter() + .for_each(|s| responder_peer.add_receiver(s)); + } + } + + self.add_peer(caller_peer_id, caller_peer); + self.add_peer(responder_peer_id, responder_peer); + + // TODO: remove this + // println!("Peers: {:#?}", self.peers); + + (caller_peer_id, responder_peer_id) + } + /// Returns borrowed [`Peer`] by its ID. pub fn get_inner_peer<'a, S>( &'a self, @@ -84,6 +162,11 @@ impl PeerRepository { impl From> for PeerRepository { fn from(map: HashMap) -> Self { - Self { peers: map } + Self { + peers: map, + waiting_members: HashMap::new(), + peers_count: 0, + last_track_id: 0, + } } } diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 2b12573c7..d273740aa 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -82,10 +82,7 @@ pub struct Room { impl Room { /// Create new instance of [`Room`]. - pub fn new( - room: RoomSpec, - reconnect_timeout: Duration, - ) -> Self { + pub fn new(room: RoomSpec, reconnect_timeout: Duration) -> Self { // TODO: Rewrite it only with iterator let mut members = HashMap::new(); let mut control_signalling_members = HashMap::new(); // TODO: rename @@ -327,7 +324,8 @@ impl Handler for Room { } } -#[derive(Debug)] +// TODO: Move into peers.rs +#[derive(Debug, Clone)] pub struct NewPeer { pub signalling_id: u64, pub spec: MemberSpec, @@ -336,7 +334,6 @@ pub struct NewPeer { #[derive(Debug, Message)] #[rtype(result = "Result<(), ()>")] -// TODO: maybe fewer fields??? pub struct CreatePeer { pub caller: NewPeer, pub responder: NewPeer, @@ -356,78 +353,13 @@ impl Handler for Room { msg.caller.signalling_id, msg.responder.signalling_id ); - // TODO: Maybe need another implementation of dynamic peer ids? - self.peers_count += 1; - let caller_peer_id = self.peers_count; - self.peers_count += 1; - let responder_peer_id = self.peers_count; - - let mut caller_peer = Peer::new( - caller_peer_id, - msg.caller.signalling_id, - responder_peer_id, - msg.responder.signalling_id, - ); - let mut responder_peer = Peer::new( - responder_peer_id, - msg.responder.signalling_id, - caller_peer_id, - msg.caller.signalling_id, - ); + let (caller_peer_id, responder_peer_id) = + self.peers.create_peers(msg.caller, msg.responder); - let mut last_track_id = 0; - - // TODO: remove boilerplate - for endpoint in msg.caller.spec.get_play_endpoints().into_iter() { - if endpoint.src.member_id == msg.responder.control_id { - last_track_id += 1; - let track_audio = Arc::new(MediaTrack::new( - last_track_id, - MediaType::Audio(AudioSettings {}), - )); - last_track_id += 1; - let track_video = Arc::new(MediaTrack::new( - last_track_id, - MediaType::Video(VideoSettings {}), - )); - - responder_peer.add_sender(track_audio.clone()); - responder_peer.add_sender(track_video.clone()); - caller_peer.add_receiver(track_audio); - caller_peer.add_receiver(track_video); - } - } - - for endpoint in msg.responder.spec.get_play_endpoints().into_iter() { - if endpoint.src.member_id == msg.caller.control_id { - last_track_id += 1; - let track_audio = Arc::new(MediaTrack::new( - last_track_id, - MediaType::Audio(AudioSettings {}), - )); - last_track_id += 1; - let track_video = Arc::new(MediaTrack::new( - last_track_id, - MediaType::Video(VideoSettings {}), - )); - - caller_peer.add_sender(track_audio.clone()); - caller_peer.add_sender(track_video.clone()); - responder_peer.add_receiver(track_audio); - responder_peer.add_receiver(track_video); - } - } - - self.peers.add_peer(caller_peer_id, caller_peer); - self.peers.add_peer(responder_peer_id, responder_peer); - - ctx.notify(ConnectPeers( - caller_peer_id, - responder_peer_id, - )); + ctx.notify(ConnectPeers(caller_peer_id, responder_peer_id)); // TODO: remove this -// println!("Peers: {:#?}", self.peers); + println!("Peers: {:#?}", self.peers); Ok(()) } @@ -498,26 +430,6 @@ impl Handler for Room { msg.connection, ); - // TODO: Remove this - // get connected member Peers -// self.peers -// .get_peers_by_member_id(msg.member_id) -// .into_iter() -// .for_each(|peer| { -// // only New peers should be connected -// if let PeerStateMachine::New(peer) = peer { -// if self -// .participants -// .member_has_connection(peer.partner_member_id()) -// { -// ctx.notify(ConnectPeers( -// peer.id(), -// peer.partner_peer_id(), -// )); -// } -// } -// }); - Box::new(wrap_future(future::ok(()))) } } @@ -609,6 +521,11 @@ mod test { }); }); + println!( + "\n\n===RESPONDER===\n{:?}\n\n===CALLER===\n{:?}\n\n\n", + responder_events, caller_events + ); + let caller_events = caller_events.lock().unwrap(); let responder_events = responder_events.lock().unwrap(); assert_eq!( From 9fbba4ed2f7239ac7ca5bd45fa9462c8b90d7879 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 24 May 2019 13:33:03 +0300 Subject: [PATCH 022/735] Refactor and fix bug --- src/main.rs | 2 +- src/signalling/participants.rs | 61 ++++++++++++++++++---------------- src/signalling/peers.rs | 8 ++--- 3 files changed, 37 insertions(+), 34 deletions(-) diff --git a/src/main.rs b/src/main.rs index aca8e6b60..75abe2af8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -29,7 +29,7 @@ fn main() { let config = Conf::parse().unwrap(); info!("{:?}", config); - let room_spec = load_from_file("room_spec_test.yml").unwrap(); + let room_spec = load_from_file("room_spec.yml").unwrap(); // println!("{:#?}", room_spec); diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index e2abbab04..0f6ae35c3 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -152,6 +152,31 @@ impl ParticipantService { } } + fn connect_waiting_if_exist(&self, member: Member, ctx: &mut Context) -> Option { + let mut added_member = None; + if let Some(awaiter) = + self.members_awaiting_connection.get(&member.id) + { + added_member = Some(awaiter.control_id.clone()); + let connected_new_peer = NewPeer { + control_id: member.control_id, + signalling_id: member.id, + spec: member.spec, + }; + let awaiter_new_peer = NewPeer { + spec: awaiter.spec.clone(), + control_id: awaiter.control_id.clone(), + signalling_id: awaiter.signalling_id, + }; + + ctx.notify(CreatePeer { + caller: connected_new_peer, + responder: awaiter_new_peer, + }); + } + added_member + } + /// Stores provided [`RpcConnection`] for given [`Member`] in the [`Room`]. /// If [`Member`] already has any other [`RpcConnection`], /// then it will be closed. @@ -184,39 +209,19 @@ impl ParticipantService { let connected_member_play_endpoints = connected_member.spec.get_play_endpoints(); - // connect_awaiters - let mut added_member = None; - if let Some(awaiter) = - self.members_awaiting_connection.get_mut(&member_id) - { - added_member = Some(awaiter.control_id.clone()); - let connected_new_peer = NewPeer { - control_id: connected_member.control_id.clone(), - signalling_id: connected_member.id, - spec: connected_member.spec.clone(), - }; - let awaiter_new_peer = NewPeer { - spec: awaiter.spec.clone(), - control_id: awaiter.control_id.clone(), - signalling_id: awaiter.signalling_id, - }; - - ctx.notify(CreatePeer { - caller: connected_new_peer, - responder: awaiter_new_peer, - }); - self.members_awaiting_connection.remove(&member_id); - } + let mut added_member = self.connect_waiting_if_exist(connected_member.clone(), ctx); + self.members_awaiting_connection.remove(&member_id); // connect_existing_play_endpoints for connected_member_endpoint in connected_member_play_endpoints { if let Some(ref c) = added_member { - if connected_member_endpoint.src.member_id.as_str() - == c.as_str() + if &connected_member_endpoint.src.member_id + == c { continue; } } + let responder_member_control_id = connected_member_endpoint.src.member_id; let responder_member_signalling_id = match self @@ -234,10 +239,7 @@ impl ParticipantService { } }; - let is_responder_connected = self - .connections - .get(&responder_member_signalling_id) - .is_some(); + let is_responder_connected = self.member_has_connection(*responder_member_signalling_id); let connected_new_peer = NewPeer { signalling_id: connected_member.id, spec: connected_member.spec.clone(), @@ -258,6 +260,7 @@ impl ParticipantService { caller: responder_new_peer, responder: connected_new_peer, }); +// self.members_awaiting_connection.remove(&member_id); } else { self.members_awaiting_connection.insert( *responder_member_signalling_id, diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index 24a133563..5f6695abd 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -79,6 +79,10 @@ impl PeerRepository { caller.spec.get_publish_endpoints(), &mut self.last_track_id, ); + responder_peer.add_publish_endpoints( + responder.spec.get_publish_endpoints(), + &mut self.last_track_id, + ); for endpoint in caller.spec.get_play_endpoints().into_iter() { if responder.control_id == endpoint.src.member_id { responder_peer @@ -88,10 +92,6 @@ impl PeerRepository { } } - responder_peer.add_publish_endpoints( - responder.spec.get_publish_endpoints(), - &mut self.last_track_id, - ); for endpoint in responder.spec.get_play_endpoints().into_iter() { if caller.control_id == endpoint.src.member_id { caller_peer From 0a0dd85bbd6c32172c92d99b04fd73c21faa1842 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 24 May 2019 13:51:38 +0300 Subject: [PATCH 023/735] Refactor --- src/signalling/participants.rs | 155 ++++++++++++++++++--------------- 1 file changed, 83 insertions(+), 72 deletions(-) diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 0f6ae35c3..52980e60d 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -152,10 +152,13 @@ impl ParticipantService { } } - fn connect_waiting_if_exist(&self, member: Member, ctx: &mut Context) -> Option { + fn connect_waiting_if_exist( + &self, + member: Member, + ctx: &mut Context, + ) -> Option { let mut added_member = None; - if let Some(awaiter) = - self.members_awaiting_connection.get(&member.id) + if let Some(awaiter) = self.members_awaiting_connection.get(&member.id) { added_member = Some(awaiter.control_id.clone()); let connected_new_peer = NewPeer { @@ -177,74 +180,58 @@ impl ParticipantService { added_member } - /// Stores provided [`RpcConnection`] for given [`Member`] in the [`Room`]. - /// If [`Member`] already has any other [`RpcConnection`], - /// then it will be closed. - pub fn connection_established( + fn connect_peers_of_member( &mut self, ctx: &mut Context, member_id: MemberId, - con: Box, ) { - // lookup previous member connection - if let Some(mut connection) = self.connections.remove(&member_id) { - debug!("Closing old RpcConnection for member {}", member_id); - - // cancel RpcConnection close task, since connection is - // reestablished - if let Some(handler) = self.drop_connection_tasks.remove(&member_id) - { - ctx.cancel_future(handler); + let connected_member = match self.members.get(&member_id) { + Some(m) => m, + None => { + warn!("Connected a non-existent member with id {}!", member_id); + return; } - ctx.spawn(wrap_future(connection.close())); - } else { - debug!("Connected member: {}", member_id); + }; + let connected_member_play_endpoints = + connected_member.spec.get_play_endpoints(); - // TODO: - // 1) Create function for that - // 2) Simplify - // 3) Reduce `clone()`s + let mut added_member = + self.connect_waiting_if_exist(connected_member.clone(), ctx); + self.members_awaiting_connection.remove(&member_id); - let connected_member = self.members.get(&member_id).unwrap(); - let connected_member_play_endpoints = - connected_member.spec.get_play_endpoints(); - - let mut added_member = self.connect_waiting_if_exist(connected_member.clone(), ctx); - self.members_awaiting_connection.remove(&member_id); + for connected_member_endpoint in connected_member_play_endpoints { + if let Some(ref c) = added_member { + if &connected_member_endpoint.src.member_id == c { + continue; + } + } - // connect_existing_play_endpoints - for connected_member_endpoint in connected_member_play_endpoints { - if let Some(ref c) = added_member { - if &connected_member_endpoint.src.member_id - == c - { - continue; - } + let responder_member_control_id = + connected_member_endpoint.src.member_id; + let responder_member_signalling_id = match self + .control_signalling_members + .get(&responder_member_control_id) + { + Some(r) => r, + None => { + warn!( + "Member with control id '{}' not found! Probably this \ + is error in spec.", + responder_member_control_id + ); + continue; } + }; - let responder_member_control_id = - connected_member_endpoint.src.member_id; - let responder_member_signalling_id = match self - .control_signalling_members - .get(&responder_member_control_id) - { - Some(r) => r, - None => { - warn!( - "Member with control id '{}' not found! Probably \ - this is error in spec.", - responder_member_control_id - ); - continue; - } - }; + let connected_new_peer = NewPeer { + signalling_id: connected_member.id, + spec: connected_member.spec.clone(), + control_id: connected_member.control_id.clone(), + }; - let is_responder_connected = self.member_has_connection(*responder_member_signalling_id); - let connected_new_peer = NewPeer { - signalling_id: connected_member.id, - spec: connected_member.spec.clone(), - control_id: connected_member.control_id.clone(), - }; + let is_responder_connected = + self.member_has_connection(*responder_member_signalling_id); + if is_responder_connected { let responder_new_peer = NewPeer { signalling_id: *responder_member_signalling_id, spec: self @@ -255,19 +242,43 @@ impl ParticipantService { .clone(), control_id: responder_member_control_id, }; - if is_responder_connected { - ctx.notify(CreatePeer { - caller: responder_new_peer, - responder: connected_new_peer, - }); -// self.members_awaiting_connection.remove(&member_id); - } else { - self.members_awaiting_connection.insert( - *responder_member_signalling_id, - connected_new_peer, - ); - } + ctx.notify(CreatePeer { + caller: responder_new_peer, + responder: connected_new_peer, + }); + } else { + self.members_awaiting_connection.insert( + *responder_member_signalling_id, + connected_new_peer, + ); } + } + } + + /// Stores provided [`RpcConnection`] for given [`Member`] in the [`Room`]. + /// If [`Member`] already has any other [`RpcConnection`], + /// then it will be closed. + pub fn connection_established( + &mut self, + ctx: &mut Context, + member_id: MemberId, + con: Box, + ) { + // lookup previous member connection + if let Some(mut connection) = self.connections.remove(&member_id) { + debug!("Closing old RpcConnection for member {}", member_id); + + // cancel RpcConnection close task, since connection is + // reestablished + if let Some(handler) = self.drop_connection_tasks.remove(&member_id) + { + ctx.cancel_future(handler); + } + ctx.spawn(wrap_future(connection.close())); + } else { + debug!("Connected member: {}", member_id); + + self.connect_peers_of_member(ctx, member_id); self.connections.insert(member_id, con); } From 7cb3300adef20cb1fb3e6e35fbae1557b4e6788e Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 24 May 2019 14:52:06 +0300 Subject: [PATCH 024/735] Add docs --- src/api/client/server.rs | 2 +- src/api/control/element.rs | 11 +++++++++-- src/api/control/member.rs | 10 +++++++++- src/api/control/mod.rs | 16 +++++++++++++++- src/api/control/pipeline.rs | 3 +++ src/api/control/room.rs | 8 ++++++++ src/main.rs | 4 ++-- src/media/peer.rs | 1 + src/signalling/participants.rs | 16 +++++++++++----- src/signalling/peers.rs | 27 +++++++++------------------ src/signalling/room.rs | 19 ++++++++----------- 11 files changed, 76 insertions(+), 41 deletions(-) diff --git a/src/api/client/server.rs b/src/api/client/server.rs index a8e71feeb..a75df23b0 100644 --- a/src/api/client/server.rs +++ b/src/api/client/server.rs @@ -118,7 +118,7 @@ mod test { /// Creates [`RoomsRepository`] for tests filled with a single [`Room`]. fn room(conf: Rpc) -> RoomsRepository { - let room_spec = control::load_from_file("room_spec_test.yml").unwrap(); + let room_spec = control::load_from_yaml_file("room_spec_test.yml").unwrap(); let client_room = Room::new(room_spec, conf.reconnect_timeout); let room_id = client_room.get_id(); diff --git a/src/api/control/element.rs b/src/api/control/element.rs index ae2793821..19a2d942b 100644 --- a/src/api/control/element.rs +++ b/src/api/control/element.rs @@ -1,3 +1,5 @@ +//! Control API specification Element definitions. + use super::{Entity, TryFromEntityError}; use serde::{ @@ -6,6 +8,7 @@ use serde::{ }; use std::{convert::TryFrom, fmt}; +/// [`Element`] represents a media element that one or more media data streams flow through. #[derive(Debug)] pub enum Element { WebRtcPublishEndpoint(WebRtcPublishEndpoint), @@ -35,19 +38,21 @@ pub enum P2pMode { } #[derive(Deserialize, Debug, Clone)] -/// Media element which is able to play media data for client via WebRTC. +/// Media element which is able to publish media data for another client via WebRTC. pub struct WebRtcPublishEndpoint { /// Peer-to-peer mode. pub p2p: P2pMode, } +/// Media element which is able to play media data for client via WebRTC. #[derive(Deserialize, Debug, Clone)] pub struct WebRtcPlayEndpoint { + /// Source URI in format `local://{room_id}/{member_id}/{pipeline_id}`. pub src: LocalUri, } #[derive(Debug, Clone)] -/// Special uri with pattern "local://{room_id}/{member_id}/{pipeline_id} +/// Special uri with pattern `local://{room_id}/{member_id}/{pipeline_id}`. pub struct LocalUri { /// ID of [`Room`] // TODO: Why this field never used??? @@ -59,6 +64,8 @@ pub struct LocalUri { } // TODO: Write unit tests? +/// Serde deserializer for [`LocalUri`]. +/// Deserialize URIs with pattern `local://{room_id}/{member_id}/{pipeline_id}. impl<'de> Deserialize<'de> for LocalUri { fn deserialize(deserializer: D) -> Result where diff --git a/src/api/control/member.rs b/src/api/control/member.rs index 3d909329a..34817e605 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -16,14 +16,19 @@ pub struct Member { /// Credentials to authorize [`Member`] with. pub credentials: String, + /// Control API specification of this [`Member`]. pub spec: MemberSpec, + /// ID from Control API specification of this [`Member`]. pub control_id: String, } +/// Newtype for [`Entity::Member`] variant. #[derive(Clone, Debug)] pub struct MemberSpec(pub Pipeline); + impl MemberSpec { + /// Get [`Element`] of this [`MemberSpec`] by ID. pub fn get_element( &self, id: &str, @@ -31,6 +36,7 @@ impl MemberSpec { Some(Element::try_from(self.0.pipeline.get(id).cloned()?)) } + /// Get all [`WebRtcPlayEndpoint`]s of this [`MemberSpec`]. pub fn get_play_endpoints(&self) -> Vec { self.0 .pipeline @@ -43,7 +49,8 @@ impl MemberSpec { .collect() } - pub fn get_play_endpoint_by_src( + /// Get all [`WebRtcPlayEndpoint`]s by ID of [`MemberSpec`]. + pub fn get_play_endpoint_by_member_id( &self, src: &str, ) -> Vec { @@ -54,6 +61,7 @@ impl MemberSpec { .collect() } + /// Get all [`WebRtcPublishEndpoint`]s of this [`MemberSpec`]. pub fn get_publish_endpoints(&self) -> Vec { self.0 .pipeline diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index 456ff5733..52aac3788 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -19,6 +19,8 @@ use self::{ pub use self::member::{Id as MemberId, Member}; +/// Errors that can occur when we try transform some spec from [`Entity`]. +/// This error used in all [`TryFrom`] of Control API. #[derive(Debug, Fail)] pub enum TryFromEntityError { #[fail(display = "This entity is not Element")] @@ -29,17 +31,29 @@ pub enum TryFromEntityError { NotMember, } +/// Entity for parsing Control API request. #[derive(Clone, Deserialize, Debug)] #[serde(tag = "kind")] pub enum Entity { + /// Represent [`RoomSpec`]. + /// Can transform into [`RoomSpec`] by `RoomSpec::try_from`. Room { id: u64, spec: Pipeline }, + + /// Represent [`MemberSpec`]. + /// Can transform into [`MemberSpec`] by `MemberSpec::try_from`. Member { spec: Pipeline }, + + /// Represent [`WebRtcPublishEndpoint`]. + /// Can transform into [`Element`] enum by `Element::try_from`. WebRtcPublishEndpoint { spec: WebRtcPublishEndpoint }, + + /// Represent [`WebRtcPlayEndpoint`]. + /// Can transform into [`Element`] enum by `Element::try_from`. WebRtcPlayEndpoint { spec: WebRtcPlayEndpoint }, } /// Load [`RoomRequest`] from file with YAML format. -pub fn load_from_file(path: &str) -> Result { +pub fn load_from_yaml_file(path: &str) -> Result { let mut file = File::open(path)?; let mut buf = String::new(); file.read_to_string(&mut buf)?; diff --git a/src/api/control/pipeline.rs b/src/api/control/pipeline.rs index 98d69127c..bb6f03306 100644 --- a/src/api/control/pipeline.rs +++ b/src/api/control/pipeline.rs @@ -1,8 +1,11 @@ +//! Control API specification Pipeline definition. + use crate::api::control::Entity; use serde::Deserialize; use std::collections::HashMap; +/// Entity that represents some pipeline of spec. #[derive(Clone, Deserialize, Debug)] pub struct Pipeline { pub pipeline: HashMap, diff --git a/src/api/control/room.rs b/src/api/control/room.rs index f621b17aa..c107a9872 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -8,12 +8,20 @@ use super::{ use crate::signalling::RoomId; +/// Control API [`Room`] specification. +/// Newtype for [`Entity::Room`] #[derive(Clone, Debug)] pub struct RoomSpec { pub id: RoomId, pub spec: Pipeline, } + impl RoomSpec { + /// Try to find [`MemberSpec`] by ID. + /// + /// Return `None` if [`MemberSpec`] not presented in [`RoomSpec`]. + /// Return `Some(TryFromEntityError::NotMember)` if entity with this ID + /// finded but its not [`MemberSpec`]. pub fn get_member( &self, id: &str, diff --git a/src/main.rs b/src/main.rs index 75abe2af8..fb3cef57d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,7 +13,7 @@ use dotenv::dotenv; use log::prelude::*; use crate::{ - api::{client::server, control::load_from_file}, + api::{client::server, control::load_from_yaml_file}, conf::Conf, signalling::{room_repo::RoomsRepository, Room}, }; @@ -29,7 +29,7 @@ fn main() { let config = Conf::parse().unwrap(); info!("{:?}", config); - let room_spec = load_from_file("room_spec.yml").unwrap(); + let room_spec = load_from_yaml_file("room_spec.yml").unwrap(); // println!("{:#?}", room_spec); diff --git a/src/media/peer.rs b/src/media/peer.rs index 26de5f040..5d121083a 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -255,6 +255,7 @@ impl Peer { }) } + /// Returns all senders [`MediaTrack`]. pub fn get_senders(&self) -> Vec> { self.context .senders diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 52980e60d..456270693 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -49,10 +49,11 @@ pub struct ParticipantService { /// before dropping it irrevocably in case it gets reestablished. drop_connection_tasks: HashMap, - // TODO: Need rename + /// Stores relation between ID of [`MemberSpec`] and ID of signalling [`Member`]. control_signalling_members: HashMap, - members_awaiting_connection: HashMap, + /// Stores [`NewPeer`] which wait connection of another [`Member`]. + members_awaiting_connection: HashMap, } impl ParticipantService { @@ -152,6 +153,9 @@ impl ParticipantService { } } + /// Create [`Peer`]s between waiting [`Member`] and connected. + /// + /// Return control ID of waiting [`MemberSpec`]. fn connect_waiting_if_exist( &self, member: Member, @@ -180,7 +184,8 @@ impl ParticipantService { added_member } - fn connect_peers_of_member( + /// Interconnect [`Peer`]s of members based on [`MemberSpec`]. + fn create_and_interconnect_members_peers( &mut self, ctx: &mut Context, member_id: MemberId, @@ -258,6 +263,7 @@ impl ParticipantService { /// Stores provided [`RpcConnection`] for given [`Member`] in the [`Room`]. /// If [`Member`] already has any other [`RpcConnection`], /// then it will be closed. + /// Create and interconnect all necessary [`Member`]'s [`Peer`]. pub fn connection_established( &mut self, ctx: &mut Context, @@ -277,8 +283,8 @@ impl ParticipantService { ctx.spawn(wrap_future(connection.close())); } else { debug!("Connected member: {}", member_id); - - self.connect_peers_of_member(ctx, member_id); + + self.create_and_interconnect_members_peers(ctx, member_id); self.connections.insert(member_id, con); } diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index 5f6695abd..37b23aa9c 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -19,9 +19,12 @@ use std::sync::Arc; pub struct PeerRepository { /// [`Peer`]s of [`Member`]s in this [`Room`]. peers: HashMap, - waiting_members: HashMap, + + /// Count of [`Peer`]s in this [`Room`]. peers_count: u64, - last_track_id: u64, + + /// Count of [`MediaTrack`]s in this [`Room`]. + tracks_count: u64, } impl PeerRepository { @@ -40,18 +43,7 @@ impl PeerRepository { .ok_or_else(|| RoomError::PeerNotFound(peer_id)) } - pub fn add_waiter_member(&mut self, id: MemberId, peer: NewPeer) { - self.waiting_members.insert(id, peer); - } - - pub fn get_waiting_member_peer(&self, id: MemberId) -> Option { - self.waiting_members.get(&id).cloned() - } - - pub fn connect_waiting_member(&self, member: &Member) { - // TODO - } - + /// Create and interconnect [`Peer`]s based on [`MemberSpec`]. pub fn create_peers( &mut self, caller: NewPeer, @@ -77,11 +69,11 @@ impl PeerRepository { caller_peer.add_publish_endpoints( caller.spec.get_publish_endpoints(), - &mut self.last_track_id, + &mut self.tracks_count, ); responder_peer.add_publish_endpoints( responder.spec.get_publish_endpoints(), - &mut self.last_track_id, + &mut self.tracks_count, ); for endpoint in caller.spec.get_play_endpoints().into_iter() { if responder.control_id == endpoint.src.member_id { @@ -164,9 +156,8 @@ impl From> for PeerRepository { fn from(map: HashMap) -> Self { Self { peers: map, - waiting_members: HashMap::new(), peers_count: 0, - last_track_id: 0, + tracks_count: 0, } } } diff --git a/src/signalling/room.rs b/src/signalling/room.rs index d273740aa..11385c505 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -74,16 +74,13 @@ pub struct Room { /// [`Peer`]s of [`Member`]s in this [`Room`]. peers: PeerRepository, - // TODO: Add docs + /// This [`Room`]'s control API specification. spec: RoomSpec, - - peers_count: u64, } impl Room { /// Create new instance of [`Room`]. pub fn new(room: RoomSpec, reconnect_timeout: Duration) -> Self { - // TODO: Rewrite it only with iterator let mut members = HashMap::new(); let mut control_signalling_members = HashMap::new(); // TODO: rename room.spec.pipeline.iter().enumerate().for_each( @@ -112,8 +109,6 @@ impl Room { reconnect_timeout, ), spec: room, - // control_signalling_members - peers_count: 0, } } @@ -342,6 +337,7 @@ pub struct CreatePeer { impl Handler for Room { type Result = Result<(), ()>; + /// Create [`Peer`] between members and interconnect it by control API spec. fn handle( &mut self, msg: CreatePeer, @@ -416,6 +412,7 @@ impl Handler for Room { /// Saves new [`RpcConnection`] in [`ParticipantService`], initiates media /// establishment between members. + /// Create and interconnect all necessary [`Member`]'s [`Peer`]. fn handle( &mut self, msg: RpcConnectionEstablished, @@ -486,7 +483,7 @@ mod test { use super::*; fn start_room() -> Addr { - let room_spec = control::load_from_file("room_spec_test.yml").unwrap(); + let room_spec = control::load_from_yaml_file("room_spec_test.yml").unwrap(); let client_room = Room::new(room_spec, Duration::from_secs(10)); Arbiter::start(move |_| client_room) } @@ -521,10 +518,10 @@ mod test { }); }); - println!( - "\n\n===RESPONDER===\n{:?}\n\n===CALLER===\n{:?}\n\n\n", - responder_events, caller_events - ); +// println!( +// "\n\n===RESPONDER===\n{:?}\n\n===CALLER===\n{:?}\n\n\n", +// responder_events, caller_events +// ); let caller_events = caller_events.lock().unwrap(); let responder_events = responder_events.lock().unwrap(); From e6e7bb84d2a198d184949d3050896bf4e0592a42 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 24 May 2019 14:56:59 +0300 Subject: [PATCH 025/735] Fix warnings --- src/media/peer.rs | 4 ++-- src/signalling/participants.rs | 2 +- src/signalling/peers.rs | 4 ---- src/signalling/room.rs | 4 +--- 4 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/media/peer.rs b/src/media/peer.rs index 5d121083a..ff6ab8096 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -260,7 +260,7 @@ impl Peer { self.context .senders .iter() - .map(|(key, value)| value) + .map(|(_key, value)| value) .cloned() .collect() } @@ -299,7 +299,7 @@ impl Peer { endpoints: Vec, last_track_id: &mut u64, ) { - for endpoint in endpoints.into_iter() { + for _endpoint in endpoints.into_iter() { *last_track_id += 1; let track_audio = Arc::new(MediaTrack::new( *last_track_id, diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 456270693..1831b46ba 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -200,7 +200,7 @@ impl ParticipantService { let connected_member_play_endpoints = connected_member.spec.get_play_endpoints(); - let mut added_member = + let added_member = self.connect_waiting_if_exist(connected_member.clone(), ctx); self.members_awaiting_connection.remove(&member_id); diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index 37b23aa9c..90976e15f 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -4,16 +4,12 @@ use hashbrown::HashMap; use std::convert::{TryFrom, TryInto}; -use crate::api::control::Member; -use crate::media::MediaTrack; use crate::signalling::room::NewPeer; use crate::{ api::control::MemberId, media::{Peer, PeerId, PeerStateMachine}, signalling::room::RoomError, }; -use medea_client_api_proto::{AudioSettings, MediaType, VideoSettings}; -use std::sync::Arc; #[derive(Debug)] pub struct PeerRepository { diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 11385c505..584678148 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -9,14 +9,13 @@ use failure::Fail; use futures::future; use hashbrown::HashMap; use medea_client_api_proto::{ - AudioSettings, Command, Event, IceCandidate, MediaType, VideoSettings, + Command, Event, IceCandidate, }; use std::time::Duration; use crate::api::control::member::MemberSpec; use crate::api::control::room::RoomSpec; -use crate::media::MediaTrack; use crate::signalling::RoomId; use crate::{ api::{ @@ -34,7 +33,6 @@ use crate::{ signalling::{participants::ParticipantService, peers::PeerRepository}, }; use std::convert::TryFrom; -use std::sync::Arc; /// ID of [`Room`]. pub type Id = u64; From 52640cc4a2dce3ef65ccc5203c511bef1cdd629e Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 24 May 2019 15:02:37 +0300 Subject: [PATCH 026/735] Fmt --- src/api/client/server.rs | 5 +++-- src/api/control/element.rs | 7 +++++-- src/api/control/member.rs | 1 + src/api/control/mod.rs | 4 ++-- src/api/control/pipeline.rs | 1 + src/media/peer.rs | 3 +-- src/signalling/participants.rs | 3 ++- src/signalling/peers.rs | 3 +-- src/signalling/room.rs | 27 ++++++++++++--------------- 9 files changed, 28 insertions(+), 26 deletions(-) diff --git a/src/api/client/server.rs b/src/api/client/server.rs index a75df23b0..c3e3a05e3 100644 --- a/src/api/client/server.rs +++ b/src/api/client/server.rs @@ -109,16 +109,17 @@ mod test { use futures::Stream; use crate::{ + api::control, conf::{Conf, Server}, signalling::Room, }; use super::*; - use crate::api::control; /// Creates [`RoomsRepository`] for tests filled with a single [`Room`]. fn room(conf: Rpc) -> RoomsRepository { - let room_spec = control::load_from_yaml_file("room_spec_test.yml").unwrap(); + let room_spec = + control::load_from_yaml_file("room_spec_test.yml").unwrap(); let client_room = Room::new(room_spec, conf.reconnect_timeout); let room_id = client_room.get_id(); diff --git a/src/api/control/element.rs b/src/api/control/element.rs index 19a2d942b..649027ff5 100644 --- a/src/api/control/element.rs +++ b/src/api/control/element.rs @@ -6,9 +6,11 @@ use serde::{ de::{self, Deserializer, Error, Visitor}, Deserialize, }; + use std::{convert::TryFrom, fmt}; -/// [`Element`] represents a media element that one or more media data streams flow through. +/// [`Element`] represents a media element that one or more media data streams +/// flow through. #[derive(Debug)] pub enum Element { WebRtcPublishEndpoint(WebRtcPublishEndpoint), @@ -38,7 +40,8 @@ pub enum P2pMode { } #[derive(Deserialize, Debug, Clone)] -/// Media element which is able to publish media data for another client via WebRTC. +/// Media element which is able to publish media data for another client via +/// WebRTC. pub struct WebRtcPublishEndpoint { /// Peer-to-peer mode. pub p2p: P2pMode, diff --git a/src/api/control/member.rs b/src/api/control/member.rs index 34817e605..82da7e29e 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -3,6 +3,7 @@ use std::convert::TryFrom; use super::{element::Element, pipeline::Pipeline, Entity, TryFromEntityError}; + use crate::api::control::element::{WebRtcPlayEndpoint, WebRtcPublishEndpoint}; pub type Id = u64; diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index 52aac3788..205539f9f 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -6,9 +6,9 @@ pub mod room; mod pipeline; -use failure::Error; -use failure::Fail; +use failure::{Error, Fail}; use serde::Deserialize; + use std::{convert::TryFrom as _, fs::File, io::Read as _}; use self::{ diff --git a/src/api/control/pipeline.rs b/src/api/control/pipeline.rs index bb6f03306..d390883f2 100644 --- a/src/api/control/pipeline.rs +++ b/src/api/control/pipeline.rs @@ -3,6 +3,7 @@ use crate::api::control::Entity; use serde::Deserialize; + use std::collections::HashMap; /// Entity that represents some pipeline of spec. diff --git a/src/media/peer.rs b/src/media/peer.rs index ff6ab8096..efa3102bc 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -11,9 +11,8 @@ use medea_client_api_proto::{ use std::{convert::TryFrom, fmt::Display, sync::Arc}; -use crate::api::control::element::WebRtcPublishEndpoint; use crate::{ - api::control::MemberId, + api::control::{element::WebRtcPublishEndpoint, MemberId}, media::{MediaTrack, TrackId}, }; diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 1831b46ba..824b8eb02 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -49,7 +49,8 @@ pub struct ParticipantService { /// before dropping it irrevocably in case it gets reestablished. drop_connection_tasks: HashMap, - /// Stores relation between ID of [`MemberSpec`] and ID of signalling [`Member`]. + /// Stores relation between ID of [`MemberSpec`] and ID of signalling + /// [`Member`]. control_signalling_members: HashMap, /// Stores [`NewPeer`] which wait connection of another [`Member`]. diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index 90976e15f..205c94097 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -4,11 +4,10 @@ use hashbrown::HashMap; use std::convert::{TryFrom, TryInto}; -use crate::signalling::room::NewPeer; use crate::{ api::control::MemberId, media::{Peer, PeerId, PeerStateMachine}, - signalling::room::RoomError, + signalling::room::{NewPeer, RoomError}, }; #[derive(Debug)] diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 584678148..e13b4d045 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -8,31 +8,27 @@ use actix::{ use failure::Fail; use futures::future; use hashbrown::HashMap; -use medea_client_api_proto::{ - Command, Event, IceCandidate, -}; +use medea_client_api_proto::{Command, Event, IceCandidate}; -use std::time::Duration; +use std::{convert::TryFrom, time::Duration}; -use crate::api::control::member::MemberSpec; -use crate::api::control::room::RoomSpec; -use crate::signalling::RoomId; use crate::{ api::{ client::rpc_connection::{ AuthorizationError, Authorize, CommandMessage, RpcConnectionClosed, RpcConnectionEstablished, }, - control::{Member, MemberId}, + control::{member::MemberSpec, room::RoomSpec, Member, MemberId}, }, log::prelude::*, media::{ New, Peer, PeerId, PeerStateError, PeerStateMachine, WaitLocalHaveRemote, WaitLocalSdp, WaitRemoteSdp, }, - signalling::{participants::ParticipantService, peers::PeerRepository}, + signalling::{ + participants::ParticipantService, peers::PeerRepository, RoomId, + }, }; -use std::convert::TryFrom; /// ID of [`Room`]. pub type Id = u64; @@ -481,7 +477,8 @@ mod test { use super::*; fn start_room() -> Addr { - let room_spec = control::load_from_yaml_file("room_spec_test.yml").unwrap(); + let room_spec = + control::load_from_yaml_file("room_spec_test.yml").unwrap(); let client_room = Room::new(room_spec, Duration::from_secs(10)); Arbiter::start(move |_| client_room) } @@ -516,10 +513,10 @@ mod test { }); }); -// println!( -// "\n\n===RESPONDER===\n{:?}\n\n===CALLER===\n{:?}\n\n\n", -// responder_events, caller_events -// ); + // println!( + // "\n\n===RESPONDER===\n{:?}\n\n===CALLER===\n{:?}\n\n\n", + // responder_events, caller_events + // ); let caller_events = caller_events.lock().unwrap(); let responder_events = responder_events.lock().unwrap(); From a96e1f7a615a1b0c39834004dba9f67590979518 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 24 May 2019 15:05:03 +0300 Subject: [PATCH 027/735] Refactor --- src/signalling/peers.rs | 1 - src/signalling/room.rs | 8 +++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index 205c94097..cedd28b5a 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -91,7 +91,6 @@ impl PeerRepository { self.add_peer(caller_peer_id, caller_peer); self.add_peer(responder_peer_id, responder_peer); - // TODO: remove this // println!("Peers: {:#?}", self.peers); (caller_peer_id, responder_peer_id) diff --git a/src/signalling/room.rs b/src/signalling/room.rs index e13b4d045..83bf9a80b 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -76,7 +76,7 @@ impl Room { /// Create new instance of [`Room`]. pub fn new(room: RoomSpec, reconnect_timeout: Duration) -> Self { let mut members = HashMap::new(); - let mut control_signalling_members = HashMap::new(); // TODO: rename + let mut control_signalling_members = HashMap::new(); room.spec.pipeline.iter().enumerate().for_each( |(i, (control_id, value))| { let id = (i as u64) + 1; @@ -337,8 +337,7 @@ impl Handler for Room { msg: CreatePeer, ctx: &mut Self::Context, ) -> Self::Result { - // TODO: Think about usefulness - info!( + debug!( "Created peer member {} with member {}", msg.caller.signalling_id, msg.responder.signalling_id ); @@ -348,8 +347,7 @@ impl Handler for Room { ctx.notify(ConnectPeers(caller_peer_id, responder_peer_id)); - // TODO: remove this - println!("Peers: {:#?}", self.peers); +// println!("Peers: {:#?}", self.peers); Ok(()) } From 31f1b09d081059e03e43d0ce58880e4e537cadb1 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 24 May 2019 15:15:15 +0300 Subject: [PATCH 028/735] Move NewPeer into peer.rs --- src/media/mod.rs | 1 + src/media/peer.rs | 9 ++++++++- src/signalling/participants.rs | 3 ++- src/signalling/peers.rs | 4 ++-- src/signalling/room.rs | 10 +--------- 5 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/media/mod.rs b/src/media/mod.rs index 3d7e8a4df..1c71fd914 100644 --- a/src/media/mod.rs +++ b/src/media/mod.rs @@ -6,6 +6,7 @@ pub use self::{ peer::{ create_peers, Id as PeerId, New, Peer, PeerStateError, PeerStateMachine, WaitLocalHaveRemote, WaitLocalSdp, WaitRemoteSdp, + NewPeer, }, track::{Id as TrackId, MediaTrack}, }; diff --git a/src/media/peer.rs b/src/media/peer.rs index efa3102bc..a7b4644c6 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -12,7 +12,7 @@ use medea_client_api_proto::{ use std::{convert::TryFrom, fmt::Display, sync::Arc}; use crate::{ - api::control::{element::WebRtcPublishEndpoint, MemberId}, + api::control::{element::WebRtcPublishEndpoint, MemberId, member::MemberSpec}, media::{MediaTrack, TrackId}, }; @@ -269,6 +269,13 @@ impl Peer { } } +#[derive(Debug, Clone)] +pub struct NewPeer { + pub signalling_id: u64, + pub spec: MemberSpec, + pub control_id: String, +} + impl Peer { /// Creates new [`Peer`] for [`Member`]. pub fn new( diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 824b8eb02..f748140b9 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -20,9 +20,10 @@ use crate::{ }, control::{Member, MemberId}, }, + media::NewPeer, log::prelude::*, signalling::{ - room::{CloseRoom, CreatePeer, NewPeer, RoomError}, + room::{CloseRoom, CreatePeer, RoomError}, Room, }, }; diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index cedd28b5a..4cf146143 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -6,8 +6,8 @@ use std::convert::{TryFrom, TryInto}; use crate::{ api::control::MemberId, - media::{Peer, PeerId, PeerStateMachine}, - signalling::room::{NewPeer, RoomError}, + media::{Peer, PeerId, PeerStateMachine, NewPeer}, + signalling::room::RoomError, }; #[derive(Debug)] diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 83bf9a80b..39d3bd572 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -23,7 +23,7 @@ use crate::{ log::prelude::*, media::{ New, Peer, PeerId, PeerStateError, PeerStateMachine, - WaitLocalHaveRemote, WaitLocalSdp, WaitRemoteSdp, + WaitLocalHaveRemote, WaitLocalSdp, WaitRemoteSdp, NewPeer, }, signalling::{ participants::ParticipantService, peers::PeerRepository, RoomId, @@ -313,14 +313,6 @@ impl Handler for Room { } } -// TODO: Move into peers.rs -#[derive(Debug, Clone)] -pub struct NewPeer { - pub signalling_id: u64, - pub spec: MemberSpec, - pub control_id: String, -} - #[derive(Debug, Message)] #[rtype(result = "Result<(), ()>")] pub struct CreatePeer { From 741b71afdd5560a099ea6206deef7895840d9280 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 24 May 2019 15:26:33 +0300 Subject: [PATCH 029/735] Remove create media::peer::create_peers --- src/api/control/room.rs | 2 +- src/media/mod.rs | 2 +- src/media/peer.rs | 27 --------------------------- 3 files changed, 2 insertions(+), 29 deletions(-) diff --git a/src/api/control/room.rs b/src/api/control/room.rs index c107a9872..13779bbb2 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -8,7 +8,7 @@ use super::{ use crate::signalling::RoomId; -/// Control API [`Room`] specification. +/// [`crate::signalling::room::Room`] specification. /// Newtype for [`Entity::Room`] #[derive(Clone, Debug)] pub struct RoomSpec { diff --git a/src/media/mod.rs b/src/media/mod.rs index 1c71fd914..53d6c8d64 100644 --- a/src/media/mod.rs +++ b/src/media/mod.rs @@ -4,7 +4,7 @@ pub mod track; pub use self::{ peer::{ - create_peers, Id as PeerId, New, Peer, PeerStateError, + Id as PeerId, New, Peer, PeerStateError, PeerStateMachine, WaitLocalHaveRemote, WaitLocalSdp, WaitRemoteSdp, NewPeer, }, diff --git a/src/media/peer.rs b/src/media/peer.rs index a7b4644c6..90384d205 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -391,33 +391,6 @@ impl Peer { } } -// TODO: remove it -pub fn create_peers( - caller: MemberId, - responder: MemberId, -) -> HashMap { - let caller_peer_id = 1; - let responder_peer_id = 2; - let mut caller_peer = - Peer::new(caller_peer_id, caller, responder_peer_id, responder_peer_id); - let mut responder_peer = - Peer::new(responder_peer_id, responder, caller_peer_id, caller_peer_id); - - let track_audio = - Arc::new(MediaTrack::new(1, MediaType::Audio(AudioSettings {}))); - let track_video = - Arc::new(MediaTrack::new(2, MediaType::Video(VideoSettings {}))); - caller_peer.add_sender(track_audio.clone()); - caller_peer.add_sender(track_video.clone()); - responder_peer.add_receiver(track_audio); - responder_peer.add_receiver(track_video); - - hashmap!( - caller_peer_id => PeerStateMachine::New(caller_peer), - responder_peer_id => PeerStateMachine::New(responder_peer), - ) -} - #[test] fn create_peer() { let peer = Peer::new(1, 1, 2, 2); From 37aebde0e5ceefe32d3de9ba3862159725a608aa Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 24 May 2019 15:53:18 +0300 Subject: [PATCH 030/735] Fix unit test --- src/signalling/room.rs | 142 ++++++++++++++++++++--------------------- 1 file changed, 69 insertions(+), 73 deletions(-) diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 39d3bd572..6769ca77d 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -472,11 +472,7 @@ mod test { let client_room = Room::new(room_spec, Duration::from_secs(10)); Arbiter::start(move |_| client_room) } - - // TODO: Fix this test. - // This test sometimes fails due to racing connections. - // When the second user connects first, and the first user - // follows him, their events are swapped. + #[test] fn start_signaling() { let stopped = Arc::new(AtomicUsize::new(0)); @@ -503,80 +499,80 @@ mod test { }); }); - // println!( - // "\n\n===RESPONDER===\n{:?}\n\n===CALLER===\n{:?}\n\n\n", - // responder_events, caller_events - // ); - let caller_events = caller_events.lock().unwrap(); let responder_events = responder_events.lock().unwrap(); - assert_eq!( - caller_events.to_vec(), - vec![ - serde_json::to_string(&Event::PeerCreated { - peer_id: 1, - sdp_offer: None, - tracks: vec![ - Track { - id: 1, - direction: Direction::Send { receivers: vec![2] }, - media_type: MediaType::Audio(AudioSettings {}), - }, - Track { - id: 2, - direction: Direction::Send { receivers: vec![2] }, - media_type: MediaType::Video(VideoSettings {}), - }, - ], - }) - .unwrap(), - serde_json::to_string(&Event::SdpAnswerMade { - peer_id: 1, - sdp_answer: "responder_answer".into(), - }) - .unwrap(), - serde_json::to_string(&Event::IceCandidateDiscovered { - peer_id: 1, - candidate: IceCandidate { - candidate: "ice_candidate".to_owned(), - sdp_m_line_index: None, - sdp_mid: None + + let first_connected_member_events = vec![ + serde_json::to_string(&Event::PeerCreated { + peer_id: 1, + sdp_offer: None, + tracks: vec![ + Track { + id: 1, + direction: Direction::Send { receivers: vec![2] }, + media_type: MediaType::Audio(AudioSettings {}), }, - }) + Track { + id: 2, + direction: Direction::Send { receivers: vec![2] }, + media_type: MediaType::Video(VideoSettings {}), + }, + ], + }) .unwrap(), - ] - ); - - assert_eq!( - responder_events.to_vec(), - vec![ - serde_json::to_string(&Event::PeerCreated { - peer_id: 2, - sdp_offer: Some("caller_offer".into()), - tracks: vec![ - Track { - id: 1, - direction: Direction::Recv { sender: 1 }, - media_type: MediaType::Audio(AudioSettings {}), - }, - Track { - id: 2, - direction: Direction::Recv { sender: 1 }, - media_type: MediaType::Video(VideoSettings {}), - }, - ], - }) + serde_json::to_string(&Event::SdpAnswerMade { + peer_id: 1, + sdp_answer: "responder_answer".into(), + }) + .unwrap(), + serde_json::to_string(&Event::IceCandidateDiscovered { + peer_id: 1, + candidate: IceCandidate { + candidate: "ice_candidate".to_owned(), + sdp_m_line_index: None, + sdp_mid: None + }, + }) .unwrap(), - serde_json::to_string(&Event::IceCandidateDiscovered { - peer_id: 2, - candidate: IceCandidate { - candidate: "ice_candidate".to_owned(), - sdp_m_line_index: None, - sdp_mid: None + ]; + let second_connected_member_events = vec![ + serde_json::to_string(&Event::PeerCreated { + peer_id: 2, + sdp_offer: Some("caller_offer".into()), + tracks: vec![ + Track { + id: 1, + direction: Direction::Recv { sender: 1 }, + media_type: MediaType::Audio(AudioSettings {}), }, - }) + Track { + id: 2, + direction: Direction::Recv { sender: 1 }, + media_type: MediaType::Video(VideoSettings {}), + }, + ], + }) .unwrap(), - ] - ); + serde_json::to_string(&Event::IceCandidateDiscovered { + peer_id: 2, + candidate: IceCandidate { + candidate: "ice_candidate".to_owned(), + sdp_m_line_index: None, + sdp_mid: None + }, + }) + .unwrap(), + ]; + + let caller_events = caller_events.to_vec(); + let responder_events = responder_events.to_vec(); + + if caller_events != first_connected_member_events { + assert_eq!(caller_events, second_connected_member_events); + } + + if responder_events != first_connected_member_events { + assert_eq!(responder_events, second_connected_member_events); + } } } From 12f3e2f7a6331d65bfcc9e5ec3efffe43fe49b7f Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 24 May 2019 16:35:55 +0300 Subject: [PATCH 031/735] Add local uri parsing unit test --- src/api/control/element.rs | 52 +++++++++++++++++++++++++++++++++++--- 1 file changed, 49 insertions(+), 3 deletions(-) diff --git a/src/api/control/element.rs b/src/api/control/element.rs index 649027ff5..059291de8 100644 --- a/src/api/control/element.rs +++ b/src/api/control/element.rs @@ -66,7 +66,6 @@ pub struct LocalUri { pub pipeline_id: String, } -// TODO: Write unit tests? /// Serde deserializer for [`LocalUri`]. /// Deserialize URIs with pattern `local://{room_id}/{member_id}/{pipeline_id}. impl<'de> Deserialize<'de> for LocalUri { @@ -85,8 +84,6 @@ impl<'de> Deserialize<'de> for LocalUri { ) } - // TODO: Return error with information about place where this error - // happened. fn visit_str(self, value: &str) -> Result where E: de::Error, @@ -139,3 +136,52 @@ impl<'de> Deserialize<'de> for LocalUri { deserializer.deserialize_identifier(LocalUriVisitor) } } + +#[cfg(test)] +mod test { + use serde::Deserialize; + + use super::*; + + #[derive(Deserialize)] + struct LocalUriTest { + src: LocalUri, + } + + #[test] + fn should_parse_local_uri() { + let valid_json_uri = "{ \"src\": \"local://room_id/member_id/pipeline_id\" }"; + let local_uri: LocalUriTest = serde_json::from_str(valid_json_uri).unwrap(); + + assert_eq!(local_uri.src.member_id, "member_id".to_string()); + assert_eq!(local_uri.src.room_id, "room_id".to_string()); + assert_eq!(local_uri.src.pipeline_id, "pipeline_id".to_string()); + } + + #[test] + fn should_return_error_when_uri_not_local() { + let invalid_json_uri = "{ \"src\": \"not_local://room_id/member_id/pipeline_id\" }"; + match serde_json::from_str::(invalid_json_uri) { + Ok(_) => assert!(false), + Err(_) => assert!(true), + } + } + + #[test] + fn should_return_error_when_uri_is_not_full() { + let invalid_json_uri = "{ \"src\": \"local://room_id/member_id\" } "; + match serde_json::from_str::(invalid_json_uri) { + Ok(_) => assert!(false), + Err(_) => assert!(true), + } + } + + #[test] + fn should_return_error_when_uri_have_empty_part() { + let invalid_json_uri = "{ \"src\": \"local://room_id//pipeline_id\" }"; + match serde_json::from_str::(invalid_json_uri) { + Ok(_) => assert!(false), + Err(_) => assert!(true), + } + } +} From 0d93761cad3b09b6cf10f7798cf6b17f8de6bb91 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 24 May 2019 16:53:44 +0300 Subject: [PATCH 032/735] Fmt --- src/api/control/element.rs | 15 +++++++++------ src/api/control/mod.rs | 2 +- src/media/mod.rs | 5 ++--- src/media/peer.rs | 4 +++- src/signalling/participants.rs | 4 ++-- src/signalling/peers.rs | 2 +- src/signalling/room.rs | 22 +++++++++++----------- 7 files changed, 29 insertions(+), 25 deletions(-) diff --git a/src/api/control/element.rs b/src/api/control/element.rs index 059291de8..52d748635 100644 --- a/src/api/control/element.rs +++ b/src/api/control/element.rs @@ -67,7 +67,7 @@ pub struct LocalUri { } /// Serde deserializer for [`LocalUri`]. -/// Deserialize URIs with pattern `local://{room_id}/{member_id}/{pipeline_id}. +/// Deserialize URIs with pattern `local://{room_id}/{member_id}/{pipeline_id}`. impl<'de> Deserialize<'de> for LocalUri { fn deserialize(deserializer: D) -> Result where @@ -150,8 +150,10 @@ mod test { #[test] fn should_parse_local_uri() { - let valid_json_uri = "{ \"src\": \"local://room_id/member_id/pipeline_id\" }"; - let local_uri: LocalUriTest = serde_json::from_str(valid_json_uri).unwrap(); + let valid_json_uri = + r#"{ "src": "local://room_id/member_id/pipeline_id" }"#; + let local_uri: LocalUriTest = + serde_json::from_str(valid_json_uri).unwrap(); assert_eq!(local_uri.src.member_id, "member_id".to_string()); assert_eq!(local_uri.src.room_id, "room_id".to_string()); @@ -160,7 +162,8 @@ mod test { #[test] fn should_return_error_when_uri_not_local() { - let invalid_json_uri = "{ \"src\": \"not_local://room_id/member_id/pipeline_id\" }"; + let invalid_json_uri = + r#"{ "src": "not_local://room_id/member_id/pipeline_id" }"#; match serde_json::from_str::(invalid_json_uri) { Ok(_) => assert!(false), Err(_) => assert!(true), @@ -169,7 +172,7 @@ mod test { #[test] fn should_return_error_when_uri_is_not_full() { - let invalid_json_uri = "{ \"src\": \"local://room_id/member_id\" } "; + let invalid_json_uri = r#"{ "src": "local://room_id/member_id" }"#; match serde_json::from_str::(invalid_json_uri) { Ok(_) => assert!(false), Err(_) => assert!(true), @@ -178,7 +181,7 @@ mod test { #[test] fn should_return_error_when_uri_have_empty_part() { - let invalid_json_uri = "{ \"src\": \"local://room_id//pipeline_id\" }"; + let invalid_json_uri = r#"{ "src": "local://room_id//pipeline_id" }"#; match serde_json::from_str::(invalid_json_uri) { Ok(_) => assert!(false), Err(_) => assert!(true), diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index 205539f9f..b7b3b4cee 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -52,7 +52,7 @@ pub enum Entity { WebRtcPlayEndpoint { spec: WebRtcPlayEndpoint }, } -/// Load [`RoomRequest`] from file with YAML format. +/// Load [`Entity`] from file with YAML format. pub fn load_from_yaml_file(path: &str) -> Result { let mut file = File::open(path)?; let mut buf = String::new(); diff --git a/src/media/mod.rs b/src/media/mod.rs index 53d6c8d64..727ad8026 100644 --- a/src/media/mod.rs +++ b/src/media/mod.rs @@ -4,9 +4,8 @@ pub mod track; pub use self::{ peer::{ - Id as PeerId, New, Peer, PeerStateError, - PeerStateMachine, WaitLocalHaveRemote, WaitLocalSdp, WaitRemoteSdp, - NewPeer, + Id as PeerId, New, NewPeer, Peer, PeerStateError, PeerStateMachine, + WaitLocalHaveRemote, WaitLocalSdp, WaitRemoteSdp, }, track::{Id as TrackId, MediaTrack}, }; diff --git a/src/media/peer.rs b/src/media/peer.rs index 90384d205..b5046c6c9 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -12,7 +12,9 @@ use medea_client_api_proto::{ use std::{convert::TryFrom, fmt::Display, sync::Arc}; use crate::{ - api::control::{element::WebRtcPublishEndpoint, MemberId, member::MemberSpec}, + api::control::{ + element::WebRtcPublishEndpoint, member::MemberSpec, MemberId, + }, media::{MediaTrack, TrackId}, }; diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index f748140b9..b158ba39d 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -20,8 +20,8 @@ use crate::{ }, control::{Member, MemberId}, }, - media::NewPeer, log::prelude::*, + media::NewPeer, signalling::{ room::{CloseRoom, CreatePeer, RoomError}, Room, @@ -157,7 +157,7 @@ impl ParticipantService { /// Create [`Peer`]s between waiting [`Member`] and connected. /// - /// Return control ID of waiting [`MemberSpec`]. + /// Returns control ID of waiting [`MemberSpec`] if there was one. fn connect_waiting_if_exist( &self, member: Member, diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index 4cf146143..6bdc94bfc 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -6,7 +6,7 @@ use std::convert::{TryFrom, TryInto}; use crate::{ api::control::MemberId, - media::{Peer, PeerId, PeerStateMachine, NewPeer}, + media::{NewPeer, Peer, PeerId, PeerStateMachine}, signalling::room::RoomError, }; diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 6769ca77d..cfd1ec797 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -22,8 +22,8 @@ use crate::{ }, log::prelude::*, media::{ - New, Peer, PeerId, PeerStateError, PeerStateMachine, - WaitLocalHaveRemote, WaitLocalSdp, WaitRemoteSdp, NewPeer, + New, NewPeer, Peer, PeerId, PeerStateError, PeerStateMachine, + WaitLocalHaveRemote, WaitLocalSdp, WaitRemoteSdp, }, signalling::{ participants::ParticipantService, peers::PeerRepository, RoomId, @@ -339,7 +339,7 @@ impl Handler for Room { ctx.notify(ConnectPeers(caller_peer_id, responder_peer_id)); -// println!("Peers: {:#?}", self.peers); + // println!("Peers: {:#?}", self.peers); Ok(()) } @@ -472,7 +472,7 @@ mod test { let client_room = Room::new(room_spec, Duration::from_secs(10)); Arbiter::start(move |_| client_room) } - + #[test] fn start_signaling() { let stopped = Arc::new(AtomicUsize::new(0)); @@ -519,21 +519,21 @@ mod test { }, ], }) - .unwrap(), + .unwrap(), serde_json::to_string(&Event::SdpAnswerMade { peer_id: 1, sdp_answer: "responder_answer".into(), }) - .unwrap(), + .unwrap(), serde_json::to_string(&Event::IceCandidateDiscovered { peer_id: 1, candidate: IceCandidate { candidate: "ice_candidate".to_owned(), sdp_m_line_index: None, - sdp_mid: None + sdp_mid: None, }, }) - .unwrap(), + .unwrap(), ]; let second_connected_member_events = vec![ serde_json::to_string(&Event::PeerCreated { @@ -552,16 +552,16 @@ mod test { }, ], }) - .unwrap(), + .unwrap(), serde_json::to_string(&Event::IceCandidateDiscovered { peer_id: 2, candidate: IceCandidate { candidate: "ice_candidate".to_owned(), sdp_m_line_index: None, - sdp_mid: None + sdp_mid: None, }, }) - .unwrap(), + .unwrap(), ]; let caller_events = caller_events.to_vec(); From b32054d31d9da6ad24b1c5ef30735082cbee9b61 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 24 May 2019 17:24:37 +0300 Subject: [PATCH 033/735] Replace unwrap with log message --- src/api/control/mod.rs | 3 +-- src/signalling/participants.rs | 13 +++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index b7b3b4cee..716f1cdb1 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -2,10 +2,9 @@ pub mod element; pub mod member; +pub mod pipeline; pub mod room; -mod pipeline; - use failure::{Error, Fail}; use serde::Deserialize; diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index b158ba39d..f4ba5dd53 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -239,6 +239,19 @@ impl ParticipantService { let is_responder_connected = self.member_has_connection(*responder_member_signalling_id); if is_responder_connected { + let responder_spec = + match self.members.get(&responder_member_signalling_id) { + Some(m) => m, + None => { + warn!( + "Try to get nonexistent member by signalling \ + id '{}'!", + responder_member_signalling_id + ); + continue; + } + }; + let responder_new_peer = NewPeer { signalling_id: *responder_member_signalling_id, spec: self From bf8c31855d2e3004ae582ec83eacafc15603f262 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 24 May 2019 17:53:11 +0300 Subject: [PATCH 034/735] Reduce clones --- src/api/control/member.rs | 14 ++++++-------- src/media/peer.rs | 4 ++-- src/signalling/participants.rs | 24 ++++++++++-------------- src/signalling/peers.rs | 2 ++ src/signalling/room.rs | 3 ++- 5 files changed, 22 insertions(+), 25 deletions(-) diff --git a/src/api/control/member.rs b/src/api/control/member.rs index 82da7e29e..c25a558e1 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -5,6 +5,7 @@ use std::convert::TryFrom; use super::{element::Element, pipeline::Pipeline, Entity, TryFromEntityError}; use crate::api::control::element::{WebRtcPlayEndpoint, WebRtcPublishEndpoint}; +use std::sync::Arc; pub type Id = u64; @@ -18,7 +19,7 @@ pub struct Member { pub credentials: String, /// Control API specification of this [`Member`]. - pub spec: MemberSpec, + pub spec: Arc, /// ID from Control API specification of this [`Member`]. pub control_id: String, @@ -38,7 +39,7 @@ impl MemberSpec { } /// Get all [`WebRtcPlayEndpoint`]s of this [`MemberSpec`]. - pub fn get_play_endpoints(&self) -> Vec { + pub fn get_play_endpoints(&self) -> Vec<&WebRtcPlayEndpoint> { self.0 .pipeline .iter() @@ -46,7 +47,6 @@ impl MemberSpec { Entity::WebRtcPlayEndpoint { spec } => Some(spec), _ => None, }) - .cloned() .collect() } @@ -54,16 +54,15 @@ impl MemberSpec { pub fn get_play_endpoint_by_member_id( &self, src: &str, - ) -> Vec { + ) -> Vec<&WebRtcPlayEndpoint> { self.get_play_endpoints() - .iter() + .into_iter() .filter(|endpoint| endpoint.src.member_id == src) - .cloned() .collect() } /// Get all [`WebRtcPublishEndpoint`]s of this [`MemberSpec`]. - pub fn get_publish_endpoints(&self) -> Vec { + pub fn get_publish_endpoints(&self) -> Vec<&WebRtcPublishEndpoint> { self.0 .pipeline .iter() @@ -71,7 +70,6 @@ impl MemberSpec { Entity::WebRtcPublishEndpoint { spec } => Some(spec), _ => None, }) - .cloned() .collect() } } diff --git a/src/media/peer.rs b/src/media/peer.rs index b5046c6c9..52ff339fa 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -274,7 +274,7 @@ impl Peer { #[derive(Debug, Clone)] pub struct NewPeer { pub signalling_id: u64, - pub spec: MemberSpec, + pub spec: Arc, pub control_id: String, } @@ -304,7 +304,7 @@ impl Peer { pub fn add_publish_endpoints( &mut self, - endpoints: Vec, + endpoints: Vec<&WebRtcPublishEndpoint>, last_track_id: &mut u64, ) { for _endpoint in endpoints.into_iter() { diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index f4ba5dd53..ec07b32eb 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -3,6 +3,7 @@ //! [`RpcConnection`] authorization, establishment, message sending. use std::time::{Duration, Instant}; +use std::sync::Arc; use actix::{fut::wrap_future, AsyncContext, Context, SpawnHandle}; use futures::{ @@ -168,12 +169,12 @@ impl ParticipantService { { added_member = Some(awaiter.control_id.clone()); let connected_new_peer = NewPeer { - control_id: member.control_id, + control_id: member.control_id.clone(), signalling_id: member.id, - spec: member.spec, + spec: Arc::clone(&member.spec), }; let awaiter_new_peer = NewPeer { - spec: awaiter.spec.clone(), + spec: Arc::clone(&awaiter.spec), control_id: awaiter.control_id.clone(), signalling_id: awaiter.signalling_id, }; @@ -214,10 +215,10 @@ impl ParticipantService { } let responder_member_control_id = - connected_member_endpoint.src.member_id; + &connected_member_endpoint.src.member_id; let responder_member_signalling_id = match self .control_signalling_members - .get(&responder_member_control_id) + .get(responder_member_control_id) { Some(r) => r, None => { @@ -232,7 +233,7 @@ impl ParticipantService { let connected_new_peer = NewPeer { signalling_id: connected_member.id, - spec: connected_member.spec.clone(), + spec: Arc::clone(&connected_member.spec), control_id: connected_member.control_id.clone(), }; @@ -241,7 +242,7 @@ impl ParticipantService { if is_responder_connected { let responder_spec = match self.members.get(&responder_member_signalling_id) { - Some(m) => m, + Some(m) => m.spec.clone(), None => { warn!( "Try to get nonexistent member by signalling \ @@ -254,13 +255,8 @@ impl ParticipantService { let responder_new_peer = NewPeer { signalling_id: *responder_member_signalling_id, - spec: self - .members - .get(&responder_member_signalling_id) - .unwrap() - .spec - .clone(), - control_id: responder_member_control_id, + spec: Arc::clone(&responder_spec), + control_id: responder_member_control_id.clone(), }; ctx.notify(CreatePeer { caller: responder_new_peer, diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index 6bdc94bfc..055358c4a 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -39,6 +39,8 @@ impl PeerRepository { } /// Create and interconnect [`Peer`]s based on [`MemberSpec`]. + /// + /// Returns IDs of created [`Peer`]s. `(caller_peer_id, responder_peer_id)`. pub fn create_peers( &mut self, caller: NewPeer, diff --git a/src/signalling/room.rs b/src/signalling/room.rs index cfd1ec797..ea66487c2 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -29,6 +29,7 @@ use crate::{ participants::ParticipantService, peers::PeerRepository, RoomId, }, }; +use std::sync::Arc; /// ID of [`Room`]. pub type Id = u64; @@ -85,7 +86,7 @@ impl Room { control_signalling_members.insert(control_id.clone(), id); let member = Member { id, - spec: member_spec, + spec: Arc::new(member_spec), credentials: format!("{}-credentials", id), control_id: control_id.clone(), }; From 7813c1bf0cc731fc0b7705385b6ba8dfd4987fe9 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 24 May 2019 18:52:31 +0300 Subject: [PATCH 035/735] Fix members_waiting_connection --- src/signalling/participants.rs | 73 ++++++++++++++++++---------------- 1 file changed, 39 insertions(+), 34 deletions(-) diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index ec07b32eb..7c3d2f347 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -55,8 +55,8 @@ pub struct ParticipantService { /// [`Member`]. control_signalling_members: HashMap, - /// Stores [`NewPeer`] which wait connection of another [`Member`]. - members_awaiting_connection: HashMap, + /// Stores [`NewPeer`]s which wait connection of another [`Member`]. + members_waiting_connection: HashMap>, } impl ParticipantService { @@ -71,7 +71,7 @@ impl ParticipantService { reconnect_timeout, drop_connection_tasks: HashMap::new(), control_signalling_members, - members_awaiting_connection: HashMap::new(), + members_waiting_connection: HashMap::new(), } } @@ -158,31 +158,33 @@ impl ParticipantService { /// Create [`Peer`]s between waiting [`Member`] and connected. /// - /// Returns control ID of waiting [`MemberSpec`] if there was one. - fn connect_waiting_if_exist( + /// Returns all control ID of members which we connected. + fn connect_waiting_members( &self, member: Member, ctx: &mut Context, - ) -> Option { - let mut added_member = None; - if let Some(awaiter) = self.members_awaiting_connection.get(&member.id) + ) -> Vec { + let mut added_member = Vec::new(); + if let Some(waiters) = self.members_waiting_connection.get(&member.id) { - added_member = Some(awaiter.control_id.clone()); - let connected_new_peer = NewPeer { - control_id: member.control_id.clone(), - signalling_id: member.id, - spec: Arc::clone(&member.spec), - }; - let awaiter_new_peer = NewPeer { - spec: Arc::clone(&awaiter.spec), - control_id: awaiter.control_id.clone(), - signalling_id: awaiter.signalling_id, - }; + for waiter in waiters { + added_member.push(waiter.control_id.clone()); + let connected_new_peer = NewPeer { + control_id: member.control_id.clone(), + signalling_id: member.id, + spec: Arc::clone(&member.spec), + }; + let waiter_new_peer = NewPeer { + spec: Arc::clone(&waiter.spec), + control_id: waiter.control_id.clone(), + signalling_id: waiter.signalling_id, + }; - ctx.notify(CreatePeer { - caller: connected_new_peer, - responder: awaiter_new_peer, - }); + ctx.notify(CreatePeer { + caller: connected_new_peer, + responder: waiter_new_peer, + }); + } } added_member } @@ -203,15 +205,14 @@ impl ParticipantService { let connected_member_play_endpoints = connected_member.spec.get_play_endpoints(); - let added_member = - self.connect_waiting_if_exist(connected_member.clone(), ctx); - self.members_awaiting_connection.remove(&member_id); + let added_waiting_members = + self.connect_waiting_members(connected_member.clone(), ctx); + self.members_waiting_connection.remove(&member_id); for connected_member_endpoint in connected_member_play_endpoints { - if let Some(ref c) = added_member { - if &connected_member_endpoint.src.member_id == c { - continue; - } + // Skip members which waiting for us because we added them before. + if added_waiting_members.contains(&connected_member_endpoint.src.member_id) { + continue; } let responder_member_control_id = @@ -263,10 +264,14 @@ impl ParticipantService { responder: connected_new_peer, }); } else { - self.members_awaiting_connection.insert( - *responder_member_signalling_id, - connected_new_peer, - ); + match self.members_waiting_connection.get_mut(responder_member_signalling_id) { + Some(m) => { + m.push(connected_new_peer); + }, + None => { + self.members_waiting_connection.insert(*responder_member_signalling_id, vec![connected_new_peer]); + }, + } } } } From 92be60ca5719268036d8a9ebfc877a6f6fc7fd9e Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 24 May 2019 19:19:00 +0300 Subject: [PATCH 036/735] Fmt --- src/api/control/element.rs | 4 ++-- src/api/control/member.rs | 6 ++++-- src/api/control/pipeline.rs | 4 ++-- src/api/control/room.rs | 4 ++-- src/signalling/participants.rs | 6 ++++-- src/signalling/room.rs | 3 +-- 6 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/api/control/element.rs b/src/api/control/element.rs index 52d748635..31f4d3f35 100644 --- a/src/api/control/element.rs +++ b/src/api/control/element.rs @@ -1,7 +1,5 @@ //! Control API specification Element definitions. -use super::{Entity, TryFromEntityError}; - use serde::{ de::{self, Deserializer, Error, Visitor}, Deserialize, @@ -9,6 +7,8 @@ use serde::{ use std::{convert::TryFrom, fmt}; +use super::{Entity, TryFromEntityError}; + /// [`Element`] represents a media element that one or more media data streams /// flow through. #[derive(Debug)] diff --git a/src/api/control/member.rs b/src/api/control/member.rs index c25a558e1..3f36621dc 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -1,11 +1,13 @@ //! Member definitions and implementations. -use std::convert::TryFrom; +use std::{ + convert::TryFrom, + sync::Arc, +}; use super::{element::Element, pipeline::Pipeline, Entity, TryFromEntityError}; use crate::api::control::element::{WebRtcPlayEndpoint, WebRtcPublishEndpoint}; -use std::sync::Arc; pub type Id = u64; diff --git a/src/api/control/pipeline.rs b/src/api/control/pipeline.rs index d390883f2..db9c7b2a2 100644 --- a/src/api/control/pipeline.rs +++ b/src/api/control/pipeline.rs @@ -1,11 +1,11 @@ //! Control API specification Pipeline definition. -use crate::api::control::Entity; - use serde::Deserialize; use std::collections::HashMap; +use crate::api::control::Entity; + /// Entity that represents some pipeline of spec. #[derive(Clone, Deserialize, Debug)] pub struct Pipeline { diff --git a/src/api/control/room.rs b/src/api/control/room.rs index 13779bbb2..f5c2fe8fa 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -2,12 +2,12 @@ use std::convert::TryFrom; +use crate::signalling::RoomId; + use super::{ member::MemberSpec, pipeline::Pipeline, Entity, TryFromEntityError, }; -use crate::signalling::RoomId; - /// [`crate::signalling::room::Room`] specification. /// Newtype for [`Entity::Room`] #[derive(Clone, Debug)] diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 7c3d2f347..3bf149e51 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -2,8 +2,10 @@ //! stores [`Members`] and associated [`RpcConnection`]s, handles //! [`RpcConnection`] authorization, establishment, message sending. -use std::time::{Duration, Instant}; -use std::sync::Arc; +use std::{ + time::{Duration, Instant}, + sync::Arc +}; use actix::{fut::wrap_future, AsyncContext, Context, SpawnHandle}; use futures::{ diff --git a/src/signalling/room.rs b/src/signalling/room.rs index ea66487c2..2e54ddf31 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -10,7 +10,7 @@ use futures::future; use hashbrown::HashMap; use medea_client_api_proto::{Command, Event, IceCandidate}; -use std::{convert::TryFrom, time::Duration}; +use std::{convert::TryFrom, time::Duration, sync::Arc}; use crate::{ api::{ @@ -29,7 +29,6 @@ use crate::{ participants::ParticipantService, peers::PeerRepository, RoomId, }, }; -use std::sync::Arc; /// ID of [`Room`]. pub type Id = u64; From 64e5dd9229f5411aadcd35a4152bde3e9f8f5e11 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 24 May 2019 19:44:46 +0300 Subject: [PATCH 037/735] Fix lint errors --- .clippy.toml | 2 +- src/api/control/element.rs | 2 +- src/api/control/member.rs | 8 ++-- src/api/control/mod.rs | 1 + src/api/control/room.rs | 3 +- src/media/peer.rs | 3 +- src/signalling/participants.rs | 82 +++++++++++++++++----------------- src/signalling/peers.rs | 8 ++-- src/signalling/room.rs | 4 +- 9 files changed, 56 insertions(+), 57 deletions(-) diff --git a/.clippy.toml b/.clippy.toml index 912185723..a2c16142f 100644 --- a/.clippy.toml +++ b/.clippy.toml @@ -8,5 +8,5 @@ doc-valid-idents = [ "IPv4", "IPv6", "JavaScript", "NaN", "NaNs", "OAuth", "OpenGL", "OpenSSH", "OpenSSL", "OpenStreetMap", "TrueType", "iOS", "macOS", "TeX", "LaTeX", "BibTeX", "BibLaTeX", "MinGW", - "WebSocket", + "WebSocket", "WebRTC", ] diff --git a/src/api/control/element.rs b/src/api/control/element.rs index 31f4d3f35..234d8a27f 100644 --- a/src/api/control/element.rs +++ b/src/api/control/element.rs @@ -69,7 +69,7 @@ pub struct LocalUri { /// Serde deserializer for [`LocalUri`]. /// Deserialize URIs with pattern `local://{room_id}/{member_id}/{pipeline_id}`. impl<'de> Deserialize<'de> for LocalUri { - fn deserialize(deserializer: D) -> Result + fn deserialize(deserializer: D) -> Result where D: Deserializer<'de>, { diff --git a/src/api/control/member.rs b/src/api/control/member.rs index 3f36621dc..1d91b95ea 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -1,9 +1,6 @@ //! Member definitions and implementations. -use std::{ - convert::TryFrom, - sync::Arc, -}; +use std::{convert::TryFrom, sync::Arc}; use super::{element::Element, pipeline::Pipeline, Entity, TryFromEntityError}; @@ -29,6 +26,7 @@ pub struct Member { /// Newtype for [`Entity::Member`] variant. #[derive(Clone, Debug)] +#[allow(clippy::module_name_repetitions)] pub struct MemberSpec(pub Pipeline); impl MemberSpec { @@ -81,7 +79,7 @@ impl TryFrom for MemberSpec { fn try_from(from: Entity) -> Result { match from { - Entity::Member { spec } => Ok(MemberSpec(spec)), + Entity::Member { spec } => Ok(Self(spec)), _ => Err(TryFromEntityError::NotMember), } } diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index 716f1cdb1..2b02e6f72 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -21,6 +21,7 @@ pub use self::member::{Id as MemberId, Member}; /// Errors that can occur when we try transform some spec from [`Entity`]. /// This error used in all [`TryFrom`] of Control API. #[derive(Debug, Fail)] +#[allow(clippy::pub_enum_variant_names)] pub enum TryFromEntityError { #[fail(display = "This entity is not Element")] NotElement, diff --git a/src/api/control/room.rs b/src/api/control/room.rs index f5c2fe8fa..a8a93ea08 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -11,6 +11,7 @@ use super::{ /// [`crate::signalling::room::Room`] specification. /// Newtype for [`Entity::Room`] #[derive(Clone, Debug)] +#[allow(clippy::module_name_repetitions)] pub struct RoomSpec { pub id: RoomId, pub spec: Pipeline, @@ -35,7 +36,7 @@ impl TryFrom for RoomSpec { fn try_from(from: Entity) -> Result { match from { - Entity::Room { id, spec } => Ok(RoomSpec { id, spec }), + Entity::Room { id, spec } => Ok(Self { id, spec }), _ => Err(TryFromEntityError::NotRoom), } } diff --git a/src/media/peer.rs b/src/media/peer.rs index 52ff339fa..63712987b 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -272,6 +272,7 @@ impl Peer { } #[derive(Debug, Clone)] +#[allow(clippy::module_name_repetitions)] pub struct NewPeer { pub signalling_id: u64, pub spec: Arc, @@ -307,7 +308,7 @@ impl Peer { endpoints: Vec<&WebRtcPublishEndpoint>, last_track_id: &mut u64, ) { - for _endpoint in endpoints.into_iter() { + for _endpoint in endpoints { *last_track_id += 1; let track_audio = Arc::new(MediaTrack::new( *last_track_id, diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 3bf149e51..81df82fad 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -3,8 +3,8 @@ //! [`RpcConnection`] authorization, establishment, message sending. use std::{ + sync::Arc, time::{Duration, Instant}, - sync::Arc }; use actix::{fut::wrap_future, AsyncContext, Context, SpawnHandle}; @@ -163,12 +163,11 @@ impl ParticipantService { /// Returns all control ID of members which we connected. fn connect_waiting_members( &self, - member: Member, + member: &Member, ctx: &mut Context, ) -> Vec { let mut added_member = Vec::new(); - if let Some(waiters) = self.members_waiting_connection.get(&member.id) - { + if let Some(waiters) = self.members_waiting_connection.get(&member.id) { for waiter in waiters { added_member.push(waiter.control_id.clone()); let connected_new_peer = NewPeer { @@ -197,41 +196,44 @@ impl ParticipantService { ctx: &mut Context, member_id: MemberId, ) { - let connected_member = match self.members.get(&member_id) { - Some(m) => m, - None => { - warn!("Connected a non-existent member with id {}!", member_id); - return; - } + let connected_member = if let Some(m) = self.members.get(&member_id) { + m + } else { + warn!("Connected a non-existent member with id {}!", member_id); + // Maybe better return error here? + return; }; let connected_member_play_endpoints = connected_member.spec.get_play_endpoints(); let added_waiting_members = - self.connect_waiting_members(connected_member.clone(), ctx); + self.connect_waiting_members(&connected_member, ctx); self.members_waiting_connection.remove(&member_id); for connected_member_endpoint in connected_member_play_endpoints { // Skip members which waiting for us because we added them before. - if added_waiting_members.contains(&connected_member_endpoint.src.member_id) { + if added_waiting_members + .contains(&connected_member_endpoint.src.member_id) + { continue; } let responder_member_control_id = &connected_member_endpoint.src.member_id; - let responder_member_signalling_id = match self + + let responder_member_signalling_id = if let Some(r) = self .control_signalling_members .get(responder_member_control_id) { - Some(r) => r, - None => { - warn!( - "Member with control id '{}' not found! Probably this \ - is error in spec.", - responder_member_control_id - ); - continue; - } + r + } else { + warn!( + "Member with control id '{}' not found! Probably this is \ + error in spec.", + responder_member_control_id + ); + // Maybe better return error here? + continue; }; let connected_new_peer = NewPeer { @@ -243,18 +245,13 @@ impl ParticipantService { let is_responder_connected = self.member_has_connection(*responder_member_signalling_id); if is_responder_connected { - let responder_spec = - match self.members.get(&responder_member_signalling_id) { - Some(m) => m.spec.clone(), - None => { - warn!( - "Try to get nonexistent member by signalling \ - id '{}'!", - responder_member_signalling_id - ); - continue; - } - }; + let responder_spec = if let Some(m) = + self.members.get(&responder_member_signalling_id) + { + m.spec.clone() + } else { + continue; + }; let responder_new_peer = NewPeer { signalling_id: *responder_member_signalling_id, @@ -265,15 +262,16 @@ impl ParticipantService { caller: responder_new_peer, responder: connected_new_peer, }); + } else if let Some(m) = self + .members_waiting_connection + .get_mut(responder_member_signalling_id) + { + m.push(connected_new_peer); } else { - match self.members_waiting_connection.get_mut(responder_member_signalling_id) { - Some(m) => { - m.push(connected_new_peer); - }, - None => { - self.members_waiting_connection.insert(*responder_member_signalling_id, vec![connected_new_peer]); - }, - } + self.members_waiting_connection.insert( + *responder_member_signalling_id, + vec![connected_new_peer], + ); } } } diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index 055358c4a..7c54a5dd1 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -43,8 +43,8 @@ impl PeerRepository { /// Returns IDs of created [`Peer`]s. `(caller_peer_id, responder_peer_id)`. pub fn create_peers( &mut self, - caller: NewPeer, - responder: NewPeer, + caller: &NewPeer, + responder: &NewPeer, ) -> (u64, u64) { self.peers_count += 1; let caller_peer_id = self.peers_count; @@ -72,7 +72,7 @@ impl PeerRepository { responder.spec.get_publish_endpoints(), &mut self.tracks_count, ); - for endpoint in caller.spec.get_play_endpoints().into_iter() { + for endpoint in caller.spec.get_play_endpoints() { if responder.control_id == endpoint.src.member_id { responder_peer .get_senders() @@ -81,7 +81,7 @@ impl PeerRepository { } } - for endpoint in responder.spec.get_play_endpoints().into_iter() { + for endpoint in responder.spec.get_play_endpoints() { if caller.control_id == endpoint.src.member_id { caller_peer .get_senders() diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 2e54ddf31..80bcc28ae 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -10,7 +10,7 @@ use futures::future; use hashbrown::HashMap; use medea_client_api_proto::{Command, Event, IceCandidate}; -use std::{convert::TryFrom, time::Duration, sync::Arc}; +use std::{convert::TryFrom, sync::Arc, time::Duration}; use crate::{ api::{ @@ -335,7 +335,7 @@ impl Handler for Room { ); let (caller_peer_id, responder_peer_id) = - self.peers.create_peers(msg.caller, msg.responder); + self.peers.create_peers(&msg.caller, &msg.responder); ctx.notify(ConnectPeers(caller_peer_id, responder_peer_id)); From 9f82645bdd0e8ab7a2975fe98996ec0ae6ec6201 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 24 May 2019 20:03:04 +0300 Subject: [PATCH 038/735] Add missing doc --- src/media/peer.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/media/peer.rs b/src/media/peer.rs index 63712987b..6f172a847 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -303,6 +303,9 @@ impl Peer { } } + /// Add all [`WebRtcPublishEndpoint`] to this [`Peer`]. + /// + /// This use `last_track_id` counter for generating new [`MediaTrack`] ID. pub fn add_publish_endpoints( &mut self, endpoints: Vec<&WebRtcPublishEndpoint>, From 359c4cd945c260d0dee1577eb6bb3bce6177f3ed Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 27 May 2019 14:20:20 +0300 Subject: [PATCH 039/735] Change type of RoomId to String --- jason/e2e-demo/js/index.js | 4 ++-- room_spec.yml | 2 +- room_spec_test.yml | 2 +- room_spec_with_3_members.yml | 2 +- src/api/client/server.rs | 12 +++++++----- src/api/control/mod.rs | 3 ++- src/api/control/room.rs | 7 ++++--- src/signalling/mod.rs | 2 +- src/signalling/room.rs | 17 +++++++---------- src/signalling/room_repo.rs | 6 +++--- 10 files changed, 29 insertions(+), 28 deletions(-) diff --git a/jason/e2e-demo/js/index.js b/jason/e2e-demo/js/index.js index fefe8fa1f..bd5874017 100644 --- a/jason/e2e-demo/js/index.js +++ b/jason/e2e-demo/js/index.js @@ -4,8 +4,8 @@ async function f() { let caller = new rust.Jason(); // let caller_room_handle = await caller.join_room("ws://localhost:8080/ws/1/1/caller_credentials"); - caller.join_room("ws://localhost:8080/ws/1/1/1-credentials"); - caller.join_room("ws://localhost:8080/ws/1/2/2-credentials"); + caller.join_room("ws://localhost:8080/ws/video-call-1/1/1-credentials"); + caller.join_room("ws://localhost:8080/ws/video-call-1/2/2-credentials"); // Use this for testing with 3 members. // caller.join_room("ws://localhost:8080/ws/1/2/2-credentials"); diff --git a/room_spec.yml b/room_spec.yml index 810b13f49..66139b81d 100644 --- a/room_spec.yml +++ b/room_spec.yml @@ -1,5 +1,5 @@ kind: Room -id: 1 +id: video-call-1 spec: pipeline: # Here we're defining a member who initiates video call. diff --git a/room_spec_test.yml b/room_spec_test.yml index 544f523ee..bf1c4100e 100644 --- a/room_spec_test.yml +++ b/room_spec_test.yml @@ -1,5 +1,5 @@ kind: Room -id: 1 +id: video-call-1 spec: pipeline: # Here we're defining a member who initiates video call. diff --git a/room_spec_with_3_members.yml b/room_spec_with_3_members.yml index 396962e2c..09fb33900 100644 --- a/room_spec_with_3_members.yml +++ b/room_spec_with_3_members.yml @@ -1,5 +1,5 @@ kind: Room -id: 1 +id: video-call-1 spec: pipeline: # Here we're defining a member who initiates video call. diff --git a/src/api/client/server.rs b/src/api/client/server.rs index c3e3a05e3..5235a5eaf 100644 --- a/src/api/client/server.rs +++ b/src/api/client/server.rs @@ -13,11 +13,11 @@ use crate::{ rpc_connection::{AuthorizationError, Authorize}, session::WsSession, }, - control::MemberId, + control::{MemberId, RoomId}, }, conf::{Conf, Rpc}, log::prelude::*, - signalling::{room_repo::RoomsRepository, RoomId}, + signalling::room_repo::RoomsRepository, }; /// Parameters of new WebSocket connection creation HTTP request. @@ -42,7 +42,7 @@ fn ws_index( ) -> FutureResponse { debug!("Request params: {:?}", info); - match state.rooms.get(info.room_id) { + match state.rooms.get(&info.room_id) { Some(room) => room .send(Authorize { member_id: info.member_id, @@ -147,7 +147,8 @@ mod test { #[test] fn responses_with_pong() { let mut server = ws_server(Conf::default()); - let (read, mut write) = server.ws_at("/ws/1/1/1-credentials").unwrap(); + let (read, mut write) = + server.ws_at("/ws/video-call-1/1/1-credentials").unwrap(); write.text(r#"{"ping":33}"#); let (item, _) = server.execute(read.into_future()).unwrap(); @@ -165,7 +166,8 @@ mod test { }; let mut server = ws_server(conf.clone()); - let (read, mut write) = server.ws_at("/ws/1/1/1-credentials").unwrap(); + let (read, mut write) = + server.ws_at("/ws/video-call-1/1/1-credentials").unwrap(); write.text(r#"{"ping":33}"#); let (item, read) = server.execute(read.into_future()).unwrap(); diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index 2b02e6f72..6d3481e44 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -17,6 +17,7 @@ use self::{ }; pub use self::member::{Id as MemberId, Member}; +pub use self::room::Id as RoomId; /// Errors that can occur when we try transform some spec from [`Entity`]. /// This error used in all [`TryFrom`] of Control API. @@ -37,7 +38,7 @@ pub enum TryFromEntityError { pub enum Entity { /// Represent [`RoomSpec`]. /// Can transform into [`RoomSpec`] by `RoomSpec::try_from`. - Room { id: u64, spec: Pipeline }, + Room { id: RoomId, spec: Pipeline }, /// Represent [`MemberSpec`]. /// Can transform into [`MemberSpec`] by `MemberSpec::try_from`. diff --git a/src/api/control/room.rs b/src/api/control/room.rs index a8a93ea08..b8e35ce32 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -2,18 +2,19 @@ use std::convert::TryFrom; -use crate::signalling::RoomId; - use super::{ member::MemberSpec, pipeline::Pipeline, Entity, TryFromEntityError, }; +/// ID of [`Room`]. +pub type Id = String; + /// [`crate::signalling::room::Room`] specification. /// Newtype for [`Entity::Room`] #[derive(Clone, Debug)] #[allow(clippy::module_name_repetitions)] pub struct RoomSpec { - pub id: RoomId, + pub id: Id, pub spec: Pipeline, } diff --git a/src/signalling/mod.rs b/src/signalling/mod.rs index 5adae3080..3befe6cdd 100644 --- a/src/signalling/mod.rs +++ b/src/signalling/mod.rs @@ -3,4 +3,4 @@ pub mod peers; pub mod room; pub mod room_repo; -pub use self::room::{Id as RoomId, Room}; +pub use self::room::Room; diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 80bcc28ae..11f6025ff 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -18,21 +18,18 @@ use crate::{ AuthorizationError, Authorize, CommandMessage, RpcConnectionClosed, RpcConnectionEstablished, }, - control::{member::MemberSpec, room::RoomSpec, Member, MemberId}, + control::{ + member::MemberSpec, room::RoomSpec, Member, MemberId, RoomId, + }, }, log::prelude::*, media::{ New, NewPeer, Peer, PeerId, PeerStateError, PeerStateMachine, WaitLocalHaveRemote, WaitLocalSdp, WaitRemoteSdp, }, - signalling::{ - participants::ParticipantService, peers::PeerRepository, RoomId, - }, + signalling::{participants::ParticipantService, peers::PeerRepository}, }; -/// ID of [`Room`]. -pub type Id = u64; - /// Ergonomic type alias for using [`ActorFuture`] for [`Room`]. type ActFuture = Box>; @@ -60,7 +57,7 @@ impl From for RoomError { /// Media server room with its [`Member`]s. #[derive(Debug)] pub struct Room { - id: Id, + id: RoomId, /// [`RpcConnection`]s of [`Member`]s in this [`Room`]. participants: ParticipantService, @@ -95,7 +92,7 @@ impl Room { debug!("Created room with {:?} users.", members); Self { - id: room.id, + id: room.id.clone(), peers: PeerRepository::from(HashMap::new()), participants: ParticipantService::new( members, @@ -107,7 +104,7 @@ impl Room { } pub fn get_id(&self) -> RoomId { - self.id + self.id.clone() } /// Sends [`Event::PeerCreated`] to one of specified [`Peer`]s based on diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs index f0df8ead4..56f2fb0b5 100644 --- a/src/signalling/room_repo.rs +++ b/src/signalling/room_repo.rs @@ -5,7 +5,7 @@ use hashbrown::HashMap; use std::sync::{Arc, Mutex}; -use crate::signalling::{Room, RoomId}; +use crate::{api::control::RoomId, signalling::Room}; /// Repository that stores [`Room`]s addresses. #[derive(Clone, Default)] @@ -24,8 +24,8 @@ impl RoomsRepository { } /// Returns [`Room`] by its ID. - pub fn get(&self, id: RoomId) -> Option> { + pub fn get(&self, id: &str) -> Option> { let rooms = self.rooms.lock().unwrap(); - rooms.get(&id).cloned() + rooms.get(id).cloned() } } From 2115db0596be6c3b65e4e443f6654452c8155d31 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 27 May 2019 14:45:50 +0300 Subject: [PATCH 040/735] Get member credentials from spec --- jason/e2e-demo/js/index.js | 4 ++-- room_spec.yml | 2 ++ room_spec_test.yml | 2 ++ room_spec_with_3_members.yml | 3 +++ src/api/client/server.rs | 4 ++-- src/api/control/member.rs | 19 +++++++++++-------- src/api/control/mod.rs | 2 +- src/signalling/participants.rs | 2 +- src/signalling/room.rs | 1 - 9 files changed, 24 insertions(+), 15 deletions(-) diff --git a/jason/e2e-demo/js/index.js b/jason/e2e-demo/js/index.js index bd5874017..64c3c9db9 100644 --- a/jason/e2e-demo/js/index.js +++ b/jason/e2e-demo/js/index.js @@ -4,8 +4,8 @@ async function f() { let caller = new rust.Jason(); // let caller_room_handle = await caller.join_room("ws://localhost:8080/ws/1/1/caller_credentials"); - caller.join_room("ws://localhost:8080/ws/video-call-1/1/1-credentials"); - caller.join_room("ws://localhost:8080/ws/video-call-1/2/2-credentials"); + caller.join_room("ws://localhost:8080/ws/video-call-1/1/test"); + caller.join_room("ws://localhost:8080/ws/video-call-1/2/test"); // Use this for testing with 3 members. // caller.join_room("ws://localhost:8080/ws/1/2/2-credentials"); diff --git a/room_spec.yml b/room_spec.yml index 66139b81d..e47af876c 100644 --- a/room_spec.yml +++ b/room_spec.yml @@ -5,6 +5,7 @@ spec: # Here we're defining a member who initiates video call. caller: kind: Member + credentials: test spec: pipeline: # Media element which is able to receive media data from client via WebRTC. @@ -20,6 +21,7 @@ spec: src: "local://video-call-2/responder/publish" responder: kind: Member + credentials: test spec: pipeline: publish: diff --git a/room_spec_test.yml b/room_spec_test.yml index bf1c4100e..ff2b4afd2 100644 --- a/room_spec_test.yml +++ b/room_spec_test.yml @@ -5,6 +5,7 @@ spec: # Here we're defining a member who initiates video call. caller: kind: Member + credentials: test spec: pipeline: # Media element which is able to receive media data from client via WebRTC. @@ -16,6 +17,7 @@ spec: # Media element which is able to play media data for client via WebRTC. responder: kind: Member + credentials: test spec: pipeline: play: diff --git a/room_spec_with_3_members.yml b/room_spec_with_3_members.yml index 09fb33900..ff09c54be 100644 --- a/room_spec_with_3_members.yml +++ b/room_spec_with_3_members.yml @@ -5,6 +5,7 @@ spec: # Here we're defining a member who initiates video call. caller: kind: Member + credentials: test spec: pipeline: # Media element which is able to receive media data from client via WebRTC. @@ -24,6 +25,7 @@ spec: src: "local://video-call-2/responder2/publish" responder: kind: Member + credentials: test spec: pipeline: publish: @@ -41,6 +43,7 @@ spec: responder2: kind: Member + credentials: test spec: pipeline: publish: diff --git a/src/api/client/server.rs b/src/api/client/server.rs index 5235a5eaf..bdc4688ca 100644 --- a/src/api/client/server.rs +++ b/src/api/client/server.rs @@ -148,7 +148,7 @@ mod test { fn responses_with_pong() { let mut server = ws_server(Conf::default()); let (read, mut write) = - server.ws_at("/ws/video-call-1/1/1-credentials").unwrap(); + server.ws_at("/ws/video-call-1/1/test").unwrap(); write.text(r#"{"ping":33}"#); let (item, _) = server.execute(read.into_future()).unwrap(); @@ -167,7 +167,7 @@ mod test { let mut server = ws_server(conf.clone()); let (read, mut write) = - server.ws_at("/ws/video-call-1/1/1-credentials").unwrap(); + server.ws_at("/ws/video-call-1/1/test").unwrap(); write.text(r#"{"ping":33}"#); let (item, read) = server.execute(read.into_future()).unwrap(); diff --git a/src/api/control/member.rs b/src/api/control/member.rs index 1d91b95ea..c186e46d2 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -14,9 +14,6 @@ pub struct Member { /// ID of [`Member`]. pub id: Id, - /// Credentials to authorize [`Member`] with. - pub credentials: String, - /// Control API specification of this [`Member`]. pub spec: Arc, @@ -27,7 +24,10 @@ pub struct Member { /// Newtype for [`Entity::Member`] variant. #[derive(Clone, Debug)] #[allow(clippy::module_name_repetitions)] -pub struct MemberSpec(pub Pipeline); +pub struct MemberSpec { + pub pipeline: Pipeline, + pub credentials: String, +} impl MemberSpec { /// Get [`Element`] of this [`MemberSpec`] by ID. @@ -35,12 +35,12 @@ impl MemberSpec { &self, id: &str, ) -> Option> { - Some(Element::try_from(self.0.pipeline.get(id).cloned()?)) + Some(Element::try_from(self.pipeline.pipeline.get(id).cloned()?)) } /// Get all [`WebRtcPlayEndpoint`]s of this [`MemberSpec`]. pub fn get_play_endpoints(&self) -> Vec<&WebRtcPlayEndpoint> { - self.0 + self.pipeline .pipeline .iter() .filter_map(|(_name, e)| match e { @@ -63,7 +63,7 @@ impl MemberSpec { /// Get all [`WebRtcPublishEndpoint`]s of this [`MemberSpec`]. pub fn get_publish_endpoints(&self) -> Vec<&WebRtcPublishEndpoint> { - self.0 + self.pipeline .pipeline .iter() .filter_map(|(_name, e)| match e { @@ -79,7 +79,10 @@ impl TryFrom for MemberSpec { fn try_from(from: Entity) -> Result { match from { - Entity::Member { spec } => Ok(Self(spec)), + Entity::Member { spec, credentials } => Ok(Self { + pipeline: spec, + credentials, + }), _ => Err(TryFromEntityError::NotMember), } } diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index 6d3481e44..e712cf5fe 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -42,7 +42,7 @@ pub enum Entity { /// Represent [`MemberSpec`]. /// Can transform into [`MemberSpec`] by `MemberSpec::try_from`. - Member { spec: Pipeline }, + Member { spec: Pipeline, credentials: String }, /// Represent [`WebRtcPublishEndpoint`]. /// Can transform into [`Element`] enum by `Element::try_from`. diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 81df82fad..6bab21740 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -88,7 +88,7 @@ impl ParticipantService { ) -> Result<&Member, AuthorizationError> { match self.members.get(&member_id) { Some(ref member) => { - if member.credentials.eq(credentials) { + if member.spec.credentials.eq(credentials) { Ok(member) } else { Err(AuthorizationError::InvalidCredentials) diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 11f6025ff..ba9c7dc2b 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -83,7 +83,6 @@ impl Room { let member = Member { id, spec: Arc::new(member_spec), - credentials: format!("{}-credentials", id), control_id: control_id.clone(), }; members.insert(id, member); From fb88cb92b6222815699ee3f01cff65e10f9fc857 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 27 May 2019 15:33:39 +0300 Subject: [PATCH 041/735] Add loading specs from directory --- config.toml | 6 ++++ room_spec.yml => specs/room_spec.yml | 0 .../room_spec_test.yml | 2 +- .../room_spec_with_3_members.yml | 2 +- src/api/client/server.rs | 2 +- src/api/control/mod.rs | 26 ++++++++++++--- src/conf/server.rs | 4 +++ src/main.rs | 32 ++++++++++++------- src/signalling/room.rs | 2 +- 9 files changed, 56 insertions(+), 20 deletions(-) rename room_spec.yml => specs/room_spec.yml (100%) rename room_spec_test.yml => specs/room_spec_test.yml (97%) rename room_spec_with_3_members.yml => specs/room_spec_with_3_members.yml (99%) diff --git a/config.toml b/config.toml index 500fa0dd8..ef22c52a0 100644 --- a/config.toml +++ b/config.toml @@ -9,6 +9,12 @@ # Default: # bind_port = 8080 +# Path to directory with static control API specs. +# +# Default: +# static_specs_path = None +static_specs_path = "specs" + diff --git a/room_spec.yml b/specs/room_spec.yml similarity index 100% rename from room_spec.yml rename to specs/room_spec.yml diff --git a/room_spec_test.yml b/specs/room_spec_test.yml similarity index 97% rename from room_spec_test.yml rename to specs/room_spec_test.yml index ff2b4afd2..7438bd07c 100644 --- a/room_spec_test.yml +++ b/specs/room_spec_test.yml @@ -1,5 +1,5 @@ kind: Room -id: video-call-1 +id: video-call-2 spec: pipeline: # Here we're defining a member who initiates video call. diff --git a/room_spec_with_3_members.yml b/specs/room_spec_with_3_members.yml similarity index 99% rename from room_spec_with_3_members.yml rename to specs/room_spec_with_3_members.yml index ff09c54be..deaab7b54 100644 --- a/room_spec_with_3_members.yml +++ b/specs/room_spec_with_3_members.yml @@ -1,5 +1,5 @@ kind: Room -id: video-call-1 +id: video-call-3 spec: pipeline: # Here we're defining a member who initiates video call. diff --git a/src/api/client/server.rs b/src/api/client/server.rs index bdc4688ca..e48b240c9 100644 --- a/src/api/client/server.rs +++ b/src/api/client/server.rs @@ -119,7 +119,7 @@ mod test { /// Creates [`RoomsRepository`] for tests filled with a single [`Room`]. fn room(conf: Rpc) -> RoomsRepository { let room_spec = - control::load_from_yaml_file("room_spec_test.yml").unwrap(); + control::load_from_yaml_file("./specs/room_spec.yml").unwrap(); let client_room = Room::new(room_spec, conf.reconnect_timeout); let room_id = client_room.get_id(); diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index e712cf5fe..1b97d726a 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -8,7 +8,7 @@ pub mod room; use failure::{Error, Fail}; use serde::Deserialize; -use std::{convert::TryFrom as _, fs::File, io::Read as _}; +use std::{convert::TryFrom as _, fs::File, io::Read as _, path::Path}; use self::{ element::{WebRtcPlayEndpoint, WebRtcPublishEndpoint}, @@ -16,8 +16,10 @@ use self::{ room::RoomSpec, }; -pub use self::member::{Id as MemberId, Member}; -pub use self::room::Id as RoomId; +pub use self::{ + member::{Id as MemberId, Member}, + room::Id as RoomId, +}; /// Errors that can occur when we try transform some spec from [`Entity`]. /// This error used in all [`TryFrom`] of Control API. @@ -53,8 +55,8 @@ pub enum Entity { WebRtcPlayEndpoint { spec: WebRtcPlayEndpoint }, } -/// Load [`Entity`] from file with YAML format. -pub fn load_from_yaml_file(path: &str) -> Result { +/// Load [`RoomSpec`] from file with YAML format. +pub fn load_from_yaml_file>(path: P) -> Result { let mut file = File::open(path)?; let mut buf = String::new(); file.read_to_string(&mut buf)?; @@ -63,3 +65,17 @@ pub fn load_from_yaml_file(path: &str) -> Result { Ok(room) } + +/// Load all [`RoomSpec`] from YAML files from provided path. +pub fn load_static_specs_from_dir>( + path: P, +) -> Result, Error> { + let mut specs = Vec::new(); + for entry in std::fs::read_dir(path)? { + let entry = entry?; + let spec = load_from_yaml_file(entry.path())?; + specs.push(spec) + } + + Ok(specs) +} diff --git a/src/conf/server.rs b/src/conf/server.rs index bd89c3965..a1d8187a3 100644 --- a/src/conf/server.rs +++ b/src/conf/server.rs @@ -12,9 +12,13 @@ pub struct Server { /// IP address to bind HTTP server to. Defaults to `0.0.0.0`. #[default(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)))] pub bind_ip: IpAddr, + /// Port to bind HTTP server to. Defaults to `8080`. #[default(8080)] pub bind_port: u16, + + /// Path to directory with static control API specs. + pub static_specs_path: Option, } impl Server { diff --git a/src/main.rs b/src/main.rs index fb3cef57d..da9bc6644 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,10 +13,11 @@ use dotenv::dotenv; use log::prelude::*; use crate::{ - api::{client::server, control::load_from_yaml_file}, + api::{client::server, control::load_static_specs_from_dir}, conf::Conf, signalling::{room_repo::RoomsRepository, Room}, }; +use hashbrown::HashMap; fn main() { dotenv().ok(); @@ -29,18 +30,27 @@ fn main() { let config = Conf::parse().unwrap(); info!("{:?}", config); - let room_spec = load_from_yaml_file("room_spec.yml").unwrap(); - - // println!("{:#?}", room_spec); - - let client_room = Room::new(room_spec, config.rpc.reconnect_timeout); - let room_id = client_room.get_id(); - let client_room = Arbiter::start(move |_| client_room); - let room_hash_map = hashmap! { - room_id => client_room, + let rooms: HashMap> = if let Some(static_specs_path) = + config.server.static_specs_path.clone() + { + let room_specs = load_static_specs_from_dir(static_specs_path).unwrap(); + room_specs + .into_iter() + .map(|s| { + let room = Room::new(s, config.rpc.reconnect_timeout); + let room_id = room.get_id(); + let room = Arbiter::start(move |_| room); + + (room_id, room) + }) + .collect() + } else { + HashMap::new() }; - let room_repo = RoomsRepository::new(room_hash_map); + info!("Loaded static specs: {:?}", rooms); + + let room_repo = RoomsRepository::new(rooms); server::run(room_repo, config); let _ = sys.run(); diff --git a/src/signalling/room.rs b/src/signalling/room.rs index ba9c7dc2b..49b2cb6c7 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -464,7 +464,7 @@ mod test { fn start_room() -> Addr { let room_spec = - control::load_from_yaml_file("room_spec_test.yml").unwrap(); + control::load_from_yaml_file("./specs/room_spec_test.yml").unwrap(); let client_room = Room::new(room_spec, Duration::from_secs(10)); Arbiter::start(move |_| client_room) } From 80a5b3aa2bea63e1b660c9f7c1ca6b7df9eccd00 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 27 May 2019 15:39:50 +0300 Subject: [PATCH 042/735] Refactor --- src/api/control/member.rs | 14 +++++++++----- src/main.rs | 1 - 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/api/control/member.rs b/src/api/control/member.rs index c186e46d2..83951cb3c 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -6,6 +6,7 @@ use super::{element::Element, pipeline::Pipeline, Entity, TryFromEntityError}; use crate::api::control::element::{WebRtcPlayEndpoint, WebRtcPublishEndpoint}; +/// ID of [`Member`]. pub type Id = u64; /// Media server user with its ID and credentials. @@ -25,7 +26,10 @@ pub struct Member { #[derive(Clone, Debug)] #[allow(clippy::module_name_repetitions)] pub struct MemberSpec { - pub pipeline: Pipeline, + /// Spec of this [`Member`]. + pub spec: Pipeline, + + /// Credentials to authorize [`Member`] with. pub credentials: String, } @@ -35,12 +39,12 @@ impl MemberSpec { &self, id: &str, ) -> Option> { - Some(Element::try_from(self.pipeline.pipeline.get(id).cloned()?)) + Some(Element::try_from(self.spec.pipeline.get(id).cloned()?)) } /// Get all [`WebRtcPlayEndpoint`]s of this [`MemberSpec`]. pub fn get_play_endpoints(&self) -> Vec<&WebRtcPlayEndpoint> { - self.pipeline + self.spec .pipeline .iter() .filter_map(|(_name, e)| match e { @@ -63,7 +67,7 @@ impl MemberSpec { /// Get all [`WebRtcPublishEndpoint`]s of this [`MemberSpec`]. pub fn get_publish_endpoints(&self) -> Vec<&WebRtcPublishEndpoint> { - self.pipeline + self.spec .pipeline .iter() .filter_map(|(_name, e)| match e { @@ -80,7 +84,7 @@ impl TryFrom for MemberSpec { fn try_from(from: Entity) -> Result { match from { Entity::Member { spec, credentials } => Ok(Self { - pipeline: spec, + spec: spec, credentials, }), _ => Err(TryFromEntityError::NotMember), diff --git a/src/main.rs b/src/main.rs index da9bc6644..5a14da6f1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -47,7 +47,6 @@ fn main() { } else { HashMap::new() }; - info!("Loaded static specs: {:?}", rooms); let room_repo = RoomsRepository::new(rooms); From 50d45ac1b4c04b09aee3fe69957fa22424f7e878 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 27 May 2019 17:13:23 +0300 Subject: [PATCH 043/735] Combine signalling and control id --- jason/e2e-demo/js/index.js | 4 ++-- src/api/client/rpc_connection.rs | 4 ++-- src/api/client/server.rs | 8 ++++---- src/api/client/session.rs | 14 ++++++++------ src/api/control/member.rs | 2 +- src/media/peer.rs | 10 +++++----- src/signalling/participants.rs | 24 ++++++++++++------------ src/signalling/peers.rs | 8 ++++---- src/signalling/room.rs | 16 ++++++++-------- 9 files changed, 46 insertions(+), 44 deletions(-) diff --git a/jason/e2e-demo/js/index.js b/jason/e2e-demo/js/index.js index 64c3c9db9..a274cd135 100644 --- a/jason/e2e-demo/js/index.js +++ b/jason/e2e-demo/js/index.js @@ -4,8 +4,8 @@ async function f() { let caller = new rust.Jason(); // let caller_room_handle = await caller.join_room("ws://localhost:8080/ws/1/1/caller_credentials"); - caller.join_room("ws://localhost:8080/ws/video-call-1/1/test"); - caller.join_room("ws://localhost:8080/ws/video-call-1/2/test"); + caller.join_room("ws://localhost:8080/ws/video-call-1/caller/test"); + caller.join_room("ws://localhost:8080/ws/video-call-1/responder/test"); // Use this for testing with 3 members. // caller.join_room("ws://localhost:8080/ws/1/2/2-credentials"); diff --git a/src/api/client/rpc_connection.rs b/src/api/client/rpc_connection.rs index d0f343775..9ef14d191 100644 --- a/src/api/client/rpc_connection.rs +++ b/src/api/client/rpc_connection.rs @@ -125,7 +125,7 @@ pub mod test { fn started(&mut self, ctx: &mut Self::Context) { self.room .try_send(RpcConnectionEstablished { - member_id: self.member_id, + member_id: self.member_id.clone(), connection: Box::new(ctx.address()), }) .unwrap(); @@ -193,7 +193,7 @@ pub mod test { candidate: _, } => { self.room.do_send(RpcConnectionClosed { - member_id: self.member_id, + member_id: self.member_id.clone(), reason: ClosedReason::Closed, }); } diff --git a/src/api/client/server.rs b/src/api/client/server.rs index e48b240c9..9f6e26ed5 100644 --- a/src/api/client/server.rs +++ b/src/api/client/server.rs @@ -45,7 +45,7 @@ fn ws_index( match state.rooms.get(&info.room_id) { Some(room) => room .send(Authorize { - member_id: info.member_id, + member_id: info.member_id.clone(), credentials: info.credentials.clone(), }) .from_err() @@ -53,7 +53,7 @@ fn ws_index( Ok(_) => ws::start( &r.drop_state(), WsSession::new( - info.member_id, + info.member_id.clone(), room, state.config.idle_timeout, ), @@ -148,7 +148,7 @@ mod test { fn responses_with_pong() { let mut server = ws_server(Conf::default()); let (read, mut write) = - server.ws_at("/ws/video-call-1/1/test").unwrap(); + server.ws_at("/ws/video-call-1/caller/test").unwrap(); write.text(r#"{"ping":33}"#); let (item, _) = server.execute(read.into_future()).unwrap(); @@ -167,7 +167,7 @@ mod test { let mut server = ws_server(conf.clone()); let (read, mut write) = - server.ws_at("/ws/video-call-1/1/test").unwrap(); + server.ws_at("/ws/video-call-1/caller/test").unwrap(); write.text(r#"{"ping":33}"#); let (item, read) = server.execute(read.into_future()).unwrap(); diff --git a/src/api/client/session.rs b/src/api/client/session.rs index bfba164a5..8994209a7 100644 --- a/src/api/client/session.rs +++ b/src/api/client/session.rs @@ -78,7 +78,7 @@ impl WsSession { { info!("WsSession of member {} is idle", session.member_id); if let Err(err) = session.room.try_send(RpcConnectionClosed { - member_id: session.member_id, + member_id: session.member_id.clone(), reason: ClosedReason::Lost, }) { error!( @@ -105,10 +105,12 @@ impl Actor for WsSession { self.start_watchdog(ctx); - let member_id = self.member_id; + // TODO: Fix this + let member_id1 = self.member_id.clone(); + let member_id2 = self.member_id.clone(); ctx.wait( wrap_future(self.room.send(RpcConnectionEstablished { - member_id: self.member_id, + member_id: self.member_id.clone(), connection: Box::new(ctx.address()), })) .map( @@ -119,7 +121,7 @@ impl Actor for WsSession { error!( "Room rejected Established for member {}, cause \ {:?}", - member_id, e + member_id1, e ); session.close_normal(ctx); } @@ -132,7 +134,7 @@ impl Actor for WsSession { error!( "WsSession of member {} failed to join Room, because: \ {:?}", - member_id, send_err, + member_id2, send_err, ); session.close_normal(ctx); }, @@ -237,7 +239,7 @@ impl StreamHandler for WsSession { ws::Message::Close(reason) => { if !self.closed_by_server { if let Err(err) = self.room.try_send(RpcConnectionClosed { - member_id: self.member_id, + member_id: self.member_id.clone(), reason: ClosedReason::Closed, }) { error!( diff --git a/src/api/control/member.rs b/src/api/control/member.rs index 83951cb3c..5dcc46ea4 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -7,7 +7,7 @@ use super::{element::Element, pipeline::Pipeline, Entity, TryFromEntityError}; use crate::api::control::element::{WebRtcPlayEndpoint, WebRtcPublishEndpoint}; /// ID of [`Member`]. -pub type Id = u64; +pub type Id = String; /// Media server user with its ID and credentials. #[derive(Debug, Clone)] diff --git a/src/media/peer.rs b/src/media/peer.rs index 6f172a847..8624bffb8 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -208,7 +208,7 @@ pub struct Peer { impl Peer { /// Returns ID of [`Member`] associated with this [`Peer`]. pub fn member_id(&self) -> MemberId { - self.context.member_id + self.context.member_id.clone() } /// Returns ID of [`Peer`]. @@ -222,8 +222,8 @@ impl Peer { } /// Returns ID of interconnected [`Member`]. - pub fn partner_member_id(&self) -> Id { - self.context.partner_member + pub fn partner_member_id(&self) -> MemberId { + self.context.partner_member.clone() } /// Returns [`Track`]'s of [`Peer`]. @@ -274,7 +274,7 @@ impl Peer { #[derive(Debug, Clone)] #[allow(clippy::module_name_repetitions)] pub struct NewPeer { - pub signalling_id: u64, + pub signalling_id: MemberId, pub spec: Arc, pub control_id: String, } @@ -399,7 +399,7 @@ impl Peer { #[test] fn create_peer() { - let peer = Peer::new(1, 1, 2, 2); + let peer = Peer::new(1, "1".to_string(), 2, "2".to_string()); let peer = peer.start(); assert_eq!(peer.state, WaitLocalSdp {}); diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 6bab21740..2cae9abdd 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -141,15 +141,15 @@ impl ParticipantService { } ClosedReason::Lost => { self.drop_connection_tasks.insert( - member_id, + member_id.clone(), ctx.run_later(self.reconnect_timeout, move |_, ctx| { info!( "Member {} connection lost at {:?}. Room will be \ stopped.", - member_id, closed_at + &member_id, closed_at ); ctx.notify(RpcConnectionClosed { - member_id, + member_id: member_id, reason: ClosedReason::Closed, }) }), @@ -172,13 +172,13 @@ impl ParticipantService { added_member.push(waiter.control_id.clone()); let connected_new_peer = NewPeer { control_id: member.control_id.clone(), - signalling_id: member.id, + signalling_id: member.id.clone(), spec: Arc::clone(&member.spec), }; let waiter_new_peer = NewPeer { spec: Arc::clone(&waiter.spec), control_id: waiter.control_id.clone(), - signalling_id: waiter.signalling_id, + signalling_id: waiter.signalling_id.clone(), }; ctx.notify(CreatePeer { @@ -237,16 +237,16 @@ impl ParticipantService { }; let connected_new_peer = NewPeer { - signalling_id: connected_member.id, + signalling_id: connected_member.id.clone(), spec: Arc::clone(&connected_member.spec), control_id: connected_member.control_id.clone(), }; let is_responder_connected = - self.member_has_connection(*responder_member_signalling_id); + self.member_has_connection(responder_member_signalling_id.clone()); if is_responder_connected { let responder_spec = if let Some(m) = - self.members.get(&responder_member_signalling_id) + self.members.get(responder_member_signalling_id) { m.spec.clone() } else { @@ -254,7 +254,7 @@ impl ParticipantService { }; let responder_new_peer = NewPeer { - signalling_id: *responder_member_signalling_id, + signalling_id: responder_member_signalling_id.clone(), spec: Arc::clone(&responder_spec), control_id: responder_member_control_id.clone(), }; @@ -269,7 +269,7 @@ impl ParticipantService { m.push(connected_new_peer); } else { self.members_waiting_connection.insert( - *responder_member_signalling_id, + responder_member_signalling_id.clone(), vec![connected_new_peer], ); } @@ -300,9 +300,9 @@ impl ParticipantService { } else { debug!("Connected member: {}", member_id); - self.create_and_interconnect_members_peers(ctx, member_id); + self.create_and_interconnect_members_peers(ctx, member_id.clone()); - self.connections.insert(member_id, con); + self.connections.insert(member_id.clone(), con); } } diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index 7c54a5dd1..1f0170513 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -53,15 +53,15 @@ impl PeerRepository { let mut caller_peer = Peer::new( caller_peer_id, - caller.signalling_id, + caller.signalling_id.clone(), responder_peer_id, - responder.signalling_id, + responder.signalling_id.clone(), ); let mut responder_peer = Peer::new( responder_peer_id, - responder.signalling_id, + responder.signalling_id.clone(), caller_peer_id, - caller.signalling_id, + caller.signalling_id.clone(), ); caller_peer.add_publish_endpoints( diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 49b2cb6c7..cc01ca40a 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -74,18 +74,18 @@ impl Room { pub fn new(room: RoomSpec, reconnect_timeout: Duration) -> Self { let mut members = HashMap::new(); let mut control_signalling_members = HashMap::new(); - room.spec.pipeline.iter().enumerate().for_each( - |(i, (control_id, value))| { - let id = (i as u64) + 1; + room.spec.pipeline.iter().for_each( + |(control_id, value)| { +// let id = (i as u64) + 1; let member_spec = MemberSpec::try_from(value.clone()).unwrap(); - control_signalling_members.insert(control_id.clone(), id); + control_signalling_members.insert(control_id.clone(), control_id.clone()); let member = Member { - id, + id: control_id.clone(), spec: Arc::new(member_spec), control_id: control_id.clone(), }; - members.insert(id, member); + members.insert(control_id.clone(), member); }, ); debug!("Created room with {:?} users.", members); @@ -483,13 +483,13 @@ mod test { let stopped_clone = stopped.clone(); Arbiter::start(move |_| TestConnection { events: caller_events_clone, - member_id: 1, + member_id: "caller".to_string(), room: room_clone, stopped: stopped_clone, }); Arbiter::start(move |_| TestConnection { events: responder_events_clone, - member_id: 2, + member_id: "responder".to_string(), room, stopped, }); From 5c129739d7b5f4951b24374c2a1a10d6b9c67bc7 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 27 May 2019 17:20:18 +0300 Subject: [PATCH 044/735] Remove useless fields --- src/api/control/member.rs | 3 --- src/signalling/participants.rs | 23 ++++++++--------------- src/signalling/room.rs | 6 +----- 3 files changed, 9 insertions(+), 23 deletions(-) diff --git a/src/api/control/member.rs b/src/api/control/member.rs index 5dcc46ea4..a6ddd0b90 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -17,9 +17,6 @@ pub struct Member { /// Control API specification of this [`Member`]. pub spec: Arc, - - /// ID from Control API specification of this [`Member`]. - pub control_id: String, } /// Newtype for [`Entity::Member`] variant. diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 2cae9abdd..ccdaca281 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -53,10 +53,6 @@ pub struct ParticipantService { /// before dropping it irrevocably in case it gets reestablished. drop_connection_tasks: HashMap, - /// Stores relation between ID of [`MemberSpec`] and ID of signalling - /// [`Member`]. - control_signalling_members: HashMap, - /// Stores [`NewPeer`]s which wait connection of another [`Member`]. members_waiting_connection: HashMap>, } @@ -64,7 +60,6 @@ pub struct ParticipantService { impl ParticipantService { pub fn new( members: HashMap, - control_signalling_members: HashMap, reconnect_timeout: Duration, ) -> Self { Self { @@ -72,7 +67,6 @@ impl ParticipantService { connections: HashMap::new(), reconnect_timeout, drop_connection_tasks: HashMap::new(), - control_signalling_members, members_waiting_connection: HashMap::new(), } } @@ -149,7 +143,7 @@ impl ParticipantService { &member_id, closed_at ); ctx.notify(RpcConnectionClosed { - member_id: member_id, + member_id, reason: ClosedReason::Closed, }) }), @@ -171,7 +165,7 @@ impl ParticipantService { for waiter in waiters { added_member.push(waiter.control_id.clone()); let connected_new_peer = NewPeer { - control_id: member.control_id.clone(), + control_id: member.id.clone(), signalling_id: member.id.clone(), spec: Arc::clone(&member.spec), }; @@ -221,11 +215,9 @@ impl ParticipantService { let responder_member_control_id = &connected_member_endpoint.src.member_id; - let responder_member_signalling_id = if let Some(r) = self - .control_signalling_members - .get(responder_member_control_id) + let responder_member_signalling_id = if let Some(r) = self.members.get(responder_member_control_id) { - r + r.id.clone() } else { warn!( "Member with control id '{}' not found! Probably this is \ @@ -236,17 +228,18 @@ impl ParticipantService { continue; }; + let connected_new_peer = NewPeer { signalling_id: connected_member.id.clone(), spec: Arc::clone(&connected_member.spec), - control_id: connected_member.control_id.clone(), + control_id: connected_member.id.clone(), }; let is_responder_connected = self.member_has_connection(responder_member_signalling_id.clone()); if is_responder_connected { let responder_spec = if let Some(m) = - self.members.get(responder_member_signalling_id) + self.members.get(&responder_member_signalling_id) { m.spec.clone() } else { @@ -264,7 +257,7 @@ impl ParticipantService { }); } else if let Some(m) = self .members_waiting_connection - .get_mut(responder_member_signalling_id) + .get_mut(&responder_member_signalling_id) { m.push(connected_new_peer); } else { diff --git a/src/signalling/room.rs b/src/signalling/room.rs index cc01ca40a..9627d224b 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -72,18 +72,15 @@ pub struct Room { impl Room { /// Create new instance of [`Room`]. pub fn new(room: RoomSpec, reconnect_timeout: Duration) -> Self { + // TODO: rewrite this let mut members = HashMap::new(); - let mut control_signalling_members = HashMap::new(); room.spec.pipeline.iter().for_each( |(control_id, value)| { -// let id = (i as u64) + 1; let member_spec = MemberSpec::try_from(value.clone()).unwrap(); - control_signalling_members.insert(control_id.clone(), control_id.clone()); let member = Member { id: control_id.clone(), spec: Arc::new(member_spec), - control_id: control_id.clone(), }; members.insert(control_id.clone(), member); }, @@ -95,7 +92,6 @@ impl Room { peers: PeerRepository::from(HashMap::new()), participants: ParticipantService::new( members, - control_signalling_members, reconnect_timeout, ), spec: room, From 644b21b320ec1ef0639cc7065f40be6099a3424a Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 27 May 2019 17:34:34 +0300 Subject: [PATCH 045/735] Refactor --- src/media/mod.rs | 2 +- src/media/peer.rs | 8 ------ src/signalling/participants.rs | 46 +++++++++++----------------------- src/signalling/peers.rs | 19 +++++++------- src/signalling/room.rs | 42 +++++++++++++++---------------- 5 files changed, 46 insertions(+), 71 deletions(-) diff --git a/src/media/mod.rs b/src/media/mod.rs index 727ad8026..d5dd2152b 100644 --- a/src/media/mod.rs +++ b/src/media/mod.rs @@ -4,7 +4,7 @@ pub mod track; pub use self::{ peer::{ - Id as PeerId, New, NewPeer, Peer, PeerStateError, PeerStateMachine, + Id as PeerId, New, Peer, PeerStateError, PeerStateMachine, WaitLocalHaveRemote, WaitLocalSdp, WaitRemoteSdp, }, track::{Id as TrackId, MediaTrack}, diff --git a/src/media/peer.rs b/src/media/peer.rs index 8624bffb8..1284ae15b 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -271,14 +271,6 @@ impl Peer { } } -#[derive(Debug, Clone)] -#[allow(clippy::module_name_repetitions)] -pub struct NewPeer { - pub signalling_id: MemberId, - pub spec: Arc, - pub control_id: String, -} - impl Peer { /// Creates new [`Peer`] for [`Member`]. pub fn new( diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index ccdaca281..c261b691a 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -24,7 +24,6 @@ use crate::{ control::{Member, MemberId}, }, log::prelude::*, - media::NewPeer, signalling::{ room::{CloseRoom, CreatePeer, RoomError}, Room, @@ -54,7 +53,7 @@ pub struct ParticipantService { drop_connection_tasks: HashMap, /// Stores [`NewPeer`]s which wait connection of another [`Member`]. - members_waiting_connection: HashMap>, + members_waiting_connection: HashMap>, } impl ParticipantService { @@ -163,21 +162,11 @@ impl ParticipantService { let mut added_member = Vec::new(); if let Some(waiters) = self.members_waiting_connection.get(&member.id) { for waiter in waiters { - added_member.push(waiter.control_id.clone()); - let connected_new_peer = NewPeer { - control_id: member.id.clone(), - signalling_id: member.id.clone(), - spec: Arc::clone(&member.spec), - }; - let waiter_new_peer = NewPeer { - spec: Arc::clone(&waiter.spec), - control_id: waiter.control_id.clone(), - signalling_id: waiter.signalling_id.clone(), - }; + added_member.push(waiter.id.clone()); ctx.notify(CreatePeer { - caller: connected_new_peer, - responder: waiter_new_peer, + caller: member.clone(), + responder: waiter.clone(), }); } } @@ -215,7 +204,8 @@ impl ParticipantService { let responder_member_control_id = &connected_member_endpoint.src.member_id; - let responder_member_signalling_id = if let Some(r) = self.members.get(responder_member_control_id) + let responder_member_signalling_id = if let Some(r) = + self.members.get(responder_member_control_id) { r.id.clone() } else { @@ -228,15 +218,8 @@ impl ParticipantService { continue; }; - - let connected_new_peer = NewPeer { - signalling_id: connected_member.id.clone(), - spec: Arc::clone(&connected_member.spec), - control_id: connected_member.id.clone(), - }; - - let is_responder_connected = - self.member_has_connection(responder_member_signalling_id.clone()); + let is_responder_connected = self + .member_has_connection(responder_member_signalling_id.clone()); if is_responder_connected { let responder_spec = if let Some(m) = self.members.get(&responder_member_signalling_id) @@ -246,24 +229,23 @@ impl ParticipantService { continue; }; - let responder_new_peer = NewPeer { - signalling_id: responder_member_signalling_id.clone(), + let responder = Member { + id: responder_member_control_id.clone(), spec: Arc::clone(&responder_spec), - control_id: responder_member_control_id.clone(), }; ctx.notify(CreatePeer { - caller: responder_new_peer, - responder: connected_new_peer, + caller: responder, + responder: connected_member.clone(), }); } else if let Some(m) = self .members_waiting_connection .get_mut(&responder_member_signalling_id) { - m.push(connected_new_peer); + m.push(connected_member.clone()); } else { self.members_waiting_connection.insert( responder_member_signalling_id.clone(), - vec![connected_new_peer], + vec![connected_member.clone()], ); } } diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index 1f0170513..6332a7f64 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -6,9 +6,10 @@ use std::convert::{TryFrom, TryInto}; use crate::{ api::control::MemberId, - media::{NewPeer, Peer, PeerId, PeerStateMachine}, + media::{Peer, PeerId, PeerStateMachine}, signalling::room::RoomError, }; +use crate::api::control::Member; #[derive(Debug)] pub struct PeerRepository { @@ -43,8 +44,8 @@ impl PeerRepository { /// Returns IDs of created [`Peer`]s. `(caller_peer_id, responder_peer_id)`. pub fn create_peers( &mut self, - caller: &NewPeer, - responder: &NewPeer, + caller: &Member, + responder: &Member, ) -> (u64, u64) { self.peers_count += 1; let caller_peer_id = self.peers_count; @@ -53,15 +54,15 @@ impl PeerRepository { let mut caller_peer = Peer::new( caller_peer_id, - caller.signalling_id.clone(), + caller.id.clone(), responder_peer_id, - responder.signalling_id.clone(), + responder.id.clone(), ); let mut responder_peer = Peer::new( responder_peer_id, - responder.signalling_id.clone(), + responder.id.clone(), caller_peer_id, - caller.signalling_id.clone(), + caller.id.clone(), ); caller_peer.add_publish_endpoints( @@ -73,7 +74,7 @@ impl PeerRepository { &mut self.tracks_count, ); for endpoint in caller.spec.get_play_endpoints() { - if responder.control_id == endpoint.src.member_id { + if responder.id == endpoint.src.member_id { responder_peer .get_senders() .into_iter() @@ -82,7 +83,7 @@ impl PeerRepository { } for endpoint in responder.spec.get_play_endpoints() { - if caller.control_id == endpoint.src.member_id { + if caller.id == endpoint.src.member_id { caller_peer .get_senders() .into_iter() diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 9627d224b..ad3120637 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -24,7 +24,7 @@ use crate::{ }, log::prelude::*, media::{ - New, NewPeer, Peer, PeerId, PeerStateError, PeerStateMachine, + New, Peer, PeerId, PeerStateError, PeerStateMachine, WaitLocalHaveRemote, WaitLocalSdp, WaitRemoteSdp, }, signalling::{participants::ParticipantService, peers::PeerRepository}, @@ -72,28 +72,28 @@ pub struct Room { impl Room { /// Create new instance of [`Room`]. pub fn new(room: RoomSpec, reconnect_timeout: Duration) -> Self { - // TODO: rewrite this - let mut members = HashMap::new(); - room.spec.pipeline.iter().for_each( - |(control_id, value)| { - let member_spec = MemberSpec::try_from(value.clone()).unwrap(); - - let member = Member { - id: control_id.clone(), - spec: Arc::new(member_spec), - }; - members.insert(control_id.clone(), member); - }, - ); + let members = room + .spec + .pipeline + .iter() + .map(|(control_id, entity)| { + let member_spec = MemberSpec::try_from(entity.clone()).unwrap(); + + ( + control_id.clone(), + Member { + id: control_id.clone(), + spec: Arc::new(member_spec), + }, + ) + }) + .collect(); debug!("Created room with {:?} users.", members); Self { id: room.id.clone(), peers: PeerRepository::from(HashMap::new()), - participants: ParticipantService::new( - members, - reconnect_timeout, - ), + participants: ParticipantService::new(members, reconnect_timeout), spec: room, } } @@ -308,8 +308,8 @@ impl Handler for Room { #[derive(Debug, Message)] #[rtype(result = "Result<(), ()>")] pub struct CreatePeer { - pub caller: NewPeer, - pub responder: NewPeer, + pub caller: Member, + pub responder: Member, } impl Handler for Room { @@ -323,7 +323,7 @@ impl Handler for Room { ) -> Self::Result { debug!( "Created peer member {} with member {}", - msg.caller.signalling_id, msg.responder.signalling_id + msg.caller.id, msg.responder.id ); let (caller_peer_id, responder_peer_id) = From 530d6a7dd6d322d1ab44ac9af5ecde1662600d72 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 27 May 2019 17:40:18 +0300 Subject: [PATCH 046/735] Fix lint --- src/api/control/member.rs | 2 +- src/media/peer.rs | 2 +- src/signalling/participants.rs | 28 ++++++++++++++-------------- src/signalling/peers.rs | 3 +-- src/signalling/room.rs | 4 ++-- 5 files changed, 19 insertions(+), 20 deletions(-) diff --git a/src/api/control/member.rs b/src/api/control/member.rs index a6ddd0b90..5c63539dd 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -81,7 +81,7 @@ impl TryFrom for MemberSpec { fn try_from(from: Entity) -> Result { match from { Entity::Member { spec, credentials } => Ok(Self { - spec: spec, + spec, credentials, }), _ => Err(TryFromEntityError::NotMember), diff --git a/src/media/peer.rs b/src/media/peer.rs index 1284ae15b..a64607b0f 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -13,7 +13,7 @@ use std::{convert::TryFrom, fmt::Display, sync::Arc}; use crate::{ api::control::{ - element::WebRtcPublishEndpoint, member::MemberSpec, MemberId, + element::WebRtcPublishEndpoint, MemberId, }, media::{MediaTrack, TrackId}, }; diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index c261b691a..330870aa2 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -76,10 +76,10 @@ impl ParticipantService { /// [`Member`] was found, but incorrect credentials was provided. pub fn get_member_by_id_and_credentials( &self, - member_id: MemberId, + member_id: &str, credentials: &str, ) -> Result<&Member, AuthorizationError> { - match self.members.get(&member_id) { + match self.members.get(member_id) { Some(ref member) => { if member.spec.credentials.eq(credentials) { Ok(member) @@ -92,9 +92,9 @@ impl ParticipantService { } /// Checks if [`Member`] has **active** [`RcpConnection`]. - pub fn member_has_connection(&self, member_id: MemberId) -> bool { - self.connections.contains_key(&member_id) - && !self.drop_connection_tasks.contains_key(&member_id) + pub fn member_has_connection(&self, member_id: &str) -> bool { + self.connections.contains_key(member_id) + && !self.drop_connection_tasks.contains_key(member_id) } /// Send [`Event`] to specified remote [`Member`]. @@ -177,9 +177,9 @@ impl ParticipantService { fn create_and_interconnect_members_peers( &mut self, ctx: &mut Context, - member_id: MemberId, + member_id: &str, ) { - let connected_member = if let Some(m) = self.members.get(&member_id) { + let connected_member = if let Some(m) = self.members.get(member_id) { m } else { warn!("Connected a non-existent member with id {}!", member_id); @@ -191,7 +191,7 @@ impl ParticipantService { let added_waiting_members = self.connect_waiting_members(&connected_member, ctx); - self.members_waiting_connection.remove(&member_id); + self.members_waiting_connection.remove(member_id); for connected_member_endpoint in connected_member_play_endpoints { // Skip members which waiting for us because we added them before. @@ -219,7 +219,7 @@ impl ParticipantService { }; let is_responder_connected = self - .member_has_connection(responder_member_signalling_id.clone()); + .member_has_connection(&responder_member_signalling_id); if is_responder_connected { let responder_spec = if let Some(m) = self.members.get(&responder_member_signalling_id) @@ -258,16 +258,16 @@ impl ParticipantService { pub fn connection_established( &mut self, ctx: &mut Context, - member_id: MemberId, + member_id: &str, con: Box, ) { // lookup previous member connection - if let Some(mut connection) = self.connections.remove(&member_id) { + if let Some(mut connection) = self.connections.remove(member_id) { debug!("Closing old RpcConnection for member {}", member_id); // cancel RpcConnection close task, since connection is // reestablished - if let Some(handler) = self.drop_connection_tasks.remove(&member_id) + if let Some(handler) = self.drop_connection_tasks.remove(member_id) { ctx.cancel_future(handler); } @@ -275,9 +275,9 @@ impl ParticipantService { } else { debug!("Connected member: {}", member_id); - self.create_and_interconnect_members_peers(ctx, member_id.clone()); + self.create_and_interconnect_members_peers(ctx, member_id); - self.connections.insert(member_id.clone(), con); + self.connections.insert(member_id.to_string(), con); } } diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index 6332a7f64..64a2b1d3d 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -5,7 +5,6 @@ use hashbrown::HashMap; use std::convert::{TryFrom, TryInto}; use crate::{ - api::control::MemberId, media::{Peer, PeerId, PeerStateMachine}, signalling::room::RoomError, }; @@ -119,7 +118,7 @@ impl PeerRepository { /// Panic if [`Peer`] not exists. pub fn get_peers_by_member_id( &self, - member_id: MemberId, + member_id: &str, ) -> Vec<&PeerStateMachine> { self.peers .iter() diff --git a/src/signalling/room.rs b/src/signalling/room.rs index ad3120637..72681a94b 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -262,7 +262,7 @@ impl Handler for Room { _ctx: &mut Self::Context, ) -> Self::Result { self.participants - .get_member_by_id_and_credentials(msg.member_id, &msg.credentials) + .get_member_by_id_and_credentials(&msg.member_id, &msg.credentials) .map(|_| ()) } } @@ -399,7 +399,7 @@ impl Handler for Room { // save new connection self.participants.connection_established( ctx, - msg.member_id, + &msg.member_id, msg.connection, ); From 0db5b4d1bff6255abe69f64d4384dc40c08e93f5 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 27 May 2019 17:53:12 +0300 Subject: [PATCH 047/735] Refactor --- jason/e2e-demo/js/index.js | 4 +++- src/signalling/participants.rs | 13 ++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/jason/e2e-demo/js/index.js b/jason/e2e-demo/js/index.js index a274cd135..697e2099e 100644 --- a/jason/e2e-demo/js/index.js +++ b/jason/e2e-demo/js/index.js @@ -8,7 +8,9 @@ async function f() { caller.join_room("ws://localhost:8080/ws/video-call-1/responder/test"); // Use this for testing with 3 members. - // caller.join_room("ws://localhost:8080/ws/1/2/2-credentials"); + // caller.join_room("ws://localhost:8080/ws/video-call-3/caller/test"); + // caller.join_room("ws://localhost:8080/ws/video-call-3/responder/test"); + // caller.join_room("ws://localhost:8080/ws/video-call-3/responder2/test"); // caller.join_room("ws://localhost:8080/ws/1/2/responder_credentials"); diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 330870aa2..d4a3087d5 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -3,7 +3,6 @@ //! [`RpcConnection`] authorization, establishment, message sending. use std::{ - sync::Arc, time::{Duration, Instant}, }; @@ -207,10 +206,10 @@ impl ParticipantService { let responder_member_signalling_id = if let Some(r) = self.members.get(responder_member_control_id) { - r.id.clone() + &r.id } else { warn!( - "Member with control id '{}' not found! Probably this is \ + "Member with id '{}' not found! Probably this is \ error in spec.", responder_member_control_id ); @@ -219,10 +218,10 @@ impl ParticipantService { }; let is_responder_connected = self - .member_has_connection(&responder_member_signalling_id); + .member_has_connection(responder_member_signalling_id); if is_responder_connected { let responder_spec = if let Some(m) = - self.members.get(&responder_member_signalling_id) + self.members.get(responder_member_signalling_id) { m.spec.clone() } else { @@ -231,7 +230,7 @@ impl ParticipantService { let responder = Member { id: responder_member_control_id.clone(), - spec: Arc::clone(&responder_spec), + spec: responder_spec, }; ctx.notify(CreatePeer { caller: responder, @@ -239,7 +238,7 @@ impl ParticipantService { }); } else if let Some(m) = self .members_waiting_connection - .get_mut(&responder_member_signalling_id) + .get_mut(responder_member_signalling_id) { m.push(connected_member.clone()); } else { From a8ea3c0cdd843dbfa3f74326ada3ddb80e6def92 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 27 May 2019 18:01:22 +0300 Subject: [PATCH 048/735] fmt --- src/api/client/session.rs | 7 ++----- src/api/control/member.rs | 7 +++---- src/media/peer.rs | 4 +--- src/signalling/participants.rs | 12 +++++------- src/signalling/peers.rs | 2 +- 5 files changed, 12 insertions(+), 20 deletions(-) diff --git a/src/api/client/session.rs b/src/api/client/session.rs index 8994209a7..8eddd7cb4 100644 --- a/src/api/client/session.rs +++ b/src/api/client/session.rs @@ -105,9 +105,6 @@ impl Actor for WsSession { self.start_watchdog(ctx); - // TODO: Fix this - let member_id1 = self.member_id.clone(); - let member_id2 = self.member_id.clone(); ctx.wait( wrap_future(self.room.send(RpcConnectionEstablished { member_id: self.member_id.clone(), @@ -121,7 +118,7 @@ impl Actor for WsSession { error!( "Room rejected Established for member {}, cause \ {:?}", - member_id1, e + session.member_id, e ); session.close_normal(ctx); } @@ -134,7 +131,7 @@ impl Actor for WsSession { error!( "WsSession of member {} failed to join Room, because: \ {:?}", - member_id2, send_err, + session.member_id, send_err, ); session.close_normal(ctx); }, diff --git a/src/api/control/member.rs b/src/api/control/member.rs index 5c63539dd..03305060d 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -80,10 +80,9 @@ impl TryFrom for MemberSpec { fn try_from(from: Entity) -> Result { match from { - Entity::Member { spec, credentials } => Ok(Self { - spec, - credentials, - }), + Entity::Member { spec, credentials } => { + Ok(Self { spec, credentials }) + } _ => Err(TryFromEntityError::NotMember), } } diff --git a/src/media/peer.rs b/src/media/peer.rs index a64607b0f..043906bef 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -12,9 +12,7 @@ use medea_client_api_proto::{ use std::{convert::TryFrom, fmt::Display, sync::Arc}; use crate::{ - api::control::{ - element::WebRtcPublishEndpoint, MemberId, - }, + api::control::{element::WebRtcPublishEndpoint, MemberId}, media::{MediaTrack, TrackId}, }; diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index d4a3087d5..1b5017dbd 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -2,9 +2,7 @@ //! stores [`Members`] and associated [`RpcConnection`]s, handles //! [`RpcConnection`] authorization, establishment, message sending. -use std::{ - time::{Duration, Instant}, -}; +use std::time::{Duration, Instant}; use actix::{fut::wrap_future, AsyncContext, Context, SpawnHandle}; use futures::{ @@ -209,16 +207,16 @@ impl ParticipantService { &r.id } else { warn!( - "Member with id '{}' not found! Probably this is \ - error in spec.", + "Member with id '{}' not found! Probably this is error in \ + spec.", responder_member_control_id ); // Maybe better return error here? continue; }; - let is_responder_connected = self - .member_has_connection(responder_member_signalling_id); + let is_responder_connected = + self.member_has_connection(responder_member_signalling_id); if is_responder_connected { let responder_spec = if let Some(m) = self.members.get(responder_member_signalling_id) diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index 64a2b1d3d..fc78ae9a0 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -4,11 +4,11 @@ use hashbrown::HashMap; use std::convert::{TryFrom, TryInto}; +use crate::api::control::Member; use crate::{ media::{Peer, PeerId, PeerStateMachine}, signalling::room::RoomError, }; -use crate::api::control::Member; #[derive(Debug)] pub struct PeerRepository { From 272539bbac86e8fea9b0f416432ca28297b47fd3 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 27 May 2019 18:17:58 +0300 Subject: [PATCH 049/735] Refactor --- src/signalling/participants.rs | 17 +++++++++-------- src/signalling/peers.rs | 2 +- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 1b5017dbd..8d141b118 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -49,7 +49,7 @@ pub struct ParticipantService { /// before dropping it irrevocably in case it gets reestablished. drop_connection_tasks: HashMap, - /// Stores [`NewPeer`]s which wait connection of another [`Member`]. + /// Stores [`Member`]s which wait connection of another [`Member`]. members_waiting_connection: HashMap>, } @@ -218,20 +218,21 @@ impl ParticipantService { let is_responder_connected = self.member_has_connection(responder_member_signalling_id); if is_responder_connected { - let responder_spec = if let Some(m) = + let responder = if let Some(m) = self.members.get(responder_member_signalling_id) { - m.spec.clone() + m } else { + warn!( + "Member with id {} not found, but this member has \ + connection!", + responder_member_signalling_id + ); continue; }; - let responder = Member { - id: responder_member_control_id.clone(), - spec: responder_spec, - }; ctx.notify(CreatePeer { - caller: responder, + caller: responder.clone(), responder: connected_member.clone(), }); } else if let Some(m) = self diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index fc78ae9a0..5eae3ca44 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -4,8 +4,8 @@ use hashbrown::HashMap; use std::convert::{TryFrom, TryInto}; -use crate::api::control::Member; use crate::{ + api::control::Member, media::{Peer, PeerId, PeerStateMachine}, signalling::room::RoomError, }; From 0c7455989b538efecfa6a712b1a6fdf77ec4335a Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 27 May 2019 18:25:03 +0300 Subject: [PATCH 050/735] Remove useless signalling_id --- src/signalling/participants.rs | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 8d141b118..54b88611c 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -198,35 +198,21 @@ impl ParticipantService { continue; } - let responder_member_control_id = + let responder_id = &connected_member_endpoint.src.member_id; - let responder_member_signalling_id = if let Some(r) = - self.members.get(responder_member_control_id) - { - &r.id - } else { - warn!( - "Member with id '{}' not found! Probably this is error in \ - spec.", - responder_member_control_id - ); - // Maybe better return error here? - continue; - }; - let is_responder_connected = - self.member_has_connection(responder_member_signalling_id); + self.member_has_connection(responder_id); if is_responder_connected { let responder = if let Some(m) = - self.members.get(responder_member_signalling_id) + self.members.get(responder_id) { m } else { warn!( "Member with id {} not found, but this member has \ connection!", - responder_member_signalling_id + responder_id ); continue; }; @@ -237,12 +223,12 @@ impl ParticipantService { }); } else if let Some(m) = self .members_waiting_connection - .get_mut(responder_member_signalling_id) + .get_mut(responder_id) { m.push(connected_member.clone()); } else { self.members_waiting_connection.insert( - responder_member_signalling_id.clone(), + responder_id.clone(), vec![connected_member.clone()], ); } From b466e044a7d8f563107a13a803b47777eb5bc9b9 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 27 May 2019 18:26:43 +0300 Subject: [PATCH 051/735] Fmt --- Cargo.toml | 2 +- src/signalling/participants.rs | 11 ++++------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 3b2896e56..b5d2f26e0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,7 +33,7 @@ medea-client-api-proto = { path = "proto/client-api", features = ['medea'] } newtype_derive = "0.1" serde = { version = "1.0", features = ['derive'] } serde_json = "1.0" -serde_yaml = "0.8.9" +serde_yaml = "0.8" slog = "2.4" slog-envlogger = "2.1" slog-stdlog = "3.0" diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 54b88611c..26a951f44 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -198,14 +198,12 @@ impl ParticipantService { continue; } - let responder_id = - &connected_member_endpoint.src.member_id; + let responder_id = &connected_member_endpoint.src.member_id; let is_responder_connected = self.member_has_connection(responder_id); if is_responder_connected { - let responder = if let Some(m) = - self.members.get(responder_id) + let responder = if let Some(m) = self.members.get(responder_id) { m } else { @@ -221,9 +219,8 @@ impl ParticipantService { caller: responder.clone(), responder: connected_member.clone(), }); - } else if let Some(m) = self - .members_waiting_connection - .get_mut(responder_id) + } else if let Some(m) = + self.members_waiting_connection.get_mut(responder_id) { m.push(connected_member.clone()); } else { From 9da50c5c40c34d80ff7c59aee32c1179166fca9a Mon Sep 17 00:00:00 2001 From: alexlapa Date: Tue, 28 May 2019 14:47:17 +0300 Subject: [PATCH 052/735] move room spec parsing to ParticipantService, refactor imports --- src/api/client/server.rs | 2 +- src/api/control/mod.rs | 5 ++-- src/main.rs | 24 ++++++++--------- src/signalling/participants.rs | 31 ++++++++++++++++----- src/signalling/room.rs | 49 +++++++++++----------------------- 5 files changed, 56 insertions(+), 55 deletions(-) diff --git a/src/api/client/server.rs b/src/api/client/server.rs index 9f6e26ed5..3f7f1de19 100644 --- a/src/api/client/server.rs +++ b/src/api/client/server.rs @@ -121,7 +121,7 @@ mod test { let room_spec = control::load_from_yaml_file("./specs/room_spec.yml").unwrap(); - let client_room = Room::new(room_spec, conf.reconnect_timeout); + let client_room = Room::new(&room_spec, conf.reconnect_timeout); let room_id = client_room.get_id(); let client_room = Arbiter::start(move |_| client_room); let room_hash_map = hashmap! { diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index 1b97d726a..9b37324b4 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -13,12 +13,11 @@ use std::{convert::TryFrom as _, fs::File, io::Read as _, path::Path}; use self::{ element::{WebRtcPlayEndpoint, WebRtcPublishEndpoint}, pipeline::Pipeline, - room::RoomSpec, }; pub use self::{ - member::{Id as MemberId, Member}, - room::Id as RoomId, + member::{Id as MemberId, Member, MemberSpec}, + room::{Id as RoomId, RoomSpec}, }; /// Errors that can occur when we try transform some spec from [`Entity`]. diff --git a/src/main.rs b/src/main.rs index 5a14da6f1..fd5628540 100644 --- a/src/main.rs +++ b/src/main.rs @@ -30,14 +30,20 @@ fn main() { let config = Conf::parse().unwrap(); info!("{:?}", config); - let rooms: HashMap> = if let Some(static_specs_path) = - config.server.static_specs_path.clone() - { + let room_repo = RoomsRepository::new(start_static_rooms(&config)); + + server::run(room_repo, config); + let _ = sys.run(); +} + +/// Parses static [`Room`]s from config and starts them in separate arbiters. +fn start_static_rooms(config: &Conf) -> HashMap> { + if let Some(static_specs_path) = config.server.static_specs_path.clone() { let room_specs = load_static_specs_from_dir(static_specs_path).unwrap(); room_specs .into_iter() - .map(|s| { - let room = Room::new(s, config.rpc.reconnect_timeout); + .map(|room_spec| { + let room = Room::new(&room_spec, config.rpc.reconnect_timeout); let room_id = room.get_id(); let room = Arbiter::start(move |_| room); @@ -46,11 +52,5 @@ fn main() { .collect() } else { HashMap::new() - }; - info!("Loaded static specs: {:?}", rooms); - - let room_repo = RoomsRepository::new(rooms); - - server::run(room_repo, config); - let _ = sys.run(); + } } diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 26a951f44..8ce992598 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -2,7 +2,11 @@ //! stores [`Members`] and associated [`RpcConnection`]s, handles //! [`RpcConnection`] authorization, establishment, message sending. -use std::time::{Duration, Instant}; +use std::{ + convert::TryFrom, + sync::Arc, + time::{Duration, Instant}, +}; use actix::{fut::wrap_future, AsyncContext, Context, SpawnHandle}; use futures::{ @@ -18,7 +22,7 @@ use crate::{ AuthorizationError, ClosedReason, EventMessage, RpcConnection, RpcConnectionClosed, }, - control::{Member, MemberId}, + control::{Member, MemberId, MemberSpec, RoomSpec}, }, log::prelude::*, signalling::{ @@ -54,10 +58,25 @@ pub struct ParticipantService { } impl ParticipantService { - pub fn new( - members: HashMap, - reconnect_timeout: Duration, - ) -> Self { + pub fn new(room_spec: &RoomSpec, reconnect_timeout: Duration) -> Self { + let members = room_spec + .spec + .pipeline + .iter() + .map(|(control_id, entity)| { + let member_spec = MemberSpec::try_from(entity.clone()).unwrap(); + + ( + control_id.clone(), + Member { + id: control_id.clone(), + spec: Arc::new(member_spec), + }, + ) + }) + .collect(); + debug!("Created room with {:?} users.", members); + Self { members, connections: HashMap::new(), diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 72681a94b..64f29ef21 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -1,6 +1,8 @@ //! Room definitions and implementations. Room is responsible for media //! connection establishment between concrete [`Member`]s. +use std::time::Duration; + use actix::{ fut::wrap_future, Actor, ActorFuture, AsyncContext, Context, Handler, Message, @@ -10,17 +12,13 @@ use futures::future; use hashbrown::HashMap; use medea_client_api_proto::{Command, Event, IceCandidate}; -use std::{convert::TryFrom, sync::Arc, time::Duration}; - use crate::{ api::{ client::rpc_connection::{ AuthorizationError, Authorize, CommandMessage, RpcConnectionClosed, RpcConnectionEstablished, }, - control::{ - member::MemberSpec, room::RoomSpec, Member, MemberId, RoomId, - }, + control::{Member, MemberId, RoomId, RoomSpec}, }, log::prelude::*, media::{ @@ -64,38 +62,23 @@ pub struct Room { /// [`Peer`]s of [`Member`]s in this [`Room`]. peers: PeerRepository, - - /// This [`Room`]'s control API specification. - spec: RoomSpec, } impl Room { /// Create new instance of [`Room`]. - pub fn new(room: RoomSpec, reconnect_timeout: Duration) -> Self { - let members = room - .spec - .pipeline - .iter() - .map(|(control_id, entity)| { - let member_spec = MemberSpec::try_from(entity.clone()).unwrap(); - - ( - control_id.clone(), - Member { - id: control_id.clone(), - spec: Arc::new(member_spec), - }, - ) - }) - .collect(); - debug!("Created room with {:?} users.", members); - - Self { - id: room.id.clone(), + pub fn new(room_spec: &RoomSpec, reconnect_timeout: Duration) -> Self { + let room = Self { + id: room_spec.id.clone(), peers: PeerRepository::from(HashMap::new()), - participants: ParticipantService::new(members, reconnect_timeout), - spec: room, - } + participants: ParticipantService::new( + &room_spec, + reconnect_timeout, + ), + }; + + info!("Starting new Room {:?}", room); + + room } pub fn get_id(&self) -> RoomId { @@ -461,7 +444,7 @@ mod test { fn start_room() -> Addr { let room_spec = control::load_from_yaml_file("./specs/room_spec_test.yml").unwrap(); - let client_room = Room::new(room_spec, Duration::from_secs(10)); + let client_room = Room::new(&room_spec, Duration::from_secs(10)); Arbiter::start(move |_| client_room) } From ef9ec3e940154d668ba37bb348fd606536334af8 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 28 May 2019 16:38:45 +0300 Subject: [PATCH 053/735] Rename spec and fix signalling_test --- signaling_test.html | 4 ++-- specs/{room_spec_test.yml => pub_sub_room.yml} | 4 ++-- specs/room_spec.yml | 4 ++-- specs/room_spec_with_3_members.yml | 12 ++++++------ src/signalling/room.rs | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) rename specs/{room_spec_test.yml => pub_sub_room.yml} (88%) diff --git a/signaling_test.html b/signaling_test.html index db8c8f7af..f986f1c12 100644 --- a/signaling_test.html +++ b/signaling_test.html @@ -10,8 +10,8 @@ var pcs = {}; function connectSocket(caller) { - let role = caller ? "1/caller_credentials" : "2/responder_credentials"; - socket = new WebSocket("ws://localhost:8080/ws/1/" + role); + let role = caller ? "caller/test" : "responder/test"; + socket = new WebSocket("ws://localhost:8080/ws/pub-sub-video-call/" + role); socket.onmessage = handleSocketMessage; window.setInterval(function () { diff --git a/specs/room_spec_test.yml b/specs/pub_sub_room.yml similarity index 88% rename from specs/room_spec_test.yml rename to specs/pub_sub_room.yml index 7438bd07c..bf8af54e4 100644 --- a/specs/room_spec_test.yml +++ b/specs/pub_sub_room.yml @@ -1,5 +1,5 @@ kind: Room -id: video-call-2 +id: pub-sub-video-call spec: pipeline: # Here we're defining a member who initiates video call. @@ -23,4 +23,4 @@ spec: play: kind: WebRtcPlayEndpoint spec: - src: "local://video-call-1/caller/publish" + src: "local://pub-sub-video-call/caller/publish" diff --git a/specs/room_spec.yml b/specs/room_spec.yml index e47af876c..936c8d69f 100644 --- a/specs/room_spec.yml +++ b/specs/room_spec.yml @@ -18,7 +18,7 @@ spec: play: kind: WebRtcPlayEndpoint spec: - src: "local://video-call-2/responder/publish" + src: "local://video-call-1/responder/publish" responder: kind: Member credentials: test @@ -31,4 +31,4 @@ spec: play: kind: WebRtcPlayEndpoint spec: - src: "local://video-call-2/caller/publish" + src: "local://video-call-1/caller/publish" diff --git a/specs/room_spec_with_3_members.yml b/specs/room_spec_with_3_members.yml index deaab7b54..d6511b2a7 100644 --- a/specs/room_spec_with_3_members.yml +++ b/specs/room_spec_with_3_members.yml @@ -18,11 +18,11 @@ spec: play: kind: WebRtcPlayEndpoint spec: - src: "local://video-call-2/responder/publish" + src: "local://video-call-3/responder/publish" play2: kind: WebRtcPlayEndpoint spec: - src: "local://video-call-2/responder2/publish" + src: "local://video-call-3/responder2/publish" responder: kind: Member credentials: test @@ -35,11 +35,11 @@ spec: play1: kind: WebRtcPlayEndpoint spec: - src: "local://video-call-2/caller/publish" + src: "local://video-call-3/caller/publish" play2: kind: WebRtcPlayEndpoint spec: - src: "local://video-call-2/responder2/publish" + src: "local://video-call-3/responder2/publish" responder2: kind: Member @@ -53,8 +53,8 @@ spec: play1: kind: WebRtcPlayEndpoint spec: - src: "local://video-call-2/caller/publish" + src: "local://video-call-3/caller/publish" play2: kind: WebRtcPlayEndpoint spec: - src: "local://video-call-2/responder/publish" + src: "local://video-call-3/responder/publish" diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 64f29ef21..109017293 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -443,7 +443,7 @@ mod test { fn start_room() -> Addr { let room_spec = - control::load_from_yaml_file("./specs/room_spec_test.yml").unwrap(); + control::load_from_yaml_file("./specs/pub_sub_room.yml").unwrap(); let client_room = Room::new(&room_spec, Duration::from_secs(10)); Arbiter::start(move |_| client_room) } From e94989f4a7ab3a222c8633d8722aed3ddf571352 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 29 May 2019 15:59:45 +0300 Subject: [PATCH 054/735] Add duplicate room ID check --- src/main.rs | 59 +++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 44 insertions(+), 15 deletions(-) diff --git a/src/main.rs b/src/main.rs index fd5628540..381e07fc9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,10 +13,13 @@ use dotenv::dotenv; use log::prelude::*; use crate::{ + api::control::RoomId, api::{client::server, control::load_static_specs_from_dir}, conf::Conf, signalling::{room_repo::RoomsRepository, Room}, }; + +use failure::Fail; use hashbrown::HashMap; fn main() { @@ -30,27 +33,53 @@ fn main() { let config = Conf::parse().unwrap(); info!("{:?}", config); - let room_repo = RoomsRepository::new(start_static_rooms(&config)); + match start_static_rooms(&config) { + Ok(r) => { + let room_repo = RoomsRepository::new(r); + server::run(room_repo, config); + } + Err(e) => { + error!("Server not started because of error: '{}'", e); + System::current().stop_with_code(100); + } + }; - server::run(room_repo, config); let _ = sys.run(); } +// TODO: add doc +#[derive(Debug, Fail)] +enum ServerStartError { + #[fail(display = "Duplicate of room ID '{}'", _0)] + DuplicateRoomId(RoomId), + #[fail(display = "Failed to load specs. {}", _0)] + LoadSpec(failure::Error), +} + +// TODO: update doc /// Parses static [`Room`]s from config and starts them in separate arbiters. -fn start_static_rooms(config: &Conf) -> HashMap> { +fn start_static_rooms( + config: &Conf, +) -> Result>, ServerStartError> { if let Some(static_specs_path) = config.server.static_specs_path.clone() { - let room_specs = load_static_specs_from_dir(static_specs_path).unwrap(); - room_specs - .into_iter() - .map(|room_spec| { - let room = Room::new(&room_spec, config.rpc.reconnect_timeout); - let room_id = room.get_id(); - let room = Arbiter::start(move |_| room); - - (room_id, room) - }) - .collect() + let room_specs = match load_static_specs_from_dir(static_specs_path) { + Ok(r) => r, + Err(e) => return Err(ServerStartError::LoadSpec(e)), + }; + let mut rooms = HashMap::new(); + + for spec in room_specs { + if rooms.contains_key(&spec.id) { + return Err(ServerStartError::DuplicateRoomId(spec.id)); + } + + let room = Room::new(&spec, config.rpc.reconnect_timeout); + let room = Arbiter::start(move |_| room); + rooms.insert(spec.id, room); + } + + Ok(rooms) } else { - HashMap::new() + Ok(HashMap::new()) } } From d5d2a4d7c019bd8b73d3e067af30edb913082648 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 29 May 2019 16:39:15 +0300 Subject: [PATCH 055/735] Use type alias --- src/api/control/member.rs | 4 ++-- src/api/control/room.rs | 5 +++-- src/signalling/participants.rs | 12 ++++++++---- src/signalling/peers.rs | 7 ++++--- src/signalling/room_repo.rs | 3 ++- 5 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/api/control/member.rs b/src/api/control/member.rs index 03305060d..2731525f2 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -44,7 +44,7 @@ impl MemberSpec { self.spec .pipeline .iter() - .filter_map(|(_name, e)| match e { + .filter_map(|(_, e)| match e { Entity::WebRtcPlayEndpoint { spec } => Some(spec), _ => None, }) @@ -67,7 +67,7 @@ impl MemberSpec { self.spec .pipeline .iter() - .filter_map(|(_name, e)| match e { + .filter_map(|(_, e)| match e { Entity::WebRtcPublishEndpoint { spec } => Some(spec), _ => None, }) diff --git a/src/api/control/room.rs b/src/api/control/room.rs index b8e35ce32..3f6838ed8 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -3,7 +3,7 @@ use std::convert::TryFrom; use super::{ - member::MemberSpec, pipeline::Pipeline, Entity, TryFromEntityError, + member::MemberSpec, pipeline::Pipeline, Entity, TryFromEntityError, MemberId, }; /// ID of [`Room`]. @@ -24,9 +24,10 @@ impl RoomSpec { /// Return `None` if [`MemberSpec`] not presented in [`RoomSpec`]. /// Return `Some(TryFromEntityError::NotMember)` if entity with this ID /// finded but its not [`MemberSpec`]. + #[allow(clippy::ptr_arg)] pub fn get_member( &self, - id: &str, + id: &MemberId, ) -> Option> { Some(MemberSpec::try_from(self.spec.pipeline.get(id).cloned()?)) } diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 8ce992598..7b64f33fe 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -90,9 +90,10 @@ impl ParticipantService { /// [`Err(AuthorizationError::MemberNotExists)`] if lookup by [`MemberId`] /// failed. Returns [`Err(AuthorizationError::InvalidCredentials)`] if /// [`Member`] was found, but incorrect credentials was provided. + #[allow(clippy::ptr_arg)] pub fn get_member_by_id_and_credentials( &self, - member_id: &str, + member_id: &MemberId, credentials: &str, ) -> Result<&Member, AuthorizationError> { match self.members.get(member_id) { @@ -108,7 +109,8 @@ impl ParticipantService { } /// Checks if [`Member`] has **active** [`RcpConnection`]. - pub fn member_has_connection(&self, member_id: &str) -> bool { + #[allow(clippy::ptr_arg)] + pub fn member_has_connection(&self, member_id: &MemberId) -> bool { self.connections.contains_key(member_id) && !self.drop_connection_tasks.contains_key(member_id) } @@ -190,10 +192,11 @@ impl ParticipantService { } /// Interconnect [`Peer`]s of members based on [`MemberSpec`]. + #[allow(clippy::ptr_arg)] fn create_and_interconnect_members_peers( &mut self, ctx: &mut Context, - member_id: &str, + member_id: &MemberId, ) { let connected_member = if let Some(m) = self.members.get(member_id) { m @@ -255,10 +258,11 @@ impl ParticipantService { /// If [`Member`] already has any other [`RpcConnection`], /// then it will be closed. /// Create and interconnect all necessary [`Member`]'s [`Peer`]. + #[allow(clippy::ptr_arg)] pub fn connection_established( &mut self, ctx: &mut Context, - member_id: &str, + member_id: &MemberId, con: Box, ) { // lookup previous member connection diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index 5eae3ca44..cf41a5bca 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -5,7 +5,7 @@ use hashbrown::HashMap; use std::convert::{TryFrom, TryInto}; use crate::{ - api::control::Member, + api::control::{Member, MemberId}, media::{Peer, PeerId, PeerStateMachine}, signalling::room::RoomError, }; @@ -116,14 +116,15 @@ impl PeerRepository { /// Returns [`Peer`] of specified [`Member`]. /// /// Panic if [`Peer`] not exists. + #[allow(clippy::ptr_arg)] pub fn get_peers_by_member_id( &self, - member_id: &str, + member_id: &MemberId, ) -> Vec<&PeerStateMachine> { self.peers .iter() .filter_map(|(_, peer)| { - if peer.member_id() == member_id { + if peer.member_id().as_str() == member_id.as_str() { Some(peer) } else { None diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs index 56f2fb0b5..35b17513d 100644 --- a/src/signalling/room_repo.rs +++ b/src/signalling/room_repo.rs @@ -24,7 +24,8 @@ impl RoomsRepository { } /// Returns [`Room`] by its ID. - pub fn get(&self, id: &str) -> Option> { + #[allow(clippy::ptr_arg)] + pub fn get(&self, id: &RoomId) -> Option> { let rooms = self.rooms.lock().unwrap(); rooms.get(id).cloned() } From f524a3d6d788d39edbb1694ed9512b5f134b9de5 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 29 May 2019 18:21:13 +0300 Subject: [PATCH 056/735] Change peer creation and interconnection algorithm --- src/api/control/mod.rs | 1 + src/api/control/room.rs | 3 +- src/signalling/participants.rs | 100 +++------------------------------ src/signalling/room.rs | 83 ++++++++++++++++++++++++--- 4 files changed, 84 insertions(+), 103 deletions(-) diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index 9b37324b4..8dc0708df 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -16,6 +16,7 @@ use self::{ }; pub use self::{ + element::Element, member::{Id as MemberId, Member, MemberSpec}, room::{Id as RoomId, RoomSpec}, }; diff --git a/src/api/control/room.rs b/src/api/control/room.rs index 3f6838ed8..60f44130c 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -3,7 +3,8 @@ use std::convert::TryFrom; use super::{ - member::MemberSpec, pipeline::Pipeline, Entity, TryFromEntityError, MemberId, + member::MemberSpec, pipeline::Pipeline, Entity, MemberId, + TryFromEntityError, }; /// ID of [`Room`]. diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 7b64f33fe..edaa7c26b 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -26,7 +26,7 @@ use crate::{ }, log::prelude::*, signalling::{ - room::{CloseRoom, CreatePeer, RoomError}, + room::{CloseRoom, RoomError}, Room, }, }; @@ -52,9 +52,6 @@ pub struct ParticipantService { /// If [`RpcConnection`] is lost, [`Room`] waits for connection_timeout /// before dropping it irrevocably in case it gets reestablished. drop_connection_tasks: HashMap, - - /// Stores [`Member`]s which wait connection of another [`Member`]. - members_waiting_connection: HashMap>, } impl ParticipantService { @@ -82,10 +79,15 @@ impl ParticipantService { connections: HashMap::new(), reconnect_timeout, drop_connection_tasks: HashMap::new(), - members_waiting_connection: HashMap::new(), } } + // TODO: add doc + #[allow(clippy::ptr_arg)] + pub fn get_member_by_id(&self, id: &MemberId) -> Option<&Member> { + self.members.get(id) + } + /// Lookup [`Member`] by provided id and credentials. Returns /// [`Err(AuthorizationError::MemberNotExists)`] if lookup by [`MemberId`] /// failed. Returns [`Err(AuthorizationError::InvalidCredentials)`] if @@ -169,95 +171,9 @@ impl ParticipantService { } } - /// Create [`Peer`]s between waiting [`Member`] and connected. - /// - /// Returns all control ID of members which we connected. - fn connect_waiting_members( - &self, - member: &Member, - ctx: &mut Context, - ) -> Vec { - let mut added_member = Vec::new(); - if let Some(waiters) = self.members_waiting_connection.get(&member.id) { - for waiter in waiters { - added_member.push(waiter.id.clone()); - - ctx.notify(CreatePeer { - caller: member.clone(), - responder: waiter.clone(), - }); - } - } - added_member - } - - /// Interconnect [`Peer`]s of members based on [`MemberSpec`]. - #[allow(clippy::ptr_arg)] - fn create_and_interconnect_members_peers( - &mut self, - ctx: &mut Context, - member_id: &MemberId, - ) { - let connected_member = if let Some(m) = self.members.get(member_id) { - m - } else { - warn!("Connected a non-existent member with id {}!", member_id); - // Maybe better return error here? - return; - }; - let connected_member_play_endpoints = - connected_member.spec.get_play_endpoints(); - - let added_waiting_members = - self.connect_waiting_members(&connected_member, ctx); - self.members_waiting_connection.remove(member_id); - - for connected_member_endpoint in connected_member_play_endpoints { - // Skip members which waiting for us because we added them before. - if added_waiting_members - .contains(&connected_member_endpoint.src.member_id) - { - continue; - } - - let responder_id = &connected_member_endpoint.src.member_id; - - let is_responder_connected = - self.member_has_connection(responder_id); - if is_responder_connected { - let responder = if let Some(m) = self.members.get(responder_id) - { - m - } else { - warn!( - "Member with id {} not found, but this member has \ - connection!", - responder_id - ); - continue; - }; - - ctx.notify(CreatePeer { - caller: responder.clone(), - responder: connected_member.clone(), - }); - } else if let Some(m) = - self.members_waiting_connection.get_mut(responder_id) - { - m.push(connected_member.clone()); - } else { - self.members_waiting_connection.insert( - responder_id.clone(), - vec![connected_member.clone()], - ); - } - } - } - /// Stores provided [`RpcConnection`] for given [`Member`] in the [`Room`]. /// If [`Member`] already has any other [`RpcConnection`], /// then it will be closed. - /// Create and interconnect all necessary [`Member`]'s [`Peer`]. #[allow(clippy::ptr_arg)] pub fn connection_established( &mut self, @@ -279,8 +195,6 @@ impl ParticipantService { } else { debug!("Connected member: {}", member_id); - self.create_and_interconnect_members_peers(ctx, member_id); - self.connections.insert(member_id.to_string(), con); } } diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 109017293..6789bfd51 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -1,7 +1,7 @@ //! Room definitions and implementations. Room is responsible for media //! connection establishment between concrete [`Member`]s. -use std::time::Duration; +use std::{convert::TryFrom, time::Duration}; use actix::{ fut::wrap_future, Actor, ActorFuture, AsyncContext, Context, Handler, @@ -18,7 +18,7 @@ use crate::{ AuthorizationError, Authorize, CommandMessage, RpcConnectionClosed, RpcConnectionEstablished, }, - control::{Member, MemberId, RoomId, RoomSpec}, + control::{Element, Member, MemberId, MemberSpec, RoomId, RoomSpec}, }, log::prelude::*, media::{ @@ -62,23 +62,47 @@ pub struct Room { /// [`Peer`]s of [`Member`]s in this [`Room`]. peers: PeerRepository, + + // TODO: add doc + member_receivers: HashMap>, } impl Room { /// Create new instance of [`Room`]. pub fn new(room_spec: &RoomSpec, reconnect_timeout: Duration) -> Self { - let room = Self { + // TODO: Need refactor + let mut member_receivers: HashMap> = + HashMap::new(); + for (member_id, member_entity) in &room_spec.spec.pipeline { + let member = MemberSpec::try_from(member_entity.clone()).unwrap(); + for element_entity in member.spec.pipeline.values() { + let element = + Element::try_from(element_entity.clone()).unwrap(); + + if let Element::WebRtcPlayEndpoint(play) = element { + if let Some(m) = + member_receivers.get_mut(&play.src.member_id) + { + m.push(member_id.clone()); + } else { + member_receivers.insert( + play.src.member_id.clone(), + vec![member_id.clone()], + ); + } + } + } + } + + Self { id: room_spec.id.clone(), peers: PeerRepository::from(HashMap::new()), participants: ParticipantService::new( &room_spec, reconnect_timeout, ), - }; - - info!("Starting new Room {:?}", room); - - room + member_receivers, + } } pub fn get_id(&self) -> RoomId { @@ -314,7 +338,7 @@ impl Handler for Room { ctx.notify(ConnectPeers(caller_peer_id, responder_peer_id)); - // println!("Peers: {:#?}", self.peers); + // println!("Peers: {:#?}", self.peers); Ok(()) } @@ -369,6 +393,7 @@ impl Handler for Room { impl Handler for Room { type Result = ActFuture<(), ()>; + // TODO: update doc /// Saves new [`RpcConnection`] in [`ParticipantService`], initiates media /// establishment between members. /// Create and interconnect all necessary [`Member`]'s [`Peer`]. @@ -386,6 +411,46 @@ impl Handler for Room { msg.connection, ); + let member_id = &msg.member_id; + let member = self.participants.get_member_by_id(member_id).unwrap(); + + // connect receivers + let mut already_connected_members = Vec::new(); + if let Some(m) = self.member_receivers.get(member_id) { + for recv_member_id in m { + if self.participants.member_has_connection(recv_member_id) { + let recv_member = self + .participants + .get_member_by_id(recv_member_id) + .unwrap(); + already_connected_members.push(recv_member_id.clone()); + ctx.notify(CreatePeer { + caller: recv_member.clone(), + responder: member.clone(), + }); + } + } + } + + // connect senders + for play in member.spec.get_play_endpoints() { + let sender_member_id = &play.src.member_id; + if already_connected_members.contains(sender_member_id) { + continue; + } + + if self.participants.member_has_connection(sender_member_id) { + let sender_member = self + .participants + .get_member_by_id(sender_member_id) + .unwrap(); + ctx.notify(CreatePeer { + caller: sender_member.clone(), + responder: member.clone(), + }); + } + } + Box::new(wrap_future(future::ok(()))) } } From 8fa9b2c3b8ef2f27dd6c1879e5d312ffccd6b16d Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 29 May 2019 18:51:13 +0300 Subject: [PATCH 057/735] Add and upd docs --- src/api/control/mod.rs | 6 ++--- src/main.rs | 34 +++++++++++++++++++++--- src/signalling/participants.rs | 2 +- src/signalling/room.rs | 48 ++++++++++++++++++++++------------ 4 files changed, 67 insertions(+), 23 deletions(-) diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index 8dc0708df..b03c657ad 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -26,11 +26,11 @@ pub use self::{ #[derive(Debug, Fail)] #[allow(clippy::pub_enum_variant_names)] pub enum TryFromEntityError { - #[fail(display = "This entity is not Element")] + #[fail(display = "Entity is not Element")] NotElement, - #[fail(display = "This entity is not Room")] + #[fail(display = "Entity is not Room")] NotRoom, - #[fail(display = "This entity is not Member")] + #[fail(display = "Entity is not Member")] NotMember, } diff --git a/src/main.rs b/src/main.rs index 381e07fc9..4d5f4f015 100644 --- a/src/main.rs +++ b/src/main.rs @@ -17,6 +17,7 @@ use crate::{ api::{client::server, control::load_static_specs_from_dir}, conf::Conf, signalling::{room_repo::RoomsRepository, Room}, + signalling::room::RoomError }; use failure::Fail; @@ -47,17 +48,44 @@ fn main() { let _ = sys.run(); } -// TODO: add doc +/// Errors which can happen while server starting. #[derive(Debug, Fail)] enum ServerStartError { + /// Duplicate room ID finded. #[fail(display = "Duplicate of room ID '{}'", _0)] DuplicateRoomId(RoomId), + + /// Some error happened while loading spec. #[fail(display = "Failed to load specs. {}", _0)] LoadSpec(failure::Error), + + /// Some error happened while creating new room from spec. + #[fail(display = "Bad room spec. {}", _0)] + BadRoomSpec(String), + + /// Unexpected error returned from room. + #[fail(display = "Unknown room error.")] + UnknownRoomError, +} + +impl From for ServerStartError { + fn from(err: RoomError) -> Self { + match err { + RoomError::BadRoomSpec(m) => ServerStartError::BadRoomSpec(m), + _ => ServerStartError::UnknownRoomError, + } + } } -// TODO: update doc /// Parses static [`Room`]s from config and starts them in separate arbiters. +/// +/// Returns [`ServerStartError::DuplicateRoomId`] if find duplicated room ID. +/// +/// Returns [`ServerStartError::LoadSpec`] if some error happened +/// while loading spec. +/// +/// Returns [`ServerStartError::BadRoomSpec`] +/// if some error happened while creating room from spec. fn start_static_rooms( config: &Conf, ) -> Result>, ServerStartError> { @@ -73,7 +101,7 @@ fn start_static_rooms( return Err(ServerStartError::DuplicateRoomId(spec.id)); } - let room = Room::new(&spec, config.rpc.reconnect_timeout); + let room = Room::new(&spec, config.rpc.reconnect_timeout)?; let room = Arbiter::start(move |_| room); rooms.insert(spec.id, room); } diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index edaa7c26b..63790eaec 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -82,7 +82,7 @@ impl ParticipantService { } } - // TODO: add doc + /// Lookup [`Member`] by provided id. #[allow(clippy::ptr_arg)] pub fn get_member_by_id(&self, id: &MemberId) -> Option<&Member> { self.members.get(id) diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 6789bfd51..f0dc57f5a 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -18,7 +18,10 @@ use crate::{ AuthorizationError, Authorize, CommandMessage, RpcConnectionClosed, RpcConnectionEstablished, }, - control::{Element, Member, MemberId, MemberSpec, RoomId, RoomSpec}, + control::{ + Element, Member, MemberId, MemberSpec, RoomId, RoomSpec, + TryFromEntityError, + }, }, log::prelude::*, media::{ @@ -52,6 +55,15 @@ impl From for RoomError { } } +impl From for RoomError { + fn from(err: TryFromEntityError) -> Self { + RoomError::BadRoomSpec(format!( + "Entity occured in wrong place. {}", + err + )) + } +} + /// Media server room with its [`Member`]s. #[derive(Debug)] pub struct Room { @@ -63,29 +75,33 @@ pub struct Room { /// [`Peer`]s of [`Member`]s in this [`Room`]. peers: PeerRepository, - // TODO: add doc - member_receivers: HashMap>, + /// Stores [`MemberId`]s of all sender's receivers. + /// + /// __Key__ is sender's [`MemberId`]. + /// __Value__ is all sender's receivers. + sender_receivers: HashMap>, } impl Room { /// Create new instance of [`Room`]. - pub fn new(room_spec: &RoomSpec, reconnect_timeout: Duration) -> Self { - // TODO: Need refactor - let mut member_receivers: HashMap> = + pub fn new( + room_spec: &RoomSpec, + reconnect_timeout: Duration, + ) -> Result { + let mut sender_receivers: HashMap> = HashMap::new(); for (member_id, member_entity) in &room_spec.spec.pipeline { - let member = MemberSpec::try_from(member_entity.clone()).unwrap(); + let member = MemberSpec::try_from(member_entity.clone())?; for element_entity in member.spec.pipeline.values() { - let element = - Element::try_from(element_entity.clone()).unwrap(); + let element = Element::try_from(element_entity.clone())?; if let Element::WebRtcPlayEndpoint(play) = element { if let Some(m) = - member_receivers.get_mut(&play.src.member_id) + sender_receivers.get_mut(&play.src.member_id) { m.push(member_id.clone()); } else { - member_receivers.insert( + sender_receivers.insert( play.src.member_id.clone(), vec![member_id.clone()], ); @@ -94,15 +110,15 @@ impl Room { } } - Self { + Ok(Self { id: room_spec.id.clone(), peers: PeerRepository::from(HashMap::new()), participants: ParticipantService::new( &room_spec, reconnect_timeout, ), - member_receivers, - } + sender_receivers, + }) } pub fn get_id(&self) -> RoomId { @@ -393,7 +409,6 @@ impl Handler for Room { impl Handler for Room { type Result = ActFuture<(), ()>; - // TODO: update doc /// Saves new [`RpcConnection`] in [`ParticipantService`], initiates media /// establishment between members. /// Create and interconnect all necessary [`Member`]'s [`Peer`]. @@ -411,12 +426,13 @@ impl Handler for Room { msg.connection, ); + // TODO: move it into separate fn let member_id = &msg.member_id; let member = self.participants.get_member_by_id(member_id).unwrap(); // connect receivers let mut already_connected_members = Vec::new(); - if let Some(m) = self.member_receivers.get(member_id) { + if let Some(m) = self.sender_receivers.get(member_id) { for recv_member_id in m { if self.participants.member_has_connection(recv_member_id) { let recv_member = self From 98f1db930f303a5576cc2027376c5e87980b2fce Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 29 May 2019 19:09:10 +0300 Subject: [PATCH 058/735] Refactor --- src/api/client/server.rs | 3 +- src/main.rs | 2 +- src/signalling/room.rs | 67 +++++++++++++++++++++++++--------------- 3 files changed, 45 insertions(+), 27 deletions(-) diff --git a/src/api/client/server.rs b/src/api/client/server.rs index 3f7f1de19..3c3d9dfd1 100644 --- a/src/api/client/server.rs +++ b/src/api/client/server.rs @@ -121,7 +121,8 @@ mod test { let room_spec = control::load_from_yaml_file("./specs/room_spec.yml").unwrap(); - let client_room = Room::new(&room_spec, conf.reconnect_timeout); + let client_room = + Room::new(&room_spec, conf.reconnect_timeout).unwrap(); let room_id = client_room.get_id(); let client_room = Arbiter::start(move |_| client_room); let room_hash_map = hashmap! { diff --git a/src/main.rs b/src/main.rs index 4d5f4f015..c3198504a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -16,8 +16,8 @@ use crate::{ api::control::RoomId, api::{client::server, control::load_static_specs_from_dir}, conf::Conf, + signalling::room::RoomError, signalling::{room_repo::RoomsRepository, Room}, - signalling::room::RoomError }; use failure::Fail; diff --git a/src/signalling/room.rs b/src/signalling/room.rs index f0dc57f5a..4c8c25940 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -84,6 +84,9 @@ pub struct Room { impl Room { /// Create new instance of [`Room`]. + /// + /// Returns [`RoomError::BadRoomSpec`] when error in [`Entity`] + /// transformation happens. pub fn new( room_spec: &RoomSpec, reconnect_timeout: Duration, @@ -102,7 +105,7 @@ impl Room { m.push(member_id.clone()); } else { sender_receivers.insert( - play.src.member_id.clone(), + play.src.member_id, vec![member_id.clone()], ); } @@ -113,10 +116,7 @@ impl Room { Ok(Self { id: room_spec.id.clone(), peers: PeerRepository::from(HashMap::new()), - participants: ParticipantService::new( - &room_spec, - reconnect_timeout, - ), + participants: ParticipantService::new(room_spec, reconnect_timeout), sender_receivers, }) } @@ -406,34 +406,26 @@ impl Handler for Room { } } -impl Handler for Room { - type Result = ActFuture<(), ()>; +#[derive(Debug, Message)] +#[rtype(result = "()")] +struct CreateNecessaryMemberPeers(MemberId); + +impl Handler for Room { + type Result = (); - /// Saves new [`RpcConnection`] in [`ParticipantService`], initiates media - /// establishment between members. /// Create and interconnect all necessary [`Member`]'s [`Peer`]. fn handle( &mut self, - msg: RpcConnectionEstablished, + msg: CreateNecessaryMemberPeers, ctx: &mut Self::Context, - ) -> Self::Result { - info!("RpcConnectionEstablished for member {}", msg.member_id); - - // save new connection - self.participants.connection_established( - ctx, - &msg.member_id, - msg.connection, - ); - - // TODO: move it into separate fn - let member_id = &msg.member_id; + ) { + let member_id = &msg.0; let member = self.participants.get_member_by_id(member_id).unwrap(); // connect receivers let mut already_connected_members = Vec::new(); - if let Some(m) = self.sender_receivers.get(member_id) { - for recv_member_id in m { + if let Some(receivers) = self.sender_receivers.get(member_id) { + for recv_member_id in receivers { if self.participants.member_has_connection(recv_member_id) { let recv_member = self .participants @@ -466,6 +458,30 @@ impl Handler for Room { }); } } + } +} + +impl Handler for Room { + type Result = ActFuture<(), ()>; + + /// Saves new [`RpcConnection`] in [`ParticipantService`], initiates media + /// establishment between members. + /// Create and interconnect all necessary [`Member`]'s [`Peer`]. + fn handle( + &mut self, + msg: RpcConnectionEstablished, + ctx: &mut Self::Context, + ) -> Self::Result { + info!("RpcConnectionEstablished for member {}", msg.member_id); + + // save new connection + self.participants.connection_established( + ctx, + &msg.member_id, + msg.connection, + ); + + ctx.notify(CreateNecessaryMemberPeers(msg.member_id)); Box::new(wrap_future(future::ok(()))) } @@ -525,7 +541,8 @@ mod test { fn start_room() -> Addr { let room_spec = control::load_from_yaml_file("./specs/pub_sub_room.yml").unwrap(); - let client_room = Room::new(&room_spec, Duration::from_secs(10)); + let client_room = + Room::new(&room_spec, Duration::from_secs(10)).unwrap(); Arbiter::start(move |_| client_room) } From ad66e34b79cbb382164a4beb3d91c86f65322d61 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 29 May 2019 19:18:48 +0300 Subject: [PATCH 059/735] Remove unwraps --- src/signalling/room.rs | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 4c8c25940..855df0390 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -420,22 +420,40 @@ impl Handler for Room { ctx: &mut Self::Context, ) { let member_id = &msg.0; - let member = self.participants.get_member_by_id(member_id).unwrap(); + let member = + if let Some(m) = self.participants.get_member_by_id(member_id) { + m + } else { + error!( + "Try to create necessary peers for nonexistent member \ + with ID {}. Room will be stopped.", + member_id + ); + ctx.notify(CloseRoom {}); + return; + }; // connect receivers let mut already_connected_members = Vec::new(); if let Some(receivers) = self.sender_receivers.get(member_id) { for recv_member_id in receivers { if self.participants.member_has_connection(recv_member_id) { - let recv_member = self - .participants - .get_member_by_id(recv_member_id) - .unwrap(); - already_connected_members.push(recv_member_id.clone()); - ctx.notify(CreatePeer { - caller: recv_member.clone(), - responder: member.clone(), - }); + if let Some(recv_member) = + self.participants.get_member_by_id(recv_member_id) + { + already_connected_members.push(recv_member_id.clone()); + ctx.notify(CreatePeer { + caller: recv_member.clone(), + responder: member.clone(), + }); + } else { + error!( + "Try to create peer for nonexistent member with \ + ID {}. Room wil be stopped.", + recv_member_id + ); + ctx.notify(CloseRoom {}); + } } } } From 63edb964874181edd6faa10ced236bd8a727065d Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 29 May 2019 19:42:47 +0300 Subject: [PATCH 060/735] Refactor --- src/api/control/element.rs | 7 ++++--- src/api/control/member.rs | 4 ++-- src/api/control/mod.rs | 2 +- src/api/control/room.rs | 2 +- src/media/track.rs | 2 +- src/signalling/room.rs | 21 +++++++++++---------- 6 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/api/control/element.rs b/src/api/control/element.rs index 234d8a27f..49f94330c 100644 --- a/src/api/control/element.rs +++ b/src/api/control/element.rs @@ -16,6 +16,7 @@ pub enum Element { WebRtcPublishEndpoint(WebRtcPublishEndpoint), WebRtcPlayEndpoint(WebRtcPlayEndpoint), } + impl TryFrom for Element { type Error = TryFromEntityError; @@ -32,16 +33,16 @@ impl TryFrom for Element { } } -#[derive(Deserialize, Debug, Clone)] /// Peer-to-peer mode of [`WebRtcPublishEndpoint`]. +#[derive(Deserialize, Debug, Clone)] pub enum P2pMode { /// Always connect peer-to-peer. Always, } -#[derive(Deserialize, Debug, Clone)] /// Media element which is able to publish media data for another client via /// WebRTC. +#[derive(Deserialize, Debug, Clone)] pub struct WebRtcPublishEndpoint { /// Peer-to-peer mode. pub p2p: P2pMode, @@ -54,8 +55,8 @@ pub struct WebRtcPlayEndpoint { pub src: LocalUri, } -#[derive(Debug, Clone)] /// Special uri with pattern `local://{room_id}/{member_id}/{pipeline_id}`. +#[derive(Debug, Clone)] pub struct LocalUri { /// ID of [`Room`] // TODO: Why this field never used??? diff --git a/src/api/control/member.rs b/src/api/control/member.rs index 2731525f2..b2968bec6 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -20,8 +20,8 @@ pub struct Member { } /// Newtype for [`Entity::Member`] variant. -#[derive(Clone, Debug)] #[allow(clippy::module_name_repetitions)] +#[derive(Clone, Debug)] pub struct MemberSpec { /// Spec of this [`Member`]. pub spec: Pipeline, @@ -52,7 +52,7 @@ impl MemberSpec { } /// Get all [`WebRtcPlayEndpoint`]s by ID of [`MemberSpec`]. - pub fn get_play_endpoint_by_member_id( + pub fn get_play_endpoints_by_member_id( &self, src: &str, ) -> Vec<&WebRtcPlayEndpoint> { diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index b03c657ad..6cd193571 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -23,8 +23,8 @@ pub use self::{ /// Errors that can occur when we try transform some spec from [`Entity`]. /// This error used in all [`TryFrom`] of Control API. -#[derive(Debug, Fail)] #[allow(clippy::pub_enum_variant_names)] +#[derive(Debug, Fail)] pub enum TryFromEntityError { #[fail(display = "Entity is not Element")] NotElement, diff --git a/src/api/control/room.rs b/src/api/control/room.rs index 60f44130c..9f465eed2 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -12,8 +12,8 @@ pub type Id = String; /// [`crate::signalling::room::Room`] specification. /// Newtype for [`Entity::Room`] -#[derive(Clone, Debug)] #[allow(clippy::module_name_repetitions)] +#[derive(Clone, Debug)] pub struct RoomSpec { pub id: Id, pub spec: Pipeline, diff --git a/src/media/track.rs b/src/media/track.rs index 3f21550ce..20f385259 100644 --- a/src/media/track.rs +++ b/src/media/track.rs @@ -8,8 +8,8 @@ use medea_client_api_proto::MediaType; pub type Id = u64; /// [`MediaStreamTrack`] representation. -#[derive(Debug)] #[allow(clippy::module_name_repetitions)] +#[derive(Debug)] pub struct MediaTrack { pub id: Id, pub media_type: MediaType, diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 855df0390..63f096859 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -34,8 +34,8 @@ use crate::{ /// Ergonomic type alias for using [`ActorFuture`] for [`Room`]. type ActFuture = Box>; -#[derive(Fail, Debug)] #[allow(clippy::module_name_repetitions)] +#[derive(Fail, Debug)] pub enum RoomError { #[fail(display = "Couldn't find Peer with [id = {}]", _0)] PeerNotFound(PeerId), @@ -85,7 +85,7 @@ pub struct Room { impl Room { /// Create new instance of [`Room`]. /// - /// Returns [`RoomError::BadRoomSpec`] when error in [`Entity`] + /// Returns [`RoomError::BadRoomSpec`] when error while [`Entity`] /// transformation happens. pub fn new( room_spec: &RoomSpec, @@ -121,6 +121,7 @@ impl Room { }) } + /// Returns [`RoomId`] of this [`Room`]. pub fn get_id(&self) -> RoomId { self.id.clone() } @@ -330,18 +331,18 @@ impl Handler for Room { #[derive(Debug, Message)] #[rtype(result = "Result<(), ()>")] -pub struct CreatePeer { +pub struct CreatePeers { pub caller: Member, pub responder: Member, } -impl Handler for Room { +impl Handler for Room { type Result = Result<(), ()>; /// Create [`Peer`] between members and interconnect it by control API spec. fn handle( &mut self, - msg: CreatePeer, + msg: CreatePeers, ctx: &mut Self::Context, ) -> Self::Result { debug!( @@ -413,7 +414,7 @@ struct CreateNecessaryMemberPeers(MemberId); impl Handler for Room { type Result = (); - /// Create and interconnect all necessary [`Member`]'s [`Peer`]. + /// Create and interconnect all necessary [`Member`]'s [`Peer`]s. fn handle( &mut self, msg: CreateNecessaryMemberPeers, @@ -442,7 +443,7 @@ impl Handler for Room { self.participants.get_member_by_id(recv_member_id) { already_connected_members.push(recv_member_id.clone()); - ctx.notify(CreatePeer { + ctx.notify(CreatePeers { caller: recv_member.clone(), responder: member.clone(), }); @@ -470,7 +471,7 @@ impl Handler for Room { .participants .get_member_by_id(sender_member_id) .unwrap(); - ctx.notify(CreatePeer { + ctx.notify(CreatePeers { caller: sender_member.clone(), responder: member.clone(), }); @@ -484,7 +485,7 @@ impl Handler for Room { /// Saves new [`RpcConnection`] in [`ParticipantService`], initiates media /// establishment between members. - /// Create and interconnect all necessary [`Member`]'s [`Peer`]. + /// Create and interconnect all necessary [`Member`]'s [`Peer`]s. fn handle( &mut self, msg: RpcConnectionEstablished, @@ -506,9 +507,9 @@ impl Handler for Room { } /// Signal of close [`Room`]. +#[allow(clippy::module_name_repetitions)] #[derive(Debug, Message)] #[rtype(result = "()")] -#[allow(clippy::module_name_repetitions)] pub struct CloseRoom {} impl Handler for Room { From 491252082cd3ceb22c10e1a94b5881c1eec91d83 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 29 May 2019 20:13:06 +0300 Subject: [PATCH 061/735] Improve signalling_test.html --- signaling_test.html | 40 +++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/signaling_test.html b/signaling_test.html index f986f1c12..beb5b82a9 100644 --- a/signaling_test.html +++ b/signaling_test.html @@ -152,17 +152,47 @@ } + + -
-
-
+
+
+ You
-
+
+ Partner
-
+
+ + +
From 9ef8920945255f8df6f787a2a91df52bf10ead80 Mon Sep 17 00:00:00 2001 From: alexlapa Date: Thu, 30 May 2019 14:16:03 +0300 Subject: [PATCH 062/735] use newtype for MemberId --- src/api/control/element.rs | 17 +++++++++++------ src/api/control/member.rs | 24 +++++++++++------------- src/api/control/room.rs | 4 +++- src/media/peer.rs | 7 ++++++- src/signalling/participants.rs | 7 +++---- src/signalling/peers.rs | 2 +- src/signalling/room.rs | 5 +++-- 7 files changed, 38 insertions(+), 28 deletions(-) diff --git a/src/api/control/element.rs b/src/api/control/element.rs index 49f94330c..a1821149f 100644 --- a/src/api/control/element.rs +++ b/src/api/control/element.rs @@ -1,11 +1,13 @@ //! Control API specification Element definitions. +use std::{convert::TryFrom, fmt}; + use serde::{ de::{self, Deserializer, Error, Visitor}, Deserialize, }; -use std::{convert::TryFrom, fmt}; +use crate::api::control::MemberId; use super::{Entity, TryFromEntityError}; @@ -62,7 +64,7 @@ pub struct LocalUri { // TODO: Why this field never used??? pub room_id: String, /// ID of [`Member`] - pub member_id: String, + pub member_id: MemberId, /// Control ID of [`Element`] pub pipeline_id: String, } @@ -128,7 +130,7 @@ impl<'de> Deserialize<'de> for LocalUri { Ok(LocalUri { room_id, - member_id, + member_id: MemberId(member_id), pipeline_id, }) } @@ -156,9 +158,12 @@ mod test { let local_uri: LocalUriTest = serde_json::from_str(valid_json_uri).unwrap(); - assert_eq!(local_uri.src.member_id, "member_id".to_string()); - assert_eq!(local_uri.src.room_id, "room_id".to_string()); - assert_eq!(local_uri.src.pipeline_id, "pipeline_id".to_string()); + assert_eq!( + local_uri.src.member_id, + MemberId(String::from("member_id")) + ); + assert_eq!(local_uri.src.room_id, String::from("room_id")); + assert_eq!(local_uri.src.pipeline_id, String::from("pipeline_id")); } #[test] diff --git a/src/api/control/member.rs b/src/api/control/member.rs index b2968bec6..8b88d40b7 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -1,13 +1,22 @@ //! Member definitions and implementations. -use std::{convert::TryFrom, sync::Arc}; +use std::{convert::TryFrom, fmt::Display, sync::Arc}; + +use serde::Deserialize; use super::{element::Element, pipeline::Pipeline, Entity, TryFromEntityError}; use crate::api::control::element::{WebRtcPlayEndpoint, WebRtcPublishEndpoint}; /// ID of [`Member`]. -pub type Id = String; +#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq)] +pub struct Id(pub String); + +impl Display for Id { + fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(fmt, "{}", self.0) + } +} /// Media server user with its ID and credentials. #[derive(Debug, Clone)] @@ -51,17 +60,6 @@ impl MemberSpec { .collect() } - /// Get all [`WebRtcPlayEndpoint`]s by ID of [`MemberSpec`]. - pub fn get_play_endpoints_by_member_id( - &self, - src: &str, - ) -> Vec<&WebRtcPlayEndpoint> { - self.get_play_endpoints() - .into_iter() - .filter(|endpoint| endpoint.src.member_id == src) - .collect() - } - /// Get all [`WebRtcPublishEndpoint`]s of this [`MemberSpec`]. pub fn get_publish_endpoints(&self) -> Vec<&WebRtcPublishEndpoint> { self.spec diff --git a/src/api/control/room.rs b/src/api/control/room.rs index 9f465eed2..9e51d202b 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -30,7 +30,9 @@ impl RoomSpec { &self, id: &MemberId, ) -> Option> { - Some(MemberSpec::try_from(self.spec.pipeline.get(id).cloned()?)) + Some(MemberSpec::try_from( + self.spec.pipeline.get(&id.0).cloned()?, + )) } } diff --git a/src/media/peer.rs b/src/media/peer.rs index 25bb398d4..0e87fa645 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -347,7 +347,12 @@ mod test { #[test] fn create_peer() { - let peer = Peer::new(1, "1".to_string(), 2, "2".to_string()); + let peer = Peer::new( + 1, + MemberId(String::from("1")), + 2, + MemberId(String::from("2")), + ); let peer = peer.start(); assert_eq!(peer.state, WaitLocalSdp {}); diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 63790eaec..cf0d2c712 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -64,9 +64,9 @@ impl ParticipantService { let member_spec = MemberSpec::try_from(entity.clone()).unwrap(); ( - control_id.clone(), + MemberId(control_id.clone()), Member { - id: control_id.clone(), + id: MemberId(control_id.clone()), spec: Arc::new(member_spec), }, ) @@ -174,7 +174,6 @@ impl ParticipantService { /// Stores provided [`RpcConnection`] for given [`Member`] in the [`Room`]. /// If [`Member`] already has any other [`RpcConnection`], /// then it will be closed. - #[allow(clippy::ptr_arg)] pub fn connection_established( &mut self, ctx: &mut Context, @@ -195,7 +194,7 @@ impl ParticipantService { } else { debug!("Connected member: {}", member_id); - self.connections.insert(member_id.to_string(), con); + self.connections.insert(member_id.clone(), con); } } diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index cf41a5bca..7fa62ea09 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -124,7 +124,7 @@ impl PeerRepository { self.peers .iter() .filter_map(|(_, peer)| { - if peer.member_id().as_str() == member_id.as_str() { + if &peer.member_id() == member_id { Some(peer) } else { None diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 63f096859..90ba2a179 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -94,6 +94,7 @@ impl Room { let mut sender_receivers: HashMap> = HashMap::new(); for (member_id, member_entity) in &room_spec.spec.pipeline { + let member_id = MemberId(member_id.clone()); let member = MemberSpec::try_from(member_entity.clone())?; for element_entity in member.spec.pipeline.values() { let element = Element::try_from(element_entity.clone())?; @@ -579,13 +580,13 @@ mod test { let stopped_clone = stopped.clone(); Arbiter::start(move |_| TestConnection { events: caller_events_clone, - member_id: "caller".to_string(), + member_id: MemberId(String::from("caller")), room: room_clone, stopped: stopped_clone, }); Arbiter::start(move |_| TestConnection { events: responder_events_clone, - member_id: "responder".to_string(), + member_id: MemberId(String::from("responder")), room, stopped, }); From 229ff1bcc455983182ccc3d7bbd2f9c9f8673ee3 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 30 May 2019 17:28:48 +0300 Subject: [PATCH 063/735] Remove useless Result --- src/signalling/room.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 90ba2a179..ce520248c 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -331,14 +331,14 @@ impl Handler for Room { } #[derive(Debug, Message)] -#[rtype(result = "Result<(), ()>")] +#[rtype(result = "()")] pub struct CreatePeers { pub caller: Member, pub responder: Member, } impl Handler for Room { - type Result = Result<(), ()>; + type Result = (); /// Create [`Peer`] between members and interconnect it by control API spec. fn handle( @@ -357,8 +357,6 @@ impl Handler for Room { ctx.notify(ConnectPeers(caller_peer_id, responder_peer_id)); // println!("Peers: {:#?}", self.peers); - - Ok(()) } } From 432be2d472d3163e5f955888e5385f6e132c59de Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 30 May 2019 17:37:47 +0300 Subject: [PATCH 064/735] Use newtype for RoomId --- src/api/control/room.rs | 4 +++- src/main.rs | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/api/control/room.rs b/src/api/control/room.rs index 9e51d202b..af4ad5037 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -1,5 +1,6 @@ //! Room definitions and implementations. +use serde::Deserialize; use std::convert::TryFrom; use super::{ @@ -8,7 +9,8 @@ use super::{ }; /// ID of [`Room`]. -pub type Id = String; +#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq)] +pub struct Id(pub String); /// [`crate::signalling::room::Room`] specification. /// Newtype for [`Entity::Room`] diff --git a/src/main.rs b/src/main.rs index c3198504a..7261dbbe4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -52,7 +52,7 @@ fn main() { #[derive(Debug, Fail)] enum ServerStartError { /// Duplicate room ID finded. - #[fail(display = "Duplicate of room ID '{}'", _0)] + #[fail(display = "Duplicate of room ID '{:?}'", _0)] DuplicateRoomId(RoomId), /// Some error happened while loading spec. @@ -88,7 +88,7 @@ impl From for ServerStartError { /// if some error happened while creating room from spec. fn start_static_rooms( config: &Conf, -) -> Result>, ServerStartError> { +) -> Result>, ServerStartError> { if let Some(static_specs_path) = config.server.static_specs_path.clone() { let room_specs = match load_static_specs_from_dir(static_specs_path) { Ok(r) => r, From d2e1bcc16947f2afb9952ce01a0ead99bfa3ef6e Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 30 May 2019 17:52:49 +0300 Subject: [PATCH 065/735] Refactor uses --- src/main.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index 7261dbbe4..0794e619b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,6 +10,9 @@ pub mod signalling; use actix::prelude::*; use dotenv::dotenv; +use failure::Fail; +use hashbrown::HashMap; + use log::prelude::*; use crate::{ @@ -20,9 +23,6 @@ use crate::{ signalling::{room_repo::RoomsRepository, Room}, }; -use failure::Fail; -use hashbrown::HashMap; - fn main() { dotenv().ok(); let logger = log::new_dual_logger(std::io::stdout(), std::io::stderr()); From d51b1f371149a2207f3a4783554ab5223e463744 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 31 May 2019 20:24:48 +0300 Subject: [PATCH 066/735] Add e2e signalling test --- proto/client-api/src/lib.rs | 11 +- src/lib.rs | 83 ++++++++++++ src/log/prelude.rs | 2 +- src/main.rs | 94 +------------- src/signalling/room.rs | 194 +++++---------------------- src/utils/mod.rs | 1 + tests/signalling.rs | 253 ++++++++++++++++++++++++++++++++++++ 7 files changed, 382 insertions(+), 256 deletions(-) create mode 100644 src/lib.rs create mode 100644 tests/signalling.rs diff --git a/proto/client-api/src/lib.rs b/proto/client-api/src/lib.rs index a350a0b4a..c71632d97 100644 --- a/proto/client-api/src/lib.rs +++ b/proto/client-api/src/lib.rs @@ -1,5 +1,7 @@ use serde::{de::Deserializer, ser::Serializer, Deserialize, Serialize}; +// TODO: Deal with #[cfg_attr(test, ...)] when running e2e tests. + // TODO: should be properly shared between medea and jason #[cfg_attr(test, derive(PartialEq, Debug))] #[allow(dead_code)] @@ -48,6 +50,7 @@ pub enum Command { #[cfg_attr(test, derive(PartialEq, Debug))] #[serde(tag = "event", content = "data")] #[allow(dead_code)] +#[derive(Debug, Clone, PartialEq)] pub enum Event { /// Media Server notifies Web Client about necessity of RTCPeerConnection /// creation. @@ -84,6 +87,7 @@ pub struct IceCandidate { #[cfg_attr(feature = "medea", derive(Serialize))] #[cfg_attr(feature = "jason", derive(Deserialize))] #[cfg_attr(test, derive(PartialEq, Debug))] +#[derive(Debug, Clone, PartialEq)] pub struct Track { pub id: u64, pub direction: Direction, @@ -94,13 +98,14 @@ pub struct Track { #[cfg_attr(feature = "medea", derive(Serialize))] #[cfg_attr(feature = "jason", derive(Deserialize))] #[cfg_attr(test, derive(PartialEq, Debug))] +#[derive(Debug, Clone, PartialEq)] pub enum Direction { Send { receivers: Vec }, Recv { sender: u64 }, } /// Type of [`Track`]. -#[derive(Clone, Debug)] +#[derive(Clone, Debug, PartialEq)] #[cfg_attr(feature = "medea", derive(Serialize))] #[cfg_attr(feature = "jason", derive(Deserialize))] #[cfg_attr(test, derive(PartialEq))] @@ -109,13 +114,13 @@ pub enum MediaType { Video(VideoSettings), } -#[derive(Clone, Debug)] +#[derive(Clone, Debug, PartialEq)] #[cfg_attr(feature = "medea", derive(Serialize))] #[cfg_attr(feature = "jason", derive(Deserialize))] #[cfg_attr(test, derive(PartialEq))] pub struct AudioSettings {} -#[derive(Clone, Debug)] +#[derive(Clone, Debug, PartialEq)] #[cfg_attr(feature = "medea", derive(Serialize))] #[cfg_attr(feature = "jason", derive(Deserialize))] #[cfg_attr(test, derive(PartialEq))] diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 000000000..d2b5fee87 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,83 @@ +//! Medea media server application. + +#[macro_use] +pub mod utils; +pub mod api; +pub mod conf; +pub mod log; +pub mod media; +pub mod signalling; + +use actix::prelude::*; +use failure::Fail; +use hashbrown::HashMap; + +use crate::{ + api::{control::load_static_specs_from_dir, control::RoomId}, + conf::Conf, + signalling::{room::RoomError, Room}, +}; + +/// Errors which can happen while server starting. +#[derive(Debug, Fail)] +pub enum ServerStartError { + /// Duplicate room ID finded. + #[fail(display = "Duplicate of room ID '{:?}'", _0)] + DuplicateRoomId(RoomId), + + /// Some error happened while loading spec. + #[fail(display = "Failed to load specs. {}", _0)] + LoadSpec(failure::Error), + + /// Some error happened while creating new room from spec. + #[fail(display = "Bad room spec. {}", _0)] + BadRoomSpec(String), + + /// Unexpected error returned from room. + #[fail(display = "Unknown room error.")] + UnknownRoomError, +} + +impl From for ServerStartError { + fn from(err: RoomError) -> Self { + match err { + RoomError::BadRoomSpec(m) => ServerStartError::BadRoomSpec(m), + _ => ServerStartError::UnknownRoomError, + } + } +} + +/// Parses static [`Room`]s from config and starts them in separate arbiters. +/// +/// Returns [`ServerStartError::DuplicateRoomId`] if find duplicated room ID. +/// +/// Returns [`ServerStartError::LoadSpec`] if some error happened +/// while loading spec. +/// +/// Returns [`ServerStartError::BadRoomSpec`] +/// if some error happened while creating room from spec. +pub fn start_static_rooms( + config: &Conf, +) -> Result>, ServerStartError> { + if let Some(static_specs_path) = config.server.static_specs_path.clone() { + let room_specs = match load_static_specs_from_dir(static_specs_path) { + Ok(r) => r, + Err(e) => return Err(ServerStartError::LoadSpec(e)), + }; + let mut rooms = HashMap::new(); + + for spec in room_specs { + if rooms.contains_key(&spec.id) { + return Err(ServerStartError::DuplicateRoomId(spec.id)); + } + + let room = Room::new(&spec, config.rpc.reconnect_timeout)?; + let room = Arbiter::start(move |_| room); + rooms.insert(spec.id, room); + } + + Ok(rooms) + } else { + Ok(HashMap::new()) + } +} diff --git a/src/log/prelude.rs b/src/log/prelude.rs index a09db6ec8..537645ab0 100644 --- a/src/log/prelude.rs +++ b/src/log/prelude.rs @@ -2,7 +2,7 @@ //! //! Use this module as following: //! ```rust -//! use crate::log::prelude::*; +//! use medea::log::prelude::*; //! ``` pub use slog::{slog_debug, slog_error, slog_info, slog_trace, slog_warn}; diff --git a/src/main.rs b/src/main.rs index 0794e619b..6609fd725 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,30 +1,14 @@ -//! Medea media server application. - -#[macro_use] -pub mod utils; -pub mod api; -pub mod conf; -pub mod log; -pub mod media; -pub mod signalling; - -use actix::prelude::*; -use dotenv::dotenv; -use failure::Fail; -use hashbrown::HashMap; - -use log::prelude::*; - -use crate::{ - api::control::RoomId, - api::{client::server, control::load_static_specs_from_dir}, +use actix::System; +use medea::{ + api::client::server, conf::Conf, - signalling::room::RoomError, - signalling::{room_repo::RoomsRepository, Room}, + log::{self, prelude::*}, + signalling::room_repo::RoomsRepository, + start_static_rooms, }; fn main() { - dotenv().ok(); + dotenv::dotenv().ok(); let logger = log::new_dual_logger(std::io::stdout(), std::io::stderr()); let _scope_guard = slog_scope::set_global_logger(logger); slog_stdlog::init().unwrap(); @@ -47,67 +31,3 @@ fn main() { let _ = sys.run(); } - -/// Errors which can happen while server starting. -#[derive(Debug, Fail)] -enum ServerStartError { - /// Duplicate room ID finded. - #[fail(display = "Duplicate of room ID '{:?}'", _0)] - DuplicateRoomId(RoomId), - - /// Some error happened while loading spec. - #[fail(display = "Failed to load specs. {}", _0)] - LoadSpec(failure::Error), - - /// Some error happened while creating new room from spec. - #[fail(display = "Bad room spec. {}", _0)] - BadRoomSpec(String), - - /// Unexpected error returned from room. - #[fail(display = "Unknown room error.")] - UnknownRoomError, -} - -impl From for ServerStartError { - fn from(err: RoomError) -> Self { - match err { - RoomError::BadRoomSpec(m) => ServerStartError::BadRoomSpec(m), - _ => ServerStartError::UnknownRoomError, - } - } -} - -/// Parses static [`Room`]s from config and starts them in separate arbiters. -/// -/// Returns [`ServerStartError::DuplicateRoomId`] if find duplicated room ID. -/// -/// Returns [`ServerStartError::LoadSpec`] if some error happened -/// while loading spec. -/// -/// Returns [`ServerStartError::BadRoomSpec`] -/// if some error happened while creating room from spec. -fn start_static_rooms( - config: &Conf, -) -> Result>, ServerStartError> { - if let Some(static_specs_path) = config.server.static_specs_path.clone() { - let room_specs = match load_static_specs_from_dir(static_specs_path) { - Ok(r) => r, - Err(e) => return Err(ServerStartError::LoadSpec(e)), - }; - let mut rooms = HashMap::new(); - - for spec in room_specs { - if rooms.contains_key(&spec.id) { - return Err(ServerStartError::DuplicateRoomId(spec.id)); - } - - let room = Room::new(&spec, config.rpc.reconnect_timeout)?; - let room = Arbiter::start(move |_| room); - rooms.insert(spec.id, room); - } - - Ok(rooms) - } else { - Ok(HashMap::new()) - } -} diff --git a/src/signalling/room.rs b/src/signalling/room.rs index ce520248c..c6d8ef0d0 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -269,6 +269,28 @@ impl Room { self.participants.send_event_to_member(to_member_id, event), ))) } + + fn create_peers( + &mut self, + to_create: Vec<(&Member, Member)>, + ctx: &mut ::Context, + ) { + for p in to_create { + let caller = p.0; + let responder = p.1; + debug!( + "Created peer member {} with member {}", + caller.id, responder.id + ); + + let (caller_peer_id, responder_peer_id) = + self.peers.create_peers(caller, &responder); + + ctx.notify(ConnectPeers(caller_peer_id, responder_peer_id)); + + // println!("Peers: {:#?}", self.peers); + } + } } /// [`Actor`] implementation that provides an ergonomic way @@ -330,36 +352,6 @@ impl Handler for Room { } } -#[derive(Debug, Message)] -#[rtype(result = "()")] -pub struct CreatePeers { - pub caller: Member, - pub responder: Member, -} - -impl Handler for Room { - type Result = (); - - /// Create [`Peer`] between members and interconnect it by control API spec. - fn handle( - &mut self, - msg: CreatePeers, - ctx: &mut Self::Context, - ) -> Self::Result { - debug!( - "Created peer member {} with member {}", - msg.caller.id, msg.responder.id - ); - - let (caller_peer_id, responder_peer_id) = - self.peers.create_peers(&msg.caller, &msg.responder); - - ctx.notify(ConnectPeers(caller_peer_id, responder_peer_id)); - - // println!("Peers: {:#?}", self.peers); - } -} - impl Handler for Room { type Result = ActFuture<(), ()>; @@ -422,7 +414,7 @@ impl Handler for Room { let member_id = &msg.0; let member = if let Some(m) = self.participants.get_member_by_id(member_id) { - m + m.clone() } else { error!( "Try to create necessary peers for nonexistent member \ @@ -433,6 +425,8 @@ impl Handler for Room { return; }; + let mut need_create = Vec::new(); + // connect receivers let mut already_connected_members = Vec::new(); if let Some(receivers) = self.sender_receivers.get(member_id) { @@ -442,10 +436,7 @@ impl Handler for Room { self.participants.get_member_by_id(recv_member_id) { already_connected_members.push(recv_member_id.clone()); - ctx.notify(CreatePeers { - caller: recv_member.clone(), - responder: member.clone(), - }); + need_create.push((&member, recv_member.clone())); } else { error!( "Try to create peer for nonexistent member with \ @@ -470,12 +461,11 @@ impl Handler for Room { .participants .get_member_by_id(sender_member_id) .unwrap(); - ctx.notify(CreatePeers { - caller: sender_member.clone(), - responder: member.clone(), - }); + need_create.push((&member, sender_member.clone())); } } + + self.create_peers(need_create, ctx); } } @@ -541,129 +531,3 @@ impl Handler for Room { .connection_closed(ctx, msg.member_id, &msg.reason); } } - -#[cfg(test)] -mod test { - use std::sync::{atomic::AtomicUsize, Arc, Mutex}; - - use actix::{Addr, Arbiter, System}; - use medea_client_api_proto::{ - AudioSettings, Direction, MediaType, Track, VideoSettings, - }; - - use crate::api::client::rpc_connection::test::TestConnection; - use crate::api::control; - - use super::*; - - fn start_room() -> Addr { - let room_spec = - control::load_from_yaml_file("./specs/pub_sub_room.yml").unwrap(); - let client_room = - Room::new(&room_spec, Duration::from_secs(10)).unwrap(); - Arbiter::start(move |_| client_room) - } - - #[test] - fn start_signaling() { - let stopped = Arc::new(AtomicUsize::new(0)); - let caller_events = Arc::new(Mutex::new(vec![])); - let caller_events_clone = Arc::clone(&caller_events); - let responder_events = Arc::new(Mutex::new(vec![])); - let responder_events_clone = Arc::clone(&responder_events); - - System::run(move || { - let room = start_room(); - let room_clone = room.clone(); - let stopped_clone = stopped.clone(); - Arbiter::start(move |_| TestConnection { - events: caller_events_clone, - member_id: MemberId(String::from("caller")), - room: room_clone, - stopped: stopped_clone, - }); - Arbiter::start(move |_| TestConnection { - events: responder_events_clone, - member_id: MemberId(String::from("responder")), - room, - stopped, - }); - }); - - let caller_events = caller_events.lock().unwrap(); - let responder_events = responder_events.lock().unwrap(); - - let first_connected_member_events = vec![ - serde_json::to_string(&Event::PeerCreated { - peer_id: 1, - sdp_offer: None, - tracks: vec![ - Track { - id: 1, - direction: Direction::Send { receivers: vec![2] }, - media_type: MediaType::Audio(AudioSettings {}), - }, - Track { - id: 2, - direction: Direction::Send { receivers: vec![2] }, - media_type: MediaType::Video(VideoSettings {}), - }, - ], - }) - .unwrap(), - serde_json::to_string(&Event::SdpAnswerMade { - peer_id: 1, - sdp_answer: "responder_answer".into(), - }) - .unwrap(), - serde_json::to_string(&Event::IceCandidateDiscovered { - peer_id: 1, - candidate: IceCandidate { - candidate: "ice_candidate".to_owned(), - sdp_m_line_index: None, - sdp_mid: None, - }, - }) - .unwrap(), - ]; - let second_connected_member_events = vec![ - serde_json::to_string(&Event::PeerCreated { - peer_id: 2, - sdp_offer: Some("caller_offer".into()), - tracks: vec![ - Track { - id: 1, - direction: Direction::Recv { sender: 1 }, - media_type: MediaType::Audio(AudioSettings {}), - }, - Track { - id: 2, - direction: Direction::Recv { sender: 1 }, - media_type: MediaType::Video(VideoSettings {}), - }, - ], - }) - .unwrap(), - serde_json::to_string(&Event::IceCandidateDiscovered { - peer_id: 2, - candidate: IceCandidate { - candidate: "ice_candidate".to_owned(), - sdp_m_line_index: None, - sdp_mid: None, - }, - }) - .unwrap(), - ]; - - let caller_events = caller_events.to_vec(); - let responder_events = responder_events.to_vec(); - - if caller_events != first_connected_member_events { - assert_eq!(caller_events, second_connected_member_events); - } - - if responder_events != first_connected_member_events { - assert_eq!(responder_events, second_connected_member_events); - } - } -} diff --git a/src/utils/mod.rs b/src/utils/mod.rs index 82d6712ad..ab2452b6f 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -5,6 +5,7 @@ /// ## Example /// /// ```rust +/// # use medea::hashmap; /// let map = hashmap! { /// "a" => 1, /// "b" => 2, diff --git a/tests/signalling.rs b/tests/signalling.rs new file mode 100644 index 000000000..2bc62d17e --- /dev/null +++ b/tests/signalling.rs @@ -0,0 +1,253 @@ +use actix::{ + Actor, Arbiter, AsyncContext, Context, Handler, Message, StreamHandler, + System, +}; +use actix_web::ws::{ + Client, ClientWriter, Message as WebMessage, ProtocolError, +}; +use futures::future::Future; +use medea::{ + api::client::server, conf::Conf, signalling::room_repo::RoomsRepository, + start_static_rooms, +}; +use medea_client_api_proto::{Command, Direction, Event, IceCandidate}; +use serde_json::error::Error as SerdeError; +use std::{ + cell::Cell, + sync::{Arc, Mutex}, + time::Duration, +}; + +struct TestMember { + writer: ClientWriter, + is_caller: bool, + events: Vec, +} + +#[derive(Message)] +#[rtype(result = ())] +struct ClientCommand(Command); + +impl Actor for TestMember { + type Context = Context; + + fn started(&mut self, ctx: &mut Self::Context) { + self.hb(ctx); + ctx.run_later(Duration::new(5, 0), |act, _ctx| { + panic!( + "This test lasts more than 5 seconds. Most likely, this is \ + not normal. Here is all events of member: {:?}", + act.events + ); + }); + } +} + +impl TestMember { + fn hb(&self, ctx: &mut Context) { + ctx.run_later(Duration::new(1, 0), |act, ctx| { + act.writer.text(r#"{"ping": 1}"#); + act.hb(ctx); + }); + } + + fn test_events(&self) { + let mut is_caller = false; + if let Event::PeerCreated { + peer_id, + sdp_offer, + tracks, + } = &self.events[0] + { + if let Some(_) = sdp_offer { + is_caller = false; + } else { + is_caller = true; + } + assert_eq!(tracks.len(), 2); + for track in tracks { + match &track.direction { + Direction::Send { receivers } => { + assert!(is_caller); + assert!(!receivers.contains(&peer_id)); + } + Direction::Recv { sender } => { + assert!(!is_caller); + assert_ne!(sender, peer_id); + } + } + } + } else { + assert!(false) + } + + if is_caller { + if let Event::SdpAnswerMade { + peer_id: _, + sdp_answer: _, + } = &self.events[1] + { + assert!(true); + } else { + assert!(false); + } + + if let Event::IceCandidateDiscovered { + peer_id: _, + candidate: _, + } = &self.events[2] + { + assert!(true); + } else { + assert!(false); + } + } else { + if let Event::IceCandidateDiscovered { + peer_id: _, + candidate: _, + } = &self.events[1] + { + assert!(true); + } else { + assert!(false); + } + } + } + + pub fn start(uri: &str) { + Arbiter::spawn( + Client::new(uri) + .connect() + .map_err(|e| { + panic!("Error: {}", e); + }) + .map(|(reader, writer)| { + TestMember::create(|ctx| { + TestMember::add_stream(reader, ctx); + TestMember { + writer, + events: Vec::new(), + is_caller: false, + } + }); + }), + ) + } +} + +impl Handler for TestMember { + type Result = (); + + fn handle(&mut self, msg: ClientCommand, _ctx: &mut Context) { + self.writer.text(&serde_json::to_string(&msg.0).unwrap()); + } +} + +impl StreamHandler for TestMember { + // TODO: provide here FnOnce + fn handle(&mut self, msg: WebMessage, ctx: &mut Context) { + match msg { + WebMessage::Text(txt) => { + let event: Result = + serde_json::from_str(&txt); + if let Ok(event) = event { + self.events.push(event.clone()); + match event { + Event::PeerCreated { + peer_id, + sdp_offer, + tracks: _, + } => { + match sdp_offer { + Some(_) => { + self.is_caller = false; + ctx.notify(ClientCommand( + Command::MakeSdpAnswer { + peer_id, + sdp_answer: "responder_answer" + .to_string(), + }, + )); + } + None => { + self.is_caller = true; + ctx.notify(ClientCommand( + Command::MakeSdpOffer { + peer_id, + sdp_offer: "caller_offer" + .to_string(), + }, + )); + } + } + ctx.notify(ClientCommand( + Command::SetIceCandidate { + peer_id, + candidate: IceCandidate { + candidate: "ice_candidate".to_string(), + sdp_m_line_index: None, + sdp_mid: None, + }, + }, + )); + } + Event::IceCandidateDiscovered { + peer_id: _, + candidate: _, + } => { + // TODO: provide and use FnOnce instead of this. + self.test_events(); + if self.is_caller { + System::current().stop(); + } + } + _ => (), + } + } + } + _ => (), + } + } +} + +// TODO: deal with async testing. Maybe use different ports? +#[test] +fn sig_test() { + let is_server_starting = Arc::new(Mutex::new(Cell::new(true))); + let is_server_starting_ref = Arc::clone(&is_server_starting); + + let server_thread = std::thread::spawn(move || { + dotenv::dotenv().ok(); + let _sys = System::new("medea"); + + // TODO: Don't load config from file. Use static. + let config = Conf::parse().unwrap(); + + match start_static_rooms(&config) { + Ok(r) => { + let room_repo = RoomsRepository::new(r); + server::run(room_repo, config); + } + Err(e) => { + panic!("Server not started because of error: '{}'", e); + } + }; + let is_server_starting_guard = is_server_starting_ref.lock().unwrap(); + is_server_starting_guard.set(false); + }); + + // Wait until server is up + while is_server_starting.lock().unwrap().get() {} + + let sys = System::new("medea-signalling-test"); + + TestMember::start("ws://localhost:8080/ws/pub-sub-video-call/caller/test"); + TestMember::start( + "ws://localhost:8080/ws/pub-sub-video-call/responder/test", + ); + + let _ = sys.run(); + server_thread.join().unwrap(); +} + +// TODO: add ping-pong e2e test From 1d311107e997ca74c998b4a529f6ea909afcb1b4 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 3 Jun 2019 13:36:19 +0300 Subject: [PATCH 067/735] Another fix race condition --- src/signalling/room.rs | 136 +++++++++++++++++++---------------------- tests/signalling.rs | 63 +++++++------------ 2 files changed, 86 insertions(+), 113 deletions(-) diff --git a/src/signalling/room.rs b/src/signalling/room.rs index c6d8ef0d0..bcdd43bea 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -288,9 +288,70 @@ impl Room { ctx.notify(ConnectPeers(caller_peer_id, responder_peer_id)); - // println!("Peers: {:#?}", self.peers); + // println!("Peers: {:#?}", self.peers); } } + + fn create_neccessary_peers( + &mut self, + member_id: &MemberId, + ctx: &mut ::Context, + ) { + let member = + if let Some(m) = self.participants.get_member_by_id(member_id) { + m.clone() + } else { + error!( + "Try to create necessary peers for nonexistent member \ + with ID {}. Room will be stopped.", + member_id + ); + ctx.notify(CloseRoom {}); + return; + }; + + let mut need_create = Vec::new(); + + // connect receivers + let mut already_connected_members = Vec::new(); + if let Some(receivers) = self.sender_receivers.get(member_id) { + for recv_member_id in receivers { + if self.participants.member_has_connection(recv_member_id) { + if let Some(recv_member) = + self.participants.get_member_by_id(recv_member_id) + { + already_connected_members.push(recv_member_id.clone()); + need_create.push((&member, recv_member.clone())); + } else { + error!( + "Try to create peer for nonexistent member with \ + ID {}. Room wil be stopped.", + recv_member_id + ); + ctx.notify(CloseRoom {}); + } + } + } + } + + // connect senders + for play in member.spec.get_play_endpoints() { + let sender_member_id = &play.src.member_id; + if already_connected_members.contains(sender_member_id) { + continue; + } + + if self.participants.member_has_connection(sender_member_id) { + let sender_member = self + .participants + .get_member_by_id(sender_member_id) + .unwrap(); + need_create.push((&member, sender_member.clone())); + } + } + + self.create_peers(need_create, ctx); + } } /// [`Actor`] implementation that provides an ergonomic way @@ -398,77 +459,6 @@ impl Handler for Room { } } -#[derive(Debug, Message)] -#[rtype(result = "()")] -struct CreateNecessaryMemberPeers(MemberId); - -impl Handler for Room { - type Result = (); - - /// Create and interconnect all necessary [`Member`]'s [`Peer`]s. - fn handle( - &mut self, - msg: CreateNecessaryMemberPeers, - ctx: &mut Self::Context, - ) { - let member_id = &msg.0; - let member = - if let Some(m) = self.participants.get_member_by_id(member_id) { - m.clone() - } else { - error!( - "Try to create necessary peers for nonexistent member \ - with ID {}. Room will be stopped.", - member_id - ); - ctx.notify(CloseRoom {}); - return; - }; - - let mut need_create = Vec::new(); - - // connect receivers - let mut already_connected_members = Vec::new(); - if let Some(receivers) = self.sender_receivers.get(member_id) { - for recv_member_id in receivers { - if self.participants.member_has_connection(recv_member_id) { - if let Some(recv_member) = - self.participants.get_member_by_id(recv_member_id) - { - already_connected_members.push(recv_member_id.clone()); - need_create.push((&member, recv_member.clone())); - } else { - error!( - "Try to create peer for nonexistent member with \ - ID {}. Room wil be stopped.", - recv_member_id - ); - ctx.notify(CloseRoom {}); - } - } - } - } - - // connect senders - for play in member.spec.get_play_endpoints() { - let sender_member_id = &play.src.member_id; - if already_connected_members.contains(sender_member_id) { - continue; - } - - if self.participants.member_has_connection(sender_member_id) { - let sender_member = self - .participants - .get_member_by_id(sender_member_id) - .unwrap(); - need_create.push((&member, sender_member.clone())); - } - } - - self.create_peers(need_create, ctx); - } -} - impl Handler for Room { type Result = ActFuture<(), ()>; @@ -489,7 +479,7 @@ impl Handler for Room { msg.connection, ); - ctx.notify(CreateNecessaryMemberPeers(msg.member_id)); + self.create_neccessary_peers(&msg.member_id, ctx); Box::new(wrap_future(future::ok(()))) } diff --git a/tests/signalling.rs b/tests/signalling.rs index 2bc62d17e..837507c69 100644 --- a/tests/signalling.rs +++ b/tests/signalling.rs @@ -1,7 +1,4 @@ -use actix::{ - Actor, Arbiter, AsyncContext, Context, Handler, Message, StreamHandler, - System, -}; +use actix::{Actor, Arbiter, AsyncContext, Context, StreamHandler, System}; use actix_web::ws::{ Client, ClientWriter, Message as WebMessage, ProtocolError, }; @@ -24,10 +21,6 @@ struct TestMember { events: Vec, } -#[derive(Message)] -#[rtype(result = ())] -struct ClientCommand(Command); - impl Actor for TestMember { type Context = Context; @@ -51,6 +44,10 @@ impl TestMember { }); } + fn send_command(&mut self, msg: Command) { + self.writer.text(&serde_json::to_string(&msg).unwrap()); + } + fn test_events(&self) { let mut is_caller = false; if let Event::PeerCreated { @@ -135,19 +132,12 @@ impl TestMember { } } -impl Handler for TestMember { - type Result = (); - - fn handle(&mut self, msg: ClientCommand, _ctx: &mut Context) { - self.writer.text(&serde_json::to_string(&msg.0).unwrap()); - } -} - impl StreamHandler for TestMember { // TODO: provide here FnOnce - fn handle(&mut self, msg: WebMessage, ctx: &mut Context) { + fn handle(&mut self, msg: WebMessage, _ctx: &mut Context) { match msg { WebMessage::Text(txt) => { + // println!("[{}]\t{}", self.is_caller, txt); let event: Result = serde_json::from_str(&txt); if let Ok(event) = event { @@ -161,35 +151,28 @@ impl StreamHandler for TestMember { match sdp_offer { Some(_) => { self.is_caller = false; - ctx.notify(ClientCommand( - Command::MakeSdpAnswer { - peer_id, - sdp_answer: "responder_answer" - .to_string(), - }, - )); + self.send_command(Command::MakeSdpAnswer { + peer_id, + sdp_answer: "responder_answer" + .to_string(), + }); } None => { self.is_caller = true; - ctx.notify(ClientCommand( - Command::MakeSdpOffer { - peer_id, - sdp_offer: "caller_offer" - .to_string(), - }, - )); + self.send_command(Command::MakeSdpOffer { + peer_id, + sdp_offer: "caller_offer".to_string(), + }); } } - ctx.notify(ClientCommand( - Command::SetIceCandidate { - peer_id, - candidate: IceCandidate { - candidate: "ice_candidate".to_string(), - sdp_m_line_index: None, - sdp_mid: None, - }, + self.send_command(Command::SetIceCandidate { + peer_id, + candidate: IceCandidate { + candidate: "ice_candidate".to_string(), + sdp_m_line_index: None, + sdp_mid: None, }, - )); + }); } Event::IceCandidateDiscovered { peer_id: _, From b17c3b94974f4b7e04b7787736a37ea2db63bec3 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 3 Jun 2019 13:59:54 +0300 Subject: [PATCH 068/735] Add test function providing --- tests/signalling.rs | 160 +++++++++++++++++++++++--------------------- 1 file changed, 85 insertions(+), 75 deletions(-) diff --git a/tests/signalling.rs b/tests/signalling.rs index 837507c69..8d3434d83 100644 --- a/tests/signalling.rs +++ b/tests/signalling.rs @@ -19,6 +19,7 @@ struct TestMember { writer: ClientWriter, is_caller: bool, events: Vec, + test_fn: Box)>, } impl Actor for TestMember { @@ -48,70 +49,7 @@ impl TestMember { self.writer.text(&serde_json::to_string(&msg).unwrap()); } - fn test_events(&self) { - let mut is_caller = false; - if let Event::PeerCreated { - peer_id, - sdp_offer, - tracks, - } = &self.events[0] - { - if let Some(_) = sdp_offer { - is_caller = false; - } else { - is_caller = true; - } - assert_eq!(tracks.len(), 2); - for track in tracks { - match &track.direction { - Direction::Send { receivers } => { - assert!(is_caller); - assert!(!receivers.contains(&peer_id)); - } - Direction::Recv { sender } => { - assert!(!is_caller); - assert_ne!(sender, peer_id); - } - } - } - } else { - assert!(false) - } - - if is_caller { - if let Event::SdpAnswerMade { - peer_id: _, - sdp_answer: _, - } = &self.events[1] - { - assert!(true); - } else { - assert!(false); - } - - if let Event::IceCandidateDiscovered { - peer_id: _, - candidate: _, - } = &self.events[2] - { - assert!(true); - } else { - assert!(false); - } - } else { - if let Event::IceCandidateDiscovered { - peer_id: _, - candidate: _, - } = &self.events[1] - { - assert!(true); - } else { - assert!(false); - } - } - } - - pub fn start(uri: &str) { + pub fn start(uri: &str, test_fn: Box)>) { Arbiter::spawn( Client::new(uri) .connect() @@ -125,6 +63,7 @@ impl TestMember { writer, events: Vec::new(), is_caller: false, + test_fn, } }); }), @@ -133,11 +72,10 @@ impl TestMember { } impl StreamHandler for TestMember { - // TODO: provide here FnOnce fn handle(&mut self, msg: WebMessage, _ctx: &mut Context) { match msg { WebMessage::Text(txt) => { - // println!("[{}]\t{}", self.is_caller, txt); + // println!("[{}]\t{}", self.is_caller, txt); let event: Result = serde_json::from_str(&txt); if let Ok(event) = event { @@ -178,11 +116,7 @@ impl StreamHandler for TestMember { peer_id: _, candidate: _, } => { - // TODO: provide and use FnOnce instead of this. - self.test_events(); - if self.is_caller { - System::current().stop(); - } + (self.test_fn)(&self.events); } _ => (), } @@ -194,8 +128,7 @@ impl StreamHandler for TestMember { } // TODO: deal with async testing. Maybe use different ports? -#[test] -fn sig_test() { +fn run_test_server() { let is_server_starting = Arc::new(Mutex::new(Cell::new(true))); let is_server_starting_ref = Arc::clone(&is_server_starting); @@ -222,15 +155,92 @@ fn sig_test() { // Wait until server is up while is_server_starting.lock().unwrap().get() {} + server_thread.join().unwrap(); +} + +#[test] +fn sig_test() { + run_test_server(); + let sys = System::new("medea-signalling-test"); - TestMember::start("ws://localhost:8080/ws/pub-sub-video-call/caller/test"); + let pub_sub_test = |events: &Vec| { + let mut is_caller = false; + if let Event::PeerCreated { + peer_id, + sdp_offer, + tracks, + } = &events[0] + { + if let Some(_) = sdp_offer { + is_caller = false; + } else { + is_caller = true; + } + assert_eq!(tracks.len(), 2); + for track in tracks { + match &track.direction { + Direction::Send { receivers } => { + assert!(is_caller); + assert!(!receivers.contains(&peer_id)); + } + Direction::Recv { sender } => { + assert!(!is_caller); + assert_ne!(sender, peer_id); + } + } + } + } else { + assert!(false) + } + + if is_caller { + if let Event::SdpAnswerMade { + peer_id: _, + sdp_answer: _, + } = &events[1] + { + assert!(true); + } else { + assert!(false); + } + + if let Event::IceCandidateDiscovered { + peer_id: _, + candidate: _, + } = &events[2] + { + assert!(true); + } else { + assert!(false); + } + } else { + if let Event::IceCandidateDiscovered { + peer_id: _, + candidate: _, + } = &events[1] + { + assert!(true); + } else { + assert!(false); + } + } + + if is_caller { + System::current().stop(); + } + }; + + TestMember::start( + "ws://localhost:8080/ws/pub-sub-video-call/caller/test", + Box::new(pub_sub_test.clone()), + ); TestMember::start( "ws://localhost:8080/ws/pub-sub-video-call/responder/test", + Box::new(pub_sub_test.clone()), ); let _ = sys.run(); - server_thread.join().unwrap(); } // TODO: add ping-pong e2e test From b8607cac4596648528d2073f72cdc4566c4dc8bd Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 3 Jun 2019 14:20:57 +0300 Subject: [PATCH 069/735] Add async tests support --- tests/signalling.rs | 25 ++++++++++++++++++------- tests/specs/pub_sub_room.yml | 26 ++++++++++++++++++++++++++ tests/test_ports.rs | 1 + 3 files changed, 45 insertions(+), 7 deletions(-) create mode 100644 tests/specs/pub_sub_room.yml create mode 100644 tests/test_ports.rs diff --git a/tests/signalling.rs b/tests/signalling.rs index 8d3434d83..964eb1d49 100644 --- a/tests/signalling.rs +++ b/tests/signalling.rs @@ -1,3 +1,5 @@ +mod test_ports; + use actix::{Actor, Arbiter, AsyncContext, Context, StreamHandler, System}; use actix_web::ws::{ Client, ClientWriter, Message as WebMessage, ProtocolError, @@ -14,6 +16,7 @@ use std::{ sync::{Arc, Mutex}, time::Duration, }; +use medea::conf::Server; struct TestMember { writer: ClientWriter, @@ -128,7 +131,7 @@ impl StreamHandler for TestMember { } // TODO: deal with async testing. Maybe use different ports? -fn run_test_server() { +fn run_test_server(bind_port: u16) { let is_server_starting = Arc::new(Mutex::new(Cell::new(true))); let is_server_starting_ref = Arc::clone(&is_server_starting); @@ -136,8 +139,14 @@ fn run_test_server() { dotenv::dotenv().ok(); let _sys = System::new("medea"); - // TODO: Don't load config from file. Use static. - let config = Conf::parse().unwrap(); + let config = Conf { + server: Server { + static_specs_path: Some("tests/specs".to_string()), + bind_port, + ..Default::default() + }, + ..Default::default() + }; match start_static_rooms(&config) { Ok(r) => { @@ -159,8 +168,10 @@ fn run_test_server() { } #[test] -fn sig_test() { - run_test_server(); +fn pub_sub_test() { + let bind_port = test_ports::SIGNALLING_TEST_PUB_SUB_TEST; + run_test_server(bind_port); + let base_url = format!("ws://localhost:{}/ws", bind_port); let sys = System::new("medea-signalling-test"); @@ -232,11 +243,11 @@ fn sig_test() { }; TestMember::start( - "ws://localhost:8080/ws/pub-sub-video-call/caller/test", + &format!("{}/pub-sub-video-call/caller/test", base_url), Box::new(pub_sub_test.clone()), ); TestMember::start( - "ws://localhost:8080/ws/pub-sub-video-call/responder/test", + &format!("{}/pub-sub-video-call/responder/test", base_url), Box::new(pub_sub_test.clone()), ); diff --git a/tests/specs/pub_sub_room.yml b/tests/specs/pub_sub_room.yml new file mode 100644 index 000000000..bf8af54e4 --- /dev/null +++ b/tests/specs/pub_sub_room.yml @@ -0,0 +1,26 @@ +kind: Room +id: pub-sub-video-call +spec: + pipeline: + # Here we're defining a member who initiates video call. + caller: + kind: Member + credentials: test + spec: + pipeline: + # Media element which is able to receive media data from client via WebRTC. + publish: + kind: WebRtcPublishEndpoint + spec: + # Actually, it receives not media data, but ICE candidates only. + p2p: Always + # Media element which is able to play media data for client via WebRTC. + responder: + kind: Member + credentials: test + spec: + pipeline: + play: + kind: WebRtcPlayEndpoint + spec: + src: "local://pub-sub-video-call/caller/publish" diff --git a/tests/test_ports.rs b/tests/test_ports.rs new file mode 100644 index 000000000..7b23daaf7 --- /dev/null +++ b/tests/test_ports.rs @@ -0,0 +1 @@ +pub const SIGNALLING_TEST_PUB_SUB_TEST: u16 = 9000; From c6ab75af9fc78fa24ac47d54eed176d337dee06c Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 3 Jun 2019 17:03:40 +0300 Subject: [PATCH 070/735] Add three members p2p video call test --- tests/signalling.rs | 252 +++++++++++++----- ...ub_sub_room.yml => pub_sub_video_call.yml} | 0 tests/specs/three_members_conference.yml | 60 +++++ tests/test_ports.rs | 1 + 4 files changed, 239 insertions(+), 74 deletions(-) rename tests/specs/{pub_sub_room.yml => pub_sub_video_call.yml} (100%) create mode 100644 tests/specs/three_members_conference.yml diff --git a/tests/signalling.rs b/tests/signalling.rs index 964eb1d49..37284e615 100644 --- a/tests/signalling.rs +++ b/tests/signalling.rs @@ -5,24 +5,24 @@ use actix_web::ws::{ Client, ClientWriter, Message as WebMessage, ProtocolError, }; use futures::future::Future; +use medea::conf::Server; use medea::{ api::client::server, conf::Conf, signalling::room_repo::RoomsRepository, start_static_rooms, }; use medea_client_api_proto::{Command, Direction, Event, IceCandidate}; use serde_json::error::Error as SerdeError; +use std::rc::Rc; use std::{ cell::Cell, sync::{Arc, Mutex}, time::Duration, }; -use medea::conf::Server; struct TestMember { writer: ClientWriter, - is_caller: bool, events: Vec, - test_fn: Box)>, + test_fn: Box, } impl Actor for TestMember { @@ -52,7 +52,7 @@ impl TestMember { self.writer.text(&serde_json::to_string(&msg).unwrap()); } - pub fn start(uri: &str, test_fn: Box)>) { + pub fn start(uri: &str, test_fn: Box) { Arbiter::spawn( Client::new(uri) .connect() @@ -65,7 +65,6 @@ impl TestMember { TestMember { writer, events: Vec::new(), - is_caller: false, test_fn, } }); @@ -78,11 +77,11 @@ impl StreamHandler for TestMember { fn handle(&mut self, msg: WebMessage, _ctx: &mut Context) { match msg { WebMessage::Text(txt) => { - // println!("[{}]\t{}", self.is_caller, txt); let event: Result = serde_json::from_str(&txt); if let Ok(event) = event { self.events.push(event.clone()); + (self.test_fn)(&event); match event { Event::PeerCreated { peer_id, @@ -91,7 +90,6 @@ impl StreamHandler for TestMember { } => { match sdp_offer { Some(_) => { - self.is_caller = false; self.send_command(Command::MakeSdpAnswer { peer_id, sdp_answer: "responder_answer" @@ -99,7 +97,6 @@ impl StreamHandler for TestMember { }); } None => { - self.is_caller = true; self.send_command(Command::MakeSdpOffer { peer_id, sdp_offer: "caller_offer".to_string(), @@ -115,12 +112,6 @@ impl StreamHandler for TestMember { }, }); } - Event::IceCandidateDiscovered { - peer_id: _, - candidate: _, - } => { - (self.test_fn)(&self.events); - } _ => (), } } @@ -130,7 +121,7 @@ impl StreamHandler for TestMember { } } -// TODO: deal with async testing. Maybe use different ports? +// TODO: give thread name fn run_test_server(bind_port: u16) { let is_server_starting = Arc::new(Mutex::new(Cell::new(true))); let is_server_starting_ref = Arc::clone(&is_server_starting); @@ -168,90 +159,203 @@ fn run_test_server(bind_port: u16) { } #[test] -fn pub_sub_test() { +fn should_work_pub_sub_video_call() { let bind_port = test_ports::SIGNALLING_TEST_PUB_SUB_TEST; run_test_server(bind_port); let base_url = format!("ws://localhost:{}/ws", bind_port); - let sys = System::new("medea-signalling-test"); + let sys = System::new("medea-signaling-pub-sub-test"); - let pub_sub_test = |events: &Vec| { - let mut is_caller = false; - if let Event::PeerCreated { - peer_id, - sdp_offer, - tracks, - } = &events[0] + let mut events = Vec::new(); + let test_fn = move |event: &Event| { + events.push(event.clone()); + if let Event::IceCandidateDiscovered { + peer_id: _, + candidate: _, + } = event { - if let Some(_) = sdp_offer { - is_caller = false; - } else { - is_caller = true; - } - assert_eq!(tracks.len(), 2); - for track in tracks { - match &track.direction { - Direction::Send { receivers } => { - assert!(is_caller); - assert!(!receivers.contains(&peer_id)); - } - Direction::Recv { sender } => { - assert!(!is_caller); - assert_ne!(sender, peer_id); + let peers_count = events + .iter() + .filter(|e| match e { + Event::PeerCreated { + peer_id: _, + sdp_offer: _, + tracks: _, + } => true, + _ => false, + }) + .count(); + assert_eq!(peers_count, 1); + + let mut is_caller = false; + if let Event::PeerCreated { + peer_id, + sdp_offer, + tracks, + } = &events[0] + { + if let Some(_) = sdp_offer { + is_caller = false; + } else { + is_caller = true; + } + assert_eq!(tracks.len(), 2); + for track in tracks { + match &track.direction { + Direction::Send { receivers } => { + assert!(is_caller); + assert!(!receivers.contains(&peer_id)); + } + Direction::Recv { sender } => { + assert!(!is_caller); + assert_ne!(sender, peer_id); + } } } + } else { + assert!(false) } - } else { - assert!(false) - } - if is_caller { - if let Event::SdpAnswerMade { - peer_id: _, - sdp_answer: _, - } = &events[1] - { - assert!(true); + if is_caller { + if let Event::SdpAnswerMade { + peer_id: _, + sdp_answer: _, + } = &events[1] + { + assert!(true); + } else { + assert!(false); + } + + if let Event::IceCandidateDiscovered { + peer_id: _, + candidate: _, + } = &events[2] + { + assert!(true); + } else { + assert!(false); + } } else { - assert!(false); + if let Event::IceCandidateDiscovered { + peer_id: _, + candidate: _, + } = &events[1] + { + assert!(true); + } else { + assert!(false); + } } - if let Event::IceCandidateDiscovered { + if is_caller { + System::current().stop(); + } + } + }; + + TestMember::start( + &format!("{}/pub-sub-video-call/caller/test", base_url), + Box::new(test_fn.clone()), + ); + TestMember::start( + &format!("{}/pub-sub-video-call/responder/test", base_url), + Box::new(test_fn), + ); + + let _ = sys.run(); +} + +#[test] +fn should_work_three_members_p2p_video_call() { + let bind_port = test_ports::SIGNALLING_TEST_THREE_MEMBERS; + run_test_server(bind_port); + let base_url = format!("ws://localhost:{}/ws", bind_port); + + let sys = System::new("medea-signaling-3-members-test"); + + let mut events = Vec::new(); + let mut peer_created_count = 0; + let mut ice_candidates = 0; + let members_tested = Rc::new(Cell::new(0)); + + let test_fn = move |event: &Event| { + events.push(event.clone()); + match event { + Event::PeerCreated { peer_id: _, - candidate: _, - } = &events[2] - { - assert!(true); - } else { - assert!(false); + sdp_offer: _, + tracks: _, + } => { + peer_created_count += 1; } - } else { - if let Event::IceCandidateDiscovered { + Event::IceCandidateDiscovered { peer_id: _, candidate: _, - } = &events[1] - { - assert!(true); - } else { - assert!(false); - } - } + } => { + ice_candidates += 1; + if ice_candidates == 2 { + assert_eq!(peer_created_count, 2); + + events.iter().for_each(|e| match e { + Event::PeerCreated { + peer_id, + sdp_offer: _, + tracks, + } => { + assert_eq!(tracks.len(), 4); + let recv_count = tracks + .iter() + .filter_map(|t| match &t.direction { + Direction::Recv { sender } => Some(sender), + _ => None, + }) + .map(|sender| { + assert_ne!(sender, peer_id); + }) + .count(); + assert_eq!(recv_count, 2); + + let send_count = tracks + .iter() + .filter_map(|t| match &t.direction { + Direction::Send { receivers } => { + Some(receivers) + } + _ => None, + }) + .map(|receivers| { + assert!(!receivers.contains(peer_id)); + assert_eq!(receivers.len(), 1); + }) + .count(); + assert_eq!(send_count, 2); + } + _ => (), + }); - if is_caller { - System::current().stop(); + members_tested.set(members_tested.get() + 1); + if members_tested.get() == 3 { + System::current().stop(); + } + } + } + _ => (), } }; TestMember::start( - &format!("{}/pub-sub-video-call/caller/test", base_url), - Box::new(pub_sub_test.clone()), + &format!("{}/three-members-conference/caller/test", base_url), + Box::new(test_fn.clone()), ); TestMember::start( - &format!("{}/pub-sub-video-call/responder/test", base_url), - Box::new(pub_sub_test.clone()), + &format!("{}/three-members-conference/responder/test", base_url), + Box::new(test_fn.clone()), + ); + TestMember::start( + &format!("{}/three-members-conference/responder2/test", base_url), + Box::new(test_fn), ); let _ = sys.run(); } - -// TODO: add ping-pong e2e test diff --git a/tests/specs/pub_sub_room.yml b/tests/specs/pub_sub_video_call.yml similarity index 100% rename from tests/specs/pub_sub_room.yml rename to tests/specs/pub_sub_video_call.yml diff --git a/tests/specs/three_members_conference.yml b/tests/specs/three_members_conference.yml new file mode 100644 index 000000000..b2bc33080 --- /dev/null +++ b/tests/specs/three_members_conference.yml @@ -0,0 +1,60 @@ +kind: Room +id: three-members-conference +spec: + pipeline: + # Here we're defining a member who initiates video call. + caller: + kind: Member + credentials: test + spec: + pipeline: + # Media element which is able to receive media data from client via WebRTC. + publish: + kind: WebRtcPublishEndpoint + spec: + # Actually, it receives not media data, but ICE candidates only. + p2p: Always + # Media element which is able to play media data for client via WebRTC. + play: + kind: WebRtcPlayEndpoint + spec: + src: "local://video-call-3/responder/publish" + play2: + kind: WebRtcPlayEndpoint + spec: + src: "local://video-call-3/responder2/publish" + responder: + kind: Member + credentials: test + spec: + pipeline: + publish: + kind: WebRtcPublishEndpoint + spec: + p2p: Always + play1: + kind: WebRtcPlayEndpoint + spec: + src: "local://video-call-3/caller/publish" + play2: + kind: WebRtcPlayEndpoint + spec: + src: "local://video-call-3/responder2/publish" + + responder2: + kind: Member + credentials: test + spec: + pipeline: + publish: + kind: WebRtcPublishEndpoint + spec: + p2p: Always + play1: + kind: WebRtcPlayEndpoint + spec: + src: "local://video-call-3/caller/publish" + play2: + kind: WebRtcPlayEndpoint + spec: + src: "local://video-call-3/responder/publish" diff --git a/tests/test_ports.rs b/tests/test_ports.rs index 7b23daaf7..71aba611f 100644 --- a/tests/test_ports.rs +++ b/tests/test_ports.rs @@ -1 +1,2 @@ pub const SIGNALLING_TEST_PUB_SUB_TEST: u16 = 9000; +pub const SIGNALLING_TEST_THREE_MEMBERS: u16 = 9001; From bf606f9b2f44dbd0fcf9e257983d9feac1af1c4a Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 3 Jun 2019 17:10:05 +0300 Subject: [PATCH 071/735] Naming test server thread --- tests/signalling.rs | 61 ++++++++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 29 deletions(-) diff --git a/tests/signalling.rs b/tests/signalling.rs index 37284e615..e611270a8 100644 --- a/tests/signalling.rs +++ b/tests/signalling.rs @@ -121,36 +121,39 @@ impl StreamHandler for TestMember { } } -// TODO: give thread name -fn run_test_server(bind_port: u16) { +fn run_test_server(bind_port: u16, thread_name: &str) { let is_server_starting = Arc::new(Mutex::new(Cell::new(true))); let is_server_starting_ref = Arc::clone(&is_server_starting); - - let server_thread = std::thread::spawn(move || { - dotenv::dotenv().ok(); - let _sys = System::new("medea"); - - let config = Conf { - server: Server { - static_specs_path: Some("tests/specs".to_string()), - bind_port, + let builder = std::thread::Builder::new().name(thread_name.to_string()); + + let server_thread = builder + .spawn(move || { + dotenv::dotenv().ok(); + let _sys = System::new("medea"); + + let config = Conf { + server: Server { + static_specs_path: Some("tests/specs".to_string()), + bind_port, + ..Default::default() + }, ..Default::default() - }, - ..Default::default() - }; - - match start_static_rooms(&config) { - Ok(r) => { - let room_repo = RoomsRepository::new(r); - server::run(room_repo, config); - } - Err(e) => { - panic!("Server not started because of error: '{}'", e); - } - }; - let is_server_starting_guard = is_server_starting_ref.lock().unwrap(); - is_server_starting_guard.set(false); - }); + }; + + match start_static_rooms(&config) { + Ok(r) => { + let room_repo = RoomsRepository::new(r); + server::run(room_repo, config); + } + Err(e) => { + panic!("Server not started because of error: '{}'", e); + } + }; + let is_server_starting_guard = + is_server_starting_ref.lock().unwrap(); + is_server_starting_guard.set(false); + }) + .unwrap(); // Wait until server is up while is_server_starting.lock().unwrap().get() {} @@ -161,7 +164,7 @@ fn run_test_server(bind_port: u16) { #[test] fn should_work_pub_sub_video_call() { let bind_port = test_ports::SIGNALLING_TEST_PUB_SUB_TEST; - run_test_server(bind_port); + run_test_server(bind_port, "should_work_pub_sub_video_call"); let base_url = format!("ws://localhost:{}/ws", bind_port); let sys = System::new("medea-signaling-pub-sub-test"); @@ -269,7 +272,7 @@ fn should_work_pub_sub_video_call() { #[test] fn should_work_three_members_p2p_video_call() { let bind_port = test_ports::SIGNALLING_TEST_THREE_MEMBERS; - run_test_server(bind_port); + run_test_server(bind_port, "should_work_three_members_p2p_video_call"); let base_url = format!("ws://localhost:{}/ws", bind_port); let sys = System::new("medea-signaling-3-members-test"); From a21351eb2fb597ca9d4a68c31dab27deb1116e10 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 3 Jun 2019 19:56:11 +0300 Subject: [PATCH 072/735] Add docs and test ports generation --- Cargo.lock | 1 + Cargo.toml | 1 + src/signalling/room.rs | 26 +++++++++----- tests/signalling.rs | 77 +++++++++++++++++++++++++++++++----------- tests/test_ports.rs | 45 ++++++++++++++++++++++-- 5 files changed, 121 insertions(+), 29 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 16845bd7d..5058d000b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -848,6 +848,7 @@ dependencies = [ "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "macro-attr 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "medea-client-api-proto 0.1.0-dev", "medea-macro 0.1.0-dev", diff --git a/Cargo.toml b/Cargo.toml index 9218dfa24..48734017c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -49,6 +49,7 @@ toml = "0.4" branch = "serde_wrapper" [dev-dependencies] +lazy_static = "1.3" serial_test = "0.2" serial_test_derive = "0.2" tokio = "0.1" diff --git a/src/signalling/room.rs b/src/signalling/room.rs index bcdd43bea..7c9dac34c 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -270,6 +270,7 @@ impl Room { ))) } + /// Create [`Peer`] between members and interconnect it by control API spec. fn create_peers( &mut self, to_create: Vec<(&Member, Member)>, @@ -292,7 +293,8 @@ impl Room { } } - fn create_neccessary_peers( + /// Create and interconnect all necessary [`Member`]'s [`Peer`]s. + fn create_necessary_peers( &mut self, member_id: &MemberId, ctx: &mut ::Context, @@ -325,7 +327,7 @@ impl Room { } else { error!( "Try to create peer for nonexistent member with \ - ID {}. Room wil be stopped.", + ID {}. Room will be stopped.", recv_member_id ); ctx.notify(CloseRoom {}); @@ -342,11 +344,19 @@ impl Room { } if self.participants.member_has_connection(sender_member_id) { - let sender_member = self - .participants - .get_member_by_id(sender_member_id) - .unwrap(); - need_create.push((&member, sender_member.clone())); + if let Some(sender_member) = + self.participants.get_member_by_id(sender_member_id) + { + need_create.push((&member, sender_member.clone())); + } else { + error!( + "Try to get member with ID {} which has active \ + RpcConnection but not presented in participants! \ + Room will be stopped.", + sender_member_id + ); + ctx.notify(CloseRoom {}); + } } } @@ -479,7 +489,7 @@ impl Handler for Room { msg.connection, ); - self.create_neccessary_peers(&msg.member_id, ctx); + self.create_necessary_peers(&msg.member_id, ctx); Box::new(wrap_future(future::ok(()))) } diff --git a/tests/signalling.rs b/tests/signalling.rs index e611270a8..f57cef3ff 100644 --- a/tests/signalling.rs +++ b/tests/signalling.rs @@ -1,3 +1,5 @@ +//! Signalling API e2e tests. + mod test_ports; use actix::{Actor, Arbiter, AsyncContext, Context, StreamHandler, System}; @@ -5,32 +7,44 @@ use actix_web::ws::{ Client, ClientWriter, Message as WebMessage, ProtocolError, }; use futures::future::Future; -use medea::conf::Server; use medea::{ - api::client::server, conf::Conf, signalling::room_repo::RoomsRepository, - start_static_rooms, + api::client::server, conf::Conf, conf::Server, + signalling::room_repo::RoomsRepository, start_static_rooms, }; use medea_client_api_proto::{Command, Direction, Event, IceCandidate}; use serde_json::error::Error as SerdeError; -use std::rc::Rc; use std::{ cell::Cell, + rc::Rc, sync::{Arc, Mutex}, time::Duration, }; +/// Medea client for testing purposes. struct TestMember { + /// Writer to websocket. writer: ClientWriter, + + /// All [`Event`]s which this [`TestMember`] received. + /// This field used for give some debug info when test just stuck forever + /// (most often, such a test will end on a timer of five seconds + /// and display all events of this [`TestMember`]). events: Vec, + + /// Function which will be called at every received by this [`TestMember`] + /// [`Event`]. test_fn: Box, } impl Actor for TestMember { type Context = Context; + /// Start heartbeat and set a timer that will panic when 5 seconds expire. + /// The timer is needed because some tests may just stuck + /// and listen socket forever. fn started(&mut self, ctx: &mut Self::Context) { - self.hb(ctx); - ctx.run_later(Duration::new(5, 0), |act, _ctx| { + self.heartbeat(ctx); + ctx.run_later(Duration::from_secs(5), |act, _ctx| { panic!( "This test lasts more than 5 seconds. Most likely, this is \ not normal. Here is all events of member: {:?}", @@ -41,17 +55,25 @@ impl Actor for TestMember { } impl TestMember { - fn hb(&self, ctx: &mut Context) { - ctx.run_later(Duration::new(1, 0), |act, ctx| { + /// Signaling heartbeat for server. + /// Most likely, this ping will never be sent, + /// because it has been established that it is sent once per 3 seconds, + /// and there are simply no tests that last so much. + fn heartbeat(&self, ctx: &mut Context) { + ctx.run_later(Duration::from_secs(3), |act, ctx| { act.writer.text(r#"{"ping": 1}"#); - act.hb(ctx); + act.heartbeat(ctx); }); } + /// Send command to the server. fn send_command(&mut self, msg: Command) { self.writer.text(&serde_json::to_string(&msg).unwrap()); } + /// Start test member in new [`Arbiter`] by given uri. + /// `test_fn` - is function which will be called at every [`Event`] + /// received from server. pub fn start(uri: &str, test_fn: Box) { Arbiter::spawn( Client::new(uri) @@ -74,6 +96,9 @@ impl TestMember { } impl StreamHandler for TestMember { + /// Basic signalling implementation. + /// A `TestMember::test_fn` function will be called for each [`Event`] + /// received from test server. fn handle(&mut self, msg: WebMessage, _ctx: &mut Context) { match msg { WebMessage::Text(txt) => { @@ -81,6 +106,7 @@ impl StreamHandler for TestMember { serde_json::from_str(&txt); if let Ok(event) = event { self.events.push(event.clone()); + // Test function call (self.test_fn)(&event); match event { Event::PeerCreated { @@ -121,6 +147,15 @@ impl StreamHandler for TestMember { } } +/// Run medea server. This function lock main thread until server is up. +/// Server starts in different thread and `join`'ed with main thread. +/// When test is done, server will be destroyed. +/// Server load all specs from `tests/specs`. +/// Provide name for thread same as your test function's name. This will +/// help you when server is panic in some test case. +/// __Please, generate port__ by adding your test name to +/// `/tests/test_port.rs::generate_ports_for_tests!` for dealing with +/// asynchronously of tests. fn run_test_server(bind_port: u16, thread_name: &str) { let is_server_starting = Arc::new(Mutex::new(Cell::new(true))); let is_server_starting_ref = Arc::clone(&is_server_starting); @@ -163,9 +198,11 @@ fn run_test_server(bind_port: u16, thread_name: &str) { #[test] fn should_work_pub_sub_video_call() { - let bind_port = test_ports::SIGNALLING_TEST_PUB_SUB_TEST; + let test_name = "should_work_pub_sub_video_call"; + let bind_port = test_ports::get_port_for_test(test_name); run_test_server(bind_port, "should_work_pub_sub_video_call"); - let base_url = format!("ws://localhost:{}/ws", bind_port); + let base_url = + format!("ws://localhost:{}/ws/pub-sub-video-call", bind_port); let sys = System::new("medea-signaling-pub-sub-test"); @@ -258,11 +295,11 @@ fn should_work_pub_sub_video_call() { }; TestMember::start( - &format!("{}/pub-sub-video-call/caller/test", base_url), + &format!("{}/caller/test", base_url), Box::new(test_fn.clone()), ); TestMember::start( - &format!("{}/pub-sub-video-call/responder/test", base_url), + &format!("{}/responder/test", base_url), Box::new(test_fn), ); @@ -271,9 +308,11 @@ fn should_work_pub_sub_video_call() { #[test] fn should_work_three_members_p2p_video_call() { - let bind_port = test_ports::SIGNALLING_TEST_THREE_MEMBERS; - run_test_server(bind_port, "should_work_three_members_p2p_video_call"); - let base_url = format!("ws://localhost:{}/ws", bind_port); + let test_name = "should_work_three_members_p2p_video_call"; + let bind_port = test_ports::get_port_for_test(test_name); + run_test_server(bind_port, test_name); + let base_url = + format!("ws://localhost:{}/ws/three-members-conference", bind_port); let sys = System::new("medea-signaling-3-members-test"); @@ -348,15 +387,15 @@ fn should_work_three_members_p2p_video_call() { }; TestMember::start( - &format!("{}/three-members-conference/caller/test", base_url), + &format!("{}/caller/test", base_url), Box::new(test_fn.clone()), ); TestMember::start( - &format!("{}/three-members-conference/responder/test", base_url), + &format!("{}/responder/test", base_url), Box::new(test_fn.clone()), ); TestMember::start( - &format!("{}/three-members-conference/responder2/test", base_url), + &format!("{}/responder2/test", base_url), Box::new(test_fn), ); diff --git a/tests/test_ports.rs b/tests/test_ports.rs index 71aba611f..3bcc1355e 100644 --- a/tests/test_ports.rs +++ b/tests/test_ports.rs @@ -1,2 +1,43 @@ -pub const SIGNALLING_TEST_PUB_SUB_TEST: u16 = 9000; -pub const SIGNALLING_TEST_THREE_MEMBERS: u16 = 9001; +//! Test ports generating. + +/// Macro for generating ports numbers. +/// This should used when you want to start test server. +/// It's necessary because tests run asynchronously and ports +/// should not overlap. Enumerating start from 40000 because +/// the chance to cross the already used port is very small. +macro_rules! generate_ports_for_tests { + ( $( $x:tt ),* $(,)* ) => { + use lazy_static::lazy_static; + use hashbrown::HashMap; + + lazy_static! { + static ref PORTS: HashMap = { + let mut names: Vec = Vec::new(); + $( names.push(stringify!($x).to_string()); )* + names + .into_iter() + .enumerate() + .map(|(i, t)| { + let port = 40000 + i as u16; + (t, port) + }) + .collect() + }; + } + }; +} + +generate_ports_for_tests!( + should_work_three_members_p2p_video_call, + should_work_pub_sub_video_call, +); + +/// Use it for easy get port by declared before name. +/// +/// It will panic in runtime when port with provided name is not defined. +pub fn get_port_for_test(name: &str) -> u16 { + *PORTS.get(name).expect("Port for this name is not defined!") +} + + + From 8a753bdc972746791692f98653da27c97f4d433e Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 3 Jun 2019 20:00:29 +0300 Subject: [PATCH 073/735] Refactor --- tests/signalling.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/signalling.rs b/tests/signalling.rs index f57cef3ff..59c454e74 100644 --- a/tests/signalling.rs +++ b/tests/signalling.rs @@ -204,8 +204,10 @@ fn should_work_pub_sub_video_call() { let base_url = format!("ws://localhost:{}/ws/pub-sub-video-call", bind_port); - let sys = System::new("medea-signaling-pub-sub-test"); + let sys = System::new(test_name); + // Note that events is separated by members. + // Every member will have different instance of this. let mut events = Vec::new(); let test_fn = move |event: &Event| { events.push(event.clone()); @@ -314,8 +316,11 @@ fn should_work_three_members_p2p_video_call() { let base_url = format!("ws://localhost:{}/ws/three-members-conference", bind_port); - let sys = System::new("medea-signaling-3-members-test"); + let sys = System::new(test_name); + // Note that events, peer_created_count, ice_candidates and members_tested + // is separated by members. + // Every member will have different instance of this. let mut events = Vec::new(); let mut peer_created_count = 0; let mut ice_candidates = 0; From c0262651bd52a492003701f0fc2caa4860407d7e Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 3 Jun 2019 20:14:13 +0300 Subject: [PATCH 074/735] Move proto derives for testing purposes into cfg_attr medea --- proto/client-api/src/lib.rs | 24 ++++++------------------ tests/test_ports.rs | 3 --- 2 files changed, 6 insertions(+), 21 deletions(-) diff --git a/proto/client-api/src/lib.rs b/proto/client-api/src/lib.rs index c71632d97..714d201b9 100644 --- a/proto/client-api/src/lib.rs +++ b/proto/client-api/src/lib.rs @@ -45,12 +45,10 @@ pub enum Command { } /// WebSocket message from Medea to Jason. -#[cfg_attr(feature = "medea", derive(Serialize))] +#[cfg_attr(feature = "medea", derive(Serialize, Debug, Clone, PartialEq))] #[cfg_attr(feature = "jason", derive(Deserialize))] -#[cfg_attr(test, derive(PartialEq, Debug))] #[serde(tag = "event", content = "data")] #[allow(dead_code)] -#[derive(Debug, Clone, PartialEq)] pub enum Event { /// Media Server notifies Web Client about necessity of RTCPeerConnection /// creation. @@ -84,10 +82,8 @@ pub struct IceCandidate { } /// [`Track] with specified direction. -#[cfg_attr(feature = "medea", derive(Serialize))] +#[cfg_attr(feature = "medea", derive(Serialize, Debug, Clone, PartialEq))] #[cfg_attr(feature = "jason", derive(Deserialize))] -#[cfg_attr(test, derive(PartialEq, Debug))] -#[derive(Debug, Clone, PartialEq)] pub struct Track { pub id: u64, pub direction: Direction, @@ -95,35 +91,27 @@ pub struct Track { } /// Direction of [`Track`]. -#[cfg_attr(feature = "medea", derive(Serialize))] +#[cfg_attr(feature = "medea", derive(Serialize, Debug, Clone, PartialEq))] #[cfg_attr(feature = "jason", derive(Deserialize))] -#[cfg_attr(test, derive(PartialEq, Debug))] -#[derive(Debug, Clone, PartialEq)] pub enum Direction { Send { receivers: Vec }, Recv { sender: u64 }, } /// Type of [`Track`]. -#[derive(Clone, Debug, PartialEq)] -#[cfg_attr(feature = "medea", derive(Serialize))] +#[cfg_attr(feature = "medea", derive(Serialize, Debug, PartialEq, Clone))] #[cfg_attr(feature = "jason", derive(Deserialize))] -#[cfg_attr(test, derive(PartialEq))] pub enum MediaType { Audio(AudioSettings), Video(VideoSettings), } -#[derive(Clone, Debug, PartialEq)] -#[cfg_attr(feature = "medea", derive(Serialize))] +#[cfg_attr(feature = "medea", derive(Serialize, Clone, Debug, PartialEq))] #[cfg_attr(feature = "jason", derive(Deserialize))] -#[cfg_attr(test, derive(PartialEq))] pub struct AudioSettings {} -#[derive(Clone, Debug, PartialEq)] -#[cfg_attr(feature = "medea", derive(Serialize))] +#[cfg_attr(feature = "medea", derive(Serialize, Clone, Debug, PartialEq))] #[cfg_attr(feature = "jason", derive(Deserialize))] -#[cfg_attr(test, derive(PartialEq))] pub struct VideoSettings {} #[cfg(feature = "jason")] diff --git a/tests/test_ports.rs b/tests/test_ports.rs index 3bcc1355e..36e16f7f0 100644 --- a/tests/test_ports.rs +++ b/tests/test_ports.rs @@ -38,6 +38,3 @@ generate_ports_for_tests!( pub fn get_port_for_test(name: &str) -> u16 { *PORTS.get(name).expect("Port for this name is not defined!") } - - - From 286b08791b51c1318d32ba58ec6bd01b0a9532d7 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 4 Jun 2019 13:19:20 +0300 Subject: [PATCH 075/735] Refactoring --- src/api/control/element.rs | 51 ++++++++++++------- src/api/control/member.rs | 14 ++--- src/api/control/mod.rs | 2 +- src/api/control/room.rs | 41 +++++++++++++-- src/lib.rs | 2 +- src/main.rs | 5 ++ src/media/peer.rs | 23 ++++++++- src/signalling/participants.rs | 3 -- src/signalling/peers.rs | 69 +++++++++++-------------- src/signalling/room.rs | 38 +++----------- src/signalling/room_repo.rs | 1 - tests/signalling.rs | 93 +++++++++++++--------------------- tests/test_ports.rs | 10 ++-- 13 files changed, 185 insertions(+), 167 deletions(-) diff --git a/src/api/control/element.rs b/src/api/control/element.rs index a1821149f..b661bc279 100644 --- a/src/api/control/element.rs +++ b/src/api/control/element.rs @@ -10,25 +10,26 @@ use serde::{ use crate::api::control::MemberId; use super::{Entity, TryFromEntityError}; +use serde::de::Unexpected; /// [`Element`] represents a media element that one or more media data streams /// flow through. #[derive(Debug)] -pub enum Element { - WebRtcPublishEndpoint(WebRtcPublishEndpoint), - WebRtcPlayEndpoint(WebRtcPlayEndpoint), +pub enum Endpoint { + WebRtcPublish(WebRtcPublishEndpoint), + WebRtcPlay(WebRtcPlayEndpoint), } -impl TryFrom for Element { +impl TryFrom for Endpoint { type Error = TryFromEntityError; fn try_from(from: Entity) -> Result { match from { Entity::WebRtcPlayEndpoint { spec } => { - Ok(Element::WebRtcPlayEndpoint(spec)) + Ok(Endpoint::WebRtcPlay(spec)) } Entity::WebRtcPublishEndpoint { spec } => { - Ok(Element::WebRtcPublishEndpoint(spec)) + Ok(Endpoint::WebRtcPublish(spec)) } _ => Err(TryFromEntityError::NotElement), } @@ -93,9 +94,12 @@ impl<'de> Deserialize<'de> for LocalUri { { let protocol_name: String = value.chars().take(8).collect(); if protocol_name != "local://" { - return Err(Error::custom( - "Expected local uri in format \ - local://room_id/member_id/pipeline_id!", + return Err(Error::invalid_value( + Unexpected::Str(&format!( + "{} in {}", + protocol_name, value + )), + &self, )); } @@ -105,27 +109,40 @@ impl<'de> Deserialize<'de> for LocalUri { let uri_body_splitted_len = uri_body_splitted.len(); if uri_body_splitted_len != 3 { let error_msg = if uri_body_splitted_len == 0 { - "Missing room_id, member_id, pipeline_id" + "room_id, member_id, pipeline_id" } else if uri_body_splitted_len == 1 { - "Missing member_id, pipeline_id" + "member_id, pipeline_id" } else if uri_body_splitted_len == 2 { - "Missing pipeline_id" + "pipeline_id" } else { - "Too many params" + return Err(Error::custom(format!( + "Too many fields: {}. Expecting 3 fields, found \ + {}.", + uri_body, uri_body_splitted_len + ))); }; - return Err(Error::custom(error_msg)); + return Err(Error::missing_field(error_msg)); } let room_id = uri_body_splitted.pop().unwrap().to_string(); if room_id.is_empty() { - return Err(Error::custom("room_id is empty!")); + return Err(Error::custom(format!( + "room_id in {} is empty!", + value + ))); } let member_id = uri_body_splitted.pop().unwrap().to_string(); if member_id.is_empty() { - return Err(Error::custom("member_id is empty!")); + return Err(Error::custom(format!( + "member_id in {} is empty!", + value + ))); } let pipeline_id = uri_body_splitted.pop().unwrap().to_string(); if pipeline_id.is_empty() { - return Err(Error::custom("pipeline_id is empty!")); + return Err(Error::custom(format!( + "pipeline_id in {} is empty!", + value + ))); } Ok(LocalUri { diff --git a/src/api/control/member.rs b/src/api/control/member.rs index 8b88d40b7..3511f662d 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -4,7 +4,9 @@ use std::{convert::TryFrom, fmt::Display, sync::Arc}; use serde::Deserialize; -use super::{element::Element, pipeline::Pipeline, Entity, TryFromEntityError}; +use super::{ + element::Endpoint, pipeline::Pipeline, Entity, TryFromEntityError, +}; use crate::api::control::element::{WebRtcPlayEndpoint, WebRtcPublishEndpoint}; @@ -41,15 +43,15 @@ pub struct MemberSpec { impl MemberSpec { /// Get [`Element`] of this [`MemberSpec`] by ID. - pub fn get_element( + pub fn get_element_by_id( &self, id: &str, - ) -> Option> { - Some(Element::try_from(self.spec.pipeline.get(id).cloned()?)) + ) -> Option> { + Some(Endpoint::try_from(self.spec.pipeline.get(id).cloned()?)) } /// Get all [`WebRtcPlayEndpoint`]s of this [`MemberSpec`]. - pub fn get_play_endpoints(&self) -> Vec<&WebRtcPlayEndpoint> { + pub fn play_endpoints(&self) -> Vec<&WebRtcPlayEndpoint> { self.spec .pipeline .iter() @@ -61,7 +63,7 @@ impl MemberSpec { } /// Get all [`WebRtcPublishEndpoint`]s of this [`MemberSpec`]. - pub fn get_publish_endpoints(&self) -> Vec<&WebRtcPublishEndpoint> { + pub fn publish_endpoints(&self) -> Vec<&WebRtcPublishEndpoint> { self.spec .pipeline .iter() diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index 6cd193571..6f0149f0b 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -16,7 +16,7 @@ use self::{ }; pub use self::{ - element::Element, + element::Endpoint, member::{Id as MemberId, Member, MemberSpec}, room::{Id as RoomId, RoomSpec}, }; diff --git a/src/api/control/room.rs b/src/api/control/room.rs index af4ad5037..9d396223d 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -1,11 +1,12 @@ //! Room definitions and implementations. +use hashbrown::HashMap; use serde::Deserialize; use std::convert::TryFrom; use super::{ - member::MemberSpec, pipeline::Pipeline, Entity, MemberId, - TryFromEntityError, + element::Endpoint, member::MemberSpec, pipeline::Pipeline, Entity, + MemberId, TryFromEntityError, }; /// ID of [`Room`]. @@ -27,7 +28,6 @@ impl RoomSpec { /// Return `None` if [`MemberSpec`] not presented in [`RoomSpec`]. /// Return `Some(TryFromEntityError::NotMember)` if entity with this ID /// finded but its not [`MemberSpec`]. - #[allow(clippy::ptr_arg)] pub fn get_member( &self, id: &MemberId, @@ -36,6 +36,41 @@ impl RoomSpec { self.spec.pipeline.get(&id.0).cloned()?, )) } + + /// Get all relations between [`Member`]s [`Endpoint`]s. + /// + /// Returns [`HashMap`] with [`MemberId`] of sender and all of his receivers + /// [`MemberId`]. + /// + /// Returns [`TryFromEntityError`] if some unexpected [`Entity`] finded. + pub fn get_sender_receivers( + &self, + ) -> Result>, TryFromEntityError> { + let mut sender_receivers: HashMap> = + HashMap::new(); + for (member_id, member_entity) in &self.spec.pipeline { + let member_id = MemberId(member_id.clone()); + let member = MemberSpec::try_from(member_entity.clone())?; + for element_entity in member.spec.pipeline.values() { + let element = Endpoint::try_from(element_entity.clone())?; + + if let Endpoint::WebRtcPlay(play) = element { + if let Some(m) = + sender_receivers.get_mut(&play.src.member_id) + { + m.push(member_id.clone()); + } else { + sender_receivers.insert( + play.src.member_id, + vec![member_id.clone()], + ); + } + } + } + } + + Ok(sender_receivers) + } } impl TryFrom for RoomSpec { diff --git a/src/lib.rs b/src/lib.rs index d2b5fee87..0353ee797 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -59,7 +59,7 @@ impl From for ServerStartError { pub fn start_static_rooms( config: &Conf, ) -> Result>, ServerStartError> { - if let Some(static_specs_path) = config.server.static_specs_path.clone() { + if let Some(static_specs_path) = &config.server.static_specs_path { let room_specs = match load_static_specs_from_dir(static_specs_path) { Ok(r) => r, Err(e) => return Err(ServerStartError::LoadSpec(e)), diff --git a/src/main.rs b/src/main.rs index 6609fd725..faa396b25 100644 --- a/src/main.rs +++ b/src/main.rs @@ -20,6 +20,11 @@ fn main() { match start_static_rooms(&config) { Ok(r) => { + // let loaded_rooms_id = + info!( + "Loaded rooms: {:?}", + r.iter().map(|(id, _)| &id.0).collect::>() + ); let room_repo = RoomsRepository::new(r); server::run(room_repo, config); } diff --git a/src/media/peer.rs b/src/media/peer.rs index 0e87fa645..cfed58737 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -13,7 +13,10 @@ use medea_macro::enum_delegate; use std::{convert::TryFrom, fmt::Display, sync::Arc}; use crate::{ - api::control::{element::WebRtcPublishEndpoint, MemberId}, + api::control::{ + element::{WebRtcPlayEndpoint, WebRtcPublishEndpoint}, + MemberId, + }, media::{MediaTrack, TrackId}, }; @@ -247,7 +250,7 @@ impl Peer { } } - /// Add all [`WebRtcPublishEndpoint`] to this [`Peer`]. + /// Add all [`WebRtcPublishEndpoint`]s to this [`Peer`]. /// /// This use `last_track_id` counter for generating new [`MediaTrack`] ID. pub fn add_publish_endpoints( @@ -272,6 +275,22 @@ impl Peer { } } + /// Add all `partner_peer` related [`WebRtcPlayEndpoint`]s to this [`Peer`]. + pub fn add_play_endpoints( + &mut self, + endpoints: Vec<&WebRtcPlayEndpoint>, + partner_peer: &mut Peer, + ) { + for endpoint in endpoints { + if self.context.partner_member == endpoint.src.member_id { + partner_peer + .get_senders() + .into_iter() + .for_each(|s| self.add_receiver(s)); + } + } + } + /// Transition new [`Peer`] into state of waiting for local description. pub fn start(self) -> Peer { Peer { diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index cf0d2c712..7deab712e 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -83,7 +83,6 @@ impl ParticipantService { } /// Lookup [`Member`] by provided id. - #[allow(clippy::ptr_arg)] pub fn get_member_by_id(&self, id: &MemberId) -> Option<&Member> { self.members.get(id) } @@ -92,7 +91,6 @@ impl ParticipantService { /// [`Err(AuthorizationError::MemberNotExists)`] if lookup by [`MemberId`] /// failed. Returns [`Err(AuthorizationError::InvalidCredentials)`] if /// [`Member`] was found, but incorrect credentials was provided. - #[allow(clippy::ptr_arg)] pub fn get_member_by_id_and_credentials( &self, member_id: &MemberId, @@ -111,7 +109,6 @@ impl ParticipantService { } /// Checks if [`Member`] has **active** [`RcpConnection`]. - #[allow(clippy::ptr_arg)] pub fn member_has_connection(&self, member_id: &MemberId) -> bool { self.connections.contains_key(member_id) && !self.drop_connection_tasks.contains_key(member_id) diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index 7fa62ea09..00a4c6bfb 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -40,62 +40,54 @@ impl PeerRepository { /// Create and interconnect [`Peer`]s based on [`MemberSpec`]. /// - /// Returns IDs of created [`Peer`]s. `(caller_peer_id, responder_peer_id)`. + /// Returns IDs of created [`Peer`]s. `(first_peer_id, second_peer_id)`. pub fn create_peers( &mut self, - caller: &Member, - responder: &Member, + first_member: &Member, + second_member: &Member, ) -> (u64, u64) { self.peers_count += 1; - let caller_peer_id = self.peers_count; + let first_peer_id = self.peers_count; self.peers_count += 1; - let responder_peer_id = self.peers_count; + let second_peer_id = self.peers_count; - let mut caller_peer = Peer::new( - caller_peer_id, - caller.id.clone(), - responder_peer_id, - responder.id.clone(), + let mut first_peer = Peer::new( + first_peer_id, + first_member.id.clone(), + second_peer_id, + second_member.id.clone(), ); - let mut responder_peer = Peer::new( - responder_peer_id, - responder.id.clone(), - caller_peer_id, - caller.id.clone(), + let mut second_peer = Peer::new( + second_peer_id, + second_member.id.clone(), + first_peer_id, + first_member.id.clone(), ); - caller_peer.add_publish_endpoints( - caller.spec.get_publish_endpoints(), + first_peer.add_publish_endpoints( + first_member.spec.publish_endpoints(), &mut self.tracks_count, ); - responder_peer.add_publish_endpoints( - responder.spec.get_publish_endpoints(), + second_peer.add_publish_endpoints( + second_member.spec.publish_endpoints(), &mut self.tracks_count, ); - for endpoint in caller.spec.get_play_endpoints() { - if responder.id == endpoint.src.member_id { - responder_peer - .get_senders() - .into_iter() - .for_each(|s| caller_peer.add_receiver(s)); - } - } - for endpoint in responder.spec.get_play_endpoints() { - if caller.id == endpoint.src.member_id { - caller_peer - .get_senders() - .into_iter() - .for_each(|s| responder_peer.add_receiver(s)); - } - } + first_peer.add_play_endpoints( + first_member.spec.play_endpoints(), + &mut second_peer, + ); + second_peer.add_play_endpoints( + second_member.spec.play_endpoints(), + &mut first_peer, + ); - self.add_peer(caller_peer_id, caller_peer); - self.add_peer(responder_peer_id, responder_peer); + self.add_peer(first_peer_id, first_peer); + self.add_peer(second_peer_id, second_peer); // println!("Peers: {:#?}", self.peers); - (caller_peer_id, responder_peer_id) + (first_peer_id, second_peer_id) } /// Returns borrowed [`Peer`] by its ID. @@ -116,7 +108,6 @@ impl PeerRepository { /// Returns [`Peer`] of specified [`Member`]. /// /// Panic if [`Peer`] not exists. - #[allow(clippy::ptr_arg)] pub fn get_peers_by_member_id( &self, member_id: &MemberId, diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 7c9dac34c..4264dd552 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -1,7 +1,7 @@ //! Room definitions and implementations. Room is responsible for media //! connection establishment between concrete [`Member`]s. -use std::{convert::TryFrom, time::Duration}; +use std::time::Duration; use actix::{ fut::wrap_future, Actor, ActorFuture, AsyncContext, Context, Handler, @@ -18,10 +18,7 @@ use crate::{ AuthorizationError, Authorize, CommandMessage, RpcConnectionClosed, RpcConnectionEstablished, }, - control::{ - Element, Member, MemberId, MemberSpec, RoomId, RoomSpec, - TryFromEntityError, - }, + control::{Member, MemberId, RoomId, RoomSpec, TryFromEntityError}, }, log::prelude::*, media::{ @@ -58,7 +55,7 @@ impl From for RoomError { impl From for RoomError { fn from(err: TryFromEntityError) -> Self { RoomError::BadRoomSpec(format!( - "Entity occured in wrong place. {}", + "Entity located in wrong place. {}", err )) } @@ -91,34 +88,11 @@ impl Room { room_spec: &RoomSpec, reconnect_timeout: Duration, ) -> Result { - let mut sender_receivers: HashMap> = - HashMap::new(); - for (member_id, member_entity) in &room_spec.spec.pipeline { - let member_id = MemberId(member_id.clone()); - let member = MemberSpec::try_from(member_entity.clone())?; - for element_entity in member.spec.pipeline.values() { - let element = Element::try_from(element_entity.clone())?; - - if let Element::WebRtcPlayEndpoint(play) = element { - if let Some(m) = - sender_receivers.get_mut(&play.src.member_id) - { - m.push(member_id.clone()); - } else { - sender_receivers.insert( - play.src.member_id, - vec![member_id.clone()], - ); - } - } - } - } - Ok(Self { id: room_spec.id.clone(), peers: PeerRepository::from(HashMap::new()), participants: ParticipantService::new(room_spec, reconnect_timeout), - sender_receivers, + sender_receivers: room_spec.get_sender_receivers()?, }) } @@ -289,7 +263,7 @@ impl Room { ctx.notify(ConnectPeers(caller_peer_id, responder_peer_id)); - // println!("Peers: {:#?}", self.peers); + // println!("Peers: {:#?}", self.peers); } } @@ -337,7 +311,7 @@ impl Room { } // connect senders - for play in member.spec.get_play_endpoints() { + for play in member.spec.play_endpoints() { let sender_member_id = &play.src.member_id; if already_connected_members.contains(sender_member_id) { continue; diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs index 35b17513d..ae446b23a 100644 --- a/src/signalling/room_repo.rs +++ b/src/signalling/room_repo.rs @@ -24,7 +24,6 @@ impl RoomsRepository { } /// Returns [`Room`] by its ID. - #[allow(clippy::ptr_arg)] pub fn get(&self, id: &RoomId) -> Option> { let rooms = self.rooms.lock().unwrap(); rooms.get(id).cloned() diff --git a/tests/signalling.rs b/tests/signalling.rs index 59c454e74..fa43c8eb0 100644 --- a/tests/signalling.rs +++ b/tests/signalling.rs @@ -22,7 +22,7 @@ use std::{ /// Medea client for testing purposes. struct TestMember { - /// Writer to websocket. + /// Writer to WebSocket. writer: ClientWriter, /// All [`Event`]s which this [`TestMember`] received. @@ -71,7 +71,7 @@ impl TestMember { self.writer.text(&serde_json::to_string(&msg).unwrap()); } - /// Start test member in new [`Arbiter`] by given uri. + /// Start test member in new [`Arbiter`] by given URI. /// `test_fn` - is function which will be called at every [`Event`] /// received from server. pub fn start(uri: &str, test_fn: Box) { @@ -97,8 +97,8 @@ impl TestMember { impl StreamHandler for TestMember { /// Basic signalling implementation. - /// A `TestMember::test_fn` function will be called for each [`Event`] - /// received from test server. + /// A `TestMember::test_fn` [`FnMut`] function will be called for each + /// [`Event`] received from test server. fn handle(&mut self, msg: WebMessage, _ctx: &mut Context) { match msg { WebMessage::Text(txt) => { @@ -110,9 +110,7 @@ impl StreamHandler for TestMember { (self.test_fn)(&event); match event { Event::PeerCreated { - peer_id, - sdp_offer, - tracks: _, + peer_id, sdp_offer, .. } => { match sdp_offer { Some(_) => { @@ -150,20 +148,24 @@ impl StreamHandler for TestMember { /// Run medea server. This function lock main thread until server is up. /// Server starts in different thread and `join`'ed with main thread. /// When test is done, server will be destroyed. +/// /// Server load all specs from `tests/specs`. +/// /// Provide name for thread same as your test function's name. This will -/// help you when server is panic in some test case. -/// __Please, generate port__ by adding your test name to -/// `/tests/test_port.rs::generate_ports_for_tests!` for dealing with -/// asynchronously of tests. -fn run_test_server(bind_port: u16, thread_name: &str) { +/// help you when server is panic in some test case. And this `test_name` +/// will be used as name for getting port from [`test_ports`] module. +/// +/// Don't forget register your test in [`test_ports`], otherwise the server +/// will just panic. +fn run_test_server(test_name: &str) -> u16 { + let bind_port = test_ports::get_port_for_test(test_name); + let is_server_starting = Arc::new(Mutex::new(Cell::new(true))); let is_server_starting_ref = Arc::clone(&is_server_starting); - let builder = std::thread::Builder::new().name(thread_name.to_string()); + let builder = std::thread::Builder::new().name(test_name.to_string()); let server_thread = builder .spawn(move || { - dotenv::dotenv().ok(); let _sys = System::new("medea"); let config = Conf { @@ -194,13 +196,14 @@ fn run_test_server(bind_port: u16, thread_name: &str) { while is_server_starting.lock().unwrap().get() {} server_thread.join().unwrap(); + + bind_port } #[test] fn should_work_pub_sub_video_call() { let test_name = "should_work_pub_sub_video_call"; - let bind_port = test_ports::get_port_for_test(test_name); - run_test_server(bind_port, "should_work_pub_sub_video_call"); + let bind_port = run_test_server(test_name); let base_url = format!("ws://localhost:{}/ws/pub-sub-video-call", bind_port); @@ -211,19 +214,13 @@ fn should_work_pub_sub_video_call() { let mut events = Vec::new(); let test_fn = move |event: &Event| { events.push(event.clone()); - if let Event::IceCandidateDiscovered { - peer_id: _, - candidate: _, - } = event - { + + // Start of checking result of test. + if let Event::IceCandidateDiscovered { .. } = event { let peers_count = events .iter() .filter(|e| match e { - Event::PeerCreated { - peer_id: _, - sdp_offer: _, - tracks: _, - } => true, + Event::PeerCreated { .. } => true, _ => false, }) .count(); @@ -259,32 +256,17 @@ fn should_work_pub_sub_video_call() { } if is_caller { - if let Event::SdpAnswerMade { - peer_id: _, - sdp_answer: _, - } = &events[1] - { - assert!(true); + if let Event::SdpAnswerMade { .. } = &events[1] { } else { assert!(false); } - if let Event::IceCandidateDiscovered { - peer_id: _, - candidate: _, - } = &events[2] - { - assert!(true); + if let Event::IceCandidateDiscovered { .. } = &events[2] { } else { assert!(false); } } else { - if let Event::IceCandidateDiscovered { - peer_id: _, - candidate: _, - } = &events[1] - { - assert!(true); + if let Event::IceCandidateDiscovered { .. } = &events[1] { } else { assert!(false); } @@ -311,44 +293,37 @@ fn should_work_pub_sub_video_call() { #[test] fn should_work_three_members_p2p_video_call() { let test_name = "should_work_three_members_p2p_video_call"; - let bind_port = test_ports::get_port_for_test(test_name); - run_test_server(bind_port, test_name); + let bind_port = run_test_server(test_name); let base_url = format!("ws://localhost:{}/ws/three-members-conference", bind_port); let sys = System::new(test_name); - // Note that events, peer_created_count, ice_candidates and members_tested + // Note that events, peer_created_count, ice_candidates // is separated by members. // Every member will have different instance of this. let mut events = Vec::new(); let mut peer_created_count = 0; let mut ice_candidates = 0; + // This is shared state of members. let members_tested = Rc::new(Cell::new(0)); let test_fn = move |event: &Event| { events.push(event.clone()); match event { - Event::PeerCreated { - peer_id: _, - sdp_offer: _, - tracks: _, - } => { + Event::PeerCreated { .. } => { peer_created_count += 1; } - Event::IceCandidateDiscovered { - peer_id: _, - candidate: _, - } => { + Event::IceCandidateDiscovered { .. } => { ice_candidates += 1; if ice_candidates == 2 { + // Start of checking result of test. + assert_eq!(peer_created_count, 2); events.iter().for_each(|e| match e { Event::PeerCreated { - peer_id, - sdp_offer: _, - tracks, + peer_id, tracks, .. } => { assert_eq!(tracks.len(), 4); let recv_count = tracks diff --git a/tests/test_ports.rs b/tests/test_ports.rs index 36e16f7f0..600afabac 100644 --- a/tests/test_ports.rs +++ b/tests/test_ports.rs @@ -3,8 +3,11 @@ /// Macro for generating ports numbers. /// This should used when you want to start test server. /// It's necessary because tests run asynchronously and ports -/// should not overlap. Enumerating start from 40000 because -/// the chance to cross the already used port is very small. +/// should not overlap. Enumerating start from 49151 because +/// based on [Registered by IANA ports][1] this is the last reserved port. +/// 16384 ought to be enough for anybody. +/// +/// [1]: https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers macro_rules! generate_ports_for_tests { ( $( $x:tt ),* $(,)* ) => { use lazy_static::lazy_static; @@ -18,7 +21,7 @@ macro_rules! generate_ports_for_tests { .into_iter() .enumerate() .map(|(i, t)| { - let port = 40000 + i as u16; + let port = 49151 + i as u16; (t, port) }) .collect() @@ -27,6 +30,7 @@ macro_rules! generate_ports_for_tests { }; } +// Register your test by adding test name into this macro call. generate_ports_for_tests!( should_work_three_members_p2p_video_call, should_work_pub_sub_video_call, From 593dcd09bfa6f78e57300a2ebada17f83a644079 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 4 Jun 2019 13:58:57 +0300 Subject: [PATCH 076/735] Rename specs --- specs/{pub_sub_room.yml => pub_sub_video_call.yml} | 0 ..._3_members.yml => three_members_conference.yml} | 14 +++++++------- specs/{room_spec.yml => video_call_1.yml} | 0 src/api/client/server.rs | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) rename specs/{pub_sub_room.yml => pub_sub_video_call.yml} (100%) rename specs/{room_spec_with_3_members.yml => three_members_conference.yml} (74%) rename specs/{room_spec.yml => video_call_1.yml} (100%) diff --git a/specs/pub_sub_room.yml b/specs/pub_sub_video_call.yml similarity index 100% rename from specs/pub_sub_room.yml rename to specs/pub_sub_video_call.yml diff --git a/specs/room_spec_with_3_members.yml b/specs/three_members_conference.yml similarity index 74% rename from specs/room_spec_with_3_members.yml rename to specs/three_members_conference.yml index d6511b2a7..34ea7e8f5 100644 --- a/specs/room_spec_with_3_members.yml +++ b/specs/three_members_conference.yml @@ -1,5 +1,5 @@ kind: Room -id: video-call-3 +id: three-members-conference spec: pipeline: # Here we're defining a member who initiates video call. @@ -18,11 +18,11 @@ spec: play: kind: WebRtcPlayEndpoint spec: - src: "local://video-call-3/responder/publish" + src: "local://three-members-conference/responder/publish" play2: kind: WebRtcPlayEndpoint spec: - src: "local://video-call-3/responder2/publish" + src: "local://three-members-conference/responder2/publish" responder: kind: Member credentials: test @@ -35,11 +35,11 @@ spec: play1: kind: WebRtcPlayEndpoint spec: - src: "local://video-call-3/caller/publish" + src: "local://three-members-conference/caller/publish" play2: kind: WebRtcPlayEndpoint spec: - src: "local://video-call-3/responder2/publish" + src: "local://three-members-conference/responder2/publish" responder2: kind: Member @@ -53,8 +53,8 @@ spec: play1: kind: WebRtcPlayEndpoint spec: - src: "local://video-call-3/caller/publish" + src: "local://three-members-conference/caller/publish" play2: kind: WebRtcPlayEndpoint spec: - src: "local://video-call-3/responder/publish" + src: "local://three-members-conference/responder/publish" diff --git a/specs/room_spec.yml b/specs/video_call_1.yml similarity index 100% rename from specs/room_spec.yml rename to specs/video_call_1.yml diff --git a/src/api/client/server.rs b/src/api/client/server.rs index 3c3d9dfd1..ae0e255a9 100644 --- a/src/api/client/server.rs +++ b/src/api/client/server.rs @@ -119,7 +119,7 @@ mod test { /// Creates [`RoomsRepository`] for tests filled with a single [`Room`]. fn room(conf: Rpc) -> RoomsRepository { let room_spec = - control::load_from_yaml_file("./specs/room_spec.yml").unwrap(); + control::load_from_yaml_file("./specs/video_call_1.yml").unwrap(); let client_room = Room::new(&room_spec, conf.reconnect_timeout).unwrap(); From d275f9d97b64cb6105a72330d10f29129193777f Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 4 Jun 2019 14:19:56 +0300 Subject: [PATCH 077/735] Rename element to endpoint --- src/api/control/{element.rs => endpoint.rs} | 18 ++++++++++-------- src/api/control/member.rs | 8 +++++--- src/api/control/mod.rs | 8 ++++---- src/api/control/room.rs | 2 +- src/main.rs | 1 - src/media/peer.rs | 2 +- 6 files changed, 21 insertions(+), 18 deletions(-) rename src/api/control/{element.rs => endpoint.rs} (93%) diff --git a/src/api/control/element.rs b/src/api/control/endpoint.rs similarity index 93% rename from src/api/control/element.rs rename to src/api/control/endpoint.rs index b661bc279..4e4bf85ed 100644 --- a/src/api/control/element.rs +++ b/src/api/control/endpoint.rs @@ -1,4 +1,4 @@ -//! Control API specification Element definitions. +//! Control API specification Endpoint definitions. use std::{convert::TryFrom, fmt}; @@ -12,7 +12,7 @@ use crate::api::control::MemberId; use super::{Entity, TryFromEntityError}; use serde::de::Unexpected; -/// [`Element`] represents a media element that one or more media data streams +/// [`Endpoint`] represents a media element that one or more media data streams /// flow through. #[derive(Debug)] pub enum Endpoint { @@ -31,13 +31,13 @@ impl TryFrom for Endpoint { Entity::WebRtcPublishEndpoint { spec } => { Ok(Endpoint::WebRtcPublish(spec)) } - _ => Err(TryFromEntityError::NotElement), + _ => Err(TryFromEntityError::NotEndpoint), } } } /// Peer-to-peer mode of [`WebRtcPublishEndpoint`]. -#[derive(Deserialize, Debug, Clone)] +#[derive(Clone, Deserialize, Debug)] pub enum P2pMode { /// Always connect peer-to-peer. Always, @@ -45,28 +45,30 @@ pub enum P2pMode { /// Media element which is able to publish media data for another client via /// WebRTC. -#[derive(Deserialize, Debug, Clone)] +#[allow(clippy::module_name_repetitions)] +#[derive(Clone, Deserialize, Debug)] pub struct WebRtcPublishEndpoint { /// Peer-to-peer mode. pub p2p: P2pMode, } /// Media element which is able to play media data for client via WebRTC. -#[derive(Deserialize, Debug, Clone)] +#[allow(clippy::module_name_repetitions)] +#[derive(Clone, Deserialize, Debug)] pub struct WebRtcPlayEndpoint { /// Source URI in format `local://{room_id}/{member_id}/{pipeline_id}`. pub src: LocalUri, } /// Special uri with pattern `local://{room_id}/{member_id}/{pipeline_id}`. -#[derive(Debug, Clone)] +#[derive(Clone, Debug)] pub struct LocalUri { /// ID of [`Room`] // TODO: Why this field never used??? pub room_id: String, /// ID of [`Member`] pub member_id: MemberId, - /// Control ID of [`Element`] + /// Control ID of [`Endpoint`] pub pipeline_id: String, } diff --git a/src/api/control/member.rs b/src/api/control/member.rs index 3511f662d..1e968f4d8 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -5,10 +5,12 @@ use std::{convert::TryFrom, fmt::Display, sync::Arc}; use serde::Deserialize; use super::{ - element::Endpoint, pipeline::Pipeline, Entity, TryFromEntityError, + endpoint::Endpoint, pipeline::Pipeline, Entity, TryFromEntityError, }; -use crate::api::control::element::{WebRtcPlayEndpoint, WebRtcPublishEndpoint}; +use crate::api::control::endpoint::{ + WebRtcPlayEndpoint, WebRtcPublishEndpoint, +}; /// ID of [`Member`]. #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq)] @@ -21,7 +23,7 @@ impl Display for Id { } /// Media server user with its ID and credentials. -#[derive(Debug, Clone)] +#[derive(Clone, Debug)] pub struct Member { /// ID of [`Member`]. pub id: Id, diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index 6f0149f0b..94e153494 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -1,6 +1,6 @@ //! Implementation of Control API. -pub mod element; +pub mod endpoint; pub mod member; pub mod pipeline; pub mod room; @@ -11,12 +11,12 @@ use serde::Deserialize; use std::{convert::TryFrom as _, fs::File, io::Read as _, path::Path}; use self::{ - element::{WebRtcPlayEndpoint, WebRtcPublishEndpoint}, + endpoint::{WebRtcPlayEndpoint, WebRtcPublishEndpoint}, pipeline::Pipeline, }; pub use self::{ - element::Endpoint, + endpoint::Endpoint, member::{Id as MemberId, Member, MemberSpec}, room::{Id as RoomId, RoomSpec}, }; @@ -27,7 +27,7 @@ pub use self::{ #[derive(Debug, Fail)] pub enum TryFromEntityError { #[fail(display = "Entity is not Element")] - NotElement, + NotEndpoint, #[fail(display = "Entity is not Room")] NotRoom, #[fail(display = "Entity is not Member")] diff --git a/src/api/control/room.rs b/src/api/control/room.rs index 9d396223d..da82f16fe 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -5,7 +5,7 @@ use serde::Deserialize; use std::convert::TryFrom; use super::{ - element::Endpoint, member::MemberSpec, pipeline::Pipeline, Entity, + endpoint::Endpoint, member::MemberSpec, pipeline::Pipeline, Entity, MemberId, TryFromEntityError, }; diff --git a/src/main.rs b/src/main.rs index faa396b25..854622a1a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -20,7 +20,6 @@ fn main() { match start_static_rooms(&config) { Ok(r) => { - // let loaded_rooms_id = info!( "Loaded rooms: {:?}", r.iter().map(|(id, _)| &id.0).collect::>() diff --git a/src/media/peer.rs b/src/media/peer.rs index cfed58737..18a41af54 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -14,7 +14,7 @@ use std::{convert::TryFrom, fmt::Display, sync::Arc}; use crate::{ api::control::{ - element::{WebRtcPlayEndpoint, WebRtcPublishEndpoint}, + endpoint::{WebRtcPlayEndpoint, WebRtcPublishEndpoint}, MemberId, }, media::{MediaTrack, TrackId}, From 8a26282955a4d0f6d137a628463ff70ed07db529 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 4 Jun 2019 14:31:06 +0300 Subject: [PATCH 078/735] Small fixes --- src/api/control/member.rs | 4 ++-- src/api/control/mod.rs | 6 +++--- src/media/peer.rs | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/api/control/member.rs b/src/api/control/member.rs index 1e968f4d8..20c597fae 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -44,8 +44,8 @@ pub struct MemberSpec { } impl MemberSpec { - /// Get [`Element`] of this [`MemberSpec`] by ID. - pub fn get_element_by_id( + /// Get [`Endpoint`] of this [`MemberSpec`] by ID. + pub fn get_endpoint_by_id( &self, id: &str, ) -> Option> { diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index 94e153494..126c0671f 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -26,7 +26,7 @@ pub use self::{ #[allow(clippy::pub_enum_variant_names)] #[derive(Debug, Fail)] pub enum TryFromEntityError { - #[fail(display = "Entity is not Element")] + #[fail(display = "Entity is not Endpoint")] NotEndpoint, #[fail(display = "Entity is not Room")] NotRoom, @@ -47,11 +47,11 @@ pub enum Entity { Member { spec: Pipeline, credentials: String }, /// Represent [`WebRtcPublishEndpoint`]. - /// Can transform into [`Element`] enum by `Element::try_from`. + /// Can transform into [`Endpoint`] enum by `Endpoint::try_from`. WebRtcPublishEndpoint { spec: WebRtcPublishEndpoint }, /// Represent [`WebRtcPlayEndpoint`]. - /// Can transform into [`Element`] enum by `Element::try_from`. + /// Can transform into [`Endpoint`] enum by `Endpoint::try_from`. WebRtcPlayEndpoint { spec: WebRtcPlayEndpoint }, } diff --git a/src/media/peer.rs b/src/media/peer.rs index 18a41af54..cb3883bfd 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -258,7 +258,7 @@ impl Peer { endpoints: Vec<&WebRtcPublishEndpoint>, last_track_id: &mut u64, ) { - for _endpoint in endpoints { + for _ in endpoints { *last_track_id += 1; let track_audio = Arc::new(MediaTrack::new( *last_track_id, From 3586bcc41de480b3398a463bd2556ef45a2ddc45 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 4 Jun 2019 14:57:04 +0300 Subject: [PATCH 079/735] Rename Entity to Element --- src/api/control/endpoint.rs | 14 +++++++------- src/api/control/member.rs | 20 ++++++++++---------- src/api/control/mod.rs | 14 +++++++------- src/api/control/pipeline.rs | 4 ++-- src/api/control/room.rs | 34 +++++++++++++++++----------------- src/signalling/participants.rs | 5 +++-- src/signalling/room.rs | 10 +++++----- 7 files changed, 51 insertions(+), 50 deletions(-) diff --git a/src/api/control/endpoint.rs b/src/api/control/endpoint.rs index 4e4bf85ed..5fe1632a6 100644 --- a/src/api/control/endpoint.rs +++ b/src/api/control/endpoint.rs @@ -9,7 +9,7 @@ use serde::{ use crate::api::control::MemberId; -use super::{Entity, TryFromEntityError}; +use super::{Element, TryFromElementError}; use serde::de::Unexpected; /// [`Endpoint`] represents a media element that one or more media data streams @@ -20,18 +20,18 @@ pub enum Endpoint { WebRtcPlay(WebRtcPlayEndpoint), } -impl TryFrom for Endpoint { - type Error = TryFromEntityError; +impl TryFrom for Endpoint { + type Error = TryFromElementError; - fn try_from(from: Entity) -> Result { + fn try_from(from: Element) -> Result { match from { - Entity::WebRtcPlayEndpoint { spec } => { + Element::WebRtcPlayEndpoint { spec } => { Ok(Endpoint::WebRtcPlay(spec)) } - Entity::WebRtcPublishEndpoint { spec } => { + Element::WebRtcPublishEndpoint { spec } => { Ok(Endpoint::WebRtcPublish(spec)) } - _ => Err(TryFromEntityError::NotEndpoint), + _ => Err(TryFromElementError::NotEndpoint), } } } diff --git a/src/api/control/member.rs b/src/api/control/member.rs index 20c597fae..0a37eda8b 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -5,7 +5,7 @@ use std::{convert::TryFrom, fmt::Display, sync::Arc}; use serde::Deserialize; use super::{ - endpoint::Endpoint, pipeline::Pipeline, Entity, TryFromEntityError, + endpoint::Endpoint, pipeline::Pipeline, Element, TryFromElementError, }; use crate::api::control::endpoint::{ @@ -32,7 +32,7 @@ pub struct Member { pub spec: Arc, } -/// Newtype for [`Entity::Member`] variant. +/// Newtype for [`Element::Member`] variant. #[allow(clippy::module_name_repetitions)] #[derive(Clone, Debug)] pub struct MemberSpec { @@ -48,7 +48,7 @@ impl MemberSpec { pub fn get_endpoint_by_id( &self, id: &str, - ) -> Option> { + ) -> Option> { Some(Endpoint::try_from(self.spec.pipeline.get(id).cloned()?)) } @@ -58,7 +58,7 @@ impl MemberSpec { .pipeline .iter() .filter_map(|(_, e)| match e { - Entity::WebRtcPlayEndpoint { spec } => Some(spec), + Element::WebRtcPlayEndpoint { spec } => Some(spec), _ => None, }) .collect() @@ -70,22 +70,22 @@ impl MemberSpec { .pipeline .iter() .filter_map(|(_, e)| match e { - Entity::WebRtcPublishEndpoint { spec } => Some(spec), + Element::WebRtcPublishEndpoint { spec } => Some(spec), _ => None, }) .collect() } } -impl TryFrom for MemberSpec { - type Error = TryFromEntityError; +impl TryFrom for MemberSpec { + type Error = TryFromElementError; - fn try_from(from: Entity) -> Result { + fn try_from(from: Element) -> Result { match from { - Entity::Member { spec, credentials } => { + Element::Member { spec, credentials } => { Ok(Self { spec, credentials }) } - _ => Err(TryFromEntityError::NotMember), + _ => Err(TryFromElementError::NotMember), } } } diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index 126c0671f..636f71ca4 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -21,23 +21,23 @@ pub use self::{ room::{Id as RoomId, RoomSpec}, }; -/// Errors that can occur when we try transform some spec from [`Entity`]. +/// Errors that can occur when we try transform some spec from [`Element`]. /// This error used in all [`TryFrom`] of Control API. #[allow(clippy::pub_enum_variant_names)] #[derive(Debug, Fail)] -pub enum TryFromEntityError { - #[fail(display = "Entity is not Endpoint")] +pub enum TryFromElementError { + #[fail(display = "Element is not Endpoint")] NotEndpoint, - #[fail(display = "Entity is not Room")] + #[fail(display = "Element is not Room")] NotRoom, - #[fail(display = "Entity is not Member")] + #[fail(display = "Element is not Member")] NotMember, } /// Entity for parsing Control API request. #[derive(Clone, Deserialize, Debug)] #[serde(tag = "kind")] -pub enum Entity { +pub enum Element { /// Represent [`RoomSpec`]. /// Can transform into [`RoomSpec`] by `RoomSpec::try_from`. Room { id: RoomId, spec: Pipeline }, @@ -60,7 +60,7 @@ pub fn load_from_yaml_file>(path: P) -> Result { let mut file = File::open(path)?; let mut buf = String::new(); file.read_to_string(&mut buf)?; - let parsed: Entity = serde_yaml::from_str(&buf)?; + let parsed: Element = serde_yaml::from_str(&buf)?; let room = RoomSpec::try_from(parsed)?; Ok(room) diff --git a/src/api/control/pipeline.rs b/src/api/control/pipeline.rs index db9c7b2a2..fb0cdb16d 100644 --- a/src/api/control/pipeline.rs +++ b/src/api/control/pipeline.rs @@ -4,10 +4,10 @@ use serde::Deserialize; use std::collections::HashMap; -use crate::api::control::Entity; +use crate::api::control::Element; /// Entity that represents some pipeline of spec. #[derive(Clone, Deserialize, Debug)] pub struct Pipeline { - pub pipeline: HashMap, + pub pipeline: HashMap, } diff --git a/src/api/control/room.rs b/src/api/control/room.rs index da82f16fe..6a904853a 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -5,8 +5,8 @@ use serde::Deserialize; use std::convert::TryFrom; use super::{ - endpoint::Endpoint, member::MemberSpec, pipeline::Pipeline, Entity, - MemberId, TryFromEntityError, + endpoint::Endpoint, member::MemberSpec, pipeline::Pipeline, Element, + MemberId, TryFromElementError, }; /// ID of [`Room`]. @@ -14,7 +14,7 @@ use super::{ pub struct Id(pub String); /// [`crate::signalling::room::Room`] specification. -/// Newtype for [`Entity::Room`] +/// Newtype for [`Element::Room`] #[allow(clippy::module_name_repetitions)] #[derive(Clone, Debug)] pub struct RoomSpec { @@ -26,12 +26,12 @@ impl RoomSpec { /// Try to find [`MemberSpec`] by ID. /// /// Return `None` if [`MemberSpec`] not presented in [`RoomSpec`]. - /// Return `Some(TryFromEntityError::NotMember)` if entity with this ID + /// Return `Some(TryFromElementError::NotMember)` if element with this ID /// finded but its not [`MemberSpec`]. pub fn get_member( &self, id: &MemberId, - ) -> Option> { + ) -> Option> { Some(MemberSpec::try_from( self.spec.pipeline.get(&id.0).cloned()?, )) @@ -42,19 +42,19 @@ impl RoomSpec { /// Returns [`HashMap`] with [`MemberId`] of sender and all of his receivers /// [`MemberId`]. /// - /// Returns [`TryFromEntityError`] if some unexpected [`Entity`] finded. + /// Returns [`TryFromElementError`] if some unexpected [`Element`] finded. pub fn get_sender_receivers( &self, - ) -> Result>, TryFromEntityError> { + ) -> Result>, TryFromElementError> { let mut sender_receivers: HashMap> = HashMap::new(); - for (member_id, member_entity) in &self.spec.pipeline { + for (member_id, member_element) in &self.spec.pipeline { let member_id = MemberId(member_id.clone()); - let member = MemberSpec::try_from(member_entity.clone())?; - for element_entity in member.spec.pipeline.values() { - let element = Endpoint::try_from(element_entity.clone())?; + let member = MemberSpec::try_from(member_element.clone())?; + for endpoint_element in member.spec.pipeline.values() { + let endpoint = Endpoint::try_from(endpoint_element.clone())?; - if let Endpoint::WebRtcPlay(play) = element { + if let Endpoint::WebRtcPlay(play) = endpoint { if let Some(m) = sender_receivers.get_mut(&play.src.member_id) { @@ -73,13 +73,13 @@ impl RoomSpec { } } -impl TryFrom for RoomSpec { - type Error = TryFromEntityError; +impl TryFrom for RoomSpec { + type Error = TryFromElementError; - fn try_from(from: Entity) -> Result { + fn try_from(from: Element) -> Result { match from { - Entity::Room { id, spec } => Ok(Self { id, spec }), - _ => Err(TryFromEntityError::NotRoom), + Element::Room { id, spec } => Ok(Self { id, spec }), + _ => Err(TryFromElementError::NotRoom), } } } diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 7deab712e..a8bc5d3ed 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -60,8 +60,9 @@ impl ParticipantService { .spec .pipeline .iter() - .map(|(control_id, entity)| { - let member_spec = MemberSpec::try_from(entity.clone()).unwrap(); + .map(|(control_id, element)| { + let member_spec = + MemberSpec::try_from(element.clone()).unwrap(); ( MemberId(control_id.clone()), diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 4264dd552..3d2e618f3 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -18,7 +18,7 @@ use crate::{ AuthorizationError, Authorize, CommandMessage, RpcConnectionClosed, RpcConnectionEstablished, }, - control::{Member, MemberId, RoomId, RoomSpec, TryFromEntityError}, + control::{Member, MemberId, RoomId, RoomSpec, TryFromElementError}, }, log::prelude::*, media::{ @@ -52,10 +52,10 @@ impl From for RoomError { } } -impl From for RoomError { - fn from(err: TryFromEntityError) -> Self { +impl From for RoomError { + fn from(err: TryFromElementError) -> Self { RoomError::BadRoomSpec(format!( - "Entity located in wrong place. {}", + "Element located in wrong place. {}", err )) } @@ -82,7 +82,7 @@ pub struct Room { impl Room { /// Create new instance of [`Room`]. /// - /// Returns [`RoomError::BadRoomSpec`] when error while [`Entity`] + /// Returns [`RoomError::BadRoomSpec`] when error while [`Element`] /// transformation happens. pub fn new( room_spec: &RoomSpec, From 257ff1e667553d47e3fce82fe63f88ffc93a1705 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 4 Jun 2019 15:56:24 +0300 Subject: [PATCH 080/735] Add deleting peers on RpcConnectionClosed --- src/signalling/peers.rs | 20 ++++++++++++++++++++ src/signalling/room.rs | 14 +++++++++++--- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index 00a4c6bfb..421fb7c16 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -138,6 +138,26 @@ impl PeerRepository { None => Err(RoomError::PeerNotFound(peer_id)), } } + + /// Close all related to disconnected [`Member`] [`Peer`]s and partner + /// [`Peer`]s. + pub fn connection_closed(&mut self, member_id: &MemberId) { + let mut peers_to_remove: Vec = Vec::new(); + for peer in self.get_peers_by_member_id(member_id) { + for partner_peer in + self.get_peers_by_member_id(&peer.partner_member_id()) + { + if &partner_peer.partner_member_id() == member_id { + peers_to_remove.push(partner_peer.id()); + } + } + peers_to_remove.push(peer.id()); + } + + for peer_id in peers_to_remove { + self.peers.remove(&peer_id); + } + } } impl From> for PeerRepository { diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 3d2e618f3..6f242aada 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -15,8 +15,8 @@ use medea_client_api_proto::{Command, Event, IceCandidate}; use crate::{ api::{ client::rpc_connection::{ - AuthorizationError, Authorize, CommandMessage, RpcConnectionClosed, - RpcConnectionEstablished, + AuthorizationError, Authorize, ClosedReason, CommandMessage, + RpcConnectionClosed, RpcConnectionEstablished, }, control::{Member, MemberId, RoomId, RoomSpec, TryFromElementError}, }, @@ -463,7 +463,10 @@ impl Handler for Room { msg.connection, ); - self.create_necessary_peers(&msg.member_id, ctx); + // Check that user is not reconnecting + if self.peers.get_peers_by_member_id(&msg.member_id).is_empty() { + self.create_necessary_peers(&msg.member_id, ctx); + } Box::new(wrap_future(future::ok(()))) } @@ -495,12 +498,17 @@ impl Handler for Room { type Result = (); /// Passes message to [`ParticipantService`] to cleanup stored connections. + /// Remove all related for disconnected [`Member`] [`Peer`]s. fn handle(&mut self, msg: RpcConnectionClosed, ctx: &mut Self::Context) { info!( "RpcConnectionClosed for member {}, reason {:?}", msg.member_id, msg.reason ); + if let ClosedReason::Closed = msg.reason { + self.peers.connection_closed(&msg.member_id); + } + self.participants .connection_closed(ctx, msg.member_id, &msg.reason); } From 43a00fd3eca395b3395a7468dc79c7b332e17af6 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 4 Jun 2019 18:04:09 +0300 Subject: [PATCH 081/735] Remove sender_receivers and move this logic into Member --- src/api/control/member.rs | 3 +++ src/api/control/room.rs | 37 ++++++--------------------- src/signalling/participants.rs | 46 +++++++++++++++++----------------- src/signalling/room.rs | 39 +++++++++++----------------- 4 files changed, 49 insertions(+), 76 deletions(-) diff --git a/src/api/control/member.rs b/src/api/control/member.rs index 0a37eda8b..0bdd65360 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -30,6 +30,9 @@ pub struct Member { /// Control API specification of this [`Member`]. pub spec: Arc, + + /// Receivers of this [`Member`]'s publish endpoints. + pub receivers: Vec, } /// Newtype for [`Element::Member`] variant. diff --git a/src/api/control/room.rs b/src/api/control/room.rs index 6a904853a..302d5e53f 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -1,11 +1,10 @@ //! Room definitions and implementations. -use hashbrown::HashMap; use serde::Deserialize; use std::convert::TryFrom; use super::{ - endpoint::Endpoint, member::MemberSpec, pipeline::Pipeline, Element, + member::MemberSpec, pipeline::Pipeline, Element, MemberId, TryFromElementError, }; @@ -37,39 +36,19 @@ impl RoomSpec { )) } - /// Get all relations between [`Member`]s [`Endpoint`]s. - /// - /// Returns [`HashMap`] with [`MemberId`] of sender and all of his receivers - /// [`MemberId`]. - /// - /// Returns [`TryFromElementError`] if some unexpected [`Element`] finded. - pub fn get_sender_receivers( - &self, - ) -> Result>, TryFromElementError> { - let mut sender_receivers: HashMap> = - HashMap::new(); + /// Get all receivers of all [`Member`]'s [`WebRtcPublishEndpoint`]s. + pub fn get_receivers_for_member(&self, id: &MemberId) -> Result, TryFromElementError> { + let mut receivers = Vec::new(); for (member_id, member_element) in &self.spec.pipeline { - let member_id = MemberId(member_id.clone()); let member = MemberSpec::try_from(member_element.clone())?; - for endpoint_element in member.spec.pipeline.values() { - let endpoint = Endpoint::try_from(endpoint_element.clone())?; - - if let Endpoint::WebRtcPlay(play) = endpoint { - if let Some(m) = - sender_receivers.get_mut(&play.src.member_id) - { - m.push(member_id.clone()); - } else { - sender_receivers.insert( - play.src.member_id, - vec![member_id.clone()], - ); - } + for endpoint in member.play_endpoints() { + if &endpoint.src.member_id == id { + receivers.push(MemberId(member_id.clone())); } } } - Ok(sender_receivers) + Ok(receivers) } } diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index a8bc5d3ed..3c3b59835 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -22,7 +22,7 @@ use crate::{ AuthorizationError, ClosedReason, EventMessage, RpcConnection, RpcConnectionClosed, }, - control::{Member, MemberId, MemberSpec, RoomSpec}, + control::{Member, MemberId, MemberSpec, RoomSpec, TryFromElementError}, }, log::prelude::*, signalling::{ @@ -55,32 +55,32 @@ pub struct ParticipantService { } impl ParticipantService { - pub fn new(room_spec: &RoomSpec, reconnect_timeout: Duration) -> Self { - let members = room_spec - .spec - .pipeline - .iter() - .map(|(control_id, element)| { - let member_spec = - MemberSpec::try_from(element.clone()).unwrap(); - - ( - MemberId(control_id.clone()), - Member { - id: MemberId(control_id.clone()), - spec: Arc::new(member_spec), - }, - ) - }) - .collect(); - debug!("Created room with {:?} users.", members); - - Self { + /// Create new [`ParticipantService`] from [`RoomSpec`]. + pub fn new(room_spec: &RoomSpec, reconnect_timeout: Duration) -> Result { + let mut members = HashMap::new(); + for (control_id, element) in &room_spec.spec.pipeline { + let member_spec = + MemberSpec::try_from(element.clone())?; + let member_id = MemberId(control_id.clone()); + + members.insert( + member_id.clone(), + Member { + receivers: room_spec.get_receivers_for_member(&member_id)?, + id: member_id, + spec: Arc::new(member_spec), + }, + ); + } + + debug!("Created room with {:?} members.", members); + + Ok(Self { members, connections: HashMap::new(), reconnect_timeout, drop_connection_tasks: HashMap::new(), - } + }) } /// Lookup [`Member`] by provided id. diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 6f242aada..9151bf775 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -71,12 +71,6 @@ pub struct Room { /// [`Peer`]s of [`Member`]s in this [`Room`]. peers: PeerRepository, - - /// Stores [`MemberId`]s of all sender's receivers. - /// - /// __Key__ is sender's [`MemberId`]. - /// __Value__ is all sender's receivers. - sender_receivers: HashMap>, } impl Room { @@ -91,8 +85,7 @@ impl Room { Ok(Self { id: room_spec.id.clone(), peers: PeerRepository::from(HashMap::new()), - participants: ParticipantService::new(room_spec, reconnect_timeout), - sender_receivers: room_spec.get_sender_receivers()?, + participants: ParticipantService::new(room_spec, reconnect_timeout)?, }) } @@ -290,22 +283,20 @@ impl Room { // connect receivers let mut already_connected_members = Vec::new(); - if let Some(receivers) = self.sender_receivers.get(member_id) { - for recv_member_id in receivers { - if self.participants.member_has_connection(recv_member_id) { - if let Some(recv_member) = - self.participants.get_member_by_id(recv_member_id) - { - already_connected_members.push(recv_member_id.clone()); - need_create.push((&member, recv_member.clone())); - } else { - error!( - "Try to create peer for nonexistent member with \ - ID {}. Room will be stopped.", - recv_member_id - ); - ctx.notify(CloseRoom {}); - } + for recv_member_id in &member.receivers { + if self.participants.member_has_connection(recv_member_id) { + if let Some(recv_member) = + self.participants.get_member_by_id(recv_member_id) + { + already_connected_members.push(recv_member_id.clone()); + need_create.push((&member, recv_member.clone())); + } else { + error!( + "Try to create peer for nonexistent member with \ + ID {}. Room will be stopped.", + recv_member_id + ); + ctx.notify(CloseRoom {}); } } } From b11689079cb91572dd7ce09baa1ff0a02c083b30 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 4 Jun 2019 18:04:37 +0300 Subject: [PATCH 082/735] Fix make test command --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index fc5961bab..de1f1a51c 100644 --- a/Makefile +++ b/Makefile @@ -136,7 +136,7 @@ ifeq ($(test-unit-crate),@all) @make test.unit crate=jason else ifeq ($(test-unit-crate),medea) - cargo test --bin medea + cargo test -p medea else ifeq ($(test-unit-crate),jason) wasm-pack test --headless --firefox jason From 17cef143cd24899251f9749b498489102675adc4 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 4 Jun 2019 18:32:29 +0300 Subject: [PATCH 083/735] Add test and small refactoring --- src/api/control/endpoint.rs | 2 +- src/api/control/room.rs | 73 ++++++++++++++++++++++++++++++++-- src/signalling/participants.rs | 15 ++++--- src/signalling/room.rs | 17 ++++---- 4 files changed, 91 insertions(+), 16 deletions(-) diff --git a/src/api/control/endpoint.rs b/src/api/control/endpoint.rs index 5fe1632a6..0a4a5ef47 100644 --- a/src/api/control/endpoint.rs +++ b/src/api/control/endpoint.rs @@ -160,7 +160,7 @@ impl<'de> Deserialize<'de> for LocalUri { } #[cfg(test)] -mod test { +mod tests { use serde::Deserialize; use super::*; diff --git a/src/api/control/room.rs b/src/api/control/room.rs index 302d5e53f..74cb84308 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -4,8 +4,8 @@ use serde::Deserialize; use std::convert::TryFrom; use super::{ - member::MemberSpec, pipeline::Pipeline, Element, - MemberId, TryFromElementError, + member::MemberSpec, pipeline::Pipeline, Element, MemberId, + TryFromElementError, }; /// ID of [`Room`]. @@ -37,7 +37,10 @@ impl RoomSpec { } /// Get all receivers of all [`Member`]'s [`WebRtcPublishEndpoint`]s. - pub fn get_receivers_for_member(&self, id: &MemberId) -> Result, TryFromElementError> { + pub fn get_receivers_for_member( + &self, + id: &MemberId, + ) -> Result, TryFromElementError> { let mut receivers = Vec::new(); for (member_id, member_element) in &self.spec.pipeline { let member = MemberSpec::try_from(member_element.clone())?; @@ -62,3 +65,67 @@ impl TryFrom for RoomSpec { } } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn should_properly_get_receivers_for_member() { + let spec = r#" + kind: Room + id: test-call + spec: + pipeline: + caller: + kind: Member + credentials: test + spec: + pipeline: + publish: + kind: WebRtcPublishEndpoint + spec: + p2p: Always + some-member: + kind: Member + credentials: test + spec: + pipeline: + publish: + kind: WebRtcPublishEndpoint + spec: + p2p: Always + responder: + kind: Member + credentials: test + spec: + pipeline: + play: + kind: WebRtcPlayEndpoint + spec: + src: "local://test-call/caller/publish" + play2: + kind: WebRtcPlayEndpoint + spec: + src: "local://test-call/some-member/publish" + "#; + let spec: Element = serde_yaml::from_str(spec).unwrap(); + let room = RoomSpec::try_from(spec).unwrap(); + + let caller_member_id = MemberId("caller".to_string()); + let responder_member_id = MemberId("responder".to_string()); + let some_member_id = MemberId("some-member".to_string()); + + let caller_receivers = + room.get_receivers_for_member(&caller_member_id).unwrap(); + assert_eq!(caller_receivers, vec![responder_member_id.clone()]); + + let responder_receivers = + room.get_receivers_for_member(&responder_member_id).unwrap(); + assert_eq!(responder_receivers, vec![]); + + let some_member_receivers = + room.get_receivers_for_member(&some_member_id).unwrap(); + assert_eq!(some_member_receivers, vec![responder_member_id.clone()]); + } +} diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 3c3b59835..f9c58a6d1 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -22,7 +22,9 @@ use crate::{ AuthorizationError, ClosedReason, EventMessage, RpcConnection, RpcConnectionClosed, }, - control::{Member, MemberId, MemberSpec, RoomSpec, TryFromElementError}, + control::{ + Member, MemberId, MemberSpec, RoomSpec, TryFromElementError, + }, }, log::prelude::*, signalling::{ @@ -56,17 +58,20 @@ pub struct ParticipantService { impl ParticipantService { /// Create new [`ParticipantService`] from [`RoomSpec`]. - pub fn new(room_spec: &RoomSpec, reconnect_timeout: Duration) -> Result { + pub fn new( + room_spec: &RoomSpec, + reconnect_timeout: Duration, + ) -> Result { let mut members = HashMap::new(); for (control_id, element) in &room_spec.spec.pipeline { - let member_spec = - MemberSpec::try_from(element.clone())?; + let member_spec = MemberSpec::try_from(element.clone())?; let member_id = MemberId(control_id.clone()); members.insert( member_id.clone(), Member { - receivers: room_spec.get_receivers_for_member(&member_id)?, + receivers: room_spec + .get_receivers_for_member(&member_id)?, id: member_id, spec: Arc::new(member_spec), }, diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 9151bf775..5ade4ac9a 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -85,7 +85,10 @@ impl Room { Ok(Self { id: room_spec.id.clone(), peers: PeerRepository::from(HashMap::new()), - participants: ParticipantService::new(room_spec, reconnect_timeout)?, + participants: ParticipantService::new( + room_spec, + reconnect_timeout, + )?, }) } @@ -244,15 +247,15 @@ impl Room { ctx: &mut ::Context, ) { for p in to_create { - let caller = p.0; - let responder = p.1; + let first_member = p.0; + let second_member = p.1; debug!( "Created peer member {} with member {}", - caller.id, responder.id + first_member.id, second_member.id ); let (caller_peer_id, responder_peer_id) = - self.peers.create_peers(caller, &responder); + self.peers.create_peers(first_member, &second_member); ctx.notify(ConnectPeers(caller_peer_id, responder_peer_id)); @@ -292,8 +295,8 @@ impl Room { need_create.push((&member, recv_member.clone())); } else { error!( - "Try to create peer for nonexistent member with \ - ID {}. Room will be stopped.", + "Try to create peer for nonexistent member with ID \ + {}. Room will be stopped.", recv_member_id ); ctx.notify(CloseRoom {}); From e501ad8cb93dafc63adc4308e84f791afbd9d90b Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 4 Jun 2019 19:13:51 +0300 Subject: [PATCH 084/735] Refactor --- proto/client-api/src/lib.rs | 2 -- src/api/control/endpoint.rs | 36 +++++++++++------------- src/api/control/member.rs | 14 ++------- src/api/control/room.rs | 14 --------- src/signalling/peers.rs | 4 +-- tests/signalling.rs | 10 +++---- tests/specs/pub_sub_video_call.yml | 4 --- tests/specs/three_members_conference.yml | 22 ++++++--------- 8 files changed, 34 insertions(+), 72 deletions(-) diff --git a/proto/client-api/src/lib.rs b/proto/client-api/src/lib.rs index 714d201b9..2be593c54 100644 --- a/proto/client-api/src/lib.rs +++ b/proto/client-api/src/lib.rs @@ -1,7 +1,5 @@ use serde::{de::Deserializer, ser::Serializer, Deserialize, Serialize}; -// TODO: Deal with #[cfg_attr(test, ...)] when running e2e tests. - // TODO: should be properly shared between medea and jason #[cfg_attr(test, derive(PartialEq, Debug))] #[allow(dead_code)] diff --git a/src/api/control/endpoint.rs b/src/api/control/endpoint.rs index 0a4a5ef47..1289a5680 100644 --- a/src/api/control/endpoint.rs +++ b/src/api/control/endpoint.rs @@ -3,14 +3,13 @@ use std::{convert::TryFrom, fmt}; use serde::{ - de::{self, Deserializer, Error, Visitor}, + de::{self, Deserializer, Error, Unexpected, Visitor}, Deserialize, }; use crate::api::control::MemberId; use super::{Element, TryFromElementError}; -use serde::de::Unexpected; /// [`Endpoint`] represents a media element that one or more media data streams /// flow through. @@ -56,24 +55,23 @@ pub struct WebRtcPublishEndpoint { #[allow(clippy::module_name_repetitions)] #[derive(Clone, Deserialize, Debug)] pub struct WebRtcPlayEndpoint { - /// Source URI in format `local://{room_id}/{member_id}/{pipeline_id}`. + /// Source URI in format `local://{room_id}/{member_id}/{endpoint_id}`. pub src: LocalUri, } -/// Special uri with pattern `local://{room_id}/{member_id}/{pipeline_id}`. +/// Special uri with pattern `local://{room_id}/{member_id}/{endpoint_id}`. #[derive(Clone, Debug)] pub struct LocalUri { /// ID of [`Room`] - // TODO: Why this field never used??? pub room_id: String, /// ID of [`Member`] pub member_id: MemberId, /// Control ID of [`Endpoint`] - pub pipeline_id: String, + pub endpoint_id: String, } /// Serde deserializer for [`LocalUri`]. -/// Deserialize URIs with pattern `local://{room_id}/{member_id}/{pipeline_id}`. +/// Deserialize URIs with pattern `local://{room_id}/{member_id}/{endpoint_id}`. impl<'de> Deserialize<'de> for LocalUri { fn deserialize(deserializer: D) -> Result where @@ -86,7 +84,7 @@ impl<'de> Deserialize<'de> for LocalUri { fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { formatter.write_str( - "Uri in format local://room_id/member_id/pipeline_id", + "Uri in format local://room_id/member_id/endpoint_id", ) } @@ -111,11 +109,11 @@ impl<'de> Deserialize<'de> for LocalUri { let uri_body_splitted_len = uri_body_splitted.len(); if uri_body_splitted_len != 3 { let error_msg = if uri_body_splitted_len == 0 { - "room_id, member_id, pipeline_id" + "room_id, member_id, endpoint_id" } else if uri_body_splitted_len == 1 { - "member_id, pipeline_id" + "member_id, endpoint_id" } else if uri_body_splitted_len == 2 { - "pipeline_id" + "endpoint_id" } else { return Err(Error::custom(format!( "Too many fields: {}. Expecting 3 fields, found \ @@ -139,10 +137,10 @@ impl<'de> Deserialize<'de> for LocalUri { value ))); } - let pipeline_id = uri_body_splitted.pop().unwrap().to_string(); - if pipeline_id.is_empty() { + let endpoint_id = uri_body_splitted.pop().unwrap().to_string(); + if endpoint_id.is_empty() { return Err(Error::custom(format!( - "pipeline_id in {} is empty!", + "endpoint_id in {} is empty!", value ))); } @@ -150,7 +148,7 @@ impl<'de> Deserialize<'de> for LocalUri { Ok(LocalUri { room_id, member_id: MemberId(member_id), - pipeline_id, + endpoint_id, }) } } @@ -173,7 +171,7 @@ mod tests { #[test] fn should_parse_local_uri() { let valid_json_uri = - r#"{ "src": "local://room_id/member_id/pipeline_id" }"#; + r#"{ "src": "local://room_id/member_id/endpoint_id" }"#; let local_uri: LocalUriTest = serde_json::from_str(valid_json_uri).unwrap(); @@ -182,13 +180,13 @@ mod tests { MemberId(String::from("member_id")) ); assert_eq!(local_uri.src.room_id, String::from("room_id")); - assert_eq!(local_uri.src.pipeline_id, String::from("pipeline_id")); + assert_eq!(local_uri.src.endpoint_id, String::from("endpoint_id")); } #[test] fn should_return_error_when_uri_not_local() { let invalid_json_uri = - r#"{ "src": "not_local://room_id/member_id/pipeline_id" }"#; + r#"{ "src": "not_local://room_id/member_id/endpoint_id" }"#; match serde_json::from_str::(invalid_json_uri) { Ok(_) => assert!(false), Err(_) => assert!(true), @@ -206,7 +204,7 @@ mod tests { #[test] fn should_return_error_when_uri_have_empty_part() { - let invalid_json_uri = r#"{ "src": "local://room_id//pipeline_id" }"#; + let invalid_json_uri = r#"{ "src": "local://room_id//endpoint_id" }"#; match serde_json::from_str::(invalid_json_uri) { Ok(_) => assert!(false), Err(_) => assert!(true), diff --git a/src/api/control/member.rs b/src/api/control/member.rs index 0bdd65360..d3c7243ac 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -4,9 +4,7 @@ use std::{convert::TryFrom, fmt::Display, sync::Arc}; use serde::Deserialize; -use super::{ - endpoint::Endpoint, pipeline::Pipeline, Element, TryFromElementError, -}; +use super::{pipeline::Pipeline, Element, TryFromElementError}; use crate::api::control::endpoint::{ WebRtcPlayEndpoint, WebRtcPublishEndpoint, @@ -22,7 +20,7 @@ impl Display for Id { } } -/// Media server user with its ID and credentials. +/// Media server user with its ID, credentials and spec. #[derive(Clone, Debug)] pub struct Member { /// ID of [`Member`]. @@ -47,14 +45,6 @@ pub struct MemberSpec { } impl MemberSpec { - /// Get [`Endpoint`] of this [`MemberSpec`] by ID. - pub fn get_endpoint_by_id( - &self, - id: &str, - ) -> Option> { - Some(Endpoint::try_from(self.spec.pipeline.get(id).cloned()?)) - } - /// Get all [`WebRtcPlayEndpoint`]s of this [`MemberSpec`]. pub fn play_endpoints(&self) -> Vec<&WebRtcPlayEndpoint> { self.spec diff --git a/src/api/control/room.rs b/src/api/control/room.rs index 74cb84308..ca713394d 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -22,20 +22,6 @@ pub struct RoomSpec { } impl RoomSpec { - /// Try to find [`MemberSpec`] by ID. - /// - /// Return `None` if [`MemberSpec`] not presented in [`RoomSpec`]. - /// Return `Some(TryFromElementError::NotMember)` if element with this ID - /// finded but its not [`MemberSpec`]. - pub fn get_member( - &self, - id: &MemberId, - ) -> Option> { - Some(MemberSpec::try_from( - self.spec.pipeline.get(&id.0).cloned()?, - )) - } - /// Get all receivers of all [`Member`]'s [`WebRtcPublishEndpoint`]s. pub fn get_receivers_for_member( &self, diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index 421fb7c16..041910939 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -105,9 +105,7 @@ impl PeerRepository { } } - /// Returns [`Peer`] of specified [`Member`]. - /// - /// Panic if [`Peer`] not exists. + /// Returns all [`Peer`]s of specified [`Member`]. pub fn get_peers_by_member_id( &self, member_id: &MemberId, diff --git a/tests/signalling.rs b/tests/signalling.rs index fa43c8eb0..c194b8179 100644 --- a/tests/signalling.rs +++ b/tests/signalling.rs @@ -157,7 +157,7 @@ impl StreamHandler for TestMember { /// /// Don't forget register your test in [`test_ports`], otherwise the server /// will just panic. -fn run_test_server(test_name: &str) -> u16 { +fn run_test_server(test_name: &'static str) -> u16 { let bind_port = test_ports::get_port_for_test(test_name); let is_server_starting = Arc::new(Mutex::new(Cell::new(true))); @@ -166,7 +166,7 @@ fn run_test_server(test_name: &str) -> u16 { let server_thread = builder .spawn(move || { - let _sys = System::new("medea"); + let _ = System::new(format!("test-medea-server-{}", test_name)); let config = Conf { server: Server { @@ -367,15 +367,15 @@ fn should_work_three_members_p2p_video_call() { }; TestMember::start( - &format!("{}/caller/test", base_url), + &format!("{}/member-1/test", base_url), Box::new(test_fn.clone()), ); TestMember::start( - &format!("{}/responder/test", base_url), + &format!("{}/member-2/test", base_url), Box::new(test_fn.clone()), ); TestMember::start( - &format!("{}/responder2/test", base_url), + &format!("{}/member-3/test", base_url), Box::new(test_fn), ); diff --git a/tests/specs/pub_sub_video_call.yml b/tests/specs/pub_sub_video_call.yml index bf8af54e4..171f34559 100644 --- a/tests/specs/pub_sub_video_call.yml +++ b/tests/specs/pub_sub_video_call.yml @@ -2,19 +2,15 @@ kind: Room id: pub-sub-video-call spec: pipeline: - # Here we're defining a member who initiates video call. caller: kind: Member credentials: test spec: pipeline: - # Media element which is able to receive media data from client via WebRTC. publish: kind: WebRtcPublishEndpoint spec: - # Actually, it receives not media data, but ICE candidates only. p2p: Always - # Media element which is able to play media data for client via WebRTC. responder: kind: Member credentials: test diff --git a/tests/specs/three_members_conference.yml b/tests/specs/three_members_conference.yml index b2bc33080..8a638c5d0 100644 --- a/tests/specs/three_members_conference.yml +++ b/tests/specs/three_members_conference.yml @@ -2,28 +2,24 @@ kind: Room id: three-members-conference spec: pipeline: - # Here we're defining a member who initiates video call. - caller: + member-1: kind: Member credentials: test spec: pipeline: - # Media element which is able to receive media data from client via WebRTC. publish: kind: WebRtcPublishEndpoint spec: - # Actually, it receives not media data, but ICE candidates only. p2p: Always - # Media element which is able to play media data for client via WebRTC. play: kind: WebRtcPlayEndpoint spec: - src: "local://video-call-3/responder/publish" + src: "local://three-members-conference/member-2/publish" play2: kind: WebRtcPlayEndpoint spec: - src: "local://video-call-3/responder2/publish" - responder: + src: "local://three-members-conference/member-3/publish" + member-2: kind: Member credentials: test spec: @@ -35,13 +31,13 @@ spec: play1: kind: WebRtcPlayEndpoint spec: - src: "local://video-call-3/caller/publish" + src: "local://three-members-conference/member-1/publish" play2: kind: WebRtcPlayEndpoint spec: - src: "local://video-call-3/responder2/publish" + src: "local://three-members-conference/member-3/publish" - responder2: + member-3: kind: Member credentials: test spec: @@ -53,8 +49,8 @@ spec: play1: kind: WebRtcPlayEndpoint spec: - src: "local://video-call-3/caller/publish" + src: "local://three-members-conference/member-2/publish" play2: kind: WebRtcPlayEndpoint spec: - src: "local://video-call-3/responder/publish" + src: "local://three-members-conference/member-1/publish" From c1f405289351d86d4e10c52c9214b29a10f2997f Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 5 Jun 2019 14:20:11 +0300 Subject: [PATCH 085/735] Small tests refactoring --- src/api/control/endpoint.rs | 10 +++++----- tests/signalling.rs | 8 ++++---- tests/test_ports.rs | 5 +---- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/api/control/endpoint.rs b/src/api/control/endpoint.rs index 1289a5680..ebf2d376a 100644 --- a/src/api/control/endpoint.rs +++ b/src/api/control/endpoint.rs @@ -158,7 +158,7 @@ impl<'de> Deserialize<'de> for LocalUri { } #[cfg(test)] -mod tests { +mod local_uri_deserialization_tests { use serde::Deserialize; use super::*; @@ -169,7 +169,7 @@ mod tests { } #[test] - fn should_parse_local_uri() { + fn deserialize() { let valid_json_uri = r#"{ "src": "local://room_id/member_id/endpoint_id" }"#; let local_uri: LocalUriTest = @@ -184,7 +184,7 @@ mod tests { } #[test] - fn should_return_error_when_uri_not_local() { + fn return_error_when_uri_not_local() { let invalid_json_uri = r#"{ "src": "not_local://room_id/member_id/endpoint_id" }"#; match serde_json::from_str::(invalid_json_uri) { @@ -194,7 +194,7 @@ mod tests { } #[test] - fn should_return_error_when_uri_is_not_full() { + fn return_error_when_uri_is_not_full() { let invalid_json_uri = r#"{ "src": "local://room_id/member_id" }"#; match serde_json::from_str::(invalid_json_uri) { Ok(_) => assert!(false), @@ -203,7 +203,7 @@ mod tests { } #[test] - fn should_return_error_when_uri_have_empty_part() { + fn return_error_when_uri_have_empty_part() { let invalid_json_uri = r#"{ "src": "local://room_id//endpoint_id" }"#; match serde_json::from_str::(invalid_json_uri) { Ok(_) => assert!(false), diff --git a/tests/signalling.rs b/tests/signalling.rs index c194b8179..1876fea65 100644 --- a/tests/signalling.rs +++ b/tests/signalling.rs @@ -201,8 +201,8 @@ fn run_test_server(test_name: &'static str) -> u16 { } #[test] -fn should_work_pub_sub_video_call() { - let test_name = "should_work_pub_sub_video_call"; +fn pub_sub_video_call() { + let test_name = "pub_sub_video_call"; let bind_port = run_test_server(test_name); let base_url = format!("ws://localhost:{}/ws/pub-sub-video-call", bind_port); @@ -291,8 +291,8 @@ fn should_work_pub_sub_video_call() { } #[test] -fn should_work_three_members_p2p_video_call() { - let test_name = "should_work_three_members_p2p_video_call"; +fn three_members_p2p_video_call() { + let test_name = "three_members_p2p_video_call"; let bind_port = run_test_server(test_name); let base_url = format!("ws://localhost:{}/ws/three-members-conference", bind_port); diff --git a/tests/test_ports.rs b/tests/test_ports.rs index 600afabac..4c1c6b34c 100644 --- a/tests/test_ports.rs +++ b/tests/test_ports.rs @@ -31,10 +31,7 @@ macro_rules! generate_ports_for_tests { } // Register your test by adding test name into this macro call. -generate_ports_for_tests!( - should_work_three_members_p2p_video_call, - should_work_pub_sub_video_call, -); +generate_ports_for_tests!(three_members_p2p_video_call, pub_sub_video_call,); /// Use it for easy get port by declared before name. /// From 20e15ce3d8319b66b1b3d712732c48b0b2147522 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 6 Jun 2019 16:35:28 +0300 Subject: [PATCH 086/735] Refactor main --- src/main.rs | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/src/main.rs b/src/main.rs index 854622a1a..de26a57d2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,5 @@ use actix::System; +use failure::Error; use medea::{ api::client::server, conf::Conf, @@ -7,31 +8,26 @@ use medea::{ start_static_rooms, }; -fn main() { +fn main() -> Result<(), Error> { dotenv::dotenv().ok(); let logger = log::new_dual_logger(std::io::stdout(), std::io::stderr()); let _scope_guard = slog_scope::set_global_logger(logger); - slog_stdlog::init().unwrap(); + slog_stdlog::init()?; let sys = System::new("medea"); - let config = Conf::parse().unwrap(); + let config = Conf::parse()?; info!("{:?}", config); - match start_static_rooms(&config) { - Ok(r) => { - info!( - "Loaded rooms: {:?}", - r.iter().map(|(id, _)| &id.0).collect::>() - ); - let room_repo = RoomsRepository::new(r); - server::run(room_repo, config); - } - Err(e) => { - error!("Server not started because of error: '{}'", e); - System::current().stop_with_code(100); - } - }; + let rooms = start_static_rooms(&config)?; + info!( + "Loaded rooms: {:?}", + rooms.iter().map(|(id, _)| &id.0).collect::>() + ); + let room_repo = RoomsRepository::new(rooms); + server::run(room_repo, config); let _ = sys.run(); + + Ok(()) } From 999b8287d2c9e0e9129792df62ee0bb4c4593831 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 6 Jun 2019 16:49:37 +0300 Subject: [PATCH 087/735] Add counter in peers --- src/media/peer.rs | 13 +++++++------ src/signalling/peers.rs | 39 ++++++++++++++++++++++++++++++--------- 2 files changed, 37 insertions(+), 15 deletions(-) diff --git a/src/media/peer.rs b/src/media/peer.rs index cb3883bfd..da1e9fbc3 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -18,6 +18,7 @@ use crate::{ MemberId, }, media::{MediaTrack, TrackId}, + signalling::peers::Counter, }; /// Newly initialized [`Peer`] ready to signalling. @@ -252,21 +253,21 @@ impl Peer { /// Add all [`WebRtcPublishEndpoint`]s to this [`Peer`]. /// - /// This use `last_track_id` counter for generating new [`MediaTrack`] ID. + /// This use `track_id_counter` counter for generating new [`MediaTrack`] + /// ID. pub fn add_publish_endpoints( &mut self, endpoints: Vec<&WebRtcPublishEndpoint>, - last_track_id: &mut u64, + track_id_counter: &mut Counter, ) { + // TODO: &mut track_id_counter looks bad for _ in endpoints { - *last_track_id += 1; let track_audio = Arc::new(MediaTrack::new( - *last_track_id, + track_id_counter.next_id(), MediaType::Audio(AudioSettings {}), )); - *last_track_id += 1; let track_video = Arc::new(MediaTrack::new( - *last_track_id, + track_id_counter.next_id(), MediaType::Video(VideoSettings {}), )); diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index 041910939..06443c381 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -2,7 +2,10 @@ use hashbrown::HashMap; -use std::convert::{TryFrom, TryInto}; +use std::{ + convert::{TryFrom, TryInto}, + fmt, +}; use crate::{ api::control::{Member, MemberId}, @@ -16,10 +19,30 @@ pub struct PeerRepository { peers: HashMap, /// Count of [`Peer`]s in this [`Room`]. - peers_count: u64, + peers_count: Counter, /// Count of [`MediaTrack`]s in this [`Room`]. - tracks_count: u64, + tracks_count: Counter, +} + +#[derive(Default)] +pub struct Counter { + count: u64, +} + +impl Counter { + pub fn next_id(&mut self) -> u64 { + let id = self.count; + self.count += 1; + + id + } +} + +impl fmt::Debug for Counter { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}", self.count) + } } impl PeerRepository { @@ -46,10 +69,8 @@ impl PeerRepository { first_member: &Member, second_member: &Member, ) -> (u64, u64) { - self.peers_count += 1; - let first_peer_id = self.peers_count; - self.peers_count += 1; - let second_peer_id = self.peers_count; + let first_peer_id = self.peers_count.next_id(); + let second_peer_id = self.peers_count.next_id(); let mut first_peer = Peer::new( first_peer_id, @@ -162,8 +183,8 @@ impl From> for PeerRepository { fn from(map: HashMap) -> Self { Self { peers: map, - peers_count: 0, - tracks_count: 0, + peers_count: Counter::default(), + tracks_count: Counter::default(), } } } From 5b249c69feeafbcd5fd34b03d527ce07a32d7c98 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 6 Jun 2019 16:52:39 +0300 Subject: [PATCH 088/735] Rename LocalUri into SrcUri --- src/api/control/endpoint.rs | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/api/control/endpoint.rs b/src/api/control/endpoint.rs index ebf2d376a..3374e9e32 100644 --- a/src/api/control/endpoint.rs +++ b/src/api/control/endpoint.rs @@ -56,12 +56,12 @@ pub struct WebRtcPublishEndpoint { #[derive(Clone, Deserialize, Debug)] pub struct WebRtcPlayEndpoint { /// Source URI in format `local://{room_id}/{member_id}/{endpoint_id}`. - pub src: LocalUri, + pub src: SrcUri, } /// Special uri with pattern `local://{room_id}/{member_id}/{endpoint_id}`. #[derive(Clone, Debug)] -pub struct LocalUri { +pub struct SrcUri { /// ID of [`Room`] pub room_id: String, /// ID of [`Member`] @@ -70,17 +70,17 @@ pub struct LocalUri { pub endpoint_id: String, } -/// Serde deserializer for [`LocalUri`]. +/// Serde deserializer for [`SrcUri`]. /// Deserialize URIs with pattern `local://{room_id}/{member_id}/{endpoint_id}`. -impl<'de> Deserialize<'de> for LocalUri { +impl<'de> Deserialize<'de> for SrcUri { fn deserialize(deserializer: D) -> Result where D: Deserializer<'de>, { - struct LocalUriVisitor; + struct SrcUriVisitor; - impl<'de> Visitor<'de> for LocalUriVisitor { - type Value = LocalUri; + impl<'de> Visitor<'de> for SrcUriVisitor { + type Value = SrcUri; fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { formatter.write_str( @@ -88,7 +88,7 @@ impl<'de> Deserialize<'de> for LocalUri { ) } - fn visit_str(self, value: &str) -> Result + fn visit_str(self, value: &str) -> Result where E: de::Error, { @@ -145,7 +145,7 @@ impl<'de> Deserialize<'de> for LocalUri { ))); } - Ok(LocalUri { + Ok(SrcUri { room_id, member_id: MemberId(member_id), endpoint_id, @@ -153,26 +153,26 @@ impl<'de> Deserialize<'de> for LocalUri { } } - deserializer.deserialize_identifier(LocalUriVisitor) + deserializer.deserialize_identifier(SrcUriVisitor) } } #[cfg(test)] -mod local_uri_deserialization_tests { +mod src_uri_deserialization_tests { use serde::Deserialize; use super::*; #[derive(Deserialize)] - struct LocalUriTest { - src: LocalUri, + struct SrcUriTest { + src: SrcUri, } #[test] fn deserialize() { let valid_json_uri = r#"{ "src": "local://room_id/member_id/endpoint_id" }"#; - let local_uri: LocalUriTest = + let local_uri: SrcUriTest = serde_json::from_str(valid_json_uri).unwrap(); assert_eq!( @@ -187,7 +187,7 @@ mod local_uri_deserialization_tests { fn return_error_when_uri_not_local() { let invalid_json_uri = r#"{ "src": "not_local://room_id/member_id/endpoint_id" }"#; - match serde_json::from_str::(invalid_json_uri) { + match serde_json::from_str::(invalid_json_uri) { Ok(_) => assert!(false), Err(_) => assert!(true), } @@ -196,7 +196,7 @@ mod local_uri_deserialization_tests { #[test] fn return_error_when_uri_is_not_full() { let invalid_json_uri = r#"{ "src": "local://room_id/member_id" }"#; - match serde_json::from_str::(invalid_json_uri) { + match serde_json::from_str::(invalid_json_uri) { Ok(_) => assert!(false), Err(_) => assert!(true), } @@ -205,7 +205,7 @@ mod local_uri_deserialization_tests { #[test] fn return_error_when_uri_have_empty_part() { let invalid_json_uri = r#"{ "src": "local://room_id//endpoint_id" }"#; - match serde_json::from_str::(invalid_json_uri) { + match serde_json::from_str::(invalid_json_uri) { Ok(_) => assert!(false), Err(_) => assert!(true), } From cb3bd6ebf52d6481b9a9b56c37cfae3e44224fa7 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 6 Jun 2019 16:54:29 +0300 Subject: [PATCH 089/735] Tests rename --- src/api/control/room.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/api/control/room.rs b/src/api/control/room.rs index ca713394d..5472e6e07 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -53,11 +53,11 @@ impl TryFrom for RoomSpec { } #[cfg(test)] -mod tests { +mod room_spec_tests { use super::*; #[test] - fn should_properly_get_receivers_for_member() { + fn properly_get_receivers_for_member() { let spec = r#" kind: Room id: test-call From ce98300f286268bbcc713b0f86714ffae012eb8a Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 6 Jun 2019 16:58:39 +0300 Subject: [PATCH 090/735] Add derive Debug to Counter --- src/signalling/peers.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index 06443c381..cdc5a0ee7 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -25,7 +25,7 @@ pub struct PeerRepository { tracks_count: Counter, } -#[derive(Default)] +#[derive(Default, Debug)] pub struct Counter { count: u64, } @@ -39,7 +39,7 @@ impl Counter { } } -impl fmt::Debug for Counter { +impl fmt::Display for Counter { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", self.count) } From a36910f1bf2803549df5c0048a8bd62a1553b2e3 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 6 Jun 2019 17:16:38 +0300 Subject: [PATCH 091/735] Make member fields - private --- src/api/control/member.rs | 58 ++++++++++++++++++++++++++++++---- src/signalling/participants.rs | 10 ++---- src/signalling/peers.rs | 16 +++++----- src/signalling/room.rs | 7 ++-- 4 files changed, 65 insertions(+), 26 deletions(-) diff --git a/src/api/control/member.rs b/src/api/control/member.rs index d3c7243ac..550c9c0cf 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -4,10 +4,15 @@ use std::{convert::TryFrom, fmt::Display, sync::Arc}; use serde::Deserialize; -use super::{pipeline::Pipeline, Element, TryFromElementError}; - -use crate::api::control::endpoint::{ - WebRtcPlayEndpoint, WebRtcPublishEndpoint, +use super::{ + pipeline::Pipeline, + room::RoomSpec, + Element, + TryFromElementError, + endpoint::{ + WebRtcPublishEndpoint, + WebRtcPlayEndpoint, + } }; /// ID of [`Member`]. @@ -24,13 +29,52 @@ impl Display for Id { #[derive(Clone, Debug)] pub struct Member { /// ID of [`Member`]. - pub id: Id, + id: Id, /// Control API specification of this [`Member`]. - pub spec: Arc, + spec: Arc, /// Receivers of this [`Member`]'s publish endpoints. - pub receivers: Vec, + receivers: Vec, +} + +impl Member { + pub fn new( + id: Id, + spec: MemberSpec, + room_spec: &RoomSpec, + ) -> Result { + Ok(Self { + receivers: room_spec.get_receivers_for_member(&id)?, + spec: Arc::new(spec), + id, + }) + } + + /// Returns [`Id`] of [`Member`]. + pub fn id(&self) -> &Id { + &self.id + } + + /// Returns credentials to authorize [`Member`] with. + pub fn credentials(&self) -> &String { + &self.spec.credentials + } + + /// Returns all [`WebRtcPlayEndpoint`]s of this [`Member`]. + pub fn play_endpoints(&self) -> Vec<&WebRtcPlayEndpoint> { + self.spec.play_endpoints() + } + + /// Returns all [`WebRtcPublishEndpoint`]s of this [`Member`]. + pub fn publish_endpoints(&self) -> Vec<&WebRtcPublishEndpoint> { + self.spec.publish_endpoints() + } + + /// Returns all receivers [`Id`] of this [`Member`]. + pub fn receivers(&self) -> &Vec { + &self.receivers + } } /// Newtype for [`Element::Member`] variant. diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index f9c58a6d1..164480b01 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -4,7 +4,6 @@ use std::{ convert::TryFrom, - sync::Arc, time::{Duration, Instant}, }; @@ -69,12 +68,7 @@ impl ParticipantService { members.insert( member_id.clone(), - Member { - receivers: room_spec - .get_receivers_for_member(&member_id)?, - id: member_id, - spec: Arc::new(member_spec), - }, + Member::new(member_id, member_spec, room_spec)?, ); } @@ -104,7 +98,7 @@ impl ParticipantService { ) -> Result<&Member, AuthorizationError> { match self.members.get(member_id) { Some(ref member) => { - if member.spec.credentials.eq(credentials) { + if member.credentials().eq(credentials) { Ok(member) } else { Err(AuthorizationError::InvalidCredentials) diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index cdc5a0ee7..2a2c31664 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -74,32 +74,32 @@ impl PeerRepository { let mut first_peer = Peer::new( first_peer_id, - first_member.id.clone(), + first_member.id().clone(), second_peer_id, - second_member.id.clone(), + second_member.id().clone(), ); let mut second_peer = Peer::new( second_peer_id, - second_member.id.clone(), + second_member.id().clone(), first_peer_id, - first_member.id.clone(), + first_member.id().clone(), ); first_peer.add_publish_endpoints( - first_member.spec.publish_endpoints(), + first_member.publish_endpoints(), &mut self.tracks_count, ); second_peer.add_publish_endpoints( - second_member.spec.publish_endpoints(), + second_member.publish_endpoints(), &mut self.tracks_count, ); first_peer.add_play_endpoints( - first_member.spec.play_endpoints(), + first_member.play_endpoints(), &mut second_peer, ); second_peer.add_play_endpoints( - second_member.spec.play_endpoints(), + second_member.play_endpoints(), &mut first_peer, ); diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 5ade4ac9a..0e438a803 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -251,7 +251,8 @@ impl Room { let second_member = p.1; debug!( "Created peer member {} with member {}", - first_member.id, second_member.id + first_member.id(), + second_member.id() ); let (caller_peer_id, responder_peer_id) = @@ -286,7 +287,7 @@ impl Room { // connect receivers let mut already_connected_members = Vec::new(); - for recv_member_id in &member.receivers { + for recv_member_id in member.receivers() { if self.participants.member_has_connection(recv_member_id) { if let Some(recv_member) = self.participants.get_member_by_id(recv_member_id) @@ -305,7 +306,7 @@ impl Room { } // connect senders - for play in member.spec.play_endpoints() { + for play in member.play_endpoints() { let sender_member_id = &play.src.member_id; if already_connected_members.contains(sender_member_id) { continue; From 4e0a92a009ca318a8a64067f2c99bbe45ad676a3 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 6 Jun 2019 17:56:25 +0300 Subject: [PATCH 092/735] Private pipeline --- src/api/control/member.rs | 49 +++++++++-------------- src/api/control/pipeline.rs | 71 +++++++++++++++++++++++++++++++++- src/api/control/room.rs | 33 ++++++++-------- src/lib.rs | 8 ++-- src/signalling/participants.rs | 20 ++-------- src/signalling/room.rs | 2 +- 6 files changed, 113 insertions(+), 70 deletions(-) diff --git a/src/api/control/member.rs b/src/api/control/member.rs index 550c9c0cf..d55b217a8 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -5,14 +5,10 @@ use std::{convert::TryFrom, fmt::Display, sync::Arc}; use serde::Deserialize; use super::{ + endpoint::{WebRtcPlayEndpoint, WebRtcPublishEndpoint}, pipeline::Pipeline, room::RoomSpec, - Element, - TryFromElementError, - endpoint::{ - WebRtcPublishEndpoint, - WebRtcPlayEndpoint, - } + Element, TryFromElementError, }; /// ID of [`Member`]. @@ -57,8 +53,8 @@ impl Member { } /// Returns credentials to authorize [`Member`] with. - pub fn credentials(&self) -> &String { - &self.spec.credentials + pub fn credentials(&self) -> &str { + self.spec.credentials() } /// Returns all [`WebRtcPlayEndpoint`]s of this [`Member`]. @@ -82,35 +78,25 @@ impl Member { #[derive(Clone, Debug)] pub struct MemberSpec { /// Spec of this [`Member`]. - pub spec: Pipeline, + pipeline: Pipeline, /// Credentials to authorize [`Member`] with. - pub credentials: String, + credentials: String, } impl MemberSpec { - /// Get all [`WebRtcPlayEndpoint`]s of this [`MemberSpec`]. + /// Returns all [`WebRtcPlayEndpoint`]s of this [`MemberSpec`]. pub fn play_endpoints(&self) -> Vec<&WebRtcPlayEndpoint> { - self.spec - .pipeline - .iter() - .filter_map(|(_, e)| match e { - Element::WebRtcPlayEndpoint { spec } => Some(spec), - _ => None, - }) - .collect() + self.pipeline.play_endpoints() } - /// Get all [`WebRtcPublishEndpoint`]s of this [`MemberSpec`]. + /// Returns all [`WebRtcPublishEndpoint`]s of this [`MemberSpec`]. pub fn publish_endpoints(&self) -> Vec<&WebRtcPublishEndpoint> { - self.spec - .pipeline - .iter() - .filter_map(|(_, e)| match e { - Element::WebRtcPublishEndpoint { spec } => Some(spec), - _ => None, - }) - .collect() + self.pipeline.publish_endpoints() + } + + pub fn credentials(&self) -> &str { + &self.credentials } } @@ -119,9 +105,10 @@ impl TryFrom for MemberSpec { fn try_from(from: Element) -> Result { match from { - Element::Member { spec, credentials } => { - Ok(Self { spec, credentials }) - } + Element::Member { spec, credentials } => Ok(Self { + pipeline: spec, + credentials, + }), _ => Err(TryFromElementError::NotMember), } } diff --git a/src/api/control/pipeline.rs b/src/api/control/pipeline.rs index fb0cdb16d..2f062c50d 100644 --- a/src/api/control/pipeline.rs +++ b/src/api/control/pipeline.rs @@ -1,13 +1,80 @@ //! Control API specification Pipeline definition. +use std::{collections::HashMap, convert::TryFrom as _}; + +use hashbrown::HashMap as HashBrownMap; use serde::Deserialize; -use std::collections::HashMap; +use super::{ + endpoint::{WebRtcPlayEndpoint, WebRtcPublishEndpoint}, + Member, MemberId, MemberSpec, RoomSpec, TryFromElementError, +}; use crate::api::control::Element; /// Entity that represents some pipeline of spec. #[derive(Clone, Deserialize, Debug)] pub struct Pipeline { - pub pipeline: HashMap, + pipeline: HashMap, +} + +impl Pipeline { + /// Get all [`WebRtcPlayEndpoint`]s from this [`Pipeline`]. + pub fn play_endpoints(&self) -> Vec<&WebRtcPlayEndpoint> { + self.pipeline + .iter() + .filter_map(|(_, e)| match e { + Element::WebRtcPlayEndpoint { spec } => Some(spec), + _ => None, + }) + .collect() + } + + /// Get all [`WebRtcPublishEndpoint`]s from this [`Pipeline`]. + pub fn publish_endpoints(&self) -> Vec<&WebRtcPublishEndpoint> { + self.pipeline + .iter() + .filter_map(|(_, e)| match e { + Element::WebRtcPublishEndpoint { spec } => Some(spec), + _ => None, + }) + .collect() + } + + /// Get all receivers of all [`Member`]'s [`WebRtcPublishEndpoint`]s. + pub fn get_receivers_for_member( + &self, + id: &MemberId, + ) -> Result, TryFromElementError> { + let mut receivers = Vec::new(); + for (member_id, member_element) in &self.pipeline { + let member = MemberSpec::try_from(member_element.clone())?; + for endpoint in member.play_endpoints() { + if &endpoint.src.member_id == id { + receivers.push(MemberId(member_id.clone())); + } + } + } + + Ok(receivers) + } + + /// Get all members from pipeline of [`RoomSpec`]. + pub fn members( + &self, + room_spec: &RoomSpec, + ) -> Result, TryFromElementError> { + let mut members = HashBrownMap::new(); + for (control_id, element) in &self.pipeline { + let member_spec = MemberSpec::try_from(element.clone())?; + let member_id = MemberId(control_id.clone()); + + members.insert( + member_id.clone(), + Member::new(member_id, member_spec, room_spec)?, + ); + } + + Ok(members) + } } diff --git a/src/api/control/room.rs b/src/api/control/room.rs index 5472e6e07..b610688fe 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -1,11 +1,12 @@ //! Room definitions and implementations. -use serde::Deserialize; use std::convert::TryFrom; +use hashbrown::HashMap; +use serde::Deserialize; + use super::{ - member::MemberSpec, pipeline::Pipeline, Element, MemberId, - TryFromElementError, + pipeline::Pipeline, Element, Member, MemberId, TryFromElementError, }; /// ID of [`Room`]. @@ -17,8 +18,8 @@ pub struct Id(pub String); #[allow(clippy::module_name_repetitions)] #[derive(Clone, Debug)] pub struct RoomSpec { - pub id: Id, - pub spec: Pipeline, + id: Id, + pipeline: Pipeline, } impl RoomSpec { @@ -27,17 +28,17 @@ impl RoomSpec { &self, id: &MemberId, ) -> Result, TryFromElementError> { - let mut receivers = Vec::new(); - for (member_id, member_element) in &self.spec.pipeline { - let member = MemberSpec::try_from(member_element.clone())?; - for endpoint in member.play_endpoints() { - if &endpoint.src.member_id == id { - receivers.push(MemberId(member_id.clone())); - } - } - } + self.pipeline.get_receivers_for_member(id) + } + + pub fn members( + &self, + ) -> Result, TryFromElementError> { + self.pipeline.members(self) + } - Ok(receivers) + pub fn id(&self) -> &Id { + &self.id } } @@ -46,7 +47,7 @@ impl TryFrom for RoomSpec { fn try_from(from: Element) -> Result { match from { - Element::Room { id, spec } => Ok(Self { id, spec }), + Element::Room { id, spec } => Ok(Self { id, pipeline: spec }), _ => Err(TryFromElementError::NotRoom), } } diff --git a/src/lib.rs b/src/lib.rs index 0353ee797..dcd5a1fb9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -67,13 +67,15 @@ pub fn start_static_rooms( let mut rooms = HashMap::new(); for spec in room_specs { - if rooms.contains_key(&spec.id) { - return Err(ServerStartError::DuplicateRoomId(spec.id)); + if rooms.contains_key(spec.id()) { + return Err(ServerStartError::DuplicateRoomId( + spec.id().clone(), + )); } let room = Room::new(&spec, config.rpc.reconnect_timeout)?; let room = Arbiter::start(move |_| room); - rooms.insert(spec.id, room); + rooms.insert(spec.id().clone(), room); } Ok(rooms) diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 164480b01..dc83b1a93 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -2,10 +2,7 @@ //! stores [`Members`] and associated [`RpcConnection`]s, handles //! [`RpcConnection`] authorization, establishment, message sending. -use std::{ - convert::TryFrom, - time::{Duration, Instant}, -}; +use std::time::{Duration, Instant}; use actix::{fut::wrap_future, AsyncContext, Context, SpawnHandle}; use futures::{ @@ -21,9 +18,7 @@ use crate::{ AuthorizationError, ClosedReason, EventMessage, RpcConnection, RpcConnectionClosed, }, - control::{ - Member, MemberId, MemberSpec, RoomSpec, TryFromElementError, - }, + control::{Member, MemberId, RoomSpec, TryFromElementError}, }, log::prelude::*, signalling::{ @@ -61,16 +56,7 @@ impl ParticipantService { room_spec: &RoomSpec, reconnect_timeout: Duration, ) -> Result { - let mut members = HashMap::new(); - for (control_id, element) in &room_spec.spec.pipeline { - let member_spec = MemberSpec::try_from(element.clone())?; - let member_id = MemberId(control_id.clone()); - - members.insert( - member_id.clone(), - Member::new(member_id, member_spec, room_spec)?, - ); - } + let members = room_spec.members()?; debug!("Created room with {:?} members.", members); diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 0e438a803..90974ec8a 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -83,7 +83,7 @@ impl Room { reconnect_timeout: Duration, ) -> Result { Ok(Self { - id: room_spec.id.clone(), + id: room_spec.id().clone(), peers: PeerRepository::from(HashMap::new()), participants: ParticipantService::new( room_spec, From 5c4ed4edc9d321ed6444197183ed60540b02bf1f Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 6 Jun 2019 18:30:35 +0300 Subject: [PATCH 093/735] Refactor e2e tests and simplify test ports generation algorithm --- tests/signalling.rs | 73 +++-------------------------------------- tests/test_ports.rs | 41 ----------------------- tests/utils.rs | 79 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 84 insertions(+), 109 deletions(-) delete mode 100644 tests/test_ports.rs create mode 100644 tests/utils.rs diff --git a/tests/signalling.rs b/tests/signalling.rs index 1876fea65..30ffeba6b 100644 --- a/tests/signalling.rs +++ b/tests/signalling.rs @@ -1,24 +1,16 @@ //! Signalling API e2e tests. -mod test_ports; +mod utils; use actix::{Actor, Arbiter, AsyncContext, Context, StreamHandler, System}; use actix_web::ws::{ Client, ClientWriter, Message as WebMessage, ProtocolError, }; use futures::future::Future; -use medea::{ - api::client::server, conf::Conf, conf::Server, - signalling::room_repo::RoomsRepository, start_static_rooms, -}; + use medea_client_api_proto::{Command, Direction, Event, IceCandidate}; use serde_json::error::Error as SerdeError; -use std::{ - cell::Cell, - rc::Rc, - sync::{Arc, Mutex}, - time::Duration, -}; +use std::{cell::Cell, rc::Rc, time::Duration}; /// Medea client for testing purposes. struct TestMember { @@ -145,65 +137,10 @@ impl StreamHandler for TestMember { } } -/// Run medea server. This function lock main thread until server is up. -/// Server starts in different thread and `join`'ed with main thread. -/// When test is done, server will be destroyed. -/// -/// Server load all specs from `tests/specs`. -/// -/// Provide name for thread same as your test function's name. This will -/// help you when server is panic in some test case. And this `test_name` -/// will be used as name for getting port from [`test_ports`] module. -/// -/// Don't forget register your test in [`test_ports`], otherwise the server -/// will just panic. -fn run_test_server(test_name: &'static str) -> u16 { - let bind_port = test_ports::get_port_for_test(test_name); - - let is_server_starting = Arc::new(Mutex::new(Cell::new(true))); - let is_server_starting_ref = Arc::clone(&is_server_starting); - let builder = std::thread::Builder::new().name(test_name.to_string()); - - let server_thread = builder - .spawn(move || { - let _ = System::new(format!("test-medea-server-{}", test_name)); - - let config = Conf { - server: Server { - static_specs_path: Some("tests/specs".to_string()), - bind_port, - ..Default::default() - }, - ..Default::default() - }; - - match start_static_rooms(&config) { - Ok(r) => { - let room_repo = RoomsRepository::new(r); - server::run(room_repo, config); - } - Err(e) => { - panic!("Server not started because of error: '{}'", e); - } - }; - let is_server_starting_guard = - is_server_starting_ref.lock().unwrap(); - is_server_starting_guard.set(false); - }) - .unwrap(); - - // Wait until server is up - while is_server_starting.lock().unwrap().get() {} - - server_thread.join().unwrap(); - - bind_port -} - #[test] fn pub_sub_video_call() { let test_name = "pub_sub_video_call"; - let bind_port = run_test_server(test_name); + let bind_port = utils::run_test_server(test_name); let base_url = format!("ws://localhost:{}/ws/pub-sub-video-call", bind_port); @@ -293,7 +230,7 @@ fn pub_sub_video_call() { #[test] fn three_members_p2p_video_call() { let test_name = "three_members_p2p_video_call"; - let bind_port = run_test_server(test_name); + let bind_port = utils::run_test_server(test_name); let base_url = format!("ws://localhost:{}/ws/three-members-conference", bind_port); diff --git a/tests/test_ports.rs b/tests/test_ports.rs deleted file mode 100644 index 4c1c6b34c..000000000 --- a/tests/test_ports.rs +++ /dev/null @@ -1,41 +0,0 @@ -//! Test ports generating. - -/// Macro for generating ports numbers. -/// This should used when you want to start test server. -/// It's necessary because tests run asynchronously and ports -/// should not overlap. Enumerating start from 49151 because -/// based on [Registered by IANA ports][1] this is the last reserved port. -/// 16384 ought to be enough for anybody. -/// -/// [1]: https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers -macro_rules! generate_ports_for_tests { - ( $( $x:tt ),* $(,)* ) => { - use lazy_static::lazy_static; - use hashbrown::HashMap; - - lazy_static! { - static ref PORTS: HashMap = { - let mut names: Vec = Vec::new(); - $( names.push(stringify!($x).to_string()); )* - names - .into_iter() - .enumerate() - .map(|(i, t)| { - let port = 49151 + i as u16; - (t, port) - }) - .collect() - }; - } - }; -} - -// Register your test by adding test name into this macro call. -generate_ports_for_tests!(three_members_p2p_video_call, pub_sub_video_call,); - -/// Use it for easy get port by declared before name. -/// -/// It will panic in runtime when port with provided name is not defined. -pub fn get_port_for_test(name: &str) -> u16 { - *PORTS.get(name).expect("Port for this name is not defined!") -} diff --git a/tests/utils.rs b/tests/utils.rs new file mode 100644 index 000000000..f109b9c06 --- /dev/null +++ b/tests/utils.rs @@ -0,0 +1,79 @@ +//! Utils useful for e2e testing of medea. + +use std::{ + cell::Cell, + sync::atomic::{AtomicUsize, Ordering}, + sync::{Arc, Mutex}, +}; + +use actix::System; +use medea::{ + api::client::server, conf::Conf, conf::Server, + signalling::room_repo::RoomsRepository, start_static_rooms, +}; + +/// Test ports counter. Used for dealing with async testing. +/// Enumerating start from 49152 because +/// based on [Registered by IANA ports][1] this is the last reserved port. +/// 16384 ought to be enough for anybody. +/// +/// Use `get_port_for_test()` instead of accessing this var directly. +/// +/// [1]: https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers +static LAST_TEST_PORT: AtomicUsize = AtomicUsize::new(49152); + +/// Use it for getting port for testing. +pub fn get_port_for_test() -> u16 { + LAST_TEST_PORT.fetch_add(1, Ordering::Relaxed) as u16 +} + +/// Run medea server. This function lock main thread until server is up. +/// Server starts in different thread and `join`'ed with main thread. +/// When test is done, server will be destroyed. +/// +/// Server load all specs from `tests/specs`. +/// +/// Provide `test_name` same as your test function's name. This will +/// help you when server panic in some test case. +pub fn run_test_server(test_name: &'static str) -> u16 { + let bind_port = get_port_for_test(); + + let is_server_starting = Arc::new(Mutex::new(Cell::new(true))); + let is_server_starting_ref = Arc::clone(&is_server_starting); + let builder = std::thread::Builder::new().name(test_name.to_string()); + + let server_thread = builder + .spawn(move || { + let _ = System::new(format!("test-medea-server-{}", test_name)); + + let config = Conf { + server: Server { + static_specs_path: Some("tests/specs".to_string()), + bind_port, + ..Default::default() + }, + ..Default::default() + }; + + match start_static_rooms(&config) { + Ok(r) => { + let room_repo = RoomsRepository::new(r); + server::run(room_repo, config); + } + Err(e) => { + panic!("Server not started because of error: '{}'", e); + } + }; + let is_server_starting_guard = + is_server_starting_ref.lock().unwrap(); + is_server_starting_guard.set(false); + }) + .unwrap(); + + // Wait until server is up + while is_server_starting.lock().unwrap().get() {} + + server_thread.join().unwrap(); + + bind_port +} From ab538c0f71d1c13a60b787bebbc12b7c597ad1b4 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 6 Jun 2019 18:45:38 +0300 Subject: [PATCH 094/735] Upd docs --- src/signalling/room.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 90974ec8a..1aa05c919 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -264,8 +264,13 @@ impl Room { } } - /// Create and interconnect all necessary [`Member`]'s [`Peer`]s. - fn create_necessary_peers( + /// Create and interconnect all [`Peer`]s between connected [`Member`] + /// and all available at this moment [`Member`]s from [`MemberSpec`]. + /// + /// Availability is determines by checking [`RpcConnection`] of all + /// [`Member`]s from [`WebRtcPlayEndpoint`]s and from receivers of + /// connected [`Member`]. + fn create_peers_with_available_members( &mut self, member_id: &MemberId, ctx: &mut ::Context, @@ -460,7 +465,7 @@ impl Handler for Room { // Check that user is not reconnecting if self.peers.get_peers_by_member_id(&msg.member_id).is_empty() { - self.create_necessary_peers(&msg.member_id, ctx); + self.create_peers_with_available_members(&msg.member_id, ctx); } Box::new(wrap_future(future::ok(()))) From 190c73b5b5632859762bfd42121f099432664851 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 6 Jun 2019 18:57:17 +0300 Subject: [PATCH 095/735] Refactoring --- src/signalling/room.rs | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 1aa05c919..f7f7b4ce2 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -240,28 +240,26 @@ impl Room { ))) } - /// Create [`Peer`] between members and interconnect it by control API spec. - fn create_peers( + /// Create [`Peer`] between [`Member`]s and interconnect it by control API + /// spec. + fn create_and_interconnect_peers( &mut self, - to_create: Vec<(&Member, Member)>, + first_member: &Member, + second_member: &Member, ctx: &mut ::Context, ) { - for p in to_create { - let first_member = p.0; - let second_member = p.1; - debug!( - "Created peer member {} with member {}", - first_member.id(), - second_member.id() - ); + debug!( + "Created peer member {} with member {}", + first_member.id(), + second_member.id() + ); - let (caller_peer_id, responder_peer_id) = - self.peers.create_peers(first_member, &second_member); + let (first_peer_id, second_peer_id) = + self.peers.create_peers(first_member, second_member); - ctx.notify(ConnectPeers(caller_peer_id, responder_peer_id)); + ctx.notify(ConnectPeers(first_peer_id, second_peer_id)); - // println!("Peers: {:#?}", self.peers); - } + // println!("Peers: {:#?}", self.peers); } /// Create and interconnect all [`Peer`]s between connected [`Member`] @@ -334,7 +332,15 @@ impl Room { } } - self.create_peers(need_create, ctx); + need_create + .into_iter() + .for_each(|(first_member, second_member)| { + self.create_and_interconnect_peers( + first_member, + &second_member, + ctx, + ); + }); } } From 12c4f5266b47a1bf65196c5342addb0ec01d0485 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 6 Jun 2019 18:59:52 +0300 Subject: [PATCH 096/735] Add docs --- src/media/peer.rs | 1 - src/signalling/peers.rs | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/media/peer.rs b/src/media/peer.rs index da1e9fbc3..f20ae656b 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -260,7 +260,6 @@ impl Peer { endpoints: Vec<&WebRtcPublishEndpoint>, track_id_counter: &mut Counter, ) { - // TODO: &mut track_id_counter looks bad for _ in endpoints { let track_audio = Arc::new(MediaTrack::new( track_id_counter.next_id(), diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index 2a2c31664..824522580 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -25,12 +25,14 @@ pub struct PeerRepository { tracks_count: Counter, } +/// Simple ID counter. #[derive(Default, Debug)] pub struct Counter { count: u64, } impl Counter { + /// Returns id and increase counter. pub fn next_id(&mut self) -> u64 { let id = self.count; self.count += 1; From aed7b9e9276fbd09550100cb0d1744dcca459427 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 6 Jun 2019 19:24:22 +0300 Subject: [PATCH 097/735] Fix imports --- src/api/control/mod.rs | 4 ++-- src/signalling/peers.rs | 4 ++-- src/signalling/room_repo.rs | 4 ++-- tests/signalling.rs | 4 ++-- tests/utils.rs | 6 ++++-- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index 636f71ca4..fd741cce0 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -5,11 +5,11 @@ pub mod member; pub mod pipeline; pub mod room; +use std::{convert::TryFrom as _, fs::File, io::Read as _, path::Path}; + use failure::{Error, Fail}; use serde::Deserialize; -use std::{convert::TryFrom as _, fs::File, io::Read as _, path::Path}; - use self::{ endpoint::{WebRtcPlayEndpoint, WebRtcPublishEndpoint}, pipeline::Pipeline, diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index 824522580..4f405ba7d 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -1,12 +1,12 @@ //! Repository that stores [`Room`]s [`Peer`]s. -use hashbrown::HashMap; - use std::{ convert::{TryFrom, TryInto}, fmt, }; +use hashbrown::HashMap; + use crate::{ api::control::{Member, MemberId}, media::{Peer, PeerId, PeerStateMachine}, diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs index ae446b23a..6f628dca5 100644 --- a/src/signalling/room_repo.rs +++ b/src/signalling/room_repo.rs @@ -1,10 +1,10 @@ //! Repository that stores [`Room`]s addresses. +use std::sync::{Arc, Mutex}; + use actix::Addr; use hashbrown::HashMap; -use std::sync::{Arc, Mutex}; - use crate::{api::control::RoomId, signalling::Room}; /// Repository that stores [`Room`]s addresses. diff --git a/tests/signalling.rs b/tests/signalling.rs index 30ffeba6b..82399709a 100644 --- a/tests/signalling.rs +++ b/tests/signalling.rs @@ -2,15 +2,15 @@ mod utils; +use std::{cell::Cell, rc::Rc, time::Duration}; + use actix::{Actor, Arbiter, AsyncContext, Context, StreamHandler, System}; use actix_web::ws::{ Client, ClientWriter, Message as WebMessage, ProtocolError, }; use futures::future::Future; - use medea_client_api_proto::{Command, Direction, Event, IceCandidate}; use serde_json::error::Error as SerdeError; -use std::{cell::Cell, rc::Rc, time::Duration}; /// Medea client for testing purposes. struct TestMember { diff --git a/tests/utils.rs b/tests/utils.rs index f109b9c06..0868cd16c 100644 --- a/tests/utils.rs +++ b/tests/utils.rs @@ -2,8 +2,10 @@ use std::{ cell::Cell, - sync::atomic::{AtomicUsize, Ordering}, - sync::{Arc, Mutex}, + sync::{ + atomic::{AtomicUsize, Ordering}, + Arc, Mutex, + }, }; use actix::System; From 8584664b0fabc3170155341bab7372bdcd9c2019 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 6 Jun 2019 19:37:19 +0300 Subject: [PATCH 098/735] Upd doc --- src/api/control/pipeline.rs | 4 ++-- src/api/control/room.rs | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/api/control/pipeline.rs b/src/api/control/pipeline.rs index 2f062c50d..724a649b6 100644 --- a/src/api/control/pipeline.rs +++ b/src/api/control/pipeline.rs @@ -41,7 +41,7 @@ impl Pipeline { .collect() } - /// Get all receivers of all [`Member`]'s [`WebRtcPublishEndpoint`]s. + /// Get all receivers of all [`Member`]'s [`WebRtcPublishEndpoint`]. pub fn get_receivers_for_member( &self, id: &MemberId, @@ -59,7 +59,7 @@ impl Pipeline { Ok(receivers) } - /// Get all members from pipeline of [`RoomSpec`]. + /// Get all [`Member`]s from pipeline of [`RoomSpec`]. pub fn members( &self, room_spec: &RoomSpec, diff --git a/src/api/control/room.rs b/src/api/control/room.rs index b610688fe..ca5f61a4a 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -31,12 +31,14 @@ impl RoomSpec { self.pipeline.get_receivers_for_member(id) } + /// Returns all [`Member`]s of this [`RoomSpec`]. pub fn members( &self, ) -> Result, TryFromElementError> { self.pipeline.members(self) } + /// Returns ID of this [`RoomSpec`] pub fn id(&self) -> &Id { &self.id } From 5ea4367bc1573143f3425d3de56e02b60f4b0ebf Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 7 Jun 2019 14:24:09 +0300 Subject: [PATCH 099/735] TryFrom ref --- src/api/control/endpoint.rs | 8 ++++---- src/api/control/member.rs | 8 ++++---- src/api/control/mod.rs | 2 +- src/api/control/pipeline.rs | 4 ++-- src/api/control/room.rs | 11 +++++++---- 5 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/api/control/endpoint.rs b/src/api/control/endpoint.rs index 3374e9e32..314400c79 100644 --- a/src/api/control/endpoint.rs +++ b/src/api/control/endpoint.rs @@ -19,16 +19,16 @@ pub enum Endpoint { WebRtcPlay(WebRtcPlayEndpoint), } -impl TryFrom for Endpoint { +impl TryFrom<&Element> for Endpoint { type Error = TryFromElementError; - fn try_from(from: Element) -> Result { + fn try_from(from: &Element) -> Result { match from { Element::WebRtcPlayEndpoint { spec } => { - Ok(Endpoint::WebRtcPlay(spec)) + Ok(Endpoint::WebRtcPlay(spec.clone())) } Element::WebRtcPublishEndpoint { spec } => { - Ok(Endpoint::WebRtcPublish(spec)) + Ok(Endpoint::WebRtcPublish(spec.clone())) } _ => Err(TryFromElementError::NotEndpoint), } diff --git a/src/api/control/member.rs b/src/api/control/member.rs index d55b217a8..6666bb244 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -100,14 +100,14 @@ impl MemberSpec { } } -impl TryFrom for MemberSpec { +impl TryFrom<&Element> for MemberSpec { type Error = TryFromElementError; - fn try_from(from: Element) -> Result { + fn try_from(from: &Element) -> Result { match from { Element::Member { spec, credentials } => Ok(Self { - pipeline: spec, - credentials, + pipeline: spec.clone(), + credentials: credentials.clone(), }), _ => Err(TryFromElementError::NotMember), } diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index fd741cce0..9faa565c8 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -61,7 +61,7 @@ pub fn load_from_yaml_file>(path: P) -> Result { let mut buf = String::new(); file.read_to_string(&mut buf)?; let parsed: Element = serde_yaml::from_str(&buf)?; - let room = RoomSpec::try_from(parsed)?; + let room = RoomSpec::try_from(&parsed)?; Ok(room) } diff --git a/src/api/control/pipeline.rs b/src/api/control/pipeline.rs index 724a649b6..45f20d287 100644 --- a/src/api/control/pipeline.rs +++ b/src/api/control/pipeline.rs @@ -48,7 +48,7 @@ impl Pipeline { ) -> Result, TryFromElementError> { let mut receivers = Vec::new(); for (member_id, member_element) in &self.pipeline { - let member = MemberSpec::try_from(member_element.clone())?; + let member = MemberSpec::try_from(member_element)?; for endpoint in member.play_endpoints() { if &endpoint.src.member_id == id { receivers.push(MemberId(member_id.clone())); @@ -66,7 +66,7 @@ impl Pipeline { ) -> Result, TryFromElementError> { let mut members = HashBrownMap::new(); for (control_id, element) in &self.pipeline { - let member_spec = MemberSpec::try_from(element.clone())?; + let member_spec = MemberSpec::try_from(element)?; let member_id = MemberId(control_id.clone()); members.insert( diff --git a/src/api/control/room.rs b/src/api/control/room.rs index ca5f61a4a..9c0ccc0d7 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -44,12 +44,15 @@ impl RoomSpec { } } -impl TryFrom for RoomSpec { +impl TryFrom<&Element> for RoomSpec { type Error = TryFromElementError; - fn try_from(from: Element) -> Result { + fn try_from(from: &Element) -> Result { match from { - Element::Room { id, spec } => Ok(Self { id, pipeline: spec }), + Element::Room { id, spec } => Ok(Self { + id: id.clone(), + pipeline: spec.clone(), + }), _ => Err(TryFromElementError::NotRoom), } } @@ -99,7 +102,7 @@ mod room_spec_tests { src: "local://test-call/some-member/publish" "#; let spec: Element = serde_yaml::from_str(spec).unwrap(); - let room = RoomSpec::try_from(spec).unwrap(); + let room = RoomSpec::try_from(&spec).unwrap(); let caller_member_id = MemberId("caller".to_string()); let responder_member_id = MemberId("responder".to_string()); From fbf39f113f5d504fb2500e9b779774a0894a1959 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 7 Jun 2019 15:10:51 +0300 Subject: [PATCH 100/735] Refactor pipeline --- src/api/control/member.rs | 16 +++++++- src/api/control/pipeline.rs | 79 ++++++++++--------------------------- src/api/control/room.rs | 28 +++++++++++-- 3 files changed, 60 insertions(+), 63 deletions(-) diff --git a/src/api/control/member.rs b/src/api/control/member.rs index 6666bb244..62fae4d0a 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -87,12 +87,24 @@ pub struct MemberSpec { impl MemberSpec { /// Returns all [`WebRtcPlayEndpoint`]s of this [`MemberSpec`]. pub fn play_endpoints(&self) -> Vec<&WebRtcPlayEndpoint> { - self.pipeline.play_endpoints() + self.pipeline + .iter() + .filter_map(|(_, e)| match e { + Element::WebRtcPlayEndpoint { spec } => Some(spec), + _ => None, + }) + .collect() } /// Returns all [`WebRtcPublishEndpoint`]s of this [`MemberSpec`]. pub fn publish_endpoints(&self) -> Vec<&WebRtcPublishEndpoint> { - self.pipeline.publish_endpoints() + self.pipeline + .iter() + .filter_map(|(_, e)| match e { + Element::WebRtcPublishEndpoint { spec } => Some(spec), + _ => None, + }) + .collect() } pub fn credentials(&self) -> &str { diff --git a/src/api/control/pipeline.rs b/src/api/control/pipeline.rs index 45f20d287..d33b33b46 100644 --- a/src/api/control/pipeline.rs +++ b/src/api/control/pipeline.rs @@ -1,15 +1,15 @@ //! Control API specification Pipeline definition. -use std::{collections::HashMap, convert::TryFrom as _}; +use std::{ + collections::{ + hash_map::{IntoIter, Iter}, + HashMap, + }, + iter::IntoIterator, +}; -use hashbrown::HashMap as HashBrownMap; use serde::Deserialize; -use super::{ - endpoint::{WebRtcPlayEndpoint, WebRtcPublishEndpoint}, - Member, MemberId, MemberSpec, RoomSpec, TryFromElementError, -}; - use crate::api::control::Element; /// Entity that represents some pipeline of spec. @@ -19,62 +19,25 @@ pub struct Pipeline { } impl Pipeline { - /// Get all [`WebRtcPlayEndpoint`]s from this [`Pipeline`]. - pub fn play_endpoints(&self) -> Vec<&WebRtcPlayEndpoint> { - self.pipeline - .iter() - .filter_map(|(_, e)| match e { - Element::WebRtcPlayEndpoint { spec } => Some(spec), - _ => None, - }) - .collect() - } - - /// Get all [`WebRtcPublishEndpoint`]s from this [`Pipeline`]. - pub fn publish_endpoints(&self) -> Vec<&WebRtcPublishEndpoint> { - self.pipeline - .iter() - .filter_map(|(_, e)| match e { - Element::WebRtcPublishEndpoint { spec } => Some(spec), - _ => None, - }) - .collect() + pub fn iter(&self) -> impl Iterator { + self.into_iter() } +} - /// Get all receivers of all [`Member`]'s [`WebRtcPublishEndpoint`]. - pub fn get_receivers_for_member( - &self, - id: &MemberId, - ) -> Result, TryFromElementError> { - let mut receivers = Vec::new(); - for (member_id, member_element) in &self.pipeline { - let member = MemberSpec::try_from(member_element)?; - for endpoint in member.play_endpoints() { - if &endpoint.src.member_id == id { - receivers.push(MemberId(member_id.clone())); - } - } - } +impl IntoIterator for Pipeline { + type IntoIter = IntoIter; + type Item = (String, Element); - Ok(receivers) + fn into_iter(self) -> Self::IntoIter { + self.pipeline.into_iter() } +} - /// Get all [`Member`]s from pipeline of [`RoomSpec`]. - pub fn members( - &self, - room_spec: &RoomSpec, - ) -> Result, TryFromElementError> { - let mut members = HashBrownMap::new(); - for (control_id, element) in &self.pipeline { - let member_spec = MemberSpec::try_from(element)?; - let member_id = MemberId(control_id.clone()); - - members.insert( - member_id.clone(), - Member::new(member_id, member_spec, room_spec)?, - ); - } +impl<'a> IntoIterator for &'a Pipeline { + type IntoIter = Iter<'a, String, Element>; + type Item = (&'a String, &'a Element); - Ok(members) + fn into_iter(self) -> Self::IntoIter { + self.pipeline.iter() } } diff --git a/src/api/control/room.rs b/src/api/control/room.rs index 9c0ccc0d7..bd36ab701 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -6,7 +6,8 @@ use hashbrown::HashMap; use serde::Deserialize; use super::{ - pipeline::Pipeline, Element, Member, MemberId, TryFromElementError, + pipeline::Pipeline, Element, Member, MemberId, MemberSpec, + TryFromElementError, }; /// ID of [`Room`]. @@ -28,14 +29,35 @@ impl RoomSpec { &self, id: &MemberId, ) -> Result, TryFromElementError> { - self.pipeline.get_receivers_for_member(id) + let mut receivers = Vec::new(); + for (member_id, member_element) in &self.pipeline { + let member = MemberSpec::try_from(member_element)?; + for endpoint in member.play_endpoints() { + if &endpoint.src.member_id == id { + receivers.push(MemberId(member_id.clone())); + } + } + } + + Ok(receivers) } /// Returns all [`Member`]s of this [`RoomSpec`]. pub fn members( &self, ) -> Result, TryFromElementError> { - self.pipeline.members(self) + let mut members = HashMap::new(); + for (control_id, element) in &self.pipeline { + let member_spec = MemberSpec::try_from(element)?; + let member_id = MemberId(control_id.clone()); + + members.insert( + member_id.clone(), + Member::new(member_id, member_spec, self)?, + ); + } + + Ok(members) } /// Returns ID of this [`RoomSpec`] From a2a9893020f49854f73aab5b0e81de885efa5fd2 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 7 Jun 2019 15:16:52 +0300 Subject: [PATCH 101/735] Use test specs in tests --- src/api/client/server.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/api/client/server.rs b/src/api/client/server.rs index ae0e255a9..7c609a318 100644 --- a/src/api/client/server.rs +++ b/src/api/client/server.rs @@ -119,7 +119,8 @@ mod test { /// Creates [`RoomsRepository`] for tests filled with a single [`Room`]. fn room(conf: Rpc) -> RoomsRepository { let room_spec = - control::load_from_yaml_file("./specs/video_call_1.yml").unwrap(); + control::load_from_yaml_file("tests/specs/pub_sub_video_call.yml") + .unwrap(); let client_room = Room::new(&room_spec, conf.reconnect_timeout).unwrap(); @@ -149,7 +150,7 @@ mod test { fn responses_with_pong() { let mut server = ws_server(Conf::default()); let (read, mut write) = - server.ws_at("/ws/video-call-1/caller/test").unwrap(); + server.ws_at("/ws/pub-sub-video-call/caller/test").unwrap(); write.text(r#"{"ping":33}"#); let (item, _) = server.execute(read.into_future()).unwrap(); @@ -168,7 +169,7 @@ mod test { let mut server = ws_server(conf.clone()); let (read, mut write) = - server.ws_at("/ws/video-call-1/caller/test").unwrap(); + server.ws_at("/ws/pub-sub-video-call/caller/test").unwrap(); write.text(r#"{"ping":33}"#); let (item, read) = server.execute(read.into_future()).unwrap(); From fc22bad4a6c03d3531d59b9ebb0bd394dd94c419 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 7 Jun 2019 18:51:06 +0300 Subject: [PATCH 102/735] Add PeersClosed event sending --- src/signalling/participants.rs | 7 +-- src/signalling/peers.rs | 60 +++++++++++++----- src/signalling/room.rs | 44 ++++++++++++- tests/signalling.rs | 109 ++++++++++++++++++++++++--------- 4 files changed, 171 insertions(+), 49 deletions(-) diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index dc83b1a93..968cd44d5 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -21,10 +21,7 @@ use crate::{ control::{Member, MemberId, RoomSpec, TryFromElementError}, }, log::prelude::*, - signalling::{ - room::{CloseRoom, RoomError}, - Room, - }, + signalling::{room::RoomError, Room}, }; /// Participant is [`Member`] with [`RpcConnection`]. [`ParticipantService`] @@ -133,7 +130,7 @@ impl ParticipantService { match reason { ClosedReason::Closed => { self.connections.remove(&member_id); - ctx.notify(CloseRoom {}) + // ctx.notify(CloseRoom {}) } ClosedReason::Lost => { self.drop_connection_tasks.insert( diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index 4f405ba7d..48bd4c5ce 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -5,12 +5,13 @@ use std::{ fmt, }; +use actix::{AsyncContext as _, Context}; use hashbrown::HashMap; use crate::{ api::control::{Member, MemberId}, media::{Peer, PeerId, PeerStateMachine}, - signalling::room::RoomError, + signalling::room::{PeersRemoved, Room, RoomError}, }; #[derive(Debug)] @@ -162,21 +163,52 @@ impl PeerRepository { /// Close all related to disconnected [`Member`] [`Peer`]s and partner /// [`Peer`]s. - pub fn connection_closed(&mut self, member_id: &MemberId) { - let mut peers_to_remove: Vec = Vec::new(); - for peer in self.get_peers_by_member_id(member_id) { - for partner_peer in + /// + /// Send [`Event::PeersRemoved`] to all affected [`Member`]s. + pub fn connection_closed( + &mut self, + member_id: &MemberId, + ctx: &mut Context, + ) { + let mut peers_to_remove: HashMap> = + HashMap::new(); + + self.get_peers_by_member_id(member_id) + .into_iter() + .map(|peer| { self.get_peers_by_member_id(&peer.partner_member_id()) - { - if &partner_peer.partner_member_id() == member_id { - peers_to_remove.push(partner_peer.id()); - } + .into_iter() + .filter(|partner_peer| { + &partner_peer.partner_member_id() == member_id + }) + .for_each(|partner_peer| { + peers_to_remove + .entry(partner_peer.member_id()) + .or_insert(Vec::new()) + .push(partner_peer.id()); + }); + + peers_to_remove + .entry(peer.partner_member_id()) + .or_insert(Vec::new()) + .push(peer.id()); + + peer.id() + }) + .collect::>() + .into_iter() + .for_each(|id| { + self.peers.remove(&id); + }); + + for (peer_member_id, peers_id) in peers_to_remove { + for peer_id in &peers_id { + self.peers.remove(peer_id); } - peers_to_remove.push(peer.id()); - } - - for peer_id in peers_to_remove { - self.peers.remove(&peer_id); + ctx.notify(PeersRemoved { + member_id: peer_member_id, + peers_id, + }) } } } diff --git a/src/signalling/room.rs b/src/signalling/room.rs index f7f7b4ce2..356d7ef9e 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -140,6 +140,18 @@ impl Room { ))) } + /// Sends [`Event::PeersRemoved`] to [`Member`]. + fn send_peers_removed( + &mut self, + member_id: MemberId, + peers: Vec, + ) -> ActFuture<(), RoomError> { + Box::new(wrap_future(self.participants.send_event_to_member( + member_id, + Event::PeersRemoved { peer_ids: peers }, + ))) + } + /// Sends [`Event::PeerCreated`] to provided [`Peer`] partner. Provided /// [`Peer`] state must be [`WaitLocalSdp`] and will be changed to /// [`WaitRemoteSdp`], partners [`Peer`] state must be [`New`] and will be @@ -403,6 +415,36 @@ impl Handler for Room { } } +#[derive(Debug, Message)] +#[rtype(result = "Result<(), ()>")] +pub struct PeersRemoved { + pub peers_id: Vec, + pub member_id: MemberId, +} + +impl Handler for Room { + type Result = ActFuture<(), ()>; + + /// Send [`Event::PeersRemoved`] to [`Member`]. + fn handle( + &mut self, + msg: PeersRemoved, + _ctx: &mut Self::Context, + ) -> Self::Result { + Box::new( + self.send_peers_removed(msg.member_id, msg.peers_id) + .map_err(|err, _, ctx: &mut Context| { + error!( + "Failed PeersEvent command, because {}. Room will be \ + stopped.", + err + ); + ctx.notify(CloseRoom {}) + }), + ) + } +} + impl Handler for Room { type Result = ActFuture<(), ()>; @@ -512,7 +554,7 @@ impl Handler for Room { ); if let ClosedReason::Closed = msg.reason { - self.peers.connection_closed(&msg.member_id); + self.peers.connection_closed(&msg.member_id, ctx); } self.participants diff --git a/tests/signalling.rs b/tests/signalling.rs index 82399709a..0cda00cdd 100644 --- a/tests/signalling.rs +++ b/tests/signalling.rs @@ -4,11 +4,16 @@ mod utils; use std::{cell::Cell, rc::Rc, time::Duration}; -use actix::{Actor, Arbiter, AsyncContext, Context, StreamHandler, System}; +use actix::{ + Actor, Arbiter, AsyncContext, Context, Handler, Message, StreamHandler, + System, +}; use actix_web::ws::{ - Client, ClientWriter, Message as WebMessage, ProtocolError, + Client, ClientWriter, CloseCode, CloseReason, Message as WebMessage, + ProtocolError, }; use futures::future::Future; +use medea::media::PeerId; use medea_client_api_proto::{Command, Direction, Event, IceCandidate}; use serde_json::error::Error as SerdeError; @@ -25,25 +30,7 @@ struct TestMember { /// Function which will be called at every received by this [`TestMember`] /// [`Event`]. - test_fn: Box, -} - -impl Actor for TestMember { - type Context = Context; - - /// Start heartbeat and set a timer that will panic when 5 seconds expire. - /// The timer is needed because some tests may just stuck - /// and listen socket forever. - fn started(&mut self, ctx: &mut Self::Context) { - self.heartbeat(ctx); - ctx.run_later(Duration::from_secs(5), |act, _ctx| { - panic!( - "This test lasts more than 5 seconds. Most likely, this is \ - not normal. Here is all events of member: {:?}", - act.events - ); - }); - } + test_fn: Box)>, } impl TestMember { @@ -66,7 +53,10 @@ impl TestMember { /// Start test member in new [`Arbiter`] by given URI. /// `test_fn` - is function which will be called at every [`Event`] /// received from server. - pub fn start(uri: &str, test_fn: Box) { + pub fn start( + uri: &str, + test_fn: Box)>, + ) { Arbiter::spawn( Client::new(uri) .connect() @@ -87,11 +77,44 @@ impl TestMember { } } +impl Actor for TestMember { + type Context = Context; + + /// Start heartbeat and set a timer that will panic when 5 seconds expire. + /// The timer is needed because some tests may just stuck + /// and listen socket forever. + fn started(&mut self, ctx: &mut Self::Context) { + self.heartbeat(ctx); + ctx.run_later(Duration::from_secs(5), |act, _ctx| { + panic!( + "This test lasts more than 5 seconds. Most likely, this is \ + not normal. Here is all events of member: {:?}", + act.events + ); + }); + } +} + +#[derive(Debug, Message)] +#[rtype(result = "()")] +struct CloseSocket; + +impl Handler for TestMember { + type Result = (); + + fn handle(&mut self, _msg: CloseSocket, _ctx: &mut Self::Context) { + self.writer.close(Some(CloseReason { + code: CloseCode::Normal, + description: None, + })); + } +} + impl StreamHandler for TestMember { /// Basic signalling implementation. /// A `TestMember::test_fn` [`FnMut`] function will be called for each /// [`Event`] received from test server. - fn handle(&mut self, msg: WebMessage, _ctx: &mut Context) { + fn handle(&mut self, msg: WebMessage, ctx: &mut Context) { match msg { WebMessage::Text(txt) => { let event: Result = @@ -99,7 +122,7 @@ impl StreamHandler for TestMember { if let Ok(event) = event { self.events.push(event.clone()); // Test function call - (self.test_fn)(&event); + (self.test_fn)(&event, ctx); match event { Event::PeerCreated { peer_id, sdp_offer, .. @@ -149,7 +172,7 @@ fn pub_sub_video_call() { // Note that events is separated by members. // Every member will have different instance of this. let mut events = Vec::new(); - let test_fn = move |event: &Event| { + let test_fn = move |event: &Event, _ctx: &mut Context| { events.push(event.clone()); // Start of checking result of test. @@ -242,10 +265,12 @@ fn three_members_p2p_video_call() { let mut events = Vec::new(); let mut peer_created_count = 0; let mut ice_candidates = 0; + // This is shared state of members. let members_tested = Rc::new(Cell::new(0)); + let members_peers_removed = Rc::new(Cell::new(0)); - let test_fn = move |event: &Event| { + let test_fn = move |event: &Event, ctx: &mut Context| { events.push(event.clone()); match event { Event::PeerCreated { .. } => { @@ -293,10 +318,36 @@ fn three_members_p2p_video_call() { _ => (), }); - members_tested.set(members_tested.get() + 1); - if members_tested.get() == 3 { - System::current().stop(); + // Check peers removing. + // After closing socket, server should send + // Event::PeersRemoved to all remaining + // members. + // Close should happen when last TestMember pass + // tests. + if members_tested.get() == 2 { + ctx.notify(CloseSocket); } + members_tested.set(members_tested.get() + 1); + } + } + Event::PeersRemoved { .. } => { + // This event should get two remaining members after closing + // last tested member. + let peers_removed: Vec<&Vec> = events + .iter() + .filter_map(|e| match e { + Event::PeersRemoved { peer_ids } => Some(peer_ids), + _ => None, + }) + .collect(); + assert_eq!(peers_removed.len(), 1); + assert_eq!(peers_removed[0].len(), 2); + assert_ne!(peers_removed[0][0], peers_removed[0][1]); + + members_peers_removed.set(members_peers_removed.get() + 1); + // Stop when all members receive Event::PeerRemoved + if members_peers_removed.get() == 2 { + System::current().stop(); } } _ => (), From 01a1a171e2d2bd665723bb3a5731a956be1285e0 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 7 Jun 2019 20:10:25 +0300 Subject: [PATCH 103/735] Make members receivers dynamic --- src/api/control/member.rs | 41 ++++++++++++++++++++++++++------------- src/api/control/room.rs | 38 ++++++++---------------------------- src/signalling/room.rs | 2 +- 3 files changed, 36 insertions(+), 45 deletions(-) diff --git a/src/api/control/member.rs b/src/api/control/member.rs index 62fae4d0a..d36ca20c1 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -7,7 +7,6 @@ use serde::Deserialize; use super::{ endpoint::{WebRtcPlayEndpoint, WebRtcPublishEndpoint}, pipeline::Pipeline, - room::RoomSpec, Element, TryFromElementError, }; @@ -30,21 +29,17 @@ pub struct Member { /// Control API specification of this [`Member`]. spec: Arc, - /// Receivers of this [`Member`]'s publish endpoints. - receivers: Vec, + /// Pipeline of [`Room`] in which this [`Member`] is located. + room_pipeline: Arc, } impl Member { - pub fn new( - id: Id, - spec: MemberSpec, - room_spec: &RoomSpec, - ) -> Result { - Ok(Self { - receivers: room_spec.get_receivers_for_member(&id)?, + pub fn new(id: Id, spec: MemberSpec, room_pipeline: Arc) -> Self { + Self { spec: Arc::new(spec), id, - }) + room_pipeline, + } } /// Returns [`Id`] of [`Member`]. @@ -67,9 +62,27 @@ impl Member { self.spec.publish_endpoints() } - /// Returns all receivers [`Id`] of this [`Member`]. - pub fn receivers(&self) -> &Vec { - &self.receivers + /// Get all receivers [`Id`] of all [`Member`]'s [`WebRtcPublishEndpoint`]s. + pub fn receivers(&self) -> Vec { + self.room_pipeline + .iter() + .filter_map(|(id, element)| { + MemberSpec::try_from(element).map(|s| (id, s)).ok() + }) + .filter_map(|(id, member)| { + if member + .play_endpoints() + .iter() + .filter(|e| e.src.member_id == self.id) + .count() + > 0 + { + Some(Id(id.clone())) + } else { + None + } + }) + .collect() } } diff --git a/src/api/control/room.rs b/src/api/control/room.rs index bd36ab701..54476fa6c 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -1,6 +1,6 @@ //! Room definitions and implementations. -use std::convert::TryFrom; +use std::{convert::TryFrom, sync::Arc}; use hashbrown::HashMap; use serde::Deserialize; @@ -20,40 +20,22 @@ pub struct Id(pub String); #[derive(Clone, Debug)] pub struct RoomSpec { id: Id, - pipeline: Pipeline, + pipeline: Arc, } impl RoomSpec { - /// Get all receivers of all [`Member`]'s [`WebRtcPublishEndpoint`]s. - pub fn get_receivers_for_member( - &self, - id: &MemberId, - ) -> Result, TryFromElementError> { - let mut receivers = Vec::new(); - for (member_id, member_element) in &self.pipeline { - let member = MemberSpec::try_from(member_element)?; - for endpoint in member.play_endpoints() { - if &endpoint.src.member_id == id { - receivers.push(MemberId(member_id.clone())); - } - } - } - - Ok(receivers) - } - /// Returns all [`Member`]s of this [`RoomSpec`]. pub fn members( &self, ) -> Result, TryFromElementError> { let mut members = HashMap::new(); - for (control_id, element) in &self.pipeline { + for (control_id, element) in self.pipeline.iter() { let member_spec = MemberSpec::try_from(element)?; let member_id = MemberId(control_id.clone()); members.insert( member_id.clone(), - Member::new(member_id, member_spec, self)?, + Member::new(member_id, member_spec, Arc::clone(&self.pipeline)), ); } @@ -73,7 +55,7 @@ impl TryFrom<&Element> for RoomSpec { match from { Element::Room { id, spec } => Ok(Self { id: id.clone(), - pipeline: spec.clone(), + pipeline: Arc::new(spec.clone()), }), _ => Err(TryFromElementError::NotRoom), } @@ -128,18 +110,14 @@ mod room_spec_tests { let caller_member_id = MemberId("caller".to_string()); let responder_member_id = MemberId("responder".to_string()); - let some_member_id = MemberId("some-member".to_string()); + let room_members = room.members().unwrap(); let caller_receivers = - room.get_receivers_for_member(&caller_member_id).unwrap(); + room_members.get(&caller_member_id).unwrap().receivers(); assert_eq!(caller_receivers, vec![responder_member_id.clone()]); let responder_receivers = - room.get_receivers_for_member(&responder_member_id).unwrap(); + room_members.get(&responder_member_id).unwrap().receivers(); assert_eq!(responder_receivers, vec![]); - - let some_member_receivers = - room.get_receivers_for_member(&some_member_id).unwrap(); - assert_eq!(some_member_receivers, vec![responder_member_id.clone()]); } } diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 356d7ef9e..d7b0a69a3 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -302,7 +302,7 @@ impl Room { // connect receivers let mut already_connected_members = Vec::new(); - for recv_member_id in member.receivers() { + for recv_member_id in &member.receivers() { if self.participants.member_has_connection(recv_member_id) { if let Some(recv_member) = self.participants.get_member_by_id(recv_member_id) From be056546bbb50708bad81b922c287d148cf0cdcc Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 7 Jun 2019 20:29:30 +0300 Subject: [PATCH 104/735] Add log error in receivers() --- src/api/control/member.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/api/control/member.rs b/src/api/control/member.rs index d36ca20c1..5f8994b8e 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -10,6 +10,8 @@ use super::{ Element, TryFromElementError, }; +use crate::log::prelude::*; + /// ID of [`Member`]. #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq)] pub struct Id(pub String); @@ -67,7 +69,16 @@ impl Member { self.room_pipeline .iter() .filter_map(|(id, element)| { - MemberSpec::try_from(element).map(|s| (id, s)).ok() + MemberSpec::try_from(element) + .map(|s| (id, s)) + .map_err(|e| { + error!( + "Given not room pipeline into member. Here is \ + error: {:?}", + e + ) + }) + .ok() }) .filter_map(|(id, member)| { if member From a588ec70646bb2e4dd2bf0b1b8b45f9269038b08 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 7 Jun 2019 20:53:55 +0300 Subject: [PATCH 105/735] Return Result in receivers() --- src/api/control/member.rs | 31 +++++++++++++------------------ src/api/control/room.rs | 14 ++++++++++---- src/signalling/room.rs | 15 ++++++++++++++- 3 files changed, 37 insertions(+), 23 deletions(-) diff --git a/src/api/control/member.rs b/src/api/control/member.rs index 5f8994b8e..28778af8f 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -2,6 +2,7 @@ use std::{convert::TryFrom, fmt::Display, sync::Arc}; +use hashbrown::HashMap; use serde::Deserialize; use super::{ @@ -10,8 +11,6 @@ use super::{ Element, TryFromElementError, }; -use crate::log::prelude::*; - /// ID of [`Member`]. #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq)] pub struct Id(pub String); @@ -65,21 +64,17 @@ impl Member { } /// Get all receivers [`Id`] of all [`Member`]'s [`WebRtcPublishEndpoint`]s. - pub fn receivers(&self) -> Vec { - self.room_pipeline - .iter() - .filter_map(|(id, element)| { - MemberSpec::try_from(element) - .map(|s| (id, s)) - .map_err(|e| { - error!( - "Given not room pipeline into member. Here is \ - error: {:?}", - e - ) - }) - .ok() - }) + /// + /// Returns [`TryFromElementError::NotMember`] when not member finded in + /// [`RoomSpec`]'s [`Pipeline`]. + pub fn receivers(&self) -> Result, TryFromElementError> { + let mut members = HashMap::new(); + for (id, element) in self.room_pipeline.iter() { + members.insert(id, MemberSpec::try_from(element)?); + } + + Ok(members + .into_iter() .filter_map(|(id, member)| { if member .play_endpoints() @@ -93,7 +88,7 @@ impl Member { None } }) - .collect() + .collect()) } } diff --git a/src/api/control/room.rs b/src/api/control/room.rs index 54476fa6c..858df0d90 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -112,12 +112,18 @@ mod room_spec_tests { let responder_member_id = MemberId("responder".to_string()); let room_members = room.members().unwrap(); - let caller_receivers = - room_members.get(&caller_member_id).unwrap().receivers(); + let caller_receivers = room_members + .get(&caller_member_id) + .unwrap() + .receivers() + .unwrap(); assert_eq!(caller_receivers, vec![responder_member_id.clone()]); - let responder_receivers = - room_members.get(&responder_member_id).unwrap().receivers(); + let responder_receivers = room_members + .get(&responder_member_id) + .unwrap() + .receivers() + .unwrap(); assert_eq!(responder_receivers, vec![]); } } diff --git a/src/signalling/room.rs b/src/signalling/room.rs index d7b0a69a3..32119ea9a 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -301,8 +301,21 @@ impl Room { let mut need_create = Vec::new(); // connect receivers + let receivers = match member.receivers() { + Ok(r) => r, + Err(e) => { + error!( + "Member {} has wrong room pipeline. Room will be stopped. \ + Here is error: {:?}", + member.id(), + e + ); + ctx.notify(CloseRoom {}); + return; + } + }; let mut already_connected_members = Vec::new(); - for recv_member_id in &member.receivers() { + for recv_member_id in &receivers { if self.participants.member_has_connection(recv_member_id) { if let Some(recv_member) = self.participants.get_member_by_id(recv_member_id) From 51eed5e5b0fa5bbaad4e13fe7ee7e4f98137172a Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 10 Jun 2019 12:39:41 +0300 Subject: [PATCH 106/735] Check publish endpoint existence --- src/api/control/member.rs | 28 +++++++++++++++++++--------- src/media/peer.rs | 6 +++--- src/signalling/room.rs | 9 +++++++-- 3 files changed, 29 insertions(+), 14 deletions(-) diff --git a/src/api/control/member.rs b/src/api/control/member.rs index 28778af8f..beb7f331b 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -54,12 +54,14 @@ impl Member { } /// Returns all [`WebRtcPlayEndpoint`]s of this [`Member`]. - pub fn play_endpoints(&self) -> Vec<&WebRtcPlayEndpoint> { + pub fn play_endpoints(&self) -> HashMap<&String, &WebRtcPlayEndpoint> { self.spec.play_endpoints() } /// Returns all [`WebRtcPublishEndpoint`]s of this [`Member`]. - pub fn publish_endpoints(&self) -> Vec<&WebRtcPublishEndpoint> { + pub fn publish_endpoints( + &self, + ) -> HashMap<&String, &WebRtcPublishEndpoint> { self.spec.publish_endpoints() } @@ -67,6 +69,7 @@ impl Member { /// /// Returns [`TryFromElementError::NotMember`] when not member finded in /// [`RoomSpec`]'s [`Pipeline`]. + #[allow(clippy::block_in_if_condition_stmt)] pub fn receivers(&self) -> Result, TryFromElementError> { let mut members = HashMap::new(); for (id, element) in self.room_pipeline.iter() { @@ -79,7 +82,12 @@ impl Member { if member .play_endpoints() .iter() - .filter(|e| e.src.member_id == self.id) + .filter(|(_, e)| e.src.member_id == self.id) + .filter(|(_, e)| { + self.spec + .publish_endpoints() + .contains_key(&e.src.endpoint_id) + }) .count() > 0 { @@ -105,22 +113,24 @@ pub struct MemberSpec { impl MemberSpec { /// Returns all [`WebRtcPlayEndpoint`]s of this [`MemberSpec`]. - pub fn play_endpoints(&self) -> Vec<&WebRtcPlayEndpoint> { + pub fn play_endpoints(&self) -> HashMap<&String, &WebRtcPlayEndpoint> { self.pipeline .iter() - .filter_map(|(_, e)| match e { - Element::WebRtcPlayEndpoint { spec } => Some(spec), + .filter_map(|(id, e)| match e { + Element::WebRtcPlayEndpoint { spec } => Some((id, spec)), _ => None, }) .collect() } /// Returns all [`WebRtcPublishEndpoint`]s of this [`MemberSpec`]. - pub fn publish_endpoints(&self) -> Vec<&WebRtcPublishEndpoint> { + pub fn publish_endpoints( + &self, + ) -> HashMap<&String, &WebRtcPublishEndpoint> { self.pipeline .iter() - .filter_map(|(_, e)| match e { - Element::WebRtcPublishEndpoint { spec } => Some(spec), + .filter_map(|(id, e)| match e { + Element::WebRtcPublishEndpoint { spec } => Some((id, spec)), _ => None, }) .collect() diff --git a/src/media/peer.rs b/src/media/peer.rs index f20ae656b..afcd03bc8 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -257,7 +257,7 @@ impl Peer { /// ID. pub fn add_publish_endpoints( &mut self, - endpoints: Vec<&WebRtcPublishEndpoint>, + endpoints: HashMap<&String, &WebRtcPublishEndpoint>, track_id_counter: &mut Counter, ) { for _ in endpoints { @@ -278,10 +278,10 @@ impl Peer { /// Add all `partner_peer` related [`WebRtcPlayEndpoint`]s to this [`Peer`]. pub fn add_play_endpoints( &mut self, - endpoints: Vec<&WebRtcPlayEndpoint>, + endpoints: HashMap<&String, &WebRtcPlayEndpoint>, partner_peer: &mut Peer, ) { - for endpoint in endpoints { + for (_, endpoint) in endpoints { if self.context.partner_member == endpoint.src.member_id { partner_peer .get_senders() diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 32119ea9a..37353e50e 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -334,7 +334,7 @@ impl Room { } // connect senders - for play in member.play_endpoints() { + for (_, play) in member.play_endpoints() { let sender_member_id = &play.src.member_id; if already_connected_members.contains(sender_member_id) { continue; @@ -344,7 +344,12 @@ impl Room { if let Some(sender_member) = self.participants.get_member_by_id(sender_member_id) { - need_create.push((&member, sender_member.clone())); + if sender_member + .publish_endpoints() + .contains_key(&play.src.endpoint_id) + { + need_create.push((&member, sender_member.clone())); + } } else { error!( "Try to get member with ID {} which has active \ From 42769908ef2d77d8a875c84a324c23f29976309b Mon Sep 17 00:00:00 2001 From: alexlapa Date: Mon, 10 Jun 2019 14:42:16 +0300 Subject: [PATCH 107/735] add todos --- src/api/control/member.rs | 4 ++++ src/signalling/room.rs | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/api/control/member.rs b/src/api/control/member.rs index 28778af8f..e9744511d 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -63,6 +63,10 @@ impl Member { self.spec.publish_endpoints() } + // TODO: remove this func in favor of extending WebRtcPublishEndpoint with + // list of play endpoints, and play endpoint should have member_id (or maybe + // ref to parent element?) + /// Get all receivers [`Id`] of all [`Member`]'s [`WebRtcPublishEndpoint`]s. /// /// Returns [`TryFromElementError::NotMember`] when not member finded in diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 32119ea9a..79e40b047 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -524,7 +524,9 @@ impl Handler for Room { msg.connection, ); - // Check that user is not reconnecting + // TODO: remove this check, create_peers_with_available_members should + // be idempotent + if self.peers.get_peers_by_member_id(&msg.member_id).is_empty() { self.create_peers_with_available_members(&msg.member_id, ctx); } From 23b6a7b152c2c19621e7484cfb0013a4b112809a Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 10 Jun 2019 14:57:53 +0300 Subject: [PATCH 108/735] Remove check create_peers_with_available_members --- src/signalling/room.rs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 154765e39..73541987c 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -529,12 +529,7 @@ impl Handler for Room { msg.connection, ); - // TODO: remove this check, create_peers_with_available_members should - // be idempotent - - if self.peers.get_peers_by_member_id(&msg.member_id).is_empty() { - self.create_peers_with_available_members(&msg.member_id, ctx); - } + self.create_peers_with_available_members(&msg.member_id, ctx); Box::new(wrap_future(future::ok(()))) } From d6d78a31a1499a34530ea340811bdbafda3ae99c Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 10 Jun 2019 18:58:31 +0300 Subject: [PATCH 109/735] Separate spec Member and Participant --- src/api/control/member.rs | 85 +------------------------- src/api/control/mod.rs | 2 +- src/api/control/pipeline.rs | 2 +- src/api/control/room.rs | 15 ++--- src/media/peer.rs | 8 +-- src/signalling/mod.rs | 2 + src/signalling/participants.rs | 25 ++++---- src/signalling/peers.rs | 19 +++--- src/signalling/room.rs | 58 +++++++++--------- src/signalling/state/member.rs | 105 +++++++++++++++++++++++++++++++++ src/signalling/state/mod.rs | 1 + 11 files changed, 173 insertions(+), 149 deletions(-) create mode 100644 src/signalling/state/member.rs create mode 100644 src/signalling/state/mod.rs diff --git a/src/api/control/member.rs b/src/api/control/member.rs index 9454e987a..93552d401 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -1,6 +1,6 @@ //! Member definitions and implementations. -use std::{convert::TryFrom, fmt::Display, sync::Arc}; +use std::{convert::TryFrom, fmt::Display}; use hashbrown::HashMap; use serde::Deserialize; @@ -21,89 +21,6 @@ impl Display for Id { } } -/// Media server user with its ID, credentials and spec. -#[derive(Clone, Debug)] -pub struct Member { - /// ID of [`Member`]. - id: Id, - - /// Control API specification of this [`Member`]. - spec: Arc, - - /// Pipeline of [`Room`] in which this [`Member`] is located. - room_pipeline: Arc, -} - -impl Member { - pub fn new(id: Id, spec: MemberSpec, room_pipeline: Arc) -> Self { - Self { - spec: Arc::new(spec), - id, - room_pipeline, - } - } - - /// Returns [`Id`] of [`Member`]. - pub fn id(&self) -> &Id { - &self.id - } - - /// Returns credentials to authorize [`Member`] with. - pub fn credentials(&self) -> &str { - self.spec.credentials() - } - - /// Returns all [`WebRtcPlayEndpoint`]s of this [`Member`]. - pub fn play_endpoints(&self) -> HashMap<&String, &WebRtcPlayEndpoint> { - self.spec.play_endpoints() - } - - /// Returns all [`WebRtcPublishEndpoint`]s of this [`Member`]. - pub fn publish_endpoints( - &self, - ) -> HashMap<&String, &WebRtcPublishEndpoint> { - self.spec.publish_endpoints() - } - - // TODO: remove this func in favor of extending WebRtcPublishEndpoint with - // list of play endpoints, and play endpoint should have member_id (or maybe - // ref to parent element?) - - /// Get all receivers [`Id`] of all [`Member`]'s [`WebRtcPublishEndpoint`]s. - /// - /// Returns [`TryFromElementError::NotMember`] when not member finded in - /// [`RoomSpec`]'s [`Pipeline`]. - #[allow(clippy::block_in_if_condition_stmt)] - pub fn receivers(&self) -> Result, TryFromElementError> { - let mut members = HashMap::new(); - for (id, element) in self.room_pipeline.iter() { - members.insert(id, MemberSpec::try_from(element)?); - } - - Ok(members - .into_iter() - .filter_map(|(id, member)| { - if member - .play_endpoints() - .iter() - .filter(|(_, e)| e.src.member_id == self.id) - .filter(|(_, e)| { - self.spec - .publish_endpoints() - .contains_key(&e.src.endpoint_id) - }) - .count() - > 0 - { - Some(Id(id.clone())) - } else { - None - } - }) - .collect()) - } -} - /// Newtype for [`Element::Member`] variant. #[allow(clippy::module_name_repetitions)] #[derive(Clone, Debug)] diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index 9faa565c8..a93966747 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -17,7 +17,7 @@ use self::{ pub use self::{ endpoint::Endpoint, - member::{Id as MemberId, Member, MemberSpec}, + member::{Id as MemberId, MemberSpec}, room::{Id as RoomId, RoomSpec}, }; diff --git a/src/api/control/pipeline.rs b/src/api/control/pipeline.rs index d33b33b46..248219e6e 100644 --- a/src/api/control/pipeline.rs +++ b/src/api/control/pipeline.rs @@ -15,7 +15,7 @@ use crate::api::control::Element; /// Entity that represents some pipeline of spec. #[derive(Clone, Deserialize, Debug)] pub struct Pipeline { - pipeline: HashMap, + pub pipeline: HashMap, } impl Pipeline { diff --git a/src/api/control/room.rs b/src/api/control/room.rs index 858df0d90..8d40521fe 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -6,7 +6,7 @@ use hashbrown::HashMap; use serde::Deserialize; use super::{ - pipeline::Pipeline, Element, Member, MemberId, MemberSpec, + member::MemberSpec, pipeline::Pipeline, Element, MemberId, TryFromElementError, }; @@ -19,24 +19,21 @@ pub struct Id(pub String); #[allow(clippy::module_name_repetitions)] #[derive(Clone, Debug)] pub struct RoomSpec { - id: Id, - pipeline: Arc, + pub id: Id, + pub pipeline: Arc, } impl RoomSpec { /// Returns all [`Member`]s of this [`RoomSpec`]. pub fn members( &self, - ) -> Result, TryFromElementError> { - let mut members = HashMap::new(); + ) -> Result, TryFromElementError> { + let mut members: HashMap = HashMap::new(); for (control_id, element) in self.pipeline.iter() { let member_spec = MemberSpec::try_from(element)?; let member_id = MemberId(control_id.clone()); - members.insert( - member_id.clone(), - Member::new(member_id, member_spec, Arc::clone(&self.pipeline)), - ); + members.insert(member_id.clone(), member_spec); } Ok(members) diff --git a/src/media/peer.rs b/src/media/peer.rs index afcd03bc8..e42fd9ed0 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -14,11 +14,11 @@ use std::{convert::TryFrom, fmt::Display, sync::Arc}; use crate::{ api::control::{ - endpoint::{WebRtcPlayEndpoint, WebRtcPublishEndpoint}, MemberId, }, media::{MediaTrack, TrackId}, signalling::peers::Counter, + signalling::state::member::Participant, }; /// Newly initialized [`Peer`] ready to signalling. @@ -257,7 +257,7 @@ impl Peer { /// ID. pub fn add_publish_endpoints( &mut self, - endpoints: HashMap<&String, &WebRtcPublishEndpoint>, + endpoints: HashMap, track_id_counter: &mut Counter, ) { for _ in endpoints { @@ -278,11 +278,11 @@ impl Peer { /// Add all `partner_peer` related [`WebRtcPlayEndpoint`]s to this [`Peer`]. pub fn add_play_endpoints( &mut self, - endpoints: HashMap<&String, &WebRtcPlayEndpoint>, + endpoints: HashMap, partner_peer: &mut Peer, ) { for (_, endpoint) in endpoints { - if self.context.partner_member == endpoint.src.member_id { + if self.context.partner_member == endpoint.id() { partner_peer .get_senders() .into_iter() diff --git a/src/signalling/mod.rs b/src/signalling/mod.rs index 3befe6cdd..4848ab631 100644 --- a/src/signalling/mod.rs +++ b/src/signalling/mod.rs @@ -1,3 +1,5 @@ +pub mod state; + pub mod participants; pub mod peers; pub mod room; diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 968cd44d5..7e044a4bc 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -18,10 +18,10 @@ use crate::{ AuthorizationError, ClosedReason, EventMessage, RpcConnection, RpcConnectionClosed, }, - control::{Member, MemberId, RoomSpec, TryFromElementError}, + control::{MemberId, RoomSpec, TryFromElementError}, }, log::prelude::*, - signalling::{room::RoomError, Room}, + signalling::{room::RoomError, state::member::Participant, Room}, }; /// Participant is [`Member`] with [`RpcConnection`]. [`ParticipantService`] @@ -30,7 +30,7 @@ use crate::{ #[derive(Debug)] pub struct ParticipantService { /// [`Member`]s which currently are present in this [`Room`]. - members: HashMap, + members: HashMap, /// Established [`RpcConnection`]s of [`Member`]s in this [`Room`]. // TODO: Replace Box> with enum, @@ -53,9 +53,9 @@ impl ParticipantService { room_spec: &RoomSpec, reconnect_timeout: Duration, ) -> Result { - let members = room_spec.members()?; - - debug!("Created room with {:?} members.", members); + let members = Participant::get_store(room_spec); + // TODO: more informative msg + debug!("Created room with {:?} members.", members.iter().map(|(id, _)| id).collect::>()); Ok(Self { members, @@ -66,8 +66,11 @@ impl ParticipantService { } /// Lookup [`Member`] by provided id. - pub fn get_member_by_id(&self, id: &MemberId) -> Option<&Member> { - self.members.get(id) + pub fn get_member_by_id( + &self, + id: &MemberId, + ) -> Option { + self.members.get(id).cloned() } /// Lookup [`Member`] by provided id and credentials. Returns @@ -78,11 +81,11 @@ impl ParticipantService { &self, member_id: &MemberId, credentials: &str, - ) -> Result<&Member, AuthorizationError> { + ) -> Result { match self.members.get(member_id) { - Some(ref member) => { + Some(member) => { if member.credentials().eq(credentials) { - Ok(member) + Ok(member.clone()) } else { Err(AuthorizationError::InvalidCredentials) } diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index 48bd4c5ce..56229ea3b 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -9,9 +9,12 @@ use actix::{AsyncContext as _, Context}; use hashbrown::HashMap; use crate::{ - api::control::{Member, MemberId}, + api::control::MemberId, media::{Peer, PeerId, PeerStateMachine}, - signalling::room::{PeersRemoved, Room, RoomError}, + signalling::{ + state::member::Participant, + room::{ PeersRemoved, Room, RoomError}, + }, }; #[derive(Debug)] @@ -69,8 +72,8 @@ impl PeerRepository { /// Returns IDs of created [`Peer`]s. `(first_peer_id, second_peer_id)`. pub fn create_peers( &mut self, - first_member: &Member, - second_member: &Member, + first_member: &Participant, + second_member: &Participant, ) -> (u64, u64) { let first_peer_id = self.peers_count.next_id(); let second_peer_id = self.peers_count.next_id(); @@ -89,20 +92,20 @@ impl PeerRepository { ); first_peer.add_publish_endpoints( - first_member.publish_endpoints(), + first_member.publish(), &mut self.tracks_count, ); second_peer.add_publish_endpoints( - second_member.publish_endpoints(), + second_member.publish(), &mut self.tracks_count, ); first_peer.add_play_endpoints( - first_member.play_endpoints(), + first_member.play(), &mut second_peer, ); second_peer.add_play_endpoints( - second_member.play_endpoints(), + second_member.play(), &mut first_peer, ); diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 73541987c..dc45ff2b3 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -18,14 +18,14 @@ use crate::{ AuthorizationError, Authorize, ClosedReason, CommandMessage, RpcConnectionClosed, RpcConnectionEstablished, }, - control::{Member, MemberId, RoomId, RoomSpec, TryFromElementError}, + control::{MemberId, RoomId, RoomSpec, TryFromElementError}, }, log::prelude::*, media::{ New, Peer, PeerId, PeerStateError, PeerStateMachine, WaitLocalHaveRemote, WaitLocalSdp, WaitRemoteSdp, }, - signalling::{participants::ParticipantService, peers::PeerRepository}, + signalling::{participants::ParticipantService, peers::PeerRepository, state::member::Participant}, }; /// Ergonomic type alias for using [`ActorFuture`] for [`Room`]. @@ -256,8 +256,8 @@ impl Room { /// spec. fn create_and_interconnect_peers( &mut self, - first_member: &Member, - second_member: &Member, + first_member: &Participant, + second_member: &Participant, ctx: &mut ::Context, ) { debug!( @@ -301,24 +301,25 @@ impl Room { let mut need_create = Vec::new(); // connect receivers - let receivers = match member.receivers() { - Ok(r) => r, - Err(e) => { - error!( - "Member {} has wrong room pipeline. Room will be stopped. \ - Here is error: {:?}", - member.id(), - e - ); - ctx.notify(CloseRoom {}); - return; - } - }; +// let (_, receivers) = match member.publish() { +// Ok(r) => r, +// Err(e) => { +// error!( +// "Member {} has wrong room pipeline. Room will be stopped. \ +// Here is error: {:?}", +// member.lock().unwrap().borrow().id(), +// e +// ); +// ctx.notify(CloseRoom {}); +// return; +// } +// }; + let receivers = member.publish(); let mut already_connected_members = Vec::new(); - for recv_member_id in &receivers { - if self.participants.member_has_connection(recv_member_id) { + for (recv_member_id, _) in receivers { + if self.participants.member_has_connection(&recv_member_id) { if let Some(recv_member) = - self.participants.get_member_by_id(recv_member_id) + self.participants.get_member_by_id(&recv_member_id) { already_connected_members.push(recv_member_id.clone()); need_create.push((&member, recv_member.clone())); @@ -334,22 +335,17 @@ impl Room { } // connect senders - for (_, play) in member.play_endpoints() { - let sender_member_id = &play.src.member_id; - if already_connected_members.contains(sender_member_id) { + for (_, play) in member.play() { + let sender_member_id = play.id(); + if already_connected_members.contains(&sender_member_id) { continue; } - if self.participants.member_has_connection(sender_member_id) { + if self.participants.member_has_connection(&sender_member_id) { if let Some(sender_member) = - self.participants.get_member_by_id(sender_member_id) + self.participants.get_member_by_id(&sender_member_id) { - if sender_member - .publish_endpoints() - .contains_key(&play.src.endpoint_id) - { - need_create.push((&member, sender_member.clone())); - } + need_create.push((&member, sender_member.clone())); } else { error!( "Try to get member with ID {} which has active \ diff --git a/src/signalling/state/member.rs b/src/signalling/state/member.rs new file mode 100644 index 000000000..9140986c3 --- /dev/null +++ b/src/signalling/state/member.rs @@ -0,0 +1,105 @@ +use std::convert::TryFrom; +use std::sync::{Arc, Mutex}; + +use crate::api::control::{ + MemberId, MemberSpec, RoomSpec, +}; +use hashbrown::HashMap; +use std::cell::RefCell; + +pub struct Id(String); + +#[derive(Debug, Clone)] +pub struct Participant(Arc>>); + +#[derive(Debug)] +pub struct ParticipantInner { + id: MemberId, + senders: HashMap, + receivers: HashMap, + credentials: String, +} + +impl Participant { + pub fn id(&self) -> MemberId { + self.0.lock().unwrap().borrow().id.clone() + } + + pub fn load( + &self, + room_spec: &RoomSpec, + store: &HashMap, + ) { + self.0.lock().unwrap().borrow_mut().load(room_spec, store); + } + + pub fn get_store(room_spec: &RoomSpec) -> HashMap { + ParticipantInner::get_store(room_spec) + } + + pub fn credentials(&self) -> String { + self.0.lock().unwrap().borrow().credentials.clone() + } + + pub fn publish(&self) -> HashMap { + self.0.lock().unwrap().borrow().senders.clone() + } + + pub fn play(&self) -> HashMap { + self.0.lock().unwrap().borrow().receivers.clone() + } +} + +impl ParticipantInner { + pub fn new(id: MemberId, credentials: String) -> Self { + Self { + id, + senders: HashMap::new(), + receivers: HashMap::new(), + credentials, + } + } + + pub fn load( + &mut self, + room_spec: &RoomSpec, + store: &HashMap, + ) { + + let spec = MemberSpec::try_from( + room_spec.pipeline.pipeline.get(&self.id.0).unwrap(), + ) + .unwrap(); + spec.play_endpoints().iter().for_each(|(_, p)| { + let sender_participant = + store.get(&MemberId(p.src.member_id.to_string())).unwrap(); + self.receivers.insert( + sender_participant.id().clone(), + sender_participant.clone(), + ); + }); + } + + pub fn get_store(room_spec: &RoomSpec) -> HashMap { + let members = room_spec.members().unwrap(); + let mut participants = HashMap::new(); + + for (id, member) in &members { + participants.insert( + id.clone(), + Participant(Arc::new(Mutex::new(RefCell::new( + Self::new( + id.clone(), + member.credentials().to_string(), + ), + )))), + ); + } + + for (_, participant) in &participants { + participant.load(room_spec, &participants); + } + + participants + } +} diff --git a/src/signalling/state/mod.rs b/src/signalling/state/mod.rs new file mode 100644 index 000000000..0dd2a0385 --- /dev/null +++ b/src/signalling/state/mod.rs @@ -0,0 +1 @@ +pub mod member; From 5bed3e50acae135455d093dc552f63dfd89ba6a6 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 10 Jun 2019 19:22:33 +0300 Subject: [PATCH 110/735] Naive receivers implementation --- src/api/control/room.rs | 120 ++++++++++++++++----------------- src/media/peer.rs | 4 +- src/signalling/participants.rs | 10 +-- src/signalling/peers.rs | 12 +--- src/signalling/room.rs | 31 +++++---- src/signalling/state/member.rs | 43 +++++++----- 6 files changed, 113 insertions(+), 107 deletions(-) diff --git a/src/api/control/room.rs b/src/api/control/room.rs index 8d40521fe..7f2146e9c 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -63,64 +63,64 @@ impl TryFrom<&Element> for RoomSpec { mod room_spec_tests { use super::*; - #[test] - fn properly_get_receivers_for_member() { - let spec = r#" - kind: Room - id: test-call - spec: - pipeline: - caller: - kind: Member - credentials: test - spec: - pipeline: - publish: - kind: WebRtcPublishEndpoint - spec: - p2p: Always - some-member: - kind: Member - credentials: test - spec: - pipeline: - publish: - kind: WebRtcPublishEndpoint - spec: - p2p: Always - responder: - kind: Member - credentials: test - spec: - pipeline: - play: - kind: WebRtcPlayEndpoint - spec: - src: "local://test-call/caller/publish" - play2: - kind: WebRtcPlayEndpoint - spec: - src: "local://test-call/some-member/publish" - "#; - let spec: Element = serde_yaml::from_str(spec).unwrap(); - let room = RoomSpec::try_from(&spec).unwrap(); - - let caller_member_id = MemberId("caller".to_string()); - let responder_member_id = MemberId("responder".to_string()); - - let room_members = room.members().unwrap(); - let caller_receivers = room_members - .get(&caller_member_id) - .unwrap() - .receivers() - .unwrap(); - assert_eq!(caller_receivers, vec![responder_member_id.clone()]); - - let responder_receivers = room_members - .get(&responder_member_id) - .unwrap() - .receivers() - .unwrap(); - assert_eq!(responder_receivers, vec![]); - } + // #[test] + // fn properly_get_receivers_for_member() { + // let spec = r#" + // kind: Room + // id: test-call + // spec: + // pipeline: + // caller: + // kind: Member + // credentials: test + // spec: + // pipeline: + // publish: + // kind: WebRtcPublishEndpoint + // spec: + // p2p: Always + // some-member: + // kind: Member + // credentials: test + // spec: + // pipeline: + // publish: + // kind: WebRtcPublishEndpoint + // spec: + // p2p: Always + // responder: + // kind: Member + // credentials: test + // spec: + // pipeline: + // play: + // kind: WebRtcPlayEndpoint + // spec: + // src: "local://test-call/caller/publish" + // play2: + // kind: WebRtcPlayEndpoint + // spec: + // src: "local://test-call/some-member/publish" + // "#; + // let spec: Element = serde_yaml::from_str(spec).unwrap(); + // let room = RoomSpec::try_from(&spec).unwrap(); + // + // let caller_member_id = MemberId("caller".to_string()); + // let responder_member_id = MemberId("responder".to_string()); + // + // let room_members = room.members().unwrap(); + // let caller_receivers = room_members + // .get(&caller_member_id) + // .unwrap() + // .receivers() + // .unwrap(); + // assert_eq!(caller_receivers, vec![responder_member_id.clone()]); + // + // let responder_receivers = room_members + // .get(&responder_member_id) + // .unwrap() + // .receivers() + // .unwrap(); + // assert_eq!(responder_receivers, vec![]); + // } } diff --git a/src/media/peer.rs b/src/media/peer.rs index e42fd9ed0..b011e4e69 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -13,9 +13,7 @@ use medea_macro::enum_delegate; use std::{convert::TryFrom, fmt::Display, sync::Arc}; use crate::{ - api::control::{ - MemberId, - }, + api::control::MemberId, media::{MediaTrack, TrackId}, signalling::peers::Counter, signalling::state::member::Participant, diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 7e044a4bc..c80351efd 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -55,7 +55,10 @@ impl ParticipantService { ) -> Result { let members = Participant::get_store(room_spec); // TODO: more informative msg - debug!("Created room with {:?} members.", members.iter().map(|(id, _)| id).collect::>()); + debug!( + "Created room with {:?} members.", + members.iter().map(|(id, _)| id).collect::>() + ); Ok(Self { members, @@ -66,10 +69,7 @@ impl ParticipantService { } /// Lookup [`Member`] by provided id. - pub fn get_member_by_id( - &self, - id: &MemberId, - ) -> Option { + pub fn get_member_by_id(&self, id: &MemberId) -> Option { self.members.get(id).cloned() } diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index 56229ea3b..dbe8a192c 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -12,8 +12,8 @@ use crate::{ api::control::MemberId, media::{Peer, PeerId, PeerStateMachine}, signalling::{ + room::{PeersRemoved, Room, RoomError}, state::member::Participant, - room::{ PeersRemoved, Room, RoomError}, }, }; @@ -100,14 +100,8 @@ impl PeerRepository { &mut self.tracks_count, ); - first_peer.add_play_endpoints( - first_member.play(), - &mut second_peer, - ); - second_peer.add_play_endpoints( - second_member.play(), - &mut first_peer, - ); + first_peer.add_play_endpoints(first_member.play(), &mut second_peer); + second_peer.add_play_endpoints(second_member.play(), &mut first_peer); self.add_peer(first_peer_id, first_peer); self.add_peer(second_peer_id, second_peer); diff --git a/src/signalling/room.rs b/src/signalling/room.rs index dc45ff2b3..32db3a561 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -25,7 +25,10 @@ use crate::{ New, Peer, PeerId, PeerStateError, PeerStateMachine, WaitLocalHaveRemote, WaitLocalSdp, WaitRemoteSdp, }, - signalling::{participants::ParticipantService, peers::PeerRepository, state::member::Participant}, + signalling::{ + participants::ParticipantService, peers::PeerRepository, + state::member::Participant, + }, }; /// Ergonomic type alias for using [`ActorFuture`] for [`Room`]. @@ -301,19 +304,19 @@ impl Room { let mut need_create = Vec::new(); // connect receivers -// let (_, receivers) = match member.publish() { -// Ok(r) => r, -// Err(e) => { -// error!( -// "Member {} has wrong room pipeline. Room will be stopped. \ -// Here is error: {:?}", -// member.lock().unwrap().borrow().id(), -// e -// ); -// ctx.notify(CloseRoom {}); -// return; -// } -// }; + // let (_, receivers) = match member.publish() { + // Ok(r) => r, + // Err(e) => { + // error!( + // "Member {} has wrong room pipeline. Room will be + // stopped. \ Here is error: {:?}", + // member.lock().unwrap().borrow().id(), + // e + // ); + // ctx.notify(CloseRoom {}); + // return; + // } + // }; let receivers = member.publish(); let mut already_connected_members = Vec::new(); for (recv_member_id, _) in receivers { diff --git a/src/signalling/state/member.rs b/src/signalling/state/member.rs index 9140986c3..1611296dd 100644 --- a/src/signalling/state/member.rs +++ b/src/signalling/state/member.rs @@ -1,9 +1,7 @@ use std::convert::TryFrom; use std::sync::{Arc, Mutex}; -use crate::api::control::{ - MemberId, MemberSpec, RoomSpec, -}; +use crate::api::control::{MemberId, MemberSpec, RoomSpec}; use hashbrown::HashMap; use std::cell::RefCell; @@ -15,7 +13,9 @@ pub struct Participant(Arc>>); #[derive(Debug)] pub struct ParticipantInner { id: MemberId, + // TODO(evdokimovs): there is memory leak because Arc. senders: HashMap, + // TODO(evdokimovs): there is memory leak because Arc. receivers: HashMap, credentials: String, } @@ -25,11 +25,7 @@ impl Participant { self.0.lock().unwrap().borrow().id.clone() } - pub fn load( - &self, - room_spec: &RoomSpec, - store: &HashMap, - ) { + pub fn load(&self, room_spec: &RoomSpec, store: &HashMap) { self.0.lock().unwrap().borrow_mut().load(room_spec, store); } @@ -65,7 +61,6 @@ impl ParticipantInner { room_spec: &RoomSpec, store: &HashMap, ) { - let spec = MemberSpec::try_from( room_spec.pipeline.pipeline.get(&self.id.0).unwrap(), ) @@ -73,11 +68,27 @@ impl ParticipantInner { spec.play_endpoints().iter().for_each(|(_, p)| { let sender_participant = store.get(&MemberId(p.src.member_id.to_string())).unwrap(); - self.receivers.insert( + self.senders.insert( sender_participant.id().clone(), sender_participant.clone(), ); }); + + let self_id = self.id.clone(); + + for (id, element) in room_spec.pipeline.iter() { + let member = MemberSpec::try_from(element).unwrap(); + + member + .play_endpoints() + .into_iter() + .filter(|(_, endpoint)| endpoint.src.member_id == self_id) + .for_each(|_| { + let member_id = MemberId(id.clone()); + let participant = store.get(&member_id).unwrap().clone(); + self.receivers.insert(member_id, participant); + }); + } } pub fn get_store(room_spec: &RoomSpec) -> HashMap { @@ -87,12 +98,10 @@ impl ParticipantInner { for (id, member) in &members { participants.insert( id.clone(), - Participant(Arc::new(Mutex::new(RefCell::new( - Self::new( - id.clone(), - member.credentials().to_string(), - ), - )))), + Participant(Arc::new(Mutex::new(RefCell::new(Self::new( + id.clone(), + member.credentials().to_string(), + ))))), ); } @@ -100,6 +109,8 @@ impl ParticipantInner { participant.load(room_spec, &participants); } + println!("\n\n\n\n{:#?}\n\n\n\n", participants); + participants } } From 79a650265b5c2d607a6ce3be919e2e5184bf3adb Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 10 Jun 2019 19:40:10 +0300 Subject: [PATCH 111/735] Fix signalling test --- src/media/peer.rs | 2 ++ src/signalling/state/member.rs | 8 +++++--- tests/signalling.rs | 6 +++--- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/media/peer.rs b/src/media/peer.rs index b011e4e69..2271df02a 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -253,6 +253,7 @@ impl Peer { /// /// This use `track_id_counter` counter for generating new [`MediaTrack`] /// ID. + // TODO (evdokimovs): Upd doc pub fn add_publish_endpoints( &mut self, endpoints: HashMap, @@ -274,6 +275,7 @@ impl Peer { } /// Add all `partner_peer` related [`WebRtcPlayEndpoint`]s to this [`Peer`]. + // TODO (evdokimovs): Upd doc pub fn add_play_endpoints( &mut self, endpoints: HashMap, diff --git a/src/signalling/state/member.rs b/src/signalling/state/member.rs index 1611296dd..c4f724c54 100644 --- a/src/signalling/state/member.rs +++ b/src/signalling/state/member.rs @@ -13,9 +13,9 @@ pub struct Participant(Arc>>); #[derive(Debug)] pub struct ParticipantInner { id: MemberId, - // TODO(evdokimovs): there is memory leak because Arc. + // TODO (evdokimovs): there is memory leak because Arc. senders: HashMap, - // TODO(evdokimovs): there is memory leak because Arc. + // TODO (evdokimovs): there is memory leak because Arc. receivers: HashMap, credentials: String, } @@ -109,8 +109,10 @@ impl ParticipantInner { participant.load(room_spec, &participants); } - println!("\n\n\n\n{:#?}\n\n\n\n", participants); +// println!("\n\n\n\n{:#?}\n\n\n\n", participants); participants } } + +// TODO (evdokimovs): add Participant unit tests diff --git a/tests/signalling.rs b/tests/signalling.rs index 0cda00cdd..510fcd65b 100644 --- a/tests/signalling.rs +++ b/tests/signalling.rs @@ -287,7 +287,7 @@ fn three_members_p2p_video_call() { Event::PeerCreated { peer_id, tracks, .. } => { - assert_eq!(tracks.len(), 4); + assert_eq!(tracks.len(), 8); let recv_count = tracks .iter() .filter_map(|t| match &t.direction { @@ -298,7 +298,7 @@ fn three_members_p2p_video_call() { assert_ne!(sender, peer_id); }) .count(); - assert_eq!(recv_count, 2); + assert_eq!(recv_count, 4); let send_count = tracks .iter() @@ -313,7 +313,7 @@ fn three_members_p2p_video_call() { assert_eq!(receivers.len(), 1); }) .count(); - assert_eq!(send_count, 2); + assert_eq!(send_count, 4); } _ => (), }); From 07d43ca293f257b3feaa345dc56b28f1603c56ad Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 10 Jun 2019 20:25:17 +0300 Subject: [PATCH 112/735] WIP rewrite using endpoints --- src/signalling/peers.rs | 6 +- src/signalling/room.rs | 2 +- src/signalling/state/endpoint.rs | 25 +++++++++ src/signalling/state/member.rs | 96 ++++++++++++++++++++++++++------ src/signalling/state/mod.rs | 1 + 5 files changed, 110 insertions(+), 20 deletions(-) create mode 100644 src/signalling/state/endpoint.rs diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index dbe8a192c..47db0ee24 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -100,8 +100,10 @@ impl PeerRepository { &mut self.tracks_count, ); - first_peer.add_play_endpoints(first_member.play(), &mut second_peer); - second_peer.add_play_endpoints(second_member.play(), &mut first_peer); + first_peer + .add_play_endpoints(first_member.receivers(), &mut second_peer); + second_peer + .add_play_endpoints(second_member.receivers(), &mut first_peer); self.add_peer(first_peer_id, first_peer); self.add_peer(second_peer_id, second_peer); diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 32db3a561..b1e000da8 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -338,7 +338,7 @@ impl Room { } // connect senders - for (_, play) in member.play() { + for (_, play) in member.receivers() { let sender_member_id = play.id(); if already_connected_members.contains(&sender_member_id) { continue; diff --git a/src/signalling/state/endpoint.rs b/src/signalling/state/endpoint.rs new file mode 100644 index 000000000..d866d7c52 --- /dev/null +++ b/src/signalling/state/endpoint.rs @@ -0,0 +1,25 @@ +use super::member::Participant; +use crate::api::control::endpoint::SrcUri; +use std::sync::Arc; + +#[derive(Debug, Clone)] +pub struct Id(String); + +#[derive(Debug, Clone)] +pub enum P2pMode { + Always, +} + +#[derive(Debug, Clone)] +pub struct WebRtcPlayEndpoint { + pub src: SrcUri, + pub publisher: Arc, + pub participant: Participant, +} + +#[derive(Debug, Clone)] +pub struct WebRtcPublishEndpoint { + pub p2p: P2pMode, + pub receivers: Vec>, + pub participant: Participant, +} diff --git a/src/signalling/state/member.rs b/src/signalling/state/member.rs index c4f724c54..5a836c9cf 100644 --- a/src/signalling/state/member.rs +++ b/src/signalling/state/member.rs @@ -5,7 +5,9 @@ use crate::api::control::{MemberId, MemberSpec, RoomSpec}; use hashbrown::HashMap; use std::cell::RefCell; -pub struct Id(String); +use super::endpoint::{ + Id as EndpointId, P2pMode, WebRtcPlayEndpoint, WebRtcPublishEndpoint, +}; #[derive(Debug, Clone)] pub struct Participant(Arc>>); @@ -14,9 +16,9 @@ pub struct Participant(Arc>>); pub struct ParticipantInner { id: MemberId, // TODO (evdokimovs): there is memory leak because Arc. - senders: HashMap, + send: HashMap>, // TODO (evdokimovs): there is memory leak because Arc. - receivers: HashMap, + recv: HashMap>, credentials: String, } @@ -37,12 +39,47 @@ impl Participant { self.0.lock().unwrap().borrow().credentials.clone() } - pub fn publish(&self) -> HashMap { - self.0.lock().unwrap().borrow().senders.clone() + pub fn publish(&self) -> HashMap> { + self.0.lock().unwrap().borrow().send.clone() } - pub fn play(&self) -> HashMap { - self.0.lock().unwrap().borrow().receivers.clone() + pub fn receivers(&self) -> HashMap> { + self.0.lock().unwrap().borrow().recv.clone() + } + + pub fn add_receiver( + &self, + id: EndpointId, + endpoint: Arc, + ) { + self.0 + .lock() + .unwrap() + .borrow_mut() + .recv + .insert(id, endpoint); + } + + pub fn add_recv_to_send( + &self, + id: EndpointId, + endpoint: Arc, + ) { + self.0 + .lock() + .unwrap() + .borrow_mut() + .send + .entry(id) + .or_insert(Vec::new()) + .push(endpoint) + } + + pub fn get_publisher( + &self, + id: &EndpointId, + ) -> Option> { + self.0.lock().unwrap().borrow().send.get(id) } } @@ -50,8 +87,8 @@ impl ParticipantInner { pub fn new(id: MemberId, credentials: String) -> Self { Self { id, - senders: HashMap::new(), - receivers: HashMap::new(), + send: HashMap::new(), + recv: HashMap::new(), credentials, } } @@ -65,16 +102,42 @@ impl ParticipantInner { room_spec.pipeline.pipeline.get(&self.id.0).unwrap(), ) .unwrap(); + let me = store.get(&self.id).unwrap(); spec.play_endpoints().iter().for_each(|(_, p)| { let sender_participant = store.get(&MemberId(p.src.member_id.to_string())).unwrap(); - self.senders.insert( - sender_participant.id().clone(), - sender_participant.clone(), - ); - }); - let self_id = self.id.clone(); + let publisher = WebRtcPublishEndpoint { + participant: sender_participant.clone(), + receivers: Vec::new(), + p2p: P2pMode::Always, + }; + + match sender_participant + .get_publisher(&EndpointId(p.src.endpoint_id.to_string())) + { + Some(publisher) => { + WebRtcPlayEndpoint { + participant: me, + publisher, + src: p.src, + } + + // TODO: Mutate publisher here + } + None => { + // Create Publisher + // create play + // add play to publisher + // insert publisher into participant + } + } + + self.recv.push(WebRtcPlayEndpoint { + src: p.src, + publisher: sender_participant.clone(), + }); + }); for (id, element) in room_spec.pipeline.iter() { let member = MemberSpec::try_from(element).unwrap(); @@ -86,7 +149,6 @@ impl ParticipantInner { .for_each(|_| { let member_id = MemberId(id.clone()); let participant = store.get(&member_id).unwrap().clone(); - self.receivers.insert(member_id, participant); }); } } @@ -109,7 +171,7 @@ impl ParticipantInner { participant.load(room_spec, &participants); } -// println!("\n\n\n\n{:#?}\n\n\n\n", participants); + // println!("\n\n\n\n{:#?}\n\n\n\n", participants); participants } diff --git a/src/signalling/state/mod.rs b/src/signalling/state/mod.rs index 0dd2a0385..bcbf282ff 100644 --- a/src/signalling/state/mod.rs +++ b/src/signalling/state/mod.rs @@ -1 +1,2 @@ +pub mod endpoint; pub mod member; From 08ec210ddf299022a5a1b5f581f7bac36f2da946 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 11 Jun 2019 13:06:33 +0300 Subject: [PATCH 113/735] WIP deadlocked implementation --- src/media/peer.rs | 13 ++-- src/signalling/room.rs | 15 ++-- src/signalling/state/endpoint.rs | 113 ++++++++++++++++++++++++++--- src/signalling/state/member.rs | 120 ++++++++++++++++--------------- 4 files changed, 183 insertions(+), 78 deletions(-) diff --git a/src/media/peer.rs b/src/media/peer.rs index 2271df02a..78ecdeb8d 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -16,7 +16,12 @@ use crate::{ api::control::MemberId, media::{MediaTrack, TrackId}, signalling::peers::Counter, - signalling::state::member::Participant, + signalling::state::{ + endpoint::{ + Id as EndpointId, WebRtcPlayEndpoint, WebRtcPublishEndpoint, + }, + member::Participant, + }, }; /// Newly initialized [`Peer`] ready to signalling. @@ -256,7 +261,7 @@ impl Peer { // TODO (evdokimovs): Upd doc pub fn add_publish_endpoints( &mut self, - endpoints: HashMap, + endpoints: HashMap, track_id_counter: &mut Counter, ) { for _ in endpoints { @@ -278,11 +283,11 @@ impl Peer { // TODO (evdokimovs): Upd doc pub fn add_play_endpoints( &mut self, - endpoints: HashMap, + endpoints: HashMap, partner_peer: &mut Peer, ) { for (_, endpoint) in endpoints { - if self.context.partner_member == endpoint.id() { + if self.context.partner_member == endpoint.src().member_id { partner_peer .get_senders() .into_iter() diff --git a/src/signalling/room.rs b/src/signalling/room.rs index b1e000da8..79139c968 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -319,18 +319,21 @@ impl Room { // }; let receivers = member.publish(); let mut already_connected_members = Vec::new(); - for (recv_member_id, _) in receivers { - if self.participants.member_has_connection(&recv_member_id) { + for (_, endpoint) in receivers { + if self + .participants + .member_has_connection(&endpoint.owner().id()) + { if let Some(recv_member) = - self.participants.get_member_by_id(&recv_member_id) + self.participants.get_member_by_id(&endpoint.owner().id()) { - already_connected_members.push(recv_member_id.clone()); + already_connected_members.push(endpoint.owner().id()); need_create.push((&member, recv_member.clone())); } else { error!( "Try to create peer for nonexistent member with ID \ {}. Room will be stopped.", - recv_member_id + endpoint.owner().id() ); ctx.notify(CloseRoom {}); } @@ -339,7 +342,7 @@ impl Room { // connect senders for (_, play) in member.receivers() { - let sender_member_id = play.id(); + let sender_member_id = play.owner().id(); if already_connected_members.contains(&sender_member_id) { continue; } diff --git a/src/signalling/state/endpoint.rs b/src/signalling/state/endpoint.rs index d866d7c52..42c1f9f0d 100644 --- a/src/signalling/state/endpoint.rs +++ b/src/signalling/state/endpoint.rs @@ -1,9 +1,62 @@ use super::member::Participant; use crate::api::control::endpoint::SrcUri; -use std::sync::Arc; +use std::cell::RefCell; +use std::sync::{Arc, Mutex}; + +#[derive(Clone, Debug, Eq, Hash, PartialEq)] +pub struct Id(pub String); #[derive(Debug, Clone)] -pub struct Id(String); +pub struct WebRtcPlayEndpointInner { + pub src: SrcUri, + pub publisher: WebRtcPublishEndpoint, + pub owner: Participant, +} + +impl WebRtcPlayEndpointInner { + pub fn src(&self) -> SrcUri { + self.src.clone() + } + + pub fn owner(&self) -> Participant { + self.owner.clone() + } + + pub fn publisher(&self) -> WebRtcPublishEndpoint { + self.publisher.clone() + } +} + +#[derive(Debug, Clone)] +pub struct WebRtcPlayEndpoint(Arc>>); + +impl WebRtcPlayEndpoint { + pub fn new( + src: SrcUri, + publisher: WebRtcPublishEndpoint, + owner: Participant, + ) -> Self { + Self(Arc::new(Mutex::new(RefCell::new( + WebRtcPlayEndpointInner { + src, + publisher, + owner, + }, + )))) + } + + pub fn src(&self) -> SrcUri { + self.0.lock().unwrap().borrow().src() + } + + pub fn owner(&self) -> Participant { + self.0.lock().unwrap().borrow().owner() + } + + pub fn publisher(&self) -> WebRtcPublishEndpoint { + self.0.lock().unwrap().borrow().publisher() + } +} #[derive(Debug, Clone)] pub enum P2pMode { @@ -11,15 +64,55 @@ pub enum P2pMode { } #[derive(Debug, Clone)] -pub struct WebRtcPlayEndpoint { - pub src: SrcUri, - pub publisher: Arc, - pub participant: Participant, +pub struct WebRtcPublishEndpointInner { + pub p2p: P2pMode, + pub receivers: Vec, + pub owner: Participant, +} + +impl WebRtcPublishEndpointInner { + pub fn add_receiver(&mut self, receiver: WebRtcPlayEndpoint) { + self.receivers.push(receiver); + } + + pub fn receivers(&self) -> Vec { + self.receivers.clone() + } + + pub fn owner(&self) -> Participant { + self.owner.clone() + } } #[derive(Debug, Clone)] -pub struct WebRtcPublishEndpoint { - pub p2p: P2pMode, - pub receivers: Vec>, - pub participant: Participant, +pub struct WebRtcPublishEndpoint( + Arc>>, +); + +impl WebRtcPublishEndpoint { + pub fn new( + p2p: P2pMode, + receivers: Vec, + owner: Participant, + ) -> Self { + Self(Arc::new(Mutex::new(RefCell::new( + WebRtcPublishEndpointInner { + p2p, + receivers, + owner, + }, + )))) + } + + pub fn add_receiver(&self, receiver: WebRtcPlayEndpoint) { + self.0.lock().unwrap().borrow_mut().add_receiver(receiver) + } + + pub fn receivers(&self) -> Vec { + self.0.lock().unwrap().borrow().receivers() + } + + pub fn owner(&self) -> Participant { + self.0.lock().unwrap().borrow().owner() + } } diff --git a/src/signalling/state/member.rs b/src/signalling/state/member.rs index 5a836c9cf..95ae007e1 100644 --- a/src/signalling/state/member.rs +++ b/src/signalling/state/member.rs @@ -16,13 +16,22 @@ pub struct Participant(Arc>>); pub struct ParticipantInner { id: MemberId, // TODO (evdokimovs): there is memory leak because Arc. - send: HashMap>, + send: HashMap, // TODO (evdokimovs): there is memory leak because Arc. - recv: HashMap>, + recv: HashMap, credentials: String, } impl Participant { + pub fn new(id: MemberId, credentials: String) -> Self { + Self(Arc::new(Mutex::new(RefCell::new(ParticipantInner { + id, + send: HashMap::new(), + recv: HashMap::new(), + credentials, + })))) + } + pub fn id(&self) -> MemberId { self.0.lock().unwrap().borrow().id.clone() } @@ -39,19 +48,15 @@ impl Participant { self.0.lock().unwrap().borrow().credentials.clone() } - pub fn publish(&self) -> HashMap> { + pub fn publish(&self) -> HashMap { self.0.lock().unwrap().borrow().send.clone() } - pub fn receivers(&self) -> HashMap> { + pub fn receivers(&self) -> HashMap { self.0.lock().unwrap().borrow().recv.clone() } - pub fn add_receiver( - &self, - id: EndpointId, - endpoint: Arc, - ) { + pub fn add_receiver(&self, id: EndpointId, endpoint: WebRtcPlayEndpoint) { self.0 .lock() .unwrap() @@ -60,26 +65,20 @@ impl Participant { .insert(id, endpoint); } - pub fn add_recv_to_send( - &self, - id: EndpointId, - endpoint: Arc, - ) { + pub fn add_sender(&self, id: EndpointId, endpoint: WebRtcPublishEndpoint) { self.0 .lock() .unwrap() .borrow_mut() .send - .entry(id) - .or_insert(Vec::new()) - .push(endpoint) + .insert(id, endpoint); } pub fn get_publisher( &self, id: &EndpointId, - ) -> Option> { - self.0.lock().unwrap().borrow().send.get(id) + ) -> Option { + self.0.lock().unwrap().borrow().send.get(id).cloned() } } @@ -102,55 +101,63 @@ impl ParticipantInner { room_spec.pipeline.pipeline.get(&self.id.0).unwrap(), ) .unwrap(); + let me = store.get(&self.id).unwrap(); - spec.play_endpoints().iter().for_each(|(_, p)| { + + spec.play_endpoints().iter().for_each(|(name_p, p)| { let sender_participant = store.get(&MemberId(p.src.member_id.to_string())).unwrap(); - let publisher = WebRtcPublishEndpoint { - participant: sender_participant.clone(), - receivers: Vec::new(), - p2p: P2pMode::Always, - }; + let publisher = WebRtcPublishEndpoint::new( + P2pMode::Always, + Vec::new(), + sender_participant.clone(), + ); match sender_participant .get_publisher(&EndpointId(p.src.endpoint_id.to_string())) { Some(publisher) => { - WebRtcPlayEndpoint { - participant: me, - publisher, - src: p.src, - } - - // TODO: Mutate publisher here + let play_endpoint = WebRtcPlayEndpoint::new( + p.src.clone(), + publisher.clone(), + me.clone(), + ); + + me.add_receiver( + EndpointId(name_p.to_string()), + play_endpoint.clone(), + ); + + publisher.add_receiver(play_endpoint); } None => { - // Create Publisher - // create play - // add play to publisher - // insert publisher into participant + let send_endpoint = WebRtcPublishEndpoint::new( + P2pMode::Always, + Vec::new(), + sender_participant.clone(), + ); + + let play_endpoint = WebRtcPlayEndpoint::new( + p.src.clone(), + send_endpoint.clone(), + me.clone(), + ); + + send_endpoint.add_receiver(play_endpoint.clone()); + + sender_participant.add_sender( + EndpointId(p.src.endpoint_id.to_string()), + send_endpoint, + ); + + me.add_receiver( + EndpointId(name_p.to_string()), + play_endpoint, + ); } } - - self.recv.push(WebRtcPlayEndpoint { - src: p.src, - publisher: sender_participant.clone(), - }); }); - - for (id, element) in room_spec.pipeline.iter() { - let member = MemberSpec::try_from(element).unwrap(); - - member - .play_endpoints() - .into_iter() - .filter(|(_, endpoint)| endpoint.src.member_id == self_id) - .for_each(|_| { - let member_id = MemberId(id.clone()); - let participant = store.get(&member_id).unwrap().clone(); - }); - } } pub fn get_store(room_spec: &RoomSpec) -> HashMap { @@ -160,10 +167,7 @@ impl ParticipantInner { for (id, member) in &members { participants.insert( id.clone(), - Participant(Arc::new(Mutex::new(RefCell::new(Self::new( - id.clone(), - member.credentials().to_string(), - ))))), + Participant::new(id.clone(), member.credentials().to_string()) ); } From 437e72e03ad5cc99c24292ed9fd573456f636d57 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 11 Jun 2019 13:32:36 +0300 Subject: [PATCH 114/735] Fix deadlock --- src/signalling/room.rs | 10 ++-- src/signalling/state/endpoint.rs | 30 ++++++------ src/signalling/state/member.rs | 80 ++++++++++++++++++++++++++++---- 3 files changed, 91 insertions(+), 29 deletions(-) diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 79139c968..3a4bfe7c5 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -322,18 +322,18 @@ impl Room { for (_, endpoint) in receivers { if self .participants - .member_has_connection(&endpoint.owner().id()) + .member_has_connection(&endpoint.owner_id()) { if let Some(recv_member) = - self.participants.get_member_by_id(&endpoint.owner().id()) + self.participants.get_member_by_id(&endpoint.owner_id()) { - already_connected_members.push(endpoint.owner().id()); + already_connected_members.push(endpoint.owner_id()); need_create.push((&member, recv_member.clone())); } else { error!( "Try to create peer for nonexistent member with ID \ {}. Room will be stopped.", - endpoint.owner().id() + endpoint.owner_id() ); ctx.notify(CloseRoom {}); } @@ -342,7 +342,7 @@ impl Room { // connect senders for (_, play) in member.receivers() { - let sender_member_id = play.owner().id(); + let sender_member_id = play.owner_id(); if already_connected_members.contains(&sender_member_id) { continue; } diff --git a/src/signalling/state/endpoint.rs b/src/signalling/state/endpoint.rs index 42c1f9f0d..a900a172e 100644 --- a/src/signalling/state/endpoint.rs +++ b/src/signalling/state/endpoint.rs @@ -1,5 +1,5 @@ use super::member::Participant; -use crate::api::control::endpoint::SrcUri; +use crate::api::control::{endpoint::SrcUri, MemberId}; use std::cell::RefCell; use std::sync::{Arc, Mutex}; @@ -10,7 +10,7 @@ pub struct Id(pub String); pub struct WebRtcPlayEndpointInner { pub src: SrcUri, pub publisher: WebRtcPublishEndpoint, - pub owner: Participant, + pub owner_id: MemberId, } impl WebRtcPlayEndpointInner { @@ -18,8 +18,8 @@ impl WebRtcPlayEndpointInner { self.src.clone() } - pub fn owner(&self) -> Participant { - self.owner.clone() + pub fn owner_id(&self) -> MemberId { + self.owner_id.clone() } pub fn publisher(&self) -> WebRtcPublishEndpoint { @@ -34,13 +34,13 @@ impl WebRtcPlayEndpoint { pub fn new( src: SrcUri, publisher: WebRtcPublishEndpoint, - owner: Participant, + owner_id: MemberId, ) -> Self { Self(Arc::new(Mutex::new(RefCell::new( WebRtcPlayEndpointInner { src, publisher, - owner, + owner_id, }, )))) } @@ -49,8 +49,8 @@ impl WebRtcPlayEndpoint { self.0.lock().unwrap().borrow().src() } - pub fn owner(&self) -> Participant { - self.0.lock().unwrap().borrow().owner() + pub fn owner_id(&self) -> MemberId { + self.0.lock().unwrap().borrow().owner_id() } pub fn publisher(&self) -> WebRtcPublishEndpoint { @@ -67,7 +67,7 @@ pub enum P2pMode { pub struct WebRtcPublishEndpointInner { pub p2p: P2pMode, pub receivers: Vec, - pub owner: Participant, + pub owner_id: MemberId, } impl WebRtcPublishEndpointInner { @@ -79,8 +79,8 @@ impl WebRtcPublishEndpointInner { self.receivers.clone() } - pub fn owner(&self) -> Participant { - self.owner.clone() + pub fn owner_id(&self) -> MemberId { + self.owner_id.clone() } } @@ -93,13 +93,13 @@ impl WebRtcPublishEndpoint { pub fn new( p2p: P2pMode, receivers: Vec, - owner: Participant, + owner_id: MemberId, ) -> Self { Self(Arc::new(Mutex::new(RefCell::new( WebRtcPublishEndpointInner { p2p, receivers, - owner, + owner_id, }, )))) } @@ -112,7 +112,7 @@ impl WebRtcPublishEndpoint { self.0.lock().unwrap().borrow().receivers() } - pub fn owner(&self) -> Participant { - self.0.lock().unwrap().borrow().owner() + pub fn owner_id(&self) -> MemberId { + self.0.lock().unwrap().borrow().owner_id() } } diff --git a/src/signalling/state/member.rs b/src/signalling/state/member.rs index 95ae007e1..6a0e82b4a 100644 --- a/src/signalling/state/member.rs +++ b/src/signalling/state/member.rs @@ -36,10 +36,6 @@ impl Participant { self.0.lock().unwrap().borrow().id.clone() } - pub fn load(&self, room_spec: &RoomSpec, store: &HashMap) { - self.0.lock().unwrap().borrow_mut().load(room_spec, store); - } - pub fn get_store(room_spec: &RoomSpec) -> HashMap { ParticipantInner::get_store(room_spec) } @@ -56,6 +52,72 @@ impl Participant { self.0.lock().unwrap().borrow().recv.clone() } + pub fn load( + &self, + room_spec: &RoomSpec, + store: &HashMap, + ) { + let spec = MemberSpec::try_from( + room_spec.pipeline.pipeline.get(&self.id().0).unwrap(), + ) + .unwrap(); + + spec.play_endpoints().iter().for_each(|(name_p, p)| { + let sender_participant = + store.get(&MemberId(p.src.member_id.to_string())).unwrap(); + + let publisher = WebRtcPublishEndpoint::new( + P2pMode::Always, + Vec::new(), + sender_participant.id(), + ); + + match sender_participant + .get_publisher(&EndpointId(p.src.endpoint_id.to_string())) + { + Some(publisher) => { + let play_endpoint = WebRtcPlayEndpoint::new( + p.src.clone(), + publisher.clone(), + self.id(), + ); + + self.add_receiver( + EndpointId(name_p.to_string()), + play_endpoint.clone(), + ); + + publisher.add_receiver(play_endpoint); + } + None => { + let send_endpoint = WebRtcPublishEndpoint::new( + P2pMode::Always, + Vec::new(), + sender_participant.id(), + ); + + let play_endpoint = WebRtcPlayEndpoint::new( + p.src.clone(), + send_endpoint.clone(), + self.id(), + ); + + send_endpoint.add_receiver(play_endpoint.clone()); + + sender_participant.add_sender( + EndpointId(p.src.endpoint_id.to_string()), + send_endpoint, + ); + + self.add_receiver( + EndpointId(name_p.to_string()), + play_endpoint, + ); + } + } + }); + } + pub fn add_receiver(&self, id: EndpointId, endpoint: WebRtcPlayEndpoint) { self.0 .lock() @@ -111,7 +173,7 @@ impl ParticipantInner { let publisher = WebRtcPublishEndpoint::new( P2pMode::Always, Vec::new(), - sender_participant.clone(), + sender_participant.id(), ); match sender_participant @@ -121,7 +183,7 @@ impl ParticipantInner { let play_endpoint = WebRtcPlayEndpoint::new( p.src.clone(), publisher.clone(), - me.clone(), + me.id(), ); me.add_receiver( @@ -135,13 +197,13 @@ impl ParticipantInner { let send_endpoint = WebRtcPublishEndpoint::new( P2pMode::Always, Vec::new(), - sender_participant.clone(), + sender_participant.id(), ); let play_endpoint = WebRtcPlayEndpoint::new( p.src.clone(), send_endpoint.clone(), - me.clone(), + me.id(), ); send_endpoint.add_receiver(play_endpoint.clone()); @@ -167,7 +229,7 @@ impl ParticipantInner { for (id, member) in &members { participants.insert( id.clone(), - Participant::new(id.clone(), member.credentials().to_string()) + Participant::new(id.clone(), member.credentials().to_string()), ); } From fdb0028770a0cc7bd33fa50c491f4dacd364d399 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 11 Jun 2019 13:53:34 +0300 Subject: [PATCH 115/735] Dirty implemenation --- src/signalling/room.rs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 3a4bfe7c5..5cd2d2154 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -301,7 +301,9 @@ impl Room { return; }; - let mut need_create = Vec::new(); + println!("Create peers for member {:#?}", member); + +// let mut need_create = Vec::new(); // connect receivers // let (_, receivers) = match member.publish() { @@ -317,6 +319,24 @@ impl Room { // return; // } // }; + + for (id, publish) in member.publish() { + for receiver in publish.receivers() { + if self.participants.member_has_connection(&receiver.owner_id()) { + let publish_participant = self.participants.get_member_by_id(&receiver.owner_id()).unwrap(); + self.create_and_interconnect_peers(&member, &publish_participant, ctx); + } + } + } + + for (id, play) in member.receivers() { + if self.participants.member_has_connection(&play.publisher().owner_id()) { + let play_participant = self.participants.get_member_by_id(&play.publisher().owner_id()).unwrap(); + self.create_and_interconnect_peers(&member, &play_participant, ctx); + } + } + /* + let receivers = member.publish(); let mut already_connected_members = Vec::new(); for (_, endpoint) in receivers { @@ -373,6 +393,7 @@ impl Room { ctx, ); }); + */ } } From ffb7c67a58973858c68a5bac0cb373ca72af79f4 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 11 Jun 2019 13:57:30 +0300 Subject: [PATCH 116/735] Fix test --- tests/signalling.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/signalling.rs b/tests/signalling.rs index 510fcd65b..0cda00cdd 100644 --- a/tests/signalling.rs +++ b/tests/signalling.rs @@ -287,7 +287,7 @@ fn three_members_p2p_video_call() { Event::PeerCreated { peer_id, tracks, .. } => { - assert_eq!(tracks.len(), 8); + assert_eq!(tracks.len(), 4); let recv_count = tracks .iter() .filter_map(|t| match &t.direction { @@ -298,7 +298,7 @@ fn three_members_p2p_video_call() { assert_ne!(sender, peer_id); }) .count(); - assert_eq!(recv_count, 4); + assert_eq!(recv_count, 2); let send_count = tracks .iter() @@ -313,7 +313,7 @@ fn three_members_p2p_video_call() { assert_eq!(receivers.len(), 1); }) .count(); - assert_eq!(send_count, 4); + assert_eq!(send_count, 2); } _ => (), }); From 5ec99ea1aa768b7045bbf04c90e03aa2d3014f45 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 11 Jun 2019 14:41:42 +0300 Subject: [PATCH 117/735] Fix creating redundant peers --- src/signalling/peers.rs | 75 +++++++++++++--- src/signalling/room.rs | 147 ++++++++++++++++++------------- src/signalling/state/endpoint.rs | 18 ++++ 3 files changed, 164 insertions(+), 76 deletions(-) diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index 47db0ee24..acfbd4f7f 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -10,12 +10,14 @@ use hashbrown::HashMap; use crate::{ api::control::MemberId, - media::{Peer, PeerId, PeerStateMachine}, + media::{MediaTrack, Peer, PeerId, PeerStateMachine}, signalling::{ room::{PeersRemoved, Room, RoomError}, state::member::Participant, }, }; +use medea_client_api_proto::{AudioSettings, MediaType, VideoSettings}; +use std::sync::Arc; #[derive(Debug)] pub struct PeerRepository { @@ -51,6 +53,8 @@ impl fmt::Display for Counter { } } +use crate::log::prelude::*; + impl PeerRepository { /// Store [`Peer`] in [`Room`]. pub fn add_peer>(&mut self, id: PeerId, peer: S) { @@ -75,6 +79,11 @@ impl PeerRepository { first_member: &Participant, second_member: &Participant, ) -> (u64, u64) { + debug!( + "Created peer between {} and {}.", + first_member.id(), + second_member.id() + ); let first_peer_id = self.peers_count.next_id(); let second_peer_id = self.peers_count.next_id(); @@ -91,19 +100,59 @@ impl PeerRepository { first_member.id().clone(), ); - first_peer.add_publish_endpoints( - first_member.publish(), - &mut self.tracks_count, - ); - second_peer.add_publish_endpoints( - second_member.publish(), - &mut self.tracks_count, - ); + first_member + .publish() + .into_iter() + .flat_map(|(_m, e)| { + e.receivers().into_iter().filter(|e| { + e.owner_id() == second_member.id() && !e.is_connected() + }) + }) + .for_each(|e| { + let track_audio = Arc::new(MediaTrack::new( + self.tracks_count.next_id(), + MediaType::Audio(AudioSettings {}), + )); + let track_video = Arc::new(MediaTrack::new( + self.tracks_count.next_id(), + MediaType::Video(VideoSettings {}), + )); + + first_peer.add_sender(track_video.clone()); + first_peer.add_sender(track_audio.clone()); + + second_peer.add_receiver(track_video); + second_peer.add_receiver(track_audio); - first_peer - .add_play_endpoints(first_member.receivers(), &mut second_peer); - second_peer - .add_play_endpoints(second_member.receivers(), &mut first_peer); + e.connected(); + }); + + second_member + .publish() + .into_iter() + .flat_map(|(_m, e)| { + e.receivers().into_iter().filter(|e| { + e.owner_id() == first_member.id() && !e.is_connected() + }) + }) + .for_each(|e| { + let track_audio = Arc::new(MediaTrack::new( + self.tracks_count.next_id(), + MediaType::Audio(AudioSettings {}), + )); + let track_video = Arc::new(MediaTrack::new( + self.tracks_count.next_id(), + MediaType::Video(VideoSettings {}), + )); + + second_peer.add_sender(track_video.clone()); + second_peer.add_sender(track_audio.clone()); + + first_peer.add_receiver(track_video); + first_peer.add_receiver(track_audio); + + e.connected(); + }); self.add_peer(first_peer_id, first_peer); self.add_peer(second_peer_id, second_peer); diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 5cd2d2154..848651fed 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -301,9 +301,9 @@ impl Room { return; }; - println!("Create peers for member {:#?}", member); + // println!("Create peers for member {:#?}", member); -// let mut need_create = Vec::new(); + // let mut need_create = Vec::new(); // connect receivers // let (_, receivers) = match member.publish() { @@ -322,78 +322,99 @@ impl Room { for (id, publish) in member.publish() { for receiver in publish.receivers() { - if self.participants.member_has_connection(&receiver.owner_id()) { - let publish_participant = self.participants.get_member_by_id(&receiver.owner_id()).unwrap(); - self.create_and_interconnect_peers(&member, &publish_participant, ctx); + if self + .participants + .member_has_connection(&receiver.owner_id()) + && !receiver.is_connected() + { + let publish_participant = self + .participants + .get_member_by_id(&receiver.owner_id()) + .unwrap(); + self.create_and_interconnect_peers( + &member, + &publish_participant, + ctx, + ); + receiver.connected(); } } } for (id, play) in member.receivers() { - if self.participants.member_has_connection(&play.publisher().owner_id()) { - let play_participant = self.participants.get_member_by_id(&play.publisher().owner_id()).unwrap(); - self.create_and_interconnect_peers(&member, &play_participant, ctx); - } - } - /* - - let receivers = member.publish(); - let mut already_connected_members = Vec::new(); - for (_, endpoint) in receivers { if self .participants - .member_has_connection(&endpoint.owner_id()) + .member_has_connection(&play.publisher().owner_id()) + && !play.is_connected() { - if let Some(recv_member) = - self.participants.get_member_by_id(&endpoint.owner_id()) - { - already_connected_members.push(endpoint.owner_id()); - need_create.push((&member, recv_member.clone())); - } else { - error!( - "Try to create peer for nonexistent member with ID \ - {}. Room will be stopped.", - endpoint.owner_id() - ); - ctx.notify(CloseRoom {}); - } - } - } - - // connect senders - for (_, play) in member.receivers() { - let sender_member_id = play.owner_id(); - if already_connected_members.contains(&sender_member_id) { - continue; - } - - if self.participants.member_has_connection(&sender_member_id) { - if let Some(sender_member) = - self.participants.get_member_by_id(&sender_member_id) - { - need_create.push((&member, sender_member.clone())); - } else { - error!( - "Try to get member with ID {} which has active \ - RpcConnection but not presented in participants! \ - Room will be stopped.", - sender_member_id - ); - ctx.notify(CloseRoom {}); - } - } - } - - need_create - .into_iter() - .for_each(|(first_member, second_member)| { + let play_participant = self + .participants + .get_member_by_id(&play.publisher().owner_id()) + .unwrap(); self.create_and_interconnect_peers( - first_member, - &second_member, + &member, + &play_participant, ctx, ); - }); - */ + play.connected(); + } + } + // let receivers = member.publish(); + // let mut already_connected_members = Vec::new(); + // for (_, endpoint) in receivers { + // if self + // .participants + // .member_has_connection(&endpoint.owner_id()) + // { + // if let Some(recv_member) = + // self.participants.get_member_by_id(&endpoint.owner_id()) + // { + // already_connected_members.push(endpoint.owner_id()); + // need_create.push((&member, recv_member.clone())); + // } else { + // error!( + // "Try to create peer for nonexistent member with ID \ + // {}. Room will be stopped.", + // endpoint.owner_id() + // ); + // ctx.notify(CloseRoom {}); + // } + // } + // } + // + // connect senders + // for (_, play) in member.receivers() { + // let sender_member_id = play.owner_id(); + // if already_connected_members.contains(&sender_member_id) { + // continue; + // } + // + // if self.participants.member_has_connection(&sender_member_id) { + // if let Some(sender_member) = + // self.participants.get_member_by_id(&sender_member_id) + // { + // need_create.push((&member, sender_member.clone())); + // } else { + // error!( + // "Try to get member with ID {} which has active \ + // RpcConnection but not presented in participants! \ + // Room will be stopped.", + // sender_member_id + // ); + // ctx.notify(CloseRoom {}); + // } + // } + // } + // + // need_create + // .into_iter() + // .for_each(|(first_member, second_member)| { + // self.create_and_interconnect_peers( + // first_member, + // &second_member, + // ctx, + // ); + // }); } } diff --git a/src/signalling/state/endpoint.rs b/src/signalling/state/endpoint.rs index a900a172e..5add79078 100644 --- a/src/signalling/state/endpoint.rs +++ b/src/signalling/state/endpoint.rs @@ -11,6 +11,7 @@ pub struct WebRtcPlayEndpointInner { pub src: SrcUri, pub publisher: WebRtcPublishEndpoint, pub owner_id: MemberId, + pub is_connected: bool, } impl WebRtcPlayEndpointInner { @@ -25,6 +26,14 @@ impl WebRtcPlayEndpointInner { pub fn publisher(&self) -> WebRtcPublishEndpoint { self.publisher.clone() } + + pub fn is_connected(&self) -> bool { + self.is_connected + } + + pub fn set_is_connected(&mut self, value: bool) { + self.is_connected = value; + } } #[derive(Debug, Clone)] @@ -41,6 +50,7 @@ impl WebRtcPlayEndpoint { src, publisher, owner_id, + is_connected: false, }, )))) } @@ -56,6 +66,14 @@ impl WebRtcPlayEndpoint { pub fn publisher(&self) -> WebRtcPublishEndpoint { self.0.lock().unwrap().borrow().publisher() } + + pub fn is_connected(&self) -> bool { + self.0.lock().unwrap().borrow().is_connected() + } + + pub fn connected(&self) { + self.0.lock().unwrap().borrow_mut().set_is_connected(true); + } } #[derive(Debug, Clone)] From 2590a83147af3f752540ae919dde475b778f8d0e Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 11 Jun 2019 15:14:26 +0300 Subject: [PATCH 118/735] Remove commented code --- src/api/control/room.rs | 66 ----------------------------------- src/signalling/room.rs | 77 ----------------------------------------- 2 files changed, 143 deletions(-) diff --git a/src/api/control/room.rs b/src/api/control/room.rs index 7f2146e9c..85dfebf51 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -58,69 +58,3 @@ impl TryFrom<&Element> for RoomSpec { } } } - -#[cfg(test)] -mod room_spec_tests { - use super::*; - - // #[test] - // fn properly_get_receivers_for_member() { - // let spec = r#" - // kind: Room - // id: test-call - // spec: - // pipeline: - // caller: - // kind: Member - // credentials: test - // spec: - // pipeline: - // publish: - // kind: WebRtcPublishEndpoint - // spec: - // p2p: Always - // some-member: - // kind: Member - // credentials: test - // spec: - // pipeline: - // publish: - // kind: WebRtcPublishEndpoint - // spec: - // p2p: Always - // responder: - // kind: Member - // credentials: test - // spec: - // pipeline: - // play: - // kind: WebRtcPlayEndpoint - // spec: - // src: "local://test-call/caller/publish" - // play2: - // kind: WebRtcPlayEndpoint - // spec: - // src: "local://test-call/some-member/publish" - // "#; - // let spec: Element = serde_yaml::from_str(spec).unwrap(); - // let room = RoomSpec::try_from(&spec).unwrap(); - // - // let caller_member_id = MemberId("caller".to_string()); - // let responder_member_id = MemberId("responder".to_string()); - // - // let room_members = room.members().unwrap(); - // let caller_receivers = room_members - // .get(&caller_member_id) - // .unwrap() - // .receivers() - // .unwrap(); - // assert_eq!(caller_receivers, vec![responder_member_id.clone()]); - // - // let responder_receivers = room_members - // .get(&responder_member_id) - // .unwrap() - // .receivers() - // .unwrap(); - // assert_eq!(responder_receivers, vec![]); - // } -} diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 848651fed..f9d639ca8 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -301,25 +301,6 @@ impl Room { return; }; - // println!("Create peers for member {:#?}", member); - - // let mut need_create = Vec::new(); - - // connect receivers - // let (_, receivers) = match member.publish() { - // Ok(r) => r, - // Err(e) => { - // error!( - // "Member {} has wrong room pipeline. Room will be - // stopped. \ Here is error: {:?}", - // member.lock().unwrap().borrow().id(), - // e - // ); - // ctx.notify(CloseRoom {}); - // return; - // } - // }; - for (id, publish) in member.publish() { for receiver in publish.receivers() { if self @@ -336,7 +317,6 @@ impl Room { &publish_participant, ctx, ); - receiver.connected(); } } } @@ -356,65 +336,8 @@ impl Room { &play_participant, ctx, ); - play.connected(); } } - // let receivers = member.publish(); - // let mut already_connected_members = Vec::new(); - // for (_, endpoint) in receivers { - // if self - // .participants - // .member_has_connection(&endpoint.owner_id()) - // { - // if let Some(recv_member) = - // self.participants.get_member_by_id(&endpoint.owner_id()) - // { - // already_connected_members.push(endpoint.owner_id()); - // need_create.push((&member, recv_member.clone())); - // } else { - // error!( - // "Try to create peer for nonexistent member with ID \ - // {}. Room will be stopped.", - // endpoint.owner_id() - // ); - // ctx.notify(CloseRoom {}); - // } - // } - // } - // - // connect senders - // for (_, play) in member.receivers() { - // let sender_member_id = play.owner_id(); - // if already_connected_members.contains(&sender_member_id) { - // continue; - // } - // - // if self.participants.member_has_connection(&sender_member_id) { - // if let Some(sender_member) = - // self.participants.get_member_by_id(&sender_member_id) - // { - // need_create.push((&member, sender_member.clone())); - // } else { - // error!( - // "Try to get member with ID {} which has active \ - // RpcConnection but not presented in participants! \ - // Room will be stopped.", - // sender_member_id - // ); - // ctx.notify(CloseRoom {}); - // } - // } - // } - // - // need_create - // .into_iter() - // .for_each(|(first_member, second_member)| { - // self.create_and_interconnect_peers( - // first_member, - // &second_member, - // ctx, - // ); - // }); } } From 76fe6f57ecfd18f8b2c652855e18fdf65995610d Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 11 Jun 2019 15:30:00 +0300 Subject: [PATCH 119/735] Reduce boilerplate in peers.rs --- src/media/peer.rs | 63 ++++++++++++++++++----------------------- src/signalling/peers.rs | 63 +++++++---------------------------------- src/signalling/room.rs | 2 ++ 3 files changed, 40 insertions(+), 88 deletions(-) diff --git a/src/media/peer.rs b/src/media/peer.rs index 78ecdeb8d..351a2d933 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -254,46 +254,39 @@ impl Peer { } } - /// Add all [`WebRtcPublishEndpoint`]s to this [`Peer`]. - /// - /// This use `track_id_counter` counter for generating new [`MediaTrack`] - /// ID. - // TODO (evdokimovs): Upd doc pub fn add_publish_endpoints( &mut self, - endpoints: HashMap, - track_id_counter: &mut Counter, - ) { - for _ in endpoints { - let track_audio = Arc::new(MediaTrack::new( - track_id_counter.next_id(), - MediaType::Audio(AudioSettings {}), - )); - let track_video = Arc::new(MediaTrack::new( - track_id_counter.next_id(), - MediaType::Video(VideoSettings {}), - )); - - self.add_sender(track_audio); - self.add_sender(track_video); - } - } - - /// Add all `partner_peer` related [`WebRtcPlayEndpoint`]s to this [`Peer`]. - // TODO (evdokimovs): Upd doc - pub fn add_play_endpoints( - &mut self, - endpoints: HashMap, partner_peer: &mut Peer, + tracks_count: &mut Counter, + publish_endpoints: HashMap, ) { - for (_, endpoint) in endpoints { - if self.context.partner_member == endpoint.src().member_id { - partner_peer - .get_senders() + let partner_id = self.partner_member_id(); + + publish_endpoints + .into_iter() + .flat_map(|(_m, e)| { + e.receivers() .into_iter() - .for_each(|s| self.add_receiver(s)); - } - } + .filter(|e| e.owner_id() == partner_id && !e.is_connected()) + }) + .for_each(|e| { + let track_audio = Arc::new(MediaTrack::new( + tracks_count.next_id(), + MediaType::Audio(AudioSettings {}), + )); + let track_video = Arc::new(MediaTrack::new( + tracks_count.next_id(), + MediaType::Video(VideoSettings {}), + )); + + self.add_sender(track_video.clone()); + self.add_sender(track_audio.clone()); + + partner_peer.add_receiver(track_video); + partner_peer.add_receiver(track_audio); + + e.connected(); + }); } /// Transition new [`Peer`] into state of waiting for local description. diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index acfbd4f7f..647a927af 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -100,59 +100,16 @@ impl PeerRepository { first_member.id().clone(), ); - first_member - .publish() - .into_iter() - .flat_map(|(_m, e)| { - e.receivers().into_iter().filter(|e| { - e.owner_id() == second_member.id() && !e.is_connected() - }) - }) - .for_each(|e| { - let track_audio = Arc::new(MediaTrack::new( - self.tracks_count.next_id(), - MediaType::Audio(AudioSettings {}), - )); - let track_video = Arc::new(MediaTrack::new( - self.tracks_count.next_id(), - MediaType::Video(VideoSettings {}), - )); - - first_peer.add_sender(track_video.clone()); - first_peer.add_sender(track_audio.clone()); - - second_peer.add_receiver(track_video); - second_peer.add_receiver(track_audio); - - e.connected(); - }); - - second_member - .publish() - .into_iter() - .flat_map(|(_m, e)| { - e.receivers().into_iter().filter(|e| { - e.owner_id() == first_member.id() && !e.is_connected() - }) - }) - .for_each(|e| { - let track_audio = Arc::new(MediaTrack::new( - self.tracks_count.next_id(), - MediaType::Audio(AudioSettings {}), - )); - let track_video = Arc::new(MediaTrack::new( - self.tracks_count.next_id(), - MediaType::Video(VideoSettings {}), - )); - - second_peer.add_sender(track_video.clone()); - second_peer.add_sender(track_audio.clone()); - - first_peer.add_receiver(track_video); - first_peer.add_receiver(track_audio); - - e.connected(); - }); + first_peer.add_publish_endpoints( + &mut second_peer, + &mut self.tracks_count, + first_member.publish(), + ); + second_peer.add_publish_endpoints( + &mut first_peer, + &mut self.tracks_count, + second_member.publish(), + ); self.add_peer(first_peer_id, first_peer); self.add_peer(second_peer_id, second_peer); diff --git a/src/signalling/room.rs b/src/signalling/room.rs index f9d639ca8..0decb4d99 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -301,6 +301,7 @@ impl Room { return; }; + // Create all connected publish endpoints. for (id, publish) in member.publish() { for receiver in publish.receivers() { if self @@ -321,6 +322,7 @@ impl Room { } } + // Create all connected play endpoint. for (id, play) in member.receivers() { if self .participants From 78e4c4b23e0210116a7ba9f27a08de6e2eacf271 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 11 Jun 2019 16:51:19 +0300 Subject: [PATCH 120/735] Fix memory leak --- src/media/peer.rs | 4 +- src/signalling/room.rs | 13 +++--- src/signalling/state/endpoint.rs | 58 ++++++++++++-------------- src/signalling/state/member.rs | 70 +++++++++++++++++--------------- 4 files changed, 75 insertions(+), 70 deletions(-) diff --git a/src/media/peer.rs b/src/media/peer.rs index 351a2d933..136f8d1e5 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -258,15 +258,17 @@ impl Peer { &mut self, partner_peer: &mut Peer, tracks_count: &mut Counter, - publish_endpoints: HashMap, + publish_endpoints: HashMap>, ) { let partner_id = self.partner_member_id(); + // TODO: unwrap weak publish_endpoints .into_iter() .flat_map(|(_m, e)| { e.receivers() .into_iter() + .map(|e| e.upgrade().unwrap()) .filter(|e| e.owner_id() == partner_id && !e.is_connected()) }) .for_each(|e| { diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 0decb4d99..8cd9c5e1a 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -304,6 +304,7 @@ impl Room { // Create all connected publish endpoints. for (id, publish) in member.publish() { for receiver in publish.receivers() { + let receiver = receiver.upgrade().unwrap(); // TODO: unwrap if self .participants .member_has_connection(&receiver.owner_id()) @@ -323,15 +324,17 @@ impl Room { } // Create all connected play endpoint. + // TODO: properly unwrap Weak for (id, play) in member.receivers() { - if self - .participants - .member_has_connection(&play.publisher().owner_id()) - && !play.is_connected() + if self.participants.member_has_connection( + &play.publisher().upgrade().unwrap().owner_id(), + ) && !play.is_connected() { let play_participant = self .participants - .get_member_by_id(&play.publisher().owner_id()) + .get_member_by_id( + &play.publisher().upgrade().unwrap().owner_id(), + ) .unwrap(); self.create_and_interconnect_peers( &member, diff --git a/src/signalling/state/endpoint.rs b/src/signalling/state/endpoint.rs index 5add79078..e4439539f 100644 --- a/src/signalling/state/endpoint.rs +++ b/src/signalling/state/endpoint.rs @@ -1,7 +1,7 @@ use super::member::Participant; use crate::api::control::{endpoint::SrcUri, MemberId}; use std::cell::RefCell; -use std::sync::{Arc, Mutex}; +use std::sync::{Arc, Mutex, Weak}; #[derive(Clone, Debug, Eq, Hash, PartialEq)] pub struct Id(pub String); @@ -9,7 +9,7 @@ pub struct Id(pub String); #[derive(Debug, Clone)] pub struct WebRtcPlayEndpointInner { pub src: SrcUri, - pub publisher: WebRtcPublishEndpoint, + pub publisher: Weak, pub owner_id: MemberId, pub is_connected: bool, } @@ -23,7 +23,7 @@ impl WebRtcPlayEndpointInner { self.owner_id.clone() } - pub fn publisher(&self) -> WebRtcPublishEndpoint { + pub fn publisher(&self) -> Weak { self.publisher.clone() } @@ -36,23 +36,21 @@ impl WebRtcPlayEndpointInner { } } -#[derive(Debug, Clone)] -pub struct WebRtcPlayEndpoint(Arc>>); +#[derive(Debug)] +pub struct WebRtcPlayEndpoint(Mutex>); impl WebRtcPlayEndpoint { pub fn new( src: SrcUri, - publisher: WebRtcPublishEndpoint, + publisher: Weak, owner_id: MemberId, ) -> Self { - Self(Arc::new(Mutex::new(RefCell::new( - WebRtcPlayEndpointInner { - src, - publisher, - owner_id, - is_connected: false, - }, - )))) + Self(Mutex::new(RefCell::new(WebRtcPlayEndpointInner { + src, + publisher, + owner_id, + is_connected: false, + }))) } pub fn src(&self) -> SrcUri { @@ -63,7 +61,7 @@ impl WebRtcPlayEndpoint { self.0.lock().unwrap().borrow().owner_id() } - pub fn publisher(&self) -> WebRtcPublishEndpoint { + pub fn publisher(&self) -> Weak { self.0.lock().unwrap().borrow().publisher() } @@ -84,16 +82,16 @@ pub enum P2pMode { #[derive(Debug, Clone)] pub struct WebRtcPublishEndpointInner { pub p2p: P2pMode, - pub receivers: Vec, + pub receivers: Vec>, pub owner_id: MemberId, } impl WebRtcPublishEndpointInner { - pub fn add_receiver(&mut self, receiver: WebRtcPlayEndpoint) { + pub fn add_receiver(&mut self, receiver: Weak) { self.receivers.push(receiver); } - pub fn receivers(&self) -> Vec { + pub fn receivers(&self) -> Vec> { self.receivers.clone() } @@ -102,31 +100,27 @@ impl WebRtcPublishEndpointInner { } } -#[derive(Debug, Clone)] -pub struct WebRtcPublishEndpoint( - Arc>>, -); +#[derive(Debug)] +pub struct WebRtcPublishEndpoint(Mutex>); impl WebRtcPublishEndpoint { pub fn new( p2p: P2pMode, - receivers: Vec, + receivers: Vec>, owner_id: MemberId, ) -> Self { - Self(Arc::new(Mutex::new(RefCell::new( - WebRtcPublishEndpointInner { - p2p, - receivers, - owner_id, - }, - )))) + Self(Mutex::new(RefCell::new(WebRtcPublishEndpointInner { + p2p, + receivers, + owner_id, + }))) } - pub fn add_receiver(&self, receiver: WebRtcPlayEndpoint) { + pub fn add_receiver(&self, receiver: Weak) { self.0.lock().unwrap().borrow_mut().add_receiver(receiver) } - pub fn receivers(&self) -> Vec { + pub fn receivers(&self) -> Vec> { self.0.lock().unwrap().borrow().receivers() } diff --git a/src/signalling/state/member.rs b/src/signalling/state/member.rs index 6a0e82b4a..125f652c1 100644 --- a/src/signalling/state/member.rs +++ b/src/signalling/state/member.rs @@ -1,5 +1,5 @@ use std::convert::TryFrom; -use std::sync::{Arc, Mutex}; +use std::sync::{Arc, Mutex, Weak}; use crate::api::control::{MemberId, MemberSpec, RoomSpec}; use hashbrown::HashMap; @@ -15,10 +15,8 @@ pub struct Participant(Arc>>); #[derive(Debug)] pub struct ParticipantInner { id: MemberId, - // TODO (evdokimovs): there is memory leak because Arc. - send: HashMap, - // TODO (evdokimovs): there is memory leak because Arc. - recv: HashMap, + send: HashMap>, + recv: HashMap>, credentials: String, } @@ -44,11 +42,11 @@ impl Participant { self.0.lock().unwrap().borrow().credentials.clone() } - pub fn publish(&self) -> HashMap { + pub fn publish(&self) -> HashMap> { self.0.lock().unwrap().borrow().send.clone() } - pub fn receivers(&self) -> HashMap { + pub fn receivers(&self) -> HashMap> { self.0.lock().unwrap().borrow().recv.clone() } @@ -76,33 +74,33 @@ impl Participant { .get_publisher(&EndpointId(p.src.endpoint_id.to_string())) { Some(publisher) => { - let play_endpoint = WebRtcPlayEndpoint::new( + let play_endpoint = Arc::new(WebRtcPlayEndpoint::new( p.src.clone(), - publisher.clone(), + Arc::downgrade(&publisher), self.id(), - ); + )); self.add_receiver( EndpointId(name_p.to_string()), - play_endpoint.clone(), + Arc::clone(&play_endpoint), ); - publisher.add_receiver(play_endpoint); + publisher.add_receiver(Arc::downgrade(&play_endpoint)); } None => { - let send_endpoint = WebRtcPublishEndpoint::new( + let send_endpoint = Arc::new(WebRtcPublishEndpoint::new( P2pMode::Always, Vec::new(), sender_participant.id(), - ); + )); - let play_endpoint = WebRtcPlayEndpoint::new( + let play_endpoint = Arc::new(WebRtcPlayEndpoint::new( p.src.clone(), - send_endpoint.clone(), + Arc::downgrade(&send_endpoint), self.id(), - ); + )); - send_endpoint.add_receiver(play_endpoint.clone()); + send_endpoint.add_receiver(Arc::downgrade(&play_endpoint)); sender_participant.add_sender( EndpointId(p.src.endpoint_id.to_string()), @@ -118,7 +116,11 @@ impl Participant { }); } - pub fn add_receiver(&self, id: EndpointId, endpoint: WebRtcPlayEndpoint) { + pub fn add_receiver( + &self, + id: EndpointId, + endpoint: Arc, + ) { self.0 .lock() .unwrap() @@ -127,7 +129,11 @@ impl Participant { .insert(id, endpoint); } - pub fn add_sender(&self, id: EndpointId, endpoint: WebRtcPublishEndpoint) { + pub fn add_sender( + &self, + id: EndpointId, + endpoint: Arc, + ) { self.0 .lock() .unwrap() @@ -139,7 +145,7 @@ impl Participant { pub fn get_publisher( &self, id: &EndpointId, - ) -> Option { + ) -> Option> { self.0.lock().unwrap().borrow().send.get(id).cloned() } } @@ -180,33 +186,33 @@ impl ParticipantInner { .get_publisher(&EndpointId(p.src.endpoint_id.to_string())) { Some(publisher) => { - let play_endpoint = WebRtcPlayEndpoint::new( + let play_endpoint = Arc::new(WebRtcPlayEndpoint::new( p.src.clone(), - publisher.clone(), + Arc::downgrade(&publisher), me.id(), - ); + )); me.add_receiver( EndpointId(name_p.to_string()), - play_endpoint.clone(), + Arc::clone(&play_endpoint), ); - publisher.add_receiver(play_endpoint); + publisher.add_receiver(Arc::downgrade(&play_endpoint)); } None => { - let send_endpoint = WebRtcPublishEndpoint::new( + let send_endpoint = Arc::new(WebRtcPublishEndpoint::new( P2pMode::Always, Vec::new(), sender_participant.id(), - ); + )); - let play_endpoint = WebRtcPlayEndpoint::new( + let play_endpoint = Arc::new(WebRtcPlayEndpoint::new( p.src.clone(), - send_endpoint.clone(), + Arc::downgrade(&send_endpoint), me.id(), - ); + )); - send_endpoint.add_receiver(play_endpoint.clone()); + send_endpoint.add_receiver(Arc::downgrade(&play_endpoint)); sender_participant.add_sender( EndpointId(p.src.endpoint_id.to_string()), From 22493f18bd34073168896e380f50f1e71299f22b Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 11 Jun 2019 17:12:12 +0300 Subject: [PATCH 121/735] Use Weak Participant in WebRtcPlayEndpoint --- src/media/peer.rs | 5 ++++- src/signalling/participants.rs | 7 ++++--- src/signalling/room.rs | 5 +++-- src/signalling/state/endpoint.rs | 14 +++++++------- src/signalling/state/member.rs | 33 +++++++++++++++++++------------- 5 files changed, 38 insertions(+), 26 deletions(-) diff --git a/src/media/peer.rs b/src/media/peer.rs index 136f8d1e5..416a84e68 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -269,7 +269,10 @@ impl Peer { e.receivers() .into_iter() .map(|e| e.upgrade().unwrap()) - .filter(|e| e.owner_id() == partner_id && !e.is_connected()) + .filter(|e| { + e.owner().upgrade().unwrap().id() == partner_id + && !e.is_connected() + }) }) .for_each(|e| { let track_audio = Arc::new(MediaTrack::new( diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index c80351efd..0137e9d2f 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -2,6 +2,7 @@ //! stores [`Members`] and associated [`RpcConnection`]s, handles //! [`RpcConnection`] authorization, establishment, message sending. +use std::sync::Arc; use std::time::{Duration, Instant}; use actix::{fut::wrap_future, AsyncContext, Context, SpawnHandle}; @@ -30,7 +31,7 @@ use crate::{ #[derive(Debug)] pub struct ParticipantService { /// [`Member`]s which currently are present in this [`Room`]. - members: HashMap, + members: HashMap>, /// Established [`RpcConnection`]s of [`Member`]s in this [`Room`]. // TODO: Replace Box> with enum, @@ -69,7 +70,7 @@ impl ParticipantService { } /// Lookup [`Member`] by provided id. - pub fn get_member_by_id(&self, id: &MemberId) -> Option { + pub fn get_member_by_id(&self, id: &MemberId) -> Option> { self.members.get(id).cloned() } @@ -81,7 +82,7 @@ impl ParticipantService { &self, member_id: &MemberId, credentials: &str, - ) -> Result { + ) -> Result, AuthorizationError> { match self.members.get(member_id) { Some(member) => { if member.credentials().eq(credentials) { diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 8cd9c5e1a..ff712505c 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -305,14 +305,15 @@ impl Room { for (id, publish) in member.publish() { for receiver in publish.receivers() { let receiver = receiver.upgrade().unwrap(); // TODO: unwrap + let receiver_owner = receiver.owner().upgrade().unwrap(); if self .participants - .member_has_connection(&receiver.owner_id()) + .member_has_connection(&receiver_owner.id()) && !receiver.is_connected() { let publish_participant = self .participants - .get_member_by_id(&receiver.owner_id()) + .get_member_by_id(&receiver_owner.id()) .unwrap(); self.create_and_interconnect_peers( &member, diff --git a/src/signalling/state/endpoint.rs b/src/signalling/state/endpoint.rs index e4439539f..f51f19e1e 100644 --- a/src/signalling/state/endpoint.rs +++ b/src/signalling/state/endpoint.rs @@ -10,7 +10,7 @@ pub struct Id(pub String); pub struct WebRtcPlayEndpointInner { pub src: SrcUri, pub publisher: Weak, - pub owner_id: MemberId, + pub owner: Weak, pub is_connected: bool, } @@ -19,8 +19,8 @@ impl WebRtcPlayEndpointInner { self.src.clone() } - pub fn owner_id(&self) -> MemberId { - self.owner_id.clone() + pub fn owner(&self) -> Weak { + Weak::clone(&self.owner) } pub fn publisher(&self) -> Weak { @@ -43,12 +43,12 @@ impl WebRtcPlayEndpoint { pub fn new( src: SrcUri, publisher: Weak, - owner_id: MemberId, + owner: Weak, ) -> Self { Self(Mutex::new(RefCell::new(WebRtcPlayEndpointInner { src, publisher, - owner_id, + owner, is_connected: false, }))) } @@ -57,8 +57,8 @@ impl WebRtcPlayEndpoint { self.0.lock().unwrap().borrow().src() } - pub fn owner_id(&self) -> MemberId { - self.0.lock().unwrap().borrow().owner_id() + pub fn owner(&self) -> Weak { + self.0.lock().unwrap().borrow().owner() } pub fn publisher(&self) -> Weak { diff --git a/src/signalling/state/member.rs b/src/signalling/state/member.rs index 125f652c1..15730738a 100644 --- a/src/signalling/state/member.rs +++ b/src/signalling/state/member.rs @@ -9,8 +9,8 @@ use super::endpoint::{ Id as EndpointId, P2pMode, WebRtcPlayEndpoint, WebRtcPublishEndpoint, }; -#[derive(Debug, Clone)] -pub struct Participant(Arc>>); +#[derive(Debug)] +pub struct Participant(Mutex>); #[derive(Debug)] pub struct ParticipantInner { @@ -22,19 +22,19 @@ pub struct ParticipantInner { impl Participant { pub fn new(id: MemberId, credentials: String) -> Self { - Self(Arc::new(Mutex::new(RefCell::new(ParticipantInner { + Self(Mutex::new(RefCell::new(ParticipantInner { id, send: HashMap::new(), recv: HashMap::new(), credentials, - })))) + }))) } pub fn id(&self) -> MemberId { self.0.lock().unwrap().borrow().id.clone() } - pub fn get_store(room_spec: &RoomSpec) -> HashMap { + pub fn get_store(room_spec: &RoomSpec) -> HashMap> { ParticipantInner::get_store(room_spec) } @@ -53,13 +53,15 @@ impl Participant { pub fn load( &self, room_spec: &RoomSpec, - store: &HashMap, + store: &HashMap>, ) { let spec = MemberSpec::try_from( room_spec.pipeline.pipeline.get(&self.id().0).unwrap(), ) .unwrap(); + let me = store.get(&self.id()).unwrap().clone(); + spec.play_endpoints().iter().for_each(|(name_p, p)| { let sender_participant = store.get(&MemberId(p.src.member_id.to_string())).unwrap(); @@ -77,7 +79,7 @@ impl Participant { let play_endpoint = Arc::new(WebRtcPlayEndpoint::new( p.src.clone(), Arc::downgrade(&publisher), - self.id(), + Arc::downgrade(&me), )); self.add_receiver( @@ -97,7 +99,7 @@ impl Participant { let play_endpoint = Arc::new(WebRtcPlayEndpoint::new( p.src.clone(), Arc::downgrade(&send_endpoint), - self.id(), + Arc::downgrade(&me), )); send_endpoint.add_receiver(Arc::downgrade(&play_endpoint)); @@ -163,7 +165,7 @@ impl ParticipantInner { pub fn load( &mut self, room_spec: &RoomSpec, - store: &HashMap, + store: &HashMap>, ) { let spec = MemberSpec::try_from( room_spec.pipeline.pipeline.get(&self.id.0).unwrap(), @@ -189,7 +191,7 @@ impl ParticipantInner { let play_endpoint = Arc::new(WebRtcPlayEndpoint::new( p.src.clone(), Arc::downgrade(&publisher), - me.id(), + Arc::downgrade(&me), )); me.add_receiver( @@ -209,7 +211,7 @@ impl ParticipantInner { let play_endpoint = Arc::new(WebRtcPlayEndpoint::new( p.src.clone(), Arc::downgrade(&send_endpoint), - me.id(), + Arc::downgrade(&me), )); send_endpoint.add_receiver(Arc::downgrade(&play_endpoint)); @@ -228,14 +230,19 @@ impl ParticipantInner { }); } - pub fn get_store(room_spec: &RoomSpec) -> HashMap { + pub fn get_store( + room_spec: &RoomSpec, + ) -> HashMap> { let members = room_spec.members().unwrap(); let mut participants = HashMap::new(); for (id, member) in &members { participants.insert( id.clone(), - Participant::new(id.clone(), member.credentials().to_string()), + Arc::new(Participant::new( + id.clone(), + member.credentials().to_string(), + )), ); } From 5fa34d4c3e5b13c437d0cd494e10cb9616cc9267 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 11 Jun 2019 17:21:52 +0300 Subject: [PATCH 122/735] Use Weak Participant in WebRtcPublishEndpoint --- src/signalling/room.rs | 26 ++++++++++++-------------- src/signalling/state/endpoint.rs | 14 +++++++------- src/signalling/state/member.rs | 8 ++++---- 3 files changed, 23 insertions(+), 25 deletions(-) diff --git a/src/signalling/room.rs b/src/signalling/room.rs index ff712505c..3bc1a1c1e 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -311,13 +311,9 @@ impl Room { .member_has_connection(&receiver_owner.id()) && !receiver.is_connected() { - let publish_participant = self - .participants - .get_member_by_id(&receiver_owner.id()) - .unwrap(); self.create_and_interconnect_peers( &member, - &publish_participant, + &receiver_owner, ctx, ); } @@ -327,16 +323,18 @@ impl Room { // Create all connected play endpoint. // TODO: properly unwrap Weak for (id, play) in member.receivers() { - if self.participants.member_has_connection( - &play.publisher().upgrade().unwrap().owner_id(), - ) && !play.is_connected() + let play_participant = play + .publisher() + .upgrade() + .unwrap() + .owner() + .upgrade() + .unwrap(); + if self + .participants + .member_has_connection(&play_participant.id()) + && !play.is_connected() { - let play_participant = self - .participants - .get_member_by_id( - &play.publisher().upgrade().unwrap().owner_id(), - ) - .unwrap(); self.create_and_interconnect_peers( &member, &play_participant, diff --git a/src/signalling/state/endpoint.rs b/src/signalling/state/endpoint.rs index f51f19e1e..b9577c71e 100644 --- a/src/signalling/state/endpoint.rs +++ b/src/signalling/state/endpoint.rs @@ -83,7 +83,7 @@ pub enum P2pMode { pub struct WebRtcPublishEndpointInner { pub p2p: P2pMode, pub receivers: Vec>, - pub owner_id: MemberId, + pub owner: Weak, } impl WebRtcPublishEndpointInner { @@ -95,8 +95,8 @@ impl WebRtcPublishEndpointInner { self.receivers.clone() } - pub fn owner_id(&self) -> MemberId { - self.owner_id.clone() + pub fn owner(&self) -> Weak { + Weak::clone(&self.owner) } } @@ -107,12 +107,12 @@ impl WebRtcPublishEndpoint { pub fn new( p2p: P2pMode, receivers: Vec>, - owner_id: MemberId, + owner: Weak, ) -> Self { Self(Mutex::new(RefCell::new(WebRtcPublishEndpointInner { p2p, receivers, - owner_id, + owner, }))) } @@ -124,7 +124,7 @@ impl WebRtcPublishEndpoint { self.0.lock().unwrap().borrow().receivers() } - pub fn owner_id(&self) -> MemberId { - self.0.lock().unwrap().borrow().owner_id() + pub fn owner(&self) -> Weak { + self.0.lock().unwrap().borrow().owner() } } diff --git a/src/signalling/state/member.rs b/src/signalling/state/member.rs index 15730738a..36542245d 100644 --- a/src/signalling/state/member.rs +++ b/src/signalling/state/member.rs @@ -69,7 +69,7 @@ impl Participant { let publisher = WebRtcPublishEndpoint::new( P2pMode::Always, Vec::new(), - sender_participant.id(), + Arc::downgrade(&sender_participant), ); match sender_participant @@ -93,7 +93,7 @@ impl Participant { let send_endpoint = Arc::new(WebRtcPublishEndpoint::new( P2pMode::Always, Vec::new(), - sender_participant.id(), + Arc::downgrade(&sender_participant), )); let play_endpoint = Arc::new(WebRtcPlayEndpoint::new( @@ -181,7 +181,7 @@ impl ParticipantInner { let publisher = WebRtcPublishEndpoint::new( P2pMode::Always, Vec::new(), - sender_participant.id(), + Arc::downgrade(&sender_participant), ); match sender_participant @@ -205,7 +205,7 @@ impl ParticipantInner { let send_endpoint = Arc::new(WebRtcPublishEndpoint::new( P2pMode::Always, Vec::new(), - sender_participant.id(), + Arc::downgrade(&sender_participant), )); let play_endpoint = Arc::new(WebRtcPlayEndpoint::new( From e4f9dc2cb7ac3ebe7319ab9845a0f2309893067a Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 11 Jun 2019 17:34:48 +0300 Subject: [PATCH 123/735] Use publisher spec --- src/signalling/state/endpoint.rs | 10 ++++------ src/signalling/state/member.rs | 22 +++++++++++++++++----- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/signalling/state/endpoint.rs b/src/signalling/state/endpoint.rs index b9577c71e..6a4c72484 100644 --- a/src/signalling/state/endpoint.rs +++ b/src/signalling/state/endpoint.rs @@ -1,5 +1,8 @@ use super::member::Participant; -use crate::api::control::{endpoint::SrcUri, MemberId}; +use crate::api::control::{ + endpoint::{P2pMode, SrcUri}, + MemberId, +}; use std::cell::RefCell; use std::sync::{Arc, Mutex, Weak}; @@ -74,11 +77,6 @@ impl WebRtcPlayEndpoint { } } -#[derive(Debug, Clone)] -pub enum P2pMode { - Always, -} - #[derive(Debug, Clone)] pub struct WebRtcPublishEndpointInner { pub p2p: P2pMode, diff --git a/src/signalling/state/member.rs b/src/signalling/state/member.rs index 36542245d..fed60e55a 100644 --- a/src/signalling/state/member.rs +++ b/src/signalling/state/member.rs @@ -1,12 +1,12 @@ use std::convert::TryFrom; use std::sync::{Arc, Mutex, Weak}; -use crate::api::control::{MemberId, MemberSpec, RoomSpec}; +use crate::api::control::{endpoint::P2pMode, MemberId, MemberSpec, RoomSpec}; use hashbrown::HashMap; use std::cell::RefCell; use super::endpoint::{ - Id as EndpointId, P2pMode, WebRtcPlayEndpoint, WebRtcPublishEndpoint, + Id as EndpointId, WebRtcPlayEndpoint, WebRtcPublishEndpoint, }; #[derive(Debug)] @@ -175,11 +175,23 @@ impl ParticipantInner { let me = store.get(&self.id).unwrap(); spec.play_endpoints().iter().for_each(|(name_p, p)| { - let sender_participant = - store.get(&MemberId(p.src.member_id.to_string())).unwrap(); + let sender_participant = store.get(&p.src.member_id).unwrap(); + let publisher_spec = MemberSpec::try_from( + room_spec + .pipeline + .pipeline + .get(&p.src.member_id.to_string()) + .unwrap(), + ) + .unwrap(); + + let publisher_endpoint = *publisher_spec + .publish_endpoints() + .get(&p.src.endpoint_id) + .unwrap(); let publisher = WebRtcPublishEndpoint::new( - P2pMode::Always, + publisher_endpoint.p2p.clone(), Vec::new(), Arc::downgrade(&sender_participant), ); From 1eb79e62f28a12a1d6815349e7bfb58cecf4dfaf Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 11 Jun 2019 17:37:06 +0300 Subject: [PATCH 124/735] Make WebRtc*EndpointInner private --- src/signalling/state/endpoint.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/signalling/state/endpoint.rs b/src/signalling/state/endpoint.rs index 6a4c72484..7334f199c 100644 --- a/src/signalling/state/endpoint.rs +++ b/src/signalling/state/endpoint.rs @@ -10,11 +10,11 @@ use std::sync::{Arc, Mutex, Weak}; pub struct Id(pub String); #[derive(Debug, Clone)] -pub struct WebRtcPlayEndpointInner { - pub src: SrcUri, - pub publisher: Weak, - pub owner: Weak, - pub is_connected: bool, +struct WebRtcPlayEndpointInner { + src: SrcUri, + publisher: Weak, + owner: Weak, + is_connected: bool, } impl WebRtcPlayEndpointInner { @@ -78,10 +78,10 @@ impl WebRtcPlayEndpoint { } #[derive(Debug, Clone)] -pub struct WebRtcPublishEndpointInner { - pub p2p: P2pMode, - pub receivers: Vec>, - pub owner: Weak, +struct WebRtcPublishEndpointInner { + p2p: P2pMode, + receivers: Vec>, + owner: Weak, } impl WebRtcPublishEndpointInner { From 26fc88e949b34f5d5f02173f173ddcdb110cc850 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 11 Jun 2019 17:51:55 +0300 Subject: [PATCH 125/735] Fix warnings and add publish endpoint creating --- src/media/peer.rs | 7 +------ src/signalling/peers.rs | 4 +--- src/signalling/room.rs | 4 ++-- src/signalling/state/endpoint.rs | 7 ++----- src/signalling/state/member.rs | 30 ++++++++++++++++-------------- 5 files changed, 22 insertions(+), 30 deletions(-) diff --git a/src/media/peer.rs b/src/media/peer.rs index 416a84e68..740a8abef 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -16,12 +16,7 @@ use crate::{ api::control::MemberId, media::{MediaTrack, TrackId}, signalling::peers::Counter, - signalling::state::{ - endpoint::{ - Id as EndpointId, WebRtcPlayEndpoint, WebRtcPublishEndpoint, - }, - member::Participant, - }, + signalling::state::endpoint::{Id as EndpointId, WebRtcPublishEndpoint}, }; /// Newly initialized [`Peer`] ready to signalling. diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index 647a927af..4c421b398 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -10,14 +10,12 @@ use hashbrown::HashMap; use crate::{ api::control::MemberId, - media::{MediaTrack, Peer, PeerId, PeerStateMachine}, + media::{Peer, PeerId, PeerStateMachine}, signalling::{ room::{PeersRemoved, Room, RoomError}, state::member::Participant, }, }; -use medea_client_api_proto::{AudioSettings, MediaType, VideoSettings}; -use std::sync::Arc; #[derive(Debug)] pub struct PeerRepository { diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 3bc1a1c1e..92bcdb109 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -302,7 +302,7 @@ impl Room { }; // Create all connected publish endpoints. - for (id, publish) in member.publish() { + for (_id, publish) in member.publish() { for receiver in publish.receivers() { let receiver = receiver.upgrade().unwrap(); // TODO: unwrap let receiver_owner = receiver.owner().upgrade().unwrap(); @@ -322,7 +322,7 @@ impl Room { // Create all connected play endpoint. // TODO: properly unwrap Weak - for (id, play) in member.receivers() { + for (_id, play) in member.receivers() { let play_participant = play .publisher() .upgrade() diff --git a/src/signalling/state/endpoint.rs b/src/signalling/state/endpoint.rs index 7334f199c..2954ffe59 100644 --- a/src/signalling/state/endpoint.rs +++ b/src/signalling/state/endpoint.rs @@ -1,10 +1,7 @@ use super::member::Participant; -use crate::api::control::{ - endpoint::{P2pMode, SrcUri}, - MemberId, -}; +use crate::api::control::endpoint::{P2pMode, SrcUri}; use std::cell::RefCell; -use std::sync::{Arc, Mutex, Weak}; +use std::sync::{Mutex, Weak}; #[derive(Clone, Debug, Eq, Hash, PartialEq)] pub struct Id(pub String); diff --git a/src/signalling/state/member.rs b/src/signalling/state/member.rs index fed60e55a..552ec62e2 100644 --- a/src/signalling/state/member.rs +++ b/src/signalling/state/member.rs @@ -1,5 +1,5 @@ use std::convert::TryFrom; -use std::sync::{Arc, Mutex, Weak}; +use std::sync::{Arc, Mutex}; use crate::api::control::{endpoint::P2pMode, MemberId, MemberSpec, RoomSpec}; use hashbrown::HashMap; @@ -66,12 +66,6 @@ impl Participant { let sender_participant = store.get(&MemberId(p.src.member_id.to_string())).unwrap(); - let publisher = WebRtcPublishEndpoint::new( - P2pMode::Always, - Vec::new(), - Arc::downgrade(&sender_participant), - ); - match sender_participant .get_publisher(&EndpointId(p.src.endpoint_id.to_string())) { @@ -190,12 +184,6 @@ impl ParticipantInner { .get(&p.src.endpoint_id) .unwrap(); - let publisher = WebRtcPublishEndpoint::new( - publisher_endpoint.p2p.clone(), - Vec::new(), - Arc::downgrade(&sender_participant), - ); - match sender_participant .get_publisher(&EndpointId(p.src.endpoint_id.to_string())) { @@ -215,7 +203,7 @@ impl ParticipantInner { } None => { let send_endpoint = Arc::new(WebRtcPublishEndpoint::new( - P2pMode::Always, + publisher_endpoint.p2p.clone(), Vec::new(), Arc::downgrade(&sender_participant), )); @@ -240,6 +228,20 @@ impl ParticipantInner { } } }); + + spec.publish_endpoints().into_iter().for_each(|(name, e)| { + let endpoint_id = EndpointId(name.clone()); + if let None = self.send.get(&endpoint_id) { + self.send.insert( + endpoint_id, + Arc::new(WebRtcPublishEndpoint::new( + e.p2p.clone(), + Vec::new(), + Arc::downgrade(me), + )), + ); + } + }) } pub fn get_store( From d929246612689285799c761969b0105eb93afbe9 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 11 Jun 2019 18:02:58 +0300 Subject: [PATCH 126/735] Remove old load() --- src/signalling/state/member.rs | 119 ++++++++------------------------- 1 file changed, 29 insertions(+), 90 deletions(-) diff --git a/src/signalling/state/member.rs b/src/signalling/state/member.rs index 552ec62e2..978a760d5 100644 --- a/src/signalling/state/member.rs +++ b/src/signalling/state/member.rs @@ -1,7 +1,7 @@ use std::convert::TryFrom; use std::sync::{Arc, Mutex}; -use crate::api::control::{endpoint::P2pMode, MemberId, MemberSpec, RoomSpec}; +use crate::api::control::{MemberId, MemberSpec, RoomSpec}; use hashbrown::HashMap; use std::cell::RefCell; @@ -65,6 +65,19 @@ impl Participant { spec.play_endpoints().iter().for_each(|(name_p, p)| { let sender_participant = store.get(&MemberId(p.src.member_id.to_string())).unwrap(); + let publisher_spec = MemberSpec::try_from( + room_spec + .pipeline + .pipeline + .get(&p.src.member_id.to_string()) + .unwrap(), + ) + .unwrap(); + + let publisher_endpoint = *publisher_spec + .publish_endpoints() + .get(&p.src.endpoint_id) + .unwrap(); match sender_participant .get_publisher(&EndpointId(p.src.endpoint_id.to_string())) @@ -85,7 +98,7 @@ impl Participant { } None => { let send_endpoint = Arc::new(WebRtcPublishEndpoint::new( - P2pMode::Always, + publisher_endpoint.p2p.clone(), Vec::new(), Arc::downgrade(&sender_participant), )); @@ -110,6 +123,20 @@ impl Participant { } } }); + + spec.publish_endpoints().into_iter().for_each(|(name, e)| { + let endpoint_id = EndpointId(name.clone()); + if let None = self.publish().get(&endpoint_id) { + self.add_sender( + endpoint_id, + Arc::new(WebRtcPublishEndpoint::new( + e.p2p.clone(), + Vec::new(), + Arc::downgrade(&me), + )), + ); + } + }) } pub fn add_receiver( @@ -156,94 +183,6 @@ impl ParticipantInner { } } - pub fn load( - &mut self, - room_spec: &RoomSpec, - store: &HashMap>, - ) { - let spec = MemberSpec::try_from( - room_spec.pipeline.pipeline.get(&self.id.0).unwrap(), - ) - .unwrap(); - - let me = store.get(&self.id).unwrap(); - - spec.play_endpoints().iter().for_each(|(name_p, p)| { - let sender_participant = store.get(&p.src.member_id).unwrap(); - let publisher_spec = MemberSpec::try_from( - room_spec - .pipeline - .pipeline - .get(&p.src.member_id.to_string()) - .unwrap(), - ) - .unwrap(); - - let publisher_endpoint = *publisher_spec - .publish_endpoints() - .get(&p.src.endpoint_id) - .unwrap(); - - match sender_participant - .get_publisher(&EndpointId(p.src.endpoint_id.to_string())) - { - Some(publisher) => { - let play_endpoint = Arc::new(WebRtcPlayEndpoint::new( - p.src.clone(), - Arc::downgrade(&publisher), - Arc::downgrade(&me), - )); - - me.add_receiver( - EndpointId(name_p.to_string()), - Arc::clone(&play_endpoint), - ); - - publisher.add_receiver(Arc::downgrade(&play_endpoint)); - } - None => { - let send_endpoint = Arc::new(WebRtcPublishEndpoint::new( - publisher_endpoint.p2p.clone(), - Vec::new(), - Arc::downgrade(&sender_participant), - )); - - let play_endpoint = Arc::new(WebRtcPlayEndpoint::new( - p.src.clone(), - Arc::downgrade(&send_endpoint), - Arc::downgrade(&me), - )); - - send_endpoint.add_receiver(Arc::downgrade(&play_endpoint)); - - sender_participant.add_sender( - EndpointId(p.src.endpoint_id.to_string()), - send_endpoint, - ); - - me.add_receiver( - EndpointId(name_p.to_string()), - play_endpoint, - ); - } - } - }); - - spec.publish_endpoints().into_iter().for_each(|(name, e)| { - let endpoint_id = EndpointId(name.clone()); - if let None = self.send.get(&endpoint_id) { - self.send.insert( - endpoint_id, - Arc::new(WebRtcPublishEndpoint::new( - e.p2p.clone(), - Vec::new(), - Arc::downgrade(me), - )), - ); - } - }) - } - pub fn get_store( room_spec: &RoomSpec, ) -> HashMap> { From 3c9432078df75d350c4c6d3475f374dd5f461059 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 11 Jun 2019 18:38:22 +0300 Subject: [PATCH 127/735] Return Result in loading spec --- src/signalling/participants.rs | 13 ++++-- src/signalling/room.rs | 11 ++++- src/signalling/state/member.rs | 83 +++++++++++++++++++++++++--------- 3 files changed, 81 insertions(+), 26 deletions(-) diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 0137e9d2f..c7a92e712 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -19,10 +19,14 @@ use crate::{ AuthorizationError, ClosedReason, EventMessage, RpcConnection, RpcConnectionClosed, }, - control::{MemberId, RoomSpec, TryFromElementError}, + control::{MemberId, RoomSpec}, }, log::prelude::*, - signalling::{room::RoomError, state::member::Participant, Room}, + signalling::{ + room::RoomError, + state::member::{Participant, ParticipantsLoadError}, + Room, + }, }; /// Participant is [`Member`] with [`RpcConnection`]. [`ParticipantService`] @@ -53,8 +57,9 @@ impl ParticipantService { pub fn new( room_spec: &RoomSpec, reconnect_timeout: Duration, - ) -> Result { - let members = Participant::get_store(room_spec); + ) -> Result { + let members = Participant::get_store(room_spec)?; + // TODO: more informative msg debug!( "Created room with {:?} members.", diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 92bcdb109..2cb69e856 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -27,7 +27,7 @@ use crate::{ }, signalling::{ participants::ParticipantService, peers::PeerRepository, - state::member::Participant, + state::member::{Participant, ParticipantsLoadError}, }, }; @@ -64,6 +64,15 @@ impl From for RoomError { } } +impl From for RoomError { + fn from(err: ParticipantsLoadError) -> Self { + RoomError::BadRoomSpec(format!( + "Error while loading room spec. {}", + err + )) + } +} + /// Media server room with its [`Member`]s. #[derive(Debug)] pub struct Room { diff --git a/src/signalling/state/member.rs b/src/signalling/state/member.rs index 978a760d5..7c152be3f 100644 --- a/src/signalling/state/member.rs +++ b/src/signalling/state/member.rs @@ -1,7 +1,10 @@ use std::convert::TryFrom; use std::sync::{Arc, Mutex}; -use crate::api::control::{MemberId, MemberSpec, RoomSpec}; +use crate::api::control::{ + MemberId, MemberSpec, RoomSpec, TryFromElementError, +}; +use failure::Fail; use hashbrown::HashMap; use std::cell::RefCell; @@ -9,6 +12,22 @@ use super::endpoint::{ Id as EndpointId, WebRtcPlayEndpoint, WebRtcPublishEndpoint, }; +#[derive(Debug, Fail)] +pub enum ParticipantsLoadError { + #[fail(display = "TryFromElementError: {}", _0)] + TryFromError(TryFromElementError), + #[fail(display = "Member with id '{}' not found.", _0)] + MemberNotFound(MemberId), + #[fail(display = "Endpoint with id '{}' not found.", _0)] + EndpointNotFound(String), +} + +impl From for ParticipantsLoadError { + fn from(err: TryFromElementError) -> ParticipantsLoadError { + ParticipantsLoadError::TryFromError(err) + } +} + #[derive(Debug)] pub struct Participant(Mutex>); @@ -34,7 +53,9 @@ impl Participant { self.0.lock().unwrap().borrow().id.clone() } - pub fn get_store(room_spec: &RoomSpec) -> HashMap> { + pub fn get_store( + room_spec: &RoomSpec, + ) -> Result>, ParticipantsLoadError> { ParticipantInner::get_store(room_spec) } @@ -54,30 +75,47 @@ impl Participant { &self, room_spec: &RoomSpec, store: &HashMap>, - ) { + ) -> Result<(), ParticipantsLoadError> { let spec = MemberSpec::try_from( - room_spec.pipeline.pipeline.get(&self.id().0).unwrap(), - ) - .unwrap(); - - let me = store.get(&self.id()).unwrap().clone(); - - spec.play_endpoints().iter().for_each(|(name_p, p)| { + room_spec + .pipeline + .pipeline + .get(&self.id().0) + .map(|e| Ok(e)) + .unwrap_or(Err(ParticipantsLoadError::MemberNotFound( + self.id(), + )))?, + )?; + + let me = store + .get(&self.id()) + .map(|p| Ok(p)) + .unwrap_or(Err(ParticipantsLoadError::MemberNotFound(self.id())))?; + + for (name_p, p) in spec.play_endpoints() { + let sender_id = MemberId(p.src.member_id.to_string()); let sender_participant = - store.get(&MemberId(p.src.member_id.to_string())).unwrap(); + store.get(&sender_id).map(|p| Ok(p)).unwrap_or(Err( + ParticipantsLoadError::MemberNotFound(sender_id), + ))?; let publisher_spec = MemberSpec::try_from( room_spec .pipeline .pipeline .get(&p.src.member_id.to_string()) - .unwrap(), - ) - .unwrap(); + .map(|e| Ok(e)) + .unwrap_or(Err(ParticipantsLoadError::MemberNotFound( + p.src.member_id.clone(), + )))?, + )?; let publisher_endpoint = *publisher_spec .publish_endpoints() .get(&p.src.endpoint_id) - .unwrap(); + .map(|e| Ok(e)) + .unwrap_or(Err(ParticipantsLoadError::EndpointNotFound( + p.src.endpoint_id.clone(), + )))?; match sender_participant .get_publisher(&EndpointId(p.src.endpoint_id.to_string())) @@ -122,7 +160,7 @@ impl Participant { ); } } - }); + } spec.publish_endpoints().into_iter().for_each(|(name, e)| { let endpoint_id = EndpointId(name.clone()); @@ -136,7 +174,9 @@ impl Participant { )), ); } - }) + }); + + Ok(()) } pub fn add_receiver( @@ -185,8 +225,9 @@ impl ParticipantInner { pub fn get_store( room_spec: &RoomSpec, - ) -> HashMap> { - let members = room_spec.members().unwrap(); + ) -> Result>, ParticipantsLoadError> + { + let members = room_spec.members()?; let mut participants = HashMap::new(); for (id, member) in &members { @@ -200,12 +241,12 @@ impl ParticipantInner { } for (_, participant) in &participants { - participant.load(room_spec, &participants); + participant.load(room_spec, &participants)?; } // println!("\n\n\n\n{:#?}\n\n\n\n", participants); - participants + Ok(participants) } } From 9548c542ec9f4b1e1e275558b2b7090259b90cfe Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 11 Jun 2019 19:37:43 +0300 Subject: [PATCH 128/735] Fix lints --- src/signalling/room.rs | 3 +- src/signalling/state/endpoint.rs | 2 + src/signalling/state/member.rs | 127 +++++++++++++++---------------- 3 files changed, 66 insertions(+), 66 deletions(-) diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 2cb69e856..b338ef76d 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -26,7 +26,8 @@ use crate::{ WaitLocalHaveRemote, WaitLocalSdp, WaitRemoteSdp, }, signalling::{ - participants::ParticipantService, peers::PeerRepository, + participants::ParticipantService, + peers::PeerRepository, state::member::{Participant, ParticipantsLoadError}, }, }; diff --git a/src/signalling/state/endpoint.rs b/src/signalling/state/endpoint.rs index 2954ffe59..19c80519c 100644 --- a/src/signalling/state/endpoint.rs +++ b/src/signalling/state/endpoint.rs @@ -36,6 +36,7 @@ impl WebRtcPlayEndpointInner { } } +#[allow(clippy::module_name_repetitions)] #[derive(Debug)] pub struct WebRtcPlayEndpoint(Mutex>); @@ -95,6 +96,7 @@ impl WebRtcPublishEndpointInner { } } +#[allow(clippy::module_name_repetitions)] #[derive(Debug)] pub struct WebRtcPublishEndpoint(Mutex>); diff --git a/src/signalling/state/member.rs b/src/signalling/state/member.rs index 7c152be3f..93a37d3f5 100644 --- a/src/signalling/state/member.rs +++ b/src/signalling/state/member.rs @@ -23,7 +23,7 @@ pub enum ParticipantsLoadError { } impl From for ParticipantsLoadError { - fn from(err: TryFromElementError) -> ParticipantsLoadError { + fn from(err: TryFromElementError) -> Self { ParticipantsLoadError::TryFromError(err) } } @@ -74,97 +74,94 @@ impl Participant { pub fn load( &self, room_spec: &RoomSpec, - store: &HashMap>, + store: &HashMap>, ) -> Result<(), ParticipantsLoadError> { let spec = MemberSpec::try_from( - room_spec - .pipeline - .pipeline - .get(&self.id().0) - .map(|e| Ok(e)) - .unwrap_or(Err(ParticipantsLoadError::MemberNotFound( - self.id(), - )))?, + room_spec.pipeline.pipeline.get(&self.id().0).map_or( + Err(ParticipantsLoadError::MemberNotFound(self.id())), + Ok, + )?, )?; - let me = store - .get(&self.id()) - .map(|p| Ok(p)) - .unwrap_or(Err(ParticipantsLoadError::MemberNotFound(self.id())))?; + let me = store.get(&self.id()).map_or( + Err(ParticipantsLoadError::MemberNotFound(self.id())), + Ok, + )?; for (name_p, p) in spec.play_endpoints() { let sender_id = MemberId(p.src.member_id.to_string()); - let sender_participant = - store.get(&sender_id).map(|p| Ok(p)).unwrap_or(Err( - ParticipantsLoadError::MemberNotFound(sender_id), - ))?; + let sender_participant = store.get(&sender_id).map_or( + Err(ParticipantsLoadError::MemberNotFound(sender_id)), + Ok, + )?; let publisher_spec = MemberSpec::try_from( room_spec .pipeline .pipeline .get(&p.src.member_id.to_string()) - .map(|e| Ok(e)) - .unwrap_or(Err(ParticipantsLoadError::MemberNotFound( - p.src.member_id.clone(), - )))?, + .map_or( + Err(ParticipantsLoadError::MemberNotFound( + p.src.member_id.clone(), + )), + Ok, + )?, )?; let publisher_endpoint = *publisher_spec .publish_endpoints() .get(&p.src.endpoint_id) - .map(|e| Ok(e)) - .unwrap_or(Err(ParticipantsLoadError::EndpointNotFound( - p.src.endpoint_id.clone(), - )))?; + .map_or( + Err(ParticipantsLoadError::EndpointNotFound( + p.src.endpoint_id.clone(), + )), + Ok, + )?; - match sender_participant + if let Some(publisher) = sender_participant .get_publisher(&EndpointId(p.src.endpoint_id.to_string())) { - Some(publisher) => { - let play_endpoint = Arc::new(WebRtcPlayEndpoint::new( - p.src.clone(), - Arc::downgrade(&publisher), - Arc::downgrade(&me), - )); - - self.add_receiver( - EndpointId(name_p.to_string()), - Arc::clone(&play_endpoint), - ); - - publisher.add_receiver(Arc::downgrade(&play_endpoint)); - } - None => { - let send_endpoint = Arc::new(WebRtcPublishEndpoint::new( - publisher_endpoint.p2p.clone(), - Vec::new(), - Arc::downgrade(&sender_participant), - )); - - let play_endpoint = Arc::new(WebRtcPlayEndpoint::new( - p.src.clone(), - Arc::downgrade(&send_endpoint), - Arc::downgrade(&me), - )); - - send_endpoint.add_receiver(Arc::downgrade(&play_endpoint)); + let play_endpoint = Arc::new(WebRtcPlayEndpoint::new( + p.src.clone(), + Arc::downgrade(&publisher), + Arc::downgrade(&me), + )); + + self.add_receiver( + EndpointId(name_p.to_string()), + Arc::clone(&play_endpoint), + ); - sender_participant.add_sender( - EndpointId(p.src.endpoint_id.to_string()), - send_endpoint, - ); + publisher.add_receiver(Arc::downgrade(&play_endpoint)); + } else { + let send_endpoint = Arc::new(WebRtcPublishEndpoint::new( + publisher_endpoint.p2p.clone(), + Vec::new(), + Arc::downgrade(&sender_participant), + )); + + let play_endpoint = Arc::new(WebRtcPlayEndpoint::new( + p.src.clone(), + Arc::downgrade(&send_endpoint), + Arc::downgrade(&me), + )); + + send_endpoint.add_receiver(Arc::downgrade(&play_endpoint)); + + sender_participant.add_sender( + EndpointId(p.src.endpoint_id.to_string()), + send_endpoint, + ); - self.add_receiver( - EndpointId(name_p.to_string()), - play_endpoint, - ); - } + self.add_receiver( + EndpointId(name_p.to_string()), + play_endpoint, + ); } } spec.publish_endpoints().into_iter().for_each(|(name, e)| { let endpoint_id = EndpointId(name.clone()); - if let None = self.publish().get(&endpoint_id) { + if self.publish().get(&endpoint_id).is_none() { self.add_sender( endpoint_id, Arc::new(WebRtcPublishEndpoint::new( From e5de00c57fd2201c7dd314d875ebcc7100b9d090 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 11 Jun 2019 20:13:45 +0300 Subject: [PATCH 129/735] Refactor --- src/api/control/pipeline.rs | 6 +- src/signalling/participants.rs | 10 +- src/signalling/peers.rs | 8 +- src/signalling/room.rs | 10 +- src/signalling/state/endpoint.rs | 26 +-- src/signalling/state/mod.rs | 2 +- .../state/{member.rs => participant.rs} | 160 ++++++++++-------- 7 files changed, 121 insertions(+), 101 deletions(-) rename src/signalling/state/{member.rs => participant.rs} (51%) diff --git a/src/api/control/pipeline.rs b/src/api/control/pipeline.rs index 248219e6e..1456ae7d2 100644 --- a/src/api/control/pipeline.rs +++ b/src/api/control/pipeline.rs @@ -15,13 +15,17 @@ use crate::api::control::Element; /// Entity that represents some pipeline of spec. #[derive(Clone, Deserialize, Debug)] pub struct Pipeline { - pub pipeline: HashMap, + pipeline: HashMap, } impl Pipeline { pub fn iter(&self) -> impl Iterator { self.into_iter() } + + pub fn get(&self, id: &str) -> Option<&Element> { + self.pipeline.get(id) + } } impl IntoIterator for Pipeline { diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index c7a92e712..cf48a7c7d 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -2,8 +2,10 @@ //! stores [`Members`] and associated [`RpcConnection`]s, handles //! [`RpcConnection`] authorization, establishment, message sending. -use std::sync::Arc; -use std::time::{Duration, Instant}; +use std::{ + sync::Arc, + time::{Duration, Instant}, +}; use actix::{fut::wrap_future, AsyncContext, Context, SpawnHandle}; use futures::{ @@ -24,7 +26,7 @@ use crate::{ log::prelude::*, signalling::{ room::RoomError, - state::member::{Participant, ParticipantsLoadError}, + state::participant::{Participant, ParticipantsLoadError}, Room, }, }; @@ -58,7 +60,7 @@ impl ParticipantService { room_spec: &RoomSpec, reconnect_timeout: Duration, ) -> Result { - let members = Participant::get_store(room_spec)?; + let members = Participant::load_store(room_spec)?; // TODO: more informative msg debug!( diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index 4c421b398..a06950d33 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -13,7 +13,7 @@ use crate::{ media::{Peer, PeerId, PeerStateMachine}, signalling::{ room::{PeersRemoved, Room, RoomError}, - state::member::Participant, + state::participant::Participant, }, }; @@ -69,7 +69,7 @@ impl PeerRepository { .ok_or_else(|| RoomError::PeerNotFound(peer_id)) } - /// Create and interconnect [`Peer`]s based on [`MemberSpec`]. + /// Create and interconnect [`Peer`]s based on [`Participant`]. /// /// Returns IDs of created [`Peer`]s. `(first_peer_id, second_peer_id)`. pub fn create_peers( @@ -101,12 +101,12 @@ impl PeerRepository { first_peer.add_publish_endpoints( &mut second_peer, &mut self.tracks_count, - first_member.publish(), + first_member.publishers(), ); second_peer.add_publish_endpoints( &mut first_peer, &mut self.tracks_count, - second_member.publish(), + second_member.publishers(), ); self.add_peer(first_peer_id, first_peer); diff --git a/src/signalling/room.rs b/src/signalling/room.rs index b338ef76d..c8051f603 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -28,7 +28,7 @@ use crate::{ signalling::{ participants::ParticipantService, peers::PeerRepository, - state::member::{Participant, ParticipantsLoadError}, + state::participant::{Participant, ParticipantsLoadError}, }, }; @@ -265,8 +265,8 @@ impl Room { ))) } - /// Create [`Peer`] between [`Member`]s and interconnect it by control API - /// spec. + /// Create [`Peer`] between [`Participant`]s and interconnect it by control + /// API spec. fn create_and_interconnect_peers( &mut self, first_member: &Participant, @@ -288,7 +288,7 @@ impl Room { } /// Create and interconnect all [`Peer`]s between connected [`Member`] - /// and all available at this moment [`Member`]s from [`MemberSpec`]. + /// and all available at this moment [`Member`]s from [`Participant`]. /// /// Availability is determines by checking [`RpcConnection`] of all /// [`Member`]s from [`WebRtcPlayEndpoint`]s and from receivers of @@ -312,7 +312,7 @@ impl Room { }; // Create all connected publish endpoints. - for (_id, publish) in member.publish() { + for (_id, publish) in member.publishers() { for receiver in publish.receivers() { let receiver = receiver.upgrade().unwrap(); // TODO: unwrap let receiver_owner = receiver.owner().upgrade().unwrap(); diff --git a/src/signalling/state/endpoint.rs b/src/signalling/state/endpoint.rs index 19c80519c..12e004478 100644 --- a/src/signalling/state/endpoint.rs +++ b/src/signalling/state/endpoint.rs @@ -1,7 +1,11 @@ -use super::member::Participant; +use std::{ + cell::RefCell, + sync::{Mutex, Weak}, +}; + use crate::api::control::endpoint::{P2pMode, SrcUri}; -use std::cell::RefCell; -use std::sync::{Mutex, Weak}; + +use super::participant::Participant; #[derive(Clone, Debug, Eq, Hash, PartialEq)] pub struct Id(pub String); @@ -15,23 +19,23 @@ struct WebRtcPlayEndpointInner { } impl WebRtcPlayEndpointInner { - pub fn src(&self) -> SrcUri { + fn src(&self) -> SrcUri { self.src.clone() } - pub fn owner(&self) -> Weak { + fn owner(&self) -> Weak { Weak::clone(&self.owner) } - pub fn publisher(&self) -> Weak { + fn publisher(&self) -> Weak { self.publisher.clone() } - pub fn is_connected(&self) -> bool { + fn is_connected(&self) -> bool { self.is_connected } - pub fn set_is_connected(&mut self, value: bool) { + fn set_is_connected(&mut self, value: bool) { self.is_connected = value; } } @@ -83,15 +87,15 @@ struct WebRtcPublishEndpointInner { } impl WebRtcPublishEndpointInner { - pub fn add_receiver(&mut self, receiver: Weak) { + fn add_receiver(&mut self, receiver: Weak) { self.receivers.push(receiver); } - pub fn receivers(&self) -> Vec> { + fn receivers(&self) -> Vec> { self.receivers.clone() } - pub fn owner(&self) -> Weak { + fn owner(&self) -> Weak { Weak::clone(&self.owner) } } diff --git a/src/signalling/state/mod.rs b/src/signalling/state/mod.rs index bcbf282ff..e20afdd53 100644 --- a/src/signalling/state/mod.rs +++ b/src/signalling/state/mod.rs @@ -1,2 +1,2 @@ pub mod endpoint; -pub mod member; +pub mod participant; diff --git a/src/signalling/state/member.rs b/src/signalling/state/participant.rs similarity index 51% rename from src/signalling/state/member.rs rename to src/signalling/state/participant.rs index 93a37d3f5..65056cac8 100644 --- a/src/signalling/state/member.rs +++ b/src/signalling/state/participant.rs @@ -1,12 +1,15 @@ -use std::convert::TryFrom; -use std::sync::{Arc, Mutex}; +use std::{ + cell::RefCell, + convert::TryFrom as _, + sync::{Arc, Mutex}, +}; + +use failure::Fail; +use hashbrown::HashMap; use crate::api::control::{ MemberId, MemberSpec, RoomSpec, TryFromElementError, }; -use failure::Fail; -use hashbrown::HashMap; -use std::cell::RefCell; use super::endpoint::{ Id as EndpointId, WebRtcPlayEndpoint, WebRtcPublishEndpoint, @@ -31,20 +34,21 @@ impl From for ParticipantsLoadError { #[derive(Debug)] pub struct Participant(Mutex>); +#[allow(clippy::module_name_repetitions)] #[derive(Debug)] pub struct ParticipantInner { id: MemberId, - send: HashMap>, - recv: HashMap>, + publishers: HashMap>, + receivers: HashMap>, credentials: String, } impl Participant { - pub fn new(id: MemberId, credentials: String) -> Self { + fn new(id: MemberId, credentials: String) -> Self { Self(Mutex::new(RefCell::new(ParticipantInner { id, - send: HashMap::new(), - recv: HashMap::new(), + publishers: HashMap::new(), + receivers: HashMap::new(), credentials, }))) } @@ -53,55 +57,59 @@ impl Participant { self.0.lock().unwrap().borrow().id.clone() } - pub fn get_store( + pub fn load_store( room_spec: &RoomSpec, ) -> Result>, ParticipantsLoadError> { - ParticipantInner::get_store(room_spec) + ParticipantInner::load_store(room_spec) } pub fn credentials(&self) -> String { self.0.lock().unwrap().borrow().credentials.clone() } - pub fn publish(&self) -> HashMap> { - self.0.lock().unwrap().borrow().send.clone() + pub fn publishers( + &self, + ) -> HashMap> { + self.0.lock().unwrap().borrow().publishers.clone() } pub fn receivers(&self) -> HashMap> { - self.0.lock().unwrap().borrow().recv.clone() + self.0.lock().unwrap().borrow().receivers.clone() } - pub fn load( + fn load( &self, room_spec: &RoomSpec, store: &HashMap>, ) -> Result<(), ParticipantsLoadError> { - let spec = MemberSpec::try_from( - room_spec.pipeline.pipeline.get(&self.id().0).map_or( + let this_member_spec = MemberSpec::try_from( + room_spec.pipeline.get(&self.id().0).map_or( Err(ParticipantsLoadError::MemberNotFound(self.id())), Ok, )?, )?; - let me = store.get(&self.id()).map_or( + let this_member = store.get(&self.id()).map_or( Err(ParticipantsLoadError::MemberNotFound(self.id())), Ok, )?; - for (name_p, p) in spec.play_endpoints() { - let sender_id = MemberId(p.src.member_id.to_string()); - let sender_participant = store.get(&sender_id).map_or( - Err(ParticipantsLoadError::MemberNotFound(sender_id)), + for (spec_play_name, spec_play_endpoint) in + this_member_spec.play_endpoints() + { + let publisher_id = + MemberId(spec_play_endpoint.src.member_id.to_string()); + let publisher_participant = store.get(&publisher_id).map_or( + Err(ParticipantsLoadError::MemberNotFound(publisher_id)), Ok, )?; let publisher_spec = MemberSpec::try_from( room_spec .pipeline - .pipeline - .get(&p.src.member_id.to_string()) + .get(&spec_play_endpoint.src.member_id.to_string()) .map_or( Err(ParticipantsLoadError::MemberNotFound( - p.src.member_id.clone(), + spec_play_endpoint.src.member_id.clone(), )), Ok, )?, @@ -109,74 +117,78 @@ impl Participant { let publisher_endpoint = *publisher_spec .publish_endpoints() - .get(&p.src.endpoint_id) + .get(&spec_play_endpoint.src.endpoint_id) .map_or( Err(ParticipantsLoadError::EndpointNotFound( - p.src.endpoint_id.clone(), + spec_play_endpoint.src.endpoint_id.clone(), )), Ok, )?; - if let Some(publisher) = sender_participant - .get_publisher(&EndpointId(p.src.endpoint_id.to_string())) - { - let play_endpoint = Arc::new(WebRtcPlayEndpoint::new( - p.src.clone(), + if let Some(publisher) = publisher_participant.get_publisher_by_id( + &EndpointId(spec_play_endpoint.src.endpoint_id.to_string()), + ) { + let new_play_endpoint = Arc::new(WebRtcPlayEndpoint::new( + spec_play_endpoint.src.clone(), Arc::downgrade(&publisher), - Arc::downgrade(&me), + Arc::downgrade(&this_member), )); - self.add_receiver( - EndpointId(name_p.to_string()), - Arc::clone(&play_endpoint), + self.insert_receiver( + EndpointId(spec_play_name.to_string()), + Arc::clone(&new_play_endpoint), ); - publisher.add_receiver(Arc::downgrade(&play_endpoint)); + publisher.add_receiver(Arc::downgrade(&new_play_endpoint)); } else { - let send_endpoint = Arc::new(WebRtcPublishEndpoint::new( + let new_publish = Arc::new(WebRtcPublishEndpoint::new( publisher_endpoint.p2p.clone(), Vec::new(), - Arc::downgrade(&sender_participant), + Arc::downgrade(&publisher_participant), )); - let play_endpoint = Arc::new(WebRtcPlayEndpoint::new( - p.src.clone(), - Arc::downgrade(&send_endpoint), - Arc::downgrade(&me), + let new_self_play = Arc::new(WebRtcPlayEndpoint::new( + spec_play_endpoint.src.clone(), + Arc::downgrade(&new_publish), + Arc::downgrade(&this_member), )); - send_endpoint.add_receiver(Arc::downgrade(&play_endpoint)); + new_publish.add_receiver(Arc::downgrade(&new_self_play)); - sender_participant.add_sender( - EndpointId(p.src.endpoint_id.to_string()), - send_endpoint, + publisher_participant.insert_publisher( + EndpointId(spec_play_endpoint.src.endpoint_id.to_string()), + new_publish, ); - self.add_receiver( - EndpointId(name_p.to_string()), - play_endpoint, + self.insert_receiver( + EndpointId(spec_play_name.to_string()), + new_self_play, ); } } - spec.publish_endpoints().into_iter().for_each(|(name, e)| { - let endpoint_id = EndpointId(name.clone()); - if self.publish().get(&endpoint_id).is_none() { - self.add_sender( - endpoint_id, - Arc::new(WebRtcPublishEndpoint::new( - e.p2p.clone(), - Vec::new(), - Arc::downgrade(&me), - )), - ); - } - }); + // First of all, it is necessary to create [`WebRtcPublishEndpoint`]s + // to which no [`WebRtcPlayEndpoint`] refers. + this_member_spec.publish_endpoints().into_iter().for_each( + |(name, e)| { + let endpoint_id = EndpointId(name.clone()); + if self.publishers().get(&endpoint_id).is_none() { + self.insert_publisher( + endpoint_id, + Arc::new(WebRtcPublishEndpoint::new( + e.p2p.clone(), + Vec::new(), + Arc::downgrade(&this_member), + )), + ); + } + }, + ); Ok(()) } - pub fn add_receiver( + pub fn insert_receiver( &self, id: EndpointId, endpoint: Arc, @@ -185,11 +197,11 @@ impl Participant { .lock() .unwrap() .borrow_mut() - .recv + .receivers .insert(id, endpoint); } - pub fn add_sender( + pub fn insert_publisher( &self, id: EndpointId, endpoint: Arc, @@ -198,15 +210,15 @@ impl Participant { .lock() .unwrap() .borrow_mut() - .send + .publishers .insert(id, endpoint); } - pub fn get_publisher( + pub fn get_publisher_by_id( &self, id: &EndpointId, ) -> Option> { - self.0.lock().unwrap().borrow().send.get(id).cloned() + self.0.lock().unwrap().borrow().publishers.get(id).cloned() } } @@ -214,13 +226,13 @@ impl ParticipantInner { pub fn new(id: MemberId, credentials: String) -> Self { Self { id, - send: HashMap::new(), - recv: HashMap::new(), + publishers: HashMap::new(), + receivers: HashMap::new(), credentials, } } - pub fn get_store( + pub fn load_store( room_spec: &RoomSpec, ) -> Result>, ParticipantsLoadError> { @@ -241,8 +253,6 @@ impl ParticipantInner { participant.load(room_spec, &participants)?; } - // println!("\n\n\n\n{:#?}\n\n\n\n", participants); - Ok(participants) } } From 24351dddeffb4b8a2f6055e6b2c955ac3e664cef Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 12 Jun 2019 13:45:58 +0300 Subject: [PATCH 130/735] Add peer_id to Participant --- src/media/peer.rs | 4 +- src/signalling/peers.rs | 12 ++--- src/signalling/room.rs | 27 +++++++--- src/signalling/state/endpoint.rs | 80 ++++++++++++++++++++++++++--- src/signalling/state/participant.rs | 13 +++++ 5 files changed, 114 insertions(+), 22 deletions(-) diff --git a/src/media/peer.rs b/src/media/peer.rs index 740a8abef..23c55a736 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -256,11 +256,13 @@ impl Peer { publish_endpoints: HashMap>, ) { let partner_id = self.partner_member_id(); + let self_id = self.id(); // TODO: unwrap weak publish_endpoints .into_iter() .flat_map(|(_m, e)| { + e.add_peer_id(self_id); e.receivers() .into_iter() .map(|e| e.upgrade().unwrap()) @@ -285,7 +287,7 @@ impl Peer { partner_peer.add_receiver(track_video); partner_peer.add_receiver(track_audio); - e.connected(); + e.connect(partner_peer.id()); }); } diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index a06950d33..15b1b6122 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -178,7 +178,7 @@ impl PeerRepository { self.get_peers_by_member_id(member_id) .into_iter() - .map(|peer| { + .for_each(|peer| { self.get_peers_by_member_id(&peer.partner_member_id()) .into_iter() .filter(|partner_peer| { @@ -196,12 +196,10 @@ impl PeerRepository { .or_insert(Vec::new()) .push(peer.id()); - peer.id() - }) - .collect::>() - .into_iter() - .for_each(|id| { - self.peers.remove(&id); + peers_to_remove + .entry(peer.member_id()) + .or_insert(Vec::new()) + .push(peer.id()); }); for (peer_member_id, peers_id) in peers_to_remove { diff --git a/src/signalling/room.rs b/src/signalling/room.rs index c8051f603..b3457226b 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -282,6 +282,11 @@ impl Room { let (first_peer_id, second_peer_id) = self.peers.create_peers(first_member, second_member); + // println!( + // "\n\nParticipants: {:#?}\n\nPeers: {:#?}\n\n", + // self.participants, self.peers + // ); + ctx.notify(ConnectPeers(first_peer_id, second_peer_id)); // println!("Peers: {:#?}", self.peers); @@ -430,15 +435,23 @@ impl Handler for Room { msg: PeersRemoved, _ctx: &mut Self::Context, ) -> Self::Result { + self.participants + .get_member_by_id(&msg.member_id) + .unwrap() + .peers_removed(&msg.peers_id); + Box::new( self.send_peers_removed(msg.member_id, msg.peers_id) - .map_err(|err, _, ctx: &mut Context| { - error!( - "Failed PeersEvent command, because {}. Room will be \ - stopped.", - err - ); - ctx.notify(CloseRoom {}) + .map_err(|err, _, ctx: &mut Context| match err { + RoomError::ConnectionNotExists(_) => (), + _ => { + error!( + "Failed PeersEvent command, because {}. Room will \ + be stopped.", + err + ); + ctx.notify(CloseRoom {}) + } }), ) } diff --git a/src/signalling/state/endpoint.rs b/src/signalling/state/endpoint.rs index 12e004478..5421ee272 100644 --- a/src/signalling/state/endpoint.rs +++ b/src/signalling/state/endpoint.rs @@ -4,8 +4,10 @@ use std::{ }; use crate::api::control::endpoint::{P2pMode, SrcUri}; +use crate::media::PeerId; use super::participant::Participant; +use hashbrown::HashSet; #[derive(Clone, Debug, Eq, Hash, PartialEq)] pub struct Id(pub String); @@ -15,7 +17,7 @@ struct WebRtcPlayEndpointInner { src: SrcUri, publisher: Weak, owner: Weak, - is_connected: bool, + peer_id: Option, } impl WebRtcPlayEndpointInner { @@ -32,11 +34,19 @@ impl WebRtcPlayEndpointInner { } fn is_connected(&self) -> bool { - self.is_connected + self.peer_id.is_some() } - fn set_is_connected(&mut self, value: bool) { - self.is_connected = value; + fn set_peer_id(&mut self, peer_id: PeerId) { + self.peer_id = Some(peer_id) + } + + fn peer_id(&self) -> Option { + self.peer_id.clone() + } + + fn reset(&mut self) { + self.peer_id = None } } @@ -54,7 +64,7 @@ impl WebRtcPlayEndpoint { src, publisher, owner, - is_connected: false, + peer_id: None, }))) } @@ -74,8 +84,16 @@ impl WebRtcPlayEndpoint { self.0.lock().unwrap().borrow().is_connected() } - pub fn connected(&self) { - self.0.lock().unwrap().borrow_mut().set_is_connected(true); + pub fn connect(&self, peer_id: PeerId) { + self.0.lock().unwrap().borrow_mut().set_peer_id(peer_id); + } + + pub fn peer_id(&self) -> Option { + self.0.lock().unwrap().borrow().peer_id() + } + + pub fn reset(&self) { + self.0.lock().unwrap().borrow_mut().reset() } } @@ -84,6 +102,7 @@ struct WebRtcPublishEndpointInner { p2p: P2pMode, receivers: Vec>, owner: Weak, + peer_ids: HashSet, } impl WebRtcPublishEndpointInner { @@ -98,6 +117,28 @@ impl WebRtcPublishEndpointInner { fn owner(&self) -> Weak { Weak::clone(&self.owner) } + + fn add_peer_id(&mut self, peer_id: PeerId) { + self.peer_ids.insert(peer_id); + } + + fn peer_ids(&self) -> HashSet { + self.peer_ids.clone() + } + + pub fn reset(&mut self) { + self.peer_ids = HashSet::new() + } + + pub fn remove_peer_id(&mut self, peer_id: &PeerId) { + self.peer_ids.remove(peer_id); + } + + pub fn remove_peer_ids(&mut self, peer_ids: &Vec) { + for peer_id in peer_ids { + self.remove_peer_id(peer_id) + } + } } #[allow(clippy::module_name_repetitions)] @@ -114,6 +155,7 @@ impl WebRtcPublishEndpoint { p2p, receivers, owner, + peer_ids: HashSet::new(), }))) } @@ -128,4 +170,28 @@ impl WebRtcPublishEndpoint { pub fn owner(&self) -> Weak { self.0.lock().unwrap().borrow().owner() } + + pub fn add_peer_id(&self, peer_id: PeerId) { + self.0.lock().unwrap().borrow_mut().add_peer_id(peer_id) + } + + pub fn peer_ids(&self) -> HashSet { + self.0.lock().unwrap().borrow().peer_ids() + } + + pub fn reset(&self) { + self.0.lock().unwrap().borrow_mut().reset() + } + + pub fn remove_peer_id(&self, peer_id: &PeerId) { + self.0.lock().unwrap().borrow_mut().remove_peer_id(peer_id) + } + + pub fn remove_peer_ids(&self, peer_ids: &Vec) { + self.0 + .lock() + .unwrap() + .borrow_mut() + .remove_peer_ids(peer_ids) + } } diff --git a/src/signalling/state/participant.rs b/src/signalling/state/participant.rs index 65056cac8..4b7a68b12 100644 --- a/src/signalling/state/participant.rs +++ b/src/signalling/state/participant.rs @@ -10,6 +10,7 @@ use hashbrown::HashMap; use crate::api::control::{ MemberId, MemberSpec, RoomSpec, TryFromElementError, }; +use crate::media::PeerId; use super::endpoint::{ Id as EndpointId, WebRtcPlayEndpoint, WebRtcPublishEndpoint, @@ -53,6 +54,18 @@ impl Participant { }))) } + pub fn peers_removed(&self, peer_ids: &Vec) { + self.publishers() + .into_iter() + .for_each(|(_, p)| p.remove_peer_ids(peer_ids)); + + self.receivers() + .into_iter() + .filter_map(|(_, p)| p.peer_id().map(|id| (id, p))) + .filter(|(id, _)| peer_ids.contains(&id)) + .for_each(|(_, p)| p.reset()); + } + pub fn id(&self) -> MemberId { self.0.lock().unwrap().borrow().id.clone() } From 74ede3b78a6e6b0187111cfe56aab1c6a56e5904 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 12 Jun 2019 14:26:41 +0300 Subject: [PATCH 131/735] Properly unwrap Weak --- src/media/peer.rs | 23 +++++++++++--- src/signalling/room.rs | 71 +++++++++++++++++++++++++++--------------- 2 files changed, 64 insertions(+), 30 deletions(-) diff --git a/src/media/peer.rs b/src/media/peer.rs index 23c55a736..341757da9 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -17,6 +17,7 @@ use crate::{ media::{MediaTrack, TrackId}, signalling::peers::Counter, signalling::state::endpoint::{Id as EndpointId, WebRtcPublishEndpoint}, + log::prelude::*, }; /// Newly initialized [`Peer`] ready to signalling. @@ -258,20 +259,32 @@ impl Peer { let partner_id = self.partner_member_id(); let self_id = self.id(); - // TODO: unwrap weak publish_endpoints .into_iter() .flat_map(|(_m, e)| { e.add_peer_id(self_id); e.receivers() .into_iter() - .map(|e| e.upgrade().unwrap()) - .filter(|e| { - e.owner().upgrade().unwrap().id() == partner_id + .filter_map(|e| { + let upgraded_play = e.upgrade(); + if upgraded_play.is_none() { + warn!("Empty weak pointer of publisher's play endpoint. {:?}.", e); + } + upgraded_play + }) + .filter_map(|p| { + let owner = p.owner().upgrade(); + if owner.is_none() { + warn!("Empty weak pointer for publisher's play's owner participant. {:?}.", p); + } + owner.map(|owner| (p, owner)) + }) + .filter(|(e, owner)| { + owner.id() == partner_id && !e.is_connected() }) }) - .for_each(|e| { + .for_each(|(e, _)| { let track_audio = Arc::new(MediaTrack::new( tracks_count.next_id(), MediaType::Audio(AudioSettings {}), diff --git a/src/signalling/room.rs b/src/signalling/room.rs index b3457226b..c6359a7d7 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -282,14 +282,7 @@ impl Room { let (first_peer_id, second_peer_id) = self.peers.create_peers(first_member, second_member); - // println!( - // "\n\nParticipants: {:#?}\n\nPeers: {:#?}\n\n", - // self.participants, self.peers - // ); - ctx.notify(ConnectPeers(first_peer_id, second_peer_id)); - - // println!("Peers: {:#?}", self.peers); } /// Create and interconnect all [`Peer`]s between connected [`Member`] @@ -319,8 +312,21 @@ impl Room { // Create all connected publish endpoints. for (_id, publish) in member.publishers() { for receiver in publish.receivers() { - let receiver = receiver.upgrade().unwrap(); // TODO: unwrap - let receiver_owner = receiver.owner().upgrade().unwrap(); + let receiver = if let Some(receiver) = receiver.upgrade() { + receiver + } else { + error!("Empty weak pointer for publisher receiver. {:?}. Closing room.", publish); + ctx.notify(CloseRoom {}); + return; + }; + let receiver_owner = if let Some(receiver_owner) = receiver.owner().upgrade() { + receiver_owner + } else { + error!("Empty weak pointer for publisher's receiver's owner. {:?}. Closing room.", receiver); + ctx.notify(CloseRoom {}); + return; + }; + if self .participants .member_has_connection(&receiver_owner.id()) @@ -335,24 +341,30 @@ impl Room { } } - // Create all connected play endpoint. - // TODO: properly unwrap Weak + // Create all connected play receivers peers. for (_id, play) in member.receivers() { - let play_participant = play - .publisher() - .upgrade() - .unwrap() - .owner() - .upgrade() - .unwrap(); + let plays_publisher_participant = if let Some(plays_publisher) = play.publisher().upgrade() { + if let Some(owner) = plays_publisher.owner().upgrade() { + owner + } else { + error!("Empty weak pointer for play's publisher owner. {:?}. Closing room.", plays_publisher); + ctx.notify(CloseRoom {}); + return; + } + } else { + error!("Empty weak pointer for play's publisher. {:?}. Closing room.", play); + ctx.notify(CloseRoom {}); + return; + }; + if self .participants - .member_has_connection(&play_participant.id()) + .member_has_connection(&plays_publisher_participant.id()) && !play.is_connected() { self.create_and_interconnect_peers( &member, - &play_participant, + &plays_publisher_participant, ctx, ); } @@ -433,12 +445,21 @@ impl Handler for Room { fn handle( &mut self, msg: PeersRemoved, - _ctx: &mut Self::Context, + ctx: &mut Self::Context, ) -> Self::Result { - self.participants - .get_member_by_id(&msg.member_id) - .unwrap() - .peers_removed(&msg.peers_id); + if let Some(participant) = + self.participants.get_member_by_id(&msg.member_id) + { + participant.peers_removed(&msg.peers_id); + } else { + error!( + "Participant with id {} for which received \ + Event::PeersRemoved not found. Closing room.", + msg.member_id + ); + ctx.notify(CloseRoom {}); + return Box::new(wrap_future(future::err(()))); + } Box::new( self.send_peers_removed(msg.member_id, msg.peers_id) From edeee5a1936c1a95b652a90ca96ccb06123f2eae Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 12 Jun 2019 15:18:40 +0300 Subject: [PATCH 132/735] Upd docs --- src/api/client/rpc_connection.rs | 22 ++--- src/api/client/server.rs | 6 +- src/api/client/session.rs | 6 +- src/media/peer.rs | 33 ++++--- src/signalling/{state => control}/endpoint.rs | 57 ++++++++++-- src/signalling/control/mod.rs | 4 + .../{state => control}/participant.rs | 89 ++++++++++--------- src/signalling/mod.rs | 2 +- src/signalling/participants.rs | 49 +++++----- src/signalling/peers.rs | 10 +-- src/signalling/room.rs | 84 ++++++++++------- src/signalling/state/mod.rs | 2 - 12 files changed, 228 insertions(+), 136 deletions(-) rename src/signalling/{state => control}/endpoint.rs (68%) create mode 100644 src/signalling/control/mod.rs rename src/signalling/{state => control}/participant.rs (84%) delete mode 100644 src/signalling/state/mod.rs diff --git a/src/api/client/rpc_connection.rs b/src/api/client/rpc_connection.rs index 9ef14d191..656956358 100644 --- a/src/api/client/rpc_connection.rs +++ b/src/api/client/rpc_connection.rs @@ -22,14 +22,14 @@ macro_attr! { pub struct EventMessage(Event); } -/// Abstraction over RPC connection with some remote [`Member`]. +/// Abstraction over RPC connection with some remote [`Participant`]. pub trait RpcConnection: fmt::Debug + Send { /// Closes [`RpcConnection`]. /// No [`RpcConnectionClosed`] signals should be emitted. /// Always returns success. fn close(&mut self) -> Box>; - /// Sends [`Event`] to remote [`Member`]. + /// Sends [`Event`] to remote [`Participant`]. fn send_event( &self, msg: EventMessage, @@ -40,7 +40,7 @@ pub trait RpcConnection: fmt::Debug + Send { #[derive(Debug, Message)] #[rtype(result = "Result<(), AuthorizationError>")] pub struct Authorize { - /// ID of [`Member`] to authorize [`RpcConnection`] for. + /// ID of [`Participant`] to authorize [`RpcConnection`] for. pub member_id: MemberId, /// Credentials to authorize [`RpcConnection`] with. pub credentials: String, // TODO: &str when futures will allow references @@ -49,28 +49,30 @@ pub struct Authorize { /// Error of authorization [`RpcConnection`] in [`Room`]. #[derive(Debug)] pub enum AuthorizationError { - /// Authorizing [`Member`] does not exists in the [`Room`]. - MemberNotExists, + /// Authorizing [`Participant`] does not exists in the [`Room`]. + ParticipantNotExists, /// Provided credentials are invalid. InvalidCredentials, } -/// Signal of new [`RpcConnection`] being established with specified [`Member`]. -/// Transport should consider dropping connection if message result is err. +/// Signal of new [`RpcConnection`] being established with specified +/// [`Participant`]. Transport should consider dropping connection if message +/// result is err. #[derive(Debug, Message)] #[rtype(result = "Result<(), ()>")] #[allow(clippy::module_name_repetitions)] pub struct RpcConnectionEstablished { - /// ID of [`Member`] that establishes [`RpcConnection`]. + /// ID of [`Participant`] that establishes [`RpcConnection`]. pub member_id: MemberId, /// Established [`RpcConnection`]. pub connection: Box, } -/// Signal of existing [`RpcConnection`] of specified [`Member`] being closed. +/// Signal of existing [`RpcConnection`] of specified [`Participant`] being +/// closed. #[derive(Debug, Message)] #[allow(clippy::module_name_repetitions)] pub struct RpcConnectionClosed { - /// ID of [`Member`] which [`RpcConnection`] is closed. + /// ID of [`Participant`] which [`RpcConnection`] is closed. pub member_id: MemberId, /// Reason of why [`RpcConnection`] is closed. pub reason: ClosedReason, diff --git a/src/api/client/server.rs b/src/api/client/server.rs index 7c609a318..ca9cfb96b 100644 --- a/src/api/client/server.rs +++ b/src/api/client/server.rs @@ -25,9 +25,9 @@ use crate::{ struct RequestParams { /// ID of [`Room`] that WebSocket connection connects to. room_id: RoomId, - /// ID of [`Member`] that establishes WebSocket connection. + /// ID of [`Participant`] that establishes WebSocket connection. member_id: MemberId, - /// Credential of [`Member`] to authorize WebSocket connection with. + /// Credential of [`Participant`] to authorize WebSocket connection with. credentials: String, } @@ -58,7 +58,7 @@ fn ws_index( state.config.idle_timeout, ), ), - Err(AuthorizationError::MemberNotExists) => { + Err(AuthorizationError::ParticipantNotExists) => { Ok(HttpResponse::NotFound().into()) } Err(AuthorizationError::InvalidCredentials) => { diff --git a/src/api/client/session.rs b/src/api/client/session.rs index 8eddd7cb4..152cb57c3 100644 --- a/src/api/client/session.rs +++ b/src/api/client/session.rs @@ -26,10 +26,10 @@ use crate::{ #[derive(Debug)] #[allow(clippy::module_name_repetitions)] pub struct WsSession { - /// ID of [`Member`] that WebSocket connection is associated with. + /// ID of [`Participant`] that WebSocket connection is associated with. member_id: MemberId, - /// [`Room`] that [`Member`] is associated with. + /// [`Room`] that [`Participant`] is associated with. room: Addr, /// Timeout of receiving any messages from client. @@ -48,7 +48,7 @@ pub struct WsSession { } impl WsSession { - /// Creates new [`WsSession`] for specified [`Member`]. + /// Creates new [`WsSession`] for specified [`Participant`]. pub fn new( member_id: MemberId, room: Addr, diff --git a/src/media/peer.rs b/src/media/peer.rs index 341757da9..2a094a866 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -14,10 +14,12 @@ use std::{convert::TryFrom, fmt::Display, sync::Arc}; use crate::{ api::control::MemberId, - media::{MediaTrack, TrackId}, - signalling::peers::Counter, - signalling::state::endpoint::{Id as EndpointId, WebRtcPublishEndpoint}, log::prelude::*, + media::{MediaTrack, TrackId}, + signalling::{ + control::endpoint::{Id as EndpointId, WebRtcPublishEndpoint}, + peers::Counter + } }; /// Newly initialized [`Peer`] ready to signalling. @@ -161,7 +163,7 @@ pub struct Peer { } impl Peer { - /// Returns ID of [`Member`] associated with this [`Peer`]. + /// Returns ID of [`Participant`] associated with this [`Peer`]. pub fn member_id(&self) -> MemberId { self.context.member_id.clone() } @@ -176,7 +178,7 @@ impl Peer { self.context.partner_peer } - /// Returns ID of interconnected [`Member`]. + /// Returns ID of interconnected [`Participant`]. pub fn partner_member_id(&self) -> MemberId { self.context.partner_member.clone() } @@ -227,7 +229,7 @@ impl Peer { } impl Peer { - /// Creates new [`Peer`] for [`Member`]. + /// Creates new [`Peer`] for [`Participant`]. pub fn new( id: Id, member_id: MemberId, @@ -250,6 +252,10 @@ impl Peer { } } + /// Add all publish endpoints to this [`Peer`]. + /// + /// This also create [`Peer`]s for [`WebRtcPlayEndpoint`]s that + /// receive something from us. pub fn add_publish_endpoints( &mut self, partner_peer: &mut Peer, @@ -268,20 +274,27 @@ impl Peer { .filter_map(|e| { let upgraded_play = e.upgrade(); if upgraded_play.is_none() { - warn!("Empty weak pointer of publisher's play endpoint. {:?}.", e); + warn!( + "Empty weak pointer of publisher's play \ + endpoint. {:?}.", + e + ); } upgraded_play }) .filter_map(|p| { let owner = p.owner().upgrade(); if owner.is_none() { - warn!("Empty weak pointer for publisher's play's owner participant. {:?}.", p); + warn!( + "Empty weak pointer for publisher's play's \ + owner participant. {:?}.", + p + ); } owner.map(|owner| (p, owner)) }) .filter(|(e, owner)| { - owner.id() == partner_id - && !e.is_connected() + owner.id() == partner_id && !e.is_connected() }) }) .for_each(|(e, _)| { diff --git a/src/signalling/state/endpoint.rs b/src/signalling/control/endpoint.rs similarity index 68% rename from src/signalling/state/endpoint.rs rename to src/signalling/control/endpoint.rs index 5421ee272..d3cba40d9 100644 --- a/src/signalling/state/endpoint.rs +++ b/src/signalling/control/endpoint.rs @@ -1,22 +1,37 @@ +//! Signalling representation of endpoints. + use std::{ cell::RefCell, sync::{Mutex, Weak}, }; -use crate::api::control::endpoint::{P2pMode, SrcUri}; -use crate::media::PeerId; +use hashbrown::HashSet; + +use crate::{ + api::control::endpoint::{P2pMode, SrcUri}, + media::PeerId, +}; use super::participant::Participant; -use hashbrown::HashSet; +/// ID of endpoint. #[derive(Clone, Debug, Eq, Hash, PartialEq)] pub struct Id(pub String); #[derive(Debug, Clone)] struct WebRtcPlayEndpointInner { + /// Source URI of [`WebRtcPublishEndpoint`] from which this + /// [`WebRtcPlayEndpoint`] receive data. src: SrcUri, + + /// Publisher [`WebRtcPublishEndpoint`] from which this + /// [`WebRtcPlayEndpoint`] receive data. publisher: Weak, + + /// Owner [`Participant`] of this [`WebRtcPlayEndpoint`]. owner: Weak, + + /// [`PeerId`] of [`Peer`] created for this [`WebRtcPlayEndpoint`]. peer_id: Option, } @@ -50,11 +65,13 @@ impl WebRtcPlayEndpointInner { } } +/// Signalling representation of WebRtcPlayEndpoint. #[allow(clippy::module_name_repetitions)] #[derive(Debug)] pub struct WebRtcPlayEndpoint(Mutex>); impl WebRtcPlayEndpoint { + /// Create new [`WebRtcPlayEndpoint`]. pub fn new( src: SrcUri, publisher: Weak, @@ -68,30 +85,39 @@ impl WebRtcPlayEndpoint { }))) } + /// Returns [`SrcUri`] of this [`WebRtcPlayEndpoint`]. pub fn src(&self) -> SrcUri { self.0.lock().unwrap().borrow().src() } + /// Returns owner [`Participant`] of this [`WebRtcPlayEndpoint`]. pub fn owner(&self) -> Weak { self.0.lock().unwrap().borrow().owner() } + /// Returns publisher's [`WebRtcPublishEndpoint`]. pub fn publisher(&self) -> Weak { self.0.lock().unwrap().borrow().publisher() } + /// Check that peer connection established for this [`WebRtcPlayEndpoint`]. pub fn is_connected(&self) -> bool { self.0.lock().unwrap().borrow().is_connected() } + /// Save [`PeerId`] of this [`WebRtcPlayEndpoint`]. pub fn connect(&self, peer_id: PeerId) { self.0.lock().unwrap().borrow_mut().set_peer_id(peer_id); } + /// Return [`PeerId`] of [`Peer`] of this [`WebRtcPlayEndpoint`]. pub fn peer_id(&self) -> Option { self.0.lock().unwrap().borrow().peer_id() } + /// Reset state of this [`WebRtcPlayEndpoint`]. + /// + /// Atm this only reset peer_id. pub fn reset(&self) { self.0.lock().unwrap().borrow_mut().reset() } @@ -99,9 +125,16 @@ impl WebRtcPlayEndpoint { #[derive(Debug, Clone)] struct WebRtcPublishEndpointInner { + /// P2P connection mode for this [`WebRtcPublishEndpoint`]. p2p: P2pMode, + + /// All receivers of this [`WebRtcPublishEndpoint`]. receivers: Vec>, + + /// Owner [`Participant`] of this [`WebRtcPublishEndpoint`]. owner: Weak, + + /// All [`PeerId`]s created for this [`WebRtcPublishEndpoint`]. peer_ids: HashSet, } @@ -126,26 +159,28 @@ impl WebRtcPublishEndpointInner { self.peer_ids.clone() } - pub fn reset(&mut self) { + fn reset(&mut self) { self.peer_ids = HashSet::new() } - pub fn remove_peer_id(&mut self, peer_id: &PeerId) { + fn remove_peer_id(&mut self, peer_id: &PeerId) { self.peer_ids.remove(peer_id); } - pub fn remove_peer_ids(&mut self, peer_ids: &Vec) { + fn remove_peer_ids(&mut self, peer_ids: &Vec) { for peer_id in peer_ids { self.remove_peer_id(peer_id) } } } +/// Signalling representation of WebRtcPublishEndpoint. #[allow(clippy::module_name_repetitions)] #[derive(Debug)] pub struct WebRtcPublishEndpoint(Mutex>); impl WebRtcPublishEndpoint { + /// Create new [`WebRtcPublishEndpoint`]. pub fn new( p2p: P2pMode, receivers: Vec>, @@ -159,34 +194,44 @@ impl WebRtcPublishEndpoint { }))) } + /// Add receiver for this [`WebRtcPublishEndpoint`]. pub fn add_receiver(&self, receiver: Weak) { self.0.lock().unwrap().borrow_mut().add_receiver(receiver) } + /// Returns all receivers of this [`WebRtcPublishEndpoint`]. pub fn receivers(&self) -> Vec> { self.0.lock().unwrap().borrow().receivers() } + /// Returns owner [`Participant`] of this [`WebRtcPublishEndpoint`]. pub fn owner(&self) -> Weak { self.0.lock().unwrap().borrow().owner() } + /// Add [`PeerId`] of this [`WebRtcPublishEndpoint`]. pub fn add_peer_id(&self, peer_id: PeerId) { self.0.lock().unwrap().borrow_mut().add_peer_id(peer_id) } + /// Returns all [`PeerId`] of this [`WebRtcPublishEndpoint`]. pub fn peer_ids(&self) -> HashSet { self.0.lock().unwrap().borrow().peer_ids() } + /// Reset state of this [`WebRtcPublishEndpoint`]. + /// + /// Atm this only reset peer_ids. pub fn reset(&self) { self.0.lock().unwrap().borrow_mut().reset() } + /// Remove [`PeerId`] from peer_ids. pub fn remove_peer_id(&self, peer_id: &PeerId) { self.0.lock().unwrap().borrow_mut().remove_peer_id(peer_id) } + /// Remove all [`PeerId`]s related to this [`WebRtcPublishEndpoint`]. pub fn remove_peer_ids(&self, peer_ids: &Vec) { self.0 .lock() diff --git a/src/signalling/control/mod.rs b/src/signalling/control/mod.rs new file mode 100644 index 000000000..1cb83e698 --- /dev/null +++ b/src/signalling/control/mod.rs @@ -0,0 +1,4 @@ +//! Signalling representation of control spec. + +pub mod endpoint; +pub mod participant; diff --git a/src/signalling/state/participant.rs b/src/signalling/control/participant.rs similarity index 84% rename from src/signalling/state/participant.rs rename to src/signalling/control/participant.rs index 4b7a68b12..a03599be0 100644 --- a/src/signalling/state/participant.rs +++ b/src/signalling/control/participant.rs @@ -1,3 +1,5 @@ +//! [`Participant`] is member of [`Room`] with [`RpcConnection`]. + use std::{ cell::RefCell, convert::TryFrom as _, @@ -7,21 +9,29 @@ use std::{ use failure::Fail; use hashbrown::HashMap; -use crate::api::control::{ - MemberId, MemberSpec, RoomSpec, TryFromElementError, +use crate::{ + api::control::{ + MemberId, MemberSpec, RoomSpec, TryFromElementError, + }, + media::PeerId }; -use crate::media::PeerId; use super::endpoint::{ Id as EndpointId, WebRtcPlayEndpoint, WebRtcPublishEndpoint, }; +/// Errors which may occur while loading [`Participant`]s from [`RoomSpec`]. #[derive(Debug, Fail)] pub enum ParticipantsLoadError { + /// Errors that can occur when we try transform some spec from [`Element`]. #[fail(display = "TryFromElementError: {}", _0)] TryFromError(TryFromElementError), + + /// [`Participant`] not found. #[fail(display = "Member with id '{}' not found.", _0)] MemberNotFound(MemberId), + + /// [`Endpoint`] not found. #[fail(display = "Endpoint with id '{}' not found.", _0)] EndpointNotFound(String), } @@ -32,12 +42,13 @@ impl From for ParticipantsLoadError { } } +/// [`Participant`] is member of [`Room`] with [`RpcConnection`]. #[derive(Debug)] pub struct Participant(Mutex>); #[allow(clippy::module_name_repetitions)] #[derive(Debug)] -pub struct ParticipantInner { +struct ParticipantInner { id: MemberId, publishers: HashMap>, receivers: HashMap>, @@ -45,6 +56,7 @@ pub struct ParticipantInner { } impl Participant { + /// Create new empty [`Participant`]. fn new(id: MemberId, credentials: String) -> Self { Self(Mutex::new(RefCell::new(ParticipantInner { id, @@ -54,6 +66,9 @@ impl Participant { }))) } + /// Notify [`Participant`] that some [`Peer`]s removed. + /// + /// All [`PeerId`]s related to this [`Participant`] will be removed. pub fn peers_removed(&self, peer_ids: &Vec) { self.publishers() .into_iter() @@ -66,30 +81,56 @@ impl Participant { .for_each(|(_, p)| p.reset()); } + /// Returns [`MemberId`] of this [`Participant`]. pub fn id(&self) -> MemberId { self.0.lock().unwrap().borrow().id.clone() } + /// Creates all empty [`Participant`] from [`RoomSpec`] and then + /// load all related to this [`Participant`]s receivers and publishers. + /// + /// Returns store of all [`Participant`]s loaded from [`RoomSpec`]. pub fn load_store( room_spec: &RoomSpec, ) -> Result>, ParticipantsLoadError> { - ParticipantInner::load_store(room_spec) + let members = room_spec.members()?; + let mut participants = HashMap::new(); + + for (id, member) in &members { + participants.insert( + id.clone(), + Arc::new(Participant::new( + id.clone(), + member.credentials().to_string(), + )), + ); + } + + for (_, participant) in &participants { + participant.load(room_spec, &participants)?; + } + + Ok(participants) } + /// Returns credentials of this [`Participant`]. pub fn credentials(&self) -> String { self.0.lock().unwrap().borrow().credentials.clone() } + /// Returns all publishers of this [`Participant`]. pub fn publishers( &self, ) -> HashMap> { self.0.lock().unwrap().borrow().publishers.clone() } + /// Returns all receivers of this [`Participant`]. pub fn receivers(&self) -> HashMap> { self.0.lock().unwrap().borrow().receivers.clone() } + /// Load all publishers and receivers of this [`Participant`]. fn load( &self, room_spec: &RoomSpec, @@ -201,6 +242,7 @@ impl Participant { Ok(()) } + /// Insert new receiver into this [`Participant`]. pub fn insert_receiver( &self, id: EndpointId, @@ -214,6 +256,7 @@ impl Participant { .insert(id, endpoint); } + /// Insert new publisher into this [`Participant`]. pub fn insert_publisher( &self, id: EndpointId, @@ -227,6 +270,7 @@ impl Participant { .insert(id, endpoint); } + /// Lookup [`WebRtcPublishEndpoint`] publisher by id. pub fn get_publisher_by_id( &self, id: &EndpointId, @@ -235,39 +279,4 @@ impl Participant { } } -impl ParticipantInner { - pub fn new(id: MemberId, credentials: String) -> Self { - Self { - id, - publishers: HashMap::new(), - receivers: HashMap::new(), - credentials, - } - } - - pub fn load_store( - room_spec: &RoomSpec, - ) -> Result>, ParticipantsLoadError> - { - let members = room_spec.members()?; - let mut participants = HashMap::new(); - - for (id, member) in &members { - participants.insert( - id.clone(), - Arc::new(Participant::new( - id.clone(), - member.credentials().to_string(), - )), - ); - } - - for (_, participant) in &participants { - participant.load(room_spec, &participants)?; - } - - Ok(participants) - } -} - // TODO (evdokimovs): add Participant unit tests diff --git a/src/signalling/mod.rs b/src/signalling/mod.rs index 4848ab631..0d24658c6 100644 --- a/src/signalling/mod.rs +++ b/src/signalling/mod.rs @@ -1,4 +1,4 @@ -pub mod state; +pub mod control; pub mod participants; pub mod peers; diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index cf48a7c7d..9e474fe3c 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -1,6 +1,7 @@ -//! Participant is [`Member`] with [`RpcConnection`]. [`ParticipantService`] -//! stores [`Members`] and associated [`RpcConnection`]s, handles -//! [`RpcConnection`] authorization, establishment, message sending. +//! [`Participant`] is member of [`Room`] with [`RpcConnection`]. +//! [`ParticipantService`] stores [`Participant`]s and associated +//! [`RpcConnection`]s, handles [`RpcConnection`] authorization, establishment, +//! message sending. use std::{ sync::Arc, @@ -25,21 +26,22 @@ use crate::{ }, log::prelude::*, signalling::{ + control::participant::{Participant, ParticipantsLoadError}, room::RoomError, - state::participant::{Participant, ParticipantsLoadError}, Room, }, }; -/// Participant is [`Member`] with [`RpcConnection`]. [`ParticipantService`] -/// stores [`Members`] and associated [`RpcConnection`]s, handles -/// [`RpcConnection`] authorization, establishment, message sending. +/// [`Participant`] is member of [`Room`] with [`RpcConnection`]. +/// [`ParticipantService`] stores [`Participant`]s and associated +/// [`RpcConnection`]s, handles [`RpcConnection`] authorization, establishment, +/// message sending. #[derive(Debug)] pub struct ParticipantService { - /// [`Member`]s which currently are present in this [`Room`]. + /// [`Participant`]s which currently are present in this [`Room`]. members: HashMap>, - /// Established [`RpcConnection`]s of [`Member`]s in this [`Room`]. + /// Established [`RpcConnection`]s of [`Participant`]s in this [`Room`]. // TODO: Replace Box> with enum, // as the set of all possible RpcConnection types is not closed. connections: HashMap>, @@ -76,15 +78,16 @@ impl ParticipantService { }) } - /// Lookup [`Member`] by provided id. + /// Lookup [`Participant`] by provided id. pub fn get_member_by_id(&self, id: &MemberId) -> Option> { self.members.get(id).cloned() } - /// Lookup [`Member`] by provided id and credentials. Returns - /// [`Err(AuthorizationError::MemberNotExists)`] if lookup by [`MemberId`] - /// failed. Returns [`Err(AuthorizationError::InvalidCredentials)`] if - /// [`Member`] was found, but incorrect credentials was provided. + /// Lookup [`Participant`] by provided id and credentials. Returns + /// [`Err(AuthorizationError::ParticipantNotExists)`] if lookup by + /// [`MemberId`] failed. Returns + /// [`Err(AuthorizationError::InvalidCredentials)`] if [`Participant`] + /// was found, but incorrect credentials was provided. pub fn get_member_by_id_and_credentials( &self, member_id: &MemberId, @@ -98,17 +101,17 @@ impl ParticipantService { Err(AuthorizationError::InvalidCredentials) } } - None => Err(AuthorizationError::MemberNotExists), + None => Err(AuthorizationError::ParticipantNotExists), } } - /// Checks if [`Member`] has **active** [`RcpConnection`]. + /// Checks if [`Participant`] has **active** [`RcpConnection`]. pub fn member_has_connection(&self, member_id: &MemberId) -> bool { self.connections.contains_key(member_id) && !self.drop_connection_tasks.contains_key(member_id) } - /// Send [`Event`] to specified remote [`Member`]. + /// Send [`Event`] to specified remote [`Participant`]. pub fn send_event_to_member( &mut self, member_id: MemberId, @@ -126,9 +129,9 @@ impl ParticipantService { } /// If [`ClosedReason::Closed`], then removes [`RpcConnection`] associated - /// with specified user [`Member`] from the storage and closes the room. - /// If [`ClosedReason::Lost`], then creates delayed task that emits - /// [`ClosedReason::Closed`]. + /// with specified user [`Participant`] from the storage and closes the + /// room. If [`ClosedReason::Lost`], then creates delayed task that + /// emits [`ClosedReason::Closed`]. // TODO: Dont close the room. It is being closed atm, because we have // no way to handle absence of RtcPeerConnection when. pub fn connection_closed( @@ -162,9 +165,9 @@ impl ParticipantService { } } - /// Stores provided [`RpcConnection`] for given [`Member`] in the [`Room`]. - /// If [`Member`] already has any other [`RpcConnection`], - /// then it will be closed. + /// Stores provided [`RpcConnection`] for given [`Participant`] in the + /// [`Room`]. If [`Participant`] already has any other + /// [`RpcConnection`], then it will be closed. pub fn connection_established( &mut self, ctx: &mut Context, diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index 15b1b6122..3b67881ca 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -12,14 +12,14 @@ use crate::{ api::control::MemberId, media::{Peer, PeerId, PeerStateMachine}, signalling::{ + control::participant::Participant, room::{PeersRemoved, Room, RoomError}, - state::participant::Participant, }, }; #[derive(Debug)] pub struct PeerRepository { - /// [`Peer`]s of [`Member`]s in this [`Room`]. + /// [`Peer`]s of [`Participant`]s in this [`Room`]. peers: HashMap, /// Count of [`Peer`]s in this [`Room`]. @@ -132,7 +132,7 @@ impl PeerRepository { } } - /// Returns all [`Peer`]s of specified [`Member`]. + /// Returns all [`Peer`]s of specified [`Participant`]. pub fn get_peers_by_member_id( &self, member_id: &MemberId, @@ -164,10 +164,10 @@ impl PeerRepository { } } - /// Close all related to disconnected [`Member`] [`Peer`]s and partner + /// Close all related to disconnected [`Participant`] [`Peer`]s and partner /// [`Peer`]s. /// - /// Send [`Event::PeersRemoved`] to all affected [`Member`]s. + /// Send [`Event::PeersRemoved`] to all affected [`Participant`]s. pub fn connection_closed( &mut self, member_id: &MemberId, diff --git a/src/signalling/room.rs b/src/signalling/room.rs index c6359a7d7..e58913b80 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -1,5 +1,5 @@ //! Room definitions and implementations. Room is responsible for media -//! connection establishment between concrete [`Member`]s. +//! connection establishment between concrete [`Participant`]s. use std::time::Duration; @@ -26,9 +26,9 @@ use crate::{ WaitLocalHaveRemote, WaitLocalSdp, WaitRemoteSdp, }, signalling::{ + control::participant::{Participant, ParticipantsLoadError}, participants::ParticipantService, peers::PeerRepository, - state::participant::{Participant, ParticipantsLoadError}, }, }; @@ -74,15 +74,15 @@ impl From for RoomError { } } -/// Media server room with its [`Member`]s. +/// Media server room with its [`Participant`]s. #[derive(Debug)] pub struct Room { id: RoomId, - /// [`RpcConnection`]s of [`Member`]s in this [`Room`]. + /// [`RpcConnection`]s of [`Participant`]s in this [`Room`]. participants: ParticipantService, - /// [`Peer`]s of [`Member`]s in this [`Room`]. + /// [`Peer`]s of [`Participant`]s in this [`Room`]. peers: PeerRepository, } @@ -153,7 +153,7 @@ impl Room { ))) } - /// Sends [`Event::PeersRemoved`] to [`Member`]. + /// Sends [`Event::PeersRemoved`] to [`Participant`]. fn send_peers_removed( &mut self, member_id: MemberId, @@ -285,12 +285,12 @@ impl Room { ctx.notify(ConnectPeers(first_peer_id, second_peer_id)); } - /// Create and interconnect all [`Peer`]s between connected [`Member`] - /// and all available at this moment [`Member`]s from [`Participant`]. + /// Create and interconnect all [`Peer`]s between connected [`Participant`] + /// and all available at this moment [`Participant`]. /// /// Availability is determines by checking [`RpcConnection`] of all - /// [`Member`]s from [`WebRtcPlayEndpoint`]s and from receivers of - /// connected [`Member`]. + /// [`Participant`]s from [`WebRtcPlayEndpoint`]s and from receivers of + /// connected [`Participant`]. fn create_peers_with_available_members( &mut self, member_id: &MemberId, @@ -315,17 +315,26 @@ impl Room { let receiver = if let Some(receiver) = receiver.upgrade() { receiver } else { - error!("Empty weak pointer for publisher receiver. {:?}. Closing room.", publish); - ctx.notify(CloseRoom {}); - return; - }; - let receiver_owner = if let Some(receiver_owner) = receiver.owner().upgrade() { - receiver_owner - } else { - error!("Empty weak pointer for publisher's receiver's owner. {:?}. Closing room.", receiver); + error!( + "Empty weak pointer for publisher receiver. {:?}. \ + Closing room.", + publish + ); ctx.notify(CloseRoom {}); return; }; + let receiver_owner = + if let Some(receiver_owner) = receiver.owner().upgrade() { + receiver_owner + } else { + error!( + "Empty weak pointer for publisher's receiver's \ + owner. {:?}. Closing room.", + receiver + ); + ctx.notify(CloseRoom {}); + return; + }; if self .participants @@ -343,19 +352,28 @@ impl Room { // Create all connected play receivers peers. for (_id, play) in member.receivers() { - let plays_publisher_participant = if let Some(plays_publisher) = play.publisher().upgrade() { - if let Some(owner) = plays_publisher.owner().upgrade() { - owner + let plays_publisher_participant = + if let Some(plays_publisher) = play.publisher().upgrade() { + if let Some(owner) = plays_publisher.owner().upgrade() { + owner + } else { + error!( + "Empty weak pointer for play's publisher owner. \ + {:?}. Closing room.", + plays_publisher + ); + ctx.notify(CloseRoom {}); + return; + } } else { - error!("Empty weak pointer for play's publisher owner. {:?}. Closing room.", plays_publisher); + error!( + "Empty weak pointer for play's publisher. {:?}. \ + Closing room.", + play + ); ctx.notify(CloseRoom {}); return; - } - } else { - error!("Empty weak pointer for play's publisher. {:?}. Closing room.", play); - ctx.notify(CloseRoom {}); - return; - }; + }; if self .participants @@ -402,7 +420,7 @@ impl Handler for Room { type Result = ActFuture<(), ()>; /// Check state of interconnected [`Peer`]s and sends [`Event`] about - /// [`Peer`] created to remote [`Member`]. + /// [`Peer`] created to remote [`Participant`]. fn handle( &mut self, msg: ConnectPeers, @@ -441,7 +459,7 @@ pub struct PeersRemoved { impl Handler for Room { type Result = ActFuture<(), ()>; - /// Send [`Event::PeersRemoved`] to [`Member`]. + /// Send [`Event::PeersRemoved`] to [`Participant`]. fn handle( &mut self, msg: PeersRemoved, @@ -529,7 +547,7 @@ impl Handler for Room { /// Saves new [`RpcConnection`] in [`ParticipantService`], initiates media /// establishment between members. - /// Create and interconnect all necessary [`Member`]'s [`Peer`]s. + /// Create and interconnect all necessary [`Participant`]'s [`Peer`]s. fn handle( &mut self, msg: RpcConnectionEstablished, @@ -559,7 +577,7 @@ pub struct CloseRoom {} impl Handler for Room { type Result = (); - /// Sends to remote [`Member`] the [`Event`] about [`Peer`] removed. + /// Sends to remote [`Participant`] the [`Event`] about [`Peer`] removed. /// Closes all active [`RpcConnection`]s. fn handle( &mut self, @@ -576,7 +594,7 @@ impl Handler for Room { type Result = (); /// Passes message to [`ParticipantService`] to cleanup stored connections. - /// Remove all related for disconnected [`Member`] [`Peer`]s. + /// Remove all related for disconnected [`Participant`] [`Peer`]s. fn handle(&mut self, msg: RpcConnectionClosed, ctx: &mut Self::Context) { info!( "RpcConnectionClosed for member {}, reason {:?}", diff --git a/src/signalling/state/mod.rs b/src/signalling/state/mod.rs deleted file mode 100644 index e20afdd53..000000000 --- a/src/signalling/state/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod endpoint; -pub mod participant; From e9a5e69fba925df1601f33a2b3066cbd3b8068db Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 12 Jun 2019 15:29:19 +0300 Subject: [PATCH 133/735] Fix lints --- src/media/peer.rs | 4 ++-- src/signalling/control/endpoint.rs | 12 +++++++----- src/signalling/control/participant.rs | 10 ++++------ src/signalling/room.rs | 1 + 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/media/peer.rs b/src/media/peer.rs index 2a094a866..2e98364f0 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -18,8 +18,8 @@ use crate::{ media::{MediaTrack, TrackId}, signalling::{ control::endpoint::{Id as EndpointId, WebRtcPublishEndpoint}, - peers::Counter - } + peers::Counter, + }, }; /// Newly initialized [`Peer`] ready to signalling. diff --git a/src/signalling/control/endpoint.rs b/src/signalling/control/endpoint.rs index d3cba40d9..bfaf8361b 100644 --- a/src/signalling/control/endpoint.rs +++ b/src/signalling/control/endpoint.rs @@ -57,7 +57,7 @@ impl WebRtcPlayEndpointInner { } fn peer_id(&self) -> Option { - self.peer_id.clone() + self.peer_id } fn reset(&mut self) { @@ -65,7 +65,7 @@ impl WebRtcPlayEndpointInner { } } -/// Signalling representation of WebRtcPlayEndpoint. +/// Signalling representation of `WebRtcPlayEndpoint`. #[allow(clippy::module_name_repetitions)] #[derive(Debug)] pub struct WebRtcPlayEndpoint(Mutex>); @@ -163,18 +163,19 @@ impl WebRtcPublishEndpointInner { self.peer_ids = HashSet::new() } + #[allow(clippy::trivially_copy_pass_by_ref)] fn remove_peer_id(&mut self, peer_id: &PeerId) { self.peer_ids.remove(peer_id); } - fn remove_peer_ids(&mut self, peer_ids: &Vec) { + fn remove_peer_ids(&mut self, peer_ids: &[PeerId]) { for peer_id in peer_ids { self.remove_peer_id(peer_id) } } } -/// Signalling representation of WebRtcPublishEndpoint. +/// Signalling representation of `WebRtcPublishEndpoint`. #[allow(clippy::module_name_repetitions)] #[derive(Debug)] pub struct WebRtcPublishEndpoint(Mutex>); @@ -227,12 +228,13 @@ impl WebRtcPublishEndpoint { } /// Remove [`PeerId`] from peer_ids. + #[allow(clippy::trivially_copy_pass_by_ref)] pub fn remove_peer_id(&self, peer_id: &PeerId) { self.0.lock().unwrap().borrow_mut().remove_peer_id(peer_id) } /// Remove all [`PeerId`]s related to this [`WebRtcPublishEndpoint`]. - pub fn remove_peer_ids(&self, peer_ids: &Vec) { + pub fn remove_peer_ids(&self, peer_ids: &[PeerId]) { self.0 .lock() .unwrap() diff --git a/src/signalling/control/participant.rs b/src/signalling/control/participant.rs index a03599be0..37476999d 100644 --- a/src/signalling/control/participant.rs +++ b/src/signalling/control/participant.rs @@ -10,10 +10,8 @@ use failure::Fail; use hashbrown::HashMap; use crate::{ - api::control::{ - MemberId, MemberSpec, RoomSpec, TryFromElementError, - }, - media::PeerId + api::control::{MemberId, MemberSpec, RoomSpec, TryFromElementError}, + media::PeerId, }; use super::endpoint::{ @@ -69,7 +67,7 @@ impl Participant { /// Notify [`Participant`] that some [`Peer`]s removed. /// /// All [`PeerId`]s related to this [`Participant`] will be removed. - pub fn peers_removed(&self, peer_ids: &Vec) { + pub fn peers_removed(&self, peer_ids: &[PeerId]) { self.publishers() .into_iter() .for_each(|(_, p)| p.remove_peer_ids(peer_ids)); @@ -99,7 +97,7 @@ impl Participant { for (id, member) in &members { participants.insert( id.clone(), - Arc::new(Participant::new( + Arc::new(Self::new( id.clone(), member.credentials().to_string(), )), diff --git a/src/signalling/room.rs b/src/signalling/room.rs index e58913b80..e4efaf34f 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -460,6 +460,7 @@ impl Handler for Room { type Result = ActFuture<(), ()>; /// Send [`Event::PeersRemoved`] to [`Participant`]. + #[allow(clippy::single_match_else)] fn handle( &mut self, msg: PeersRemoved, From a06072ca0be407fe4d1efb08b361d819b172e79c Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 12 Jun 2019 15:34:18 +0300 Subject: [PATCH 134/735] Remove useless dependency --- Cargo.lock | 1 - Cargo.toml | 1 - 2 files changed, 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7597ed656..090c77704 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -857,7 +857,6 @@ dependencies = [ "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "macro-attr 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "medea-client-api-proto 0.1.0-dev", "medea-macro 0.1.0-dev", diff --git a/Cargo.toml b/Cargo.toml index 48734017c..9218dfa24 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -49,7 +49,6 @@ toml = "0.4" branch = "serde_wrapper" [dev-dependencies] -lazy_static = "1.3" serial_test = "0.2" serial_test_derive = "0.2" tokio = "0.1" From 9ecdc7a8ac3e85e284b4fdcdbf6ce4595748d72c Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 12 Jun 2019 15:34:48 +0300 Subject: [PATCH 135/735] Fix uris for three-members-conference in jason --- jason/e2e-demo/js/index.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/jason/e2e-demo/js/index.js b/jason/e2e-demo/js/index.js index 697e2099e..d9030eb79 100644 --- a/jason/e2e-demo/js/index.js +++ b/jason/e2e-demo/js/index.js @@ -8,9 +8,9 @@ async function f() { caller.join_room("ws://localhost:8080/ws/video-call-1/responder/test"); // Use this for testing with 3 members. - // caller.join_room("ws://localhost:8080/ws/video-call-3/caller/test"); - // caller.join_room("ws://localhost:8080/ws/video-call-3/responder/test"); - // caller.join_room("ws://localhost:8080/ws/video-call-3/responder2/test"); + // caller.join_room("ws://localhost:8080/ws/three-members-conference/caller/test"); + // caller.join_room("ws://localhost:8080/ws/three-members-conference/responder/test"); + // caller.join_room("ws://localhost:8080/ws/three-members-conference/responder2/test"); // caller.join_room("ws://localhost:8080/ws/1/2/responder_credentials"); @@ -19,7 +19,6 @@ async function f() { // let responder_room_handler = await responder.join_room("ws://localhost:8080/ws/1/2/responder_credentials"); // caller.dispose(); - // responder.dispose(); } f(); From b0dc151550ef6f86e380277419a9c2492116c327 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 12 Jun 2019 16:52:12 +0300 Subject: [PATCH 136/735] Add participant loading test --- src/signalling/control/participant.rs | 121 ++++++++++++++++++++++++-- 1 file changed, 113 insertions(+), 8 deletions(-) diff --git a/src/signalling/control/participant.rs b/src/signalling/control/participant.rs index 37476999d..9de829f7a 100644 --- a/src/signalling/control/participant.rs +++ b/src/signalling/control/participant.rs @@ -84,6 +84,11 @@ impl Participant { self.0.lock().unwrap().borrow().id.clone() } + /// Returns credentials of this [`Participant`]. + pub fn credentials(&self) -> String { + self.0.lock().unwrap().borrow().credentials.clone() + } + /// Creates all empty [`Participant`] from [`RoomSpec`] and then /// load all related to this [`Participant`]s receivers and publishers. /// @@ -111,11 +116,6 @@ impl Participant { Ok(participants) } - /// Returns credentials of this [`Participant`]. - pub fn credentials(&self) -> String { - self.0.lock().unwrap().borrow().credentials.clone() - } - /// Returns all publishers of this [`Participant`]. pub fn publishers( &self, @@ -240,7 +240,7 @@ impl Participant { Ok(()) } - /// Insert new receiver into this [`Participant`]. + /// Insert receiver into this [`Participant`]. pub fn insert_receiver( &self, id: EndpointId, @@ -254,7 +254,7 @@ impl Participant { .insert(id, endpoint); } - /// Insert new publisher into this [`Participant`]. + /// Insert publisher into this [`Participant`]. pub fn insert_publisher( &self, id: EndpointId, @@ -275,6 +275,111 @@ impl Participant { ) -> Option> { self.0.lock().unwrap().borrow().publishers.get(id).cloned() } + + /// Lookup [`WebRtcPlayEndpoint`] receiver by id. + pub fn get_receiver_by_id( + &self, + id: &EndpointId, + ) -> Option> { + self.0.lock().unwrap().borrow().receivers.get(id).cloned() + } } -// TODO (evdokimovs): add Participant unit tests +#[cfg(test)] +mod participant_loading_tests { + use super::*; + + use std::sync::Arc; + + use crate::api::control::Element; + + #[test] + pub fn load_store() { + let spec = r#" + kind: Room + id: test-call + spec: + pipeline: + caller: + kind: Member + credentials: test + spec: + pipeline: + publish: + kind: WebRtcPublishEndpoint + spec: + p2p: Always + some-member: + kind: Member + credentials: test + spec: + pipeline: + publish: + kind: WebRtcPublishEndpoint + spec: + p2p: Always + responder: + kind: Member + credentials: test + spec: + pipeline: + play: + kind: WebRtcPlayEndpoint + spec: + src: "local://test-call/caller/publish" + play2: + kind: WebRtcPlayEndpoint + spec: + src: "local://test-call/some-member/publish" + "#; + let room_element: Element = serde_yaml::from_str(&spec).unwrap(); + let room_spec = RoomSpec::try_from(&room_element).unwrap(); + let store = Participant::load_store(&room_spec).unwrap(); + + let caller = store.get(&MemberId("caller".to_string())).unwrap(); + let responder = store.get(&MemberId("responder".to_string())).unwrap(); + + let caller_publish_endpoint = caller + .get_publisher_by_id(&EndpointId("publish".to_string())) + .unwrap(); + let responder_play_endpoint = responder + .get_receiver_by_id(&EndpointId("play".to_string())) + .unwrap(); + + let is_caller_has_responder_in_receivers = caller_publish_endpoint + .receivers() + .into_iter() + .map(|p| p.upgrade().unwrap()) + .filter(|p| Arc::ptr_eq(p, &responder_play_endpoint)) + .count() + == 1; + assert!(is_caller_has_responder_in_receivers); + + assert!(Arc::ptr_eq( + &responder_play_endpoint.publisher().upgrade().unwrap(), + &caller_publish_endpoint + )); + + let some_participant = + store.get(&MemberId("some-member".to_string())).unwrap(); + assert!(some_participant.receivers().is_empty()); + assert_eq!(some_participant.publishers().len(), 1); + + let responder_play2_endpoint = responder + .get_receiver_by_id(&EndpointId("play2".to_string())) + .unwrap(); + let some_participant_publisher = some_participant + .get_publisher_by_id(&EndpointId("publish".to_string())) + .unwrap(); + assert_eq!(some_participant_publisher.receivers().len(), 1); + let is_some_participant_has_responder_in_receivers = + some_participant_publisher + .receivers() + .into_iter() + .map(|p| p.upgrade().unwrap()) + .filter(|p| Arc::ptr_eq(p, &responder_play2_endpoint)) + .count() + == 1; + assert!(is_some_participant_has_responder_in_receivers); + } +} From 940d130c414a5c22cc2e0374d127ee6cf2a02ebf Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 12 Jun 2019 17:06:15 +0300 Subject: [PATCH 137/735] Improve log message in creating new ParticipantSerivce --- src/signalling/control/endpoint.rs | 7 +++++++ src/signalling/participants.rs | 21 ++++++++++++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/signalling/control/endpoint.rs b/src/signalling/control/endpoint.rs index bfaf8361b..b14e1cd11 100644 --- a/src/signalling/control/endpoint.rs +++ b/src/signalling/control/endpoint.rs @@ -2,6 +2,7 @@ use std::{ cell::RefCell, + fmt::Display, sync::{Mutex, Weak}, }; @@ -18,6 +19,12 @@ use super::participant::Participant; #[derive(Clone, Debug, Eq, Hash, PartialEq)] pub struct Id(pub String); +impl Display for Id { + fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(fmt, "{}", self.0) + } +} + #[derive(Debug, Clone)] struct WebRtcPlayEndpointInner { /// Source URI of [`WebRtcPublishEndpoint`] from which this diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 9e474fe3c..c3d31c697 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -64,10 +64,25 @@ impl ParticipantService { ) -> Result { let members = Participant::load_store(room_spec)?; - // TODO: more informative msg debug!( - "Created room with {:?} members.", - members.iter().map(|(id, _)| id).collect::>() + "Created ParticipantService with participants: {:?}.", + members + .iter() + .map(|(id, p)| { + format!( + "{{ id: {}, receivers: {:?}, publishers: {:?} }};", + id, + p.receivers() + .into_iter() + .map(|(id, _)| id.to_string()) + .collect::>(), + p.publishers() + .into_iter() + .map(|(id, _)| id.to_string()) + .collect::>() + ) + }) + .collect::>() ); Ok(Self { From 2053f0ff3205d11e9a3be4e0151eb611c29f5bf6 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 12 Jun 2019 17:17:14 +0300 Subject: [PATCH 138/735] Fix doc --- src/api/control/endpoint.rs | 2 +- src/api/control/member.rs | 6 +++--- src/api/control/room.rs | 2 +- src/signalling/control/participant.rs | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/api/control/endpoint.rs b/src/api/control/endpoint.rs index 314400c79..1139b37d0 100644 --- a/src/api/control/endpoint.rs +++ b/src/api/control/endpoint.rs @@ -64,7 +64,7 @@ pub struct WebRtcPlayEndpoint { pub struct SrcUri { /// ID of [`Room`] pub room_id: String, - /// ID of [`Member`] + /// ID of `Member` pub member_id: MemberId, /// Control ID of [`Endpoint`] pub endpoint_id: String, diff --git a/src/api/control/member.rs b/src/api/control/member.rs index 93552d401..e0b743998 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -11,7 +11,7 @@ use super::{ Element, TryFromElementError, }; -/// ID of [`Member`]. +/// ID of `Member`. #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq)] pub struct Id(pub String); @@ -25,10 +25,10 @@ impl Display for Id { #[allow(clippy::module_name_repetitions)] #[derive(Clone, Debug)] pub struct MemberSpec { - /// Spec of this [`Member`]. + /// Spec of this `Member`. pipeline: Pipeline, - /// Credentials to authorize [`Member`] with. + /// Credentials to authorize `Member` with. credentials: String, } diff --git a/src/api/control/room.rs b/src/api/control/room.rs index 85dfebf51..4516e622e 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -24,7 +24,7 @@ pub struct RoomSpec { } impl RoomSpec { - /// Returns all [`Member`]s of this [`RoomSpec`]. + /// Returns all [`MemberSpec`]s of this [`RoomSpec`]. pub fn members( &self, ) -> Result, TryFromElementError> { diff --git a/src/signalling/control/participant.rs b/src/signalling/control/participant.rs index 9de829f7a..4ec6c3d50 100644 --- a/src/signalling/control/participant.rs +++ b/src/signalling/control/participant.rs @@ -287,12 +287,12 @@ impl Participant { #[cfg(test)] mod participant_loading_tests { - use super::*; - use std::sync::Arc; use crate::api::control::Element; + use super::*; + #[test] pub fn load_store() { let spec = r#" From e86d8375a8e938006d1484b5c14a277365383fe6 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 12 Jun 2019 17:53:11 +0300 Subject: [PATCH 139/735] Corrections --- src/signalling/control/participant.rs | 8 ++++---- src/signalling/peers.rs | 5 +---- src/signalling/room.rs | 13 +++++++++---- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/signalling/control/participant.rs b/src/signalling/control/participant.rs index 4ec6c3d50..187433322 100644 --- a/src/signalling/control/participant.rs +++ b/src/signalling/control/participant.rs @@ -219,8 +219,8 @@ impl Participant { } } - // First of all, it is necessary to create [`WebRtcPublishEndpoint`]s - // to which no [`WebRtcPlayEndpoint`] refers. + // This is necessary to create [`WebRtcPublishEndpoint`], + // to which none [`WebRtcPlayEndpoint`] refers. this_member_spec.publish_endpoints().into_iter().for_each( |(name, e)| { let endpoint_id = EndpointId(name.clone()); @@ -268,7 +268,7 @@ impl Participant { .insert(id, endpoint); } - /// Lookup [`WebRtcPublishEndpoint`] publisher by id. + /// Lookup [`WebRtcPublishEndpoint`] publisher by [`EndpointId`]. pub fn get_publisher_by_id( &self, id: &EndpointId, @@ -276,7 +276,7 @@ impl Participant { self.0.lock().unwrap().borrow().publishers.get(id).cloned() } - /// Lookup [`WebRtcPlayEndpoint`] receiver by id. + /// Lookup [`WebRtcPlayEndpoint`] receiver by [`EndpointId`]. pub fn get_receiver_by_id( &self, id: &EndpointId, diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index 3b67881ca..2090f4d8c 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -10,6 +10,7 @@ use hashbrown::HashMap; use crate::{ api::control::MemberId, + log::prelude::*, media::{Peer, PeerId, PeerStateMachine}, signalling::{ control::participant::Participant, @@ -51,8 +52,6 @@ impl fmt::Display for Counter { } } -use crate::log::prelude::*; - impl PeerRepository { /// Store [`Peer`] in [`Room`]. pub fn add_peer>(&mut self, id: PeerId, peer: S) { @@ -112,8 +111,6 @@ impl PeerRepository { self.add_peer(first_peer_id, first_peer); self.add_peer(second_peer_id, second_peer); - // println!("Peers: {:#?}", self.peers); - (first_peer_id, second_peer_id) } diff --git a/src/signalling/room.rs b/src/signalling/room.rs index e4efaf34f..752393a3e 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -265,7 +265,7 @@ impl Room { ))) } - /// Create [`Peer`] between [`Participant`]s and interconnect it by control + /// Create [`Peer`]s between [`Participant`]s and interconnect it by control /// API spec. fn create_and_interconnect_peers( &mut self, @@ -350,7 +350,7 @@ impl Room { } } - // Create all connected play receivers peers. + // Create all connected play's receivers peers. for (_id, play) in member.receivers() { let plays_publisher_participant = if let Some(plays_publisher) = play.publisher().upgrade() { @@ -449,6 +449,7 @@ impl Handler for Room { } } +/// Signal of removing [`Participant`]'s [`Peer`]s. #[derive(Debug, Message)] #[rtype(result = "Result<(), ()>")] pub struct PeersRemoved { @@ -459,13 +460,17 @@ pub struct PeersRemoved { impl Handler for Room { type Result = ActFuture<(), ()>; - /// Send [`Event::PeersRemoved`] to [`Participant`]. + /// Send [`Event::PeersRemoved`] to remote [`Participant`]. + /// + /// Delete all removed [`PeerId`]s from all [`Participant`]'s + /// endpoints. #[allow(clippy::single_match_else)] fn handle( &mut self, msg: PeersRemoved, ctx: &mut Self::Context, ) -> Self::Result { + info!("Peers {:?} removed for member '{}'.", msg.peers_id, msg.member_id); if let Some(participant) = self.participants.get_member_by_id(&msg.member_id) { @@ -548,7 +553,7 @@ impl Handler for Room { /// Saves new [`RpcConnection`] in [`ParticipantService`], initiates media /// establishment between members. - /// Create and interconnect all necessary [`Participant`]'s [`Peer`]s. + /// Create and interconnect all available [`Participant`]'s [`Peer`]s. fn handle( &mut self, msg: RpcConnectionEstablished, From b82ecd36d79d12e01cb6bc234ac3f38212f5f47f Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 12 Jun 2019 17:54:59 +0300 Subject: [PATCH 140/735] Fmt --- src/signalling/room.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 752393a3e..056e3d95a 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -470,7 +470,10 @@ impl Handler for Room { msg: PeersRemoved, ctx: &mut Self::Context, ) -> Self::Result { - info!("Peers {:?} removed for member '{}'.", msg.peers_id, msg.member_id); + info!( + "Peers {:?} removed for member '{}'.", + msg.peers_id, msg.member_id + ); if let Some(participant) = self.participants.get_member_by_id(&msg.member_id) { From db6e836e2d8581ccc49502757f4e1aa1442244ef Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 13 Jun 2019 15:38:56 +0300 Subject: [PATCH 141/735] Fix creating IceUser --- src/api/client/server.rs | 11 +++++++---- src/api/control/room.rs | 3 +-- src/lib.rs | 10 +++++++--- src/signalling/control/participant.rs | 21 ++++++++++++++++----- src/signalling/participants.rs | 8 +++++--- src/signalling/room.rs | 24 ++++++++++++++---------- src/turn/service.rs | 2 +- 7 files changed, 51 insertions(+), 28 deletions(-) diff --git a/src/api/client/server.rs b/src/api/client/server.rs index 04fac9846..98a01911b 100644 --- a/src/api/client/server.rs +++ b/src/api/client/server.rs @@ -110,8 +110,8 @@ mod test { use crate::{ api::control, - conf::{Conf, Server}, api::control::Member, + conf::{Conf, Server}, conf::{Conf, Server, Turn}, media::create_peers, signalling::Room, @@ -126,9 +126,12 @@ mod test { control::load_from_yaml_file("tests/specs/pub_sub_video_call.yml") .unwrap(); - let client_room = - Room::new(&room_spec, conf.reconnect_timeout, - new_turn_auth_service_mock() ).unwrap(); + let client_room = Room::new( + &room_spec, + conf.reconnect_timeout, + new_turn_auth_service_mock(), + ) + .unwrap(); let room_id = client_room.get_id(); let client_room = Arbiter::start(move |_| client_room); let room_hash_map = hashmap! { diff --git a/src/api/control/room.rs b/src/api/control/room.rs index 350a01db0..4a465faa1 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -1,7 +1,7 @@ //! Room definitions and implementations. -use std::{convert::TryFrom, sync::Arc}; use std::fmt::Display; +use std::{convert::TryFrom, sync::Arc}; use hashbrown::HashMap; use serde::Deserialize; @@ -21,7 +21,6 @@ impl Display for Id { } } - /// [`crate::signalling::room::Room`] specification. /// Newtype for [`Element::Room`] #[allow(clippy::module_name_repetitions)] diff --git a/src/lib.rs b/src/lib.rs index 0bc378125..5dc80a892 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -75,10 +75,14 @@ pub fn start_static_rooms( )); } - let turn_auth_service = new_turn_auth_service(&config).expect("Unable to start turn service"); + let turn_auth_service = new_turn_auth_service(&config) + .expect("Unable to start turn service"); - let room = Room::new(&spec, config.rpc.reconnect_timeout, - turn_auth_service)?; + let room = Room::new( + &spec, + config.rpc.reconnect_timeout, + turn_auth_service, + )?; let room = Arbiter::start(move |_| room); rooms.insert(spec.id().clone(), room); } diff --git a/src/signalling/control/participant.rs b/src/signalling/control/participant.rs index 4acfbfcc0..aebc46f39 100644 --- a/src/signalling/control/participant.rs +++ b/src/signalling/control/participant.rs @@ -3,18 +3,18 @@ use std::{ cell::RefCell, convert::TryFrom as _, - sync::{Arc, Mutex}, ops::Deref as _, + sync::{Arc, Mutex}, }; use failure::Fail; use hashbrown::HashMap; +use crate::media::IceUser; use crate::{ api::control::{MemberId, MemberSpec, RoomSpec, TryFromElementError}, media::PeerId, }; -use crate::media::IceUser; use super::endpoint::{ Id as EndpointId, WebRtcPlayEndpoint, WebRtcPublishEndpoint, @@ -54,7 +54,7 @@ struct ParticipantInner { publishers: HashMap>, receivers: HashMap>, credentials: String, - ice_user: Option + ice_user: Option, } impl Participant { @@ -85,7 +85,13 @@ impl Participant { } pub fn servers_list(&self) -> Option> { - self.0.lock().unwrap().borrow().ice_user.as_ref().map(|u| u.servers_list()) + self.0 + .lock() + .unwrap() + .borrow() + .ice_user + .as_ref() + .map(|u| u.servers_list()) } pub fn take_ice_user(&self) -> Option { @@ -93,7 +99,12 @@ impl Participant { } pub fn replace_ice_user(&self, new_ice_user: IceUser) -> Option { - self.0.lock().unwrap().borrow_mut().ice_user.replace(new_ice_user) + self.0 + .lock() + .unwrap() + .borrow_mut() + .ice_user + .replace(new_ice_user) } /// Returns [`MemberId`] of this [`Participant`]. diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 11fdcc87e..94735d9b3 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -170,7 +170,10 @@ impl ParticipantService { self.members.get(&member_id).cloned() } - pub fn take_member(&mut self, member_id: MemberId) -> Option> { + pub fn take_member( + &mut self, + member_id: MemberId, + ) -> Option> { self.members.remove(&member_id) } @@ -229,10 +232,9 @@ impl ParticipantService { .and_then( move |ice: IceUser, room: &mut Room, _| { if let Some(mut member) = - room.participants.take_member(member_id.clone()) + room.participants.get_member_by_id(&member_id) { member.replace_ice_user(ice); - room.participants.insert_member(member); }; wrap_future(future::ok(())) }, diff --git a/src/signalling/room.rs b/src/signalling/room.rs index e93fc01c6..d48058f9f 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -206,7 +206,9 @@ impl Room { .get_member(to_member_id.clone()) .ok_or_else(|| RoomError::MemberNotFound(to_member_id.clone()))? .servers_list() - .ok_or_else(|| RoomError::NoTurnCredentials(to_member_id.clone()))?; + .ok_or_else(|| { + RoomError::NoTurnCredentials(to_member_id.clone()) + })?; let event = Event::PeerCreated { peer_id: to_peer_id, @@ -592,16 +594,18 @@ impl Handler for Room { ) -> Self::Result { info!("RpcConnectionEstablished for member {}", msg.member_id); - // save new connection - self.participants.connection_established( - ctx, - msg.member_id.clone(), - msg.connection, - ); - - self.create_peers_with_available_members(&msg.member_id, ctx); + let member_id = msg.member_id; - Box::new(wrap_future(future::ok(()))) + let fut = self + .participants + .connection_established(ctx, member_id.clone(), msg.connection) + .map_err(|err, _, _| { + error!("RpcConnectionEstablished error {:?}", err) + }) + .map(move |_, room, ctx| { + room.create_peers_with_available_members(&member_id, ctx); + }); + Box::new(fut) } } diff --git a/src/turn/service.rs b/src/turn/service.rs index 249e8c75e..fe68e83c9 100644 --- a/src/turn/service.rs +++ b/src/turn/service.rs @@ -13,9 +13,9 @@ use redis::ConnectionInfo; use crate::{ api::control::MemberId, + api::control::RoomId, conf::Conf, media::IceUser, - api::control::RoomId, turn::repo::{TurnDatabase, TurnDatabaseErr}, }; From 8b0d9d9947922a5bd5dcb53ec736486af5bffd21 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 13 Jun 2019 16:38:28 +0300 Subject: [PATCH 142/735] Fix test --- Cargo.toml | 3 +++ Makefile | 2 +- proto/client-api/src/lib.rs | 1 - src/api/client/server.rs | 3 --- src/lib.rs | 9 ++++++--- src/turn/service.rs | 5 +++-- tests/signalling.rs | 10 +++++++--- 7 files changed, 20 insertions(+), 13 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 788e39985..60a60f32c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,6 +19,9 @@ members = [ [profile.release] lto = "thin" +[features] +e2e_test = [] + [dependencies] actix = "0.7" actix-web = "0.7" diff --git a/Makefile b/Makefile index 65d8476f2..4b88891db 100644 --- a/Makefile +++ b/Makefile @@ -136,7 +136,7 @@ ifeq ($(test-unit-crate),@all) @make test.unit crate=jason else ifeq ($(test-unit-crate),medea) - cargo test -p medea + cargo test -p medea --features "e2e_test" else ifeq ($(test-unit-crate),jason) wasm-pack test --headless --firefox jason diff --git a/proto/client-api/src/lib.rs b/proto/client-api/src/lib.rs index 6e95cc8a8..ad01bf563 100644 --- a/proto/client-api/src/lib.rs +++ b/proto/client-api/src/lib.rs @@ -99,7 +99,6 @@ pub struct Track { #[derive(Clone, Debug)] #[cfg_attr(feature = "medea", derive(Serialize, PartialEq))] #[cfg_attr(feature = "jason", derive(Deserialize))] -#[cfg_attr(test, derive(PartialEq))] pub struct IceServer { pub urls: Vec, #[serde(skip_serializing_if = "Option::is_none")] diff --git a/src/api/client/server.rs b/src/api/client/server.rs index 98a01911b..b8b3f4bc4 100644 --- a/src/api/client/server.rs +++ b/src/api/client/server.rs @@ -110,10 +110,7 @@ mod test { use crate::{ api::control, - api::control::Member, - conf::{Conf, Server}, conf::{Conf, Server, Turn}, - media::create_peers, signalling::Room, turn::new_turn_auth_service_mock, }; diff --git a/src/lib.rs b/src/lib.rs index 5dc80a892..f9c6f8c1a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -17,13 +17,13 @@ use crate::{ api::{control::load_static_specs_from_dir, control::RoomId}, conf::Conf, signalling::{room::RoomError, Room}, - turn::new_turn_auth_service, + turn::service, }; /// Errors which can happen while server starting. #[derive(Debug, Fail)] pub enum ServerStartError { - /// Duplicate room ID finded. + /// Duplicate [`RoomId`] founded. #[fail(display = "Duplicate of room ID '{:?}'", _0)] DuplicateRoomId(RoomId), @@ -75,7 +75,10 @@ pub fn start_static_rooms( )); } - let turn_auth_service = new_turn_auth_service(&config) + #[cfg(feature = "e2e_test")] + let turn_auth_service = service::test::new_turn_auth_service_mock(); + #[cfg(not(feature = "e2e_test"))] + let turn_auth_service = service::new_turn_auth_service(config) .expect("Unable to start turn service"); let room = Room::new( diff --git a/src/turn/service.rs b/src/turn/service.rs index fe68e83c9..6862069e3 100644 --- a/src/turn/service.rs +++ b/src/turn/service.rs @@ -276,7 +276,8 @@ impl Handler for Service { } } -#[cfg(test)] + +#[cfg(any(feature = "e2e_test", test))] pub mod test { use futures::future; @@ -290,7 +291,7 @@ pub mod test { impl TurnAuthService for TurnAuthServiceMock { fn create( &self, - _: u64, + _: MemberId, _: RoomId, _: UnreachablePolicy, ) -> Box> { diff --git a/tests/signalling.rs b/tests/signalling.rs index 0cda00cdd..35182b672 100644 --- a/tests/signalling.rs +++ b/tests/signalling.rs @@ -175,7 +175,7 @@ fn pub_sub_video_call() { let test_fn = move |event: &Event, _ctx: &mut Context| { events.push(event.clone()); - // Start of checking result of test. + // Start checking result of test. if let Event::IceCandidateDiscovered { .. } = event { let peers_count = events .iter() @@ -191,8 +191,11 @@ fn pub_sub_video_call() { peer_id, sdp_offer, tracks, + ice_servers, } = &events[0] { + assert_eq!(ice_servers.len(), 2); + if let Some(_) = sdp_offer { is_caller = false; } else { @@ -273,13 +276,14 @@ fn three_members_p2p_video_call() { let test_fn = move |event: &Event, ctx: &mut Context| { events.push(event.clone()); match event { - Event::PeerCreated { .. } => { + Event::PeerCreated { ice_servers, .. } => { + assert_eq!(ice_servers.len(), 2); peer_created_count += 1; } Event::IceCandidateDiscovered { .. } => { ice_candidates += 1; if ice_candidates == 2 { - // Start of checking result of test. + // Start checking result of test. assert_eq!(peer_created_count, 2); From 004ebbc4f0746498b7d3c4d265ef31b6da0bd501 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 13 Jun 2019 17:21:58 +0300 Subject: [PATCH 143/735] Fix formating --- src/conf/rpc.rs | 2 +- src/conf/server.rs | 2 +- src/conf/turn.rs | 2 +- src/media/peer.rs | 5 +++-- src/signalling/control/participant.rs | 5 ++--- src/signalling/participants.rs | 24 ++++++++---------------- src/signalling/room.rs | 1 - src/turn/service.rs | 1 - tests/signalling.rs | 4 ++-- 9 files changed, 18 insertions(+), 28 deletions(-) diff --git a/src/conf/rpc.rs b/src/conf/rpc.rs index 097b09b89..0408de3ef 100644 --- a/src/conf/rpc.rs +++ b/src/conf/rpc.rs @@ -1,6 +1,6 @@ //! RPC connection settings. use serde::{Deserialize, Serialize}; -use smart_default::*; +use smart_default::SmartDefault; use std::time::Duration; diff --git a/src/conf/server.rs b/src/conf/server.rs index 637b96d71..e7e53a99e 100644 --- a/src/conf/server.rs +++ b/src/conf/server.rs @@ -3,7 +3,7 @@ use std::net::{IpAddr, Ipv4Addr, SocketAddr, ToSocketAddrs as _}; use serde::{Deserialize, Serialize}; -use smart_default::*; +use smart_default::SmartDefault; /// HTTP server settings. #[derive(Clone, Debug, Deserialize, Serialize, SmartDefault)] diff --git a/src/conf/turn.rs b/src/conf/turn.rs index 0b599e21f..3b6d23c48 100644 --- a/src/conf/turn.rs +++ b/src/conf/turn.rs @@ -6,7 +6,7 @@ use std::{ }; use serde::{Deserialize, Serialize}; -use smart_default::*; +use smart_default::SmartDefault; /// STUN/TURN server settings. #[derive(Clone, Debug, Deserialize, Serialize, SmartDefault)] diff --git a/src/media/peer.rs b/src/media/peer.rs index 2e98364f0..fb5fc1b73 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -3,6 +3,9 @@ //! [1]: https://www.w3.org/TR/webrtc/#rtcpeerconnection-interface #![allow(clippy::use_self)] + +use std::{convert::TryFrom, fmt::Display, sync::Arc}; + use failure::Fail; use hashbrown::HashMap; use medea_client_api_proto::{ @@ -10,8 +13,6 @@ use medea_client_api_proto::{ }; use medea_macro::enum_delegate; -use std::{convert::TryFrom, fmt::Display, sync::Arc}; - use crate::{ api::control::MemberId, log::prelude::*, diff --git a/src/signalling/control/participant.rs b/src/signalling/control/participant.rs index aebc46f39..d929165fe 100644 --- a/src/signalling/control/participant.rs +++ b/src/signalling/control/participant.rs @@ -3,23 +3,22 @@ use std::{ cell::RefCell, convert::TryFrom as _, - ops::Deref as _, sync::{Arc, Mutex}, }; use failure::Fail; use hashbrown::HashMap; +use medea_client_api_proto::IceServer; -use crate::media::IceUser; use crate::{ api::control::{MemberId, MemberSpec, RoomSpec, TryFromElementError}, + media::IceUser, media::PeerId, }; use super::endpoint::{ Id as EndpointId, WebRtcPlayEndpoint, WebRtcPublishEndpoint, }; -use medea_client_api_proto::IceServer; /// Errors which may occur while loading [`Participant`]s from [`RoomSpec`]. #[derive(Debug, Fail)] diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 94735d9b3..91427a797 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -18,27 +18,27 @@ use futures::{ Future, }; use hashbrown::HashMap; - use medea_client_api_proto::Event; -use crate::api::control::RoomId; use crate::{ api::{ client::rpc_connection::{ AuthorizationError, ClosedReason, EventMessage, RpcConnection, RpcConnectionClosed, }, + control::RoomId, control::{MemberId, RoomSpec}, }, log::prelude::*, media::IceUser, signalling::{ control::participant::{Participant, ParticipantsLoadError}, - room::{ActFuture, CloseRoom, RoomError}, + room::{ActFuture, RoomError}, Room, }, turn::{TurnAuthService, TurnServiceErr, UnreachablePolicy}, }; + #[derive(Fail, Debug)] #[allow(clippy::module_name_repetitions)] pub enum ParticipantServiceErr { @@ -148,7 +148,7 @@ impl ParticipantService { member_id: &MemberId, credentials: &str, ) -> Result, AuthorizationError> { - match self.members.get(member_id) { + match self.get_member_by_id(member_id) { Some(member) => { if member.credentials().eq(credentials) { Ok(member.clone()) @@ -170,13 +170,6 @@ impl ParticipantService { self.members.get(&member_id).cloned() } - pub fn take_member( - &mut self, - member_id: MemberId, - ) -> Option> { - self.members.remove(&member_id) - } - pub fn insert_member(&mut self, member: Arc) { self.members.insert(member.id(), member); } @@ -231,7 +224,7 @@ impl ParticipantService { }) .and_then( move |ice: IceUser, room: &mut Room, _| { - if let Some(mut member) = + if let Some(member) = room.participants.get_member_by_id(&member_id) { member.replace_ice_user(ice); @@ -291,13 +284,12 @@ impl ParticipantService { &mut self, member_id: MemberId, ) -> Box> { - match self.members.remove(&member_id) { - Some(mut member) => { + match self.get_member_by_id(&member_id) { + Some(member) => { let delete_fut = match member.take_ice_user() { Some(ice_user) => self.turn.delete(vec![ice_user]), None => Box::new(future::ok(())), }; - self.members.insert(member_id, member); delete_fut } @@ -328,7 +320,7 @@ impl ParticipantService { let remove_ice_users = Box::new({ let mut room_users = Vec::with_capacity(self.members.len()); - self.members.iter_mut().for_each(|(_, data)| { + self.members.iter().for_each(|(_, data)| { if let Some(ice_user) = data.take_ice_user() { room_users.push(ice_user); } diff --git a/src/signalling/room.rs b/src/signalling/room.rs index d48058f9f..185ccf4c8 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -10,7 +10,6 @@ use actix::{ use failure::Fail; use futures::future; use hashbrown::HashMap; - use medea_client_api_proto::{Command, Event, IceCandidate}; use crate::{ diff --git a/src/turn/service.rs b/src/turn/service.rs index 6862069e3..94b8ea746 100644 --- a/src/turn/service.rs +++ b/src/turn/service.rs @@ -276,7 +276,6 @@ impl Handler for Service { } } - #[cfg(any(feature = "e2e_test", test))] pub mod test { use futures::future; diff --git a/tests/signalling.rs b/tests/signalling.rs index 35182b672..db4e2af78 100644 --- a/tests/signalling.rs +++ b/tests/signalling.rs @@ -102,7 +102,7 @@ struct CloseSocket; impl Handler for TestMember { type Result = (); - fn handle(&mut self, _msg: CloseSocket, _ctx: &mut Self::Context) { + fn handle(&mut self, _: CloseSocket, _: &mut Self::Context) { self.writer.close(Some(CloseReason { code: CloseCode::Normal, description: None, @@ -172,7 +172,7 @@ fn pub_sub_video_call() { // Note that events is separated by members. // Every member will have different instance of this. let mut events = Vec::new(); - let test_fn = move |event: &Event, _ctx: &mut Context| { + let test_fn = move |event: &Event, _: &mut Context| { events.push(event.clone()); // Start checking result of test. From 266bd53c9707c37f03b9e89a3e01af3af3f067ef Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 13 Jun 2019 17:33:42 +0300 Subject: [PATCH 144/735] Fix lints --- proto/client-api/src/lib.rs | 1 + src/media/ice_user.rs | 2 +- src/signalling/control/participant.rs | 2 +- src/signalling/participants.rs | 18 +++++++----------- src/signalling/room.rs | 4 ++-- src/turn/service.rs | 2 +- 6 files changed, 13 insertions(+), 16 deletions(-) diff --git a/proto/client-api/src/lib.rs b/proto/client-api/src/lib.rs index ad01bf563..bb838c836 100644 --- a/proto/client-api/src/lib.rs +++ b/proto/client-api/src/lib.rs @@ -91,6 +91,7 @@ pub struct Track { pub media_type: MediaType, } +#[allow(clippy::doc_markdown)] /// Representation of [RTCIceServer][1] (item of `iceServers` field /// from [RTCConfiguration][2]). /// diff --git a/src/media/ice_user.rs b/src/media/ice_user.rs index 0712ace35..1c18da31d 100644 --- a/src/media/ice_user.rs +++ b/src/media/ice_user.rs @@ -23,7 +23,7 @@ impl IceUser { /// Build new non static [`IceUser`]. pub fn build( address: SocketAddr, - room_id: RoomId, + room_id: &RoomId, name: &str, pass: String, ) -> Self { diff --git a/src/signalling/control/participant.rs b/src/signalling/control/participant.rs index d929165fe..e74d957b7 100644 --- a/src/signalling/control/participant.rs +++ b/src/signalling/control/participant.rs @@ -90,7 +90,7 @@ impl Participant { .borrow() .ice_user .as_ref() - .map(|u| u.servers_list()) + .map(IceUser::servers_list) } pub fn take_ice_user(&self) -> Option { diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 91427a797..c45cad38c 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -166,7 +166,7 @@ impl ParticipantService { && !self.drop_connection_tasks.contains_key(member_id) } - pub fn get_member(&self, member_id: MemberId) -> Option> { + pub fn get_member(&self, member_id: &MemberId) -> Option> { self.members.get(&member_id).cloned() } @@ -254,7 +254,7 @@ impl ParticipantService { self.connections.remove(&member_id); ctx.spawn(wrap_future( - self.delete_ice_user(member_id).map_err(|err| { + self.delete_ice_user(&member_id).map_err(|err| { error!("Error deleting IceUser {:?}", err) }), )); @@ -282,17 +282,13 @@ impl ParticipantService { /// Deletes [`IceUser`] associated with provided [`Member`]. fn delete_ice_user( &mut self, - member_id: MemberId, + member_id: &MemberId, ) -> Box> { match self.get_member_by_id(&member_id) { - Some(member) => { - let delete_fut = match member.take_ice_user() { - Some(ice_user) => self.turn.delete(vec![ice_user]), - None => Box::new(future::ok(())), - }; - - delete_fut - } + Some(member) => match member.take_ice_user() { + Some(ice_user) => self.turn.delete(vec![ice_user]), + None => Box::new(future::ok(())), + }, None => Box::new(future::ok(())), } } diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 185ccf4c8..5ec1ddb01 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -153,7 +153,7 @@ impl Room { let member_id = sender.member_id(); let ice_servers = self .participants - .get_member(member_id.clone()) + .get_member(&member_id) .ok_or_else(|| RoomError::MemberNotFound(member_id.clone()))? .servers_list() .ok_or_else(|| RoomError::NoTurnCredentials(member_id.clone()))?; @@ -202,7 +202,7 @@ impl Room { let to_member_id = to_peer.member_id(); let ice_servers = self .participants - .get_member(to_member_id.clone()) + .get_member(&to_member_id) .ok_or_else(|| RoomError::MemberNotFound(to_member_id.clone()))? .servers_list() .ok_or_else(|| { diff --git a/src/turn/service.rs b/src/turn/service.rs index 94b8ea746..8293fdde9 100644 --- a/src/turn/service.rs +++ b/src/turn/service.rs @@ -232,7 +232,7 @@ impl Handler for Service { ) -> Self::Result { let ice_user = IceUser::build( self.turn_address, - msg.room_id.clone(), + &msg.room_id, &msg.member_id.to_string(), self.new_password(TURN_PASS_LEN), ); From eec798e0c5d53d5c4c2ec181b35555765ba126b9 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 13 Jun 2019 17:43:22 +0300 Subject: [PATCH 145/735] Add docs --- src/signalling/control/participant.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/signalling/control/participant.rs b/src/signalling/control/participant.rs index e74d957b7..f56cde99c 100644 --- a/src/signalling/control/participant.rs +++ b/src/signalling/control/participant.rs @@ -50,14 +50,25 @@ pub struct Participant(Mutex>); #[derive(Debug)] struct ParticipantInner { id: MemberId, + + /// All [`WebRtcPublishEndpoint`]s of this [`Participant`]. publishers: HashMap>, + + /// All [`WebRtcPlayEndpoint`]s of this [`Participant`]. receivers: HashMap>, + + /// Credentials for this [`Participant`]. credentials: String, + + /// [`IceUser`] of this [`Participant`]. ice_user: Option, } impl Participant { /// Create new empty [`Participant`]. + /// + /// To fill this [`Participant`], you need to call the [`Participant::load`] + /// function. fn new(id: MemberId, credentials: String) -> Self { Self(Mutex::new(RefCell::new(ParticipantInner { id, @@ -83,6 +94,7 @@ impl Participant { .for_each(|(_, p)| p.reset()); } + /// Returns list of [`IceServer`] for this [`Participant`]. pub fn servers_list(&self) -> Option> { self.0 .lock() @@ -93,10 +105,12 @@ impl Participant { .map(IceUser::servers_list) } + /// Returns and set to `None` [`IceUser`] of this [`Participant`]. pub fn take_ice_user(&self) -> Option { self.0.lock().unwrap().borrow_mut().ice_user.take() } + /// Replace and return [`IceUser`] of this [`Participant`]. pub fn replace_ice_user(&self, new_ice_user: IceUser) -> Option { self.0 .lock() From 5d11254911ffd8f723b04ec6cadfc34b1ba5f0e6 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 13 Jun 2019 17:56:45 +0300 Subject: [PATCH 146/735] Refactoring --- src/signalling/mod.rs | 1 - src/signalling/participants.rs | 8 -------- src/signalling/peers.rs | 9 +++++---- src/signalling/room.rs | 22 +++++++++++----------- 4 files changed, 16 insertions(+), 24 deletions(-) diff --git a/src/signalling/mod.rs b/src/signalling/mod.rs index 0d24658c6..2b8f6a1ab 100644 --- a/src/signalling/mod.rs +++ b/src/signalling/mod.rs @@ -1,5 +1,4 @@ pub mod control; - pub mod participants; pub mod peers; pub mod room; diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index c45cad38c..c8a9ca711 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -166,14 +166,6 @@ impl ParticipantService { && !self.drop_connection_tasks.contains_key(member_id) } - pub fn get_member(&self, member_id: &MemberId) -> Option> { - self.members.get(&member_id).cloned() - } - - pub fn insert_member(&mut self, member: Arc) { - self.members.insert(member.id(), member); - } - /// Send [`Event`] to specified remote [`Participant`]. pub fn send_event_to_member( &mut self, diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index 2090f4d8c..9d2de975c 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -54,8 +54,9 @@ impl fmt::Display for Counter { impl PeerRepository { /// Store [`Peer`] in [`Room`]. - pub fn add_peer>(&mut self, id: PeerId, peer: S) { - self.peers.insert(id, peer.into()); + pub fn add_peer>(&mut self, peer: S) { + let peer = peer.into(); + self.peers.insert(peer.id(), peer); } /// Returns borrowed [`PeerStateMachine`] by its ID. @@ -108,8 +109,8 @@ impl PeerRepository { second_member.publishers(), ); - self.add_peer(first_peer_id, first_peer); - self.add_peer(second_peer_id, second_peer); + self.add_peer(first_peer); + self.add_peer(second_peer); (first_peer_id, second_peer_id) } diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 5ec1ddb01..3cfa19036 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -139,21 +139,21 @@ impl Room { } else if peer2.is_sender() { (peer2, peer1) } else { - self.peers.add_peer(peer1.id(), peer1); - self.peers.add_peer(peer2.id(), peer2); + self.peers.add_peer(peer1); + self.peers.add_peer(peer2); return Err(RoomError::BadRoomSpec(format!( "Error while trying to connect Peer [id = {}] and Peer [id = \ {}] cause neither of peers are senders", peer1_id, peer2_id ))); }; - self.peers.add_peer(receiver.id(), receiver); + self.peers.add_peer(receiver); let sender = sender.start(); let member_id = sender.member_id(); let ice_servers = self .participants - .get_member(&member_id) + .get_member_by_id(&member_id) .ok_or_else(|| RoomError::MemberNotFound(member_id.clone()))? .servers_list() .ok_or_else(|| RoomError::NoTurnCredentials(member_id.clone()))?; @@ -163,7 +163,7 @@ impl Room { tracks: sender.tracks(), ice_servers, }; - self.peers.add_peer(sender.id(), sender); + self.peers.add_peer(sender); Ok(Box::new(wrap_future( self.participants .send_event_to_member(member_id, peer_created), @@ -202,7 +202,7 @@ impl Room { let to_member_id = to_peer.member_id(); let ice_servers = self .participants - .get_member(&to_member_id) + .get_member_by_id(&to_member_id) .ok_or_else(|| RoomError::MemberNotFound(to_member_id.clone()))? .servers_list() .ok_or_else(|| { @@ -210,14 +210,14 @@ impl Room { })?; let event = Event::PeerCreated { - peer_id: to_peer_id, + peer_id: to_peer.id(), sdp_offer: Some(sdp_offer), tracks: to_peer.tracks(), ice_servers, }; - self.peers.add_peer(from_peer_id, from_peer); - self.peers.add_peer(to_peer_id, to_peer); + self.peers.add_peer(from_peer); + self.peers.add_peer(to_peer); Ok(Box::new(wrap_future( self.participants.send_event_to_member(to_member_id, event), @@ -248,8 +248,8 @@ impl Room { sdp_answer, }; - self.peers.add_peer(from_peer_id, from_peer); - self.peers.add_peer(to_peer_id, to_peer); + self.peers.add_peer(from_peer); + self.peers.add_peer(to_peer); Ok(Box::new(wrap_future( self.participants.send_event_to_member(to_member_id, event), From 7bcf7cb1531b9485eb8dfc76a58f0b5151441522 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 14 Jun 2019 12:59:34 +0300 Subject: [PATCH 147/735] Fix docker-compose, remove RefCell --- docker-compose.yml | 2 +- src/signalling/control/endpoint.rs | 47 ++++++++++++--------------- src/signalling/control/participant.rs | 43 ++++++++---------------- 3 files changed, 35 insertions(+), 57 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 86015777f..88e1a7473 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,4 @@ -version: 2 +version: "2" services: coturn: diff --git a/src/signalling/control/endpoint.rs b/src/signalling/control/endpoint.rs index b14e1cd11..e1fe433bb 100644 --- a/src/signalling/control/endpoint.rs +++ b/src/signalling/control/endpoint.rs @@ -1,7 +1,6 @@ //! Signalling representation of endpoints. use std::{ - cell::RefCell, fmt::Display, sync::{Mutex, Weak}, }; @@ -75,7 +74,7 @@ impl WebRtcPlayEndpointInner { /// Signalling representation of `WebRtcPlayEndpoint`. #[allow(clippy::module_name_repetitions)] #[derive(Debug)] -pub struct WebRtcPlayEndpoint(Mutex>); +pub struct WebRtcPlayEndpoint(Mutex); impl WebRtcPlayEndpoint { /// Create new [`WebRtcPlayEndpoint`]. @@ -84,49 +83,49 @@ impl WebRtcPlayEndpoint { publisher: Weak, owner: Weak, ) -> Self { - Self(Mutex::new(RefCell::new(WebRtcPlayEndpointInner { + Self(Mutex::new(WebRtcPlayEndpointInner { src, publisher, owner, peer_id: None, - }))) + })) } /// Returns [`SrcUri`] of this [`WebRtcPlayEndpoint`]. pub fn src(&self) -> SrcUri { - self.0.lock().unwrap().borrow().src() + self.0.lock().unwrap().src() } /// Returns owner [`Participant`] of this [`WebRtcPlayEndpoint`]. pub fn owner(&self) -> Weak { - self.0.lock().unwrap().borrow().owner() + self.0.lock().unwrap().owner() } /// Returns publisher's [`WebRtcPublishEndpoint`]. pub fn publisher(&self) -> Weak { - self.0.lock().unwrap().borrow().publisher() + self.0.lock().unwrap().publisher() } /// Check that peer connection established for this [`WebRtcPlayEndpoint`]. pub fn is_connected(&self) -> bool { - self.0.lock().unwrap().borrow().is_connected() + self.0.lock().unwrap().is_connected() } /// Save [`PeerId`] of this [`WebRtcPlayEndpoint`]. pub fn connect(&self, peer_id: PeerId) { - self.0.lock().unwrap().borrow_mut().set_peer_id(peer_id); + self.0.lock().unwrap().set_peer_id(peer_id); } /// Return [`PeerId`] of [`Peer`] of this [`WebRtcPlayEndpoint`]. pub fn peer_id(&self) -> Option { - self.0.lock().unwrap().borrow().peer_id() + self.0.lock().unwrap().peer_id() } /// Reset state of this [`WebRtcPlayEndpoint`]. /// /// Atm this only reset peer_id. pub fn reset(&self) { - self.0.lock().unwrap().borrow_mut().reset() + self.0.lock().unwrap().reset() } } @@ -185,7 +184,7 @@ impl WebRtcPublishEndpointInner { /// Signalling representation of `WebRtcPublishEndpoint`. #[allow(clippy::module_name_repetitions)] #[derive(Debug)] -pub struct WebRtcPublishEndpoint(Mutex>); +pub struct WebRtcPublishEndpoint(Mutex); impl WebRtcPublishEndpoint { /// Create new [`WebRtcPublishEndpoint`]. @@ -194,58 +193,54 @@ impl WebRtcPublishEndpoint { receivers: Vec>, owner: Weak, ) -> Self { - Self(Mutex::new(RefCell::new(WebRtcPublishEndpointInner { + Self(Mutex::new(WebRtcPublishEndpointInner { p2p, receivers, owner, peer_ids: HashSet::new(), - }))) + })) } /// Add receiver for this [`WebRtcPublishEndpoint`]. pub fn add_receiver(&self, receiver: Weak) { - self.0.lock().unwrap().borrow_mut().add_receiver(receiver) + self.0.lock().unwrap().add_receiver(receiver) } /// Returns all receivers of this [`WebRtcPublishEndpoint`]. pub fn receivers(&self) -> Vec> { - self.0.lock().unwrap().borrow().receivers() + self.0.lock().unwrap().receivers() } /// Returns owner [`Participant`] of this [`WebRtcPublishEndpoint`]. pub fn owner(&self) -> Weak { - self.0.lock().unwrap().borrow().owner() + self.0.lock().unwrap().owner() } /// Add [`PeerId`] of this [`WebRtcPublishEndpoint`]. pub fn add_peer_id(&self, peer_id: PeerId) { - self.0.lock().unwrap().borrow_mut().add_peer_id(peer_id) + self.0.lock().unwrap().add_peer_id(peer_id) } /// Returns all [`PeerId`] of this [`WebRtcPublishEndpoint`]. pub fn peer_ids(&self) -> HashSet { - self.0.lock().unwrap().borrow().peer_ids() + self.0.lock().unwrap().peer_ids() } /// Reset state of this [`WebRtcPublishEndpoint`]. /// /// Atm this only reset peer_ids. pub fn reset(&self) { - self.0.lock().unwrap().borrow_mut().reset() + self.0.lock().unwrap().reset() } /// Remove [`PeerId`] from peer_ids. #[allow(clippy::trivially_copy_pass_by_ref)] pub fn remove_peer_id(&self, peer_id: &PeerId) { - self.0.lock().unwrap().borrow_mut().remove_peer_id(peer_id) + self.0.lock().unwrap().remove_peer_id(peer_id) } /// Remove all [`PeerId`]s related to this [`WebRtcPublishEndpoint`]. pub fn remove_peer_ids(&self, peer_ids: &[PeerId]) { - self.0 - .lock() - .unwrap() - .borrow_mut() - .remove_peer_ids(peer_ids) + self.0.lock().unwrap().remove_peer_ids(peer_ids) } } diff --git a/src/signalling/control/participant.rs b/src/signalling/control/participant.rs index f56cde99c..31e370214 100644 --- a/src/signalling/control/participant.rs +++ b/src/signalling/control/participant.rs @@ -1,7 +1,6 @@ //! [`Participant`] is member of [`Room`] with [`RpcConnection`]. use std::{ - cell::RefCell, convert::TryFrom as _, sync::{Arc, Mutex}, }; @@ -44,7 +43,7 @@ impl From for ParticipantsLoadError { /// [`Participant`] is member of [`Room`] with [`RpcConnection`]. #[derive(Debug)] -pub struct Participant(Mutex>); +pub struct Participant(Mutex); #[allow(clippy::module_name_repetitions)] #[derive(Debug)] @@ -70,13 +69,13 @@ impl Participant { /// To fill this [`Participant`], you need to call the [`Participant::load`] /// function. fn new(id: MemberId, credentials: String) -> Self { - Self(Mutex::new(RefCell::new(ParticipantInner { + Self(Mutex::new(ParticipantInner { id, publishers: HashMap::new(), receivers: HashMap::new(), credentials, ice_user: None, - }))) + })) } /// Notify [`Participant`] that some [`Peer`]s removed. @@ -99,7 +98,6 @@ impl Participant { self.0 .lock() .unwrap() - .borrow() .ice_user .as_ref() .map(IceUser::servers_list) @@ -107,27 +105,22 @@ impl Participant { /// Returns and set to `None` [`IceUser`] of this [`Participant`]. pub fn take_ice_user(&self) -> Option { - self.0.lock().unwrap().borrow_mut().ice_user.take() + self.0.lock().unwrap().ice_user.take() } /// Replace and return [`IceUser`] of this [`Participant`]. pub fn replace_ice_user(&self, new_ice_user: IceUser) -> Option { - self.0 - .lock() - .unwrap() - .borrow_mut() - .ice_user - .replace(new_ice_user) + self.0.lock().unwrap().ice_user.replace(new_ice_user) } /// Returns [`MemberId`] of this [`Participant`]. pub fn id(&self) -> MemberId { - self.0.lock().unwrap().borrow().id.clone() + self.0.lock().unwrap().id.clone() } /// Returns credentials of this [`Participant`]. pub fn credentials(&self) -> String { - self.0.lock().unwrap().borrow().credentials.clone() + self.0.lock().unwrap().credentials.clone() } /// Creates all empty [`Participant`] from [`RoomSpec`] and then @@ -161,12 +154,12 @@ impl Participant { pub fn publishers( &self, ) -> HashMap> { - self.0.lock().unwrap().borrow().publishers.clone() + self.0.lock().unwrap().publishers.clone() } /// Returns all receivers of this [`Participant`]. pub fn receivers(&self) -> HashMap> { - self.0.lock().unwrap().borrow().receivers.clone() + self.0.lock().unwrap().receivers.clone() } /// Load all publishers and receivers of this [`Participant`]. @@ -287,12 +280,7 @@ impl Participant { id: EndpointId, endpoint: Arc, ) { - self.0 - .lock() - .unwrap() - .borrow_mut() - .receivers - .insert(id, endpoint); + self.0.lock().unwrap().receivers.insert(id, endpoint); } /// Insert publisher into this [`Participant`]. @@ -301,12 +289,7 @@ impl Participant { id: EndpointId, endpoint: Arc, ) { - self.0 - .lock() - .unwrap() - .borrow_mut() - .publishers - .insert(id, endpoint); + self.0.lock().unwrap().publishers.insert(id, endpoint); } /// Lookup [`WebRtcPublishEndpoint`] publisher by [`EndpointId`]. @@ -314,7 +297,7 @@ impl Participant { &self, id: &EndpointId, ) -> Option> { - self.0.lock().unwrap().borrow().publishers.get(id).cloned() + self.0.lock().unwrap().publishers.get(id).cloned() } /// Lookup [`WebRtcPlayEndpoint`] receiver by [`EndpointId`]. @@ -322,7 +305,7 @@ impl Participant { &self, id: &EndpointId, ) -> Option> { - self.0.lock().unwrap().borrow().receivers.get(id).cloned() + self.0.lock().unwrap().receivers.get(id).cloned() } } From d69f0ff4af533f69991ec9db44c86db829833dcf Mon Sep 17 00:00:00 2001 From: alexlapa Date: Fri, 14 Jun 2019 15:29:03 +0300 Subject: [PATCH 148/735] add todos --- src/signalling/control/endpoint.rs | 2 ++ tests/signalling.rs | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/signalling/control/endpoint.rs b/src/signalling/control/endpoint.rs index e1fe433bb..703c4ed63 100644 --- a/src/signalling/control/endpoint.rs +++ b/src/signalling/control/endpoint.rs @@ -140,6 +140,8 @@ struct WebRtcPublishEndpointInner { /// Owner [`Participant`] of this [`WebRtcPublishEndpoint`]. owner: Weak, + // TODO: some doc that explains why we will need this field + /// All [`PeerId`]s created for this [`WebRtcPublishEndpoint`]. peer_ids: HashSet, } diff --git a/tests/signalling.rs b/tests/signalling.rs index db4e2af78..25cb98e83 100644 --- a/tests/signalling.rs +++ b/tests/signalling.rs @@ -1,5 +1,7 @@ //! Signalling API e2e tests. +// TODO: dockerize app, run tests on single instance, remove e2e_tests feature, run tests with redis up, extend tests with ice servers check + mod utils; use std::{cell::Cell, rc::Rc, time::Duration}; From 8b6d296a5cff58462dae412fe5dfd32392a65e7d Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 14 Jun 2019 19:36:17 +0300 Subject: [PATCH 149/735] Add dockerized medea and testing on single instance --- .dockerignore | 1 + .env | 5 ++ Cargo.toml | 3 - Dockerfile | 51 ++++++++++++ Makefile | 66 +++++++++++++-- ...r-compose.yml => docker-compose.coturn.yml | 0 docker-compose.medea.yml | 17 ++++ src/lib.rs | 3 - tests/e2e/main.rs | 1 + tests/{ => e2e}/signalling.rs | 11 +-- tests/utils.rs | 81 ------------------- 11 files changed, 139 insertions(+), 100 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile rename docker-compose.yml => docker-compose.coturn.yml (100%) create mode 100644 docker-compose.medea.yml create mode 100644 tests/e2e/main.rs rename tests/{ => e2e}/signalling.rs (97%) delete mode 100644 tests/utils.rs diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..eb5a316cb --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +target diff --git a/.env b/.env index 5dbd0f089..41c2c44d5 100644 --- a/.env +++ b/.env @@ -2,3 +2,8 @@ RUST_LOG=debug MEDEA_CONF=config.toml COMPOSE_PROJECT_NAME=medea +COMPOSE_IMAGE_VER=0.0.1-dev +COMPOSE_IMAGE_NAME=medea + +MEDEA_SERVER_BIND_PORT=8080 +MEDEA_SERVER_STATIC_SPECS_PATH=./specs diff --git a/Cargo.toml b/Cargo.toml index 60a60f32c..788e39985 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,9 +19,6 @@ members = [ [profile.release] lto = "thin" -[features] -e2e_test = [] - [dependencies] actix = "0.7" actix-web = "0.7" diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..01424d02f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,51 @@ +# +# Stage 'dist' creates project distribution. +# + +# https://hub.docker.com/_/rust +ARG rust_ver=latest +FROM rust:${rust_ver} AS dist +ARG rustc_mode=release +ARG rustc_opts=--release +ARG cargo_home=/usr/local/cargo + +# Create the user and group files that will be used in the running container to +# run the process as an unprivileged user. +RUN mkdir -p /out/etc/ \ + && echo 'nobody:x:65534:65534:nobody:/:' > /out/etc/passwd \ + && echo 'nobody:x:65534:' > /out/etc/group + +COPY / /app/ + +# Build project distribution. +RUN cd /app \ + # Compile project. + && CARGO_HOME="${cargo_home}" \ + # TODO: use --out-dir once stabilized + # TODO: use --offline once stabilized + # TODO: https://github.com/rust-lang/cargo/issues/5655 + cargo build --bin=medea ${rustc_opts} \ + # Prepare the binary and all dependent dynamic libraries. + && cp /app/target/${rustc_mode}/medea /out/medea \ + && ldd /out/medea \ + | awk 'BEGIN{ORS=" "}$1~/^\//{print $1}$3~/^\//{print $3}' \ + | sed 's/,$/\n/' \ + | tr ' ' "\n" \ + | xargs -I '{}' cp -fL --parents '{}' /out/ + + + + +# +# Stage 'runtime' creates final Docker image to use in runtime. +# + +# https://hub.docker.com/_/scratch +FROM scratch AS runtime + +COPY --from=dist /out/ / + +USER nobody:nobody + +ENTRYPOINT ["/medea"] + diff --git a/Makefile b/Makefile index 4b88891db..006a06768 100644 --- a/Makefile +++ b/Makefile @@ -136,7 +136,7 @@ ifeq ($(test-unit-crate),@all) @make test.unit crate=jason else ifeq ($(test-unit-crate),medea) - cargo test -p medea --features "e2e_test" + cargo test --lib --bin medea else ifeq ($(test-unit-crate),jason) wasm-pack test --headless --firefox jason @@ -146,6 +146,31 @@ endif endif +# Run Rust e2e tests of project. +# If logs set to "yes" then medea print all logs to stdout. +# +# Usage: +# make test.e2e [dockerized=(yes|no)] [logs=(yes|no)] + +medea-env-dockerized = MEDEA_SERVER_BIND_PORT=8081 \ + MEDEA_SERVER_STATIC_SPECS_PATH=./tests/specs + +medea-env-debug = MEDEA_SERVER.BIND_PORT=8081 \ + MEDEA_SERVER.STATIC_SPECS_PATH=./tests/specs + +test.e2e: up.coturn +ifeq ($(dockerized),yes) + make down.medea + env $(medea-env-dockerized) docker-compose -f docker-compose.medea.yml up -d + cargo test --test e2e && make down.medea +else + - killall medea + echo $(medea-env) + env $(medea-env-debug) $(if $(call eq,$(logs),yes),,RUST_LOG=warn) cargo run & + sleep 2 && cargo test --test e2e && killall medea +endif + + #################### @@ -157,8 +182,8 @@ endif # Usage: # make up.coturn -up.coturn: - docker-compose up +up.coturn: down.coturn + docker-compose -f docker-compose.coturn.yml up -d # Run Jason E2E demo in development mode. @@ -175,8 +200,38 @@ up.jason: # Usage: # make up.medea -up.medea: +up.medea: up.coturn +ifeq ($(dockerized),yes) + @make down.medea + docker-compose -f docker-compose.medea.yml up + @make down.coturn +else cargo run --bin medea +endif + + + + +##################### +# Stopping commands # +##################### + +# Stop dockerized medea. +# +# Usage: +# make down.medea + +down.medea: + docker-compose -f docker-compose.medea.yml down + + +# Stop dockerized coturn. +# +# Usage: +# make down.coturn + +down.coturn: + docker-compose -f docker-compose.coturn.yml down -t 1 @@ -189,5 +244,6 @@ up.medea: docs docs.rust \ test test.unit \ up up.coturn up.jason up.medea \ - yarn + yarn down.coturn down.medea \ + test.e2e diff --git a/docker-compose.yml b/docker-compose.coturn.yml similarity index 100% rename from docker-compose.yml rename to docker-compose.coturn.yml diff --git a/docker-compose.medea.yml b/docker-compose.medea.yml new file mode 100644 index 000000000..47bccc8e6 --- /dev/null +++ b/docker-compose.medea.yml @@ -0,0 +1,17 @@ +version: "2" + +services: + medea: + container_name: ${COMPOSE_PROJECT_NAME}-backend + image: ${COMPOSE_IMAGE_NAME}:${COMPOSE_IMAGE_VER} + build: . + ports: + - "${MEDEA_SERVER_BIND_PORT}:${MEDEA_SERVER_BIND_PORT}" + volumes: + - ${MEDEA_SERVER_STATIC_SPECS_PATH}:/specs + - ./config.toml:/config.toml + network_mode: "host" + environment: + RUST_LOG: "debug" + MEDEA_CONF: "config.toml" + MEDEA_SERVER.BIND_PORT: ${MEDEA_SERVER_BIND_PORT} diff --git a/src/lib.rs b/src/lib.rs index f9c6f8c1a..07d093fab 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -75,9 +75,6 @@ pub fn start_static_rooms( )); } - #[cfg(feature = "e2e_test")] - let turn_auth_service = service::test::new_turn_auth_service_mock(); - #[cfg(not(feature = "e2e_test"))] let turn_auth_service = service::new_turn_auth_service(config) .expect("Unable to start turn service"); diff --git a/tests/e2e/main.rs b/tests/e2e/main.rs new file mode 100644 index 000000000..406a0fb40 --- /dev/null +++ b/tests/e2e/main.rs @@ -0,0 +1 @@ +mod signalling; diff --git a/tests/signalling.rs b/tests/e2e/signalling.rs similarity index 97% rename from tests/signalling.rs rename to tests/e2e/signalling.rs index 25cb98e83..ab25d61e8 100644 --- a/tests/signalling.rs +++ b/tests/e2e/signalling.rs @@ -2,8 +2,6 @@ // TODO: dockerize app, run tests on single instance, remove e2e_tests feature, run tests with redis up, extend tests with ice servers check -mod utils; - use std::{cell::Cell, rc::Rc, time::Duration}; use actix::{ @@ -165,9 +163,7 @@ impl StreamHandler for TestMember { #[test] fn pub_sub_video_call() { let test_name = "pub_sub_video_call"; - let bind_port = utils::run_test_server(test_name); - let base_url = - format!("ws://localhost:{}/ws/pub-sub-video-call", bind_port); + let base_url = "ws://localhost:8081/ws/pub-sub-video-call"; let sys = System::new(test_name); @@ -258,9 +254,8 @@ fn pub_sub_video_call() { #[test] fn three_members_p2p_video_call() { let test_name = "three_members_p2p_video_call"; - let bind_port = utils::run_test_server(test_name); - let base_url = - format!("ws://localhost:{}/ws/three-members-conference", bind_port); + + let base_url = "ws://localhost:8081/ws/three-members-conference"; let sys = System::new(test_name); diff --git a/tests/utils.rs b/tests/utils.rs deleted file mode 100644 index 0868cd16c..000000000 --- a/tests/utils.rs +++ /dev/null @@ -1,81 +0,0 @@ -//! Utils useful for e2e testing of medea. - -use std::{ - cell::Cell, - sync::{ - atomic::{AtomicUsize, Ordering}, - Arc, Mutex, - }, -}; - -use actix::System; -use medea::{ - api::client::server, conf::Conf, conf::Server, - signalling::room_repo::RoomsRepository, start_static_rooms, -}; - -/// Test ports counter. Used for dealing with async testing. -/// Enumerating start from 49152 because -/// based on [Registered by IANA ports][1] this is the last reserved port. -/// 16384 ought to be enough for anybody. -/// -/// Use `get_port_for_test()` instead of accessing this var directly. -/// -/// [1]: https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers -static LAST_TEST_PORT: AtomicUsize = AtomicUsize::new(49152); - -/// Use it for getting port for testing. -pub fn get_port_for_test() -> u16 { - LAST_TEST_PORT.fetch_add(1, Ordering::Relaxed) as u16 -} - -/// Run medea server. This function lock main thread until server is up. -/// Server starts in different thread and `join`'ed with main thread. -/// When test is done, server will be destroyed. -/// -/// Server load all specs from `tests/specs`. -/// -/// Provide `test_name` same as your test function's name. This will -/// help you when server panic in some test case. -pub fn run_test_server(test_name: &'static str) -> u16 { - let bind_port = get_port_for_test(); - - let is_server_starting = Arc::new(Mutex::new(Cell::new(true))); - let is_server_starting_ref = Arc::clone(&is_server_starting); - let builder = std::thread::Builder::new().name(test_name.to_string()); - - let server_thread = builder - .spawn(move || { - let _ = System::new(format!("test-medea-server-{}", test_name)); - - let config = Conf { - server: Server { - static_specs_path: Some("tests/specs".to_string()), - bind_port, - ..Default::default() - }, - ..Default::default() - }; - - match start_static_rooms(&config) { - Ok(r) => { - let room_repo = RoomsRepository::new(r); - server::run(room_repo, config); - } - Err(e) => { - panic!("Server not started because of error: '{}'", e); - } - }; - let is_server_starting_guard = - is_server_starting_ref.lock().unwrap(); - is_server_starting_guard.set(false); - }) - .unwrap(); - - // Wait until server is up - while is_server_starting.lock().unwrap().get() {} - - server_thread.join().unwrap(); - - bind_port -} From 4886c84e0ebd3413b999369075b9711b8eb0dd39 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 14 Jun 2019 19:42:37 +0300 Subject: [PATCH 150/735] Add stun/turn address check --- tests/e2e/signalling.rs | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/tests/e2e/signalling.rs b/tests/e2e/signalling.rs index ab25d61e8..4bc98fe37 100644 --- a/tests/e2e/signalling.rs +++ b/tests/e2e/signalling.rs @@ -1,6 +1,7 @@ //! Signalling API e2e tests. -// TODO: dockerize app, run tests on single instance, remove e2e_tests feature, run tests with redis up, extend tests with ice servers check +// TODO: dockerize app, run tests on single instance, remove e2e_tests feature, +// run tests with redis up, extend tests with ice servers check use std::{cell::Cell, rc::Rc, time::Duration}; @@ -193,6 +194,18 @@ fn pub_sub_video_call() { } = &events[0] { assert_eq!(ice_servers.len(), 2); + assert_eq!( + ice_servers[0].urls[0], + "stun:127.0.0.1:3478".to_string() + ); + assert_eq!( + ice_servers[1].urls[0], + "turn:127.0.0.1:3478".to_string() + ); + assert_eq!( + ice_servers[1].urls[1], + "turn:127.0.0.1:3478?transport=tcp".to_string() + ); if let Some(_) = sdp_offer { is_caller = false; @@ -275,6 +288,19 @@ fn three_members_p2p_video_call() { match event { Event::PeerCreated { ice_servers, .. } => { assert_eq!(ice_servers.len(), 2); + assert_eq!( + ice_servers[0].urls[0], + "stun:127.0.0.1:3478".to_string() + ); + assert_eq!( + ice_servers[1].urls[0], + "turn:127.0.0.1:3478".to_string() + ); + assert_eq!( + ice_servers[1].urls[1], + "turn:127.0.0.1:3478?transport=tcp".to_string() + ); + peer_created_count += 1; } Event::IceCandidateDiscovered { .. } => { From ced1681d6a17fc9cfaf0bce5ff8d2f85492b14e4 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 14 Jun 2019 19:49:39 +0300 Subject: [PATCH 151/735] Fix dyn traits --- jason/src/utils/event_listener.rs | 2 +- src/signalling/control/endpoint.rs | 1 - src/turn/service.rs | 4 ++-- tests/e2e/signalling.rs | 4 ++-- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/jason/src/utils/event_listener.rs b/jason/src/utils/event_listener.rs index 70299513b..6d357fcc9 100644 --- a/jason/src/utils/event_listener.rs +++ b/jason/src/utils/event_listener.rs @@ -51,7 +51,7 @@ impl, A: FromWasmAbi + 'static> where F: FnOnce(A) + 'static, { - let closure: Closure = Closure::once(closure); + let closure: Closure = Closure::once(closure); target.add_event_listener_with_callback( event_name, diff --git a/src/signalling/control/endpoint.rs b/src/signalling/control/endpoint.rs index 703c4ed63..aba398012 100644 --- a/src/signalling/control/endpoint.rs +++ b/src/signalling/control/endpoint.rs @@ -141,7 +141,6 @@ struct WebRtcPublishEndpointInner { owner: Weak, // TODO: some doc that explains why we will need this field - /// All [`PeerId`]s created for this [`WebRtcPublishEndpoint`]. peer_ids: HashSet, } diff --git a/src/turn/service.rs b/src/turn/service.rs index 8293fdde9..4d0b56457 100644 --- a/src/turn/service.rs +++ b/src/turn/service.rs @@ -46,7 +46,7 @@ impl TurnAuthService for Addr { member_id: MemberId, room_id: RoomId, policy: UnreachablePolicy, - ) -> Box> { + ) -> Box> { Box::new( self.send(CreateIceUser { member_id, @@ -69,7 +69,7 @@ impl TurnAuthService for Addr { fn delete( &self, users: Vec, - ) -> Box> { + ) -> Box> { // leave only non static users let users: Vec = users.into_iter().filter(|u| !u.is_static()).collect(); diff --git a/tests/e2e/signalling.rs b/tests/e2e/signalling.rs index 4bc98fe37..fb0653904 100644 --- a/tests/e2e/signalling.rs +++ b/tests/e2e/signalling.rs @@ -31,7 +31,7 @@ struct TestMember { /// Function which will be called at every received by this [`TestMember`] /// [`Event`]. - test_fn: Box)>, + test_fn: Box)>, } impl TestMember { @@ -56,7 +56,7 @@ impl TestMember { /// received from server. pub fn start( uri: &str, - test_fn: Box)>, + test_fn: Box)>, ) { Arbiter::spawn( Client::new(uri) From b7e1ca90993fa341d4e955fa57769c0498c23c4c Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 14 Jun 2019 19:50:01 +0300 Subject: [PATCH 152/735] Fix killing medea after failed tests --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 006a06768..0b263967c 100644 --- a/Makefile +++ b/Makefile @@ -162,12 +162,12 @@ test.e2e: up.coturn ifeq ($(dockerized),yes) make down.medea env $(medea-env-dockerized) docker-compose -f docker-compose.medea.yml up -d - cargo test --test e2e && make down.medea + - cargo test --test e2e && make down.medea else - killall medea echo $(medea-env) env $(medea-env-debug) $(if $(call eq,$(logs),yes),,RUST_LOG=warn) cargo run & - sleep 2 && cargo test --test e2e && killall medea + - sleep 2 && cargo test --test e2e && killall medea endif From 7c954001fa3bdf16c0fda8f861514a26730335e8 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 14 Jun 2019 19:51:53 +0300 Subject: [PATCH 153/735] Remove resolved TODOs --- tests/e2e/signalling.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/e2e/signalling.rs b/tests/e2e/signalling.rs index fb0653904..d617ed953 100644 --- a/tests/e2e/signalling.rs +++ b/tests/e2e/signalling.rs @@ -1,8 +1,5 @@ //! Signalling API e2e tests. -// TODO: dockerize app, run tests on single instance, remove e2e_tests feature, -// run tests with redis up, extend tests with ice servers check - use std::{cell::Cell, rc::Rc, time::Duration}; use actix::{ From 0fea62f0a1e18bcf4364136de038efc78a31208d Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 14 Jun 2019 20:31:29 +0300 Subject: [PATCH 154/735] Move specs into dev --- .env | 2 +- Makefile | 1 - config.toml | 2 +- {specs => dev/specs}/pub_sub_video_call.yml | 0 {specs => dev/specs}/three_members_conference.yml | 0 {specs => dev/specs}/video_call_1.yml | 0 6 files changed, 2 insertions(+), 3 deletions(-) rename {specs => dev/specs}/pub_sub_video_call.yml (100%) rename {specs => dev/specs}/three_members_conference.yml (100%) rename {specs => dev/specs}/video_call_1.yml (100%) diff --git a/.env b/.env index 41c2c44d5..efb4a35a3 100644 --- a/.env +++ b/.env @@ -6,4 +6,4 @@ COMPOSE_IMAGE_VER=0.0.1-dev COMPOSE_IMAGE_NAME=medea MEDEA_SERVER_BIND_PORT=8080 -MEDEA_SERVER_STATIC_SPECS_PATH=./specs +MEDEA_SERVER_STATIC_SPECS_PATH=./dev/specs diff --git a/Makefile b/Makefile index 0b263967c..e93bdac0a 100644 --- a/Makefile +++ b/Makefile @@ -165,7 +165,6 @@ ifeq ($(dockerized),yes) - cargo test --test e2e && make down.medea else - killall medea - echo $(medea-env) env $(medea-env-debug) $(if $(call eq,$(logs),yes),,RUST_LOG=warn) cargo run & - sleep 2 && cargo test --test e2e && killall medea endif diff --git a/config.toml b/config.toml index dcbf38af4..0442888d4 100644 --- a/config.toml +++ b/config.toml @@ -13,7 +13,7 @@ # # Default: # static_specs_path = None -static_specs_path = "specs" +static_specs_path = "dev/specs" diff --git a/specs/pub_sub_video_call.yml b/dev/specs/pub_sub_video_call.yml similarity index 100% rename from specs/pub_sub_video_call.yml rename to dev/specs/pub_sub_video_call.yml diff --git a/specs/three_members_conference.yml b/dev/specs/three_members_conference.yml similarity index 100% rename from specs/three_members_conference.yml rename to dev/specs/three_members_conference.yml diff --git a/specs/video_call_1.yml b/dev/specs/video_call_1.yml similarity index 100% rename from specs/video_call_1.yml rename to dev/specs/video_call_1.yml From 3c93ba1890d2a01149a55ab682315f5391e4c298 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 17 Jun 2019 12:18:19 +0300 Subject: [PATCH 155/735] Fix race condition bug --- src/api/control/room.rs | 7 +++++-- src/signalling/participants.rs | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/api/control/room.rs b/src/api/control/room.rs index 4a465faa1..5811804c4 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -1,7 +1,10 @@ //! Room definitions and implementations. -use std::fmt::Display; -use std::{convert::TryFrom, sync::Arc}; +use std::{ + fmt::Display, + convert::TryFrom, + sync::Arc +}; use hashbrown::HashMap; use serde::Deserialize; diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index c8a9ca711..6168d0559 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -204,7 +204,6 @@ impl ParticipantService { } Box::new(wrap_future(connection.close().then(|_| Ok(())))) } else { - self.connections.insert(member_id.clone(), con); Box::new( wrap_future(self.turn.create( member_id.clone(), @@ -220,6 +219,8 @@ impl ParticipantService { room.participants.get_member_by_id(&member_id) { member.replace_ice_user(ice); + // TODO: Maybe create function for this? + room.participants.connections.insert(member_id.clone(), con); }; wrap_future(future::ok(())) }, From 484197ff255a53ab986531e2e0b14b3f19776c39 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 17 Jun 2019 13:30:09 +0300 Subject: [PATCH 156/735] Improve e2e testing --- Makefile | 67 +++++++++++++++++++++++++--------- docker-compose.medea.yml | 5 ++- src/api/control/room.rs | 6 +-- src/signalling/participants.rs | 11 +++++- src/turn/service.rs | 4 +- 5 files changed, 66 insertions(+), 27 deletions(-) diff --git a/Makefile b/Makefile index e93bdac0a..c7258cc10 100644 --- a/Makefile +++ b/Makefile @@ -41,7 +41,7 @@ up: $(MAKE) -j3 up.coturn up.jason up.medea -test: test.unit +test: test.unit test.e2e @@ -149,24 +149,40 @@ endif # Run Rust e2e tests of project. # If logs set to "yes" then medea print all logs to stdout. # +# Defaults: +# dockerized=yes logs=no +# # Usage: # make test.e2e [dockerized=(yes|no)] [logs=(yes|no)] medea-env-dockerized = MEDEA_SERVER_BIND_PORT=8081 \ - MEDEA_SERVER_STATIC_SPECS_PATH=./tests/specs + $(if $(call eq,$(logs),yes),,RUST_LOG=warn) \ + MEDEA_SERVER_STATIC_SPECS_PATH=tests/specs -medea-env-debug = MEDEA_SERVER.BIND_PORT=8081 \ - MEDEA_SERVER.STATIC_SPECS_PATH=./tests/specs +medea-env-debug = RUST_BACKTRACE=1 \ + MEDEA_SERVER.BIND_PORT=8081 \ + MEDEA_SERVER.STATIC_SPECS_PATH=./tests/specs \ + $(if $(call eq,$(logs),yes),,RUST_LOG=warn) test.e2e: up.coturn -ifeq ($(dockerized),yes) - make down.medea - env $(medea-env-dockerized) docker-compose -f docker-compose.medea.yml up -d - - cargo test --test e2e && make down.medea -else - - killall medea +ifeq ($(dockerized),no) + @make down.medea dockerized=yes + @make down.medea dockerized=no + + cargo build env $(medea-env-debug) $(if $(call eq,$(logs),yes),,RUST_LOG=warn) cargo run & - - sleep 2 && cargo test --test e2e && killall medea + sleep 1 + - cargo test --test e2e + + @make down.medea +else + @make down.medea dockerized=yes + @make down.medea dockerized=no + + env $(medea-env-dockerized) docker-compose -f docker-compose.medea.yml up -d --build + docker-compose -f docker-compose.medea.yml logs & + - cargo test --test e2e + - @make down.medea dockerized=yes endif @@ -196,8 +212,11 @@ up.jason: # Run Medea media server in development mode. # +# Defaults: +# dockerized=no +# # Usage: -# make up.medea +# make up.medea [dockerized=(yes|no)] up.medea: up.coturn ifeq ($(dockerized),yes) @@ -215,13 +234,28 @@ endif # Stopping commands # ##################### -# Stop dockerized medea. +# Stop all related to Medea services. + +down: + @make down.medea dockerized=yes + @make down.medea dockerized=no + @make down.coturn + + +# Stop Medea media server. +# +# Defaults: +# dockerized=no # # Usage: -# make down.medea +# make down.medea [dockerized=(yes|no)] down.medea: +ifeq ($(dockerized),yes) docker-compose -f docker-compose.medea.yml down +else + - killall medea +endif # Stop dockerized coturn. @@ -241,8 +275,7 @@ down.coturn: .PHONY: cargo cargo.fmt cargo.lint \ docs docs.rust \ - test test.unit \ + test.e2e test test.unit \ up up.coturn up.jason up.medea \ - yarn down.coturn down.medea \ - test.e2e + yarn down down.coturn down.medea diff --git a/docker-compose.medea.yml b/docker-compose.medea.yml index 47bccc8e6..435387df6 100644 --- a/docker-compose.medea.yml +++ b/docker-compose.medea.yml @@ -8,10 +8,11 @@ services: ports: - "${MEDEA_SERVER_BIND_PORT}:${MEDEA_SERVER_BIND_PORT}" volumes: - - ${MEDEA_SERVER_STATIC_SPECS_PATH}:/specs + - ./${MEDEA_SERVER_STATIC_SPECS_PATH}:/${MEDEA_SERVER_STATIC_SPECS_PATH} - ./config.toml:/config.toml network_mode: "host" environment: - RUST_LOG: "debug" + RUST_LOG: ${RUST_LOG} MEDEA_CONF: "config.toml" MEDEA_SERVER.BIND_PORT: ${MEDEA_SERVER_BIND_PORT} + MEDEA_SERVER.STATIC_SPECS_PATH: ${MEDEA_SERVER_STATIC_SPECS_PATH} diff --git a/src/api/control/room.rs b/src/api/control/room.rs index 5811804c4..be1d552ab 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -1,10 +1,6 @@ //! Room definitions and implementations. -use std::{ - fmt::Display, - convert::TryFrom, - sync::Arc -}; +use std::{convert::TryFrom, fmt::Display, sync::Arc}; use hashbrown::HashMap; use serde::Deserialize; diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 6168d0559..b5a80882e 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -220,7 +220,8 @@ impl ParticipantService { { member.replace_ice_user(ice); // TODO: Maybe create function for this? - room.participants.connections.insert(member_id.clone(), con); + room.participants + .insert_connections(member_id.clone(), con); }; wrap_future(future::ok(())) }, @@ -229,6 +230,14 @@ impl ParticipantService { } } + fn insert_connections( + &mut self, + member_id: MemberId, + conn: Box, + ) { + self.connections.insert(member_id, conn); + } + /// If [`ClosedReason::Closed`], then removes [`RpcConnection`] associated /// with specified user [`Participant`] from the storage and closes the /// room. If [`ClosedReason::Lost`], then creates delayed task that diff --git a/src/turn/service.rs b/src/turn/service.rs index 4d0b56457..09458f186 100644 --- a/src/turn/service.rs +++ b/src/turn/service.rs @@ -293,7 +293,7 @@ pub mod test { _: MemberId, _: RoomId, _: UnreachablePolicy, - ) -> Box> { + ) -> Box> { Box::new(future::ok(IceUser::new( "5.5.5.5:1234".parse().unwrap(), String::from("username"), @@ -304,7 +304,7 @@ pub mod test { fn delete( &self, _: Vec, - ) -> Box> { + ) -> Box> { Box::new(future::ok(())) } } From f16c1132ee08410d56bf6b2715dbb58fda042d56 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 17 Jun 2019 13:39:47 +0300 Subject: [PATCH 157/735] Add logs arg to up.coturn --- Makefile | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index c7258cc10..80d2a9cba 100644 --- a/Makefile +++ b/Makefile @@ -194,11 +194,17 @@ endif # Run Coturn STUN/TURN server. # +# Defaults: +# logs=no +# # Usage: -# make up.coturn +# make up.coturn [logs=(yes|no)] -up.coturn: down.coturn +up.coturn: docker-compose -f docker-compose.coturn.yml up -d +ifeq ($(logs),yes) + docker-compose -f docker-compose.coturn.yml logs & +endif # Run Jason E2E demo in development mode. From 06652d67d1a7d70e1febda5c17fae280f4c494c1 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 17 Jun 2019 13:51:51 +0300 Subject: [PATCH 158/735] Add docs --- src/signalling/control/endpoint.rs | 13 +++++++++++-- src/signalling/participants.rs | 6 +++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/signalling/control/endpoint.rs b/src/signalling/control/endpoint.rs index aba398012..bd418c946 100644 --- a/src/signalling/control/endpoint.rs +++ b/src/signalling/control/endpoint.rs @@ -38,6 +38,12 @@ struct WebRtcPlayEndpointInner { owner: Weak, /// [`PeerId`] of [`Peer`] created for this [`WebRtcPlayEndpoint`]. + /// + /// Currently this field used for detecting status of this + /// [`WebRtcPlayEndpoint`] connection. + /// + /// In future this may be used for removing [`WebRtcPlayEndpoint`] + /// and related peer. peer_id: Option, } @@ -140,8 +146,11 @@ struct WebRtcPublishEndpointInner { /// Owner [`Participant`] of this [`WebRtcPublishEndpoint`]. owner: Weak, - // TODO: some doc that explains why we will need this field - /// All [`PeerId`]s created for this [`WebRtcPublishEndpoint`]. + /// [`PeerId`] of all [`Peer`]s created for this [`WebRtcPublishEndpoint`]. + /// + /// Currently this field used for nothing but in future this may be used + /// while removing [`WebRtcPublishEndpoint`] for removing all [`Peer`]s of + /// this [`WebRtcPublishEndpoint`]. peer_ids: HashSet, } diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index b5a80882e..20be75778 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -219,9 +219,8 @@ impl ParticipantService { room.participants.get_member_by_id(&member_id) { member.replace_ice_user(ice); - // TODO: Maybe create function for this? room.participants - .insert_connections(member_id.clone(), con); + .insert_connection(member_id.clone(), con); }; wrap_future(future::ok(())) }, @@ -230,7 +229,8 @@ impl ParticipantService { } } - fn insert_connections( + /// Insert new [`RpcConnection`] into this [`ParticipantService`]. + fn insert_connection( &mut self, member_id: MemberId, conn: Box, From 183cfd8ee3b6a1e392a1d206226cc4b12fb5544f Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 17 Jun 2019 15:20:25 +0300 Subject: [PATCH 159/735] Use Drop fix memory leak for endpoints --- src/media/peer.rs | 13 +-- src/signalling/control/endpoint.rs | 119 ++++++++++++++++++++++---- src/signalling/control/participant.rs | 93 +++++++++++--------- src/signalling/room.rs | 36 ++------ 4 files changed, 161 insertions(+), 100 deletions(-) diff --git a/src/media/peer.rs b/src/media/peer.rs index fb5fc1b73..da1dd0452 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -261,7 +261,7 @@ impl Peer { &mut self, partner_peer: &mut Peer, tracks_count: &mut Counter, - publish_endpoints: HashMap>, + publish_endpoints: HashMap, ) { let partner_id = self.partner_member_id(); let self_id = self.id(); @@ -272,17 +272,6 @@ impl Peer { e.add_peer_id(self_id); e.receivers() .into_iter() - .filter_map(|e| { - let upgraded_play = e.upgrade(); - if upgraded_play.is_none() { - warn!( - "Empty weak pointer of publisher's play \ - endpoint. {:?}.", - e - ); - } - upgraded_play - }) .filter_map(|p| { let owner = p.owner().upgrade(); if owner.is_none() { diff --git a/src/signalling/control/endpoint.rs b/src/signalling/control/endpoint.rs index bd418c946..12bdd36d2 100644 --- a/src/signalling/control/endpoint.rs +++ b/src/signalling/control/endpoint.rs @@ -2,13 +2,14 @@ use std::{ fmt::Display, - sync::{Mutex, Weak}, + sync::{Arc, Mutex, Weak}, }; use hashbrown::HashSet; use crate::{ api::control::endpoint::{P2pMode, SrcUri}, + log::prelude::*, media::PeerId, }; @@ -26,13 +27,24 @@ impl Display for Id { #[derive(Debug, Clone)] struct WebRtcPlayEndpointInner { + /// ID of this [`WebRtcPlayEndpoint`]. + id: Id, + /// Source URI of [`WebRtcPublishEndpoint`] from which this /// [`WebRtcPlayEndpoint`] receive data. src: SrcUri, /// Publisher [`WebRtcPublishEndpoint`] from which this /// [`WebRtcPlayEndpoint`] receive data. - publisher: Weak, + /// + /// __Important!__ + /// + /// As you can see, a __memory leak may occur here__... But it should not + /// occur beyond the implementation of the [`Drop`] for this + /// [`WebRtcPlayEndpoint`]. Please be careful and process all future + /// circular references in the implementation of the [`Drop`] for this + /// structure. + publisher: WebRtcPublishEndpoint, /// Owner [`Participant`] of this [`WebRtcPlayEndpoint`]. owner: Weak, @@ -56,7 +68,7 @@ impl WebRtcPlayEndpointInner { Weak::clone(&self.owner) } - fn publisher(&self) -> Weak { + fn publisher(&self) -> WebRtcPublishEndpoint { self.publisher.clone() } @@ -78,23 +90,32 @@ impl WebRtcPlayEndpointInner { } /// Signalling representation of `WebRtcPlayEndpoint`. +/// +/// __Important!__ +/// +/// Please be careful and process all future circular references in the +/// implementation of the [`Drop`] for this structure, otherwise __memory leak +/// may occur here__. #[allow(clippy::module_name_repetitions)] -#[derive(Debug)] -pub struct WebRtcPlayEndpoint(Mutex); +#[derive(Debug, Clone)] +#[doc(inline)] +pub struct WebRtcPlayEndpoint(Arc>); impl WebRtcPlayEndpoint { /// Create new [`WebRtcPlayEndpoint`]. pub fn new( src: SrcUri, - publisher: Weak, + publisher: WebRtcPublishEndpoint, owner: Weak, + id: Id, ) -> Self { - Self(Mutex::new(WebRtcPlayEndpointInner { + Self(Arc::new(Mutex::new(WebRtcPlayEndpointInner { src, publisher, owner, peer_id: None, - })) + id, + }))) } /// Returns [`SrcUri`] of this [`WebRtcPlayEndpoint`]. @@ -108,7 +129,7 @@ impl WebRtcPlayEndpoint { } /// Returns publisher's [`WebRtcPublishEndpoint`]. - pub fn publisher(&self) -> Weak { + pub fn publisher(&self) -> WebRtcPublishEndpoint { self.0.lock().unwrap().publisher() } @@ -133,15 +154,38 @@ impl WebRtcPlayEndpoint { pub fn reset(&self) { self.0.lock().unwrap().reset() } + + pub fn id(&self) -> Id { + self.0.lock().unwrap().id.clone() + } +} + +impl Drop for WebRtcPlayEndpoint { + fn drop(&mut self) { + if Arc::strong_count(&self.0) == 1 { + self.publisher().remove_receiver(&self.id()); + } + } } #[derive(Debug, Clone)] struct WebRtcPublishEndpointInner { + /// ID of this [`WebRtcPublishEndpoint`]. + id: Id, + /// P2P connection mode for this [`WebRtcPublishEndpoint`]. p2p: P2pMode, /// All receivers of this [`WebRtcPublishEndpoint`]. - receivers: Vec>, + /// + /// __Important!__ + /// + /// As you can see, a __memory leak may occur here__... But it should not + /// occur beyond the implementation of the [`Drop`] for this + /// [`WebRtcPublishEndpoint`]. Please be careful and process all future + /// circular references in the implementation of the [`Drop`] for this + /// structure. + receivers: Vec, /// Owner [`Participant`] of this [`WebRtcPublishEndpoint`]. owner: Weak, @@ -155,11 +199,11 @@ struct WebRtcPublishEndpointInner { } impl WebRtcPublishEndpointInner { - fn add_receiver(&mut self, receiver: Weak) { + fn add_receiver(&mut self, receiver: WebRtcPlayEndpoint) { self.receivers.push(receiver); } - fn receivers(&self) -> Vec> { + fn receivers(&self) -> Vec { self.receivers.clone() } @@ -192,32 +236,39 @@ impl WebRtcPublishEndpointInner { } /// Signalling representation of `WebRtcPublishEndpoint`. +/// +/// __Important!__ +/// +/// Please be careful and process all future circular references in the +/// implementation of the [`Drop`] for this structure. #[allow(clippy::module_name_repetitions)] -#[derive(Debug)] -pub struct WebRtcPublishEndpoint(Mutex); +#[derive(Debug, Clone)] +pub struct WebRtcPublishEndpoint(Arc>); impl WebRtcPublishEndpoint { /// Create new [`WebRtcPublishEndpoint`]. pub fn new( p2p: P2pMode, - receivers: Vec>, + receivers: Vec, owner: Weak, + id: Id, ) -> Self { - Self(Mutex::new(WebRtcPublishEndpointInner { + Self(Arc::new(Mutex::new(WebRtcPublishEndpointInner { p2p, receivers, owner, peer_ids: HashSet::new(), - })) + id, + }))) } /// Add receiver for this [`WebRtcPublishEndpoint`]. - pub fn add_receiver(&self, receiver: Weak) { + pub fn add_receiver(&self, receiver: WebRtcPlayEndpoint) { self.0.lock().unwrap().add_receiver(receiver) } /// Returns all receivers of this [`WebRtcPublishEndpoint`]. - pub fn receivers(&self) -> Vec> { + pub fn receivers(&self) -> Vec { self.0.lock().unwrap().receivers() } @@ -253,4 +304,34 @@ impl WebRtcPublishEndpoint { pub fn remove_peer_ids(&self, peer_ids: &[PeerId]) { self.0.lock().unwrap().remove_peer_ids(peer_ids) } + + /// Returns ID of this [`WebRtcPublishEndpoint`]. + pub fn id(&self) -> Id { + self.0.lock().unwrap().id.clone() + } + + /// Remove [`WebRtcPlayEndpoint`] with provided [`Id`] from receivers. + pub fn remove_receiver(&self, id: &Id) { + self.0.lock().unwrap().receivers.retain(|e| &e.id() == id); + } +} + +/// This is memory leak fix for [`WebRtcPublishEndpoint`]. +impl Drop for WebRtcPublishEndpoint { + fn drop(&mut self) { + if Arc::strong_count(&self.0) == self.receivers().len() { + let inner = self.0.lock().unwrap(); + for receiver in &inner.receivers { + if let Some(receiver_owner) = receiver.owner().upgrade() { + receiver_owner.remove_receiver(&receiver.id()); + } else { + error!( + "Receiver owner for {} WebRtcPublishEndpoint not \ + found.", + inner.id + ); + } + } + } + } } diff --git a/src/signalling/control/participant.rs b/src/signalling/control/participant.rs index 31e370214..ae5f10e87 100644 --- a/src/signalling/control/participant.rs +++ b/src/signalling/control/participant.rs @@ -51,10 +51,10 @@ struct ParticipantInner { id: MemberId, /// All [`WebRtcPublishEndpoint`]s of this [`Participant`]. - publishers: HashMap>, + publishers: HashMap, /// All [`WebRtcPlayEndpoint`]s of this [`Participant`]. - receivers: HashMap>, + receivers: HashMap, /// Credentials for this [`Participant`]. credentials: String, @@ -103,6 +103,16 @@ impl Participant { .map(IceUser::servers_list) } + /// Remove publisher [`WebRtcPublishEndpoint`] from this [`Participant`]. + pub fn remove_publisher(&self, id: &EndpointId) { + self.0.lock().unwrap().publishers.remove(id); + } + + /// Remove receiver [`WebRtcPlayEndpoint`] from this [`Participant`]. + pub fn remove_receiver(&self, id: &EndpointId) { + self.0.lock().unwrap().receivers.remove(id); + } + /// Returns and set to `None` [`IceUser`] of this [`Participant`]. pub fn take_ice_user(&self) -> Option { self.0.lock().unwrap().ice_user.take() @@ -151,14 +161,12 @@ impl Participant { } /// Returns all publishers of this [`Participant`]. - pub fn publishers( - &self, - ) -> HashMap> { + pub fn publishers(&self) -> HashMap { self.0.lock().unwrap().publishers.clone() } /// Returns all receivers of this [`Participant`]. - pub fn receivers(&self) -> HashMap> { + pub fn receivers(&self) -> HashMap { self.0.lock().unwrap().receivers.clone() } @@ -214,42 +222,46 @@ impl Participant { if let Some(publisher) = publisher_participant.get_publisher_by_id( &EndpointId(spec_play_endpoint.src.endpoint_id.to_string()), ) { - let new_play_endpoint = Arc::new(WebRtcPlayEndpoint::new( + let new_play_endpoint_id = + EndpointId(spec_play_name.to_string()); + let new_play_endpoint = WebRtcPlayEndpoint::new( spec_play_endpoint.src.clone(), - Arc::downgrade(&publisher), + publisher.clone(), Arc::downgrade(&this_member), - )); + new_play_endpoint_id.clone(), + ); self.insert_receiver( EndpointId(spec_play_name.to_string()), - Arc::clone(&new_play_endpoint), + new_play_endpoint.clone(), ); - publisher.add_receiver(Arc::downgrade(&new_play_endpoint)); + publisher.add_receiver(new_play_endpoint.clone()); } else { - let new_publish = Arc::new(WebRtcPublishEndpoint::new( + let new_publish_endpoint_id = + EndpointId(spec_play_endpoint.src.endpoint_id.to_string()); + let new_publish = WebRtcPublishEndpoint::new( publisher_endpoint.p2p.clone(), Vec::new(), Arc::downgrade(&publisher_participant), - )); + new_publish_endpoint_id.clone(), + ); - let new_self_play = Arc::new(WebRtcPlayEndpoint::new( + let new_self_play_endpoint_id = + EndpointId(spec_play_name.to_string()); + let new_self_play = WebRtcPlayEndpoint::new( spec_play_endpoint.src.clone(), - Arc::downgrade(&new_publish), + new_publish.clone(), Arc::downgrade(&this_member), - )); + new_self_play_endpoint_id.clone(), + ); - new_publish.add_receiver(Arc::downgrade(&new_self_play)); + new_publish.add_receiver(new_self_play.clone()); - publisher_participant.insert_publisher( - EndpointId(spec_play_endpoint.src.endpoint_id.to_string()), - new_publish, - ); + publisher_participant + .insert_publisher(new_publish_endpoint_id, new_publish); - self.insert_receiver( - EndpointId(spec_play_name.to_string()), - new_self_play, - ); + self.insert_receiver(new_self_play_endpoint_id, new_self_play); } } @@ -260,12 +272,13 @@ impl Participant { let endpoint_id = EndpointId(name.clone()); if self.publishers().get(&endpoint_id).is_none() { self.insert_publisher( - endpoint_id, - Arc::new(WebRtcPublishEndpoint::new( + endpoint_id.clone(), + WebRtcPublishEndpoint::new( e.p2p.clone(), Vec::new(), Arc::downgrade(&this_member), - )), + endpoint_id, + ), ); } }, @@ -278,7 +291,7 @@ impl Participant { pub fn insert_receiver( &self, id: EndpointId, - endpoint: Arc, + endpoint: WebRtcPlayEndpoint, ) { self.0.lock().unwrap().receivers.insert(id, endpoint); } @@ -287,7 +300,7 @@ impl Participant { pub fn insert_publisher( &self, id: EndpointId, - endpoint: Arc, + endpoint: WebRtcPublishEndpoint, ) { self.0.lock().unwrap().publishers.insert(id, endpoint); } @@ -296,7 +309,7 @@ impl Participant { pub fn get_publisher_by_id( &self, id: &EndpointId, - ) -> Option> { + ) -> Option { self.0.lock().unwrap().publishers.get(id).cloned() } @@ -304,15 +317,13 @@ impl Participant { pub fn get_receiver_by_id( &self, id: &EndpointId, - ) -> Option> { + ) -> Option { self.0.lock().unwrap().receivers.get(id).cloned() } } #[cfg(test)] mod participant_loading_tests { - use std::sync::Arc; - use crate::api::control::Element; use super::*; @@ -373,16 +384,15 @@ mod participant_loading_tests { let is_caller_has_responder_in_receivers = caller_publish_endpoint .receivers() .into_iter() - .map(|p| p.upgrade().unwrap()) - .filter(|p| Arc::ptr_eq(p, &responder_play_endpoint)) + .filter(|p| p.id() == responder_play_endpoint.id()) .count() == 1; assert!(is_caller_has_responder_in_receivers); - assert!(Arc::ptr_eq( - &responder_play_endpoint.publisher().upgrade().unwrap(), - &caller_publish_endpoint - )); + assert_eq!( + responder_play_endpoint.publisher().id(), + caller_publish_endpoint.id() + ); let some_participant = store.get(&MemberId("some-member".to_string())).unwrap(); @@ -400,8 +410,7 @@ mod participant_loading_tests { some_participant_publisher .receivers() .into_iter() - .map(|p| p.upgrade().unwrap()) - .filter(|p| Arc::ptr_eq(p, &responder_play2_endpoint)) + .filter(|p| p.id() == responder_play2_endpoint.id()) .count() == 1; assert!(is_some_participant_has_responder_in_receivers); diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 3cfa19036..e2dbd8aac 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -340,17 +340,6 @@ impl Room { // Create all connected publish endpoints. for (_id, publish) in member.publishers() { for receiver in publish.receivers() { - let receiver = if let Some(receiver) = receiver.upgrade() { - receiver - } else { - error!( - "Empty weak pointer for publisher receiver. {:?}. \ - Closing room.", - publish - ); - ctx.notify(CloseRoom {}); - return; - }; let receiver_owner = if let Some(receiver_owner) = receiver.owner().upgrade() { receiver_owner @@ -380,28 +369,21 @@ impl Room { // Create all connected play's receivers peers. for (_id, play) in member.receivers() { - let plays_publisher_participant = - if let Some(plays_publisher) = play.publisher().upgrade() { - if let Some(owner) = plays_publisher.owner().upgrade() { - owner - } else { - error!( - "Empty weak pointer for play's publisher owner. \ - {:?}. Closing room.", - plays_publisher - ); - ctx.notify(CloseRoom {}); - return; - } + // TODO: remove block + let plays_publisher_participant = { + let plays_publisher = play.publisher(); + if let Some(owner) = plays_publisher.owner().upgrade() { + owner } else { error!( - "Empty weak pointer for play's publisher. {:?}. \ + "Empty weak pointer for play's publisher owner. {:?}. \ Closing room.", - play + plays_publisher ); ctx.notify(CloseRoom {}); return; - }; + } + }; if self .participants From b17a23d46735408af8a157633453af26a68b055d Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 17 Jun 2019 17:02:11 +0300 Subject: [PATCH 160/735] Fix drop --- src/signalling/control/endpoint.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/signalling/control/endpoint.rs b/src/signalling/control/endpoint.rs index 12bdd36d2..7c743179d 100644 --- a/src/signalling/control/endpoint.rs +++ b/src/signalling/control/endpoint.rs @@ -162,7 +162,7 @@ impl WebRtcPlayEndpoint { impl Drop for WebRtcPlayEndpoint { fn drop(&mut self) { - if Arc::strong_count(&self.0) == 1 { + if (Arc::strong_count(&self.0) - 1) == 1 { self.publisher().remove_receiver(&self.id()); } } @@ -319,7 +319,7 @@ impl WebRtcPublishEndpoint { /// This is memory leak fix for [`WebRtcPublishEndpoint`]. impl Drop for WebRtcPublishEndpoint { fn drop(&mut self) { - if Arc::strong_count(&self.0) == self.receivers().len() { + if (Arc::strong_count(&self.0) - 1) == self.receivers().len() { let inner = self.0.lock().unwrap(); for receiver in &inner.receivers { if let Some(receiver_owner) = receiver.owner().upgrade() { From 345cbfd8b0eba8af509a66e7a81be86ca8dafe0a Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 17 Jun 2019 18:59:26 +0300 Subject: [PATCH 161/735] Auto removing weaks when droping Arc --- src/signalling/control/endpoint.rs | 49 ++++++++++++++++++++ src/signalling/control/participant.rs | 67 +++++++++++++++------------ 2 files changed, 87 insertions(+), 29 deletions(-) diff --git a/src/signalling/control/endpoint.rs b/src/signalling/control/endpoint.rs index bd418c946..60157cf36 100644 --- a/src/signalling/control/endpoint.rs +++ b/src/signalling/control/endpoint.rs @@ -26,6 +26,9 @@ impl Display for Id { #[derive(Debug, Clone)] struct WebRtcPlayEndpointInner { + /// ID of this [`WebRtcPlayEndpoint`]. + id: Id, + /// Source URI of [`WebRtcPublishEndpoint`] from which this /// [`WebRtcPlayEndpoint`] receive data. src: SrcUri, @@ -77,6 +80,14 @@ impl WebRtcPlayEndpointInner { } } +impl Drop for WebRtcPlayEndpointInner { + fn drop(&mut self) { + if let Some(receiver_publisher) = self.publisher().upgrade() { + receiver_publisher.remove_empty_weaks_from_receivers(); + } + } +} + /// Signalling representation of `WebRtcPlayEndpoint`. #[allow(clippy::module_name_repetitions)] #[derive(Debug)] @@ -85,11 +96,13 @@ pub struct WebRtcPlayEndpoint(Mutex); impl WebRtcPlayEndpoint { /// Create new [`WebRtcPlayEndpoint`]. pub fn new( + id: Id, src: SrcUri, publisher: Weak, owner: Weak, ) -> Self { Self(Mutex::new(WebRtcPlayEndpointInner { + id, src, publisher, owner, @@ -133,10 +146,18 @@ impl WebRtcPlayEndpoint { pub fn reset(&self) { self.0.lock().unwrap().reset() } + + /// Returns ID of this [`WebRtcPlayEndpoint`]. + pub fn id(&self) -> Id { + self.0.lock().unwrap().id.clone() + } } #[derive(Debug, Clone)] struct WebRtcPublishEndpointInner { + /// ID of this [`WebRtcPublishEndpoint`]. + id: Id, + /// P2P connection mode for this [`WebRtcPublishEndpoint`]. p2p: P2pMode, @@ -154,6 +175,17 @@ struct WebRtcPublishEndpointInner { peer_ids: HashSet, } +impl Drop for WebRtcPublishEndpointInner { + fn drop(&mut self) { + for receiver in self.receivers().iter().filter_map(|r| Weak::upgrade(r)) + { + if let Some(receiver_owner) = receiver.owner().upgrade() { + receiver_owner.remove_receiver(&receiver.id()) + } + } + } +} + impl WebRtcPublishEndpointInner { fn add_receiver(&mut self, receiver: Weak) { self.receivers.push(receiver); @@ -199,11 +231,13 @@ pub struct WebRtcPublishEndpoint(Mutex); impl WebRtcPublishEndpoint { /// Create new [`WebRtcPublishEndpoint`]. pub fn new( + id: Id, p2p: P2pMode, receivers: Vec>, owner: Weak, ) -> Self { Self(Mutex::new(WebRtcPublishEndpointInner { + id, p2p, receivers, owner, @@ -253,4 +287,19 @@ impl WebRtcPublishEndpoint { pub fn remove_peer_ids(&self, peer_ids: &[PeerId]) { self.0.lock().unwrap().remove_peer_ids(peer_ids) } + + /// Returns ID of this [`WebRtcPublishEndpoint`]. + pub fn id(&self) -> Id { + self.0.lock().unwrap().id.clone() + } + + /// Remove all empty Weak pointers from receivers of this + /// [`WebRtcPublishEndpoint`]. + pub fn remove_empty_weaks_from_receivers(&self) { + self.0 + .lock() + .unwrap() + .receivers + .retain(|e| e.upgrade().is_some()); + } } diff --git a/src/signalling/control/participant.rs b/src/signalling/control/participant.rs index 31e370214..fc3ab3761 100644 --- a/src/signalling/control/participant.rs +++ b/src/signalling/control/participant.rs @@ -214,26 +214,31 @@ impl Participant { if let Some(publisher) = publisher_participant.get_publisher_by_id( &EndpointId(spec_play_endpoint.src.endpoint_id.to_string()), ) { + let new_play_endpoint_id = + EndpointId(spec_play_name.to_string()); let new_play_endpoint = Arc::new(WebRtcPlayEndpoint::new( + new_play_endpoint_id.clone(), spec_play_endpoint.src.clone(), Arc::downgrade(&publisher), Arc::downgrade(&this_member), )); - self.insert_receiver( - EndpointId(spec_play_name.to_string()), - Arc::clone(&new_play_endpoint), - ); + self.insert_receiver(Arc::clone(&new_play_endpoint)); publisher.add_receiver(Arc::downgrade(&new_play_endpoint)); } else { + let new_publish_id = + EndpointId(spec_play_endpoint.src.endpoint_id.to_string()); let new_publish = Arc::new(WebRtcPublishEndpoint::new( + new_publish_id.clone(), publisher_endpoint.p2p.clone(), Vec::new(), Arc::downgrade(&publisher_participant), )); + let new_self_play_id = EndpointId(spec_play_name.to_string()); let new_self_play = Arc::new(WebRtcPlayEndpoint::new( + new_self_play_id.clone(), spec_play_endpoint.src.clone(), Arc::downgrade(&new_publish), Arc::downgrade(&this_member), @@ -241,15 +246,9 @@ impl Participant { new_publish.add_receiver(Arc::downgrade(&new_self_play)); - publisher_participant.insert_publisher( - EndpointId(spec_play_endpoint.src.endpoint_id.to_string()), - new_publish, - ); + publisher_participant.insert_publisher(new_publish); - self.insert_receiver( - EndpointId(spec_play_name.to_string()), - new_self_play, - ); + self.insert_receiver(new_self_play); } } @@ -259,14 +258,14 @@ impl Participant { |(name, e)| { let endpoint_id = EndpointId(name.clone()); if self.publishers().get(&endpoint_id).is_none() { - self.insert_publisher( - endpoint_id, - Arc::new(WebRtcPublishEndpoint::new( + self.insert_publisher(Arc::new( + WebRtcPublishEndpoint::new( + endpoint_id, e.p2p.clone(), Vec::new(), Arc::downgrade(&this_member), - )), - ); + ), + )); } }, ); @@ -275,21 +274,21 @@ impl Participant { } /// Insert receiver into this [`Participant`]. - pub fn insert_receiver( - &self, - id: EndpointId, - endpoint: Arc, - ) { - self.0.lock().unwrap().receivers.insert(id, endpoint); + pub fn insert_receiver(&self, endpoint: Arc) { + self.0 + .lock() + .unwrap() + .receivers + .insert(endpoint.id(), endpoint); } /// Insert publisher into this [`Participant`]. - pub fn insert_publisher( - &self, - id: EndpointId, - endpoint: Arc, - ) { - self.0.lock().unwrap().publishers.insert(id, endpoint); + pub fn insert_publisher(&self, endpoint: Arc) { + self.0 + .lock() + .unwrap() + .publishers + .insert(endpoint.id(), endpoint); } /// Lookup [`WebRtcPublishEndpoint`] publisher by [`EndpointId`]. @@ -307,6 +306,16 @@ impl Participant { ) -> Option> { self.0.lock().unwrap().receivers.get(id).cloned() } + + /// Remove receiver [`WebRtcPlayEndpoint`] from this [`Participant`]. + pub fn remove_receiver(&self, id: &EndpointId) { + self.0.lock().unwrap().receivers.remove(id); + } + + /// Remove receiver [`WebRtcPublishEndpoint`] from this [`Participant`]. + pub fn remove_publisher(&self, id: &EndpointId) { + self.0.lock().unwrap().publishers.remove(id); + } } #[cfg(test)] From 45fa5b73e92d90d82efe11fed83ba441c8e5cecc Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 18 Jun 2019 13:45:21 +0300 Subject: [PATCH 162/735] Add macro for Option unwrap --- src/signalling/room.rs | 165 ++++++++++++++++++++++++++--------------- 1 file changed, 106 insertions(+), 59 deletions(-) diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 3cfa19036..c585c5a36 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -37,8 +37,78 @@ use crate::{ pub type ActFuture = Box>; +/// Macro for unwrapping Option. +/// +/// If Option::None then `error!` with provided message will be +/// called, [`CloseRoom`] emitted to [`Room`] context and function +/// will be returned with provided return expression. +/// +/// You can use `format!` syntax in this macro to provide some debug info. +/// +/// ## Usage +/// ```ignore +/// option_unwrap!( +/// bar.some_weak_pointer().upgrade(), // Some Option type +/// ctx, // Context of Room +/// (), // This will be returned from function in None case +/// "Empty Weak pointer for bar with ID {}", // Error message +/// bar.id(), // format! syntax +/// ); +/// ``` +macro_rules! option_unwrap { + ($e:expr, $ctx:expr, $ret:expr, $msg:expr, $( $x:expr ),* $(,)?) => { + match $e { + Some(e) => e, + None => { + error!( + "[ROOM]: {} Room will be closed.", + format!($msg, $( $x, )*) + ); + $ctx.notify(CloseRoom {}); + return $ret; + } + } + }; + + ($e:expr, $ctx:expr, $ret:expr, $msg:expr $(,)?) => { + match $e { + Some(e) => e, + None => { + error!("[ROOM]: {} Room will be closed.", $msg); + $ctx.notify(CloseRoom {}); + return $ret; + } + } + }; +} + +/// Macro for unwrapping Option that work similar as [`option_unwrap!`], but +/// always return `()` when None case happened. This will close Room when +/// `Option::None`. +/// +/// Read more info in [`option_unwrap!`] docs. +/// +/// ## Usage +/// ```ignore +/// option_unwrap!( +/// bar.some_weak_pointer().upgrade(), // Some Option type +/// ctx, // Context of Room +/// "Empty Weak pointer for bar with ID {}", // Error message +/// bar.id(), // format! syntax +/// ); +/// ``` +macro_rules! unit_option_unwrap { + ($e:expr, $ctx:expr, $msg:tt, $( $x:expr ),* $(,)?) => { + option_unwrap!($e, $ctx, (), $msg, $( $x, )*); + }; + + ($e:expr, $ctx:expr, $msg:expr $(,)?) => { + option_unwrap!($e, $ctx, (), $msg); + } +} + #[allow(clippy::module_name_repetitions)] -#[derive(Fail, Debug)] +#[derive(Debug, Fail)] pub enum RoomError { #[fail(display = "Couldn't find Peer with [id = {}]", _0)] PeerNotFound(PeerId), @@ -324,45 +394,30 @@ impl Room { member_id: &MemberId, ctx: &mut ::Context, ) { - let member = - if let Some(m) = self.participants.get_member_by_id(member_id) { - m.clone() - } else { - error!( - "Try to create necessary peers for nonexistent member \ - with ID {}. Room will be stopped.", - member_id - ); - ctx.notify(CloseRoom {}); - return; - }; + let member = unit_option_unwrap!( + self.participants.get_member_by_id(member_id), + ctx, + "Try to create peers for nonexistent participant with ID {}.", + member_id, + ); // Create all connected publish endpoints. for (_id, publish) in member.publishers() { for receiver in publish.receivers() { - let receiver = if let Some(receiver) = receiver.upgrade() { - receiver - } else { - error!( - "Empty weak pointer for publisher receiver. {:?}. \ - Closing room.", - publish - ); - ctx.notify(CloseRoom {}); - return; - }; - let receiver_owner = - if let Some(receiver_owner) = receiver.owner().upgrade() { - receiver_owner - } else { - error!( - "Empty weak pointer for publisher's receiver's \ - owner. {:?}. Closing room.", - receiver - ); - ctx.notify(CloseRoom {}); - return; - }; + let receiver = unit_option_unwrap!( + receiver.upgrade(), + ctx, + "Empty weak pointer for publisher receiver. {:?}.", + receiver, + ); + + let receiver_owner = unit_option_unwrap!( + receiver.owner().upgrade(), + ctx, + "Empty weak pointer for publisher's receiver's owner. \ + {:?}.", + receiver, + ); if self .participants @@ -379,29 +434,21 @@ impl Room { } // Create all connected play's receivers peers. - for (_id, play) in member.receivers() { - let plays_publisher_participant = - if let Some(plays_publisher) = play.publisher().upgrade() { - if let Some(owner) = plays_publisher.owner().upgrade() { - owner - } else { - error!( - "Empty weak pointer for play's publisher owner. \ - {:?}. Closing room.", - plays_publisher - ); - ctx.notify(CloseRoom {}); - return; - } - } else { - error!( - "Empty weak pointer for play's publisher. {:?}. \ - Closing room.", - play - ); - ctx.notify(CloseRoom {}); - return; - }; + for (_, play) in member.receivers() { + let plays_publisher_participant = { + let play_publisher = unit_option_unwrap!( + play.publisher().upgrade(), + ctx, + "Empty weak pointer for play's publisher. {:?}.", + play, + ); + unit_option_unwrap!( + play_publisher.owner().upgrade(), + ctx, + "Empty weak pointer for play's publisher owner. {:?}.", + play_publisher, + ) + }; if self .participants From 67e5f65227b775ebdbc2ab6353e8764f684aef63 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 18 Jun 2019 13:51:21 +0300 Subject: [PATCH 163/735] Revert "Fix drop" This reverts commit b17a23d46735408af8a157633453af26a68b055d. --- src/signalling/control/endpoint.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/signalling/control/endpoint.rs b/src/signalling/control/endpoint.rs index 7c743179d..12bdd36d2 100644 --- a/src/signalling/control/endpoint.rs +++ b/src/signalling/control/endpoint.rs @@ -162,7 +162,7 @@ impl WebRtcPlayEndpoint { impl Drop for WebRtcPlayEndpoint { fn drop(&mut self) { - if (Arc::strong_count(&self.0) - 1) == 1 { + if Arc::strong_count(&self.0) == 1 { self.publisher().remove_receiver(&self.id()); } } @@ -319,7 +319,7 @@ impl WebRtcPublishEndpoint { /// This is memory leak fix for [`WebRtcPublishEndpoint`]. impl Drop for WebRtcPublishEndpoint { fn drop(&mut self) { - if (Arc::strong_count(&self.0) - 1) == self.receivers().len() { + if Arc::strong_count(&self.0) == self.receivers().len() { let inner = self.0.lock().unwrap(); for receiver in &inner.receivers { if let Some(receiver_owner) = receiver.owner().upgrade() { From 8eccd22bb6f57e3f5e5e87ceb0783e7577663088 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 18 Jun 2019 13:51:26 +0300 Subject: [PATCH 164/735] Revert "Use Drop fix memory leak for endpoints" This reverts commit 183cfd8ee3b6a1e392a1d206226cc4b12fb5544f. --- src/media/peer.rs | 13 ++- src/signalling/control/endpoint.rs | 119 ++++---------------------- src/signalling/control/participant.rs | 93 +++++++++----------- src/signalling/room.rs | 36 ++++++-- 4 files changed, 100 insertions(+), 161 deletions(-) diff --git a/src/media/peer.rs b/src/media/peer.rs index da1dd0452..fb5fc1b73 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -261,7 +261,7 @@ impl Peer { &mut self, partner_peer: &mut Peer, tracks_count: &mut Counter, - publish_endpoints: HashMap, + publish_endpoints: HashMap>, ) { let partner_id = self.partner_member_id(); let self_id = self.id(); @@ -272,6 +272,17 @@ impl Peer { e.add_peer_id(self_id); e.receivers() .into_iter() + .filter_map(|e| { + let upgraded_play = e.upgrade(); + if upgraded_play.is_none() { + warn!( + "Empty weak pointer of publisher's play \ + endpoint. {:?}.", + e + ); + } + upgraded_play + }) .filter_map(|p| { let owner = p.owner().upgrade(); if owner.is_none() { diff --git a/src/signalling/control/endpoint.rs b/src/signalling/control/endpoint.rs index 12bdd36d2..bd418c946 100644 --- a/src/signalling/control/endpoint.rs +++ b/src/signalling/control/endpoint.rs @@ -2,14 +2,13 @@ use std::{ fmt::Display, - sync::{Arc, Mutex, Weak}, + sync::{Mutex, Weak}, }; use hashbrown::HashSet; use crate::{ api::control::endpoint::{P2pMode, SrcUri}, - log::prelude::*, media::PeerId, }; @@ -27,24 +26,13 @@ impl Display for Id { #[derive(Debug, Clone)] struct WebRtcPlayEndpointInner { - /// ID of this [`WebRtcPlayEndpoint`]. - id: Id, - /// Source URI of [`WebRtcPublishEndpoint`] from which this /// [`WebRtcPlayEndpoint`] receive data. src: SrcUri, /// Publisher [`WebRtcPublishEndpoint`] from which this /// [`WebRtcPlayEndpoint`] receive data. - /// - /// __Important!__ - /// - /// As you can see, a __memory leak may occur here__... But it should not - /// occur beyond the implementation of the [`Drop`] for this - /// [`WebRtcPlayEndpoint`]. Please be careful and process all future - /// circular references in the implementation of the [`Drop`] for this - /// structure. - publisher: WebRtcPublishEndpoint, + publisher: Weak, /// Owner [`Participant`] of this [`WebRtcPlayEndpoint`]. owner: Weak, @@ -68,7 +56,7 @@ impl WebRtcPlayEndpointInner { Weak::clone(&self.owner) } - fn publisher(&self) -> WebRtcPublishEndpoint { + fn publisher(&self) -> Weak { self.publisher.clone() } @@ -90,32 +78,23 @@ impl WebRtcPlayEndpointInner { } /// Signalling representation of `WebRtcPlayEndpoint`. -/// -/// __Important!__ -/// -/// Please be careful and process all future circular references in the -/// implementation of the [`Drop`] for this structure, otherwise __memory leak -/// may occur here__. #[allow(clippy::module_name_repetitions)] -#[derive(Debug, Clone)] -#[doc(inline)] -pub struct WebRtcPlayEndpoint(Arc>); +#[derive(Debug)] +pub struct WebRtcPlayEndpoint(Mutex); impl WebRtcPlayEndpoint { /// Create new [`WebRtcPlayEndpoint`]. pub fn new( src: SrcUri, - publisher: WebRtcPublishEndpoint, + publisher: Weak, owner: Weak, - id: Id, ) -> Self { - Self(Arc::new(Mutex::new(WebRtcPlayEndpointInner { + Self(Mutex::new(WebRtcPlayEndpointInner { src, publisher, owner, peer_id: None, - id, - }))) + })) } /// Returns [`SrcUri`] of this [`WebRtcPlayEndpoint`]. @@ -129,7 +108,7 @@ impl WebRtcPlayEndpoint { } /// Returns publisher's [`WebRtcPublishEndpoint`]. - pub fn publisher(&self) -> WebRtcPublishEndpoint { + pub fn publisher(&self) -> Weak { self.0.lock().unwrap().publisher() } @@ -154,38 +133,15 @@ impl WebRtcPlayEndpoint { pub fn reset(&self) { self.0.lock().unwrap().reset() } - - pub fn id(&self) -> Id { - self.0.lock().unwrap().id.clone() - } -} - -impl Drop for WebRtcPlayEndpoint { - fn drop(&mut self) { - if Arc::strong_count(&self.0) == 1 { - self.publisher().remove_receiver(&self.id()); - } - } } #[derive(Debug, Clone)] struct WebRtcPublishEndpointInner { - /// ID of this [`WebRtcPublishEndpoint`]. - id: Id, - /// P2P connection mode for this [`WebRtcPublishEndpoint`]. p2p: P2pMode, /// All receivers of this [`WebRtcPublishEndpoint`]. - /// - /// __Important!__ - /// - /// As you can see, a __memory leak may occur here__... But it should not - /// occur beyond the implementation of the [`Drop`] for this - /// [`WebRtcPublishEndpoint`]. Please be careful and process all future - /// circular references in the implementation of the [`Drop`] for this - /// structure. - receivers: Vec, + receivers: Vec>, /// Owner [`Participant`] of this [`WebRtcPublishEndpoint`]. owner: Weak, @@ -199,11 +155,11 @@ struct WebRtcPublishEndpointInner { } impl WebRtcPublishEndpointInner { - fn add_receiver(&mut self, receiver: WebRtcPlayEndpoint) { + fn add_receiver(&mut self, receiver: Weak) { self.receivers.push(receiver); } - fn receivers(&self) -> Vec { + fn receivers(&self) -> Vec> { self.receivers.clone() } @@ -236,39 +192,32 @@ impl WebRtcPublishEndpointInner { } /// Signalling representation of `WebRtcPublishEndpoint`. -/// -/// __Important!__ -/// -/// Please be careful and process all future circular references in the -/// implementation of the [`Drop`] for this structure. #[allow(clippy::module_name_repetitions)] -#[derive(Debug, Clone)] -pub struct WebRtcPublishEndpoint(Arc>); +#[derive(Debug)] +pub struct WebRtcPublishEndpoint(Mutex); impl WebRtcPublishEndpoint { /// Create new [`WebRtcPublishEndpoint`]. pub fn new( p2p: P2pMode, - receivers: Vec, + receivers: Vec>, owner: Weak, - id: Id, ) -> Self { - Self(Arc::new(Mutex::new(WebRtcPublishEndpointInner { + Self(Mutex::new(WebRtcPublishEndpointInner { p2p, receivers, owner, peer_ids: HashSet::new(), - id, - }))) + })) } /// Add receiver for this [`WebRtcPublishEndpoint`]. - pub fn add_receiver(&self, receiver: WebRtcPlayEndpoint) { + pub fn add_receiver(&self, receiver: Weak) { self.0.lock().unwrap().add_receiver(receiver) } /// Returns all receivers of this [`WebRtcPublishEndpoint`]. - pub fn receivers(&self) -> Vec { + pub fn receivers(&self) -> Vec> { self.0.lock().unwrap().receivers() } @@ -304,34 +253,4 @@ impl WebRtcPublishEndpoint { pub fn remove_peer_ids(&self, peer_ids: &[PeerId]) { self.0.lock().unwrap().remove_peer_ids(peer_ids) } - - /// Returns ID of this [`WebRtcPublishEndpoint`]. - pub fn id(&self) -> Id { - self.0.lock().unwrap().id.clone() - } - - /// Remove [`WebRtcPlayEndpoint`] with provided [`Id`] from receivers. - pub fn remove_receiver(&self, id: &Id) { - self.0.lock().unwrap().receivers.retain(|e| &e.id() == id); - } -} - -/// This is memory leak fix for [`WebRtcPublishEndpoint`]. -impl Drop for WebRtcPublishEndpoint { - fn drop(&mut self) { - if Arc::strong_count(&self.0) == self.receivers().len() { - let inner = self.0.lock().unwrap(); - for receiver in &inner.receivers { - if let Some(receiver_owner) = receiver.owner().upgrade() { - receiver_owner.remove_receiver(&receiver.id()); - } else { - error!( - "Receiver owner for {} WebRtcPublishEndpoint not \ - found.", - inner.id - ); - } - } - } - } } diff --git a/src/signalling/control/participant.rs b/src/signalling/control/participant.rs index ae5f10e87..31e370214 100644 --- a/src/signalling/control/participant.rs +++ b/src/signalling/control/participant.rs @@ -51,10 +51,10 @@ struct ParticipantInner { id: MemberId, /// All [`WebRtcPublishEndpoint`]s of this [`Participant`]. - publishers: HashMap, + publishers: HashMap>, /// All [`WebRtcPlayEndpoint`]s of this [`Participant`]. - receivers: HashMap, + receivers: HashMap>, /// Credentials for this [`Participant`]. credentials: String, @@ -103,16 +103,6 @@ impl Participant { .map(IceUser::servers_list) } - /// Remove publisher [`WebRtcPublishEndpoint`] from this [`Participant`]. - pub fn remove_publisher(&self, id: &EndpointId) { - self.0.lock().unwrap().publishers.remove(id); - } - - /// Remove receiver [`WebRtcPlayEndpoint`] from this [`Participant`]. - pub fn remove_receiver(&self, id: &EndpointId) { - self.0.lock().unwrap().receivers.remove(id); - } - /// Returns and set to `None` [`IceUser`] of this [`Participant`]. pub fn take_ice_user(&self) -> Option { self.0.lock().unwrap().ice_user.take() @@ -161,12 +151,14 @@ impl Participant { } /// Returns all publishers of this [`Participant`]. - pub fn publishers(&self) -> HashMap { + pub fn publishers( + &self, + ) -> HashMap> { self.0.lock().unwrap().publishers.clone() } /// Returns all receivers of this [`Participant`]. - pub fn receivers(&self) -> HashMap { + pub fn receivers(&self) -> HashMap> { self.0.lock().unwrap().receivers.clone() } @@ -222,46 +214,42 @@ impl Participant { if let Some(publisher) = publisher_participant.get_publisher_by_id( &EndpointId(spec_play_endpoint.src.endpoint_id.to_string()), ) { - let new_play_endpoint_id = - EndpointId(spec_play_name.to_string()); - let new_play_endpoint = WebRtcPlayEndpoint::new( + let new_play_endpoint = Arc::new(WebRtcPlayEndpoint::new( spec_play_endpoint.src.clone(), - publisher.clone(), + Arc::downgrade(&publisher), Arc::downgrade(&this_member), - new_play_endpoint_id.clone(), - ); + )); self.insert_receiver( EndpointId(spec_play_name.to_string()), - new_play_endpoint.clone(), + Arc::clone(&new_play_endpoint), ); - publisher.add_receiver(new_play_endpoint.clone()); + publisher.add_receiver(Arc::downgrade(&new_play_endpoint)); } else { - let new_publish_endpoint_id = - EndpointId(spec_play_endpoint.src.endpoint_id.to_string()); - let new_publish = WebRtcPublishEndpoint::new( + let new_publish = Arc::new(WebRtcPublishEndpoint::new( publisher_endpoint.p2p.clone(), Vec::new(), Arc::downgrade(&publisher_participant), - new_publish_endpoint_id.clone(), - ); + )); - let new_self_play_endpoint_id = - EndpointId(spec_play_name.to_string()); - let new_self_play = WebRtcPlayEndpoint::new( + let new_self_play = Arc::new(WebRtcPlayEndpoint::new( spec_play_endpoint.src.clone(), - new_publish.clone(), + Arc::downgrade(&new_publish), Arc::downgrade(&this_member), - new_self_play_endpoint_id.clone(), - ); + )); - new_publish.add_receiver(new_self_play.clone()); + new_publish.add_receiver(Arc::downgrade(&new_self_play)); - publisher_participant - .insert_publisher(new_publish_endpoint_id, new_publish); + publisher_participant.insert_publisher( + EndpointId(spec_play_endpoint.src.endpoint_id.to_string()), + new_publish, + ); - self.insert_receiver(new_self_play_endpoint_id, new_self_play); + self.insert_receiver( + EndpointId(spec_play_name.to_string()), + new_self_play, + ); } } @@ -272,13 +260,12 @@ impl Participant { let endpoint_id = EndpointId(name.clone()); if self.publishers().get(&endpoint_id).is_none() { self.insert_publisher( - endpoint_id.clone(), - WebRtcPublishEndpoint::new( + endpoint_id, + Arc::new(WebRtcPublishEndpoint::new( e.p2p.clone(), Vec::new(), Arc::downgrade(&this_member), - endpoint_id, - ), + )), ); } }, @@ -291,7 +278,7 @@ impl Participant { pub fn insert_receiver( &self, id: EndpointId, - endpoint: WebRtcPlayEndpoint, + endpoint: Arc, ) { self.0.lock().unwrap().receivers.insert(id, endpoint); } @@ -300,7 +287,7 @@ impl Participant { pub fn insert_publisher( &self, id: EndpointId, - endpoint: WebRtcPublishEndpoint, + endpoint: Arc, ) { self.0.lock().unwrap().publishers.insert(id, endpoint); } @@ -309,7 +296,7 @@ impl Participant { pub fn get_publisher_by_id( &self, id: &EndpointId, - ) -> Option { + ) -> Option> { self.0.lock().unwrap().publishers.get(id).cloned() } @@ -317,13 +304,15 @@ impl Participant { pub fn get_receiver_by_id( &self, id: &EndpointId, - ) -> Option { + ) -> Option> { self.0.lock().unwrap().receivers.get(id).cloned() } } #[cfg(test)] mod participant_loading_tests { + use std::sync::Arc; + use crate::api::control::Element; use super::*; @@ -384,15 +373,16 @@ mod participant_loading_tests { let is_caller_has_responder_in_receivers = caller_publish_endpoint .receivers() .into_iter() - .filter(|p| p.id() == responder_play_endpoint.id()) + .map(|p| p.upgrade().unwrap()) + .filter(|p| Arc::ptr_eq(p, &responder_play_endpoint)) .count() == 1; assert!(is_caller_has_responder_in_receivers); - assert_eq!( - responder_play_endpoint.publisher().id(), - caller_publish_endpoint.id() - ); + assert!(Arc::ptr_eq( + &responder_play_endpoint.publisher().upgrade().unwrap(), + &caller_publish_endpoint + )); let some_participant = store.get(&MemberId("some-member".to_string())).unwrap(); @@ -410,7 +400,8 @@ mod participant_loading_tests { some_participant_publisher .receivers() .into_iter() - .filter(|p| p.id() == responder_play2_endpoint.id()) + .map(|p| p.upgrade().unwrap()) + .filter(|p| Arc::ptr_eq(p, &responder_play2_endpoint)) .count() == 1; assert!(is_some_participant_has_responder_in_receivers); diff --git a/src/signalling/room.rs b/src/signalling/room.rs index e2dbd8aac..3cfa19036 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -340,6 +340,17 @@ impl Room { // Create all connected publish endpoints. for (_id, publish) in member.publishers() { for receiver in publish.receivers() { + let receiver = if let Some(receiver) = receiver.upgrade() { + receiver + } else { + error!( + "Empty weak pointer for publisher receiver. {:?}. \ + Closing room.", + publish + ); + ctx.notify(CloseRoom {}); + return; + }; let receiver_owner = if let Some(receiver_owner) = receiver.owner().upgrade() { receiver_owner @@ -369,21 +380,28 @@ impl Room { // Create all connected play's receivers peers. for (_id, play) in member.receivers() { - // TODO: remove block - let plays_publisher_participant = { - let plays_publisher = play.publisher(); - if let Some(owner) = plays_publisher.owner().upgrade() { - owner + let plays_publisher_participant = + if let Some(plays_publisher) = play.publisher().upgrade() { + if let Some(owner) = plays_publisher.owner().upgrade() { + owner + } else { + error!( + "Empty weak pointer for play's publisher owner. \ + {:?}. Closing room.", + plays_publisher + ); + ctx.notify(CloseRoom {}); + return; + } } else { error!( - "Empty weak pointer for play's publisher owner. {:?}. \ + "Empty weak pointer for play's publisher. {:?}. \ Closing room.", - plays_publisher + play ); ctx.notify(CloseRoom {}); return; - } - }; + }; if self .participants From 8d3cde70d0a6ccd1213d34fee3ed3f7464eb67bc Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 18 Jun 2019 14:09:54 +0300 Subject: [PATCH 165/735] Fix lints and formatting --- src/signalling/room.rs | 46 ++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/src/signalling/room.rs b/src/signalling/room.rs index c585c5a36..e055509a6 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -39,7 +39,7 @@ pub type ActFuture = /// Macro for unwrapping Option. /// -/// If Option::None then `error!` with provided message will be +/// If [`Option::None`] then `error!` with provided message will be /// called, [`CloseRoom`] emitted to [`Room`] context and function /// will be returned with provided return expression. /// @@ -48,36 +48,34 @@ pub type ActFuture = /// ## Usage /// ```ignore /// option_unwrap!( -/// bar.some_weak_pointer().upgrade(), // Some Option type +/// foo.some_weak_pointer().upgrade(), // Some Option type /// ctx, // Context of Room /// (), // This will be returned from function in None case /// "Empty Weak pointer for bar with ID {}", // Error message -/// bar.id(), // format! syntax +/// foo.id(), // format! syntax /// ); /// ``` macro_rules! option_unwrap { ($e:expr, $ctx:expr, $ret:expr, $msg:expr, $( $x:expr ),* $(,)?) => { - match $e { - Some(e) => e, - None => { - error!( - "[ROOM]: {} Room will be closed.", - format!($msg, $( $x, )*) - ); - $ctx.notify(CloseRoom {}); - return $ret; - } + if let Some(e) = $e { + e + } else { + error!( + "[ROOM]: {} Room will be closed.", + format!($msg, $( $x, )*) + ); + $ctx.notify(CloseRoom {}); + return $ret; } }; ($e:expr, $ctx:expr, $ret:expr, $msg:expr $(,)?) => { - match $e { - Some(e) => e, - None => { - error!("[ROOM]: {} Room will be closed.", $msg); - $ctx.notify(CloseRoom {}); - return $ret; - } + if let Some(e) = $e { + e + } else { + error!("[ROOM]: {} Room will be closed.", $msg); + $ctx.notify(CloseRoom {}); + return $ret; } }; } @@ -90,11 +88,11 @@ macro_rules! option_unwrap { /// /// ## Usage /// ```ignore -/// option_unwrap!( -/// bar.some_weak_pointer().upgrade(), // Some Option type +/// unit_option_unwrap!( +/// foo.some_weak_pointer().upgrade(), // Some Option type /// ctx, // Context of Room /// "Empty Weak pointer for bar with ID {}", // Error message -/// bar.id(), // format! syntax +/// foo.id(), // format! syntax /// ); /// ``` macro_rules! unit_option_unwrap { @@ -104,7 +102,7 @@ macro_rules! unit_option_unwrap { ($e:expr, $ctx:expr, $msg:expr $(,)?) => { option_unwrap!($e, $ctx, (), $msg); - } + }; } #[allow(clippy::module_name_repetitions)] From a07a6f08c243cdadf3a08c30c20d788ca04dba03 Mon Sep 17 00:00:00 2001 From: alexlapa Date: Wed, 19 Jun 2019 14:53:36 +0300 Subject: [PATCH 166/735] refactor --- src/signalling/participants.rs | 117 +++++++++++++++++---------------- src/signalling/room.rs | 53 +++++++-------- 2 files changed, 85 insertions(+), 85 deletions(-) diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 20be75778..f90bd4623 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -27,7 +27,7 @@ use crate::{ RpcConnectionClosed, }, control::RoomId, - control::{MemberId, RoomSpec}, + control::{MemberId as ParticipantId, RoomSpec}, }, log::prelude::*, media::IceUser, @@ -49,6 +49,8 @@ pub enum ParticipantServiceErr { _0 )] MailBoxErr(MailboxError), + #[fail(display = "Participant with Id [{}] was not found", _0)] + ParticipantNotFound(ParticipantId), } impl From for ParticipantServiceErr { @@ -73,15 +75,15 @@ pub struct ParticipantService { room_id: RoomId, /// [`Participant`]s which currently are present in this [`Room`]. - members: HashMap>, + participants: HashMap>, /// Service for managing authorization on Turn server. turn: Box, - /// Established [`RpcConnection`]s of [`Member`]s in this [`Room`]. + /// Established [`RpcConnection`]s of [`Participants`]s in this [`Room`]. // TODO: Replace Box> with enum, // as the set of all possible RpcConnection types is not closed. - connections: HashMap>, + connections: HashMap>, /// Timeout for close [`RpcConnection`] after receiving /// [`RpcConnectionClosed`] message. @@ -90,7 +92,7 @@ pub struct ParticipantService { /// Stores [`RpcConnection`] drop tasks. /// If [`RpcConnection`] is lost, [`Room`] waits for connection_timeout /// before dropping it irrevocably in case it gets reestablished. - drop_connection_tasks: HashMap, + drop_connection_tasks: HashMap, } impl ParticipantService { @@ -100,11 +102,11 @@ impl ParticipantService { reconnect_timeout: Duration, turn: Box, ) -> Result { - let members = Participant::load_store(room_spec)?; + let participants = Participant::load_store(room_spec)?; debug!( "Created ParticipantService with participants: {:?}.", - members + participants .iter() .map(|(id, p)| { format!( @@ -125,7 +127,7 @@ impl ParticipantService { Ok(Self { room_id: room_spec.id().clone(), - members, + participants, turn, connections: HashMap::new(), reconnect_timeout, @@ -134,24 +136,24 @@ impl ParticipantService { } /// Lookup [`Participant`] by provided id. - pub fn get_member_by_id(&self, id: &MemberId) -> Option> { - self.members.get(id).cloned() + pub fn get_participant_by_id(&self, id: &ParticipantId) -> Option> { + self.participants.get(id).cloned() } /// Lookup [`Participant`] by provided id and credentials. Returns /// [`Err(AuthorizationError::ParticipantNotExists)`] if lookup by - /// [`MemberId`] failed. Returns + /// [`ParticipantId`] failed. Returns /// [`Err(AuthorizationError::InvalidCredentials)`] if [`Participant`] /// was found, but incorrect credentials was provided. - pub fn get_member_by_id_and_credentials( + pub fn get_participant_by_id_and_credentials( &self, - member_id: &MemberId, + participant_id: &ParticipantId, credentials: &str, ) -> Result, AuthorizationError> { - match self.get_member_by_id(member_id) { - Some(member) => { - if member.credentials().eq(credentials) { - Ok(member.clone()) + match self.get_participant_by_id(participant_id) { + Some(participant) => { + if participant.credentials().eq(credentials) { + Ok(participant.clone()) } else { Err(AuthorizationError::InvalidCredentials) } @@ -161,24 +163,24 @@ impl ParticipantService { } /// Checks if [`Participant`] has **active** [`RcpConnection`]. - pub fn member_has_connection(&self, member_id: &MemberId) -> bool { - self.connections.contains_key(member_id) - && !self.drop_connection_tasks.contains_key(member_id) + pub fn participant_has_connection(&self, participant_id: &ParticipantId) -> bool { + self.connections.contains_key(participant_id) + && !self.drop_connection_tasks.contains_key(participant_id) } /// Send [`Event`] to specified remote [`Participant`]. - pub fn send_event_to_member( + pub fn send_event_to_participant( &mut self, - member_id: MemberId, + participant_id: ParticipantId, event: Event, ) -> impl Future { - match self.connections.get(&member_id) { + match self.connections.get(&participant_id) { Some(conn) => Either::A( conn.send_event(EventMessage::from(event)) - .map_err(move |_| RoomError::UnableToSendEvent(member_id)), + .map_err(move |_| RoomError::UnableToSendEvent(participant_id)), ), None => Either::B(future::err(RoomError::ConnectionNotExists( - member_id, + participant_id, ))), } } @@ -189,24 +191,32 @@ impl ParticipantService { pub fn connection_established( &mut self, ctx: &mut Context, - member_id: MemberId, + participant_id: ParticipantId, con: Box, - ) -> ActFuture<(), ParticipantServiceErr> { - // lookup previous member connection - if let Some(mut connection) = self.connections.remove(&member_id) { - debug!("Closing old RpcConnection for member {}", member_id); + ) -> ActFuture, ParticipantServiceErr> { + + let participant = match self.get_participant_by_id(&participant_id) { + None => { + return Box::new(wrap_future(future::err(ParticipantServiceErr::ParticipantNotFound(participant_id)))); + }, + Some(participant) => { participant }, + }; + + // lookup previous participant connection + if let Some(mut connection) = self.connections.remove(&participant_id) { + debug!("Closing old RpcConnection for participant {}", participant_id); // cancel RpcConnection close task, since connection is // reestablished - if let Some(handler) = self.drop_connection_tasks.remove(&member_id) + if let Some(handler) = self.drop_connection_tasks.remove(&participant_id) { ctx.cancel_future(handler); } - Box::new(wrap_future(connection.close().then(|_| Ok(())))) + Box::new(wrap_future(connection.close().then(move |_| Ok(participant)))) } else { Box::new( wrap_future(self.turn.create( - member_id.clone(), + participant_id.clone(), self.room_id.clone(), UnreachablePolicy::ReturnErr, )) @@ -215,14 +225,11 @@ impl ParticipantService { }) .and_then( move |ice: IceUser, room: &mut Room, _| { - if let Some(member) = - room.participants.get_member_by_id(&member_id) - { - member.replace_ice_user(ice); - room.participants - .insert_connection(member_id.clone(), con); - }; - wrap_future(future::ok(())) + room.participants + .insert_connection(participant_id.clone(), con); + participant.replace_ice_user(ice); + + wrap_future(future::ok(participant)) }, ), ) @@ -232,10 +239,10 @@ impl ParticipantService { /// Insert new [`RpcConnection`] into this [`ParticipantService`]. fn insert_connection( &mut self, - member_id: MemberId, + participant_id: ParticipantId, conn: Box, ) { - self.connections.insert(member_id, conn); + self.connections.insert(participant_id, conn); } /// If [`ClosedReason::Closed`], then removes [`RpcConnection`] associated @@ -243,20 +250,20 @@ impl ParticipantService { /// room. If [`ClosedReason::Lost`], then creates delayed task that /// emits [`ClosedReason::Closed`]. // TODO: Dont close the room. It is being closed atm, because we have - // no way to handle absence of RtcPeerConnection. + // no way to handle absence of RpcConnection. pub fn connection_closed( &mut self, ctx: &mut Context, - member_id: MemberId, + participant_id: ParticipantId, reason: &ClosedReason, ) { let closed_at = Instant::now(); match reason { ClosedReason::Closed => { - self.connections.remove(&member_id); + self.connections.remove(&participant_id); ctx.spawn(wrap_future( - self.delete_ice_user(&member_id).map_err(|err| { + self.delete_ice_user(&participant_id).map_err(|err| { error!("Error deleting IceUser {:?}", err) }), )); @@ -264,15 +271,15 @@ impl ParticipantService { } ClosedReason::Lost => { self.drop_connection_tasks.insert( - member_id.clone(), + participant_id.clone(), ctx.run_later(self.reconnect_timeout, move |_, ctx| { info!( "Member {} connection lost at {:?}. Room will be \ stopped.", - &member_id, closed_at + &participant_id, closed_at ); ctx.notify(RpcConnectionClosed { - member_id, + member_id: participant_id, reason: ClosedReason::Closed, }) }), @@ -284,10 +291,10 @@ impl ParticipantService { /// Deletes [`IceUser`] associated with provided [`Member`]. fn delete_ice_user( &mut self, - member_id: &MemberId, + participant_id: &ParticipantId, ) -> Box> { - match self.get_member_by_id(&member_id) { - Some(member) => match member.take_ice_user() { + match self.get_participant_by_id(&participant_id) { + Some(participant) => match participant.take_ice_user() { Some(ice_user) => self.turn.delete(vec![ice_user]), None => Box::new(future::ok(())), }, @@ -316,9 +323,9 @@ impl ParticipantService { // deleting all IceUsers let remove_ice_users = Box::new({ - let mut room_users = Vec::with_capacity(self.members.len()); + let mut room_users = Vec::with_capacity(self.participants.len()); - self.members.iter().for_each(|(_, data)| { + self.participants.iter().for_each(|(_, data)| { if let Some(ice_user) = data.take_ice_user() { room_users.push(ice_user); } diff --git a/src/signalling/room.rs b/src/signalling/room.rs index e055509a6..f07df4150 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -221,7 +221,7 @@ impl Room { let member_id = sender.member_id(); let ice_servers = self .participants - .get_member_by_id(&member_id) + .get_participant_by_id(&member_id) .ok_or_else(|| RoomError::MemberNotFound(member_id.clone()))? .servers_list() .ok_or_else(|| RoomError::NoTurnCredentials(member_id.clone()))?; @@ -234,7 +234,7 @@ impl Room { self.peers.add_peer(sender); Ok(Box::new(wrap_future( self.participants - .send_event_to_member(member_id, peer_created), + .send_event_to_participant(member_id, peer_created), ))) } @@ -244,7 +244,7 @@ impl Room { member_id: MemberId, peers: Vec, ) -> ActFuture<(), RoomError> { - Box::new(wrap_future(self.participants.send_event_to_member( + Box::new(wrap_future(self.participants.send_event_to_participant( member_id, Event::PeersRemoved { peer_ids: peers }, ))) @@ -270,7 +270,7 @@ impl Room { let to_member_id = to_peer.member_id(); let ice_servers = self .participants - .get_member_by_id(&to_member_id) + .get_participant_by_id(&to_member_id) .ok_or_else(|| RoomError::MemberNotFound(to_member_id.clone()))? .servers_list() .ok_or_else(|| { @@ -288,7 +288,7 @@ impl Room { self.peers.add_peer(to_peer); Ok(Box::new(wrap_future( - self.participants.send_event_to_member(to_member_id, event), + self.participants.send_event_to_participant(to_member_id, event), ))) } @@ -320,7 +320,7 @@ impl Room { self.peers.add_peer(to_peer); Ok(Box::new(wrap_future( - self.participants.send_event_to_member(to_member_id, event), + self.participants.send_event_to_participant(to_member_id, event), ))) } @@ -357,13 +357,13 @@ impl Room { }; Ok(Box::new(wrap_future( - self.participants.send_event_to_member(to_member_id, event), + self.participants.send_event_to_participant(to_member_id, event), ))) } /// Create [`Peer`]s between [`Participant`]s and interconnect it by control /// API spec. - fn create_and_interconnect_peers( + fn connect_participants( &mut self, first_member: &Participant, second_member: &Participant, @@ -387,20 +387,13 @@ impl Room { /// Availability is determines by checking [`RpcConnection`] of all /// [`Participant`]s from [`WebRtcPlayEndpoint`]s and from receivers of /// connected [`Participant`]. - fn create_peers_with_available_members( + fn init_participant_connections( &mut self, - member_id: &MemberId, + participant: &Participant, ctx: &mut ::Context, ) { - let member = unit_option_unwrap!( - self.participants.get_member_by_id(member_id), - ctx, - "Try to create peers for nonexistent participant with ID {}.", - member_id, - ); - // Create all connected publish endpoints. - for (_id, publish) in member.publishers() { + for (_, publish) in participant.publishers() { for receiver in publish.receivers() { let receiver = unit_option_unwrap!( receiver.upgrade(), @@ -419,11 +412,11 @@ impl Room { if self .participants - .member_has_connection(&receiver_owner.id()) + .participant_has_connection(&receiver_owner.id()) && !receiver.is_connected() { - self.create_and_interconnect_peers( - &member, + self.connect_participants( + &participant, &receiver_owner, ctx, ); @@ -432,7 +425,7 @@ impl Room { } // Create all connected play's receivers peers. - for (_, play) in member.receivers() { + for (_, play) in participant.receivers() { let plays_publisher_participant = { let play_publisher = unit_option_unwrap!( play.publisher().upgrade(), @@ -450,11 +443,11 @@ impl Room { if self .participants - .member_has_connection(&plays_publisher_participant.id()) + .participant_has_connection(&plays_publisher_participant.id()) && !play.is_connected() { - self.create_and_interconnect_peers( - &member, + self.connect_participants( + &participant, &plays_publisher_participant, ctx, ); @@ -465,7 +458,7 @@ impl Room { /// [`Actor`] implementation that provides an ergonomic way /// to interact with [`Room`]. -// TODO: close connections on signal (gracefull shutdown) +// TODO: close connections on signal (graceful shutdown) impl Actor for Room { type Context = Context; } @@ -480,7 +473,7 @@ impl Handler for Room { _ctx: &mut Self::Context, ) -> Self::Result { self.participants - .get_member_by_id_and_credentials(&msg.member_id, &msg.credentials) + .get_participant_by_id_and_credentials(&msg.member_id, &msg.credentials) .map(|_| ()) } } @@ -549,7 +542,7 @@ impl Handler for Room { msg.peers_id, msg.member_id ); if let Some(participant) = - self.participants.get_member_by_id(&msg.member_id) + self.participants.get_participant_by_id(&msg.member_id) { participant.peers_removed(&msg.peers_id); } else { @@ -646,8 +639,8 @@ impl Handler for Room { .map_err(|err, _, _| { error!("RpcConnectionEstablished error {:?}", err) }) - .map(move |_, room, ctx| { - room.create_peers_with_available_members(&member_id, ctx); + .map(move |participant, room, ctx| { + room.init_participant_connections(&participant, ctx); }); Box::new(fut) } From 9666e0db7c7b251dbd4de45b2ea2f890a5e98837 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 19 Jun 2019 20:12:52 +0300 Subject: [PATCH 167/735] Bump version of actix-web to 1.0 and actix to 0.8 --- Cargo.lock | 629 ++++++++++++++++++--------------- Cargo.toml | 5 +- docker-compose.yml | 2 +- src/api/client/server.rs | 60 ++-- src/api/client/session.rs | 2 +- src/main.rs | 19 +- src/signalling/participants.rs | 3 +- src/turn/service.rs | 5 +- 8 files changed, 402 insertions(+), 323 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fda2e4e33..3a1b70c31 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11,88 +11,93 @@ dependencies = [ [[package]] name = "actix" -version = "0.7.9" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "actix_derive 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-http 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-rt 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "actix_derive 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "hashbrown 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-signal 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "trust-dns-proto 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "trust-dns-resolver 0.10.3 (registry+https://github.com/rust-lang/crates.io-index)", - "uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", + "trust-dns-resolver 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "actix-net" -version = "0.2.6" +name = "actix-codec" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "actix 0.7.9 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", - "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", - "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-current-thread 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "actix-connect" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-service 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-utils 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", + "either 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-current-thread 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "tower-service 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "trust-dns-resolver 0.10.3 (registry+https://github.com/rust-lang/crates.io-index)", + "trust-dns-resolver 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "actix-web" -version = "0.7.19" +name = "actix-http" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "actix 0.7.9 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-net 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-connect 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-server-config 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-service 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-threadpool 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-utils 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "brotli2 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "cookie 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)", + "chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "copyless 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "either 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "encoding 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "flate2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "h2 0.1.23 (registry+https://github.com/rust-lang/crates.io-index)", + "hashbrown 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "httparse 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "mime 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", - "mime_guess 2.0.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", - "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -101,22 +106,165 @@ dependencies = [ "serde_urlencoded 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", "sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-current-thread 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "trust-dns-resolver 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "actix-router" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", + "string 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "actix-rt" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "actix-threadpool 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-current-thread 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "actix-server" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "actix-rt 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-server-config 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-service 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", + "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-signal 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "actix-server-config" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "actix-service" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "actix-threadpool" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "threadpool 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "actix-utils" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-service 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "either 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-current-thread 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "actix-web" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-http 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-router 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-rt 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-server 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-server-config 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-service 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-threadpool 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-utils 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-web-codegen 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "awc 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "encoding 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "hashbrown 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "mime 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", + "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_urlencoded 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", + "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "v_htmlescape 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "actix-web-actors" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "actix 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-http 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-web 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "actix-web-codegen" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "actix_derive" -version = "0.3.2" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", @@ -187,6 +335,28 @@ name = "autocfg" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "awc" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-http 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-service 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "mime 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", + "percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_urlencoded 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "backtrace" version = "0.3.30" @@ -208,15 +378,6 @@ dependencies = [ "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "base64" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "safemem 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "base64" version = "0.10.1" @@ -372,15 +533,9 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "cookie" -version = "0.11.1" +name = "copyless" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "base64 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", - "ring 0.13.5 (registry+https://github.com/rust-lang/crates.io-index)", - "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", - "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", -] [[package]] name = "crc" @@ -475,6 +630,30 @@ dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "derive_more" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "derive_more" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "dirs" version = "1.0.5" @@ -562,6 +741,16 @@ name = "encoding_index_tests" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "enum-as-inner" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "env_logger" version = "0.6.1" @@ -574,14 +763,6 @@ dependencies = [ "termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "error-chain" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "backtrace 0.3.30 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "failure" version = "0.1.5" @@ -642,15 +823,6 @@ name = "futures" version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "futures-cpupool" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "gcc" version = "0.3.55" @@ -682,6 +854,16 @@ dependencies = [ "scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "hashbrown" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "hashbrown" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "heck" version = "0.3.1" @@ -748,14 +930,13 @@ dependencies = [ [[package]] name = "ipconfig" -version = "0.1.9" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "error-chain 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "socket2 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "widestring 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "widestring 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", - "winreg 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "winreg 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -825,11 +1006,6 @@ name = "lazy_static" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "lazycell" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "libc" version = "0.2.58" @@ -858,6 +1034,14 @@ dependencies = [ "scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "lock_api" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "log" version = "0.3.9" @@ -896,8 +1080,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "medea" version = "0.1.0-dev" dependencies = [ - "actix 0.7.9 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-web 0.7.19 (registry+https://github.com/rust-lang/crates.io-index)", + "actix 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-web 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-web-actors 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "bb8 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "bb8-redis 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -980,17 +1165,6 @@ dependencies = [ "unicase 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "mime_guess" -version = "2.0.0-alpha.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "mime 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", - "phf 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)", - "phf_codegen 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)", - "unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "miniz-sys" version = "0.1.12" @@ -1144,6 +1318,16 @@ dependencies = [ "parking_lot_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "parking_lot" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lock_api 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "parking_lot_core" version = "0.4.0" @@ -1157,44 +1341,24 @@ dependencies = [ ] [[package]] -name = "percent-encoding" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "phf" -version = "0.7.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "phf_shared 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "phf_codegen" -version = "0.7.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "phf_generator 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)", - "phf_shared 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "phf_generator" -version = "0.7.24" +name = "parking_lot_core" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "phf_shared 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "phf_shared" -version = "0.7.24" +name = "percent-encoding" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "siphasher 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", -] [[package]] name = "proc-macro2" @@ -1238,18 +1402,6 @@ dependencies = [ "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "rand" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "rand" version = "0.6.5" @@ -1440,17 +1592,6 @@ dependencies = [ "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "ring" -version = "0.13.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", - "untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "rust-crypto" version = "0.2.36" @@ -1499,11 +1640,6 @@ name = "ryu" version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "safemem" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "scoped-tls" version = "1.0.0" @@ -1519,6 +1655,11 @@ name = "scopeguard" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "scopeguard" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "semver" version = "0.1.20" @@ -1650,11 +1791,6 @@ dependencies = [ "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "siphasher" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "slab" version = "0.4.2" @@ -1857,6 +1993,14 @@ dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "threadpool" +version = "1.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "time" version = "0.1.42" @@ -2069,49 +2213,19 @@ dependencies = [ "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "tower-service" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "trust-dns-proto" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", - "socket2 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-udp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "trust-dns-proto" -version = "0.6.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "enum-as-inner 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "socket2 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2125,20 +2239,20 @@ dependencies = [ [[package]] name = "trust-dns-resolver" -version = "0.10.3" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "ipconfig 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "ipconfig 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "lru-cache 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "resolv-conf 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", - "trust-dns-proto 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "trust-dns-proto 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2146,14 +2260,6 @@ name = "ucd-util" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "unicase" -version = "1.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "unicase" version = "2.4.0" @@ -2196,11 +2302,6 @@ dependencies = [ "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "untrusted" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "url" version = "1.7.2" @@ -2222,43 +2323,6 @@ name = "utf8-ranges" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "uuid" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "v_escape" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "v_escape_derive 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "v_escape_derive" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "nom 4.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "v_htmlescape" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "v_escape 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "version_check" version = "0.1.5" @@ -2402,7 +2466,7 @@ dependencies = [ [[package]] name = "widestring" -version = "0.2.2" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -2453,7 +2517,7 @@ dependencies = [ [[package]] name = "winreg" -version = "0.5.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2486,10 +2550,21 @@ dependencies = [ [metadata] "checksum Inflector 0.11.4 (registry+https://github.com/rust-lang/crates.io-index)" = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" -"checksum actix 0.7.9 (registry+https://github.com/rust-lang/crates.io-index)" = "6c616db5fa4b0c40702fb75201c2af7f8aa8f3a2e2c1dda3b0655772aa949666" -"checksum actix-net 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "8bebfbe6629e0131730746718c9e032b58f02c6ce06ed7c982b9fef6c8545acd" -"checksum actix-web 0.7.19 (registry+https://github.com/rust-lang/crates.io-index)" = "b0ac60f86c65a50b140139f499f4f7c6e49e4b5d88fbfba08e4e3975991f7bf4" -"checksum actix_derive 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4300e9431455322ae393d43a2ba1ef96b8080573c0fc23b196219efedfb6ba69" +"checksum actix 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)" = "671ce3d27313f236827a5dd153a1073ad03ef31fc77f562020263e7830cf1ef7" +"checksum actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9f2c11af4b06dc935d8e1b1491dad56bfb32febc49096a91e773f8535c176453" +"checksum actix-connect 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d7fbab0d79b2f3415a79570e3db12eaa75c26239541e613b832655145a5e9488" +"checksum actix-http 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "81aa906e74d2cd5f219f596003b0fd94d05e75a4a448b12afea66e7658b6c9e1" +"checksum actix-router 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "23224bb527e204261d0291102cb9b52713084def67d94f7874923baefe04ccf7" +"checksum actix-rt 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ed0424cdf6542a43b32a8885c7c5099bf4110fad9b50d7fb220ab9c038ecf5ec" +"checksum actix-server 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ba8c936356c882420eab87051b12ca1926dc42348863d05fff7eb151df9cddbb" +"checksum actix-server-config 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e78703f07d0bd08b426b482d53569d84f1e1929024f0431b3a5a2dc0c1c60e0f" +"checksum actix-service 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "aaecc01bbc595ebd7a563a7d4f8a607d0b964bb55273c6f362b0b02c26508cf2" +"checksum actix-threadpool 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1c29f7c554d56b3841f4bb85d5b3dee01ba536e1307679f56eb54de28aaec3fb" +"checksum actix-utils 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7ab47adc5e67fc83a0c58570b40531f09814a5daa969e0d913ebeab908a43508" +"checksum actix-web 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6478c837afbe528cfe468976e67b6b81a6330414b00234c4546a158f9f0739fc" +"checksum actix-web-actors 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9c54489d9bcfce84a5096ba47db6a4dd2cc493987e97a987a4c5a7519b31f26d" +"checksum actix-web-codegen 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3fe9e3cdec1e645b675f354766e0688c5705021c85ab3cf739be1c8999b91c76" +"checksum actix_derive 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0bf5f6d7bf2d220ae8b4a7ae02a572bb35b7c4806b24049af905ab8110de156c" "checksum adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7e522997b529f05601e05166c07ed17789691f562762c7f3b987263d2dedee5c" "checksum aho-corasick 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ca972c2ea5f742bfce5687b9aef75506a764f61d37f8f649047846a9686ddb66" "checksum aho-corasick 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e6f484ae0c99fec2e858eb6134949117399f222608d84cadb3f58c1f97c2364c" @@ -2499,10 +2574,10 @@ dependencies = [ "checksum ascii 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a5fc969a8ce2c9c0c4b0429bb8431544f6658283c8326ba5ff8c762b75369335" "checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" "checksum autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "0e49efa51329a5fd37e7c79db4621af617cd4e3e5bc224939808d076077077bf" +"checksum awc 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c5133e9ca1d7f0560fb271f20286be3e896dac5736040a62a7ef1d62003160b6" "checksum backtrace 0.3.30 (registry+https://github.com/rust-lang/crates.io-index)" = "ada4c783bb7e7443c14e0480f429ae2cc99da95065aeab7ee1b81ada0419404f" "checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6" "checksum base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" -"checksum base64 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "489d6c0ed21b11d038c31b6ceccca973e65d73ba3bd8ecb9a2babf5546164643" "checksum bb8 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6ac04c3b2d3327a583c9a93b6c5ab4316e6609f5ec84b71b89ebe518e0edbad2" "checksum bb8-redis 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9817f38c173f0da1581b923b90e66750a090413ad67a20980d5ad64141bab476" "checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" @@ -2521,7 +2596,7 @@ dependencies = [ "checksum config 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "f9107d78ed62b3fa5a86e7d18e647abed48cfd8f8fab6c72f4cdb982d196f7e6" "checksum console_error_panic_hook 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "b8d976903543e0c48546a91908f21588a680a8c8f984df9a5d69feccb2b2a211" "checksum constant_time_eq 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8ff012e225ce166d4422e0e78419d901719760f62ae2b7969ca6b564d1b54a9e" -"checksum cookie 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)" = "99be24cfcf40d56ed37fd11c2123be833959bbc5bddecb46e1c2e442e15fa3e0" +"checksum copyless 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "f8ffa29b14f03d473f1558c789d020fe41bb7790774f429ff818f4ed9a6f9a0e" "checksum crc 1.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d663548de7f5cca343f1e0a48d14dcfb0e9eb4e079ec58883b7251539fa10aeb" "checksum crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" "checksum crossbeam 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)" = "bd66663db5a988098a89599d4857919b3acf7f61402e61365acfd3919857b9be" @@ -2532,6 +2607,8 @@ dependencies = [ "checksum crossbeam-epoch 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "04c9e3102cc2d69cd681412141b390abd55a362afc1540965dad0ad4d34280b4" "checksum crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7c979cd6cfe72335896575c6b5688da489e420d36a27a0b9eb0c73db574b4a4b" "checksum crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f8306fcef4a7b563b76b7dd949ca48f52bc1141aa067d2ea09565f3e2652aa5c" +"checksum derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6d944ac6003ed268757ef1ee686753b57efc5fcf0ebe7b64c9fc81e7e32ff839" +"checksum derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a141330240c921ec6d074a3e188a7c7ef95668bb95e7d44fa0e5778ec2a7afe" "checksum dirs 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3fd78930633bd1c6e35c4b42b1df7b0cbc6bc191146e512bb3bedf243fcc3901" "checksum dotenv 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c0d0a1279c96732bc6800ce6337b6a614697b0e74ae058dc03c62ebeb78b4d86" "checksum dtoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "ea57b42383d091c85abcc2706240b94ab2a8fa1fc81c10ff23c4de06e2a90b5e" @@ -2543,8 +2620,8 @@ dependencies = [ "checksum encoding-index-singlebyte 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3351d5acffb224af9ca265f435b859c7c01537c0849754d3db3fdf2bfe2ae84a" "checksum encoding-index-tradchinese 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fd0e20d5688ce3cab59eb3ef3a2083a5c77bf496cb798dc6fcdb75f323890c18" "checksum encoding_index_tests 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "a246d82be1c9d791c5dfde9a2bd045fc3cbba3fa2b11ad558f27d01712f00569" +"checksum enum-as-inner 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3d58266c97445680766be408285e798d3401c6d4c378ec5552e78737e681e37d" "checksum env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b61fa891024a945da30a9581546e8cfaf5602c7b3f4c137a2805cf388f92075a" -"checksum error-chain 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6930e04918388a9a2e41d518c25cf679ccafe26733fb4127dbf21993f2575d46" "checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" "checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" "checksum flate2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f87e68aa82b2de08a6e037f1385455759df6e445a8df5e005b4297191dbf18aa" @@ -2553,10 +2630,11 @@ dependencies = [ "checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" "checksum futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)" = "a2037ec1c6c1c4f79557762eab1f7eae1f64f6cb418ace90fae88f0942b60139" -"checksum futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "ab90cde24b3319636588d0c35fe03b1333857621051837ed769faefb4c2162e4" "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" "checksum h2 0.1.23 (registry+https://github.com/rust-lang/crates.io-index)" = "1e42e3daed5a7e17b12a0c23b5b2fbff23a925a570938ebee4baca1a9a1a2240" "checksum hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3bae29b6653b3412c2e71e9d486db9f9df5d701941d86683005efb9f2d28e3da" +"checksum hashbrown 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "29fba9abe4742d586dfd0c06ae4f7e73a1c2d86b856933509b269d82cdf06e18" +"checksum hashbrown 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e1de41fb8dba9714efd92241565cdff73f78508c95697dd56787d3cba27e2353" "checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" "checksum hostname 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "21ceb46a83a85e824ef93669c8b390009623863b5c195d1ba747292c0c72f94e" "checksum http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)" = "eed324f0f0daf6ec10c474f150505af2c143f251722bf9dbd1261bd1f2ee2c1a" @@ -2565,7 +2643,7 @@ dependencies = [ "checksum idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e" "checksum indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7e81a7c05f79578dbc15793d8b619db9ba32b4577003ef3af1a91c416798c58d" "checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08" -"checksum ipconfig 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "08f7eadeaf4b52700de180d147c4805f199854600b36faa963d91114827b2ffc" +"checksum ipconfig 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "aa79fa216fbe60834a9c0737d7fcd30425b32d1c58854663e24d4c4b328ed83f" "checksum isatty 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e31a8281fc93ec9693494da65fbf28c0c2aa60a2eaec25dc58e2f31952e95edc" "checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" "checksum js-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "9987e7c13a91d9cf0efe59cca48a3a7a70e2b11695d5a4640f85ae71e28f5e73" @@ -2573,11 +2651,11 @@ dependencies = [ "checksum language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a91d884b6667cd606bb5a69aa0c99ba811a115fc68915e7056ec08a46e93199a" "checksum lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "76f033c7ad61445c5b347c7382dd1237847eb1bce590fe50365dcb33d546be73" "checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" -"checksum lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f" "checksum libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)" = "6281b86796ba5e4366000be6e9e18bf35580adf9e63fbe2294aadb587613a319" "checksum linked-hash-map 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6d262045c5b87c0861b3f004610afd0e2c851e2908d08b6c870cbb9d5f494ecd" "checksum linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ae91b68aebc4ddb91978b11a1b02ddd8602a05ec19002801c5666000e05e0f83" "checksum lock_api 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "62ebf1391f6acad60e5c8b43706dde4582df75c06698ab44511d15016bc2442c" +"checksum lock_api 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ed946d4529956a20f2d63ebe1b69996d5a2137c91913fe3ebbeff957f5bca7ff" "checksum log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b" "checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6" "checksum lru-cache 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "31e24f1ad8321ca0e8a1e0ac13f23cb668e6f5466c2c57319f6a5cf1cc8e3b1c" @@ -2588,7 +2666,6 @@ dependencies = [ "checksum memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0f9dc261e2b62d7a622bf416ea3c5245cdd5d9a7fcc428c0d06804dfce1775b3" "checksum memory_units 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8452105ba047068f40ff7093dd1d9da90898e63dd61736462e9cdda6a90ad3c3" "checksum mime 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)" = "3e27ca21f40a310bd06d9031785f4801710d566c184a6e15bad4f1d9b65f9425" -"checksum mime_guess 2.0.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)" = "30de2e4613efcba1ec63d8133f344076952090c122992a903359be5a4f99c3ed" "checksum miniz-sys 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "1e9e3ae51cea1576ceba0dde3d484d30e6e5b86dee0b2d412fe3a16a15c98202" "checksum miniz_oxide 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c468f2369f07d651a5d0bb2c9079f8488a66d5466efe42d0c5c6466edcb7f71e" "checksum miniz_oxide_c_api 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b7fe927a42e3807ef71defb191dc87d4e24479b221e67015fe38ae2b7b447bab" @@ -2606,18 +2683,15 @@ dependencies = [ "checksum numtoa 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b8f8bdf33df195859076e54ab11ee78a1b208382d3a26ec40d142ffc1ecc49ef" "checksum owning_ref 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "49a4b8ea2179e6a2e27411d3bca09ca6dd630821cf6894c6c7c8467a8ee7ef13" "checksum parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ab41b4aed082705d1056416ae4468b6ea99d52599ecf3169b00088d43113e337" +"checksum parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fa7767817701cce701d5585b9c4db3cdd02086398322c1d7e8bf5094a96a2ce7" "checksum parking_lot_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "94c8c7923936b28d546dfd14d4472eaf34c99b14e1c973a32b3e6d4eb04298c9" +"checksum parking_lot_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cb88cb1cb3790baa6776844f968fea3be44956cf184fa1be5a03341f5491278c" "checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" -"checksum phf 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)" = "b3da44b85f8e8dfaec21adae67f95d93244b2ecf6ad2a692320598dcc8e6dd18" -"checksum phf_codegen 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)" = "b03e85129e324ad4166b06b2c7491ae27fe3ec353af72e72cd1654c7225d517e" -"checksum phf_generator 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)" = "09364cc93c159b8b06b1f4dd8a4398984503483891b0c26b867cf431fb132662" -"checksum phf_shared 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)" = "234f71a15de2288bcb7e3b6515828d22af7ec8598ee6d24c3b526fa0a80b67a0" "checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" "checksum quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)" = "faf4799c5d274f3868a4aae320a0a182cbd2baee377b378f080e16a23e9d80db" "checksum rand 0.3.23 (registry+https://github.com/rust-lang/crates.io-index)" = "64ac302d8f83c0c1974bf758f6b041c6c8ada916fbb44a609158ca8b064cc76c" "checksum rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" -"checksum rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c618c47cd3ebd209790115ab837de41425723956ad3ce2e6a7f09890947cacb9" "checksum rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" "checksum rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" "checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" @@ -2638,7 +2712,6 @@ dependencies = [ "checksum regex-syntax 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "f9ec002c35e86791825ed294b50008eea9ddfc8def4420124fbc6b08db834957" "checksum regex-syntax 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "dcfd8681eebe297b81d98498869d4aae052137651ad7b96822f09ceb690d0a96" "checksum resolv-conf 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b263b4aa1b5de9ffc0054a2386f96992058bb6870aab516f8cdeb8a667d56dcb" -"checksum ring 0.13.5 (registry+https://github.com/rust-lang/crates.io-index)" = "2c4db68a2e35f3497146b7e4563df7d4773a2433230c5e4b448328e31740458a" "checksum rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)" = "f76d05d3993fd5f4af9434e8e436db163a12a9d40e1a58a726f27a01dfd12a2a" "checksum rust-ini 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3e52c148ef37f8c375d49d5a73aa70713125b7f19095948a923f80afdeb22ec2" "checksum rustc-demangle 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "a7f4dccf6f4891ebcc0c39f9b6eb1a83b9bf5d747cb439ec6fba4f3b977038af" @@ -2646,10 +2719,10 @@ dependencies = [ "checksum rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "c5f5376ea5e30ce23c03eb77cbe4962b988deead10910c372b226388b594c084" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" "checksum ryu 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "b96a9549dc8d48f2c283938303c4b5a77aa29bfbc5b54b084fb1630408899a8f" -"checksum safemem 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8dca453248a96cb0749e36ccdfe2b0b4e54a61bfef89fb97ec621eb8e0a93dd9" "checksum scoped-tls 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2" "checksum scoped_threadpool 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "1d51f5df5af43ab3f1360b429fa5e0152ac5ce8c0bd6485cae490332e96846a8" "checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" +"checksum scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b42e15e59b18a828bbf5c58ea01debb36b9b096346de35d941dcb89009f24a0d" "checksum semver 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)" = "d4f410fedcf71af0345d7607d246e7ad15faaadd49d240ee3b24e5dc21a820ac" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" @@ -2666,7 +2739,6 @@ dependencies = [ "checksum sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d" "checksum signal-hook 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "72ab58f1fda436857e6337dcb6a5aaa34f16c5ddc87b3a8b6ef7a212f90b9c5a" "checksum signal-hook-registry 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cded4ffa32146722ec54ab1f16320568465aa922aa9ab4708129599740da85d7" -"checksum siphasher 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0b8de496cf83d4ed58b6be86c3a275b8602f6ffe98d3024a869e124147a9a3ac" "checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" "checksum slog 2.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1e1a2eec401952cd7b12a84ea120e2d57281329940c3f93c2bf04f462539508e" "checksum slog-async 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e544d16c6b230d84c866662fe55e31aacfca6ae71e6fc49ae9a311cb379bfc2f" @@ -2690,6 +2762,7 @@ dependencies = [ "checksum thread-id 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a9539db560102d1cef46b8b78ce737ff0bb64e7e18d35b2a5688f7d097d0ff03" "checksum thread_local 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "8576dbbfcaef9641452d5cf0df9b0e7eeab7694956dd33bb61515fb8f18cfdd5" "checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" +"checksum threadpool 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e2f0c90a5f3459330ac8bc0d2f879c693bb7a2f59689c1083fc4ef83834da865" "checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" "checksum tokio 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)" = "ec2ffcf4bcfc641413fa0f1427bf8f91dfc78f56a6559cbf50e04837ae442a87" "checksum tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5c501eceaf96f0e1793cf26beb63da3d11c738c4a943fdf3746d81d64684c39f" @@ -2707,26 +2780,18 @@ dependencies = [ "checksum tokio-udp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "66268575b80f4a4a710ef83d087fdfeeabdce9b74c797535fbac18a2cb906e92" "checksum tokio-uds 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "037ffc3ba0e12a0ab4aca92e5234e0dedeb48fddf6ccd260f1f150a36a9f2445" "checksum toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "758664fc71a3a69038656bee8b6be6477d2a6c315a6b81f7081f591bffa4111f" -"checksum tower-service 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b32f72af77f1bfe3d3d4da8516a238ebe7039b51dd8637a09841ac7f16d2c987" -"checksum trust-dns-proto 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0838272e89f1c693b4df38dc353412e389cf548ceed6f9fd1af5a8d6e0e7cf74" -"checksum trust-dns-proto 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "09144f0992b0870fa8d2972cc069cbf1e3c0fda64d1f3d45c4d68d0e0b52ad4e" -"checksum trust-dns-resolver 0.10.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8a9f877f7a1ad821ab350505e1f1b146a4960402991787191d6d8cab2ce2de2c" +"checksum trust-dns-proto 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5559ebdf6c2368ddd11e20b11d6bbaf9e46deb803acd7815e93f5a7b4a6d2901" +"checksum trust-dns-resolver 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6c9992e58dba365798803c0b91018ff6c8d3fc77e06977c4539af2a6bfe0a039" "checksum ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "535c204ee4d8434478593480b8f86ab45ec9aae0e83c568ca81abf0fd0e88f86" -"checksum unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7f4765f83163b74f957c797ad9253caf97f103fb064d3999aea9568d09fc8a33" "checksum unicase 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a84e5511b2a947f3ae965dcb29b13b7b1691b6e7332cf5dbc1744138d5acb7f6" "checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" "checksum unicode-normalization 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "141339a08b982d942be2ca06ff8b076563cbe223d1befd5450716790d44e2426" "checksum unicode-segmentation 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1967f4cdfc355b37fd76d2a954fb2ed3871034eb4f26d60537d88795cfc332a9" "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" "checksum unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56" -"checksum untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "55cd1f4b4e96b46aeb8d4855db4a7a9bd96eeeb5c6a1ab54593328761642ce2f" "checksum url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dd4e7c0d531266369519a4aa4f399d748bd37043b00bde1e4ff1f60a120b355a" "checksum utf8-ranges 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a1ca13c08c41c9c3e04224ed9ff80461d97e121589ff27c753a16cb10830ae0f" "checksum utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "796f7e48bef87609f7ade7e06495a87d5cd06c7866e6a5cbfceffc558a243737" -"checksum uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)" = "90dbc611eb48397705a6b0f6e917da23ae517e4d127123d2cf7674206627d32a" -"checksum v_escape 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8865501b78eef9193c1b45486acf18ba889e5662eba98854d6fc59d8ecf3542d" -"checksum v_escape_derive 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "306896ff4b75998501263a1dc000456de442e21d68fe8c8bdf75c66a33a58e23" -"checksum v_htmlescape 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7fbbe0fa88dd36f9c8cf61a218d4b953ba669de4d0785832f33cc72bd081e1be" "checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" "checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" "checksum wasm-bindgen 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)" = "b7ccc7b93cfd13e26700a9e2e41e6305f1951b87e166599069f77d10358100e6" @@ -2741,7 +2806,7 @@ dependencies = [ "checksum web-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "540b8259eb242ff3a566fa0140bda03a4ece4e5c226e1284b5c95dddcd4341f6" "checksum wee_alloc 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "31d4e6572d21ac55398bc91db827f48c3fdb8152ae60f4c358f6780e1035ffcc" "checksum weedle 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bcc44aa200daee8b1f3a004beaf16554369746f1b4486f0cf93b0caf8a3c2d1e" -"checksum widestring 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7157704c2e12e3d2189c507b7482c52820a16dfa4465ba91add92f266667cadb" +"checksum widestring 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "effc0e4ff8085673ea7b9b2e3c73f6bd4d118810c9009ed8f1e16bd96c331db6" "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" "checksum winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f10e386af2b13e47c89e7236a7a14a086791a2b88ebad6df9bf42040195cf770" "checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" @@ -2749,7 +2814,7 @@ dependencies = [ "checksum winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7168bab6e1daee33b4557efd0e95d5ca70a03706d39fa5f3fe7a236f584b03c9" "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" "checksum wincolor 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "561ed901ae465d6185fa7864d63fbd5720d0ef718366c9a4dc83cf6170d7e9ba" -"checksum winreg 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a27a759395c1195c4cc5cda607ef6f8f6498f64e78f7900f5de0a127a424704a" +"checksum winreg 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "daf67b95d0b1bf421c4f11048d63110ca3719977169eec86396b614c8942b6e0" "checksum winutil 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7daf138b6b14196e3830a588acf1e86966c694d3e8fb026fb105b8b5dca07e6e" "checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" "checksum yaml-rust 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "65923dd1784f44da1d2c3dbbc5e822045628c590ba72123e1c73d3c230c4434d" diff --git a/Cargo.toml b/Cargo.toml index 8a7704738..d6b8bcf20 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,8 +20,9 @@ members = [ lto = "thin" [dependencies] -actix = "0.7" -actix-web = "0.7" +actix = "0.8" +actix-web = "1.0" +actix-web-actors = "1.0" bb8 = "0.3" bb8-redis = "0.3" config = "0.9" diff --git a/docker-compose.yml b/docker-compose.yml index 86015777f..88e1a7473 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,4 @@ -version: 2 +version: "2" services: coturn: diff --git a/src/api/client/server.rs b/src/api/client/server.rs index 8b27d0675..92e48a524 100644 --- a/src/api/client/server.rs +++ b/src/api/client/server.rs @@ -1,10 +1,12 @@ //! HTTP server for handling WebSocket connections of Client API. use actix_web::{ - http, middleware, server, ws, App, AsyncResponder, FutureResponse, - HttpRequest, HttpResponse, Path, State, + http, middleware, + web::{Data, Path}, + App, HttpRequest, HttpResponse, HttpServer, }; -use futures::{future, Future as _}; +use actix_web_actors::ws; +use futures::{future, Future as _, Future, IntoFuture}; use serde::Deserialize; use crate::{ @@ -19,6 +21,9 @@ use crate::{ log::prelude::*, signalling::{RoomId, RoomsRepository}, }; +use actix_web::{client::WsClientError, web::Payload, Error}; +use futures::future::Either; +use std::convert::TryInto; /// Parameters of new WebSocket connection creation HTTP request. #[derive(Debug, Deserialize)] @@ -33,30 +38,31 @@ struct RequestParams { /// Handles all HTTP requests, performs WebSocket handshake (upgrade) and starts /// new [`WsSession`] for WebSocket connection. +// TODO: maybe not use Box? fn ws_index( - (r, info, state): ( - HttpRequest, - Path, - State, - ), -) -> FutureResponse { + r: HttpRequest, + info: Path, + state: Data, + payload: Payload, +) -> Box> { debug!("Request params: {:?}", info); match state.rooms.get(info.room_id) { - Some(room) => room - .send(Authorize { + Some(room) => Box::new( + room.send(Authorize { member_id: info.member_id, credentials: info.credentials.clone(), }) .from_err() .and_then(move |res| match res { Ok(_) => ws::start( - &r.drop_state(), WsSession::new( info.member_id, room, state.config.idle_timeout, ), + &r, // TODO: drop_state() + payload, ), Err(AuthorizationError::MemberNotExists) => { Ok(HttpResponse::NotFound().into()) @@ -64,9 +70,9 @@ fn ws_index( Err(AuthorizationError::InvalidCredentials) => { Ok(HttpResponse::Forbidden().into()) } - }) - .responder(), - None => future::ok(HttpResponse::NotFound().into()).responder(), + }), + ), + None => Box::new(future::ok(HttpResponse::NotFound().into())), } } @@ -82,16 +88,20 @@ pub struct Context { /// Starts HTTP server for handling WebSocket connections of Client API. pub fn run(rooms: RoomsRepository, config: Conf) { let server_addr = config.server.bind_addr(); - - server::new(move || { - App::with_state(Context { - rooms: rooms.clone(), - config: config.rpc.clone(), - }) - .middleware(middleware::Logger::default()) - .resource("/ws/{room_id}/{member_id}/{credentials}", |r| { - r.method(http::Method::GET).with(ws_index) - }) + //.service(web::resource("/path1").to(|| HttpResponse::Ok())) + HttpServer::new(move || { + App::new() + .data(Context { + rooms: rooms.clone(), + config: config.rpc.clone(), + }) + .service( + actix_web::web::resource( + "/ws/{room_id}/{member_id}/{credentials}", + ) + .to_async(ws_index), + ) + .wrap(middleware::Logger::default()) }) .bind(server_addr) .unwrap() diff --git a/src/api/client/session.rs b/src/api/client/session.rs index bfba164a5..56e460f5c 100644 --- a/src/api/client/session.rs +++ b/src/api/client/session.rs @@ -6,7 +6,7 @@ use actix::{ fut::wrap_future, Actor, ActorContext, ActorFuture, Addr, AsyncContext, Handler, Message, StreamHandler, }; -use actix_web::ws::{self, CloseReason, WebsocketContext}; +use actix_web_actors::ws::{self, CloseReason, WebsocketContext}; use futures::future::Future; use medea_client_api_proto::{ClientMsg, ServerMsg}; diff --git a/src/main.rs b/src/main.rs index 8009c9f05..ab5305382 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,12 +13,12 @@ use actix::prelude::*; use dotenv::dotenv; use log::prelude::*; -use crate::turn::new_turn_auth_service; use crate::{ api::{client::server, control::Member}, conf::Conf, media::create_peers, signalling::{Room, RoomsRepository}, + turn::new_turn_auth_service, }; fn main() { @@ -41,14 +41,15 @@ fn main() { let turn_auth_service = new_turn_auth_service(&config).expect("Unable to start turn service"); - let room = Room::new( - 1, - members, - peers, - config.rpc.reconnect_timeout, - turn_auth_service, - ); - let room = Arbiter::start(move |_| room); + + let rpc_reconnect_timeout = config.rpc.reconnect_timeout; + + let arbiter = Arbiter::new(); + let room = Room::start_in_arbiter(&arbiter, move |_| { + Room::new(1, members, peers, rpc_reconnect_timeout, turn_auth_service) + }); + + // let room = Arbiter::start(move |_| room); let rooms = hashmap! {1 => room}; let rooms_repo = RoomsRepository::new(rooms); diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 5fff751f0..e751742fd 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -18,7 +18,6 @@ use hashbrown::HashMap; use medea_client_api_proto::Event; -use crate::signalling::RoomId; use crate::{ api::{ client::rpc_connection::{ @@ -31,7 +30,7 @@ use crate::{ media::IceUser, signalling::{ room::{ActFuture, CloseRoom, RoomError}, - Room, + Room, RoomId, }, turn::{TurnAuthService, TurnServiceErr, UnreachablePolicy}, }; diff --git a/src/turn/service.rs b/src/turn/service.rs index 3d5f238b1..4648d6d96 100644 --- a/src/turn/service.rs +++ b/src/turn/service.rs @@ -181,7 +181,10 @@ pub fn new_turn_auth_service( static_user: None, }; - Ok(Box::new(Arbiter::start(|_| service))) + let arbiter = Arbiter::new(); + let service = Service::start_in_arbiter(&arbiter, move |_| service); + + Ok(Box::new(service)) } impl Service { From ba4d2646fe1a6db817c5b6fe987a58f2e1f68d70 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 19 Jun 2019 20:13:39 +0300 Subject: [PATCH 168/735] Set merge_imports true in rustfmt config --- .rustfmt.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.rustfmt.toml b/.rustfmt.toml index f35e36026..a53c6ac3e 100644 --- a/.rustfmt.toml +++ b/.rustfmt.toml @@ -13,3 +13,5 @@ error_on_line_overflow = true error_on_unformatted = true unstable_features = true + +merge_imports = true From 264f1ffc1c267d553e8be7312f57abd6601afb70 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 19 Jun 2019 20:27:39 +0300 Subject: [PATCH 169/735] Fix warnings --- src/api/client/server.rs | 11 ++++------- src/main.rs | 1 - src/turn/service.rs | 4 ++-- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/api/client/server.rs b/src/api/client/server.rs index 92e48a524..84d308af6 100644 --- a/src/api/client/server.rs +++ b/src/api/client/server.rs @@ -1,12 +1,12 @@ //! HTTP server for handling WebSocket connections of Client API. use actix_web::{ - http, middleware, - web::{Data, Path}, - App, HttpRequest, HttpResponse, HttpServer, + middleware, + web::{Data, Path, Payload}, + App, Error, HttpRequest, HttpResponse, HttpServer, }; use actix_web_actors::ws; -use futures::{future, Future as _, Future, IntoFuture}; +use futures::{future, Future}; use serde::Deserialize; use crate::{ @@ -21,9 +21,6 @@ use crate::{ log::prelude::*, signalling::{RoomId, RoomsRepository}, }; -use actix_web::{client::WsClientError, web::Payload, Error}; -use futures::future::Either; -use std::convert::TryInto; /// Parameters of new WebSocket connection creation HTTP request. #[derive(Debug, Deserialize)] diff --git a/src/main.rs b/src/main.rs index ab5305382..a7cd7e4db 100644 --- a/src/main.rs +++ b/src/main.rs @@ -49,7 +49,6 @@ fn main() { Room::new(1, members, peers, rpc_reconnect_timeout, turn_auth_service) }); - // let room = Arbiter::start(move |_| room); let rooms = hashmap! {1 => room}; let rooms_repo = RoomsRepository::new(rooms); diff --git a/src/turn/service.rs b/src/turn/service.rs index 4648d6d96..2d282124b 100644 --- a/src/turn/service.rs +++ b/src/turn/service.rs @@ -46,7 +46,7 @@ impl TurnAuthService for Addr { member_id: u64, room_id: RoomId, policy: UnreachablePolicy, - ) -> Box> { + ) -> Box> { Box::new( self.send(CreateIceUser { member_id, @@ -69,7 +69,7 @@ impl TurnAuthService for Addr { fn delete( &self, users: Vec, - ) -> Box> { + ) -> Box> { // leave only non static users let users: Vec = users.into_iter().filter(|u| !u.is_static()).collect(); From acd59698c28aaad22b16ce34f8e2507b1b9b5b2a Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 20 Jun 2019 14:44:37 +0300 Subject: [PATCH 170/735] Fix ping pong test --- Cargo.lock | 32 +++++++++++++ Cargo.toml | 3 ++ src/api/client/server.rs | 100 ++++++++++++++++++++++++--------------- src/signalling/room.rs | 34 ++++++++----- 4 files changed, 119 insertions(+), 50 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3a1b70c31..b5f07c9ce 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -113,6 +113,34 @@ dependencies = [ "trust-dns-resolver 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "actix-http-test" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-rt 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-server 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-service 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-utils 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "awc 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_urlencoded 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", + "sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "actix-router" version = "0.1.5" @@ -1081,6 +1109,9 @@ name = "medea" version = "0.1.0-dev" dependencies = [ "actix 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-http 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-http-test 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "actix-web 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "actix-web-actors 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "bb8 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2554,6 +2585,7 @@ dependencies = [ "checksum actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9f2c11af4b06dc935d8e1b1491dad56bfb32febc49096a91e773f8535c176453" "checksum actix-connect 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d7fbab0d79b2f3415a79570e3db12eaa75c26239541e613b832655145a5e9488" "checksum actix-http 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "81aa906e74d2cd5f219f596003b0fd94d05e75a4a448b12afea66e7658b6c9e1" +"checksum actix-http-test 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7e4ea476df1fe681a9bd2fcc37eff9393fad4a0430975e46d7c657907351f250" "checksum actix-router 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "23224bb527e204261d0291102cb9b52713084def67d94f7874923baefe04ccf7" "checksum actix-rt 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ed0424cdf6542a43b32a8885c7c5099bf4110fad9b50d7fb220ab9c038ecf5ec" "checksum actix-server 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ba8c936356c882420eab87051b12ca1926dc42348863d05fff7eb151df9cddbb" diff --git a/Cargo.toml b/Cargo.toml index d6b8bcf20..ce04cdee0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,6 +23,9 @@ lto = "thin" actix = "0.8" actix-web = "1.0" actix-web-actors = "1.0" +actix-http-test = "0.2" +actix-http = "0.2" +actix-codec = "0.1" bb8 = "0.3" bb8-redis = "0.3" config = "0.9" diff --git a/src/api/client/server.rs b/src/api/client/server.rs index 84d308af6..9db07be48 100644 --- a/src/api/client/server.rs +++ b/src/api/client/server.rs @@ -111,9 +111,12 @@ pub fn run(rooms: RoomsRepository, config: Conf) { mod test { use std::{ops::Add, thread, time::Duration}; - use actix::Arbiter; + use actix::{Actor as _, Arbiter, System}; + use actix_codec::{AsyncRead, Framed}; + use actix_http::HttpService; + use actix_http_test::{TestServer, TestServerRuntime}; use actix_web::{http, test, App}; - use futures::Stream; + use futures::{sink::Sink, Stream}; use crate::{ api::control::Member, @@ -124,6 +127,12 @@ mod test { }; use super::*; + use actix_http::{ + h1::Message::Item, + ws::{Frame, Message}, + }; + use futures::future::IntoFuture; + use tokio::prelude::AsyncWrite; /// Creates [`RoomsRepository`] for tests filled with a single [`Room`]. fn room(conf: Rpc) -> RoomsRepository { @@ -139,7 +148,8 @@ mod test { ice_user: None }, }; - let room = Arbiter::start(move |_| { + let arbiter = Arbiter::new(); + let room = Room::start_in_arbiter(&arbiter, move |_| { Room::new( 1, members, @@ -153,31 +163,26 @@ mod test { } /// Creates test WebSocket server of Client API which can handle requests. - fn ws_server(conf: Conf) -> test::TestServer { - test::TestServer::with_factory(move || { - App::with_state(Context { - rooms: room(conf.rpc.clone()), - config: conf.rpc.clone(), - }) - .resource("/ws/{room_id}/{member_id}/{credentials}", |r| { - r.method(http::Method::GET).with(ws_index) - }) + fn ws_server(conf: Conf) -> TestServerRuntime { + TestServer::new(move || { + HttpService::new( + App::new() + .data(Context { + rooms: room(conf.rpc.clone()), + config: conf.rpc.clone(), + }) + .service( + actix_web::web::resource( + "/ws/{room_id}/{member_id}/{credentials}", + ) + .to_async(ws_index), + ), + ) }) } #[test] - fn responses_with_pong() { - let mut server = ws_server(Conf::default()); - let (read, mut write) = - server.ws_at("/ws/1/1/caller_credentials").unwrap(); - - write.text(r#"{"ping":33}"#); - let (item, _) = server.execute(read.into_future()).unwrap(); - assert_eq!(Some(ws::Message::Text(r#"{"pong":33}"#.into())), item); - } - - #[test] - fn disconnects_on_idle() { + fn ping_pong_and_disconnects_on_idle() { let conf = Conf { rpc: Rpc { idle_timeout: Duration::new(2, 0), @@ -188,19 +193,38 @@ mod test { }; let mut server = ws_server(conf.clone()); - let (read, mut write) = - server.ws_at("/ws/1/1/caller_credentials").unwrap(); - - write.text(r#"{"ping":33}"#); - let (item, read) = server.execute(read.into_future()).unwrap(); - assert_eq!(Some(ws::Message::Text(r#"{"pong":33}"#.into())), item); - - thread::sleep(conf.rpc.idle_timeout.add(Duration::from_secs(1))); - - let (item, _) = server.execute(read.into_future()).unwrap(); - assert_eq!( - Some(ws::Message::Close(Some(ws::CloseCode::Normal.into()))), - item - ); + let mut socket = server.ws_at("/ws/1/1/caller_credentials").unwrap(); + + socket + .force_send(Message::Text(r#"{"ping": 33}"#.into())) + .unwrap(); + + server.block_on(socket + .flush() + .into_future() + .map_err(|_| ()) + .and_then(|socket| { + socket.into_future().map_err(|_| ()).and_then(move |(item, read)| { + assert_eq!( + Some(ws::Frame::Text(Some(r#"{"pong":33}"#.into()))), + item + ); + + thread::sleep( + conf.rpc.idle_timeout.add(Duration::from_secs(1)), + ); + + read.into_future().map_err(|(e, _)| panic!("{:?}", e)).map( + |(item, _)| { + assert_eq!( + Some(ws::Frame::Close(Some( + ws::CloseCode::Normal.into() + ))), + item + ); + }, + ) + }) + })).unwrap(); } } diff --git a/src/signalling/room.rs b/src/signalling/room.rs index caffde727..835f5d56a 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -474,7 +474,8 @@ mod test { ice_user: None }, }; - Arbiter::start(move |_| { + let arbiter = Arbiter::new(); + Room::start_in_arbiter(&arbiter, move |_| { Room::new( 1, members, @@ -497,19 +498,28 @@ mod test { let room = start_room(); let room_clone = room.clone(); let stopped_clone = stopped.clone(); - Arbiter::start(move |_| TestConnection { - events: caller_events_clone, - member_id: 1, - room: room_clone, - stopped: stopped_clone, + + let arbiter1 = Arbiter::new(); + TestConnection::start_in_arbiter(&arbiter1, move |_| { + TestConnection { + events: caller_events_clone, + member_id: 1, + room: room_clone, + stopped: stopped_clone, + } }); - Arbiter::start(move |_| TestConnection { - events: responder_events_clone, - member_id: 2, - room, - stopped, + + let arbiter2 = Arbiter::new(); + TestConnection::start_in_arbiter(&arbiter2, move |_| { + TestConnection { + events: responder_events_clone, + member_id: 2, + room, + stopped, + } }); - }); + }) + .unwrap(); let caller_events = caller_events.lock().unwrap(); let responder_events = responder_events.lock().unwrap(); From b94079c07542139e827810cbda4080833322a3e6 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 20 Jun 2019 17:50:00 +0300 Subject: [PATCH 171/735] Upd tests --- Cargo.toml | 6 ++--- src/api/client/server.rs | 50 ++++++++++++++++++++++------------------ src/signalling/room.rs | 7 +++--- 3 files changed, 34 insertions(+), 29 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ce04cdee0..0dffedfd3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,11 +21,11 @@ lto = "thin" [dependencies] actix = "0.8" +actix-codec = "0.1" +actix-http = "0.2" +actix-http-test = "0.2" actix-web = "1.0" actix-web-actors = "1.0" -actix-http-test = "0.2" -actix-http = "0.2" -actix-codec = "0.1" bb8 = "0.3" bb8-redis = "0.3" config = "0.9" diff --git a/src/api/client/server.rs b/src/api/client/server.rs index 9db07be48..e776db41d 100644 --- a/src/api/client/server.rs +++ b/src/api/client/server.rs @@ -96,7 +96,7 @@ pub fn run(rooms: RoomsRepository, config: Conf) { actix_web::web::resource( "/ws/{room_id}/{member_id}/{credentials}", ) - .to_async(ws_index), + .route(actix_web::web::get().to_async(ws_index)), ) .wrap(middleware::Logger::default()) }) @@ -199,32 +199,38 @@ mod test { .force_send(Message::Text(r#"{"ping": 33}"#.into())) .unwrap(); - server.block_on(socket - .flush() - .into_future() - .map_err(|_| ()) - .and_then(|socket| { - socket.into_future().map_err(|_| ()).and_then(move |(item, read)| { - assert_eq!( - Some(ws::Frame::Text(Some(r#"{"pong":33}"#.into()))), - item - ); - - thread::sleep( - conf.rpc.idle_timeout.add(Duration::from_secs(1)), - ); - - read.into_future().map_err(|(e, _)| panic!("{:?}", e)).map( - |(item, _)| { + server + .block_on(socket.flush().into_future().map_err(|_| ()).and_then( + |socket| { + socket.into_future().map_err(|_| ()).and_then( + move |(item, read)| { assert_eq!( - Some(ws::Frame::Close(Some( - ws::CloseCode::Normal.into() + Some(ws::Frame::Text(Some( + r#"{"pong":33}"#.into() ))), item ); + + thread::sleep( + conf.rpc + .idle_timeout + .add(Duration::from_secs(1)), + ); + + read.into_future() + .map_err(|(e, _)| panic!("{:?}", e)) + .map(|(item, _)| { + assert_eq!( + Some(ws::Frame::Close(Some( + ws::CloseCode::Normal.into() + ))), + item + ); + }) }, ) - }) - })).unwrap(); + }, + )) + .unwrap(); } } diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 835f5d56a..7ebebf4b7 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -60,6 +60,7 @@ pub enum RoomError { impl From for RoomError { fn from(err: PeerStateError) -> Self { + // panic!("{:?}", err); RoomError::PeerStateError(err) } } @@ -499,8 +500,7 @@ mod test { let room_clone = room.clone(); let stopped_clone = stopped.clone(); - let arbiter1 = Arbiter::new(); - TestConnection::start_in_arbiter(&arbiter1, move |_| { + TestConnection::start_in_arbiter(&Arbiter::new(), move |_| { TestConnection { events: caller_events_clone, member_id: 1, @@ -509,8 +509,7 @@ mod test { } }); - let arbiter2 = Arbiter::new(); - TestConnection::start_in_arbiter(&arbiter2, move |_| { + TestConnection::start_in_arbiter(&Arbiter::new(), move |_| { TestConnection { events: responder_events_clone, member_id: 2, From c422d2a28f256eed55c112263eacf96a2c457e89 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 21 Jun 2019 18:34:59 +0300 Subject: [PATCH 172/735] Fix race condition bug --- src/signalling/participants.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index e751742fd..008be76f4 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -182,7 +182,6 @@ impl ParticipantService { } Box::new(wrap_future(connection.close().then(|_| Ok(())))) } else { - self.connections.insert(member_id, con); Box::new( wrap_future(self.turn.create( member_id, @@ -199,6 +198,7 @@ impl ParticipantService { { member.ice_user.replace(ice); room.participants.insert_member(member); + room.participants.connections.insert(member_id, con); }; wrap_future(future::ok(())) }, From c375db7c247dcf1680996867f4270c3c254f4e91 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 21 Jun 2019 18:45:38 +0300 Subject: [PATCH 173/735] Fix warning, lint and formating --- jason/src/utils/event_listener.rs | 2 +- proto/client-api/src/lib.rs | 1 + src/api/client/server.rs | 15 ++++----------- src/signalling/participants.rs | 4 +++- src/turn/service.rs | 4 ++-- 5 files changed, 11 insertions(+), 15 deletions(-) diff --git a/jason/src/utils/event_listener.rs b/jason/src/utils/event_listener.rs index 70299513b..6d357fcc9 100644 --- a/jason/src/utils/event_listener.rs +++ b/jason/src/utils/event_listener.rs @@ -51,7 +51,7 @@ impl, A: FromWasmAbi + 'static> where F: FnOnce(A) + 'static, { - let closure: Closure = Closure::once(closure); + let closure: Closure = Closure::once(closure); target.add_event_listener_with_callback( event_name, diff --git a/proto/client-api/src/lib.rs b/proto/client-api/src/lib.rs index f5275a9d8..59c7805e4 100644 --- a/proto/client-api/src/lib.rs +++ b/proto/client-api/src/lib.rs @@ -93,6 +93,7 @@ pub struct Track { pub media_type: MediaType, } +#[allow(clippy::doc_markdown)] /// Representation of [RTCIceServer][1] (item of `iceServers` field /// from [RTCConfiguration][2]). /// diff --git a/src/api/client/server.rs b/src/api/client/server.rs index e776db41d..df0bef049 100644 --- a/src/api/client/server.rs +++ b/src/api/client/server.rs @@ -111,12 +111,11 @@ pub fn run(rooms: RoomsRepository, config: Conf) { mod test { use std::{ops::Add, thread, time::Duration}; - use actix::{Actor as _, Arbiter, System}; - use actix_codec::{AsyncRead, Framed}; - use actix_http::HttpService; + use actix::{Actor as _, Arbiter}; + use actix_http::{ws::Message, HttpService}; use actix_http_test::{TestServer, TestServerRuntime}; - use actix_web::{http, test, App}; - use futures::{sink::Sink, Stream}; + use actix_web::App; + use futures::{future::IntoFuture, sink::Sink, Stream}; use crate::{ api::control::Member, @@ -127,12 +126,6 @@ mod test { }; use super::*; - use actix_http::{ - h1::Message::Item, - ws::{Frame, Message}, - }; - use futures::future::IntoFuture; - use tokio::prelude::AsyncWrite; /// Creates [`RoomsRepository`] for tests filled with a single [`Room`]. fn room(conf: Rpc) -> RoomsRepository { diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 008be76f4..f408e514a 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -198,7 +198,9 @@ impl ParticipantService { { member.ice_user.replace(ice); room.participants.insert_member(member); - room.participants.connections.insert(member_id, con); + room.participants + .connections + .insert(member_id, con); }; wrap_future(future::ok(())) }, diff --git a/src/turn/service.rs b/src/turn/service.rs index 2d282124b..081b10251 100644 --- a/src/turn/service.rs +++ b/src/turn/service.rs @@ -296,7 +296,7 @@ pub mod test { _: u64, _: RoomId, _: UnreachablePolicy, - ) -> Box> { + ) -> Box> { Box::new(future::ok(IceUser::new( "5.5.5.5:1234".parse().unwrap(), String::from("username"), @@ -307,7 +307,7 @@ pub mod test { fn delete( &self, _: Vec, - ) -> Box> { + ) -> Box> { Box::new(future::ok(())) } } From 325b2ac8a5bcc3bf17e2ddafda9cf5d7077248b5 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 21 Jun 2019 18:56:21 +0300 Subject: [PATCH 174/735] Small fixes --- src/api/client/server.rs | 7 ++----- src/main.rs | 3 +-- src/signalling/room.rs | 3 +-- src/turn/service.rs | 3 +-- 4 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/api/client/server.rs b/src/api/client/server.rs index df0bef049..69645069c 100644 --- a/src/api/client/server.rs +++ b/src/api/client/server.rs @@ -35,7 +35,6 @@ struct RequestParams { /// Handles all HTTP requests, performs WebSocket handshake (upgrade) and starts /// new [`WsSession`] for WebSocket connection. -// TODO: maybe not use Box? fn ws_index( r: HttpRequest, info: Path, @@ -58,7 +57,7 @@ fn ws_index( room, state.config.idle_timeout, ), - &r, // TODO: drop_state() + &r, payload, ), Err(AuthorizationError::MemberNotExists) => { @@ -85,7 +84,6 @@ pub struct Context { /// Starts HTTP server for handling WebSocket connections of Client API. pub fn run(rooms: RoomsRepository, config: Conf) { let server_addr = config.server.bind_addr(); - //.service(web::resource("/path1").to(|| HttpResponse::Ok())) HttpServer::new(move || { App::new() .data(Context { @@ -141,8 +139,7 @@ mod test { ice_user: None }, }; - let arbiter = Arbiter::new(); - let room = Room::start_in_arbiter(&arbiter, move |_| { + let room = Room::start_in_arbiter(&Arbiter::new(), move |_| { Room::new( 1, members, diff --git a/src/main.rs b/src/main.rs index a7cd7e4db..68ed210b3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -44,8 +44,7 @@ fn main() { let rpc_reconnect_timeout = config.rpc.reconnect_timeout; - let arbiter = Arbiter::new(); - let room = Room::start_in_arbiter(&arbiter, move |_| { + let room = Room::start_in_arbiter(&Arbiter::new(), move |_| { Room::new(1, members, peers, rpc_reconnect_timeout, turn_auth_service) }); diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 7ebebf4b7..6745d96e4 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -475,8 +475,7 @@ mod test { ice_user: None }, }; - let arbiter = Arbiter::new(); - Room::start_in_arbiter(&arbiter, move |_| { + Room::start_in_arbiter(&Arbiter::new(), move |_| { Room::new( 1, members, diff --git a/src/turn/service.rs b/src/turn/service.rs index 081b10251..bfcedd679 100644 --- a/src/turn/service.rs +++ b/src/turn/service.rs @@ -181,8 +181,7 @@ pub fn new_turn_auth_service( static_user: None, }; - let arbiter = Arbiter::new(); - let service = Service::start_in_arbiter(&arbiter, move |_| service); + let service = Service::start_in_arbiter(&Arbiter::new(), move |_| service); Ok(Box::new(service)) } From 3162e0b75913fd25bc614408ae716c651925629f Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 21 Jun 2019 19:05:42 +0300 Subject: [PATCH 175/735] More clean ping pong test --- src/api/client/server.rs | 75 ++++++++++++++++++++-------------------- 1 file changed, 38 insertions(+), 37 deletions(-) diff --git a/src/api/client/server.rs b/src/api/client/server.rs index 69645069c..2507797ac 100644 --- a/src/api/client/server.rs +++ b/src/api/client/server.rs @@ -165,7 +165,7 @@ mod test { actix_web::web::resource( "/ws/{room_id}/{member_id}/{credentials}", ) - .to_async(ws_index), + .route(actix_web::web::get().to_async(ws_index)), ), ) }) @@ -183,44 +183,45 @@ mod test { }; let mut server = ws_server(conf.clone()); - let mut socket = server.ws_at("/ws/1/1/caller_credentials").unwrap(); - - socket - .force_send(Message::Text(r#"{"ping": 33}"#.into())) - .unwrap(); + let socket = server.ws_at("/ws/1/1/caller_credentials").unwrap(); server - .block_on(socket.flush().into_future().map_err(|_| ()).and_then( - |socket| { - socket.into_future().map_err(|_| ()).and_then( - move |(item, read)| { - assert_eq!( - Some(ws::Frame::Text(Some( - r#"{"pong":33}"#.into() - ))), - item - ); - - thread::sleep( - conf.rpc - .idle_timeout - .add(Duration::from_secs(1)), - ); - - read.into_future() - .map_err(|(e, _)| panic!("{:?}", e)) - .map(|(item, _)| { - assert_eq!( - Some(ws::Frame::Close(Some( - ws::CloseCode::Normal.into() - ))), - item - ); - }) - }, - ) - }, - )) + .block_on( + socket + .send(Message::Text(r#"{"ping": 33}"#.into())) + .into_future() + .map_err(|e| panic!("{:?}", e)) + .and_then(|socket| { + socket + .into_future() + .map_err(|e| panic!("{:?}", e.0)) + .and_then(move |(item, read)| { + assert_eq!( + Some(ws::Frame::Text(Some( + r#"{"pong":33}"#.into() + ))), + item + ); + + thread::sleep( + conf.rpc + .idle_timeout + .add(Duration::from_secs(1)), + ); + + read.into_future() + .map_err(|(e, _)| panic!("{:?}", e)) + .map(|(item, _)| { + assert_eq!( + Some(ws::Frame::Close(Some( + ws::CloseCode::Normal.into() + ))), + item + ); + }) + }) + }), + ) .unwrap(); } } From b02e7dc4a9f826c6e1fdd548d856fe0ed9744158 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 21 Jun 2019 19:07:39 +0300 Subject: [PATCH 176/735] Remove commented panic --- src/signalling/room.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 6745d96e4..bec8a5fbf 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -60,7 +60,6 @@ pub enum RoomError { impl From for RoomError { fn from(err: PeerStateError) -> Self { - // panic!("{:?}", err); RoomError::PeerStateError(err) } } From 579e3752c8f01f92d47036ba1e74a259d4d03c2b Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 21 Jun 2019 19:13:20 +0300 Subject: [PATCH 177/735] Small fix --- src/api/client/server.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/api/client/server.rs b/src/api/client/server.rs index 2507797ac..f2d603bd4 100644 --- a/src/api/client/server.rs +++ b/src/api/client/server.rs @@ -194,8 +194,8 @@ mod test { .and_then(|socket| { socket .into_future() - .map_err(|e| panic!("{:?}", e.0)) - .and_then(move |(item, read)| { + .map_err(|(e, _)| panic!("{:?}", e)) + .and_then(|(item, read)| { assert_eq!( Some(ws::Frame::Text(Some( r#"{"pong":33}"#.into() From 875edf94d06226994d74115d9eb0cab4db436d2f Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 21 Jun 2019 20:22:56 +0300 Subject: [PATCH 178/735] Remove Mutex from endpoints --- src/signalling/control/endpoint.rs | 52 ++++++++++++++---------------- 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/src/signalling/control/endpoint.rs b/src/signalling/control/endpoint.rs index 60157cf36..da572a316 100644 --- a/src/signalling/control/endpoint.rs +++ b/src/signalling/control/endpoint.rs @@ -1,9 +1,6 @@ //! Signalling representation of endpoints. -use std::{ - fmt::Display, - sync::{Mutex, Weak}, -}; +use std::{cell::RefCell, fmt::Display, sync::Weak}; use hashbrown::HashSet; @@ -91,7 +88,8 @@ impl Drop for WebRtcPlayEndpointInner { /// Signalling representation of `WebRtcPlayEndpoint`. #[allow(clippy::module_name_repetitions)] #[derive(Debug)] -pub struct WebRtcPlayEndpoint(Mutex); +pub struct WebRtcPlayEndpoint(RefCell); +unsafe impl std::marker::Sync for WebRtcPlayEndpoint {} impl WebRtcPlayEndpoint { /// Create new [`WebRtcPlayEndpoint`]. @@ -101,7 +99,7 @@ impl WebRtcPlayEndpoint { publisher: Weak, owner: Weak, ) -> Self { - Self(Mutex::new(WebRtcPlayEndpointInner { + Self(RefCell::new(WebRtcPlayEndpointInner { id, src, publisher, @@ -112,44 +110,44 @@ impl WebRtcPlayEndpoint { /// Returns [`SrcUri`] of this [`WebRtcPlayEndpoint`]. pub fn src(&self) -> SrcUri { - self.0.lock().unwrap().src() + self.0.borrow().src() } /// Returns owner [`Participant`] of this [`WebRtcPlayEndpoint`]. pub fn owner(&self) -> Weak { - self.0.lock().unwrap().owner() + self.0.borrow().owner() } /// Returns publisher's [`WebRtcPublishEndpoint`]. pub fn publisher(&self) -> Weak { - self.0.lock().unwrap().publisher() + self.0.borrow().publisher() } /// Check that peer connection established for this [`WebRtcPlayEndpoint`]. pub fn is_connected(&self) -> bool { - self.0.lock().unwrap().is_connected() + self.0.borrow().is_connected() } /// Save [`PeerId`] of this [`WebRtcPlayEndpoint`]. pub fn connect(&self, peer_id: PeerId) { - self.0.lock().unwrap().set_peer_id(peer_id); + self.0.borrow_mut().set_peer_id(peer_id); } /// Return [`PeerId`] of [`Peer`] of this [`WebRtcPlayEndpoint`]. pub fn peer_id(&self) -> Option { - self.0.lock().unwrap().peer_id() + self.0.borrow().peer_id() } /// Reset state of this [`WebRtcPlayEndpoint`]. /// /// Atm this only reset peer_id. pub fn reset(&self) { - self.0.lock().unwrap().reset() + self.0.borrow_mut().reset() } /// Returns ID of this [`WebRtcPlayEndpoint`]. pub fn id(&self) -> Id { - self.0.lock().unwrap().id.clone() + self.0.borrow().id.clone() } } @@ -226,7 +224,8 @@ impl WebRtcPublishEndpointInner { /// Signalling representation of `WebRtcPublishEndpoint`. #[allow(clippy::module_name_repetitions)] #[derive(Debug)] -pub struct WebRtcPublishEndpoint(Mutex); +pub struct WebRtcPublishEndpoint(RefCell); +unsafe impl std::marker::Sync for WebRtcPublishEndpoint {} impl WebRtcPublishEndpoint { /// Create new [`WebRtcPublishEndpoint`]. @@ -236,7 +235,7 @@ impl WebRtcPublishEndpoint { receivers: Vec>, owner: Weak, ) -> Self { - Self(Mutex::new(WebRtcPublishEndpointInner { + Self(RefCell::new(WebRtcPublishEndpointInner { id, p2p, receivers, @@ -247,58 +246,57 @@ impl WebRtcPublishEndpoint { /// Add receiver for this [`WebRtcPublishEndpoint`]. pub fn add_receiver(&self, receiver: Weak) { - self.0.lock().unwrap().add_receiver(receiver) + self.0.borrow_mut().add_receiver(receiver) } /// Returns all receivers of this [`WebRtcPublishEndpoint`]. pub fn receivers(&self) -> Vec> { - self.0.lock().unwrap().receivers() + self.0.borrow().receivers() } /// Returns owner [`Participant`] of this [`WebRtcPublishEndpoint`]. pub fn owner(&self) -> Weak { - self.0.lock().unwrap().owner() + self.0.borrow().owner() } /// Add [`PeerId`] of this [`WebRtcPublishEndpoint`]. pub fn add_peer_id(&self, peer_id: PeerId) { - self.0.lock().unwrap().add_peer_id(peer_id) + self.0.borrow_mut().add_peer_id(peer_id) } /// Returns all [`PeerId`] of this [`WebRtcPublishEndpoint`]. pub fn peer_ids(&self) -> HashSet { - self.0.lock().unwrap().peer_ids() + self.0.borrow().peer_ids() } /// Reset state of this [`WebRtcPublishEndpoint`]. /// /// Atm this only reset peer_ids. pub fn reset(&self) { - self.0.lock().unwrap().reset() + self.0.borrow_mut().reset() } /// Remove [`PeerId`] from peer_ids. #[allow(clippy::trivially_copy_pass_by_ref)] pub fn remove_peer_id(&self, peer_id: &PeerId) { - self.0.lock().unwrap().remove_peer_id(peer_id) + self.0.borrow_mut().remove_peer_id(peer_id) } /// Remove all [`PeerId`]s related to this [`WebRtcPublishEndpoint`]. pub fn remove_peer_ids(&self, peer_ids: &[PeerId]) { - self.0.lock().unwrap().remove_peer_ids(peer_ids) + self.0.borrow_mut().remove_peer_ids(peer_ids) } /// Returns ID of this [`WebRtcPublishEndpoint`]. pub fn id(&self) -> Id { - self.0.lock().unwrap().id.clone() + self.0.borrow().id.clone() } /// Remove all empty Weak pointers from receivers of this /// [`WebRtcPublishEndpoint`]. pub fn remove_empty_weaks_from_receivers(&self) { self.0 - .lock() - .unwrap() + .borrow_mut() .receivers .retain(|e| e.upgrade().is_some()); } From 0fb188db0847eaeb9acdb53eff3de8c08a22ab18 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 24 Jun 2019 12:55:47 +0300 Subject: [PATCH 179/735] Migrate e2e to new version of actix --- Cargo.lock | 24 ++ Cargo.toml | 1 + tests/e2e/signalling.rs | 519 +++++++++++++++++++++------------------- 3 files changed, 302 insertions(+), 242 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0a2ac6461..ca25a69e7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -478,6 +478,28 @@ name = "autocfg" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "awc" +version = "0.2.1" +source = "git+https://github.com/actix/actix-web#b948f74b540c70036cef60d16cba554ffb71f0cd" +dependencies = [ + "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-http 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-service 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "mime 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", + "percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_urlencoded 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "awc" version = "0.2.1" @@ -1285,6 +1307,7 @@ dependencies = [ "actix-web 0.7.19 (registry+https://github.com/rust-lang/crates.io-index)", "actix-web 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "actix-web-actors 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "awc 0.2.1 (git+https://github.com/actix/actix-web)", "bb8 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "bb8-redis 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3006,6 +3029,7 @@ dependencies = [ "checksum ascii 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a5fc969a8ce2c9c0c4b0429bb8431544f6658283c8326ba5ff8c762b75369335" "checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" "checksum autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "0e49efa51329a5fd37e7c79db4621af617cd4e3e5bc224939808d076077077bf" +"checksum awc 0.2.1 (git+https://github.com/actix/actix-web)" = "" "checksum awc 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c5133e9ca1d7f0560fb271f20286be3e896dac5736040a62a7ef1d62003160b6" "checksum backtrace 0.3.30 (registry+https://github.com/rust-lang/crates.io-index)" = "ada4c783bb7e7443c14e0480f429ae2cc99da95065aeab7ee1b81ada0419404f" "checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6" diff --git a/Cargo.toml b/Cargo.toml index 0a9ab5be6..05e7ef69a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,6 +26,7 @@ actix-http = "0.2" actix-http-test = "0.2" actix-web = "1.0" actix-web-actors = "1.0" +awc = { git = "https://github.com/actix/actix-web" } bb8 = "0.3" bb8-redis = "0.3" config = "0.9" diff --git a/tests/e2e/signalling.rs b/tests/e2e/signalling.rs index fcdc585f0..ff0a4d66e 100644 --- a/tests/e2e/signalling.rs +++ b/tests/e2e/signalling.rs @@ -3,22 +3,26 @@ use std::{cell::Cell, rc::Rc, time::Duration}; use futures::future::Future; +use futures::Stream; use medea::media::PeerId; use medea_client_api_proto::{Command, Direction, Event, IceCandidate}; -use old_actix::{ - Actor, Arbiter, AsyncContext, Context, Handler, Message, StreamHandler, - System, -}; -use old_actix_web::ws::{ - Client, ClientWriter, CloseCode, CloseReason, Message as WebMessage, - ProtocolError, -}; +use actix::{Actor, Arbiter, AsyncContext, Context, Handler, Message, StreamHandler, System}; + use serde_json::error::Error as SerdeError; +use awc::error::WsProtocolError; +use awc::ws::Frame; +use futures::stream::SplitSink; +use actix_codec::Framed; +use awc::BoxedSocket; +use actix_http::ws::Codec; +use futures::sink::Sink; +use actix_http::ws::Message as WsMessage; +use awc::ws::{CloseCode, CloseReason}; /// Medea client for testing purposes. struct TestMember { /// Writer to WebSocket. - writer: ClientWriter, + writer: SplitSink>, /// All [`Event`]s which this [`TestMember`] received. /// This field used for give some debug info when test just stuck forever @@ -38,34 +42,36 @@ impl TestMember { /// and there are simply no tests that last so much. fn heartbeat(&self, ctx: &mut Context) { ctx.run_later(Duration::from_secs(3), |act, ctx| { - act.writer.text(r#"{"ping": 1}"#); + act.writer.start_send(WsMessage::Text(r#"{"ping": 1}"#.to_string())).unwrap(); + act.writer.poll_complete().unwrap(); act.heartbeat(ctx); }); } /// Send command to the server. fn send_command(&mut self, msg: Command) { - self.writer.text(&serde_json::to_string(&msg).unwrap()); + //self.writer.text(&serde_json::to_string(&msg).unwrap()); + let json = serde_json::to_string(&msg).unwrap(); + self.writer.start_send(WsMessage::Text(json)); + self.writer.poll_complete().unwrap(); } - /// Start test member in new [`Arbiter`] by given URI. - /// `test_fn` - is function which will be called at every [`Event`] - /// received from server. pub fn start( uri: &str, test_fn: Box)>, ) { Arbiter::spawn( - Client::new(uri) - .connect() - .map_err(|e| { - panic!("Error: {}", e); - }) - .map(|(reader, writer)| { + awc::Client::new().ws(uri).connect() + .map_err(|e| panic!("Error: {}", e)) + .map(|(response, framed)| { + println!("1"); + let (stream, sink) = framed.split(); TestMember::create(|ctx| { - TestMember::add_stream(reader, ctx); + println!("2"); + TestMember::add_stream(sink, ctx); + println!("3"); TestMember { - writer, + writer: stream, events: Vec::new(), test_fn, } @@ -73,6 +79,33 @@ impl TestMember { }), ) } + +// /// Start test member in new [`Arbiter`] by given URI. +// /// `test_fn` - is function which will be called at every [`Event`] +// /// received from server. +// pub fn start( +// uri: &str, +// test_fn: Box)>, +// ) { +// Self::test_start(uri); +// Arbiter::spawn( +// Client::new(uri) +// .connect() +// .map_err(|e| { +// panic!("Error: {}", e); +// }) +// .map(|(reader, writer)| { +// TestMember::create(|ctx| { +// TestMember::add_stream(reader, ctx); +// TestMember { +// writer, +// events: Vec::new(), +// test_fn, +// } +// }); +// }), +// ) +// } } impl Actor for TestMember { @@ -103,20 +136,26 @@ impl Handler for TestMember { type Result = (); fn handle(&mut self, _: CloseSocket, _: &mut Self::Context) { - self.writer.close(Some(CloseReason { + self.writer.start_send(WsMessage::Close(Some(CloseReason { code: CloseCode::Normal, - description: None, - })); + description: None + }))); + self.writer.poll_complete().unwrap(); +// self.writer.close(Some(CloseReason { +// code: CloseCode::Normal, +// description: None, +// })); } } -impl StreamHandler for TestMember { +impl StreamHandler for TestMember { /// Basic signalling implementation. /// A `TestMember::test_fn` [`FnMut`] function will be called for each /// [`Event`] received from test server. - fn handle(&mut self, msg: WebMessage, ctx: &mut Context) { + fn handle(&mut self, msg: Frame, ctx: &mut Context) { match msg { - WebMessage::Text(txt) => { + Frame::Text(txt) => { + let txt = String::from_utf8(txt.unwrap().to_vec()).unwrap(); let event: Result = serde_json::from_str(&txt); if let Ok(event) = event { @@ -162,236 +201,232 @@ impl StreamHandler for TestMember { #[test] fn pub_sub_video_call() { - let test_name = "pub_sub_video_call"; - let base_url = "ws://localhost:8081/ws/pub-sub-video-call"; - - let sys = System::new(test_name); - - // Note that events is separated by members. - // Every member will have different instance of this. - let mut events = Vec::new(); - let test_fn = move |event: &Event, _: &mut Context| { - events.push(event.clone()); - - // Start checking result of test. - if let Event::IceCandidateDiscovered { .. } = event { - let peers_count = events - .iter() - .filter(|e| match e { - Event::PeerCreated { .. } => true, - _ => false, - }) - .count(); - assert_eq!(peers_count, 1); - - let mut is_caller = false; - if let Event::PeerCreated { - peer_id, - sdp_offer, - tracks, - ice_servers, - } = &events[0] - { - assert_eq!(ice_servers.len(), 2); - assert_eq!( - ice_servers[0].urls[0], - "stun:127.0.0.1:3478".to_string() - ); - assert_eq!( - ice_servers[1].urls[0], - "turn:127.0.0.1:3478".to_string() - ); - assert_eq!( - ice_servers[1].urls[1], - "turn:127.0.0.1:3478?transport=tcp".to_string() - ); - - if let Some(_) = sdp_offer { - is_caller = false; - } else { - is_caller = true; - } - assert_eq!(tracks.len(), 2); - for track in tracks { - match &track.direction { - Direction::Send { receivers } => { - assert!(is_caller); - assert!(!receivers.contains(&peer_id)); - } - Direction::Recv { sender } => { - assert!(!is_caller); - assert_ne!(sender, peer_id); + System::run(|| { + let test_name = "pub_sub_video_call"; + let base_url = "ws://localhost:8081/ws/pub-sub-video-call"; + + // Note that events is separated by members. + // Every member will have different instance of this. + let mut events = Vec::new(); + let test_fn = move |event: &Event, _: &mut Context| { + events.push(event.clone()); + + // Start checking result of test. + if let Event::IceCandidateDiscovered { .. } = event { + let peers_count = events + .iter() + .filter(|e| match e { + Event::PeerCreated { .. } => true, + _ => false, + }) + .count(); + assert_eq!(peers_count, 1); + + let mut is_caller = false; + if let Event::PeerCreated { + peer_id, + sdp_offer, + tracks, + ice_servers, + } = &events[0] + { + assert_eq!(ice_servers.len(), 2); + assert_eq!( + ice_servers[0].urls[0], + "stun:127.0.0.1:3478".to_string() + ); + assert_eq!( + ice_servers[1].urls[0], + "turn:127.0.0.1:3478".to_string() + ); + assert_eq!( + ice_servers[1].urls[1], + "turn:127.0.0.1:3478?transport=tcp".to_string() + ); + + if let Some(_) = sdp_offer { + is_caller = false; + } else { + is_caller = true; + } + assert_eq!(tracks.len(), 2); + for track in tracks { + match &track.direction { + Direction::Send { receivers } => { + assert!(is_caller); + assert!(!receivers.contains(&peer_id)); + } + Direction::Recv { sender } => { + assert!(!is_caller); + assert_ne!(sender, peer_id); + } } } - } - } else { - assert!(false) - } - - if is_caller { - if let Event::SdpAnswerMade { .. } = &events[1] { } else { - assert!(false); + assert!(false) } - if let Event::IceCandidateDiscovered { .. } = &events[2] { - } else { - assert!(false); - } - } else { - if let Event::IceCandidateDiscovered { .. } = &events[1] { + if is_caller { + if let Event::SdpAnswerMade { .. } = &events[1] { + } else { + assert!(false); + } + + if let Event::IceCandidateDiscovered { .. } = &events[2] { + } else { + assert!(false); + } } else { - assert!(false); + if let Event::IceCandidateDiscovered { .. } = &events[1] { + } else { + assert!(false); + } } - } - if is_caller { - System::current().stop(); + if is_caller { + System::current().stop(); + } } - } - }; - - TestMember::start( - &format!("{}/caller/test", base_url), - Box::new(test_fn.clone()), - ); - TestMember::start( - &format!("{}/responder/test", base_url), - Box::new(test_fn), - ); - - let _ = sys.run(); + }; + + TestMember::start( + &format!("{}/caller/test", base_url), + Box::new(test_fn.clone()), + ); + TestMember::start( + &format!("{}/responder/test", base_url), + Box::new(test_fn), + ); + }); } #[test] fn three_members_p2p_video_call() { - let test_name = "three_members_p2p_video_call"; - - let base_url = "ws://localhost:8081/ws/three-members-conference"; - - let sys = System::new(test_name); - - // Note that events, peer_created_count, ice_candidates - // is separated by members. - // Every member will have different instance of this. - let mut events = Vec::new(); - let mut peer_created_count = 0; - let mut ice_candidates = 0; - - // This is shared state of members. - let members_tested = Rc::new(Cell::new(0)); - let members_peers_removed = Rc::new(Cell::new(0)); - - let test_fn = move |event: &Event, ctx: &mut Context| { - events.push(event.clone()); - match event { - Event::PeerCreated { ice_servers, .. } => { - assert_eq!(ice_servers.len(), 2); - assert_eq!( - ice_servers[0].urls[0], - "stun:127.0.0.1:3478".to_string() - ); - assert_eq!( - ice_servers[1].urls[0], - "turn:127.0.0.1:3478".to_string() - ); - assert_eq!( - ice_servers[1].urls[1], - "turn:127.0.0.1:3478?transport=tcp".to_string() - ); - - peer_created_count += 1; - } - Event::IceCandidateDiscovered { .. } => { - ice_candidates += 1; - if ice_candidates == 2 { - // Start checking result of test. - - assert_eq!(peer_created_count, 2); - - events.iter().for_each(|e| match e { - Event::PeerCreated { - peer_id, tracks, .. - } => { - assert_eq!(tracks.len(), 4); - let recv_count = tracks - .iter() - .filter_map(|t| match &t.direction { - Direction::Recv { sender } => Some(sender), - _ => None, - }) - .map(|sender| { - assert_ne!(sender, peer_id); - }) - .count(); - assert_eq!(recv_count, 2); - - let send_count = tracks - .iter() - .filter_map(|t| match &t.direction { - Direction::Send { receivers } => { - Some(receivers) - } - _ => None, - }) - .map(|receivers| { - assert!(!receivers.contains(peer_id)); - assert_eq!(receivers.len(), 1); - }) - .count(); - assert_eq!(send_count, 2); + System::run(|| { + let test_name = "three_members_p2p_video_call"; + + let base_url = "ws://localhost:8081/ws/three-members-conference"; + + // Note that events, peer_created_count, ice_candidates + // is separated by members. + // Every member will have different instance of this. + let mut events = Vec::new(); + let mut peer_created_count = 0; + let mut ice_candidates = 0; + + // This is shared state of members. + let members_tested = Rc::new(Cell::new(0)); + let members_peers_removed = Rc::new(Cell::new(0)); + + let test_fn = move |event: &Event, ctx: &mut Context| { + events.push(event.clone()); + match event { + Event::PeerCreated { ice_servers, .. } => { + assert_eq!(ice_servers.len(), 2); + assert_eq!( + ice_servers[0].urls[0], + "stun:127.0.0.1:3478".to_string() + ); + assert_eq!( + ice_servers[1].urls[0], + "turn:127.0.0.1:3478".to_string() + ); + assert_eq!( + ice_servers[1].urls[1], + "turn:127.0.0.1:3478?transport=tcp".to_string() + ); + + peer_created_count += 1; + } + Event::IceCandidateDiscovered { .. } => { + ice_candidates += 1; + if ice_candidates == 2 { + // Start checking result of test. + + assert_eq!(peer_created_count, 2); + + events.iter().for_each(|e| match e { + Event::PeerCreated { + peer_id, tracks, .. + } => { + assert_eq!(tracks.len(), 4); + let recv_count = tracks + .iter() + .filter_map(|t| match &t.direction { + Direction::Recv { sender } => Some(sender), + _ => None, + }) + .map(|sender| { + assert_ne!(sender, peer_id); + }) + .count(); + assert_eq!(recv_count, 2); + + let send_count = tracks + .iter() + .filter_map(|t| match &t.direction { + Direction::Send { receivers } => { + Some(receivers) + } + _ => None, + }) + .map(|receivers| { + assert!(!receivers.contains(peer_id)); + assert_eq!(receivers.len(), 1); + }) + .count(); + assert_eq!(send_count, 2); + } + _ => (), + }); + + // Check peers removing. + // After closing socket, server should send + // Event::PeersRemoved to all remaining + // members. + // Close should happen when last TestMember pass + // tests. + if members_tested.get() == 2 { + ctx.notify(CloseSocket); } - _ => (), - }); - - // Check peers removing. - // After closing socket, server should send - // Event::PeersRemoved to all remaining - // members. - // Close should happen when last TestMember pass - // tests. - if members_tested.get() == 2 { - ctx.notify(CloseSocket); + members_tested.set(members_tested.get() + 1); } - members_tested.set(members_tested.get() + 1); } - } - Event::PeersRemoved { .. } => { - // This event should get two remaining members after closing - // last tested member. - let peers_removed: Vec<&Vec> = events - .iter() - .filter_map(|e| match e { - Event::PeersRemoved { peer_ids } => Some(peer_ids), - _ => None, - }) - .collect(); - assert_eq!(peers_removed.len(), 1); - assert_eq!(peers_removed[0].len(), 2); - assert_ne!(peers_removed[0][0], peers_removed[0][1]); - - members_peers_removed.set(members_peers_removed.get() + 1); - // Stop when all members receive Event::PeerRemoved - if members_peers_removed.get() == 2 { - System::current().stop(); + Event::PeersRemoved { .. } => { + // This event should get two remaining members after closing + // last tested member. + let peers_removed: Vec<&Vec> = events + .iter() + .filter_map(|e| match e { + Event::PeersRemoved { peer_ids } => Some(peer_ids), + _ => None, + }) + .collect(); + assert_eq!(peers_removed.len(), 1); + assert_eq!(peers_removed[0].len(), 2); + assert_ne!(peers_removed[0][0], peers_removed[0][1]); + + members_peers_removed.set(members_peers_removed.get() + 1); + // Stop when all members receive Event::PeerRemoved + if members_peers_removed.get() == 2 { + System::current().stop(); + } } + _ => (), } - _ => (), - } - }; - - TestMember::start( - &format!("{}/member-1/test", base_url), - Box::new(test_fn.clone()), - ); - TestMember::start( - &format!("{}/member-2/test", base_url), - Box::new(test_fn.clone()), - ); - TestMember::start( - &format!("{}/member-3/test", base_url), - Box::new(test_fn), - ); - - let _ = sys.run(); + }; + + TestMember::start( + &format!("{}/member-1/test", base_url), + Box::new(test_fn.clone()), + ); + TestMember::start( + &format!("{}/member-2/test", base_url), + Box::new(test_fn.clone()), + ); + TestMember::start( + &format!("{}/member-3/test", base_url), + Box::new(test_fn), + ); + }).unwrap(); } From 7e7e8c98910817a56e1c20cb4b1096d81743b93c Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 24 Jun 2019 13:17:50 +0300 Subject: [PATCH 180/735] Fix formatting, warnings, remove useless crates --- Cargo.lock | 416 ---------------------------------------- Cargo.toml | 5 +- tests/e2e/signalling.rs | 105 ++++------ 3 files changed, 43 insertions(+), 483 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ca25a69e7..f9da8ccda 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9,35 +9,6 @@ dependencies = [ "regex 1.1.7 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "actix" -version = "0.7.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "actix_derive 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-signal 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "trust-dns-proto 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "trust-dns-resolver 0.10.3 (registry+https://github.com/rust-lang/crates.io-index)", - "uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "actix" version = "0.8.3" @@ -170,30 +141,6 @@ dependencies = [ "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "actix-net" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "actix 0.7.9 (registry+https://github.com/rust-lang/crates.io-index)", - "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", - "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", - "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-current-thread 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "tower-service 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "trust-dns-resolver 0.10.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "actix-router" version = "0.1.5" @@ -288,58 +235,6 @@ dependencies = [ "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "actix-web" -version = "0.7.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "actix 0.7.9 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-net 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", - "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "brotli2 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "cookie 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)", - "encoding 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", - "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "flate2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "h2 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)", - "http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", - "httparse 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "mime 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", - "mime_guess 2.0.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", - "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_urlencoded 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", - "sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", - "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-current-thread 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "v_htmlescape 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "actix-web" version = "1.0.2" @@ -395,16 +290,6 @@ dependencies = [ "syn 0.15.36 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "actix_derive" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.36 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "actix_derive" version = "0.4.0" @@ -543,15 +428,6 @@ dependencies = [ "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "base64" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "safemem 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "base64" version = "0.10.1" @@ -706,17 +582,6 @@ name = "constant_time_eq" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "cookie" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "base64 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", - "ring 0.13.5 (registry+https://github.com/rust-lang/crates.io-index)", - "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", - "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "copyless" version = "0.1.3" @@ -948,14 +813,6 @@ dependencies = [ "termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "error-chain" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "backtrace 0.3.30 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "failure" version = "0.1.5" @@ -1016,15 +873,6 @@ name = "futures" version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "futures-cpupool" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "gcc" version = "0.3.55" @@ -1130,18 +978,6 @@ dependencies = [ "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "ipconfig" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "error-chain 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "socket2 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "widestring 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", - "winreg 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "ipconfig" version = "0.2.1" @@ -1220,11 +1056,6 @@ name = "lazy_static" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "lazycell" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "libc" version = "0.2.58" @@ -1299,12 +1130,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "medea" version = "0.1.0-dev" dependencies = [ - "actix 0.7.9 (registry+https://github.com/rust-lang/crates.io-index)", "actix 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)", "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "actix-http 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "actix-http-test 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-web 0.7.19 (registry+https://github.com/rust-lang/crates.io-index)", "actix-web 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "actix-web-actors 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "awc 0.2.1 (git+https://github.com/actix/actix-web)", @@ -1391,17 +1220,6 @@ dependencies = [ "unicase 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "mime_guess" -version = "2.0.0-alpha.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "mime 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", - "phf 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)", - "phf_codegen 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)", - "unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "miniz-sys" version = "0.1.12" @@ -1597,41 +1415,6 @@ name = "percent-encoding" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "phf" -version = "0.7.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "phf_shared 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "phf_codegen" -version = "0.7.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "phf_generator 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)", - "phf_shared 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "phf_generator" -version = "0.7.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "phf_shared 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "phf_shared" -version = "0.7.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "siphasher 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "proc-macro2" version = "0.4.30" @@ -1674,18 +1457,6 @@ dependencies = [ "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "rand" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "rand" version = "0.6.5" @@ -1876,17 +1647,6 @@ dependencies = [ "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "ring" -version = "0.13.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", - "untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "rust-crypto" version = "0.2.36" @@ -1935,11 +1695,6 @@ name = "ryu" version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "safemem" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "scoped-tls" version = "1.0.0" @@ -2102,11 +1857,6 @@ dependencies = [ "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "siphasher" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "slab" version = "0.4.2" @@ -2529,60 +2279,6 @@ dependencies = [ "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "tower-service" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "trust-dns-proto" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", - "socket2 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-udp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "trust-dns-proto" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", - "socket2 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-udp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "trust-dns-proto" version = "0.7.4" @@ -2607,24 +2303,6 @@ dependencies = [ "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "trust-dns-resolver" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "ipconfig 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "lru-cache 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "resolv-conf 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", - "trust-dns-proto 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "trust-dns-resolver" version = "0.11.1" @@ -2648,14 +2326,6 @@ name = "ucd-util" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "unicase" -version = "1.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "unicase" version = "2.4.0" @@ -2698,11 +2368,6 @@ dependencies = [ "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "untrusted" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "url" version = "1.7.2" @@ -2724,43 +2389,6 @@ name = "utf8-ranges" version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "uuid" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "v_escape" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "v_escape_derive 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "v_escape_derive" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "nom 4.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.36 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "v_htmlescape" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "v_escape 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "version_check" version = "0.1.5" @@ -2901,11 +2529,6 @@ dependencies = [ "nom 4.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "widestring" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "widestring" version = "0.4.0" @@ -2957,14 +2580,6 @@ dependencies = [ "winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "winreg" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "winreg" version = "0.6.0" @@ -3000,13 +2615,11 @@ dependencies = [ [metadata] "checksum Inflector 0.11.4 (registry+https://github.com/rust-lang/crates.io-index)" = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" -"checksum actix 0.7.9 (registry+https://github.com/rust-lang/crates.io-index)" = "6c616db5fa4b0c40702fb75201c2af7f8aa8f3a2e2c1dda3b0655772aa949666" "checksum actix 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)" = "671ce3d27313f236827a5dd153a1073ad03ef31fc77f562020263e7830cf1ef7" "checksum actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9f2c11af4b06dc935d8e1b1491dad56bfb32febc49096a91e773f8535c176453" "checksum actix-connect 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d7fbab0d79b2f3415a79570e3db12eaa75c26239541e613b832655145a5e9488" "checksum actix-http 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "81aa906e74d2cd5f219f596003b0fd94d05e75a4a448b12afea66e7658b6c9e1" "checksum actix-http-test 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7e4ea476df1fe681a9bd2fcc37eff9393fad4a0430975e46d7c657907351f250" -"checksum actix-net 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "8bebfbe6629e0131730746718c9e032b58f02c6ce06ed7c982b9fef6c8545acd" "checksum actix-router 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "23224bb527e204261d0291102cb9b52713084def67d94f7874923baefe04ccf7" "checksum actix-rt 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ed0424cdf6542a43b32a8885c7c5099bf4110fad9b50d7fb220ab9c038ecf5ec" "checksum actix-server 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ba8c936356c882420eab87051b12ca1926dc42348863d05fff7eb151df9cddbb" @@ -3014,11 +2627,9 @@ dependencies = [ "checksum actix-service 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "aaecc01bbc595ebd7a563a7d4f8a607d0b964bb55273c6f362b0b02c26508cf2" "checksum actix-threadpool 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1c29f7c554d56b3841f4bb85d5b3dee01ba536e1307679f56eb54de28aaec3fb" "checksum actix-utils 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7ab47adc5e67fc83a0c58570b40531f09814a5daa969e0d913ebeab908a43508" -"checksum actix-web 0.7.19 (registry+https://github.com/rust-lang/crates.io-index)" = "b0ac60f86c65a50b140139f499f4f7c6e49e4b5d88fbfba08e4e3975991f7bf4" "checksum actix-web 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6478c837afbe528cfe468976e67b6b81a6330414b00234c4546a158f9f0739fc" "checksum actix-web-actors 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9c54489d9bcfce84a5096ba47db6a4dd2cc493987e97a987a4c5a7519b31f26d" "checksum actix-web-codegen 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3fe9e3cdec1e645b675f354766e0688c5705021c85ab3cf739be1c8999b91c76" -"checksum actix_derive 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4300e9431455322ae393d43a2ba1ef96b8080573c0fc23b196219efedfb6ba69" "checksum actix_derive 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0bf5f6d7bf2d220ae8b4a7ae02a572bb35b7c4806b24049af905ab8110de156c" "checksum adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7e522997b529f05601e05166c07ed17789691f562762c7f3b987263d2dedee5c" "checksum aho-corasick 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ca972c2ea5f742bfce5687b9aef75506a764f61d37f8f649047846a9686ddb66" @@ -3034,7 +2645,6 @@ dependencies = [ "checksum backtrace 0.3.30 (registry+https://github.com/rust-lang/crates.io-index)" = "ada4c783bb7e7443c14e0480f429ae2cc99da95065aeab7ee1b81ada0419404f" "checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6" "checksum base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" -"checksum base64 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "489d6c0ed21b11d038c31b6ceccca973e65d73ba3bd8ecb9a2babf5546164643" "checksum bb8 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6ac04c3b2d3327a583c9a93b6c5ab4316e6609f5ec84b71b89ebe518e0edbad2" "checksum bb8-redis 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9817f38c173f0da1581b923b90e66750a090413ad67a20980d5ad64141bab476" "checksum bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3d155346769a6855b86399e9bc3814ab343cd3d62c7e985113d46a0ec3c281fd" @@ -3053,7 +2663,6 @@ dependencies = [ "checksum config 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "f9107d78ed62b3fa5a86e7d18e647abed48cfd8f8fab6c72f4cdb982d196f7e6" "checksum console_error_panic_hook 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "b8d976903543e0c48546a91908f21588a680a8c8f984df9a5d69feccb2b2a211" "checksum constant_time_eq 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8ff012e225ce166d4422e0e78419d901719760f62ae2b7969ca6b564d1b54a9e" -"checksum cookie 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)" = "99be24cfcf40d56ed37fd11c2123be833959bbc5bddecb46e1c2e442e15fa3e0" "checksum copyless 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "f8ffa29b14f03d473f1558c789d020fe41bb7790774f429ff818f4ed9a6f9a0e" "checksum crc 1.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d663548de7f5cca343f1e0a48d14dcfb0e9eb4e079ec58883b7251539fa10aeb" "checksum crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" @@ -3080,7 +2689,6 @@ dependencies = [ "checksum encoding_index_tests 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "a246d82be1c9d791c5dfde9a2bd045fc3cbba3fa2b11ad558f27d01712f00569" "checksum enum-as-inner 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3d58266c97445680766be408285e798d3401c6d4c378ec5552e78737e681e37d" "checksum env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b61fa891024a945da30a9581546e8cfaf5602c7b3f4c137a2805cf388f92075a" -"checksum error-chain 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6930e04918388a9a2e41d518c25cf679ccafe26733fb4127dbf21993f2575d46" "checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" "checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" "checksum flate2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "550934ad4808d5d39365e5d61727309bf18b3b02c6c56b729cb92e7dd84bc3d8" @@ -3089,7 +2697,6 @@ dependencies = [ "checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" "checksum futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)" = "a2037ec1c6c1c4f79557762eab1f7eae1f64f6cb418ace90fae88f0942b60139" -"checksum futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "ab90cde24b3319636588d0c35fe03b1333857621051837ed769faefb4c2162e4" "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" "checksum h2 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)" = "69b2a5a3092cbebbc951fe55408402e696ee2ed09019137d1800fc2c411265d2" "checksum hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3bae29b6653b3412c2e71e9d486db9f9df5d701941d86683005efb9f2d28e3da" @@ -3103,7 +2710,6 @@ dependencies = [ "checksum idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e" "checksum indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7e81a7c05f79578dbc15793d8b619db9ba32b4577003ef3af1a91c416798c58d" "checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08" -"checksum ipconfig 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "08f7eadeaf4b52700de180d147c4805f199854600b36faa963d91114827b2ffc" "checksum ipconfig 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "aa79fa216fbe60834a9c0737d7fcd30425b32d1c58854663e24d4c4b328ed83f" "checksum isatty 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e31a8281fc93ec9693494da65fbf28c0c2aa60a2eaec25dc58e2f31952e95edc" "checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" @@ -3112,7 +2718,6 @@ dependencies = [ "checksum language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a91d884b6667cd606bb5a69aa0c99ba811a115fc68915e7056ec08a46e93199a" "checksum lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "76f033c7ad61445c5b347c7382dd1237847eb1bce590fe50365dcb33d546be73" "checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" -"checksum lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f" "checksum libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)" = "6281b86796ba5e4366000be6e9e18bf35580adf9e63fbe2294aadb587613a319" "checksum linked-hash-map 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6d262045c5b87c0861b3f004610afd0e2c851e2908d08b6c870cbb9d5f494ecd" "checksum linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ae91b68aebc4ddb91978b11a1b02ddd8602a05ec19002801c5666000e05e0f83" @@ -3128,7 +2733,6 @@ dependencies = [ "checksum memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0f9dc261e2b62d7a622bf416ea3c5245cdd5d9a7fcc428c0d06804dfce1775b3" "checksum memory_units 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8452105ba047068f40ff7093dd1d9da90898e63dd61736462e9cdda6a90ad3c3" "checksum mime 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)" = "3e27ca21f40a310bd06d9031785f4801710d566c184a6e15bad4f1d9b65f9425" -"checksum mime_guess 2.0.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)" = "30de2e4613efcba1ec63d8133f344076952090c122992a903359be5a4f99c3ed" "checksum miniz-sys 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "1e9e3ae51cea1576ceba0dde3d484d30e6e5b86dee0b2d412fe3a16a15c98202" "checksum miniz_oxide 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c468f2369f07d651a5d0bb2c9079f8488a66d5466efe42d0c5c6466edcb7f71e" "checksum miniz_oxide_c_api 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b7fe927a42e3807ef71defb191dc87d4e24479b221e67015fe38ae2b7b447bab" @@ -3150,16 +2754,11 @@ dependencies = [ "checksum parking_lot_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "94c8c7923936b28d546dfd14d4472eaf34c99b14e1c973a32b3e6d4eb04298c9" "checksum parking_lot_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cb88cb1cb3790baa6776844f968fea3be44956cf184fa1be5a03341f5491278c" "checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" -"checksum phf 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)" = "b3da44b85f8e8dfaec21adae67f95d93244b2ecf6ad2a692320598dcc8e6dd18" -"checksum phf_codegen 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)" = "b03e85129e324ad4166b06b2c7491ae27fe3ec353af72e72cd1654c7225d517e" -"checksum phf_generator 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)" = "09364cc93c159b8b06b1f4dd8a4398984503483891b0c26b867cf431fb132662" -"checksum phf_shared 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)" = "234f71a15de2288bcb7e3b6515828d22af7ec8598ee6d24c3b526fa0a80b67a0" "checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" "checksum quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)" = "faf4799c5d274f3868a4aae320a0a182cbd2baee377b378f080e16a23e9d80db" "checksum rand 0.3.23 (registry+https://github.com/rust-lang/crates.io-index)" = "64ac302d8f83c0c1974bf758f6b041c6c8ada916fbb44a609158ca8b064cc76c" "checksum rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" -"checksum rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c618c47cd3ebd209790115ab837de41425723956ad3ce2e6a7f09890947cacb9" "checksum rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" "checksum rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" "checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" @@ -3180,7 +2779,6 @@ dependencies = [ "checksum regex-syntax 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "f9ec002c35e86791825ed294b50008eea9ddfc8def4420124fbc6b08db834957" "checksum regex-syntax 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)" = "9d76410686f9e3a17f06128962e0ecc5755870bb890c34820c7af7f1db2e1d48" "checksum resolv-conf 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b263b4aa1b5de9ffc0054a2386f96992058bb6870aab516f8cdeb8a667d56dcb" -"checksum ring 0.13.5 (registry+https://github.com/rust-lang/crates.io-index)" = "2c4db68a2e35f3497146b7e4563df7d4773a2433230c5e4b448328e31740458a" "checksum rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)" = "f76d05d3993fd5f4af9434e8e436db163a12a9d40e1a58a726f27a01dfd12a2a" "checksum rust-ini 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3e52c148ef37f8c375d49d5a73aa70713125b7f19095948a923f80afdeb22ec2" "checksum rustc-demangle 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "a7f4dccf6f4891ebcc0c39f9b6eb1a83b9bf5d747cb439ec6fba4f3b977038af" @@ -3188,7 +2786,6 @@ dependencies = [ "checksum rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "c5f5376ea5e30ce23c03eb77cbe4962b988deead10910c372b226388b594c084" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" "checksum ryu 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "b96a9549dc8d48f2c283938303c4b5a77aa29bfbc5b54b084fb1630408899a8f" -"checksum safemem 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8dca453248a96cb0749e36ccdfe2b0b4e54a61bfef89fb97ec621eb8e0a93dd9" "checksum scoped-tls 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2" "checksum scoped_threadpool 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "1d51f5df5af43ab3f1360b429fa5e0152ac5ce8c0bd6485cae490332e96846a8" "checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" @@ -3210,7 +2807,6 @@ dependencies = [ "checksum sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d" "checksum signal-hook 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "72ab58f1fda436857e6337dcb6a5aaa34f16c5ddc87b3a8b6ef7a212f90b9c5a" "checksum signal-hook-registry 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cded4ffa32146722ec54ab1f16320568465aa922aa9ab4708129599740da85d7" -"checksum siphasher 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0b8de496cf83d4ed58b6be86c3a275b8602f6ffe98d3024a869e124147a9a3ac" "checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" "checksum slog 2.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1e1a2eec401952cd7b12a84ea120e2d57281329940c3f93c2bf04f462539508e" "checksum slog-async 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e544d16c6b230d84c866662fe55e31aacfca6ae71e6fc49ae9a311cb379bfc2f" @@ -3252,28 +2848,18 @@ dependencies = [ "checksum tokio-udp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "66268575b80f4a4a710ef83d087fdfeeabdce9b74c797535fbac18a2cb906e92" "checksum tokio-uds 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "037ffc3ba0e12a0ab4aca92e5234e0dedeb48fddf6ccd260f1f150a36a9f2445" "checksum toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "758664fc71a3a69038656bee8b6be6477d2a6c315a6b81f7081f591bffa4111f" -"checksum tower-service 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b32f72af77f1bfe3d3d4da8516a238ebe7039b51dd8637a09841ac7f16d2c987" -"checksum trust-dns-proto 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0838272e89f1c693b4df38dc353412e389cf548ceed6f9fd1af5a8d6e0e7cf74" -"checksum trust-dns-proto 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "09144f0992b0870fa8d2972cc069cbf1e3c0fda64d1f3d45c4d68d0e0b52ad4e" "checksum trust-dns-proto 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5559ebdf6c2368ddd11e20b11d6bbaf9e46deb803acd7815e93f5a7b4a6d2901" -"checksum trust-dns-resolver 0.10.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8a9f877f7a1ad821ab350505e1f1b146a4960402991787191d6d8cab2ce2de2c" "checksum trust-dns-resolver 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6c9992e58dba365798803c0b91018ff6c8d3fc77e06977c4539af2a6bfe0a039" "checksum ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "535c204ee4d8434478593480b8f86ab45ec9aae0e83c568ca81abf0fd0e88f86" -"checksum unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7f4765f83163b74f957c797ad9253caf97f103fb064d3999aea9568d09fc8a33" "checksum unicase 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a84e5511b2a947f3ae965dcb29b13b7b1691b6e7332cf5dbc1744138d5acb7f6" "checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" "checksum unicode-normalization 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "141339a08b982d942be2ca06ff8b076563cbe223d1befd5450716790d44e2426" "checksum unicode-segmentation 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1967f4cdfc355b37fd76d2a954fb2ed3871034eb4f26d60537d88795cfc332a9" "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" "checksum unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56" -"checksum untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "55cd1f4b4e96b46aeb8d4855db4a7a9bd96eeeb5c6a1ab54593328761642ce2f" "checksum url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dd4e7c0d531266369519a4aa4f399d748bd37043b00bde1e4ff1f60a120b355a" "checksum utf8-ranges 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a1ca13c08c41c9c3e04224ed9ff80461d97e121589ff27c753a16cb10830ae0f" "checksum utf8-ranges 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "9d50aa7650df78abf942826607c62468ce18d9019673d4a2ebe1865dbb96ffde" -"checksum uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)" = "90dbc611eb48397705a6b0f6e917da23ae517e4d127123d2cf7674206627d32a" -"checksum v_escape 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8865501b78eef9193c1b45486acf18ba889e5662eba98854d6fc59d8ecf3542d" -"checksum v_escape_derive 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "306896ff4b75998501263a1dc000456de442e21d68fe8c8bdf75c66a33a58e23" -"checksum v_htmlescape 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7fbbe0fa88dd36f9c8cf61a218d4b953ba669de4d0785832f33cc72bd081e1be" "checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" "checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" "checksum wasm-bindgen 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)" = "22029998cc650473cb05f10f19c06a1536b9e1f1572e4f5dacd45ab4d3f85877" @@ -3288,7 +2874,6 @@ dependencies = [ "checksum web-sys 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "22306ce642c58266cb5c5938150194911322bc179aa895146076217410ddbc82" "checksum wee_alloc 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "31d4e6572d21ac55398bc91db827f48c3fdb8152ae60f4c358f6780e1035ffcc" "checksum weedle 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bcc44aa200daee8b1f3a004beaf16554369746f1b4486f0cf93b0caf8a3c2d1e" -"checksum widestring 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7157704c2e12e3d2189c507b7482c52820a16dfa4465ba91add92f266667cadb" "checksum widestring 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "effc0e4ff8085673ea7b9b2e3c73f6bd4d118810c9009ed8f1e16bd96c331db6" "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" "checksum winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f10e386af2b13e47c89e7236a7a14a086791a2b88ebad6df9bf42040195cf770" @@ -3297,7 +2882,6 @@ dependencies = [ "checksum winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7168bab6e1daee33b4557efd0e95d5ca70a03706d39fa5f3fe7a236f584b03c9" "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" "checksum wincolor 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "561ed901ae465d6185fa7864d63fbd5720d0ef718366c9a4dc83cf6170d7e9ba" -"checksum winreg 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a27a759395c1195c4cc5cda607ef6f8f6498f64e78f7900f5de0a127a424704a" "checksum winreg 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "daf67b95d0b1bf421c4f11048d63110ca3719977169eec86396b614c8942b6e0" "checksum winutil 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7daf138b6b14196e3830a588acf1e86966c694d3e8fb026fb105b8b5dca07e6e" "checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" diff --git a/Cargo.toml b/Cargo.toml index 05e7ef69a..db7f58056 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,6 +26,9 @@ actix-http = "0.2" actix-http-test = "0.2" actix-web = "1.0" actix-web-actors = "1.0" +# TODO: use version from crates.io when commit +# https://github.com/actix/actix-web/commit/ff724e239db50210a9913de6e214be214f41befa#diff-c39fd968c2b6beb9a6960dd533618bcbR41 +# will be released in crates.io. awc = { git = "https://github.com/actix/actix-web" } bb8 = "0.3" bb8-redis = "0.3" @@ -60,7 +63,5 @@ toml = "0.4" branch = "serde_wrapper" [dev-dependencies] -old-actix = { version = "0.7", package = "actix" } -old-actix-web = { version = "0.7", package = "actix-web" } serial_test = "0.2" serial_test_derive = "0.2" diff --git a/tests/e2e/signalling.rs b/tests/e2e/signalling.rs index ff0a4d66e..2430c0364 100644 --- a/tests/e2e/signalling.rs +++ b/tests/e2e/signalling.rs @@ -2,22 +2,21 @@ use std::{cell::Cell, rc::Rc, time::Duration}; -use futures::future::Future; -use futures::Stream; +use actix::{ + Actor, Arbiter, AsyncContext, Context, Handler, Message, StreamHandler, + System, +}; +use actix_codec::Framed; +use actix_http::ws::{Codec, Message as WsMessage}; +use awc::{ + error::WsProtocolError, + ws::{CloseCode, CloseReason, Frame}, + BoxedSocket, +}; +use futures::{future::Future, sink::Sink, stream::SplitSink, Stream}; use medea::media::PeerId; use medea_client_api_proto::{Command, Direction, Event, IceCandidate}; -use actix::{Actor, Arbiter, AsyncContext, Context, Handler, Message, StreamHandler, System}; - use serde_json::error::Error as SerdeError; -use awc::error::WsProtocolError; -use awc::ws::Frame; -use futures::stream::SplitSink; -use actix_codec::Framed; -use awc::BoxedSocket; -use actix_http::ws::Codec; -use futures::sink::Sink; -use actix_http::ws::Message as WsMessage; -use awc::ws::{CloseCode, CloseReason}; /// Medea client for testing purposes. struct TestMember { @@ -42,7 +41,9 @@ impl TestMember { /// and there are simply no tests that last so much. fn heartbeat(&self, ctx: &mut Context) { ctx.run_later(Duration::from_secs(3), |act, ctx| { - act.writer.start_send(WsMessage::Text(r#"{"ping": 1}"#.to_string())).unwrap(); + act.writer + .start_send(WsMessage::Text(r#"{"ping": 1}"#.to_string())) + .unwrap(); act.writer.poll_complete().unwrap(); act.heartbeat(ctx); }); @@ -50,28 +51,30 @@ impl TestMember { /// Send command to the server. fn send_command(&mut self, msg: Command) { - //self.writer.text(&serde_json::to_string(&msg).unwrap()); + // self.writer.text(&serde_json::to_string(&msg).unwrap()); let json = serde_json::to_string(&msg).unwrap(); - self.writer.start_send(WsMessage::Text(json)); + self.writer.start_send(WsMessage::Text(json)).unwrap(); self.writer.poll_complete().unwrap(); } + /// Start test member in new [`Arbiter`] by given URI. + /// `test_fn` - is function which will be called at every [`Event`] + /// received from server. pub fn start( uri: &str, test_fn: Box)>, ) { Arbiter::spawn( - awc::Client::new().ws(uri).connect() + awc::Client::new() + .ws(uri) + .connect() .map_err(|e| panic!("Error: {}", e)) - .map(|(response, framed)| { - println!("1"); - let (stream, sink) = framed.split(); + .map(|(_, framed)| { + let (sink, stream) = framed.split(); TestMember::create(|ctx| { - println!("2"); - TestMember::add_stream(sink, ctx); - println!("3"); + TestMember::add_stream(stream, ctx); TestMember { - writer: stream, + writer: sink, events: Vec::new(), test_fn, } @@ -79,33 +82,6 @@ impl TestMember { }), ) } - -// /// Start test member in new [`Arbiter`] by given URI. -// /// `test_fn` - is function which will be called at every [`Event`] -// /// received from server. -// pub fn start( -// uri: &str, -// test_fn: Box)>, -// ) { -// Self::test_start(uri); -// Arbiter::spawn( -// Client::new(uri) -// .connect() -// .map_err(|e| { -// panic!("Error: {}", e); -// }) -// .map(|(reader, writer)| { -// TestMember::create(|ctx| { -// TestMember::add_stream(reader, ctx); -// TestMember { -// writer, -// events: Vec::new(), -// test_fn, -// } -// }); -// }), -// ) -// } } impl Actor for TestMember { @@ -136,15 +112,13 @@ impl Handler for TestMember { type Result = (); fn handle(&mut self, _: CloseSocket, _: &mut Self::Context) { - self.writer.start_send(WsMessage::Close(Some(CloseReason { - code: CloseCode::Normal, - description: None - }))); + self.writer + .start_send(WsMessage::Close(Some(CloseReason { + code: CloseCode::Normal, + description: None, + }))) + .unwrap(); self.writer.poll_complete().unwrap(); -// self.writer.close(Some(CloseReason { -// code: CloseCode::Normal, -// description: None, -// })); } } @@ -202,7 +176,6 @@ impl StreamHandler for TestMember { #[test] fn pub_sub_video_call() { System::run(|| { - let test_name = "pub_sub_video_call"; let base_url = "ws://localhost:8081/ws/pub-sub-video-call"; // Note that events is separated by members. @@ -297,14 +270,13 @@ fn pub_sub_video_call() { &format!("{}/responder/test", base_url), Box::new(test_fn), ); - }); + }) + .unwrap(); } #[test] fn three_members_p2p_video_call() { System::run(|| { - let test_name = "three_members_p2p_video_call"; - let base_url = "ws://localhost:8081/ws/three-members-conference"; // Note that events, peer_created_count, ice_candidates @@ -353,7 +325,9 @@ fn three_members_p2p_video_call() { let recv_count = tracks .iter() .filter_map(|t| match &t.direction { - Direction::Recv { sender } => Some(sender), + Direction::Recv { sender } => { + Some(sender) + } _ => None, }) .map(|sender| { @@ -428,5 +402,6 @@ fn three_members_p2p_video_call() { &format!("{}/member-3/test", base_url), Box::new(test_fn), ); - }).unwrap(); + }) + .unwrap(); } From ffc2d84dd6f331bc1f127b55d57fdd4422158ae1 Mon Sep 17 00:00:00 2001 From: alexlapa Date: Mon, 24 Jun 2019 14:24:00 +0300 Subject: [PATCH 181/735] minor refactor --- Cargo.toml | 6 +++--- src/api/client/server.rs | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 0dffedfd3..82bd24d44 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,8 +28,8 @@ actix-web = "1.0" actix-web-actors = "1.0" bb8 = "0.3" bb8-redis = "0.3" -config = "0.9" chrono = "0.4" +config = "0.9" dotenv = "0.13" failure = "0.1" futures = "0.1" @@ -45,11 +45,11 @@ rust-crypto = "0.2" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" slog = "2.4" -slog-envlogger = "2.1" -slog-stdlog = "3.0" slog-async = "2.3" +slog-envlogger = "2.1" slog-json = "2.3" slog-scope = "4.1" +slog-stdlog = "3.0" smart-default = "0.5" tokio = "0.1" toml = "0.4" diff --git a/src/api/client/server.rs b/src/api/client/server.rs index f2d603bd4..07abf32d4 100644 --- a/src/api/client/server.rs +++ b/src/api/client/server.rs @@ -3,7 +3,7 @@ use actix_web::{ middleware, web::{Data, Path, Payload}, - App, Error, HttpRequest, HttpResponse, HttpServer, + App, HttpRequest, HttpResponse, HttpServer, }; use actix_web_actors::ws; use futures::{future, Future}; @@ -36,15 +36,15 @@ struct RequestParams { /// Handles all HTTP requests, performs WebSocket handshake (upgrade) and starts /// new [`WsSession`] for WebSocket connection. fn ws_index( - r: HttpRequest, + request: HttpRequest, info: Path, state: Data, payload: Payload, -) -> Box> { +) -> impl Future { debug!("Request params: {:?}", info); match state.rooms.get(info.room_id) { - Some(room) => Box::new( + Some(room) => future::Either::A( room.send(Authorize { member_id: info.member_id, credentials: info.credentials.clone(), @@ -57,7 +57,7 @@ fn ws_index( room, state.config.idle_timeout, ), - &r, + &request, payload, ), Err(AuthorizationError::MemberNotExists) => { @@ -68,7 +68,7 @@ fn ws_index( } }), ), - None => Box::new(future::ok(HttpResponse::NotFound().into())), + None => future::Either::B(future::ok(HttpResponse::NotFound().into())), } } @@ -113,7 +113,7 @@ mod test { use actix_http::{ws::Message, HttpService}; use actix_http_test::{TestServer, TestServerRuntime}; use actix_web::App; - use futures::{future::IntoFuture, sink::Sink, Stream}; + use futures::{future::IntoFuture as _, sink::Sink as _, Stream as _}; use crate::{ api::control::Member, From 22862994db13feb2fe17316389f565edc24d9df3 Mon Sep 17 00:00:00 2001 From: alexlapa Date: Mon, 24 Jun 2019 15:16:31 +0300 Subject: [PATCH 182/735] minor refactor --- .rustfmt.toml | 3 +-- src/api/client/server.rs | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.rustfmt.toml b/.rustfmt.toml index a53c6ac3e..2051bcb37 100644 --- a/.rustfmt.toml +++ b/.rustfmt.toml @@ -3,6 +3,7 @@ max_width = 80 format_strings = true +merge_imports = true normalize_comments = true wrap_comments = true @@ -13,5 +14,3 @@ error_on_line_overflow = true error_on_unformatted = true unstable_features = true - -merge_imports = true diff --git a/src/api/client/server.rs b/src/api/client/server.rs index 07abf32d4..95ec1a20b 100644 --- a/src/api/client/server.rs +++ b/src/api/client/server.rs @@ -90,13 +90,13 @@ pub fn run(rooms: RoomsRepository, config: Conf) { rooms: rooms.clone(), config: config.rpc.clone(), }) + .wrap(middleware::Logger::default()) .service( actix_web::web::resource( "/ws/{room_id}/{member_id}/{credentials}", ) .route(actix_web::web::get().to_async(ws_index)), ) - .wrap(middleware::Logger::default()) }) .bind(server_addr) .unwrap() From aed620f0a880b009c0c2d20878ede5e8344766d9 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 24 Jun 2019 15:53:20 +0300 Subject: [PATCH 183/735] Remove all Arc and Mutex --- src/api/client/server.rs | 19 ++--- src/api/control/room.rs | 6 +- src/lib.rs | 17 ++-- src/media/peer.rs | 18 ++--- src/signalling/control/endpoint.rs | 4 +- src/signalling/control/participant.rs | 111 ++++++++++++-------------- src/signalling/participants.rs | 10 +-- 7 files changed, 86 insertions(+), 99 deletions(-) diff --git a/src/api/client/server.rs b/src/api/client/server.rs index 640d84b14..6d44b24e4 100644 --- a/src/api/client/server.rs +++ b/src/api/client/server.rs @@ -130,15 +130,16 @@ mod test { control::load_from_yaml_file("tests/specs/pub_sub_video_call.yml") .unwrap(); - let client_room = Room::new( - &room_spec, - conf.reconnect_timeout, - new_turn_auth_service_mock(), - ) - .unwrap(); - let room_id = client_room.get_id(); - let client_room = - Room::start_in_arbiter(&Arbiter::new(), move |_| client_room); + let room_id = room_spec.id.clone(); + let client_room = Room::start_in_arbiter(&Arbiter::new(), move |_| { + let client_room = Room::new( + &room_spec, + conf.reconnect_timeout, + new_turn_auth_service_mock(), + ) + .unwrap(); + client_room + }); let room_hash_map = hashmap! { room_id => client_room, }; diff --git a/src/api/control/room.rs b/src/api/control/room.rs index be1d552ab..8a075f12f 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -1,6 +1,6 @@ //! Room definitions and implementations. -use std::{convert::TryFrom, fmt::Display, sync::Arc}; +use std::{convert::TryFrom, fmt::Display}; use hashbrown::HashMap; use serde::Deserialize; @@ -26,7 +26,7 @@ impl Display for Id { #[derive(Clone, Debug)] pub struct RoomSpec { pub id: Id, - pub pipeline: Arc, + pub pipeline: Pipeline, } impl RoomSpec { @@ -58,7 +58,7 @@ impl TryFrom<&Element> for RoomSpec { match from { Element::Room { id, spec } => Ok(Self { id: id.clone(), - pipeline: Arc::new(spec.clone()), + pipeline: spec.clone(), }), _ => Err(TryFromElementError::NotRoom), } diff --git a/src/lib.rs b/src/lib.rs index 83dca5740..0773fcbf4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -67,6 +67,7 @@ pub fn start_static_rooms( Err(e) => return Err(ServerStartError::LoadSpec(e)), }; let mut rooms = HashMap::new(); + let arbiter = Arbiter::new(); for spec in room_specs { if rooms.contains_key(spec.id()) { @@ -75,16 +76,16 @@ pub fn start_static_rooms( )); } - let turn_auth_service = service::new_turn_auth_service(config) + let turn_auth_service = service::new_turn_auth_service(&config) .expect("Unable to start turn service"); - let room = Room::new( - &spec, - config.rpc.reconnect_timeout, - turn_auth_service, - )?; - let room = Room::start_in_arbiter(&Arbiter::new(), move |_| room); - rooms.insert(spec.id().clone(), room); + let room_id = spec.id().clone(); + let rpc_reconnect_timeout = config.rpc.reconnect_timeout; + let room = Room::start_in_arbiter(&arbiter, move |_| { + Room::new(&spec, rpc_reconnect_timeout, turn_auth_service) + .unwrap() + }); + rooms.insert(room_id, room); } Ok(rooms) diff --git a/src/media/peer.rs b/src/media/peer.rs index fb5fc1b73..d853b7890 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -4,7 +4,7 @@ #![allow(clippy::use_self)] -use std::{convert::TryFrom, fmt::Display, sync::Arc}; +use std::{convert::TryFrom, fmt::Display, rc::Rc}; use failure::Fail; use hashbrown::HashMap; @@ -152,8 +152,8 @@ pub struct Context { partner_member: MemberId, sdp_offer: Option, sdp_answer: Option, - receivers: HashMap>, - senders: HashMap>, + receivers: HashMap>, + senders: HashMap>, } /// [`RTCPeerConnection`] representation. @@ -215,7 +215,7 @@ impl Peer { } /// Returns all senders [`MediaTrack`]. - pub fn get_senders(&self) -> Vec> { + pub fn get_senders(&self) -> Vec> { self.context .senders .iter() @@ -261,7 +261,7 @@ impl Peer { &mut self, partner_peer: &mut Peer, tracks_count: &mut Counter, - publish_endpoints: HashMap>, + publish_endpoints: HashMap>, ) { let partner_id = self.partner_member_id(); let self_id = self.id(); @@ -299,11 +299,11 @@ impl Peer { }) }) .for_each(|(e, _)| { - let track_audio = Arc::new(MediaTrack::new( + let track_audio = Rc::new(MediaTrack::new( tracks_count.next_id(), MediaType::Audio(AudioSettings {}), )); - let track_video = Arc::new(MediaTrack::new( + let track_video = Rc::new(MediaTrack::new( tracks_count.next_id(), MediaType::Video(VideoSettings {}), )); @@ -340,12 +340,12 @@ impl Peer { } /// Add [`Track`] to [`Peer`] for send. - pub fn add_sender(&mut self, track: Arc) { + pub fn add_sender(&mut self, track: Rc) { self.context.senders.insert(track.id, track); } /// Add [`Track`] to [`Peer`] for receive. - pub fn add_receiver(&mut self, track: Arc) { + pub fn add_receiver(&mut self, track: Rc) { self.context.receivers.insert(track.id, track); } } diff --git a/src/signalling/control/endpoint.rs b/src/signalling/control/endpoint.rs index da572a316..33ca78451 100644 --- a/src/signalling/control/endpoint.rs +++ b/src/signalling/control/endpoint.rs @@ -1,6 +1,6 @@ //! Signalling representation of endpoints. -use std::{cell::RefCell, fmt::Display, sync::Weak}; +use std::{cell::RefCell, fmt::Display, rc::Weak}; use hashbrown::HashSet; @@ -89,7 +89,6 @@ impl Drop for WebRtcPlayEndpointInner { #[allow(clippy::module_name_repetitions)] #[derive(Debug)] pub struct WebRtcPlayEndpoint(RefCell); -unsafe impl std::marker::Sync for WebRtcPlayEndpoint {} impl WebRtcPlayEndpoint { /// Create new [`WebRtcPlayEndpoint`]. @@ -225,7 +224,6 @@ impl WebRtcPublishEndpointInner { #[allow(clippy::module_name_repetitions)] #[derive(Debug)] pub struct WebRtcPublishEndpoint(RefCell); -unsafe impl std::marker::Sync for WebRtcPublishEndpoint {} impl WebRtcPublishEndpoint { /// Create new [`WebRtcPublishEndpoint`]. diff --git a/src/signalling/control/participant.rs b/src/signalling/control/participant.rs index c8bcbb79e..73639b315 100644 --- a/src/signalling/control/participant.rs +++ b/src/signalling/control/participant.rs @@ -1,9 +1,6 @@ //! [`Participant`] is member of [`Room`] with [`RpcConnection`]. -use std::{ - convert::TryFrom as _, - sync::{Arc, Mutex}, -}; +use std::convert::TryFrom as _; use failure::Fail; use hashbrown::HashMap; @@ -17,6 +14,7 @@ use crate::{ use super::endpoint::{ Id as EndpointId, WebRtcPlayEndpoint, WebRtcPublishEndpoint, }; +use std::{cell::RefCell, rc::Rc}; /// Errors which may occur while loading [`Participant`]s from [`RoomSpec`]. #[derive(Debug, Fail)] @@ -42,7 +40,7 @@ impl From for ParticipantsLoadError { /// [`Participant`] is member of [`Room`] with [`RpcConnection`]. #[derive(Debug)] -pub struct Participant(Mutex); +pub struct Participant(RefCell); #[allow(clippy::module_name_repetitions)] #[derive(Debug)] @@ -50,10 +48,10 @@ struct ParticipantInner { id: MemberId, /// All [`WebRtcPublishEndpoint`]s of this [`Participant`]. - publishers: HashMap>, + publishers: HashMap>, /// All [`WebRtcPlayEndpoint`]s of this [`Participant`]. - receivers: HashMap>, + receivers: HashMap>, /// Credentials for this [`Participant`]. credentials: String, @@ -68,7 +66,7 @@ impl Participant { /// To fill this [`Participant`], you need to call the [`Participant::load`] /// function. fn new(id: MemberId, credentials: String) -> Self { - Self(Mutex::new(ParticipantInner { + Self(RefCell::new(ParticipantInner { id, publishers: HashMap::new(), receivers: HashMap::new(), @@ -94,32 +92,27 @@ impl Participant { /// Returns list of [`IceServer`] for this [`Participant`]. pub fn servers_list(&self) -> Option> { - self.0 - .lock() - .unwrap() - .ice_user - .as_ref() - .map(IceUser::servers_list) + self.0.borrow().ice_user.as_ref().map(IceUser::servers_list) } /// Returns and set to `None` [`IceUser`] of this [`Participant`]. pub fn take_ice_user(&self) -> Option { - self.0.lock().unwrap().ice_user.take() + self.0.borrow_mut().ice_user.take() } /// Replace and return [`IceUser`] of this [`Participant`]. pub fn replace_ice_user(&self, new_ice_user: IceUser) -> Option { - self.0.lock().unwrap().ice_user.replace(new_ice_user) + self.0.borrow_mut().ice_user.replace(new_ice_user) } /// Returns [`MemberId`] of this [`Participant`]. pub fn id(&self) -> MemberId { - self.0.lock().unwrap().id.clone() + self.0.borrow().id.clone() } /// Returns credentials of this [`Participant`]. pub fn credentials(&self) -> String { - self.0.lock().unwrap().credentials.clone() + self.0.borrow().credentials.clone() } /// Creates all empty [`Participant`] from [`RoomSpec`] and then @@ -128,14 +121,14 @@ impl Participant { /// Returns store of all [`Participant`]s loaded from [`RoomSpec`]. pub fn load_store( room_spec: &RoomSpec, - ) -> Result>, ParticipantsLoadError> { + ) -> Result>, ParticipantsLoadError> { let members = room_spec.members()?; let mut participants = HashMap::new(); for (id, member) in &members { participants.insert( id.clone(), - Arc::new(Self::new( + Rc::new(Self::new( id.clone(), member.credentials().to_string(), )), @@ -150,22 +143,20 @@ impl Participant { } /// Returns all publishers of this [`Participant`]. - pub fn publishers( - &self, - ) -> HashMap> { - self.0.lock().unwrap().publishers.clone() + pub fn publishers(&self) -> HashMap> { + self.0.borrow().publishers.clone() } /// Returns all receivers of this [`Participant`]. - pub fn receivers(&self) -> HashMap> { - self.0.lock().unwrap().receivers.clone() + pub fn receivers(&self) -> HashMap> { + self.0.borrow().receivers.clone() } /// Load all publishers and receivers of this [`Participant`]. fn load( &self, room_spec: &RoomSpec, - store: &HashMap>, + store: &HashMap>, ) -> Result<(), ParticipantsLoadError> { let this_member_spec = MemberSpec::try_from( room_spec.pipeline.get(&self.id().0).map_or( @@ -215,35 +206,35 @@ impl Participant { ) { let new_play_endpoint_id = EndpointId(spec_play_name.to_string()); - let new_play_endpoint = Arc::new(WebRtcPlayEndpoint::new( + let new_play_endpoint = Rc::new(WebRtcPlayEndpoint::new( new_play_endpoint_id.clone(), spec_play_endpoint.src.clone(), - Arc::downgrade(&publisher), - Arc::downgrade(&this_member), + Rc::downgrade(&publisher), + Rc::downgrade(&this_member), )); - self.insert_receiver(Arc::clone(&new_play_endpoint)); + self.insert_receiver(Rc::clone(&new_play_endpoint)); - publisher.add_receiver(Arc::downgrade(&new_play_endpoint)); + publisher.add_receiver(Rc::downgrade(&new_play_endpoint)); } else { let new_publish_id = EndpointId(spec_play_endpoint.src.endpoint_id.to_string()); - let new_publish = Arc::new(WebRtcPublishEndpoint::new( + let new_publish = Rc::new(WebRtcPublishEndpoint::new( new_publish_id.clone(), publisher_endpoint.p2p.clone(), Vec::new(), - Arc::downgrade(&publisher_participant), + Rc::downgrade(&publisher_participant), )); let new_self_play_id = EndpointId(spec_play_name.to_string()); - let new_self_play = Arc::new(WebRtcPlayEndpoint::new( + let new_self_play = Rc::new(WebRtcPlayEndpoint::new( new_self_play_id.clone(), spec_play_endpoint.src.clone(), - Arc::downgrade(&new_publish), - Arc::downgrade(&this_member), + Rc::downgrade(&new_publish), + Rc::downgrade(&this_member), )); - new_publish.add_receiver(Arc::downgrade(&new_self_play)); + new_publish.add_receiver(Rc::downgrade(&new_self_play)); publisher_participant.insert_publisher(new_publish); @@ -257,14 +248,12 @@ impl Participant { |(name, e)| { let endpoint_id = EndpointId(name.clone()); if self.publishers().get(&endpoint_id).is_none() { - self.insert_publisher(Arc::new( - WebRtcPublishEndpoint::new( - endpoint_id, - e.p2p.clone(), - Vec::new(), - Arc::downgrade(&this_member), - ), - )); + self.insert_publisher(Rc::new(WebRtcPublishEndpoint::new( + endpoint_id, + e.p2p.clone(), + Vec::new(), + Rc::downgrade(&this_member), + ))); } }, ); @@ -273,19 +262,17 @@ impl Participant { } /// Insert receiver into this [`Participant`]. - pub fn insert_receiver(&self, endpoint: Arc) { + pub fn insert_receiver(&self, endpoint: Rc) { self.0 - .lock() - .unwrap() + .borrow_mut() .receivers .insert(endpoint.id(), endpoint); } /// Insert publisher into this [`Participant`]. - pub fn insert_publisher(&self, endpoint: Arc) { + pub fn insert_publisher(&self, endpoint: Rc) { self.0 - .lock() - .unwrap() + .borrow_mut() .publishers .insert(endpoint.id(), endpoint); } @@ -294,32 +281,32 @@ impl Participant { pub fn get_publisher_by_id( &self, id: &EndpointId, - ) -> Option> { - self.0.lock().unwrap().publishers.get(id).cloned() + ) -> Option> { + self.0.borrow().publishers.get(id).cloned() } /// Lookup [`WebRtcPlayEndpoint`] receiver by [`EndpointId`]. pub fn get_receiver_by_id( &self, id: &EndpointId, - ) -> Option> { - self.0.lock().unwrap().receivers.get(id).cloned() + ) -> Option> { + self.0.borrow().receivers.get(id).cloned() } /// Remove receiver [`WebRtcPlayEndpoint`] from this [`Participant`]. pub fn remove_receiver(&self, id: &EndpointId) { - self.0.lock().unwrap().receivers.remove(id); + self.0.borrow_mut().receivers.remove(id); } /// Remove receiver [`WebRtcPublishEndpoint`] from this [`Participant`]. pub fn remove_publisher(&self, id: &EndpointId) { - self.0.lock().unwrap().publishers.remove(id); + self.0.borrow_mut().publishers.remove(id); } } #[cfg(test)] mod participant_loading_tests { - use std::sync::Arc; + use std::rc::Rc; use crate::api::control::Element; @@ -382,12 +369,12 @@ mod participant_loading_tests { .receivers() .into_iter() .map(|p| p.upgrade().unwrap()) - .filter(|p| Arc::ptr_eq(p, &responder_play_endpoint)) + .filter(|p| Rc::ptr_eq(p, &responder_play_endpoint)) .count() == 1; assert!(is_caller_has_responder_in_receivers); - assert!(Arc::ptr_eq( + assert!(Rc::ptr_eq( &responder_play_endpoint.publisher().upgrade().unwrap(), &caller_publish_endpoint )); @@ -409,7 +396,7 @@ mod participant_loading_tests { .receivers() .into_iter() .map(|p| p.upgrade().unwrap()) - .filter(|p| Arc::ptr_eq(p, &responder_play2_endpoint)) + .filter(|p| Rc::ptr_eq(p, &responder_play2_endpoint)) .count() == 1; assert!(is_some_participant_has_responder_in_receivers); diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 5fd86efe0..7a04741ba 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -4,7 +4,7 @@ //! credentials management. use std::{ - sync::Arc, + rc::Rc, time::{Duration, Instant}, }; @@ -74,7 +74,7 @@ pub struct ParticipantService { room_id: RoomId, /// [`Participant`]s which currently are present in this [`Room`]. - participants: HashMap>, + participants: HashMap>, /// Service for managing authorization on Turn server. turn: Box, @@ -138,7 +138,7 @@ impl ParticipantService { pub fn get_participant_by_id( &self, id: &ParticipantId, - ) -> Option> { + ) -> Option> { self.participants.get(id).cloned() } @@ -151,7 +151,7 @@ impl ParticipantService { &self, participant_id: &ParticipantId, credentials: &str, - ) -> Result, AuthorizationError> { + ) -> Result, AuthorizationError> { match self.get_participant_by_id(participant_id) { Some(participant) => { if participant.credentials().eq(credentials) { @@ -199,7 +199,7 @@ impl ParticipantService { ctx: &mut Context, participant_id: ParticipantId, con: Box, - ) -> ActFuture, ParticipantServiceErr> { + ) -> ActFuture, ParticipantServiceErr> { let participant = match self.get_participant_by_id(&participant_id) { None => { return Box::new(wrap_future(future::err( From 05d0bb06a0c674ce40835a2d3a241b024be7ee6e Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 25 Jun 2019 17:12:43 +0300 Subject: [PATCH 184/735] Minor fix --- src/signalling/control/participant.rs | 3 +-- src/signalling/room.rs | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/signalling/control/participant.rs b/src/signalling/control/participant.rs index 73639b315..3b404a325 100644 --- a/src/signalling/control/participant.rs +++ b/src/signalling/control/participant.rs @@ -1,6 +1,6 @@ //! [`Participant`] is member of [`Room`] with [`RpcConnection`]. -use std::convert::TryFrom as _; +use std::{cell::RefCell, convert::TryFrom as _, rc::Rc}; use failure::Fail; use hashbrown::HashMap; @@ -14,7 +14,6 @@ use crate::{ use super::endpoint::{ Id as EndpointId, WebRtcPlayEndpoint, WebRtcPublishEndpoint, }; -use std::{cell::RefCell, rc::Rc}; /// Errors which may occur while loading [`Participant`]s from [`RoomSpec`]. #[derive(Debug, Fail)] diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 3f61f5d38..6b7cc665e 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -402,7 +402,7 @@ impl Room { receiver.upgrade(), ctx, "Empty weak pointer for publisher receiver. {:?}.", - receiver, + publish, ); let receiver_owner = unit_option_unwrap!( From 010bc02cd5b0fe882353b8b83f1b7f3dffa1cd0d Mon Sep 17 00:00:00 2001 From: tyranron Date: Tue, 25 Jun 2019 18:06:37 +0300 Subject: [PATCH 185/735] Corrections --- .clippy.toml | 1 + Cargo.lock | 1 - Cargo.toml | 5 ++-- docker-compose.yml | 2 +- proto/client-api/src/lib.rs | 1 - src/api/client/server.rs | 44 +++++++++++++++----------------- src/signalling/room.rs | 51 +++++++++++++++++-------------------- src/turn/service.rs | 1 - 8 files changed, 49 insertions(+), 57 deletions(-) diff --git a/.clippy.toml b/.clippy.toml index 912185723..679f3a09c 100644 --- a/.clippy.toml +++ b/.clippy.toml @@ -9,4 +9,5 @@ doc-valid-idents = [ "OAuth", "OpenGL", "OpenSSH", "OpenSSL", "OpenStreetMap", "TrueType", "iOS", "macOS", "TeX", "LaTeX", "BibTeX", "BibLaTeX", "MinGW", "WebSocket", + "RTCIceServer", "RTCConfiguration", ] diff --git a/Cargo.lock b/Cargo.lock index b5f07c9ce..208434b44 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1109,7 +1109,6 @@ name = "medea" version = "0.1.0-dev" dependencies = [ "actix 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "actix-http 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "actix-http-test 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "actix-web 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index 82bd24d44..e741ef103 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,9 +21,6 @@ lto = "thin" [dependencies] actix = "0.8" -actix-codec = "0.1" -actix-http = "0.2" -actix-http-test = "0.2" actix-web = "1.0" actix-web-actors = "1.0" bb8 = "0.3" @@ -58,5 +55,7 @@ toml = "0.4" branch = "serde_wrapper" [dev-dependencies] +actix-http = "0.2" +actix-http-test = "0.2" serial_test = "0.2" serial_test_derive = "0.2" diff --git a/docker-compose.yml b/docker-compose.yml index 88e1a7473..86015777f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,4 @@ -version: "2" +version: 2 services: coturn: diff --git a/proto/client-api/src/lib.rs b/proto/client-api/src/lib.rs index 59c7805e4..f5275a9d8 100644 --- a/proto/client-api/src/lib.rs +++ b/proto/client-api/src/lib.rs @@ -93,7 +93,6 @@ pub struct Track { pub media_type: MediaType, } -#[allow(clippy::doc_markdown)] /// Representation of [RTCIceServer][1] (item of `iceServers` field /// from [RTCConfiguration][2]). /// diff --git a/src/api/client/server.rs b/src/api/client/server.rs index 95ec1a20b..af6280a00 100644 --- a/src/api/client/server.rs +++ b/src/api/client/server.rs @@ -2,11 +2,14 @@ use actix_web::{ middleware, - web::{Data, Path, Payload}, + web::{resource, Data, Path, Payload}, App, HttpRequest, HttpResponse, HttpServer, }; use actix_web_actors::ws; -use futures::{future, Future}; +use futures::{ + future::{self, Either}, + Future, +}; use serde::Deserialize; use crate::{ @@ -44,7 +47,7 @@ fn ws_index( debug!("Request params: {:?}", info); match state.rooms.get(info.room_id) { - Some(room) => future::Either::A( + Some(room) => Either::A( room.send(Authorize { member_id: info.member_id, credentials: info.credentials.clone(), @@ -68,7 +71,7 @@ fn ws_index( } }), ), - None => future::Either::B(future::ok(HttpResponse::NotFound().into())), + None => Either::B(future::ok(HttpResponse::NotFound().into())), } } @@ -84,6 +87,7 @@ pub struct Context { /// Starts HTTP server for handling WebSocket connections of Client API. pub fn run(rooms: RoomsRepository, config: Conf) { let server_addr = config.server.bind_addr(); + HttpServer::new(move || { App::new() .data(Context { @@ -92,10 +96,8 @@ pub fn run(rooms: RoomsRepository, config: Conf) { }) .wrap(middleware::Logger::default()) .service( - actix_web::web::resource( - "/ws/{room_id}/{member_id}/{credentials}", - ) - .route(actix_web::web::get().to_async(ws_index)), + resource("/ws/{room_id}/{member_id}/{credentials}") + .route(actix_web::web::get().to_async(ws_index)), ) }) .bind(server_addr) @@ -109,10 +111,9 @@ pub fn run(rooms: RoomsRepository, config: Conf) { mod test { use std::{ops::Add, thread, time::Duration}; - use actix::{Actor as _, Arbiter}; + use actix::Actor as _; use actix_http::{ws::Message, HttpService}; use actix_http_test::{TestServer, TestServerRuntime}; - use actix_web::App; use futures::{future::IntoFuture as _, sink::Sink as _, Stream as _}; use crate::{ @@ -139,15 +140,14 @@ mod test { ice_user: None }, }; - let room = Room::start_in_arbiter(&Arbiter::new(), move |_| { - Room::new( - 1, - members, - create_peers(1, 2), - conf.reconnect_timeout, - new_turn_auth_service_mock(), - ) - }); + let room = Room::new( + 1, + members, + create_peers(1, 2), + conf.reconnect_timeout, + new_turn_auth_service_mock(), + ) + .start(); let rooms = hashmap! {1 => room}; RoomsRepository::new(rooms) } @@ -162,10 +162,8 @@ mod test { config: conf.rpc.clone(), }) .service( - actix_web::web::resource( - "/ws/{room_id}/{member_id}/{credentials}", - ) - .route(actix_web::web::get().to_async(ws_index)), + resource("/ws/{room_id}/{member_id}/{credentials}") + .route(actix_web::web::get().to_async(ws_index)), ), ) }) diff --git a/src/signalling/room.rs b/src/signalling/room.rs index bec8a5fbf..86914fb4a 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -448,7 +448,7 @@ impl Handler for Room { mod test { use std::sync::{atomic::AtomicUsize, Arc, Mutex}; - use actix::{Addr, Arbiter, System}; + use actix::{Addr, System}; use medea_client_api_proto::{ AudioSettings, Direction, IceServer, MediaType, Track, VideoSettings, @@ -474,15 +474,14 @@ mod test { ice_user: None }, }; - Room::start_in_arbiter(&Arbiter::new(), move |_| { - Room::new( - 1, - members, - create_peers(1, 2), - Duration::from_secs(10), - new_turn_auth_service_mock(), - ) - }) + Room::new( + 1, + members, + create_peers(1, 2), + Duration::from_secs(10), + new_turn_auth_service_mock(), + ) + .start() } #[test] @@ -498,23 +497,21 @@ mod test { let room_clone = room.clone(); let stopped_clone = stopped.clone(); - TestConnection::start_in_arbiter(&Arbiter::new(), move |_| { - TestConnection { - events: caller_events_clone, - member_id: 1, - room: room_clone, - stopped: stopped_clone, - } - }); - - TestConnection::start_in_arbiter(&Arbiter::new(), move |_| { - TestConnection { - events: responder_events_clone, - member_id: 2, - room, - stopped, - } - }); + TestConnection { + events: caller_events_clone, + member_id: 1, + room: room_clone, + stopped: stopped_clone, + } + .start(); + + TestConnection { + events: responder_events_clone, + member_id: 2, + room, + stopped, + } + .start(); }) .unwrap(); diff --git a/src/turn/service.rs b/src/turn/service.rs index bfcedd679..fff40389c 100644 --- a/src/turn/service.rs +++ b/src/turn/service.rs @@ -182,7 +182,6 @@ pub fn new_turn_auth_service( }; let service = Service::start_in_arbiter(&Arbiter::new(), move |_| service); - Ok(Box::new(service)) } From 29180a97e2ac57fab83ddfff93e0a841f0323273 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 26 Jun 2019 12:44:42 +0300 Subject: [PATCH 186/735] Minor fix --- src/api/client/server.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/api/client/server.rs b/src/api/client/server.rs index 2b9bc970f..b91c22864 100644 --- a/src/api/client/server.rs +++ b/src/api/client/server.rs @@ -6,7 +6,10 @@ use actix_web::{ App, Error, HttpRequest, HttpResponse, HttpServer, }; use actix_web_actors::ws; -use futures::{future, Future}; +use futures::{ + future::{self, Either}, + Future, +}; use serde::Deserialize; use crate::{ @@ -44,7 +47,7 @@ fn ws_index( debug!("Request params: {:?}", info); match state.rooms.get(&info.room_id) { - Some(room) => future::Either::A( + Some(room) => Either::A( room.send(Authorize { member_id: info.member_id.clone(), credentials: info.credentials.clone(), @@ -68,7 +71,7 @@ fn ws_index( } }), ), - None => future::Either::B(future::ok(HttpResponse::NotFound().into())), + None => Either::B(future::ok(HttpResponse::NotFound().into())), } } From 778bbfe474e52377af11268c47baecda1caf71a3 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 26 Jun 2019 13:19:39 +0300 Subject: [PATCH 187/735] Delete old useless cfg for e2e tests --- src/turn/service.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/turn/service.rs b/src/turn/service.rs index 15c735352..300e07f63 100644 --- a/src/turn/service.rs +++ b/src/turn/service.rs @@ -276,7 +276,7 @@ impl Handler for Service { } } -#[cfg(any(feature = "e2e_test", test))] +#[cfg(test)] pub mod test { use futures::future; From 4ea95003408f3ea902b08d00993c1d4886e15496 Mon Sep 17 00:00:00 2001 From: alexlapa Date: Wed, 26 Jun 2019 19:30:18 +0300 Subject: [PATCH 188/735] minor refactor --- src/signalling/control/mod.rs | 3 + src/signalling/control/participant.rs | 208 +++++++++++++++----------- src/signalling/participants.rs | 26 +--- 3 files changed, 122 insertions(+), 115 deletions(-) diff --git a/src/signalling/control/mod.rs b/src/signalling/control/mod.rs index 1cb83e698..74fee0a4c 100644 --- a/src/signalling/control/mod.rs +++ b/src/signalling/control/mod.rs @@ -2,3 +2,6 @@ pub mod endpoint; pub mod participant; + +#[doc(inline)] +pub use self::participant::{Participant, ParticipantsLoadError, parse_participants}; \ No newline at end of file diff --git a/src/signalling/control/participant.rs b/src/signalling/control/participant.rs index 3b404a325..6ec0fc09e 100644 --- a/src/signalling/control/participant.rs +++ b/src/signalling/control/participant.rs @@ -7,7 +7,10 @@ use hashbrown::HashMap; use medea_client_api_proto::IceServer; use crate::{ - api::control::{MemberId, MemberSpec, RoomSpec, TryFromElementError}, + api::control::{ + MemberId as ParticipantId, MemberSpec, RoomSpec, TryFromElementError, + }, + log::prelude::*, media::{IceUser, PeerId}, }; @@ -24,7 +27,7 @@ pub enum ParticipantsLoadError { /// [`Participant`] not found. #[fail(display = "Member with id '{}' not found.", _0)] - MemberNotFound(MemberId), + ParticipantNotFound(ParticipantId), /// [`Endpoint`] not found. #[fail(display = "Endpoint with id '{}' not found.", _0)] @@ -44,7 +47,7 @@ pub struct Participant(RefCell); #[allow(clippy::module_name_repetitions)] #[derive(Debug)] struct ParticipantInner { - id: MemberId, + id: ParticipantId, /// All [`WebRtcPublishEndpoint`]s of this [`Participant`]. publishers: HashMap>, @@ -64,7 +67,7 @@ impl Participant { /// /// To fill this [`Participant`], you need to call the [`Participant::load`] /// function. - fn new(id: MemberId, credentials: String) -> Self { + fn new(id: ParticipantId, credentials: String) -> Self { Self(RefCell::new(ParticipantInner { id, publishers: HashMap::new(), @@ -74,98 +77,21 @@ impl Participant { })) } - /// Notify [`Participant`] that some [`Peer`]s removed. - /// - /// All [`PeerId`]s related to this [`Participant`] will be removed. - pub fn peers_removed(&self, peer_ids: &[PeerId]) { - self.publishers() - .into_iter() - .for_each(|(_, p)| p.remove_peer_ids(peer_ids)); - - self.receivers() - .into_iter() - .filter_map(|(_, p)| p.peer_id().map(|id| (id, p))) - .filter(|(id, _)| peer_ids.contains(&id)) - .for_each(|(_, p)| p.reset()); - } - - /// Returns list of [`IceServer`] for this [`Participant`]. - pub fn servers_list(&self) -> Option> { - self.0.borrow().ice_user.as_ref().map(IceUser::servers_list) - } - - /// Returns and set to `None` [`IceUser`] of this [`Participant`]. - pub fn take_ice_user(&self) -> Option { - self.0.borrow_mut().ice_user.take() - } - - /// Replace and return [`IceUser`] of this [`Participant`]. - pub fn replace_ice_user(&self, new_ice_user: IceUser) -> Option { - self.0.borrow_mut().ice_user.replace(new_ice_user) - } - - /// Returns [`MemberId`] of this [`Participant`]. - pub fn id(&self) -> MemberId { - self.0.borrow().id.clone() - } - - /// Returns credentials of this [`Participant`]. - pub fn credentials(&self) -> String { - self.0.borrow().credentials.clone() - } - - /// Creates all empty [`Participant`] from [`RoomSpec`] and then - /// load all related to this [`Participant`]s receivers and publishers. - /// - /// Returns store of all [`Participant`]s loaded from [`RoomSpec`]. - pub fn load_store( - room_spec: &RoomSpec, - ) -> Result>, ParticipantsLoadError> { - let members = room_spec.members()?; - let mut participants = HashMap::new(); - - for (id, member) in &members { - participants.insert( - id.clone(), - Rc::new(Self::new( - id.clone(), - member.credentials().to_string(), - )), - ); - } - - for (_, participant) in &participants { - participant.load(room_spec, &participants)?; - } - - Ok(participants) - } - - /// Returns all publishers of this [`Participant`]. - pub fn publishers(&self) -> HashMap> { - self.0.borrow().publishers.clone() - } - - /// Returns all receivers of this [`Participant`]. - pub fn receivers(&self) -> HashMap> { - self.0.borrow().receivers.clone() - } - /// Load all publishers and receivers of this [`Participant`]. fn load( &self, room_spec: &RoomSpec, - store: &HashMap>, + store: &HashMap>, ) -> Result<(), ParticipantsLoadError> { let this_member_spec = MemberSpec::try_from( room_spec.pipeline.get(&self.id().0).map_or( - Err(ParticipantsLoadError::MemberNotFound(self.id())), + Err(ParticipantsLoadError::ParticipantNotFound(self.id())), Ok, )?, )?; let this_member = store.get(&self.id()).map_or( - Err(ParticipantsLoadError::MemberNotFound(self.id())), + Err(ParticipantsLoadError::ParticipantNotFound(self.id())), Ok, )?; @@ -173,9 +99,9 @@ impl Participant { this_member_spec.play_endpoints() { let publisher_id = - MemberId(spec_play_endpoint.src.member_id.to_string()); + ParticipantId(spec_play_endpoint.src.member_id.to_string()); let publisher_participant = store.get(&publisher_id).map_or( - Err(ParticipantsLoadError::MemberNotFound(publisher_id)), + Err(ParticipantsLoadError::ParticipantNotFound(publisher_id)), Ok, )?; let publisher_spec = MemberSpec::try_from( @@ -183,7 +109,7 @@ impl Participant { .pipeline .get(&spec_play_endpoint.src.member_id.to_string()) .map_or( - Err(ParticipantsLoadError::MemberNotFound( + Err(ParticipantsLoadError::ParticipantNotFound( spec_play_endpoint.src.member_id.clone(), )), Ok, @@ -260,6 +186,56 @@ impl Participant { Ok(()) } + /// Notify [`Participant`] that some [`Peer`]s removed. + /// + /// All [`PeerId`]s related to this [`Participant`] will be removed. + pub fn peers_removed(&self, peer_ids: &[PeerId]) { + self.publishers() + .into_iter() + .for_each(|(_, p)| p.remove_peer_ids(peer_ids)); + + self.receivers() + .into_iter() + .filter_map(|(_, p)| p.peer_id().map(|id| (id, p))) + .filter(|(id, _)| peer_ids.contains(&id)) + .for_each(|(_, p)| p.reset()); + } + + /// Returns list of [`IceServer`] for this [`Participant`]. + pub fn servers_list(&self) -> Option> { + self.0.borrow().ice_user.as_ref().map(IceUser::servers_list) + } + + /// Returns and set to `None` [`IceUser`] of this [`Participant`]. + pub fn take_ice_user(&self) -> Option { + self.0.borrow_mut().ice_user.take() + } + + /// Replace and return [`IceUser`] of this [`Participant`]. + pub fn replace_ice_user(&self, new_ice_user: IceUser) -> Option { + self.0.borrow_mut().ice_user.replace(new_ice_user) + } + + /// Returns [`ParticipantId`] of this [`Participant`]. + pub fn id(&self) -> ParticipantId { + self.0.borrow().id.clone() + } + + /// Returns credentials of this [`Participant`]. + pub fn credentials(&self) -> String { + self.0.borrow().credentials.clone() + } + + /// Returns all publishers of this [`Participant`]. + pub fn publishers(&self) -> HashMap> { + self.0.borrow().publishers.clone() + } + + /// Returns all receivers of this [`Participant`]. + pub fn receivers(&self) -> HashMap> { + self.0.borrow().receivers.clone() + } + /// Insert receiver into this [`Participant`]. pub fn insert_receiver(&self, endpoint: Rc) { self.0 @@ -303,6 +279,54 @@ impl Participant { } } +/// Creates all empty [`Participant`] from [`RoomSpec`] and then +/// load all related to this [`Participant`]s receivers and publishers. +/// +/// Returns store of all [`Participant`]s loaded from [`RoomSpec`]. +pub fn parse_participants( + room_spec: &RoomSpec, +) -> Result>, ParticipantsLoadError> { + let members = room_spec.members()?; + let mut participants = HashMap::new(); + + for (id, member) in &members { + participants.insert( + id.clone(), + Rc::new(Participant::new( + id.clone(), + member.credentials().to_string(), + )), + ); + } + + for (_, participant) in &participants { + participant.load(room_spec, &participants)?; + } + + debug!( + "Created ParticipantService with participants: {:?}.", + participants + .iter() + .map(|(id, p)| { + format!( + "{{ id: {}, receivers: {:?}, publishers: {:?} }};", + id, + p.receivers() + .into_iter() + .map(|(id, _)| id.to_string()) + .collect::>(), + p.publishers() + .into_iter() + .map(|(id, _)| id.to_string()) + .collect::>() + ) + }) + .collect::>() + ); + + Ok(participants) +} + #[cfg(test)] mod participant_loading_tests { use std::rc::Rc; @@ -354,8 +378,9 @@ mod participant_loading_tests { let room_spec = RoomSpec::try_from(&room_element).unwrap(); let store = Participant::load_store(&room_spec).unwrap(); - let caller = store.get(&MemberId("caller".to_string())).unwrap(); - let responder = store.get(&MemberId("responder".to_string())).unwrap(); + let caller = store.get(&ParticipantId("caller".to_string())).unwrap(); + let responder = + store.get(&ParticipantId("responder".to_string())).unwrap(); let caller_publish_endpoint = caller .get_publisher_by_id(&EndpointId("publish".to_string())) @@ -378,8 +403,9 @@ mod participant_loading_tests { &caller_publish_endpoint )); - let some_participant = - store.get(&MemberId("some-member".to_string())).unwrap(); + let some_participant = store + .get(&ParticipantId("some-member".to_string())) + .unwrap(); assert!(some_participant.receivers().is_empty()); assert_eq!(some_participant.publishers().len(), 1); diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 7a04741ba..976842ea2 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -31,7 +31,7 @@ use crate::{ log::prelude::*, media::IceUser, signalling::{ - control::participant::{Participant, ParticipantsLoadError}, + control::{Participant, ParticipantsLoadError, parse_participants}, room::{ActFuture, RoomError}, Room, }, @@ -101,32 +101,10 @@ impl ParticipantService { reconnect_timeout: Duration, turn: Box, ) -> Result { - let participants = Participant::load_store(room_spec)?; - - debug!( - "Created ParticipantService with participants: {:?}.", - participants - .iter() - .map(|(id, p)| { - format!( - "{{ id: {}, receivers: {:?}, publishers: {:?} }};", - id, - p.receivers() - .into_iter() - .map(|(id, _)| id.to_string()) - .collect::>(), - p.publishers() - .into_iter() - .map(|(id, _)| id.to_string()) - .collect::>() - ) - }) - .collect::>() - ); Ok(Self { room_id: room_spec.id().clone(), - participants, + participants: parse_participants(room_spec)?, turn, connections: HashMap::new(), reconnect_timeout, From d5553311f58ccf086a37b4f67f447b01e50f52fb Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 27 Jun 2019 12:37:40 +0300 Subject: [PATCH 189/735] Convert ConnectPeers into function --- src/signalling/control/mod.rs | 4 +- src/signalling/participants.rs | 3 +- src/signalling/room.rs | 73 ++++++++++++++++------------------ 3 files changed, 38 insertions(+), 42 deletions(-) diff --git a/src/signalling/control/mod.rs b/src/signalling/control/mod.rs index 74fee0a4c..6e59c0562 100644 --- a/src/signalling/control/mod.rs +++ b/src/signalling/control/mod.rs @@ -4,4 +4,6 @@ pub mod endpoint; pub mod participant; #[doc(inline)] -pub use self::participant::{Participant, ParticipantsLoadError, parse_participants}; \ No newline at end of file +pub use self::participant::{ + parse_participants, Participant, ParticipantsLoadError, +}; diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 976842ea2..74721ca42 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -31,7 +31,7 @@ use crate::{ log::prelude::*, media::IceUser, signalling::{ - control::{Participant, ParticipantsLoadError, parse_participants}, + control::{parse_participants, Participant, ParticipantsLoadError}, room::{ActFuture, RoomError}, Room, }, @@ -101,7 +101,6 @@ impl ParticipantService { reconnect_timeout: Duration, turn: Box, ) -> Result { - Ok(Self { room_id: room_spec.id().clone(), participants: parse_participants(room_spec)?, diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 6b7cc665e..beb8d6eed 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -381,7 +381,7 @@ impl Room { let (first_peer_id, second_peer_id) = self.peers.create_peers(first_member, second_member); - ctx.notify(ConnectPeers(first_peer_id, second_peer_id)); + self.connect_peers(ctx, first_peer_id, second_peer_id); } /// Create and interconnect all [`Peer`]s between connected [`Participant`] @@ -457,6 +457,39 @@ impl Room { } } } + + /// Check state of interconnected [`Peer`]s and sends [`Event`] about + /// [`Peer`] created to remote [`Participant`]. + fn connect_peers( + &mut self, + ctx: &mut Context, + first_peer: PeerId, + second_peer: PeerId, + ) { + let fut: ActFuture<(), ()> = match self + .send_peer_created(first_peer, second_peer) + { + Ok(res) => { + Box::new(res.map_err(|err, _, ctx: &mut Context| { + error!( + "Failed handle command, because {}. Room will be \ + stopped.", + err + ); + ctx.notify(CloseRoom {}) + })) + } + Err(err) => { + error!( + "Failed handle command, because {}. Room will be stopped.", + err + ); + ctx.notify(CloseRoom {}); + Box::new(wrap_future(future::ok(()))) + } + }; + ctx.spawn(fut); + } } /// [`Actor`] implementation that provides an ergonomic way @@ -484,44 +517,6 @@ impl Handler for Room { } } -/// Signal of start signaling between specified [`Peer`]'s. -#[derive(Debug, Message)] -#[rtype(result = "Result<(), ()>")] -pub struct ConnectPeers(PeerId, PeerId); - -impl Handler for Room { - type Result = ActFuture<(), ()>; - - /// Check state of interconnected [`Peer`]s and sends [`Event`] about - /// [`Peer`] created to remote [`Participant`]. - fn handle( - &mut self, - msg: ConnectPeers, - ctx: &mut Self::Context, - ) -> Self::Result { - match self.send_peer_created(msg.0, msg.1) { - Ok(res) => { - Box::new(res.map_err(|err, _, ctx: &mut Context| { - error!( - "Failed handle command, because {}. Room will be \ - stopped.", - err - ); - ctx.notify(CloseRoom {}) - })) - } - Err(err) => { - error!( - "Failed handle command, because {}. Room will be stopped.", - err - ); - ctx.notify(CloseRoom {}); - Box::new(wrap_future(future::ok(()))) - } - } - } -} - /// Signal of removing [`Participant`]'s [`Peer`]s. #[derive(Debug, Message)] #[rtype(result = "Result<(), ()>")] From 7ca8af5e6316b9ec5e64f6f33bfa1d5b6d0d9be1 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 27 Jun 2019 15:20:10 +0300 Subject: [PATCH 190/735] Add build cache and start e2e in official rust image --- .dockerignore | 10 +++++++++- Dockerfile | 9 +++++++++ Makefile | 38 +++++++++++++++++++++++--------------- 3 files changed, 41 insertions(+), 16 deletions(-) diff --git a/.dockerignore b/.dockerignore index eb5a316cb..4a36a0500 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1 +1,9 @@ -target +* +!Cargo.toml +!Cargo.lock +!src +!crates +!jason/Cargo.toml +!jason/src +!proto +!Makefile diff --git a/Dockerfile b/Dockerfile index 01424d02f..95db9b381 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,6 +17,15 @@ RUN mkdir -p /out/etc/ \ COPY / /app/ +RUN mkdir -p /app/target +RUN mkdir -p /usr/local/cargo + +VOLUME .cache/medea:/app/target +VOLUME .cache/cargo:/usr/local/cargo + +RUN touch /app/target +RUN ls /app + # Build project distribution. RUN cd /app \ # Compile project. diff --git a/Makefile b/Makefile index 80d2a9cba..77d1f530c 100644 --- a/Makefile +++ b/Makefile @@ -155,34 +155,42 @@ endif # Usage: # make test.e2e [dockerized=(yes|no)] [logs=(yes|no)] -medea-env-dockerized = MEDEA_SERVER_BIND_PORT=8081 \ - $(if $(call eq,$(logs),yes),,RUST_LOG=warn) \ - MEDEA_SERVER_STATIC_SPECS_PATH=tests/specs - -medea-env-debug = RUST_BACKTRACE=1 \ +medea-env = RUST_BACKTRACE=1 \ MEDEA_SERVER.BIND_PORT=8081 \ - MEDEA_SERVER.STATIC_SPECS_PATH=./tests/specs \ - $(if $(call eq,$(logs),yes),,RUST_LOG=warn) + $(if $(call eq,$(logs),yes),,RUST_LOG=warn) \ + MEDEA_SERVER.STATIC_SPECS_PATH=tests/specs -test.e2e: up.coturn +test.e2e: +ifeq ($(coturn),no) +else + @make up.coturn +endif ifeq ($(dockerized),no) - @make down.medea dockerized=yes @make down.medea dockerized=no - cargo build - env $(medea-env-debug) $(if $(call eq,$(logs),yes),,RUST_LOG=warn) cargo run & + cargo build $(if $(call eq,$(release),yes),--release) + env $(medea-env) $(if $(call eq,$(logs),yes),,RUST_LOG=warn) cargo run $(if $(call eq,$(release),yes),--release) & + sleep 1 - cargo test --test e2e @make down.medea +ifeq ($(coturn),no) +else + @make down.coturn +endif else @make down.medea dockerized=yes @make down.medea dockerized=no + @make up.coturn - env $(medea-env-dockerized) docker-compose -f docker-compose.medea.yml up -d --build - docker-compose -f docker-compose.medea.yml logs & - - cargo test --test e2e - - @make down.medea dockerized=yes + docker run --rm --network=host -v "$(PWD)":/app -w /app \ + -v "$(PWD)/.cache/medea/registry":/usr/local/cargo/registry \ + -v "$(PWD)/.cache/medea/target":/app/target \ + rust:latest \ + make test.e2e dockerized=no coturn=no release=yes + + @make down.coturn endif From bbdc901523244ef311d90374ec6f9c9ffba82dd9 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 27 Jun 2019 17:31:37 +0300 Subject: [PATCH 191/735] WIP create basic structure --- src/media/peer.rs | 2 +- src/signalling/control/endpoint.rs | 301 ------------ src/signalling/control/member.rs | 24 + src/signalling/control/mod.rs | 10 +- src/signalling/control/participant.rs | 429 ------------------ src/signalling/control/play_endpoint.rs | 17 + src/signalling/control/publish_endpoint.rs | 18 + src/signalling/endpoints_manager.rs | 63 +++ .../{participants.rs => members_manager.rs} | 138 +++--- src/signalling/mod.rs | 4 +- src/signalling/peers.rs | 16 +- src/signalling/pipeline.rs | 51 +++ src/signalling/room.rs | 80 ++-- src/turn/service.rs | 5 +- 14 files changed, 284 insertions(+), 874 deletions(-) delete mode 100644 src/signalling/control/endpoint.rs create mode 100644 src/signalling/control/member.rs delete mode 100644 src/signalling/control/participant.rs create mode 100644 src/signalling/control/play_endpoint.rs create mode 100644 src/signalling/control/publish_endpoint.rs create mode 100644 src/signalling/endpoints_manager.rs rename src/signalling/{participants.rs => members_manager.rs} (65%) create mode 100644 src/signalling/pipeline.rs diff --git a/src/media/peer.rs b/src/media/peer.rs index d853b7890..2cb72a6da 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -18,7 +18,7 @@ use crate::{ log::prelude::*, media::{MediaTrack, TrackId}, signalling::{ - control::endpoint::{Id as EndpointId, WebRtcPublishEndpoint}, + control::publish_endpoint::{Id as EndpointId, WebRtcPublishEndpoint}, peers::Counter, }, }; diff --git a/src/signalling/control/endpoint.rs b/src/signalling/control/endpoint.rs deleted file mode 100644 index 33ca78451..000000000 --- a/src/signalling/control/endpoint.rs +++ /dev/null @@ -1,301 +0,0 @@ -//! Signalling representation of endpoints. - -use std::{cell::RefCell, fmt::Display, rc::Weak}; - -use hashbrown::HashSet; - -use crate::{ - api::control::endpoint::{P2pMode, SrcUri}, - media::PeerId, -}; - -use super::participant::Participant; - -/// ID of endpoint. -#[derive(Clone, Debug, Eq, Hash, PartialEq)] -pub struct Id(pub String); - -impl Display for Id { - fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(fmt, "{}", self.0) - } -} - -#[derive(Debug, Clone)] -struct WebRtcPlayEndpointInner { - /// ID of this [`WebRtcPlayEndpoint`]. - id: Id, - - /// Source URI of [`WebRtcPublishEndpoint`] from which this - /// [`WebRtcPlayEndpoint`] receive data. - src: SrcUri, - - /// Publisher [`WebRtcPublishEndpoint`] from which this - /// [`WebRtcPlayEndpoint`] receive data. - publisher: Weak, - - /// Owner [`Participant`] of this [`WebRtcPlayEndpoint`]. - owner: Weak, - - /// [`PeerId`] of [`Peer`] created for this [`WebRtcPlayEndpoint`]. - /// - /// Currently this field used for detecting status of this - /// [`WebRtcPlayEndpoint`] connection. - /// - /// In future this may be used for removing [`WebRtcPlayEndpoint`] - /// and related peer. - peer_id: Option, -} - -impl WebRtcPlayEndpointInner { - fn src(&self) -> SrcUri { - self.src.clone() - } - - fn owner(&self) -> Weak { - Weak::clone(&self.owner) - } - - fn publisher(&self) -> Weak { - self.publisher.clone() - } - - fn is_connected(&self) -> bool { - self.peer_id.is_some() - } - - fn set_peer_id(&mut self, peer_id: PeerId) { - self.peer_id = Some(peer_id) - } - - fn peer_id(&self) -> Option { - self.peer_id - } - - fn reset(&mut self) { - self.peer_id = None - } -} - -impl Drop for WebRtcPlayEndpointInner { - fn drop(&mut self) { - if let Some(receiver_publisher) = self.publisher().upgrade() { - receiver_publisher.remove_empty_weaks_from_receivers(); - } - } -} - -/// Signalling representation of `WebRtcPlayEndpoint`. -#[allow(clippy::module_name_repetitions)] -#[derive(Debug)] -pub struct WebRtcPlayEndpoint(RefCell); - -impl WebRtcPlayEndpoint { - /// Create new [`WebRtcPlayEndpoint`]. - pub fn new( - id: Id, - src: SrcUri, - publisher: Weak, - owner: Weak, - ) -> Self { - Self(RefCell::new(WebRtcPlayEndpointInner { - id, - src, - publisher, - owner, - peer_id: None, - })) - } - - /// Returns [`SrcUri`] of this [`WebRtcPlayEndpoint`]. - pub fn src(&self) -> SrcUri { - self.0.borrow().src() - } - - /// Returns owner [`Participant`] of this [`WebRtcPlayEndpoint`]. - pub fn owner(&self) -> Weak { - self.0.borrow().owner() - } - - /// Returns publisher's [`WebRtcPublishEndpoint`]. - pub fn publisher(&self) -> Weak { - self.0.borrow().publisher() - } - - /// Check that peer connection established for this [`WebRtcPlayEndpoint`]. - pub fn is_connected(&self) -> bool { - self.0.borrow().is_connected() - } - - /// Save [`PeerId`] of this [`WebRtcPlayEndpoint`]. - pub fn connect(&self, peer_id: PeerId) { - self.0.borrow_mut().set_peer_id(peer_id); - } - - /// Return [`PeerId`] of [`Peer`] of this [`WebRtcPlayEndpoint`]. - pub fn peer_id(&self) -> Option { - self.0.borrow().peer_id() - } - - /// Reset state of this [`WebRtcPlayEndpoint`]. - /// - /// Atm this only reset peer_id. - pub fn reset(&self) { - self.0.borrow_mut().reset() - } - - /// Returns ID of this [`WebRtcPlayEndpoint`]. - pub fn id(&self) -> Id { - self.0.borrow().id.clone() - } -} - -#[derive(Debug, Clone)] -struct WebRtcPublishEndpointInner { - /// ID of this [`WebRtcPublishEndpoint`]. - id: Id, - - /// P2P connection mode for this [`WebRtcPublishEndpoint`]. - p2p: P2pMode, - - /// All receivers of this [`WebRtcPublishEndpoint`]. - receivers: Vec>, - - /// Owner [`Participant`] of this [`WebRtcPublishEndpoint`]. - owner: Weak, - - /// [`PeerId`] of all [`Peer`]s created for this [`WebRtcPublishEndpoint`]. - /// - /// Currently this field used for nothing but in future this may be used - /// while removing [`WebRtcPublishEndpoint`] for removing all [`Peer`]s of - /// this [`WebRtcPublishEndpoint`]. - peer_ids: HashSet, -} - -impl Drop for WebRtcPublishEndpointInner { - fn drop(&mut self) { - for receiver in self.receivers().iter().filter_map(|r| Weak::upgrade(r)) - { - if let Some(receiver_owner) = receiver.owner().upgrade() { - receiver_owner.remove_receiver(&receiver.id()) - } - } - } -} - -impl WebRtcPublishEndpointInner { - fn add_receiver(&mut self, receiver: Weak) { - self.receivers.push(receiver); - } - - fn receivers(&self) -> Vec> { - self.receivers.clone() - } - - fn owner(&self) -> Weak { - Weak::clone(&self.owner) - } - - fn add_peer_id(&mut self, peer_id: PeerId) { - self.peer_ids.insert(peer_id); - } - - fn peer_ids(&self) -> HashSet { - self.peer_ids.clone() - } - - fn reset(&mut self) { - self.peer_ids = HashSet::new() - } - - #[allow(clippy::trivially_copy_pass_by_ref)] - fn remove_peer_id(&mut self, peer_id: &PeerId) { - self.peer_ids.remove(peer_id); - } - - fn remove_peer_ids(&mut self, peer_ids: &[PeerId]) { - for peer_id in peer_ids { - self.remove_peer_id(peer_id) - } - } -} - -/// Signalling representation of `WebRtcPublishEndpoint`. -#[allow(clippy::module_name_repetitions)] -#[derive(Debug)] -pub struct WebRtcPublishEndpoint(RefCell); - -impl WebRtcPublishEndpoint { - /// Create new [`WebRtcPublishEndpoint`]. - pub fn new( - id: Id, - p2p: P2pMode, - receivers: Vec>, - owner: Weak, - ) -> Self { - Self(RefCell::new(WebRtcPublishEndpointInner { - id, - p2p, - receivers, - owner, - peer_ids: HashSet::new(), - })) - } - - /// Add receiver for this [`WebRtcPublishEndpoint`]. - pub fn add_receiver(&self, receiver: Weak) { - self.0.borrow_mut().add_receiver(receiver) - } - - /// Returns all receivers of this [`WebRtcPublishEndpoint`]. - pub fn receivers(&self) -> Vec> { - self.0.borrow().receivers() - } - - /// Returns owner [`Participant`] of this [`WebRtcPublishEndpoint`]. - pub fn owner(&self) -> Weak { - self.0.borrow().owner() - } - - /// Add [`PeerId`] of this [`WebRtcPublishEndpoint`]. - pub fn add_peer_id(&self, peer_id: PeerId) { - self.0.borrow_mut().add_peer_id(peer_id) - } - - /// Returns all [`PeerId`] of this [`WebRtcPublishEndpoint`]. - pub fn peer_ids(&self) -> HashSet { - self.0.borrow().peer_ids() - } - - /// Reset state of this [`WebRtcPublishEndpoint`]. - /// - /// Atm this only reset peer_ids. - pub fn reset(&self) { - self.0.borrow_mut().reset() - } - - /// Remove [`PeerId`] from peer_ids. - #[allow(clippy::trivially_copy_pass_by_ref)] - pub fn remove_peer_id(&self, peer_id: &PeerId) { - self.0.borrow_mut().remove_peer_id(peer_id) - } - - /// Remove all [`PeerId`]s related to this [`WebRtcPublishEndpoint`]. - pub fn remove_peer_ids(&self, peer_ids: &[PeerId]) { - self.0.borrow_mut().remove_peer_ids(peer_ids) - } - - /// Returns ID of this [`WebRtcPublishEndpoint`]. - pub fn id(&self) -> Id { - self.0.borrow().id.clone() - } - - /// Remove all empty Weak pointers from receivers of this - /// [`WebRtcPublishEndpoint`]. - pub fn remove_empty_weaks_from_receivers(&self) { - self.0 - .borrow_mut() - .receivers - .retain(|e| e.upgrade().is_some()); - } -} diff --git a/src/signalling/control/member.rs b/src/signalling/control/member.rs new file mode 100644 index 000000000..b53930728 --- /dev/null +++ b/src/signalling/control/member.rs @@ -0,0 +1,24 @@ +use crate::api::client::rpc_connection::RpcConnection; + +pub use crate::api::control::MemberId; + +#[derive(Debug)] +pub struct Member { + id: MemberId, + credentials: String, + connection: Option> +} + +impl Member { + pub fn connection(&self) -> Option<&Box> { + self.connection.as_ref() + } + + pub fn take_connection(&mut self) -> Option> { + self.connection.take() + } + + pub fn id(&self) -> &MemberId { + &self.id + } +} diff --git a/src/signalling/control/mod.rs b/src/signalling/control/mod.rs index 6e59c0562..85fb3464e 100644 --- a/src/signalling/control/mod.rs +++ b/src/signalling/control/mod.rs @@ -1,9 +1,5 @@ //! Signalling representation of control spec. -pub mod endpoint; -pub mod participant; - -#[doc(inline)] -pub use self::participant::{ - parse_participants, Participant, ParticipantsLoadError, -}; +pub mod publish_endpoint; +pub mod play_endpoint; +pub mod member; diff --git a/src/signalling/control/participant.rs b/src/signalling/control/participant.rs deleted file mode 100644 index 6ec0fc09e..000000000 --- a/src/signalling/control/participant.rs +++ /dev/null @@ -1,429 +0,0 @@ -//! [`Participant`] is member of [`Room`] with [`RpcConnection`]. - -use std::{cell::RefCell, convert::TryFrom as _, rc::Rc}; - -use failure::Fail; -use hashbrown::HashMap; -use medea_client_api_proto::IceServer; - -use crate::{ - api::control::{ - MemberId as ParticipantId, MemberSpec, RoomSpec, TryFromElementError, - }, - log::prelude::*, - media::{IceUser, PeerId}, -}; - -use super::endpoint::{ - Id as EndpointId, WebRtcPlayEndpoint, WebRtcPublishEndpoint, -}; - -/// Errors which may occur while loading [`Participant`]s from [`RoomSpec`]. -#[derive(Debug, Fail)] -pub enum ParticipantsLoadError { - /// Errors that can occur when we try transform some spec from [`Element`]. - #[fail(display = "TryFromElementError: {}", _0)] - TryFromError(TryFromElementError), - - /// [`Participant`] not found. - #[fail(display = "Member with id '{}' not found.", _0)] - ParticipantNotFound(ParticipantId), - - /// [`Endpoint`] not found. - #[fail(display = "Endpoint with id '{}' not found.", _0)] - EndpointNotFound(String), -} - -impl From for ParticipantsLoadError { - fn from(err: TryFromElementError) -> Self { - ParticipantsLoadError::TryFromError(err) - } -} - -/// [`Participant`] is member of [`Room`] with [`RpcConnection`]. -#[derive(Debug)] -pub struct Participant(RefCell); - -#[allow(clippy::module_name_repetitions)] -#[derive(Debug)] -struct ParticipantInner { - id: ParticipantId, - - /// All [`WebRtcPublishEndpoint`]s of this [`Participant`]. - publishers: HashMap>, - - /// All [`WebRtcPlayEndpoint`]s of this [`Participant`]. - receivers: HashMap>, - - /// Credentials for this [`Participant`]. - credentials: String, - - /// [`IceUser`] of this [`Participant`]. - ice_user: Option, -} - -impl Participant { - /// Create new empty [`Participant`]. - /// - /// To fill this [`Participant`], you need to call the [`Participant::load`] - /// function. - fn new(id: ParticipantId, credentials: String) -> Self { - Self(RefCell::new(ParticipantInner { - id, - publishers: HashMap::new(), - receivers: HashMap::new(), - credentials, - ice_user: None, - })) - } - - /// Load all publishers and receivers of this [`Participant`]. - fn load( - &self, - room_spec: &RoomSpec, - store: &HashMap>, - ) -> Result<(), ParticipantsLoadError> { - let this_member_spec = MemberSpec::try_from( - room_spec.pipeline.get(&self.id().0).map_or( - Err(ParticipantsLoadError::ParticipantNotFound(self.id())), - Ok, - )?, - )?; - - let this_member = store.get(&self.id()).map_or( - Err(ParticipantsLoadError::ParticipantNotFound(self.id())), - Ok, - )?; - - for (spec_play_name, spec_play_endpoint) in - this_member_spec.play_endpoints() - { - let publisher_id = - ParticipantId(spec_play_endpoint.src.member_id.to_string()); - let publisher_participant = store.get(&publisher_id).map_or( - Err(ParticipantsLoadError::ParticipantNotFound(publisher_id)), - Ok, - )?; - let publisher_spec = MemberSpec::try_from( - room_spec - .pipeline - .get(&spec_play_endpoint.src.member_id.to_string()) - .map_or( - Err(ParticipantsLoadError::ParticipantNotFound( - spec_play_endpoint.src.member_id.clone(), - )), - Ok, - )?, - )?; - - let publisher_endpoint = *publisher_spec - .publish_endpoints() - .get(&spec_play_endpoint.src.endpoint_id) - .map_or( - Err(ParticipantsLoadError::EndpointNotFound( - spec_play_endpoint.src.endpoint_id.clone(), - )), - Ok, - )?; - - if let Some(publisher) = publisher_participant.get_publisher_by_id( - &EndpointId(spec_play_endpoint.src.endpoint_id.to_string()), - ) { - let new_play_endpoint_id = - EndpointId(spec_play_name.to_string()); - let new_play_endpoint = Rc::new(WebRtcPlayEndpoint::new( - new_play_endpoint_id.clone(), - spec_play_endpoint.src.clone(), - Rc::downgrade(&publisher), - Rc::downgrade(&this_member), - )); - - self.insert_receiver(Rc::clone(&new_play_endpoint)); - - publisher.add_receiver(Rc::downgrade(&new_play_endpoint)); - } else { - let new_publish_id = - EndpointId(spec_play_endpoint.src.endpoint_id.to_string()); - let new_publish = Rc::new(WebRtcPublishEndpoint::new( - new_publish_id.clone(), - publisher_endpoint.p2p.clone(), - Vec::new(), - Rc::downgrade(&publisher_participant), - )); - - let new_self_play_id = EndpointId(spec_play_name.to_string()); - let new_self_play = Rc::new(WebRtcPlayEndpoint::new( - new_self_play_id.clone(), - spec_play_endpoint.src.clone(), - Rc::downgrade(&new_publish), - Rc::downgrade(&this_member), - )); - - new_publish.add_receiver(Rc::downgrade(&new_self_play)); - - publisher_participant.insert_publisher(new_publish); - - self.insert_receiver(new_self_play); - } - } - - // This is necessary to create [`WebRtcPublishEndpoint`], - // to which none [`WebRtcPlayEndpoint`] refers. - this_member_spec.publish_endpoints().into_iter().for_each( - |(name, e)| { - let endpoint_id = EndpointId(name.clone()); - if self.publishers().get(&endpoint_id).is_none() { - self.insert_publisher(Rc::new(WebRtcPublishEndpoint::new( - endpoint_id, - e.p2p.clone(), - Vec::new(), - Rc::downgrade(&this_member), - ))); - } - }, - ); - - Ok(()) - } - - /// Notify [`Participant`] that some [`Peer`]s removed. - /// - /// All [`PeerId`]s related to this [`Participant`] will be removed. - pub fn peers_removed(&self, peer_ids: &[PeerId]) { - self.publishers() - .into_iter() - .for_each(|(_, p)| p.remove_peer_ids(peer_ids)); - - self.receivers() - .into_iter() - .filter_map(|(_, p)| p.peer_id().map(|id| (id, p))) - .filter(|(id, _)| peer_ids.contains(&id)) - .for_each(|(_, p)| p.reset()); - } - - /// Returns list of [`IceServer`] for this [`Participant`]. - pub fn servers_list(&self) -> Option> { - self.0.borrow().ice_user.as_ref().map(IceUser::servers_list) - } - - /// Returns and set to `None` [`IceUser`] of this [`Participant`]. - pub fn take_ice_user(&self) -> Option { - self.0.borrow_mut().ice_user.take() - } - - /// Replace and return [`IceUser`] of this [`Participant`]. - pub fn replace_ice_user(&self, new_ice_user: IceUser) -> Option { - self.0.borrow_mut().ice_user.replace(new_ice_user) - } - - /// Returns [`ParticipantId`] of this [`Participant`]. - pub fn id(&self) -> ParticipantId { - self.0.borrow().id.clone() - } - - /// Returns credentials of this [`Participant`]. - pub fn credentials(&self) -> String { - self.0.borrow().credentials.clone() - } - - /// Returns all publishers of this [`Participant`]. - pub fn publishers(&self) -> HashMap> { - self.0.borrow().publishers.clone() - } - - /// Returns all receivers of this [`Participant`]. - pub fn receivers(&self) -> HashMap> { - self.0.borrow().receivers.clone() - } - - /// Insert receiver into this [`Participant`]. - pub fn insert_receiver(&self, endpoint: Rc) { - self.0 - .borrow_mut() - .receivers - .insert(endpoint.id(), endpoint); - } - - /// Insert publisher into this [`Participant`]. - pub fn insert_publisher(&self, endpoint: Rc) { - self.0 - .borrow_mut() - .publishers - .insert(endpoint.id(), endpoint); - } - - /// Lookup [`WebRtcPublishEndpoint`] publisher by [`EndpointId`]. - pub fn get_publisher_by_id( - &self, - id: &EndpointId, - ) -> Option> { - self.0.borrow().publishers.get(id).cloned() - } - - /// Lookup [`WebRtcPlayEndpoint`] receiver by [`EndpointId`]. - pub fn get_receiver_by_id( - &self, - id: &EndpointId, - ) -> Option> { - self.0.borrow().receivers.get(id).cloned() - } - - /// Remove receiver [`WebRtcPlayEndpoint`] from this [`Participant`]. - pub fn remove_receiver(&self, id: &EndpointId) { - self.0.borrow_mut().receivers.remove(id); - } - - /// Remove receiver [`WebRtcPublishEndpoint`] from this [`Participant`]. - pub fn remove_publisher(&self, id: &EndpointId) { - self.0.borrow_mut().publishers.remove(id); - } -} - -/// Creates all empty [`Participant`] from [`RoomSpec`] and then -/// load all related to this [`Participant`]s receivers and publishers. -/// -/// Returns store of all [`Participant`]s loaded from [`RoomSpec`]. -pub fn parse_participants( - room_spec: &RoomSpec, -) -> Result>, ParticipantsLoadError> { - let members = room_spec.members()?; - let mut participants = HashMap::new(); - - for (id, member) in &members { - participants.insert( - id.clone(), - Rc::new(Participant::new( - id.clone(), - member.credentials().to_string(), - )), - ); - } - - for (_, participant) in &participants { - participant.load(room_spec, &participants)?; - } - - debug!( - "Created ParticipantService with participants: {:?}.", - participants - .iter() - .map(|(id, p)| { - format!( - "{{ id: {}, receivers: {:?}, publishers: {:?} }};", - id, - p.receivers() - .into_iter() - .map(|(id, _)| id.to_string()) - .collect::>(), - p.publishers() - .into_iter() - .map(|(id, _)| id.to_string()) - .collect::>() - ) - }) - .collect::>() - ); - - Ok(participants) -} - -#[cfg(test)] -mod participant_loading_tests { - use std::rc::Rc; - - use crate::api::control::Element; - - use super::*; - - #[test] - pub fn load_store() { - let spec = r#" - kind: Room - id: test-call - spec: - pipeline: - caller: - kind: Member - credentials: test - spec: - pipeline: - publish: - kind: WebRtcPublishEndpoint - spec: - p2p: Always - some-member: - kind: Member - credentials: test - spec: - pipeline: - publish: - kind: WebRtcPublishEndpoint - spec: - p2p: Always - responder: - kind: Member - credentials: test - spec: - pipeline: - play: - kind: WebRtcPlayEndpoint - spec: - src: "local://test-call/caller/publish" - play2: - kind: WebRtcPlayEndpoint - spec: - src: "local://test-call/some-member/publish" - "#; - let room_element: Element = serde_yaml::from_str(&spec).unwrap(); - let room_spec = RoomSpec::try_from(&room_element).unwrap(); - let store = Participant::load_store(&room_spec).unwrap(); - - let caller = store.get(&ParticipantId("caller".to_string())).unwrap(); - let responder = - store.get(&ParticipantId("responder".to_string())).unwrap(); - - let caller_publish_endpoint = caller - .get_publisher_by_id(&EndpointId("publish".to_string())) - .unwrap(); - let responder_play_endpoint = responder - .get_receiver_by_id(&EndpointId("play".to_string())) - .unwrap(); - - let is_caller_has_responder_in_receivers = caller_publish_endpoint - .receivers() - .into_iter() - .map(|p| p.upgrade().unwrap()) - .filter(|p| Rc::ptr_eq(p, &responder_play_endpoint)) - .count() - == 1; - assert!(is_caller_has_responder_in_receivers); - - assert!(Rc::ptr_eq( - &responder_play_endpoint.publisher().upgrade().unwrap(), - &caller_publish_endpoint - )); - - let some_participant = store - .get(&ParticipantId("some-member".to_string())) - .unwrap(); - assert!(some_participant.receivers().is_empty()); - assert_eq!(some_participant.publishers().len(), 1); - - let responder_play2_endpoint = responder - .get_receiver_by_id(&EndpointId("play2".to_string())) - .unwrap(); - let some_participant_publisher = some_participant - .get_publisher_by_id(&EndpointId("publish".to_string())) - .unwrap(); - assert_eq!(some_participant_publisher.receivers().len(), 1); - let is_some_participant_has_responder_in_receivers = - some_participant_publisher - .receivers() - .into_iter() - .map(|p| p.upgrade().unwrap()) - .filter(|p| Rc::ptr_eq(p, &responder_play2_endpoint)) - .count() - == 1; - assert!(is_some_participant_has_responder_in_receivers); - } -} diff --git a/src/signalling/control/play_endpoint.rs b/src/signalling/control/play_endpoint.rs new file mode 100644 index 000000000..49a9f6347 --- /dev/null +++ b/src/signalling/control/play_endpoint.rs @@ -0,0 +1,17 @@ +use super::publish_endpoint::Id as PublishEndpointId; +use crate::api::control::MemberId; +use std::rc::Rc; +use crate::media::IceUser; +use crate::media::PeerId; + +#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq)] +pub struct Id(String); + +#[derive(Debug)] +pub struct WebRtcPlayEndpoint { + id: Id, + src: PublishEndpointId, + owner: MemberId, + ice_user: Option>, + peer_id: Option +} diff --git a/src/signalling/control/publish_endpoint.rs b/src/signalling/control/publish_endpoint.rs new file mode 100644 index 000000000..16afdd885 --- /dev/null +++ b/src/signalling/control/publish_endpoint.rs @@ -0,0 +1,18 @@ +use super::play_endpoint::{Id as PlayerEndpointId}; +use crate::api::control::MemberId; +use std::rc::Rc; +use crate::media::IceUser; +use crate::media::PeerId; +use hashbrown::HashSet; + +#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq)] +pub struct Id(String); + +#[derive(Debug)] +pub struct WebRtcPublishEndpoint { + id: Id, + sinks: Vec, + owner: MemberId, + ice_user: Option>, + peer_ids: HashSet +} diff --git a/src/signalling/endpoints_manager.rs b/src/signalling/endpoints_manager.rs new file mode 100644 index 000000000..0ca664408 --- /dev/null +++ b/src/signalling/endpoints_manager.rs @@ -0,0 +1,63 @@ +use hashbrown::HashMap; +use std::rc::Rc; +use super::control::publish_endpoint::WebRtcPublishEndpoint; +use super::control::play_endpoint::WebRtcPlayEndpoint; +use crate::api::control::RoomSpec; +use crate::api::control::MemberId; +use super::control::play_endpoint::Id as PlayEndpointId; +use super::control::publish_endpoint::Id as PublishEndpointId; +use crate::media::IceUser; +use crate::signalling::room::Room; +use futures::Future; +use actix::Context; +use std::iter::Iterator; +use std::iter::IntoIterator; + +#[derive(Debug)] +pub struct EndpointsManager { + ice_users: HashMap>, + publishers: HashMap, + receivers: HashMap, +} + +impl EndpointsManager { + pub fn new(spec: &RoomSpec) -> Self { + // TODO + Self { + ice_users: HashMap::new(), + publishers: HashMap::new(), + receivers: HashMap::new(), + } + } + + pub fn take_ice_users(&mut self) -> HashMap> { + let mut ice_users = HashMap::new(); + std::mem::swap(&mut self.ice_users, &mut ice_users); + + ice_users + } + +// pub fn drop_connections(&mut self, ctx: &mut Context) -> impl Future { +// let remove_ice_users = Box::new({ +// let mut ice_users = HashMap::new(); +// std::mem::swap(&mut self.ice_users, &mut ice_users); +// let ice_users: Vec> = ice_users.into_iter().map(|(_, ice_user)| ice_user).collect(); +// +// }); +//// let remove_ice_users = Box::new({ +//// let mut room_users = Vec::with_capacity(self.participants.len()); +//// +//// self.participants.iter().for_each(|(_, data)| { +//// if let Some(ice_user) = data.take_ice_user() { +//// room_users.push(ice_user); +//// } +//// }); +//// self.turn +//// .delete(room_users) +//// .map_err(|err| error!("Error removing IceUsers {:?}", err)) +//// }); +//// close_fut.push(remove_ice_users); +//// +//// join_all(close_fut).map(|_| ()) +// } +} diff --git a/src/signalling/participants.rs b/src/signalling/members_manager.rs similarity index 65% rename from src/signalling/participants.rs rename to src/signalling/members_manager.rs index 74721ca42..dc11dc7d7 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/members_manager.rs @@ -1,5 +1,5 @@ -//! [`Participant`] is member with [`RpcConnection`]. [`ParticipantService`] -//! stores [`Participant`]s and associated [`RpcConnection`]s, handles +//! [`Member`] is member with [`RpcConnection`]. [`MemberService`] +//! stores [`Member`]s and associated [`RpcConnection`]s, handles //! [`RpcConnection`] authorization, establishment, message sending, Turn //! credentials management. @@ -26,63 +26,55 @@ use crate::{ AuthorizationError, ClosedReason, EventMessage, RpcConnection, RpcConnectionClosed, }, - control::{MemberId as ParticipantId, RoomId, RoomSpec}, + control::{MemberId, RoomId, RoomSpec}, }, log::prelude::*, media::IceUser, signalling::{ - control::{parse_participants, Participant, ParticipantsLoadError}, room::{ActFuture, RoomError}, Room, + control::member::Member, }, turn::{TurnAuthService, TurnServiceErr, UnreachablePolicy}, }; #[derive(Fail, Debug)] #[allow(clippy::module_name_repetitions)] -pub enum ParticipantServiceErr { - #[fail(display = "TurnService Error in ParticipantService: {}", _0)] +pub enum MemberServiceErr { + #[fail(display = "TurnService Error in MemberService: {}", _0)] TurnServiceErr(TurnServiceErr), #[fail( - display = "Mailbox error when accessing ParticipantService: {}", + display = "Mailbox error when accessing MemberService: {}", _0 )] MailBoxErr(MailboxError), - #[fail(display = "Participant with Id [{}] was not found", _0)] - ParticipantNotFound(ParticipantId), + #[fail(display = "Member with Id [{}] was not found", _0)] + MemberNotFound(MemberId), } -impl From for ParticipantServiceErr { +impl From for MemberServiceErr { fn from(err: TurnServiceErr) -> Self { - ParticipantServiceErr::TurnServiceErr(err) + MemberServiceErr::TurnServiceErr(err) } } -impl From for ParticipantServiceErr { +impl From for MemberServiceErr { fn from(err: MailboxError) -> Self { - ParticipantServiceErr::MailBoxErr(err) + MemberServiceErr::MailBoxErr(err) } } -/// [`Participant`] is member of [`Room`] with [`RpcConnection`]. -/// [`ParticipantService`] stores [`Participant`]s and associated +/// [`Member`] is member of [`Room`] with [`RpcConnection`]. +/// [`MemberService`] stores [`Member`]s and associated /// [`RpcConnection`]s, handles [`RpcConnection`] authorization, establishment, /// message sending. #[derive(Debug)] -pub struct ParticipantService { - /// [`Room`]s id from which this [`ParticipantService`] was created. +pub struct MembersManager { + /// [`Room`]s id from which this [`MemberService`] was created. room_id: RoomId, - /// [`Participant`]s which currently are present in this [`Room`]. - participants: HashMap>, - - /// Service for managing authorization on Turn server. - turn: Box, - - /// Established [`RpcConnection`]s of [`Participants`]s in this [`Room`]. - // TODO: Replace Box> with enum, - // as the set of all possible RpcConnection types is not closed. - connections: HashMap>, + /// [`Member`]s which currently are present in this [`Room`]. + participants: HashMap, /// Timeout for close [`RpcConnection`] after receiving /// [`RpcConnectionClosed`] message. @@ -91,44 +83,41 @@ pub struct ParticipantService { /// Stores [`RpcConnection`] drop tasks. /// If [`RpcConnection`] is lost, [`Room`] waits for connection_timeout /// before dropping it irrevocably in case it gets reestablished. - drop_connection_tasks: HashMap, + drop_connection_tasks: HashMap, } -impl ParticipantService { - /// Create new [`ParticipantService`] from [`RoomSpec`]. +impl MembersManager { + /// Create new [`MemberService`] from [`RoomSpec`]. pub fn new( room_spec: &RoomSpec, reconnect_timeout: Duration, - turn: Box, - ) -> Result { + ) -> Result { Ok(Self { room_id: room_spec.id().clone(), - participants: parse_participants(room_spec)?, - turn, - connections: HashMap::new(), + participants: HashMap::new(), // TODO reconnect_timeout, drop_connection_tasks: HashMap::new(), }) } - /// Lookup [`Participant`] by provided id. + /// Lookup [`Member`] by provided id. pub fn get_participant_by_id( &self, - id: &ParticipantId, - ) -> Option> { + id: &MemberId, + ) -> Option> { self.participants.get(id).cloned() } - /// Lookup [`Participant`] by provided id and credentials. Returns - /// [`Err(AuthorizationError::ParticipantNotExists)`] if lookup by - /// [`ParticipantId`] failed. Returns - /// [`Err(AuthorizationError::InvalidCredentials)`] if [`Participant`] + /// Lookup [`Member`] by provided id and credentials. Returns + /// [`Err(AuthorizationError::MemberNotExists)`] if lookup by + /// [`MemberId`] failed. Returns + /// [`Err(AuthorizationError::InvalidCredentials)`] if [`Member`] /// was found, but incorrect credentials was provided. pub fn get_participant_by_id_and_credentials( &self, - participant_id: &ParticipantId, + participant_id: &MemberId, credentials: &str, - ) -> Result, AuthorizationError> { + ) -> Result, AuthorizationError> { match self.get_participant_by_id(participant_id) { Some(participant) => { if participant.credentials().eq(credentials) { @@ -137,26 +126,28 @@ impl ParticipantService { Err(AuthorizationError::InvalidCredentials) } } - None => Err(AuthorizationError::ParticipantNotExists), + None => Err(AuthorizationError::MemberNotExists), } } - /// Checks if [`Participant`] has **active** [`RcpConnection`]. + /// Checks if [`Member`] has **active** [`RcpConnection`]. pub fn participant_has_connection( &self, - participant_id: &ParticipantId, + participant_id: &MemberId, ) -> bool { self.connections.contains_key(participant_id) && !self.drop_connection_tasks.contains_key(participant_id) } - /// Send [`Event`] to specified remote [`Participant`]. + /// Send [`Event`] to specified remote [`Member`]. pub fn send_event_to_participant( &mut self, - participant_id: ParticipantId, + participant_id: MemberId, event: Event, ) -> impl Future { - match self.connections.get(&participant_id) { + let member = self.get_participant_by_id(&participant_id).unwrap(); + + match member.connection() { Some(conn) => { Either::A(conn.send_event(EventMessage::from(event)).map_err( move |_| RoomError::UnableToSendEvent(participant_id), @@ -169,18 +160,18 @@ impl ParticipantService { } /// Saves provided [`RpcConnection`], registers [`ICEUser`]. - /// If [`Participant`] already has any other [`RpcConnection`], + /// If [`Member`] already has any other [`RpcConnection`], /// then it will be closed. pub fn connection_established( &mut self, ctx: &mut Context, - participant_id: ParticipantId, + participant_id: MemberId, con: Box, - ) -> ActFuture, ParticipantServiceErr> { + ) -> ActFuture, MemberServiceErr> { let participant = match self.get_participant_by_id(&participant_id) { None => { return Box::new(wrap_future(future::err( - ParticipantServiceErr::ParticipantNotFound(participant_id), + MemberServiceErr::MemberNotFound(participant_id), ))); } Some(participant) => participant, @@ -211,7 +202,7 @@ impl ParticipantService { UnreachablePolicy::ReturnErr, )) .map_err(|err, _: &mut Room, _| { - ParticipantServiceErr::from(err) + MemberServiceErr::from(err) }) .and_then( move |ice: IceUser, room: &mut Room, _| { @@ -226,17 +217,17 @@ impl ParticipantService { } } - /// Insert new [`RpcConnection`] into this [`ParticipantService`]. + /// Insert new [`RpcConnection`] into this [`MemberService`]. fn insert_connection( &mut self, - participant_id: ParticipantId, + participant_id: MemberId, conn: Box, ) { self.connections.insert(participant_id, conn); } /// If [`ClosedReason::Closed`], then removes [`RpcConnection`] associated - /// with specified user [`Participant`] from the storage and closes the + /// with specified user [`Member`] from the storage and closes the /// room. If [`ClosedReason::Lost`], then creates delayed task that /// emits [`ClosedReason::Closed`]. // TODO: Dont close the room. It is being closed atm, because we have @@ -244,7 +235,7 @@ impl ParticipantService { pub fn connection_closed( &mut self, ctx: &mut Context, - participant_id: ParticipantId, + participant_id: MemberId, reason: &ClosedReason, ) { let closed_at = Instant::now(); @@ -281,7 +272,7 @@ impl ParticipantService { /// Deletes [`IceUser`] associated with provided [`Member`]. fn delete_ice_user( &mut self, - participant_id: &ParticipantId, + participant_id: &MemberId, ) -> Box> { match self.get_participant_by_id(&participant_id) { Some(participant) => match participant.take_ice_user() { @@ -302,29 +293,10 @@ impl ParticipantService { ctx.cancel_future(handle); }); - // closing all RpcConnection's - let mut close_fut = self.connections.drain().fold( - vec![], - |mut futures, (_, mut connection)| { - futures.push(connection.close()); - futures - }, - ); - - // deleting all IceUsers - let remove_ice_users = Box::new({ - let mut room_users = Vec::with_capacity(self.participants.len()); - - self.participants.iter().for_each(|(_, data)| { - if let Some(ice_user) = data.take_ice_user() { - room_users.push(ice_user); - } - }); - self.turn - .delete(room_users) - .map_err(|err| error!("Error removing IceUsers {:?}", err)) - }); - close_fut.push(remove_ice_users); + let mut close_fut = Vec::new(); + for (id, participant) in self.participants { + close_fut.push(participant.take_connection().unwrap().close()); + } join_all(close_fut).map(|_| ()) } diff --git a/src/signalling/mod.rs b/src/signalling/mod.rs index 2b8f6a1ab..86810af25 100644 --- a/src/signalling/mod.rs +++ b/src/signalling/mod.rs @@ -1,5 +1,7 @@ pub mod control; -pub mod participants; +pub mod members_manager; +pub mod endpoints_manager; +pub mod pipeline; pub mod peers; pub mod room; pub mod room_repo; diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index 9d2de975c..2630ad617 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -13,14 +13,14 @@ use crate::{ log::prelude::*, media::{Peer, PeerId, PeerStateMachine}, signalling::{ - control::participant::Participant, room::{PeersRemoved, Room, RoomError}, + control::member::Member, }, }; #[derive(Debug)] pub struct PeerRepository { - /// [`Peer`]s of [`Participant`]s in this [`Room`]. + /// [`Peer`]s of [`Member`]s in this [`Room`]. peers: HashMap, /// Count of [`Peer`]s in this [`Room`]. @@ -69,13 +69,13 @@ impl PeerRepository { .ok_or_else(|| RoomError::PeerNotFound(peer_id)) } - /// Create and interconnect [`Peer`]s based on [`Participant`]. + /// Create and interconnect [`Peer`]s based on [`Member`]. /// /// Returns IDs of created [`Peer`]s. `(first_peer_id, second_peer_id)`. pub fn create_peers( &mut self, - first_member: &Participant, - second_member: &Participant, + first_member: &Member, + second_member: &Member, ) -> (u64, u64) { debug!( "Created peer between {} and {}.", @@ -130,7 +130,7 @@ impl PeerRepository { } } - /// Returns all [`Peer`]s of specified [`Participant`]. + /// Returns all [`Peer`]s of specified [`Member`]. pub fn get_peers_by_member_id( &self, member_id: &MemberId, @@ -162,10 +162,10 @@ impl PeerRepository { } } - /// Close all related to disconnected [`Participant`] [`Peer`]s and partner + /// Close all related to disconnected [`Member`] [`Peer`]s and partner /// [`Peer`]s. /// - /// Send [`Event::PeersRemoved`] to all affected [`Participant`]s. + /// Send [`Event::PeersRemoved`] to all affected [`Member`]s. pub fn connection_closed( &mut self, member_id: &MemberId, diff --git a/src/signalling/pipeline.rs b/src/signalling/pipeline.rs new file mode 100644 index 000000000..119358e5c --- /dev/null +++ b/src/signalling/pipeline.rs @@ -0,0 +1,51 @@ +use crate::turn::service::TurnAuthService; +use super::members_manager::MembersManager; +use super::endpoints_manager::EndpointsManager; +use super::peers::PeerRepository; +use crate::api::control::RoomSpec; +use std::convert::TryFrom; +use std::time::Duration; +use hashbrown::HashMap; +use crate::signalling::room::Room; +use actix::Context; +use std::rc::Rc; +use hashbrown::hash_map::IntoIter as _; +use crate::media::IceUser; +use futures::future::{join_all, IntoFuture}; +use futures::Future; +use futures::future::Either; + +#[derive(Debug)] +pub struct Pipeline { + turn: Box, + members: MembersManager, + endpoints: EndpointsManager, + peers: PeerRepository, +} + +impl Pipeline { + pub fn new(turn: Box, reconnect_timeout: Duration, spec: &RoomSpec) -> Self { + Self { + turn, + members: MembersManager::new(spec, reconnect_timeout).unwrap(), + endpoints: EndpointsManager::new(spec), + peers: PeerRepository::from(HashMap::new()), + } + } + + fn test(&mut self, ice_users: Vec>) -> impl Future{ + self.turn.delete(ice_users).map_err(|_| ()) + } + + pub fn drop_connections(&mut self, ctx: &mut Context) -> impl Future { + let mut fut = Vec::new(); + + fut.push(Either::A(self.members.drop_connections(ctx))); + let ice_users = self.endpoints.take_ice_users(); + let ice_users: Vec> = ice_users.into_iter().map(|(_, ice_user)| ice_user).collect(); + + fut.push(Either::B(self.test(ice_users))); + + join_all(fut).map(|_| ()) + } +} diff --git a/src/signalling/room.rs b/src/signalling/room.rs index beb8d6eed..80a761e75 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -1,5 +1,5 @@ //! Room definitions and implementations. Room is responsible for media -//! connection establishment between concrete [`Participant`]s. +//! connection establishment between concrete [`Member`]s. use std::time::Duration; @@ -18,7 +18,7 @@ use crate::{ AuthorizationError, Authorize, ClosedReason, CommandMessage, RpcConnectionClosed, RpcConnectionEstablished, }, - control::{MemberId, RoomId, RoomSpec, TryFromElementError}, + control::{RoomId, RoomSpec, TryFromElementError}, }, log::prelude::*, media::{ @@ -26,12 +26,13 @@ use crate::{ WaitLocalHaveRemote, WaitLocalSdp, WaitRemoteSdp, }, signalling::{ - control::participant::{Participant, ParticipantsLoadError}, - participants::ParticipantService, + members_manager::MembersManager, peers::PeerRepository, + control::member::{Member, MemberId}, }, turn::TurnAuthService, }; +use crate::signalling::pipeline::Pipeline; /// Ergonomic type alias for using [`ActorFuture`] for [`Room`]. pub type ActFuture = @@ -141,25 +142,24 @@ impl From for RoomError { } } -impl From for RoomError { - fn from(err: ParticipantsLoadError) -> Self { - RoomError::BadRoomSpec(format!( - "Error while loading room spec. {}", - err - )) - } -} +//impl From for RoomError { +// fn from(err: MembersLoadError) -> Self { +// RoomError::BadRoomSpec(format!( +// "Error while loading room spec. {}", +// err +// )) +// } +//} -/// Media server room with its [`Participant`]s. +/// Media server room with its [`Member`]s. #[derive(Debug)] pub struct Room { id: RoomId, - /// [`RpcConnection`]s of [`Participant`]s in this [`Room`]. - pub participants: ParticipantService, - - /// [`Peer`]s of [`Participant`]s in this [`Room`]. + /// [`Peer`]s of [`Member`]s in this [`Room`]. peers: PeerRepository, + + pipeline: Pipeline, } impl Room { @@ -175,11 +175,7 @@ impl Room { Ok(Self { id: room_spec.id().clone(), peers: PeerRepository::from(HashMap::new()), - participants: ParticipantService::new( - room_spec, - reconnect_timeout, - turn, - )?, + pipeline: Pipeline::new(), }) } @@ -238,7 +234,7 @@ impl Room { ))) } - /// Sends [`Event::PeersRemoved`] to [`Participant`]. + /// Sends [`Event::PeersRemoved`] to [`Member`]. fn send_peers_removed( &mut self, member_id: MemberId, @@ -364,12 +360,12 @@ impl Room { ))) } - /// Create [`Peer`]s between [`Participant`]s and interconnect it by control + /// Create [`Peer`]s between [`Member`]s and interconnect it by control /// API spec. fn connect_participants( &mut self, - first_member: &Participant, - second_member: &Participant, + first_member: &Member, + second_member: &Member, ctx: &mut ::Context, ) { debug!( @@ -384,15 +380,15 @@ impl Room { self.connect_peers(ctx, first_peer_id, second_peer_id); } - /// Create and interconnect all [`Peer`]s between connected [`Participant`] - /// and all available at this moment [`Participant`]. + /// Create and interconnect all [`Peer`]s between connected [`Member`] + /// and all available at this moment [`Member`]. /// /// Availability is determines by checking [`RpcConnection`] of all - /// [`Participant`]s from [`WebRtcPlayEndpoint`]s and from receivers of - /// connected [`Participant`]. + /// [`Member`]s from [`WebRtcPlayEndpoint`]s and from receivers of + /// connected [`Member`]. fn init_participant_connections( &mut self, - participant: &Participant, + participant: &Member, ctx: &mut ::Context, ) { // Create all connected publish endpoints. @@ -459,7 +455,7 @@ impl Room { } /// Check state of interconnected [`Peer`]s and sends [`Event`] about - /// [`Peer`] created to remote [`Participant`]. + /// [`Peer`] created to remote [`Member`]. fn connect_peers( &mut self, ctx: &mut Context, @@ -517,7 +513,7 @@ impl Handler for Room { } } -/// Signal of removing [`Participant`]'s [`Peer`]s. +/// Signal of removing [`Member`]'s [`Peer`]s. #[derive(Debug, Message)] #[rtype(result = "Result<(), ()>")] pub struct PeersRemoved { @@ -528,9 +524,9 @@ pub struct PeersRemoved { impl Handler for Room { type Result = ActFuture<(), ()>; - /// Send [`Event::PeersRemoved`] to remote [`Participant`]. + /// Send [`Event::PeersRemoved`] to remote [`Member`]. /// - /// Delete all removed [`PeerId`]s from all [`Participant`]'s + /// Delete all removed [`PeerId`]s from all [`Member`]'s /// endpoints. #[allow(clippy::single_match_else)] fn handle( @@ -548,7 +544,7 @@ impl Handler for Room { participant.peers_removed(&msg.peers_id); } else { error!( - "Participant with id {} for which received \ + "Member with id {} for which received \ Event::PeersRemoved not found. Closing room.", msg.member_id ); @@ -622,9 +618,9 @@ impl Handler for Room { impl Handler for Room { type Result = ActFuture<(), ()>; - /// Saves new [`RpcConnection`] in [`ParticipantService`], initiates media + /// Saves new [`RpcConnection`] in [`MemberService`], initiates media /// establishment between members. - /// Create and interconnect all available [`Participant`]'s [`Peer`]s. + /// Create and interconnect all available [`Member`]'s [`Peer`]s. fn handle( &mut self, msg: RpcConnectionEstablished, @@ -656,7 +652,7 @@ pub struct CloseRoom {} impl Handler for Room { type Result = (); - /// Sends to remote [`Participant`] the [`Event`] about [`Peer`] removed. + /// Sends to remote [`Member`] the [`Event`] about [`Peer`] removed. /// Closes all active [`RpcConnection`]s. fn handle( &mut self, @@ -664,7 +660,7 @@ impl Handler for Room { ctx: &mut Self::Context, ) -> Self::Result { info!("Closing Room [id = {:?}]", self.id); - let drop_fut = self.participants.drop_connections(ctx); + let drop_fut = self.pipeline.drop_connections(ctx); ctx.wait(wrap_future(drop_fut)); } } @@ -672,8 +668,8 @@ impl Handler for Room { impl Handler for Room { type Result = (); - /// Passes message to [`ParticipantService`] to cleanup stored connections. - /// Remove all related for disconnected [`Participant`] [`Peer`]s. + /// Passes message to [`MemberService`] to cleanup stored connections. + /// Remove all related for disconnected [`Member`] [`Peer`]s. fn handle(&mut self, msg: RpcConnectionClosed, ctx: &mut Self::Context) { info!( "RpcConnectionClosed for member {}, reason {:?}", diff --git a/src/turn/service.rs b/src/turn/service.rs index 300e07f63..323da8bd7 100644 --- a/src/turn/service.rs +++ b/src/turn/service.rs @@ -17,6 +17,7 @@ use crate::{ media::IceUser, turn::repo::{TurnDatabase, TurnDatabaseErr}, }; +use std::rc::Rc; static TURN_PASS_LEN: usize = 16; @@ -34,7 +35,7 @@ pub trait TurnAuthService: fmt::Debug + Send { /// Deletes batch of [`IceUser`]s. fn delete( &self, - users: Vec, + users: Vec>, ) -> Box>; } @@ -67,7 +68,7 @@ impl TurnAuthService for Addr { /// Sends [`DeleteRoom`] to [`Service`]. fn delete( &self, - users: Vec, + users: Vec>, ) -> Box> { // leave only non static users let users: Vec = From be59ccf53ef21829aeaadf05b9f296d3fc83f120 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 27 Jun 2019 17:39:00 +0300 Subject: [PATCH 192/735] Add publish endpoint useful fns --- src/signalling/control/publish_endpoint.rs | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/signalling/control/publish_endpoint.rs b/src/signalling/control/publish_endpoint.rs index 16afdd885..afbc14763 100644 --- a/src/signalling/control/publish_endpoint.rs +++ b/src/signalling/control/publish_endpoint.rs @@ -16,3 +16,35 @@ pub struct WebRtcPublishEndpoint { ice_user: Option>, peer_ids: HashSet } + +impl WebRtcPublishEndpoint { + pub fn add_peer_id(&mut self, peer_id: PeerId) { + self.peer_ids.insert(peer_id); + } + + pub fn add_sink(&mut self, id: PlayerEndpointId) { + self.sinks.push(id); + } + + pub fn owner(&self) -> &MemberId { + &self.owner + } + + pub fn peer_ids(&self) -> &HashSet { + &self.peer_ids + } + + pub fn reset(&mut self) { + self.peer_ids = HashSet::new(); + } + + pub fn remove_peer_id(&mut self, peer_id: &PeerId) -> bool { + self.peer_ids.remove(peer_id) + } + + pub fn remove_peer_ids(&mut self, peer_ids: &[PeerId]) { + for peer_id in peer_ids { + self.remove_peer_id(peer_id) + } + } +} From 5fcc8a40493d3317f9bbf47cd93a53e8653fb221 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 27 Jun 2019 17:43:35 +0300 Subject: [PATCH 193/735] Add play endpoint useful fns --- src/signalling/control/play_endpoint.rs | 34 +++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/signalling/control/play_endpoint.rs b/src/signalling/control/play_endpoint.rs index 49a9f6347..4445b14af 100644 --- a/src/signalling/control/play_endpoint.rs +++ b/src/signalling/control/play_endpoint.rs @@ -15,3 +15,37 @@ pub struct WebRtcPlayEndpoint { ice_user: Option>, peer_id: Option } + +impl WebRtcPlayEndpoint { + pub fn src(&self) -> &PublishEndpointId { + &self.src + } + + pub fn owner(&self) -> &MemberId { + &self.owner + } + + pub fn is_connected(&self) -> bool { + self.peer_id.is_some() + } + + pub fn set_peer_id(&mut self, peer_id: PeerId) { + self.peer_id = Some(peer_id) + } + + pub fn peer_id(&self) -> &Option { + &self.peer_id + } + + pub fn reset(&mut self) { + self.peer_id = None; + } + + pub fn take_ice_user(&mut self) -> Option> { + self.ice_user.take() + } + + pub fn set_ice_user(&mut self, user: Rc) { + self.ice_user = Some(user); + } +} From c1319267c44f60513951f2a027c74fe7556f0a19 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 27 Jun 2019 18:16:16 +0300 Subject: [PATCH 194/735] Add basic useful fns to EndpointsManager --- src/signalling/endpoints_manager.rs | 65 ++++++++++++++++++----------- 1 file changed, 40 insertions(+), 25 deletions(-) diff --git a/src/signalling/endpoints_manager.rs b/src/signalling/endpoints_manager.rs index 0ca664408..13fac5554 100644 --- a/src/signalling/endpoints_manager.rs +++ b/src/signalling/endpoints_manager.rs @@ -7,11 +7,10 @@ use crate::api::control::MemberId; use super::control::play_endpoint::Id as PlayEndpointId; use super::control::publish_endpoint::Id as PublishEndpointId; use crate::media::IceUser; +use medea_client_api_proto::IceServer; use crate::signalling::room::Room; use futures::Future; use actix::Context; -use std::iter::Iterator; -use std::iter::IntoIterator; #[derive(Debug)] pub struct EndpointsManager { @@ -37,27 +36,43 @@ impl EndpointsManager { ice_users } -// pub fn drop_connections(&mut self, ctx: &mut Context) -> impl Future { -// let remove_ice_users = Box::new({ -// let mut ice_users = HashMap::new(); -// std::mem::swap(&mut self.ice_users, &mut ice_users); -// let ice_users: Vec> = ice_users.into_iter().map(|(_, ice_user)| ice_user).collect(); -// -// }); -//// let remove_ice_users = Box::new({ -//// let mut room_users = Vec::with_capacity(self.participants.len()); -//// -//// self.participants.iter().for_each(|(_, data)| { -//// if let Some(ice_user) = data.take_ice_user() { -//// room_users.push(ice_user); -//// } -//// }); -//// self.turn -//// .delete(room_users) -//// .map_err(|err| error!("Error removing IceUsers {:?}", err)) -//// }); -//// close_fut.push(remove_ice_users); -//// -//// join_all(close_fut).map(|_| ()) -// } + pub fn take_ice_user_by_member_id(&mut self, member_id: &MemberId) -> Option { + self.ice_users.remove(member_id) + } + + pub fn replace_ice_user(&mut self, member_id: MemberId, mut new_ice_user: Rc) -> Option> { + self.ice_users.insert(member_id.clone(), new_ice_user) + } + + pub fn peers_removed(&mut self, peer_ids: &[PeerId]) { + self.publishers + .iter() + .for_each(|(_, p)| p.remove_peer_ids(peer_ids)); + + self.receivers + .iter() + .filter_map(|(_, p)| p.peer_id().map(|id| (id, p))) + .filter(|(id, _)| peer_ids.contains(&id)) + .for_each(|(_, p)| p.reset()); + } + + pub fn get_servers_list_by_member_id(&self, member_id: &MemberId) -> Option> { + self.ice_users.get(member_id).as_ref().map(IceUser::servers_list) + } + + pub fn insert_receiver(&mut self, id: PlayEndpointId, receiver: WebRtcPlayEndpoint) { + self.receivers.insert(id, receiver); + } + + pub fn insert_publisher(&mut self, id: PublishEndpointId, publisher: WebRtcPublishEndpoint) { + self.publishers.insert(id, publisher); + } + + pub fn get_publisher_by_id(&self, id: &PublishEndpointId) -> &WebRtcPublishEndpoint { + self.publishers.get(id) + } + + pub fn get_receiver_by_id(&self, id: &PlayEndpointId) -> &WebRtcPlayEndpoint { + self.receivers.get(id) + } } From 865887272d6de98cc37ea8fd61408ea9ba2ce276 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 27 Jun 2019 18:48:19 +0300 Subject: [PATCH 195/735] Make IceUser RefCell, add some fns --- src/api/client/rpc_connection.rs | 2 +- src/api/client/server.rs | 2 +- src/signalling/control/member.rs | 8 ++++++++ src/signalling/control/play_endpoint.rs | 2 +- src/signalling/control/publish_endpoint.rs | 4 ++-- src/signalling/endpoints_manager.rs | 10 ++++++---- src/signalling/members_manager.rs | 22 ++++++++++++---------- src/signalling/pipeline.rs | 11 +++++++++-- src/signalling/room.rs | 2 +- src/turn/repo.rs | 6 ++++-- src/turn/service.rs | 11 ++++++----- 11 files changed, 51 insertions(+), 29 deletions(-) diff --git a/src/api/client/rpc_connection.rs b/src/api/client/rpc_connection.rs index 5992e9c79..75aedd535 100644 --- a/src/api/client/rpc_connection.rs +++ b/src/api/client/rpc_connection.rs @@ -50,7 +50,7 @@ pub struct Authorize { #[derive(Debug)] pub enum AuthorizationError { /// Authorizing [`Participant`] does not exists in the [`Room`]. - ParticipantNotExists, + MemberNotExists, /// Provided credentials are invalid. InvalidCredentials, } diff --git a/src/api/client/server.rs b/src/api/client/server.rs index b91c22864..968d4c61b 100644 --- a/src/api/client/server.rs +++ b/src/api/client/server.rs @@ -63,7 +63,7 @@ fn ws_index( &r, payload, ), - Err(AuthorizationError::ParticipantNotExists) => { + Err(AuthorizationError::MemberNotExists) => { Ok(HttpResponse::NotFound().into()) } Err(AuthorizationError::InvalidCredentials) => { diff --git a/src/signalling/control/member.rs b/src/signalling/control/member.rs index b53930728..dfde229c9 100644 --- a/src/signalling/control/member.rs +++ b/src/signalling/control/member.rs @@ -21,4 +21,12 @@ impl Member { pub fn id(&self) -> &MemberId { &self.id } + + pub fn credentials(&self) -> &str { + &self.credentials + } + + pub fn set_connection(&mut self, connection: Box) { + self.connection = Some(connection) + } } diff --git a/src/signalling/control/play_endpoint.rs b/src/signalling/control/play_endpoint.rs index 4445b14af..1cbccd261 100644 --- a/src/signalling/control/play_endpoint.rs +++ b/src/signalling/control/play_endpoint.rs @@ -4,7 +4,7 @@ use std::rc::Rc; use crate::media::IceUser; use crate::media::PeerId; -#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq)] +#[derive(Clone, Debug, Eq, Hash, PartialEq)] pub struct Id(String); #[derive(Debug)] diff --git a/src/signalling/control/publish_endpoint.rs b/src/signalling/control/publish_endpoint.rs index afbc14763..a9c08877c 100644 --- a/src/signalling/control/publish_endpoint.rs +++ b/src/signalling/control/publish_endpoint.rs @@ -5,7 +5,7 @@ use crate::media::IceUser; use crate::media::PeerId; use hashbrown::HashSet; -#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq)] +#[derive(Clone, Debug, Eq, Hash, PartialEq)] pub struct Id(String); #[derive(Debug)] @@ -44,7 +44,7 @@ impl WebRtcPublishEndpoint { pub fn remove_peer_ids(&mut self, peer_ids: &[PeerId]) { for peer_id in peer_ids { - self.remove_peer_id(peer_id) + self.remove_peer_id(peer_id); } } } diff --git a/src/signalling/endpoints_manager.rs b/src/signalling/endpoints_manager.rs index 13fac5554..f640a11c9 100644 --- a/src/signalling/endpoints_manager.rs +++ b/src/signalling/endpoints_manager.rs @@ -11,10 +11,12 @@ use medea_client_api_proto::IceServer; use crate::signalling::room::Room; use futures::Future; use actix::Context; +use crate::media::PeerId; +use std::cell::RefCell; #[derive(Debug)] pub struct EndpointsManager { - ice_users: HashMap>, + ice_users: HashMap>>, publishers: HashMap, receivers: HashMap, } @@ -29,18 +31,18 @@ impl EndpointsManager { } } - pub fn take_ice_users(&mut self) -> HashMap> { + pub fn take_ice_users(&mut self) -> HashMap>> { let mut ice_users = HashMap::new(); std::mem::swap(&mut self.ice_users, &mut ice_users); ice_users } - pub fn take_ice_user_by_member_id(&mut self, member_id: &MemberId) -> Option { + pub fn take_ice_user_by_member_id(&mut self, member_id: &MemberId) -> Option>> { self.ice_users.remove(member_id) } - pub fn replace_ice_user(&mut self, member_id: MemberId, mut new_ice_user: Rc) -> Option> { + pub fn replace_ice_user(&mut self, member_id: MemberId, mut new_ice_user: Rc>) -> Option>> { self.ice_users.insert(member_id.clone(), new_ice_user) } diff --git a/src/signalling/members_manager.rs b/src/signalling/members_manager.rs index dc11dc7d7..857e95719 100644 --- a/src/signalling/members_manager.rs +++ b/src/signalling/members_manager.rs @@ -104,8 +104,8 @@ impl MembersManager { pub fn get_participant_by_id( &self, id: &MemberId, - ) -> Option> { - self.participants.get(id).cloned() + ) -> Option<&Member> { + self.participants.get(id) } /// Lookup [`Member`] by provided id and credentials. Returns @@ -117,11 +117,11 @@ impl MembersManager { &self, participant_id: &MemberId, credentials: &str, - ) -> Result, AuthorizationError> { + ) -> Result<&Member, AuthorizationError> { match self.get_participant_by_id(participant_id) { Some(participant) => { - if participant.credentials().eq(credentials) { - Ok(participant.clone()) + if participant.credentials() == credentials { + Ok(participant) } else { Err(AuthorizationError::InvalidCredentials) } @@ -206,8 +206,8 @@ impl MembersManager { }) .and_then( move |ice: IceUser, room: &mut Room, _| { - room.participants - .insert_connection(participant_id.clone(), con); + room.pipeline.insert_connection(&participant_id, con); + participant.replace_ice_user(ice); wrap_future(future::ok(participant)) @@ -218,12 +218,14 @@ impl MembersManager { } /// Insert new [`RpcConnection`] into this [`MemberService`]. - fn insert_connection( + pub fn insert_connection( &mut self, - participant_id: MemberId, + participant_id: &MemberId, conn: Box, ) { - self.connections.insert(participant_id, conn); + if let Some(member) = self.participants.get_mut(&participant_id) { + member.set_connection(conn); + } } /// If [`ClosedReason::Closed`], then removes [`RpcConnection`] associated diff --git a/src/signalling/pipeline.rs b/src/signalling/pipeline.rs index 119358e5c..de61417db 100644 --- a/src/signalling/pipeline.rs +++ b/src/signalling/pipeline.rs @@ -14,6 +14,9 @@ use crate::media::IceUser; use futures::future::{join_all, IntoFuture}; use futures::Future; use futures::future::Either; +use crate::api::client::rpc_connection::RpcConnection; +use crate::api::control::MemberId; +use std::cell::RefCell; #[derive(Debug)] pub struct Pipeline { @@ -33,7 +36,7 @@ impl Pipeline { } } - fn test(&mut self, ice_users: Vec>) -> impl Future{ + fn test(&mut self, ice_users: Vec>>) -> impl Future{ self.turn.delete(ice_users).map_err(|_| ()) } @@ -42,10 +45,14 @@ impl Pipeline { fut.push(Either::A(self.members.drop_connections(ctx))); let ice_users = self.endpoints.take_ice_users(); - let ice_users: Vec> = ice_users.into_iter().map(|(_, ice_user)| ice_user).collect(); + let ice_users: Vec>> = ice_users.into_iter().map(|(_, ice_user)| ice_user).collect(); fut.push(Either::B(self.test(ice_users))); join_all(fut).map(|_| ()) } + + pub fn insert_connection(&mut self, member_id: &MemberId, connection: Box) { + self.members.insert_connection(member_id, connection); + } } diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 80a761e75..e326c288f 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -159,7 +159,7 @@ pub struct Room { /// [`Peer`]s of [`Member`]s in this [`Room`]. peers: PeerRepository, - pipeline: Pipeline, + pub pipeline: Pipeline, } impl Room { diff --git a/src/turn/repo.rs b/src/turn/repo.rs index 1b7044fe8..b974b2898 100644 --- a/src/turn/repo.rs +++ b/src/turn/repo.rs @@ -11,6 +11,8 @@ use redis::{ConnectionInfo, RedisError}; use tokio::prelude::*; use crate::{log::prelude::*, media::IceUser}; +use std::rc::Rc; +use std::cell::RefCell; #[derive(Fail, Debug)] pub enum TurnDatabaseErr { @@ -86,14 +88,14 @@ impl TurnDatabase { /// Deletes batch of provided [`IceUser`]s. pub fn remove( &mut self, - users: &[IceUser], + users: &[Rc>], ) -> impl Future> { debug!("Remove ICE users: {:?}", users); let mut delete_keys = Vec::with_capacity(users.len()); for user in users { delete_keys - .push(format!("turn/realm/medea/user/{}/key", user.user())); + .push(format!("turn/realm/medea/user/{}/key", user.borrow().user())); } self.pool.run(|connection| { diff --git a/src/turn/service.rs b/src/turn/service.rs index 323da8bd7..7b9370252 100644 --- a/src/turn/service.rs +++ b/src/turn/service.rs @@ -18,6 +18,7 @@ use crate::{ turn::repo::{TurnDatabase, TurnDatabaseErr}, }; use std::rc::Rc; +use std::cell::RefCell; static TURN_PASS_LEN: usize = 16; @@ -35,7 +36,7 @@ pub trait TurnAuthService: fmt::Debug + Send { /// Deletes batch of [`IceUser`]s. fn delete( &self, - users: Vec>, + users: Vec>>, ) -> Box>; } @@ -68,10 +69,10 @@ impl TurnAuthService for Addr { /// Sends [`DeleteRoom`] to [`Service`]. fn delete( &self, - users: Vec>, + users: Vec>>, ) -> Box> { // leave only non static users - let users: Vec = + let users: Vec>> = users.into_iter().filter(|u| !u.is_static()).collect(); if users.is_empty() { @@ -257,7 +258,7 @@ impl Handler for Service { /// Deletes all users from given room in redis. #[derive(Debug, Message)] #[rtype(result = "Result<(), TurnServiceErr>")] -struct DeleteIceUsers(Vec); +struct DeleteIceUsers(Vec>>); impl Handler for Service { type Result = ActFuture<(), TurnServiceErr>; @@ -304,7 +305,7 @@ pub mod test { fn delete( &self, - _: Vec, + _: Vec>>, ) -> Box> { Box::new(future::ok(())) } From f4dad6a0e5b08a1a63106404555562b0fb78511f Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 27 Jun 2019 19:11:19 +0300 Subject: [PATCH 196/735] Refactor part of MembersManager --- src/signalling/control/member.rs | 8 ++++++++ src/signalling/members_manager.rs | 10 ++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/signalling/control/member.rs b/src/signalling/control/member.rs index dfde229c9..a55cdc7ff 100644 --- a/src/signalling/control/member.rs +++ b/src/signalling/control/member.rs @@ -29,4 +29,12 @@ impl Member { pub fn set_connection(&mut self, connection: Box) { self.connection = Some(connection) } + + pub fn remove_connection(&mut self) { + self.connection = None; + } + + pub fn is_connected(&self) -> bool { + self.connection.is_some() + } } diff --git a/src/signalling/members_manager.rs b/src/signalling/members_manager.rs index 857e95719..180bed833 100644 --- a/src/signalling/members_manager.rs +++ b/src/signalling/members_manager.rs @@ -135,7 +135,8 @@ impl MembersManager { &self, participant_id: &MemberId, ) -> bool { - self.connections.contains_key(participant_id) + let member = self.participants.get(participant_id).unwrap(); + member.is_connected() && !self.drop_connection_tasks.contains_key(participant_id) } @@ -167,7 +168,7 @@ impl MembersManager { ctx: &mut Context, participant_id: MemberId, con: Box, - ) -> ActFuture, MemberServiceErr> { + ) -> ActFuture<&Member, MemberServiceErr> { let participant = match self.get_participant_by_id(&participant_id) { None => { return Box::new(wrap_future(future::err( @@ -178,7 +179,7 @@ impl MembersManager { }; // lookup previous participant connection - if let Some(mut connection) = self.connections.remove(&participant_id) { + if let Some(mut connection) = participant.connection() { debug!( "Closing old RpcConnection for participant {}", participant_id @@ -243,7 +244,8 @@ impl MembersManager { let closed_at = Instant::now(); match reason { ClosedReason::Closed => { - self.connections.remove(&participant_id); + let member = self.participants.get(&participant_id).unwrap(); + member.remove_connection(); ctx.spawn(wrap_future( self.delete_ice_user(&participant_id).map_err(|err| { From 1d398f8cf04c7fb0e0d714e45d8d70198ac11042 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 27 Jun 2019 19:11:42 +0300 Subject: [PATCH 197/735] Fmt --- src/signalling/control/member.rs | 2 +- src/signalling/control/mod.rs | 4 +- src/signalling/control/play_endpoint.rs | 13 ++-- src/signalling/control/publish_endpoint.rs | 13 ++-- src/signalling/endpoints_manager.rs | 72 +++++++++++++++------- src/signalling/members_manager.rs | 16 ++--- src/signalling/mod.rs | 4 +- src/signalling/peers.rs | 2 +- src/signalling/pipeline.rs | 64 ++++++++++++------- src/signalling/room.rs | 10 +-- src/turn/repo.rs | 9 +-- src/turn/service.rs | 3 +- 12 files changed, 126 insertions(+), 86 deletions(-) diff --git a/src/signalling/control/member.rs b/src/signalling/control/member.rs index a55cdc7ff..777a4895c 100644 --- a/src/signalling/control/member.rs +++ b/src/signalling/control/member.rs @@ -6,7 +6,7 @@ pub use crate::api::control::MemberId; pub struct Member { id: MemberId, credentials: String, - connection: Option> + connection: Option>, } impl Member { diff --git a/src/signalling/control/mod.rs b/src/signalling/control/mod.rs index 85fb3464e..5084d1d2b 100644 --- a/src/signalling/control/mod.rs +++ b/src/signalling/control/mod.rs @@ -1,5 +1,5 @@ //! Signalling representation of control spec. -pub mod publish_endpoint; -pub mod play_endpoint; pub mod member; +pub mod play_endpoint; +pub mod publish_endpoint; diff --git a/src/signalling/control/play_endpoint.rs b/src/signalling/control/play_endpoint.rs index 1cbccd261..4f1e2a5c4 100644 --- a/src/signalling/control/play_endpoint.rs +++ b/src/signalling/control/play_endpoint.rs @@ -1,8 +1,9 @@ use super::publish_endpoint::Id as PublishEndpointId; -use crate::api::control::MemberId; +use crate::{ + api::control::MemberId, + media::{IceUser, PeerId}, +}; use std::rc::Rc; -use crate::media::IceUser; -use crate::media::PeerId; #[derive(Clone, Debug, Eq, Hash, PartialEq)] pub struct Id(String); @@ -13,7 +14,7 @@ pub struct WebRtcPlayEndpoint { src: PublishEndpointId, owner: MemberId, ice_user: Option>, - peer_id: Option + peer_id: Option, } impl WebRtcPlayEndpoint { @@ -32,9 +33,9 @@ impl WebRtcPlayEndpoint { pub fn set_peer_id(&mut self, peer_id: PeerId) { self.peer_id = Some(peer_id) } - + pub fn peer_id(&self) -> &Option { - &self.peer_id + &self.peer_id } pub fn reset(&mut self) { diff --git a/src/signalling/control/publish_endpoint.rs b/src/signalling/control/publish_endpoint.rs index a9c08877c..3c988dc4d 100644 --- a/src/signalling/control/publish_endpoint.rs +++ b/src/signalling/control/publish_endpoint.rs @@ -1,9 +1,10 @@ -use super::play_endpoint::{Id as PlayerEndpointId}; -use crate::api::control::MemberId; -use std::rc::Rc; -use crate::media::IceUser; -use crate::media::PeerId; +use super::play_endpoint::Id as PlayerEndpointId; +use crate::{ + api::control::MemberId, + media::{IceUser, PeerId}, +}; use hashbrown::HashSet; +use std::rc::Rc; #[derive(Clone, Debug, Eq, Hash, PartialEq)] pub struct Id(String); @@ -14,7 +15,7 @@ pub struct WebRtcPublishEndpoint { sinks: Vec, owner: MemberId, ice_user: Option>, - peer_ids: HashSet + peer_ids: HashSet, } impl WebRtcPublishEndpoint { diff --git a/src/signalling/endpoints_manager.rs b/src/signalling/endpoints_manager.rs index f640a11c9..49cebd445 100644 --- a/src/signalling/endpoints_manager.rs +++ b/src/signalling/endpoints_manager.rs @@ -1,18 +1,17 @@ +use super::control::{ + play_endpoint::{Id as PlayEndpointId, WebRtcPlayEndpoint}, + publish_endpoint::{Id as PublishEndpointId, WebRtcPublishEndpoint}, +}; +use crate::{ + api::control::{MemberId, RoomSpec}, + media::{IceUser, PeerId}, + signalling::room::Room, +}; +use actix::Context; +use futures::Future; use hashbrown::HashMap; -use std::rc::Rc; -use super::control::publish_endpoint::WebRtcPublishEndpoint; -use super::control::play_endpoint::WebRtcPlayEndpoint; -use crate::api::control::RoomSpec; -use crate::api::control::MemberId; -use super::control::play_endpoint::Id as PlayEndpointId; -use super::control::publish_endpoint::Id as PublishEndpointId; -use crate::media::IceUser; use medea_client_api_proto::IceServer; -use crate::signalling::room::Room; -use futures::Future; -use actix::Context; -use crate::media::PeerId; -use std::cell::RefCell; +use std::{cell::RefCell, rc::Rc}; #[derive(Debug)] pub struct EndpointsManager { @@ -31,18 +30,27 @@ impl EndpointsManager { } } - pub fn take_ice_users(&mut self) -> HashMap>> { + pub fn take_ice_users( + &mut self, + ) -> HashMap>> { let mut ice_users = HashMap::new(); std::mem::swap(&mut self.ice_users, &mut ice_users); ice_users } - pub fn take_ice_user_by_member_id(&mut self, member_id: &MemberId) -> Option>> { + pub fn take_ice_user_by_member_id( + &mut self, + member_id: &MemberId, + ) -> Option>> { self.ice_users.remove(member_id) } - pub fn replace_ice_user(&mut self, member_id: MemberId, mut new_ice_user: Rc>) -> Option>> { + pub fn replace_ice_user( + &mut self, + member_id: MemberId, + mut new_ice_user: Rc>, + ) -> Option>> { self.ice_users.insert(member_id.clone(), new_ice_user) } @@ -58,23 +66,43 @@ impl EndpointsManager { .for_each(|(_, p)| p.reset()); } - pub fn get_servers_list_by_member_id(&self, member_id: &MemberId) -> Option> { - self.ice_users.get(member_id).as_ref().map(IceUser::servers_list) + pub fn get_servers_list_by_member_id( + &self, + member_id: &MemberId, + ) -> Option> { + self.ice_users + .get(member_id) + .as_ref() + .map(IceUser::servers_list) } - pub fn insert_receiver(&mut self, id: PlayEndpointId, receiver: WebRtcPlayEndpoint) { + pub fn insert_receiver( + &mut self, + id: PlayEndpointId, + receiver: WebRtcPlayEndpoint, + ) { self.receivers.insert(id, receiver); } - pub fn insert_publisher(&mut self, id: PublishEndpointId, publisher: WebRtcPublishEndpoint) { + pub fn insert_publisher( + &mut self, + id: PublishEndpointId, + publisher: WebRtcPublishEndpoint, + ) { self.publishers.insert(id, publisher); } - pub fn get_publisher_by_id(&self, id: &PublishEndpointId) -> &WebRtcPublishEndpoint { + pub fn get_publisher_by_id( + &self, + id: &PublishEndpointId, + ) -> &WebRtcPublishEndpoint { self.publishers.get(id) } - pub fn get_receiver_by_id(&self, id: &PlayEndpointId) -> &WebRtcPlayEndpoint { + pub fn get_receiver_by_id( + &self, + id: &PlayEndpointId, + ) -> &WebRtcPlayEndpoint { self.receivers.get(id) } } diff --git a/src/signalling/members_manager.rs b/src/signalling/members_manager.rs index 180bed833..21d7dd639 100644 --- a/src/signalling/members_manager.rs +++ b/src/signalling/members_manager.rs @@ -31,9 +31,9 @@ use crate::{ log::prelude::*, media::IceUser, signalling::{ + control::member::Member, room::{ActFuture, RoomError}, Room, - control::member::Member, }, turn::{TurnAuthService, TurnServiceErr, UnreachablePolicy}, }; @@ -43,10 +43,7 @@ use crate::{ pub enum MemberServiceErr { #[fail(display = "TurnService Error in MemberService: {}", _0)] TurnServiceErr(TurnServiceErr), - #[fail( - display = "Mailbox error when accessing MemberService: {}", - _0 - )] + #[fail(display = "Mailbox error when accessing MemberService: {}", _0)] MailBoxErr(MailboxError), #[fail(display = "Member with Id [{}] was not found", _0)] MemberNotFound(MemberId), @@ -101,10 +98,7 @@ impl MembersManager { } /// Lookup [`Member`] by provided id. - pub fn get_participant_by_id( - &self, - id: &MemberId, - ) -> Option<&Member> { + pub fn get_participant_by_id(&self, id: &MemberId) -> Option<&Member> { self.participants.get(id) } @@ -202,9 +196,7 @@ impl MembersManager { self.room_id.clone(), UnreachablePolicy::ReturnErr, )) - .map_err(|err, _: &mut Room, _| { - MemberServiceErr::from(err) - }) + .map_err(|err, _: &mut Room, _| MemberServiceErr::from(err)) .and_then( move |ice: IceUser, room: &mut Room, _| { room.pipeline.insert_connection(&participant_id, con); diff --git a/src/signalling/mod.rs b/src/signalling/mod.rs index 86810af25..37ef7eec4 100644 --- a/src/signalling/mod.rs +++ b/src/signalling/mod.rs @@ -1,8 +1,8 @@ pub mod control; -pub mod members_manager; pub mod endpoints_manager; -pub mod pipeline; +pub mod members_manager; pub mod peers; +pub mod pipeline; pub mod room; pub mod room_repo; diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index 2630ad617..ebcd8f547 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -13,8 +13,8 @@ use crate::{ log::prelude::*, media::{Peer, PeerId, PeerStateMachine}, signalling::{ - room::{PeersRemoved, Room, RoomError}, control::member::Member, + room::{PeersRemoved, Room, RoomError}, }, }; diff --git a/src/signalling/pipeline.rs b/src/signalling/pipeline.rs index de61417db..02824bfef 100644 --- a/src/signalling/pipeline.rs +++ b/src/signalling/pipeline.rs @@ -1,22 +1,23 @@ -use crate::turn::service::TurnAuthService; -use super::members_manager::MembersManager; -use super::endpoints_manager::EndpointsManager; -use super::peers::PeerRepository; -use crate::api::control::RoomSpec; -use std::convert::TryFrom; -use std::time::Duration; -use hashbrown::HashMap; -use crate::signalling::room::Room; +use super::{ + endpoints_manager::EndpointsManager, members_manager::MembersManager, + peers::PeerRepository, +}; +use crate::{ + api::{ + client::rpc_connection::RpcConnection, + control::{MemberId, RoomSpec}, + }, + media::IceUser, + signalling::room::Room, + turn::service::TurnAuthService, +}; use actix::Context; -use std::rc::Rc; -use hashbrown::hash_map::IntoIter as _; -use crate::media::IceUser; -use futures::future::{join_all, IntoFuture}; -use futures::Future; -use futures::future::Either; -use crate::api::client::rpc_connection::RpcConnection; -use crate::api::control::MemberId; -use std::cell::RefCell; +use futures::{ + future::{join_all, Either, IntoFuture}, + Future, +}; +use hashbrown::{hash_map::IntoIter as _, HashMap}; +use std::{cell::RefCell, convert::TryFrom, rc::Rc, time::Duration}; #[derive(Debug)] pub struct Pipeline { @@ -27,7 +28,11 @@ pub struct Pipeline { } impl Pipeline { - pub fn new(turn: Box, reconnect_timeout: Duration, spec: &RoomSpec) -> Self { + pub fn new( + turn: Box, + reconnect_timeout: Duration, + spec: &RoomSpec, + ) -> Self { Self { turn, members: MembersManager::new(spec, reconnect_timeout).unwrap(), @@ -36,23 +41,36 @@ impl Pipeline { } } - fn test(&mut self, ice_users: Vec>>) -> impl Future{ + fn test( + &mut self, + ice_users: Vec>>, + ) -> impl Future { self.turn.delete(ice_users).map_err(|_| ()) } - pub fn drop_connections(&mut self, ctx: &mut Context) -> impl Future { + pub fn drop_connections( + &mut self, + ctx: &mut Context, + ) -> impl Future { let mut fut = Vec::new(); fut.push(Either::A(self.members.drop_connections(ctx))); let ice_users = self.endpoints.take_ice_users(); - let ice_users: Vec>> = ice_users.into_iter().map(|(_, ice_user)| ice_user).collect(); + let ice_users: Vec>> = ice_users + .into_iter() + .map(|(_, ice_user)| ice_user) + .collect(); fut.push(Either::B(self.test(ice_users))); join_all(fut).map(|_| ()) } - pub fn insert_connection(&mut self, member_id: &MemberId, connection: Box) { + pub fn insert_connection( + &mut self, + member_id: &MemberId, + connection: Box, + ) { self.members.insert_connection(member_id, connection); } } diff --git a/src/signalling/room.rs b/src/signalling/room.rs index e326c288f..9b2a64c3e 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -26,13 +26,13 @@ use crate::{ WaitLocalHaveRemote, WaitLocalSdp, WaitRemoteSdp, }, signalling::{ + control::member::{Member, MemberId}, members_manager::MembersManager, peers::PeerRepository, - control::member::{Member, MemberId}, + pipeline::Pipeline, }, turn::TurnAuthService, }; -use crate::signalling::pipeline::Pipeline; /// Ergonomic type alias for using [`ActorFuture`] for [`Room`]. pub type ActFuture = @@ -142,7 +142,7 @@ impl From for RoomError { } } -//impl From for RoomError { +// impl From for RoomError { // fn from(err: MembersLoadError) -> Self { // RoomError::BadRoomSpec(format!( // "Error while loading room spec. {}", @@ -544,8 +544,8 @@ impl Handler for Room { participant.peers_removed(&msg.peers_id); } else { error!( - "Member with id {} for which received \ - Event::PeersRemoved not found. Closing room.", + "Member with id {} for which received Event::PeersRemoved not \ + found. Closing room.", msg.member_id ); ctx.notify(CloseRoom {}); diff --git a/src/turn/repo.rs b/src/turn/repo.rs index b974b2898..d1ac04764 100644 --- a/src/turn/repo.rs +++ b/src/turn/repo.rs @@ -11,8 +11,7 @@ use redis::{ConnectionInfo, RedisError}; use tokio::prelude::*; use crate::{log::prelude::*, media::IceUser}; -use std::rc::Rc; -use std::cell::RefCell; +use std::{cell::RefCell, rc::Rc}; #[derive(Fail, Debug)] pub enum TurnDatabaseErr { @@ -94,8 +93,10 @@ impl TurnDatabase { let mut delete_keys = Vec::with_capacity(users.len()); for user in users { - delete_keys - .push(format!("turn/realm/medea/user/{}/key", user.borrow().user())); + delete_keys.push(format!( + "turn/realm/medea/user/{}/key", + user.borrow().user() + )); } self.pool.run(|connection| { diff --git a/src/turn/service.rs b/src/turn/service.rs index 7b9370252..999b0480c 100644 --- a/src/turn/service.rs +++ b/src/turn/service.rs @@ -17,8 +17,7 @@ use crate::{ media::IceUser, turn::repo::{TurnDatabase, TurnDatabaseErr}, }; -use std::rc::Rc; -use std::cell::RefCell; +use std::{cell::RefCell, rc::Rc}; static TURN_PASS_LEN: usize = 16; From cbc8d6d0a87cf0c25e7a9fde71736ba5ff245d28 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 27 Jun 2019 19:35:08 +0300 Subject: [PATCH 198/735] Refactor --- src/signalling/endpoints_manager.rs | 6 +++--- src/signalling/members_manager.rs | 2 +- src/signalling/pipeline.rs | 22 ++++++++++++++++++++++ src/signalling/room.rs | 17 ++++++++--------- 4 files changed, 34 insertions(+), 13 deletions(-) diff --git a/src/signalling/endpoints_manager.rs b/src/signalling/endpoints_manager.rs index 49cebd445..5ea88e938 100644 --- a/src/signalling/endpoints_manager.rs +++ b/src/signalling/endpoints_manager.rs @@ -73,7 +73,7 @@ impl EndpointsManager { self.ice_users .get(member_id) .as_ref() - .map(IceUser::servers_list) + .map(|u| u.borrow().servers_list()) } pub fn insert_receiver( @@ -95,14 +95,14 @@ impl EndpointsManager { pub fn get_publisher_by_id( &self, id: &PublishEndpointId, - ) -> &WebRtcPublishEndpoint { + ) -> Option<&WebRtcPublishEndpoint> { self.publishers.get(id) } pub fn get_receiver_by_id( &self, id: &PlayEndpointId, - ) -> &WebRtcPlayEndpoint { + ) -> Option<&WebRtcPlayEndpoint> { self.receivers.get(id) } } diff --git a/src/signalling/members_manager.rs b/src/signalling/members_manager.rs index 21d7dd639..28f077f32 100644 --- a/src/signalling/members_manager.rs +++ b/src/signalling/members_manager.rs @@ -200,7 +200,7 @@ impl MembersManager { .and_then( move |ice: IceUser, room: &mut Room, _| { room.pipeline.insert_connection(&participant_id, con); - + participant.replace_ice_user(ice); wrap_future(future::ok(participant)) diff --git a/src/signalling/pipeline.rs b/src/signalling/pipeline.rs index 02824bfef..a540e6e97 100644 --- a/src/signalling/pipeline.rs +++ b/src/signalling/pipeline.rs @@ -18,6 +18,11 @@ use futures::{ }; use hashbrown::{hash_map::IntoIter as _, HashMap}; use std::{cell::RefCell, convert::TryFrom, rc::Rc, time::Duration}; +use medea_client_api_proto::Event; +use crate::signalling::room::RoomError; +use crate::signalling::room::ActFuture; +use crate::signalling::members_manager::MemberServiceErr; +use crate::signalling::control::member::Member; #[derive(Debug)] pub struct Pipeline { @@ -41,6 +46,23 @@ impl Pipeline { } } + pub fn is_member_has_connection(&self, id: &MemberId) -> bool { + self.members.get_participant_by_id(id).unwrap().is_connected() + } + + pub fn send_event_to_participant(&mut self, member_id: MemberId, event: Event) -> impl Future { + self.members.send_event_to_participant(member_id, event) + } + + pub fn get_member_by_id(&self, id: &MemberId) -> &Member { + self.members.get_participant_by_id(id) + } + + pub fn connection_established(&mut self, ctx: &mut Context, id: MemberId, connection: Box) -> ActFuture<&Member, MemberServiceErr> { + self.members.connection_established(ctx, id, connection) + } + + fn test( &mut self, ice_users: Vec>>, diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 9b2a64c3e..1c6505de0 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -229,8 +229,7 @@ impl Room { }; self.peers.add_peer(sender); Ok(Box::new(wrap_future( - self.participants - .send_event_to_participant(member_id, peer_created), + self.pipeline.send_event_to_participant(member_id, peer_created), ))) } @@ -240,7 +239,7 @@ impl Room { member_id: MemberId, peers: Vec, ) -> ActFuture<(), RoomError> { - Box::new(wrap_future(self.participants.send_event_to_participant( + Box::new(wrap_future(self.pipeline.send_event_to_participant( member_id, Event::PeersRemoved { peer_ids: peers }, ))) @@ -284,7 +283,7 @@ impl Room { self.peers.add_peer(to_peer); Ok(Box::new(wrap_future( - self.participants + self.pipeline .send_event_to_participant(to_member_id, event), ))) } @@ -317,7 +316,7 @@ impl Room { self.peers.add_peer(to_peer); Ok(Box::new(wrap_future( - self.participants + self.pipeline .send_event_to_participant(to_member_id, event), ))) } @@ -355,7 +354,7 @@ impl Room { }; Ok(Box::new(wrap_future( - self.participants + self.pipeline .send_event_to_participant(to_member_id, event), ))) } @@ -410,8 +409,8 @@ impl Room { ); if self - .participants - .participant_has_connection(&receiver_owner.id()) + .pipeline + .is_member_has_connection(&receiver_owner.id()) && !receiver.is_connected() { self.connect_participants( @@ -539,7 +538,7 @@ impl Handler for Room { msg.peers_id, msg.member_id ); if let Some(participant) = - self.participants.get_participant_by_id(&msg.member_id) + self.pipeline.get_member_by_id(&msg.member_id) { participant.peers_removed(&msg.peers_id); } else { From 10d32fc5d6c70c2708a7a86feb70bd48d8cf1602 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 27 Jun 2019 19:35:27 +0300 Subject: [PATCH 199/735] Fmt --- src/signalling/members_manager.rs | 2 +- src/signalling/pipeline.rs | 31 +++++++++++++++++++++---------- src/signalling/room.rs | 16 ++++++---------- 3 files changed, 28 insertions(+), 21 deletions(-) diff --git a/src/signalling/members_manager.rs b/src/signalling/members_manager.rs index 28f077f32..21d7dd639 100644 --- a/src/signalling/members_manager.rs +++ b/src/signalling/members_manager.rs @@ -200,7 +200,7 @@ impl MembersManager { .and_then( move |ice: IceUser, room: &mut Room, _| { room.pipeline.insert_connection(&participant_id, con); - + participant.replace_ice_user(ice); wrap_future(future::ok(participant)) diff --git a/src/signalling/pipeline.rs b/src/signalling/pipeline.rs index a540e6e97..2991b16eb 100644 --- a/src/signalling/pipeline.rs +++ b/src/signalling/pipeline.rs @@ -8,7 +8,11 @@ use crate::{ control::{MemberId, RoomSpec}, }, media::IceUser, - signalling::room::Room, + signalling::{ + control::member::Member, + members_manager::MemberServiceErr, + room::{ActFuture, Room, RoomError}, + }, turn::service::TurnAuthService, }; use actix::Context; @@ -17,12 +21,8 @@ use futures::{ Future, }; use hashbrown::{hash_map::IntoIter as _, HashMap}; -use std::{cell::RefCell, convert::TryFrom, rc::Rc, time::Duration}; use medea_client_api_proto::Event; -use crate::signalling::room::RoomError; -use crate::signalling::room::ActFuture; -use crate::signalling::members_manager::MemberServiceErr; -use crate::signalling::control::member::Member; +use std::{cell::RefCell, convert::TryFrom, rc::Rc, time::Duration}; #[derive(Debug)] pub struct Pipeline { @@ -47,10 +47,17 @@ impl Pipeline { } pub fn is_member_has_connection(&self, id: &MemberId) -> bool { - self.members.get_participant_by_id(id).unwrap().is_connected() + self.members + .get_participant_by_id(id) + .unwrap() + .is_connected() } - pub fn send_event_to_participant(&mut self, member_id: MemberId, event: Event) -> impl Future { + pub fn send_event_to_participant( + &mut self, + member_id: MemberId, + event: Event, + ) -> impl Future { self.members.send_event_to_participant(member_id, event) } @@ -58,11 +65,15 @@ impl Pipeline { self.members.get_participant_by_id(id) } - pub fn connection_established(&mut self, ctx: &mut Context, id: MemberId, connection: Box) -> ActFuture<&Member, MemberServiceErr> { + pub fn connection_established( + &mut self, + ctx: &mut Context, + id: MemberId, + connection: Box, + ) -> ActFuture<&Member, MemberServiceErr> { self.members.connection_established(ctx, id, connection) } - fn test( &mut self, ice_users: Vec>>, diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 1c6505de0..6fc775fea 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -229,7 +229,8 @@ impl Room { }; self.peers.add_peer(sender); Ok(Box::new(wrap_future( - self.pipeline.send_event_to_participant(member_id, peer_created), + self.pipeline + .send_event_to_participant(member_id, peer_created), ))) } @@ -283,8 +284,7 @@ impl Room { self.peers.add_peer(to_peer); Ok(Box::new(wrap_future( - self.pipeline - .send_event_to_participant(to_member_id, event), + self.pipeline.send_event_to_participant(to_member_id, event), ))) } @@ -316,8 +316,7 @@ impl Room { self.peers.add_peer(to_peer); Ok(Box::new(wrap_future( - self.pipeline - .send_event_to_participant(to_member_id, event), + self.pipeline.send_event_to_participant(to_member_id, event), ))) } @@ -354,8 +353,7 @@ impl Room { }; Ok(Box::new(wrap_future( - self.pipeline - .send_event_to_participant(to_member_id, event), + self.pipeline.send_event_to_participant(to_member_id, event), ))) } @@ -408,9 +406,7 @@ impl Room { receiver, ); - if self - .pipeline - .is_member_has_connection(&receiver_owner.id()) + if self.pipeline.is_member_has_connection(&receiver_owner.id()) && !receiver.is_connected() { self.connect_participants( From a6dd9edc8db5e5deeff0ae50ff1e161da23a82b8 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 27 Jun 2019 19:58:23 +0300 Subject: [PATCH 200/735] Refactor --- src/signalling/endpoints_manager.rs | 20 +++++++++++++++++ src/signalling/pipeline.rs | 35 ++++++++++++++++++++++++++--- src/signalling/room.rs | 19 ++++++++-------- src/turn/service.rs | 6 +++-- 4 files changed, 65 insertions(+), 15 deletions(-) diff --git a/src/signalling/endpoints_manager.rs b/src/signalling/endpoints_manager.rs index 5ea88e938..5328d6e85 100644 --- a/src/signalling/endpoints_manager.rs +++ b/src/signalling/endpoints_manager.rs @@ -39,6 +39,26 @@ impl EndpointsManager { ice_users } + pub fn get_publishers_by_member_id( + &self, + id: &MemberId, + ) -> HashMap<&PublishEndpointId, &WebRtcPublishEndpoint> { + self.publishers + .iter() + .filter(|(_, p)| p.owner() == id) + .collect() + } + + pub fn get_receivers_by_member_id( + &self, + id: &MemberId, + ) -> HashMap<&PlayEndpointId, &WebRtcPlayEndpoint> { + self.receivers + .iter() + .filter(|(_, p)| p.owner() == id) + .collect() + } + pub fn take_ice_user_by_member_id( &mut self, member_id: &MemberId, diff --git a/src/signalling/pipeline.rs b/src/signalling/pipeline.rs index 2991b16eb..b6679d643 100644 --- a/src/signalling/pipeline.rs +++ b/src/signalling/pipeline.rs @@ -4,12 +4,18 @@ use super::{ }; use crate::{ api::{ - client::rpc_connection::RpcConnection, + client::rpc_connection::{AuthorizationError, RpcConnection}, control::{MemberId, RoomSpec}, }, media::IceUser, signalling::{ - control::member::Member, + control::{ + member::Member, + play_endpoint::{Id as PlayEndpointId, WebRtcPlayEndpoint}, + publish_endpoint::{ + Id as PublishEndpointId, WebRtcPublishEndpoint, + }, + }, members_manager::MemberServiceErr, room::{ActFuture, Room, RoomError}, }, @@ -61,10 +67,33 @@ impl Pipeline { self.members.send_event_to_participant(member_id, event) } - pub fn get_member_by_id(&self, id: &MemberId) -> &Member { + pub fn get_member_by_id(&self, id: &MemberId) -> Option<&Member> { self.members.get_participant_by_id(id) } + pub fn get_member_by_id_and_credentials( + &self, + id: &MemberId, + credentials: &str, + ) -> Result<&Member, AuthorizationError> { + self.members + .get_participant_by_id_and_credentials(id, credentials) + } + + pub fn get_publishers_by_member_id( + &self, + id: &MemberId, + ) -> HashMap<&PublishEndpointId, &WebRtcPublishEndpoint> { + self.endpoints.get_publishers_by_member_id(id) + } + + pub fn get_receivers_by_member_id( + &self, + id: &MemberId, + ) -> HashMap<&PlayEndpointId, &WebRtcPlayEndpoint> { + self.endpoints.get_receivers_by_member_id(id) + } + pub fn connection_established( &mut self, ctx: &mut Context, diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 6fc775fea..1ab4ab9a7 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -388,8 +388,10 @@ impl Room { participant: &Member, ctx: &mut ::Context, ) { + let participant_publishers = + self.pipeline.get_publishers_by_member_id(participant.id()); // Create all connected publish endpoints. - for (_, publish) in participant.publishers() { + for (_, publish) in participant_publishers() { for receiver in publish.receivers() { let receiver = unit_option_unwrap!( receiver.upgrade(), @@ -436,8 +438,8 @@ impl Room { }; if self - .participants - .participant_has_connection(&plays_publisher_participant.id()) + .pipeline + .is_member_has_connection(&plays_publisher_participant.id()) && !play.is_connected() { self.connect_participants( @@ -499,11 +501,8 @@ impl Handler for Room { msg: Authorize, _ctx: &mut Self::Context, ) -> Self::Result { - self.participants - .get_participant_by_id_and_credentials( - &msg.member_id, - &msg.credentials, - ) + self.pipeline + .get_member_by_id_and_credentials(&msg.member_id, &msg.credentials) .map(|_| ()) } } @@ -626,7 +625,7 @@ impl Handler for Room { let member_id = msg.member_id; let fut = self - .participants + .pipeline .connection_established(ctx, member_id.clone(), msg.connection) .map_err(|err, _, _| { error!("RpcConnectionEstablished error {:?}", err) @@ -675,7 +674,7 @@ impl Handler for Room { self.peers.connection_closed(&msg.member_id, ctx); } - self.participants + self.pipeline .connection_closed(ctx, msg.member_id, &msg.reason); } } diff --git a/src/turn/service.rs b/src/turn/service.rs index 999b0480c..7056bc3b6 100644 --- a/src/turn/service.rs +++ b/src/turn/service.rs @@ -71,8 +71,10 @@ impl TurnAuthService for Addr { users: Vec>>, ) -> Box> { // leave only non static users - let users: Vec>> = - users.into_iter().filter(|u| !u.is_static()).collect(); + let users: Vec>> = users + .into_iter() + .filter(|u| !u.borrow().is_static()) + .collect(); if users.is_empty() { Box::new(futures::future::ok(())) From 782894c1d940f7eb5284ef9782f3db423db20e08 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 28 Jun 2019 13:40:01 +0300 Subject: [PATCH 201/735] Use Rc> in endpoints_manager --- Cargo.lock | 12 +- Cargo.toml | 2 +- src/media/peer.rs | 130 +++++++++++++-------- src/signalling/control/publish_endpoint.rs | 4 + src/signalling/endpoints_manager.rs | 36 ++++-- src/signalling/members_manager.rs | 8 +- src/signalling/peers.rs | 25 ++-- src/signalling/pipeline.rs | 10 ++ 8 files changed, 139 insertions(+), 88 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0405f165f..6866ecfd7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -896,15 +896,6 @@ dependencies = [ "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "hashbrown" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "hashbrown" version = "0.3.1" @@ -1145,7 +1136,7 @@ dependencies = [ "dotenv 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "hashbrown 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "macro-attr 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "medea-client-api-proto 0.1.0-dev", @@ -2700,7 +2691,6 @@ dependencies = [ "checksum futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)" = "a2037ec1c6c1c4f79557762eab1f7eae1f64f6cb418ace90fae88f0942b60139" "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" "checksum h2 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)" = "69b2a5a3092cbebbc951fe55408402e696ee2ed09019137d1800fc2c411265d2" -"checksum hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3bae29b6653b3412c2e71e9d486db9f9df5d701941d86683005efb9f2d28e3da" "checksum hashbrown 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "29fba9abe4742d586dfd0c06ae4f7e73a1c2d86b856933509b269d82cdf06e18" "checksum hashbrown 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e1de41fb8dba9714efd92241565cdff73f78508c95697dd56787d3cba27e2353" "checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" diff --git a/Cargo.toml b/Cargo.toml index d07f5f272..c9658dfc6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,7 +34,7 @@ config = "0.9" dotenv = "0.13" failure = "0.1" futures = "0.1" -hashbrown = "0.1" +hashbrown = "0.5" humantime = "1.2" macro-attr = "0.2" medea-client-api-proto = { path = "proto/client-api", features = ["medea"] } diff --git a/src/media/peer.rs b/src/media/peer.rs index 2cb72a6da..5d3522b37 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -22,6 +22,8 @@ use crate::{ peers::Counter, }, }; +use crate::signalling::endpoints_manager::EndpointsManager; +use crate::signalling::control::play_endpoint::WebRtcPlayEndpoint; /// Newly initialized [`Peer`] ready to signalling. #[derive(Debug, PartialEq)] @@ -253,6 +255,7 @@ impl Peer { } } + /// Add all publish endpoints to this [`Peer`]. /// /// This also create [`Peer`]s for [`WebRtcPlayEndpoint`]s that @@ -261,61 +264,86 @@ impl Peer { &mut self, partner_peer: &mut Peer, tracks_count: &mut Counter, - publish_endpoints: HashMap>, + member_id: &MemberId, + endpoints_manager: &mut EndpointsManager, ) { + use crate::signalling::control::play_endpoint::Id as PlayerId; let partner_id = self.partner_member_id(); let self_id = self.id(); + let mut publish_endpoints = endpoints_manager.get_publishers_by_member_id(member_id); - publish_endpoints - .into_iter() - .flat_map(|(_m, e)| { - e.add_peer_id(self_id); - e.receivers() - .into_iter() - .filter_map(|e| { - let upgraded_play = e.upgrade(); - if upgraded_play.is_none() { - warn!( - "Empty weak pointer of publisher's play \ - endpoint. {:?}.", - e - ); - } - upgraded_play - }) - .filter_map(|p| { - let owner = p.owner().upgrade(); - if owner.is_none() { - warn!( - "Empty weak pointer for publisher's play's \ - owner participant. {:?}.", - p - ); - } - owner.map(|owner| (p, owner)) - }) - .filter(|(e, owner)| { - owner.id() == partner_id && !e.is_connected() - }) - }) - .for_each(|(e, _)| { - let track_audio = Rc::new(MediaTrack::new( - tracks_count.next_id(), - MediaType::Audio(AudioSettings {}), - )); - let track_video = Rc::new(MediaTrack::new( - tracks_count.next_id(), - MediaType::Video(VideoSettings {}), - )); - - self.add_sender(track_video.clone()); - self.add_sender(track_audio.clone()); - - partner_peer.add_receiver(track_video); - partner_peer.add_receiver(track_audio); - - e.connect(partner_peer.id()); - }); + publish_endpoints.iter_mut() + .for_each(|(_, e)| e.borrow_mut().add_peer_id(self_id)); + + // pub fn get_publish_sinks(&mut self, member_id; &MemberId, partner_id: &MemberId) -> Vec<&mut WebRtcPlayEndpoint> + let mut publish_sinks = endpoints_manager.get_publish_sinks(member_id, &partner_id); + + for sink in publish_sinks { + let track_audio = Rc::new(MediaTrack::new( + tracks_count.next_id(), + MediaType::Audio(AudioSettings {}), + )); + let track_video = Rc::new(MediaTrack::new( + tracks_count.next_id(), + MediaType::Video(VideoSettings {}), + )); + + self.add_sender(track_video.clone()); + self.add_sender(track_audio.clone()); + + partner_peer.add_receiver(track_video); + partner_peer.add_receiver(track_audio); + + sink.borrow_mut().set_peer_id(partner_peer.id()); + } + + +// publish_endpoints +// .into_iter() +// .map(|(m, e)| { +// e.add_peer_id(self_id); +// (m, e) +// }) +// .flat_map(|(_m, e)| { +// e.sinks() +// .iter() +// .filter_map(|e: &PlayerId| { +// endpoints_manager.get_mut_receiver_by_id(e) +//// if play.is_none() { +//// warn!( +//// "Empty weak pointer of publisher's play \ +//// endpoint. {:?}.", +//// e +//// ); +//// } +//// play.map(|play| (e, play)) +// }) +// .map(|p| { +// let owner_id = p.owner(); +// (p, owner_id) +// }) +// .filter(|(e, owner_id)| { +// **owner_id == partner_id && !e.is_connected() +// }) +// }) +// .for_each(|(e, _)| { +// let track_audio = Rc::new(MediaTrack::new( +// tracks_count.next_id(), +// MediaType::Audio(AudioSettings {}), +// )); +// let track_video = Rc::new(MediaTrack::new( +// tracks_count.next_id(), +// MediaType::Video(VideoSettings {}), +// )); +// +// self.add_sender(track_video.clone()); +// self.add_sender(track_audio.clone()); +// +// partner_peer.add_receiver(track_video); +// partner_peer.add_receiver(track_audio); +// +// e.set_peer_id(partner_peer.id()); +// }); } /// Transition new [`Peer`] into state of waiting for local description. diff --git a/src/signalling/control/publish_endpoint.rs b/src/signalling/control/publish_endpoint.rs index 3c988dc4d..9e158b1a4 100644 --- a/src/signalling/control/publish_endpoint.rs +++ b/src/signalling/control/publish_endpoint.rs @@ -27,6 +27,10 @@ impl WebRtcPublishEndpoint { self.sinks.push(id); } + pub fn sinks(&self) -> Vec<&PlayerEndpointId> { + self.sinks.iter().collect() + } + pub fn owner(&self) -> &MemberId { &self.owner } diff --git a/src/signalling/endpoints_manager.rs b/src/signalling/endpoints_manager.rs index 5328d6e85..1585caa48 100644 --- a/src/signalling/endpoints_manager.rs +++ b/src/signalling/endpoints_manager.rs @@ -16,8 +16,8 @@ use std::{cell::RefCell, rc::Rc}; #[derive(Debug)] pub struct EndpointsManager { ice_users: HashMap>>, - publishers: HashMap, - receivers: HashMap, + publishers: HashMap>>, + receivers: HashMap>>, } impl EndpointsManager { @@ -30,6 +30,16 @@ impl EndpointsManager { } } + + // TODO: rename + pub fn get_publish_sinks(&mut self, member_id: &MemberId, partner_id: &MemberId) -> Vec>> { + self.get_publishers_by_member_id(member_id) + .into_iter() + .flat_map(|(_, p)| p.borrow().sinks().into_iter()) + .filter_map(|id| self.get_receiver_by_id(id)) + .collect() + } + pub fn take_ice_users( &mut self, ) -> HashMap>> { @@ -42,20 +52,22 @@ impl EndpointsManager { pub fn get_publishers_by_member_id( &self, id: &MemberId, - ) -> HashMap<&PublishEndpointId, &WebRtcPublishEndpoint> { + ) -> HashMap>> { self.publishers .iter() - .filter(|(_, p)| p.owner() == id) + .map(|(id, p)| (id.clone(), p.clone())) + .filter(|(id, p)| p.borrow().owner() == id) .collect() } pub fn get_receivers_by_member_id( &self, id: &MemberId, - ) -> HashMap<&PlayEndpointId, &WebRtcPlayEndpoint> { + ) -> HashMap<&PlayEndpointId, Rc>> { self.receivers .iter() - .filter(|(_, p)| p.owner() == id) + .map(|(id, p)| (id, Rc::clone(p))) + .filter(|(_, p)| p.borrow().owner() == id) .collect() } @@ -101,7 +113,7 @@ impl EndpointsManager { id: PlayEndpointId, receiver: WebRtcPlayEndpoint, ) { - self.receivers.insert(id, receiver); + self.receivers.insert(id, Rc::new(RefCell::new(receiver))); } pub fn insert_publisher( @@ -109,20 +121,20 @@ impl EndpointsManager { id: PublishEndpointId, publisher: WebRtcPublishEndpoint, ) { - self.publishers.insert(id, publisher); + self.publishers.insert(id, Rc::new(RefCell::new(publisher))); } pub fn get_publisher_by_id( &self, id: &PublishEndpointId, - ) -> Option<&WebRtcPublishEndpoint> { - self.publishers.get(id) + ) -> Option>> { + self.publishers.get(id).map(Rc::clone) } pub fn get_receiver_by_id( &self, id: &PlayEndpointId, - ) -> Option<&WebRtcPlayEndpoint> { - self.receivers.get(id) + ) -> Option>> { + self.receivers.get(id).map(Rc::clone) } } diff --git a/src/signalling/members_manager.rs b/src/signalling/members_manager.rs index 21d7dd639..46912965f 100644 --- a/src/signalling/members_manager.rs +++ b/src/signalling/members_manager.rs @@ -37,6 +37,8 @@ use crate::{ }, turn::{TurnAuthService, TurnServiceErr, UnreachablePolicy}, }; +use crate::signalling::pipeline::Pipeline; +use std::cell::RefCell; #[derive(Fail, Debug)] #[allow(clippy::module_name_repetitions)] @@ -160,6 +162,7 @@ impl MembersManager { pub fn connection_established( &mut self, ctx: &mut Context, + pipeline: &Pipeline, participant_id: MemberId, con: Box, ) -> ActFuture<&Member, MemberServiceErr> { @@ -191,7 +194,7 @@ impl MembersManager { )) } else { Box::new( - wrap_future(self.turn.create( + wrap_future(pipeline.create_turn( participant_id.clone(), self.room_id.clone(), UnreachablePolicy::ReturnErr, @@ -200,8 +203,7 @@ impl MembersManager { .and_then( move |ice: IceUser, room: &mut Room, _| { room.pipeline.insert_connection(&participant_id, con); - - participant.replace_ice_user(ice); + room.pipeline.replace_ice_user(&participant_id, Rc::new(RefCell::new(ice))); wrap_future(future::ok(participant)) }, diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index ebcd8f547..8d84b86e5 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -17,6 +17,7 @@ use crate::{ room::{PeersRemoved, Room, RoomError}, }, }; +use crate::signalling::endpoints_manager::EndpointsManager; #[derive(Debug)] pub struct PeerRepository { @@ -74,39 +75,43 @@ impl PeerRepository { /// Returns IDs of created [`Peer`]s. `(first_peer_id, second_peer_id)`. pub fn create_peers( &mut self, - first_member: &Member, - second_member: &Member, + first_member_id: &MemberId, + second_member_id: &MemberId, + endpoints_manager: &mut EndpointsManager, ) -> (u64, u64) { debug!( "Created peer between {} and {}.", - first_member.id(), - second_member.id() + first_member_id, + second_member_id ); let first_peer_id = self.peers_count.next_id(); let second_peer_id = self.peers_count.next_id(); let mut first_peer = Peer::new( first_peer_id, - first_member.id().clone(), + first_member_id.clone(), second_peer_id, - second_member.id().clone(), + second_member_id.clone(), ); let mut second_peer = Peer::new( second_peer_id, - second_member.id().clone(), + second_member_id.clone(), first_peer_id, - first_member.id().clone(), + first_member_id.clone(), ); + let first_publishers = endpoints_manager.get_mut_publishers_by_member_id(first_member_id); + let second_publishers = endpoints_manager.get_mut_publishers_by_member_id(second_member_id); + first_peer.add_publish_endpoints( &mut second_peer, &mut self.tracks_count, - first_member.publishers(), + first_publishers, ); second_peer.add_publish_endpoints( &mut first_peer, &mut self.tracks_count, - second_member.publishers(), + second_publishers, ); self.add_peer(first_peer); diff --git a/src/signalling/pipeline.rs b/src/signalling/pipeline.rs index b6679d643..fdac25927 100644 --- a/src/signalling/pipeline.rs +++ b/src/signalling/pipeline.rs @@ -29,6 +29,8 @@ use futures::{ use hashbrown::{hash_map::IntoIter as _, HashMap}; use medea_client_api_proto::Event; use std::{cell::RefCell, convert::TryFrom, rc::Rc, time::Duration}; +use crate::turn::{TurnServiceErr, UnreachablePolicy}; +use crate::api::control::RoomId; #[derive(Debug)] pub struct Pipeline { @@ -94,6 +96,14 @@ impl Pipeline { self.endpoints.get_receivers_by_member_id(id) } + pub fn create_turn(&self, member_id: MemberId, room_id: RoomId, policy: UnreachablePolicy) -> Box> { + self.turn.create(member_id, room_id, policy) + } + + pub fn replace_ice_user(&mut self, member_id: &MemberId, ice_user: Rc>) -> Option>>{ + self.endpoints.replace_ice_user(member_id.clone(), ice_user) + } + pub fn connection_established( &mut self, ctx: &mut Context, From 03241b99b2b1be394225eef100e2d2a62b912fd9 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 28 Jun 2019 13:59:33 +0300 Subject: [PATCH 202/735] Wrap Member to Rc> --- src/media/peer.rs | 2 +- src/signalling/endpoints_manager.rs | 13 ++++++------- src/signalling/members_manager.rs | 26 +++++++++++++------------- src/signalling/peers.rs | 12 +++++++----- src/signalling/pipeline.rs | 13 +++++++++---- src/signalling/room.rs | 9 +++++---- 6 files changed, 41 insertions(+), 34 deletions(-) diff --git a/src/media/peer.rs b/src/media/peer.rs index 5d3522b37..7b68a5bf6 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -265,7 +265,7 @@ impl Peer { partner_peer: &mut Peer, tracks_count: &mut Counter, member_id: &MemberId, - endpoints_manager: &mut EndpointsManager, + endpoints_manager: &EndpointsManager, ) { use crate::signalling::control::play_endpoint::Id as PlayerId; let partner_id = self.partner_member_id(); diff --git a/src/signalling/endpoints_manager.rs b/src/signalling/endpoints_manager.rs index 1585caa48..cf40e850a 100644 --- a/src/signalling/endpoints_manager.rs +++ b/src/signalling/endpoints_manager.rs @@ -30,7 +30,6 @@ impl EndpointsManager { } } - // TODO: rename pub fn get_publish_sinks(&mut self, member_id: &MemberId, partner_id: &MemberId) -> Vec>> { self.get_publishers_by_member_id(member_id) @@ -52,11 +51,11 @@ impl EndpointsManager { pub fn get_publishers_by_member_id( &self, id: &MemberId, - ) -> HashMap>> { + ) -> HashMap<&PublishEndpointId, Rc>> { self.publishers .iter() - .map(|(id, p)| (id.clone(), p.clone())) - .filter(|(id, p)| p.borrow().owner() == id) + .map(|(id, p)| (id, p.clone())) + .filter(|(_, p)| p.borrow().owner() == id) .collect() } @@ -89,13 +88,13 @@ impl EndpointsManager { pub fn peers_removed(&mut self, peer_ids: &[PeerId]) { self.publishers .iter() - .for_each(|(_, p)| p.remove_peer_ids(peer_ids)); + .for_each(|(_, p)| p.borrow_mut().remove_peer_ids(peer_ids)); self.receivers .iter() - .filter_map(|(_, p)| p.peer_id().map(|id| (id, p))) + .filter_map(|(_, p)| p.borrow().peer_id().map(|id| (id, p))) .filter(|(id, _)| peer_ids.contains(&id)) - .for_each(|(_, p)| p.reset()); + .for_each(|(_, p)| p.borrow_mut().reset()); } pub fn get_servers_list_by_member_id( diff --git a/src/signalling/members_manager.rs b/src/signalling/members_manager.rs index 46912965f..66078c045 100644 --- a/src/signalling/members_manager.rs +++ b/src/signalling/members_manager.rs @@ -73,7 +73,7 @@ pub struct MembersManager { room_id: RoomId, /// [`Member`]s which currently are present in this [`Room`]. - participants: HashMap, + participants: HashMap>>, /// Timeout for close [`RpcConnection`] after receiving /// [`RpcConnectionClosed`] message. @@ -100,8 +100,8 @@ impl MembersManager { } /// Lookup [`Member`] by provided id. - pub fn get_participant_by_id(&self, id: &MemberId) -> Option<&Member> { - self.participants.get(id) + pub fn get_participant_by_id(&self, id: &MemberId) -> Option>> { + self.participants.get(id).map(Rc::clone) } /// Lookup [`Member`] by provided id and credentials. Returns @@ -113,10 +113,10 @@ impl MembersManager { &self, participant_id: &MemberId, credentials: &str, - ) -> Result<&Member, AuthorizationError> { + ) -> Result>, AuthorizationError> { match self.get_participant_by_id(participant_id) { Some(participant) => { - if participant.credentials() == credentials { + if participant.borrow().credentials() == credentials { Ok(participant) } else { Err(AuthorizationError::InvalidCredentials) @@ -132,7 +132,7 @@ impl MembersManager { participant_id: &MemberId, ) -> bool { let member = self.participants.get(participant_id).unwrap(); - member.is_connected() + member.borrow().is_connected() && !self.drop_connection_tasks.contains_key(participant_id) } @@ -144,7 +144,7 @@ impl MembersManager { ) -> impl Future { let member = self.get_participant_by_id(&participant_id).unwrap(); - match member.connection() { + match member.borrow().connection() { Some(conn) => { Either::A(conn.send_event(EventMessage::from(event)).map_err( move |_| RoomError::UnableToSendEvent(participant_id), @@ -165,7 +165,7 @@ impl MembersManager { pipeline: &Pipeline, participant_id: MemberId, con: Box, - ) -> ActFuture<&Member, MemberServiceErr> { + ) -> ActFuture>, MemberServiceErr> { let participant = match self.get_participant_by_id(&participant_id) { None => { return Box::new(wrap_future(future::err( @@ -176,7 +176,7 @@ impl MembersManager { }; // lookup previous participant connection - if let Some(mut connection) = participant.connection() { + if let Some(mut connection) = participant.borrow().connection() { debug!( "Closing old RpcConnection for participant {}", participant_id @@ -219,7 +219,7 @@ impl MembersManager { conn: Box, ) { if let Some(member) = self.participants.get_mut(&participant_id) { - member.set_connection(conn); + member.borrow_mut().set_connection(conn); } } @@ -239,7 +239,7 @@ impl MembersManager { match reason { ClosedReason::Closed => { let member = self.participants.get(&participant_id).unwrap(); - member.remove_connection(); + member.borrow_mut().remove_connection(); ctx.spawn(wrap_future( self.delete_ice_user(&participant_id).map_err(|err| { @@ -273,7 +273,7 @@ impl MembersManager { participant_id: &MemberId, ) -> Box> { match self.get_participant_by_id(&participant_id) { - Some(participant) => match participant.take_ice_user() { + Some(participant) => match participant.borrow_mut().take_ice_user() { Some(ice_user) => self.turn.delete(vec![ice_user]), None => Box::new(future::ok(())), }, @@ -293,7 +293,7 @@ impl MembersManager { let mut close_fut = Vec::new(); for (id, participant) in self.participants { - close_fut.push(participant.take_connection().unwrap().close()); + close_fut.push(participant.borrow_mut().take_connection().unwrap().close()); } join_all(close_fut).map(|_| ()) diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index 8d84b86e5..0c7107dcc 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -77,7 +77,7 @@ impl PeerRepository { &mut self, first_member_id: &MemberId, second_member_id: &MemberId, - endpoints_manager: &mut EndpointsManager, + endpoints_manager: &EndpointsManager, ) -> (u64, u64) { debug!( "Created peer between {} and {}.", @@ -100,18 +100,20 @@ impl PeerRepository { first_member_id.clone(), ); - let first_publishers = endpoints_manager.get_mut_publishers_by_member_id(first_member_id); - let second_publishers = endpoints_manager.get_mut_publishers_by_member_id(second_member_id); + let first_publishers = endpoints_manager.get_publishers_by_member_id(first_member_id); + let second_publishers = endpoints_manager.get_publishers_by_member_id(second_member_id); first_peer.add_publish_endpoints( &mut second_peer, &mut self.tracks_count, - first_publishers, + first_member_id, + &endpoints_manager, ); second_peer.add_publish_endpoints( &mut first_peer, &mut self.tracks_count, - second_publishers, + second_member_id, + &endpoints_manager, ); self.add_peer(first_peer); diff --git a/src/signalling/pipeline.rs b/src/signalling/pipeline.rs index fdac25927..d5c450839 100644 --- a/src/signalling/pipeline.rs +++ b/src/signalling/pipeline.rs @@ -58,6 +58,7 @@ impl Pipeline { self.members .get_participant_by_id(id) .unwrap() + .borrow() .is_connected() } @@ -69,7 +70,7 @@ impl Pipeline { self.members.send_event_to_participant(member_id, event) } - pub fn get_member_by_id(&self, id: &MemberId) -> Option<&Member> { + pub fn get_member_by_id(&self, id: &MemberId) -> Option>> { self.members.get_participant_by_id(id) } @@ -77,7 +78,7 @@ impl Pipeline { &self, id: &MemberId, credentials: &str, - ) -> Result<&Member, AuthorizationError> { + ) -> Result>, AuthorizationError> { self.members .get_participant_by_id_and_credentials(id, credentials) } @@ -85,14 +86,18 @@ impl Pipeline { pub fn get_publishers_by_member_id( &self, id: &MemberId, - ) -> HashMap<&PublishEndpointId, &WebRtcPublishEndpoint> { + ) -> HashMap<&PublishEndpointId, Rc>> { self.endpoints.get_publishers_by_member_id(id) } + pub fn endpoints_manager(&self) -> &EndpointsManager { + &self.endpoints + } + pub fn get_receivers_by_member_id( &self, id: &MemberId, - ) -> HashMap<&PlayEndpointId, &WebRtcPlayEndpoint> { + ) -> HashMap<&PlayEndpointId, Rc>> { self.endpoints.get_receivers_by_member_id(id) } diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 1ab4ab9a7..07285ffad 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -33,6 +33,7 @@ use crate::{ }, turn::TurnAuthService, }; +use core::borrow::Borrow; /// Ergonomic type alias for using [`ActorFuture`] for [`Room`]. pub type ActFuture = @@ -361,8 +362,8 @@ impl Room { /// API spec. fn connect_participants( &mut self, - first_member: &Member, - second_member: &Member, + first_member: &MemberId, + second_member: &MemberId, ctx: &mut ::Context, ) { debug!( @@ -372,7 +373,7 @@ impl Room { ); let (first_peer_id, second_peer_id) = - self.peers.create_peers(first_member, second_member); + self.peers.create_peers(first_member, second_member, self.pipeline.endpoints_manager()); self.connect_peers(ctx, first_peer_id, second_peer_id); } @@ -443,7 +444,7 @@ impl Room { && !play.is_connected() { self.connect_participants( - &participant, + participant.id(), &plays_publisher_participant, ctx, ); From 9d61cb47e9992d2c3439d19b3743a81f0c81c375 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 28 Jun 2019 14:18:15 +0300 Subject: [PATCH 203/735] Move part of turn logic into endpoints_manager --- src/media/peer.rs | 114 ++++++++++++++-------------- src/signalling/endpoints_manager.rs | 19 ++++- src/signalling/members_manager.rs | 39 ++++------ src/signalling/peers.rs | 11 +-- src/signalling/pipeline.rs | 56 +++++++++++--- src/signalling/room.rs | 10 ++- 6 files changed, 147 insertions(+), 102 deletions(-) diff --git a/src/media/peer.rs b/src/media/peer.rs index 7b68a5bf6..e7f9c9ec5 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -18,12 +18,14 @@ use crate::{ log::prelude::*, media::{MediaTrack, TrackId}, signalling::{ - control::publish_endpoint::{Id as EndpointId, WebRtcPublishEndpoint}, + control::{ + play_endpoint::WebRtcPlayEndpoint, + publish_endpoint::{Id as EndpointId, WebRtcPublishEndpoint}, + }, + endpoints_manager::EndpointsManager, peers::Counter, }, }; -use crate::signalling::endpoints_manager::EndpointsManager; -use crate::signalling::control::play_endpoint::WebRtcPlayEndpoint; /// Newly initialized [`Peer`] ready to signalling. #[derive(Debug, PartialEq)] @@ -255,7 +257,6 @@ impl Peer { } } - /// Add all publish endpoints to this [`Peer`]. /// /// This also create [`Peer`]s for [`WebRtcPlayEndpoint`]s that @@ -270,13 +271,17 @@ impl Peer { use crate::signalling::control::play_endpoint::Id as PlayerId; let partner_id = self.partner_member_id(); let self_id = self.id(); - let mut publish_endpoints = endpoints_manager.get_publishers_by_member_id(member_id); + let mut publish_endpoints = + endpoints_manager.get_publishers_by_member_id(member_id); - publish_endpoints.iter_mut() + publish_endpoints + .iter_mut() .for_each(|(_, e)| e.borrow_mut().add_peer_id(self_id)); - // pub fn get_publish_sinks(&mut self, member_id; &MemberId, partner_id: &MemberId) -> Vec<&mut WebRtcPlayEndpoint> - let mut publish_sinks = endpoints_manager.get_publish_sinks(member_id, &partner_id); + // pub fn get_publish_sinks(&mut self, member_id; &MemberId, partner_id: + // &MemberId) -> Vec<&mut WebRtcPlayEndpoint> + let mut publish_sinks = + endpoints_manager.get_publish_sinks(member_id, &partner_id); for sink in publish_sinks { let track_audio = Rc::new(MediaTrack::new( @@ -297,53 +302,52 @@ impl Peer { sink.borrow_mut().set_peer_id(partner_peer.id()); } - -// publish_endpoints -// .into_iter() -// .map(|(m, e)| { -// e.add_peer_id(self_id); -// (m, e) -// }) -// .flat_map(|(_m, e)| { -// e.sinks() -// .iter() -// .filter_map(|e: &PlayerId| { -// endpoints_manager.get_mut_receiver_by_id(e) -//// if play.is_none() { -//// warn!( -//// "Empty weak pointer of publisher's play \ -//// endpoint. {:?}.", -//// e -//// ); -//// } -//// play.map(|play| (e, play)) -// }) -// .map(|p| { -// let owner_id = p.owner(); -// (p, owner_id) -// }) -// .filter(|(e, owner_id)| { -// **owner_id == partner_id && !e.is_connected() -// }) -// }) -// .for_each(|(e, _)| { -// let track_audio = Rc::new(MediaTrack::new( -// tracks_count.next_id(), -// MediaType::Audio(AudioSettings {}), -// )); -// let track_video = Rc::new(MediaTrack::new( -// tracks_count.next_id(), -// MediaType::Video(VideoSettings {}), -// )); -// -// self.add_sender(track_video.clone()); -// self.add_sender(track_audio.clone()); -// -// partner_peer.add_receiver(track_video); -// partner_peer.add_receiver(track_audio); -// -// e.set_peer_id(partner_peer.id()); -// }); + // publish_endpoints + // .into_iter() + // .map(|(m, e)| { + // e.add_peer_id(self_id); + // (m, e) + // }) + // .flat_map(|(_m, e)| { + // e.sinks() + // .iter() + // .filter_map(|e: &PlayerId| { + // endpoints_manager.get_mut_receiver_by_id(e) + //// if play.is_none() { + //// warn!( + //// "Empty weak pointer of publisher's + //// play \ endpoint. {:?}.", + //// e + //// ); + //// } + //// play.map(|play| (e, play)) + // }) + // .map(|p| { + // let owner_id = p.owner(); + // (p, owner_id) + // }) + // .filter(|(e, owner_id)| { + // **owner_id == partner_id && !e.is_connected() + // }) + // }) + // .for_each(|(e, _)| { + // let track_audio = Rc::new(MediaTrack::new( + // tracks_count.next_id(), + // MediaType::Audio(AudioSettings {}), + // )); + // let track_video = Rc::new(MediaTrack::new( + // tracks_count.next_id(), + // MediaType::Video(VideoSettings {}), + // )); + // + // self.add_sender(track_video.clone()); + // self.add_sender(track_audio.clone()); + // + // partner_peer.add_receiver(track_video); + // partner_peer.add_receiver(track_audio); + // + // e.set_peer_id(partner_peer.id()); + // }); } /// Transition new [`Peer`] into state of waiting for local description. diff --git a/src/signalling/endpoints_manager.rs b/src/signalling/endpoints_manager.rs index cf40e850a..3448663fa 100644 --- a/src/signalling/endpoints_manager.rs +++ b/src/signalling/endpoints_manager.rs @@ -12,6 +12,11 @@ use futures::Future; use hashbrown::HashMap; use medea_client_api_proto::IceServer; use std::{cell::RefCell, rc::Rc}; +use crate::api::client::rpc_connection::ClosedReason; +use actix::fut::wrap_future; +use actix::AsyncContext as _; + +use crate::log::prelude::*; #[derive(Debug)] pub struct EndpointsManager { @@ -30,8 +35,20 @@ impl EndpointsManager { } } + pub fn connection_closed( + &mut self, + ctx: &mut Context, + participant_id: MemberId, + reason: &ClosedReason, + ) { + } + // TODO: rename - pub fn get_publish_sinks(&mut self, member_id: &MemberId, partner_id: &MemberId) -> Vec>> { + pub fn get_publish_sinks( + &mut self, + member_id: &MemberId, + partner_id: &MemberId, + ) -> Vec>> { self.get_publishers_by_member_id(member_id) .into_iter() .flat_map(|(_, p)| p.borrow().sinks().into_iter()) diff --git a/src/signalling/members_manager.rs b/src/signalling/members_manager.rs index 66078c045..f03f9ec7c 100644 --- a/src/signalling/members_manager.rs +++ b/src/signalling/members_manager.rs @@ -32,12 +32,12 @@ use crate::{ media::IceUser, signalling::{ control::member::Member, + pipeline::Pipeline, room::{ActFuture, RoomError}, Room, }, turn::{TurnAuthService, TurnServiceErr, UnreachablePolicy}, }; -use crate::signalling::pipeline::Pipeline; use std::cell::RefCell; #[derive(Fail, Debug)] @@ -100,7 +100,10 @@ impl MembersManager { } /// Lookup [`Member`] by provided id. - pub fn get_participant_by_id(&self, id: &MemberId) -> Option>> { + pub fn get_participant_by_id( + &self, + id: &MemberId, + ) -> Option>> { self.participants.get(id).map(Rc::clone) } @@ -203,7 +206,10 @@ impl MembersManager { .and_then( move |ice: IceUser, room: &mut Room, _| { room.pipeline.insert_connection(&participant_id, con); - room.pipeline.replace_ice_user(&participant_id, Rc::new(RefCell::new(ice))); + room.pipeline.replace_ice_user( + &participant_id, + Rc::new(RefCell::new(ice)), + ); wrap_future(future::ok(participant)) }, @@ -232,7 +238,7 @@ impl MembersManager { pub fn connection_closed( &mut self, ctx: &mut Context, - participant_id: MemberId, + participant_id: &MemberId, reason: &ClosedReason, ) { let closed_at = Instant::now(); @@ -241,11 +247,6 @@ impl MembersManager { let member = self.participants.get(&participant_id).unwrap(); member.borrow_mut().remove_connection(); - ctx.spawn(wrap_future( - self.delete_ice_user(&participant_id).map_err(|err| { - error!("Error deleting IceUser {:?}", err) - }), - )); // ctx.notify(CloseRoom {}) } ClosedReason::Lost => { @@ -258,7 +259,7 @@ impl MembersManager { &participant_id, closed_at ); ctx.notify(RpcConnectionClosed { - member_id: participant_id, + member_id: participant_id.clone(), reason: ClosedReason::Closed, }) }), @@ -267,20 +268,6 @@ impl MembersManager { } } - /// Deletes [`IceUser`] associated with provided [`Member`]. - fn delete_ice_user( - &mut self, - participant_id: &MemberId, - ) -> Box> { - match self.get_participant_by_id(&participant_id) { - Some(participant) => match participant.borrow_mut().take_ice_user() { - Some(ice_user) => self.turn.delete(vec![ice_user]), - None => Box::new(future::ok(())), - }, - None => Box::new(future::ok(())), - } - } - /// Cancels all connection close tasks, closes all [`RpcConnection`]s, pub fn drop_connections( &mut self, @@ -293,7 +280,9 @@ impl MembersManager { let mut close_fut = Vec::new(); for (id, participant) in self.participants { - close_fut.push(participant.borrow_mut().take_connection().unwrap().close()); + close_fut.push( + participant.borrow_mut().take_connection().unwrap().close(), + ); } join_all(close_fut).map(|_| ()) diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index 0c7107dcc..b97340aad 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -14,10 +14,10 @@ use crate::{ media::{Peer, PeerId, PeerStateMachine}, signalling::{ control::member::Member, + endpoints_manager::EndpointsManager, room::{PeersRemoved, Room, RoomError}, }, }; -use crate::signalling::endpoints_manager::EndpointsManager; #[derive(Debug)] pub struct PeerRepository { @@ -81,8 +81,7 @@ impl PeerRepository { ) -> (u64, u64) { debug!( "Created peer between {} and {}.", - first_member_id, - second_member_id + first_member_id, second_member_id ); let first_peer_id = self.peers_count.next_id(); let second_peer_id = self.peers_count.next_id(); @@ -100,8 +99,10 @@ impl PeerRepository { first_member_id.clone(), ); - let first_publishers = endpoints_manager.get_publishers_by_member_id(first_member_id); - let second_publishers = endpoints_manager.get_publishers_by_member_id(second_member_id); + let first_publishers = + endpoints_manager.get_publishers_by_member_id(first_member_id); + let second_publishers = + endpoints_manager.get_publishers_by_member_id(second_member_id); first_peer.add_publish_endpoints( &mut second_peer, diff --git a/src/signalling/pipeline.rs b/src/signalling/pipeline.rs index d5c450839..3770c18a1 100644 --- a/src/signalling/pipeline.rs +++ b/src/signalling/pipeline.rs @@ -5,7 +5,7 @@ use super::{ use crate::{ api::{ client::rpc_connection::{AuthorizationError, RpcConnection}, - control::{MemberId, RoomSpec}, + control::{MemberId, RoomId, RoomSpec}, }, media::IceUser, signalling::{ @@ -19,18 +19,17 @@ use crate::{ members_manager::MemberServiceErr, room::{ActFuture, Room, RoomError}, }, - turn::service::TurnAuthService, + turn::{service::TurnAuthService, TurnServiceErr, UnreachablePolicy}, }; use actix::Context; -use futures::{ - future::{join_all, Either, IntoFuture}, - Future, -}; +use futures::{future::{join_all, Either, IntoFuture}, Future, future}; use hashbrown::{hash_map::IntoIter as _, HashMap}; use medea_client_api_proto::Event; use std::{cell::RefCell, convert::TryFrom, rc::Rc, time::Duration}; -use crate::turn::{TurnServiceErr, UnreachablePolicy}; -use crate::api::control::RoomId; +use crate::api::client::rpc_connection::ClosedReason; +use actix::fut::wrap_future; +use crate::log::prelude::*; +use actix::AsyncContext; #[derive(Debug)] pub struct Pipeline { @@ -70,7 +69,10 @@ impl Pipeline { self.members.send_event_to_participant(member_id, event) } - pub fn get_member_by_id(&self, id: &MemberId) -> Option>> { + pub fn get_member_by_id( + &self, + id: &MemberId, + ) -> Option>> { self.members.get_participant_by_id(id) } @@ -83,6 +85,27 @@ impl Pipeline { .get_participant_by_id_and_credentials(id, credentials) } + pub fn connection_closed(&mut self, ctx: &mut Context, member_id: MemberId, close_reason: ClosedReason) { + ctx.spawn(wrap_future( + self.delete_ice_user(&member_id).map_err(|err| { + error!("Error deleting IceUser {:?}", err) + }), + )); + self.members.connection_closed(ctx, &member_id, &close_reason); + } + + pub fn delete_ice_user(&mut self, member_id: &MemberId) -> Box>{ + let ice_user = self.endpoints.take_ice_user_by_member_id(member_id); + match self.get_member_by_id(member_id) { + Some(participant) => match ice_user + { + Some(ice_user) => self.turn.delete(vec![ice_user]), + None => Box::new(future::ok(())), + }, + None => Box::new(future::ok(())), + } + } + pub fn get_publishers_by_member_id( &self, id: &MemberId, @@ -101,11 +124,20 @@ impl Pipeline { self.endpoints.get_receivers_by_member_id(id) } - pub fn create_turn(&self, member_id: MemberId, room_id: RoomId, policy: UnreachablePolicy) -> Box> { + pub fn create_turn( + &self, + member_id: MemberId, + room_id: RoomId, + policy: UnreachablePolicy, + ) -> Box> { self.turn.create(member_id, room_id, policy) } - pub fn replace_ice_user(&mut self, member_id: &MemberId, ice_user: Rc>) -> Option>>{ + pub fn replace_ice_user( + &mut self, + member_id: &MemberId, + ice_user: Rc>, + ) -> Option>> { self.endpoints.replace_ice_user(member_id.clone(), ice_user) } @@ -115,7 +147,7 @@ impl Pipeline { id: MemberId, connection: Box, ) -> ActFuture<&Member, MemberServiceErr> { - self.members.connection_established(ctx, id, connection) + //self.members.connection_established(ctx, &self, id, connection) } fn test( diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 07285ffad..2fc30471d 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -33,7 +33,6 @@ use crate::{ }, turn::TurnAuthService, }; -use core::borrow::Borrow; /// Ergonomic type alias for using [`ActorFuture`] for [`Room`]. pub type ActFuture = @@ -372,8 +371,11 @@ impl Room { second_member.id() ); - let (first_peer_id, second_peer_id) = - self.peers.create_peers(first_member, second_member, self.pipeline.endpoints_manager()); + let (first_peer_id, second_peer_id) = self.peers.create_peers( + first_member, + second_member, + self.pipeline.endpoints_manager(), + ); self.connect_peers(ctx, first_peer_id, second_peer_id); } @@ -676,6 +678,6 @@ impl Handler for Room { } self.pipeline - .connection_closed(ctx, msg.member_id, &msg.reason); + .connection_closed(ctx, msg.member_id, msg.reason); } } From cb269b500340ff179ae6d4f2f413dbd6dfdd746a Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 28 Jun 2019 14:25:04 +0300 Subject: [PATCH 204/735] Fix ice_servers list --- src/signalling/pipeline.rs | 6 +++++- src/signalling/room.rs | 24 +++++++++--------------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/signalling/pipeline.rs b/src/signalling/pipeline.rs index 3770c18a1..5fa3682a8 100644 --- a/src/signalling/pipeline.rs +++ b/src/signalling/pipeline.rs @@ -24,7 +24,7 @@ use crate::{ use actix::Context; use futures::{future::{join_all, Either, IntoFuture}, Future, future}; use hashbrown::{hash_map::IntoIter as _, HashMap}; -use medea_client_api_proto::Event; +use medea_client_api_proto::{Event, IceServer}; use std::{cell::RefCell, convert::TryFrom, rc::Rc, time::Duration}; use crate::api::client::rpc_connection::ClosedReason; use actix::fut::wrap_future; @@ -150,6 +150,10 @@ impl Pipeline { //self.members.connection_established(ctx, &self, id, connection) } + pub fn get_ice_servers(&self, id: &MemberId) -> Option> { + self.endpoints.get_servers_list_by_member_id(id) + } + fn test( &mut self, ice_users: Vec>>, diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 2fc30471d..d1fe63114 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -215,12 +215,10 @@ impl Room { let sender = sender.start(); let member_id = sender.member_id(); - let ice_servers = self - .participants - .get_participant_by_id(&member_id) - .ok_or_else(|| RoomError::MemberNotFound(member_id.clone()))? - .servers_list() + self.pipeline.get_ice_servers(&member_id); + let ice_servers = self.pipeline.get_ice_servers(&member_id) .ok_or_else(|| RoomError::NoTurnCredentials(member_id.clone()))?; + let peer_created = Event::PeerCreated { peer_id: sender.id(), sdp_offer: None, @@ -264,14 +262,10 @@ impl Room { let to_peer = to_peer.set_remote_sdp(sdp_offer.clone()); let to_member_id = to_peer.member_id(); - let ice_servers = self - .participants - .get_participant_by_id(&to_member_id) - .ok_or_else(|| RoomError::MemberNotFound(to_member_id.clone()))? - .servers_list() - .ok_or_else(|| { - RoomError::NoTurnCredentials(to_member_id.clone()) - })?; + + // TODO: better error + let ice_servers = self.pipeline.get_ice_servers(&to_member_id) + .ok_or_else(|| RoomError::NoTurnCredentials(to_member_id.clone()))?; let event = Event::PeerCreated { peer_id: to_peer.id(), @@ -367,8 +361,8 @@ impl Room { ) { debug!( "Created peer member {} with member {}", - first_member.id(), - second_member.id() + first_member, + second_member ); let (first_peer_id, second_peer_id) = self.peers.create_peers( From a79eb690bacc80becd7845782d06bcb61d162cdb Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 28 Jun 2019 14:38:11 +0300 Subject: [PATCH 205/735] Fix connection of new member --- src/signalling/pipeline.rs | 8 ++++++ src/signalling/room.rs | 59 +++++++++++++++++++------------------- 2 files changed, 37 insertions(+), 30 deletions(-) diff --git a/src/signalling/pipeline.rs b/src/signalling/pipeline.rs index 5fa3682a8..e1a3eca94 100644 --- a/src/signalling/pipeline.rs +++ b/src/signalling/pipeline.rs @@ -154,6 +154,14 @@ impl Pipeline { self.endpoints.get_servers_list_by_member_id(id) } + pub fn get_receiver_by_id(&self, id: &PlayEndpointId) -> Option>> { + self.endpoints.get_receiver_by_id(id) + } + + pub fn get_publisher_by_id(&self, id: &PublishEndpointId) -> Option>> { + self.endpoints.get_publisher_by_id(id) + } + fn test( &mut self, ice_users: Vec>>, diff --git a/src/signalling/room.rs b/src/signalling/room.rs index d1fe63114..6966f6c63 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -382,66 +382,65 @@ impl Room { /// connected [`Member`]. fn init_participant_connections( &mut self, - participant: &Member, + member_id: &MemberId, ctx: &mut ::Context, ) { let participant_publishers = - self.pipeline.get_publishers_by_member_id(participant.id()); + self.pipeline.get_publishers_by_member_id(member_id); // Create all connected publish endpoints. - for (_, publish) in participant_publishers() { - for receiver in publish.receivers() { + for (_, publish) in participant_publishers { + for receiver in publish.borrow().sinks() { + let q = self.pipeline.get_receiver_by_id(receiver); let receiver = unit_option_unwrap!( - receiver.upgrade(), + q, ctx, "Empty weak pointer for publisher receiver. {:?}.", publish, ); - let receiver_owner = unit_option_unwrap!( - receiver.owner().upgrade(), - ctx, - "Empty weak pointer for publisher's receiver's owner. \ - {:?}.", - receiver, - ); - - if self.pipeline.is_member_has_connection(&receiver_owner.id()) - && !receiver.is_connected() +// let q = self.pipeline.get_member_by_id(receiver.borrow().owner()); +// let receiver_owner = unit_option_unwrap!( +// q, +// ctx, +// "Empty weak pointer for publisher's receiver's owner. \ +// {:?}.", +// receiver, +// ); + + if self.pipeline.is_member_has_connection(receiver.borrow().owner()) + && !receiver.borrow().is_connected() { self.connect_participants( - &participant, - &receiver_owner, + member_id, + receiver.borrow().owner(), ctx, ); } } } + let member_receivers = self.pipeline.get_receivers_by_member_id(member_id); // Create all connected play's receivers peers. - for (_, play) in participant.receivers() { - let plays_publisher_participant = { + for (_, play) in member_receivers { + let plays_publisher_id = { + let q = self.pipeline.get_publisher_by_id(play.borrow().src()); let play_publisher = unit_option_unwrap!( - play.publisher().upgrade(), + q, ctx, "Empty weak pointer for play's publisher. {:?}.", play, ); - unit_option_unwrap!( - play_publisher.owner().upgrade(), - ctx, - "Empty weak pointer for play's publisher owner. {:?}.", - play_publisher, - ) + play_publisher.borrow().owner() }; if self .pipeline - .is_member_has_connection(&plays_publisher_participant.id()) - && !play.is_connected() + .is_member_has_connection(&plays_publisher_id) + && !play.borrow().is_connected() { self.connect_participants( - participant.id(), - &plays_publisher_participant, + member_id, + &plays_publisher_id, ctx, ); } From 14c19cfc0d7776deb54eddb9bb95b906c3dd7123 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 28 Jun 2019 14:41:43 +0300 Subject: [PATCH 206/735] Fix some warns, fmt --- src/media/peer.rs | 13 +----- src/signalling/endpoints_manager.rs | 11 ++---- src/signalling/members_manager.rs | 2 +- src/signalling/peers.rs | 1 - src/signalling/pipeline.rs | 61 ++++++++++++++++++----------- src/signalling/room.rs | 46 +++++++++------------- 6 files changed, 63 insertions(+), 71 deletions(-) diff --git a/src/media/peer.rs b/src/media/peer.rs index e7f9c9ec5..10a5f883f 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -15,16 +15,8 @@ use medea_macro::enum_delegate; use crate::{ api::control::MemberId, - log::prelude::*, media::{MediaTrack, TrackId}, - signalling::{ - control::{ - play_endpoint::WebRtcPlayEndpoint, - publish_endpoint::{Id as EndpointId, WebRtcPublishEndpoint}, - }, - endpoints_manager::EndpointsManager, - peers::Counter, - }, + signalling::{endpoints_manager::EndpointsManager, peers::Counter}, }; /// Newly initialized [`Peer`] ready to signalling. @@ -266,9 +258,8 @@ impl Peer { partner_peer: &mut Peer, tracks_count: &mut Counter, member_id: &MemberId, - endpoints_manager: &EndpointsManager, + endpoints_manager: &mut EndpointsManager, ) { - use crate::signalling::control::play_endpoint::Id as PlayerId; let partner_id = self.partner_member_id(); let self_id = self.id(); let mut publish_endpoints = diff --git a/src/signalling/endpoints_manager.rs b/src/signalling/endpoints_manager.rs index 3448663fa..cc87aac66 100644 --- a/src/signalling/endpoints_manager.rs +++ b/src/signalling/endpoints_manager.rs @@ -3,20 +3,17 @@ use super::control::{ publish_endpoint::{Id as PublishEndpointId, WebRtcPublishEndpoint}, }; use crate::{ - api::control::{MemberId, RoomSpec}, + api::{ + client::rpc_connection::ClosedReason, + control::{MemberId, RoomSpec}, + }, media::{IceUser, PeerId}, signalling::room::Room, }; use actix::Context; -use futures::Future; use hashbrown::HashMap; use medea_client_api_proto::IceServer; use std::{cell::RefCell, rc::Rc}; -use crate::api::client::rpc_connection::ClosedReason; -use actix::fut::wrap_future; -use actix::AsyncContext as _; - -use crate::log::prelude::*; #[derive(Debug)] pub struct EndpointsManager { diff --git a/src/signalling/members_manager.rs b/src/signalling/members_manager.rs index f03f9ec7c..81f81322d 100644 --- a/src/signalling/members_manager.rs +++ b/src/signalling/members_manager.rs @@ -36,7 +36,7 @@ use crate::{ room::{ActFuture, RoomError}, Room, }, - turn::{TurnAuthService, TurnServiceErr, UnreachablePolicy}, + turn::{TurnServiceErr, UnreachablePolicy}, }; use std::cell::RefCell; diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index b97340aad..81615bf5f 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -13,7 +13,6 @@ use crate::{ log::prelude::*, media::{Peer, PeerId, PeerStateMachine}, signalling::{ - control::member::Member, endpoints_manager::EndpointsManager, room::{PeersRemoved, Room, RoomError}, }, diff --git a/src/signalling/pipeline.rs b/src/signalling/pipeline.rs index e1a3eca94..5242506db 100644 --- a/src/signalling/pipeline.rs +++ b/src/signalling/pipeline.rs @@ -4,9 +4,12 @@ use super::{ }; use crate::{ api::{ - client::rpc_connection::{AuthorizationError, RpcConnection}, + client::rpc_connection::{ + AuthorizationError, ClosedReason, RpcConnection, + }, control::{MemberId, RoomId, RoomSpec}, }, + log::prelude::*, media::IceUser, signalling::{ control::{ @@ -21,15 +24,14 @@ use crate::{ }, turn::{service::TurnAuthService, TurnServiceErr, UnreachablePolicy}, }; -use actix::Context; -use futures::{future::{join_all, Either, IntoFuture}, Future, future}; -use hashbrown::{hash_map::IntoIter as _, HashMap}; +use actix::{fut::wrap_future, AsyncContext, Context}; +use futures::{ + future::{self, join_all, Either}, + Future, +}; +use hashbrown::HashMap; use medea_client_api_proto::{Event, IceServer}; -use std::{cell::RefCell, convert::TryFrom, rc::Rc, time::Duration}; -use crate::api::client::rpc_connection::ClosedReason; -use actix::fut::wrap_future; -use crate::log::prelude::*; -use actix::AsyncContext; +use std::{cell::RefCell, rc::Rc, time::Duration}; #[derive(Debug)] pub struct Pipeline { @@ -85,23 +87,30 @@ impl Pipeline { .get_participant_by_id_and_credentials(id, credentials) } - pub fn connection_closed(&mut self, ctx: &mut Context, member_id: MemberId, close_reason: ClosedReason) { + pub fn connection_closed( + &mut self, + ctx: &mut Context, + member_id: MemberId, + close_reason: ClosedReason, + ) { ctx.spawn(wrap_future( - self.delete_ice_user(&member_id).map_err(|err| { - error!("Error deleting IceUser {:?}", err) - }), + self.delete_ice_user(&member_id) + .map_err(|err| error!("Error deleting IceUser {:?}", err)), )); - self.members.connection_closed(ctx, &member_id, &close_reason); + self.members + .connection_closed(ctx, &member_id, &close_reason); } - pub fn delete_ice_user(&mut self, member_id: &MemberId) -> Box>{ + pub fn delete_ice_user( + &mut self, + member_id: &MemberId, + ) -> Box> { let ice_user = self.endpoints.take_ice_user_by_member_id(member_id); match self.get_member_by_id(member_id) { - Some(participant) => match ice_user - { - Some(ice_user) => self.turn.delete(vec![ice_user]), - None => Box::new(future::ok(())), - }, + Some(participant) => match ice_user { + Some(ice_user) => self.turn.delete(vec![ice_user]), + None => Box::new(future::ok(())), + }, None => Box::new(future::ok(())), } } @@ -147,18 +156,24 @@ impl Pipeline { id: MemberId, connection: Box, ) -> ActFuture<&Member, MemberServiceErr> { - //self.members.connection_established(ctx, &self, id, connection) + // self.members.connection_established(ctx, &self, id, connection) } pub fn get_ice_servers(&self, id: &MemberId) -> Option> { self.endpoints.get_servers_list_by_member_id(id) } - pub fn get_receiver_by_id(&self, id: &PlayEndpointId) -> Option>> { + pub fn get_receiver_by_id( + &self, + id: &PlayEndpointId, + ) -> Option>> { self.endpoints.get_receiver_by_id(id) } - pub fn get_publisher_by_id(&self, id: &PublishEndpointId) -> Option>> { + pub fn get_publisher_by_id( + &self, + id: &PublishEndpointId, + ) -> Option>> { self.endpoints.get_publisher_by_id(id) } diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 6966f6c63..18253eba9 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -26,10 +26,7 @@ use crate::{ WaitLocalHaveRemote, WaitLocalSdp, WaitRemoteSdp, }, signalling::{ - control::member::{Member, MemberId}, - members_manager::MembersManager, - peers::PeerRepository, - pipeline::Pipeline, + control::member::MemberId, peers::PeerRepository, pipeline::Pipeline, }, turn::TurnAuthService, }; @@ -216,7 +213,9 @@ impl Room { let sender = sender.start(); let member_id = sender.member_id(); self.pipeline.get_ice_servers(&member_id); - let ice_servers = self.pipeline.get_ice_servers(&member_id) + let ice_servers = self + .pipeline + .get_ice_servers(&member_id) .ok_or_else(|| RoomError::NoTurnCredentials(member_id.clone()))?; let peer_created = Event::PeerCreated { @@ -264,8 +263,12 @@ impl Room { let to_member_id = to_peer.member_id(); // TODO: better error - let ice_servers = self.pipeline.get_ice_servers(&to_member_id) - .ok_or_else(|| RoomError::NoTurnCredentials(to_member_id.clone()))?; + let ice_servers = self + .pipeline + .get_ice_servers(&to_member_id) + .ok_or_else(|| { + RoomError::NoTurnCredentials(to_member_id.clone()) + })?; let event = Event::PeerCreated { peer_id: to_peer.id(), @@ -361,8 +364,7 @@ impl Room { ) { debug!( "Created peer member {} with member {}", - first_member, - second_member + first_member, second_member ); let (first_peer_id, second_peer_id) = self.peers.create_peers( @@ -398,16 +400,9 @@ impl Room { publish, ); -// let q = self.pipeline.get_member_by_id(receiver.borrow().owner()); -// let receiver_owner = unit_option_unwrap!( -// q, -// ctx, -// "Empty weak pointer for publisher's receiver's owner. \ -// {:?}.", -// receiver, -// ); - - if self.pipeline.is_member_has_connection(receiver.borrow().owner()) + if self + .pipeline + .is_member_has_connection(receiver.borrow().owner()) && !receiver.borrow().is_connected() { self.connect_participants( @@ -419,7 +414,8 @@ impl Room { } } - let member_receivers = self.pipeline.get_receivers_by_member_id(member_id); + let member_receivers = + self.pipeline.get_receivers_by_member_id(member_id); // Create all connected play's receivers peers. for (_, play) in member_receivers { let plays_publisher_id = { @@ -433,16 +429,10 @@ impl Room { play_publisher.borrow().owner() }; - if self - .pipeline - .is_member_has_connection(&plays_publisher_id) + if self.pipeline.is_member_has_connection(&plays_publisher_id) && !play.borrow().is_connected() { - self.connect_participants( - member_id, - &plays_publisher_id, - ctx, - ); + self.connect_participants(member_id, &plays_publisher_id, ctx); } } } From e9868e1c8efbbef715532ba47751bb0badaa32c3 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 28 Jun 2019 14:47:15 +0300 Subject: [PATCH 207/735] Some fixes --- src/signalling/members_manager.rs | 11 ++++++----- src/signalling/peers.rs | 6 +++--- src/signalling/pipeline.rs | 4 ++-- src/signalling/room.rs | 2 +- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/signalling/members_manager.rs b/src/signalling/members_manager.rs index 81f81322d..1569a2310 100644 --- a/src/signalling/members_manager.rs +++ b/src/signalling/members_manager.rs @@ -238,28 +238,29 @@ impl MembersManager { pub fn connection_closed( &mut self, ctx: &mut Context, - participant_id: &MemberId, + member_id: &MemberId, reason: &ClosedReason, ) { + let member_id = member_id.clone(); // TODO: temp let closed_at = Instant::now(); match reason { ClosedReason::Closed => { - let member = self.participants.get(&participant_id).unwrap(); + let member = self.participants.get(&member_id).unwrap(); member.borrow_mut().remove_connection(); // ctx.notify(CloseRoom {}) } ClosedReason::Lost => { self.drop_connection_tasks.insert( - participant_id.clone(), + member_id.clone(), ctx.run_later(self.reconnect_timeout, move |_, ctx| { info!( "Member {} connection lost at {:?}. Room will be \ stopped.", - &participant_id, closed_at + &member_id, closed_at ); ctx.notify(RpcConnectionClosed { - member_id: participant_id.clone(), + member_id: member_id.clone(), reason: ClosedReason::Closed, }) }), diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index 81615bf5f..669d77684 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -76,7 +76,7 @@ impl PeerRepository { &mut self, first_member_id: &MemberId, second_member_id: &MemberId, - endpoints_manager: &EndpointsManager, + endpoints_manager: &mut EndpointsManager, ) -> (u64, u64) { debug!( "Created peer between {} and {}.", @@ -107,13 +107,13 @@ impl PeerRepository { &mut second_peer, &mut self.tracks_count, first_member_id, - &endpoints_manager, + endpoints_manager, ); second_peer.add_publish_endpoints( &mut first_peer, &mut self.tracks_count, second_member_id, - &endpoints_manager, + endpoints_manager, ); self.add_peer(first_peer); diff --git a/src/signalling/pipeline.rs b/src/signalling/pipeline.rs index 5242506db..e45295a44 100644 --- a/src/signalling/pipeline.rs +++ b/src/signalling/pipeline.rs @@ -122,8 +122,8 @@ impl Pipeline { self.endpoints.get_publishers_by_member_id(id) } - pub fn endpoints_manager(&self) -> &EndpointsManager { - &self.endpoints + pub fn endpoints_manager(&mut self) -> &mut EndpointsManager { + &mut self.endpoints } pub fn get_receivers_by_member_id( diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 18253eba9..cf9e74a94 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -172,7 +172,7 @@ impl Room { Ok(Self { id: room_spec.id().clone(), peers: PeerRepository::from(HashMap::new()), - pipeline: Pipeline::new(), + pipeline: Pipeline::new(turn, reconnect_timeout, room_spec), }) } From 8f724c0a6cae3aaa52ee07fb6a1a3bfbe46b6889 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 28 Jun 2019 14:53:36 +0300 Subject: [PATCH 208/735] Fix PeersRemoved --- src/signalling/pipeline.rs | 5 +++++ src/signalling/room.rs | 14 +------------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src/signalling/pipeline.rs b/src/signalling/pipeline.rs index e45295a44..79516428b 100644 --- a/src/signalling/pipeline.rs +++ b/src/signalling/pipeline.rs @@ -32,6 +32,7 @@ use futures::{ use hashbrown::HashMap; use medea_client_api_proto::{Event, IceServer}; use std::{cell::RefCell, rc::Rc, time::Duration}; +use crate::media::PeerId; #[derive(Debug)] pub struct Pipeline { @@ -163,6 +164,10 @@ impl Pipeline { self.endpoints.get_servers_list_by_member_id(id) } + pub fn peers_removed(&mut self, peers_id: &[PeerId]) { + self.endpoints.peers_removed(peers_id) + } + pub fn get_receiver_by_id( &self, id: &PlayEndpointId, diff --git a/src/signalling/room.rs b/src/signalling/room.rs index cf9e74a94..5b0804346 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -518,19 +518,7 @@ impl Handler for Room { "Peers {:?} removed for member '{}'.", msg.peers_id, msg.member_id ); - if let Some(participant) = - self.pipeline.get_member_by_id(&msg.member_id) - { - participant.peers_removed(&msg.peers_id); - } else { - error!( - "Member with id {} for which received Event::PeersRemoved not \ - found. Closing room.", - msg.member_id - ); - ctx.notify(CloseRoom {}); - return Box::new(wrap_future(future::err(()))); - } + self.pipeline.peers_removed(&msg.peers_id); Box::new( self.send_peers_removed(msg.member_id, msg.peers_id) From 9dcab91cc8a9ded88cec24d2744236b264d194e2 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 28 Jun 2019 14:56:34 +0300 Subject: [PATCH 209/735] Fix connection_established --- src/signalling/pipeline.rs | 4 ++-- src/signalling/room.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/signalling/pipeline.rs b/src/signalling/pipeline.rs index 79516428b..c21ce6310 100644 --- a/src/signalling/pipeline.rs +++ b/src/signalling/pipeline.rs @@ -156,8 +156,8 @@ impl Pipeline { ctx: &mut Context, id: MemberId, connection: Box, - ) -> ActFuture<&Member, MemberServiceErr> { - // self.members.connection_established(ctx, &self, id, connection) + ) -> ActFuture>, MemberServiceErr> { + self.members.connection_established(ctx, &self, id, connection) } pub fn get_ice_servers(&self, id: &MemberId) -> Option> { diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 5b0804346..ff0035e9a 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -605,7 +605,7 @@ impl Handler for Room { error!("RpcConnectionEstablished error {:?}", err) }) .map(move |participant, room, ctx| { - room.init_participant_connections(&participant, ctx); + room.init_participant_connections(participant.borrow().id(), ctx); }); Box::new(fut) } From 1a17f325455835e5def60a1684dd5f2f136d5710 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 28 Jun 2019 15:00:57 +0300 Subject: [PATCH 210/735] Fix ice user deleting --- src/turn/repo.rs | 6 ++++-- src/turn/service.rs | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/turn/repo.rs b/src/turn/repo.rs index d1ac04764..79f0e8511 100644 --- a/src/turn/repo.rs +++ b/src/turn/repo.rs @@ -84,10 +84,12 @@ impl TurnDatabase { }) } + // TODO: explain username + /// Deletes batch of provided [`IceUser`]s. pub fn remove( &mut self, - users: &[Rc>], + users: &[String], ) -> impl Future> { debug!("Remove ICE users: {:?}", users); let mut delete_keys = Vec::with_capacity(users.len()); @@ -95,7 +97,7 @@ impl TurnDatabase { for user in users { delete_keys.push(format!( "turn/realm/medea/user/{}/key", - user.borrow().user() + user )); } diff --git a/src/turn/service.rs b/src/turn/service.rs index 7056bc3b6..829f91a0f 100644 --- a/src/turn/service.rs +++ b/src/turn/service.rs @@ -71,9 +71,10 @@ impl TurnAuthService for Addr { users: Vec>>, ) -> Box> { // leave only non static users - let users: Vec>> = users + let users: Vec = users .into_iter() .filter(|u| !u.borrow().is_static()) + .map(|u| u.borrow().user().to_string()) .collect(); if users.is_empty() { @@ -259,7 +260,7 @@ impl Handler for Service { /// Deletes all users from given room in redis. #[derive(Debug, Message)] #[rtype(result = "Result<(), TurnServiceErr>")] -struct DeleteIceUsers(Vec>>); +struct DeleteIceUsers(Vec); impl Handler for Service { type Result = ActFuture<(), TurnServiceErr>; From fb3fd64b7e04b3bcf5fc6caa980f7f8e20db603c Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 28 Jun 2019 15:01:09 +0300 Subject: [PATCH 211/735] Fmt --- src/signalling/pipeline.rs | 6 +++--- src/signalling/room.rs | 5 ++++- src/turn/repo.rs | 5 +---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/signalling/pipeline.rs b/src/signalling/pipeline.rs index c21ce6310..ce3a241af 100644 --- a/src/signalling/pipeline.rs +++ b/src/signalling/pipeline.rs @@ -10,7 +10,7 @@ use crate::{ control::{MemberId, RoomId, RoomSpec}, }, log::prelude::*, - media::IceUser, + media::{IceUser, PeerId}, signalling::{ control::{ member::Member, @@ -32,7 +32,6 @@ use futures::{ use hashbrown::HashMap; use medea_client_api_proto::{Event, IceServer}; use std::{cell::RefCell, rc::Rc, time::Duration}; -use crate::media::PeerId; #[derive(Debug)] pub struct Pipeline { @@ -157,7 +156,8 @@ impl Pipeline { id: MemberId, connection: Box, ) -> ActFuture>, MemberServiceErr> { - self.members.connection_established(ctx, &self, id, connection) + self.members + .connection_established(ctx, &self, id, connection) } pub fn get_ice_servers(&self, id: &MemberId) -> Option> { diff --git a/src/signalling/room.rs b/src/signalling/room.rs index ff0035e9a..455735d9e 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -605,7 +605,10 @@ impl Handler for Room { error!("RpcConnectionEstablished error {:?}", err) }) .map(move |participant, room, ctx| { - room.init_participant_connections(participant.borrow().id(), ctx); + room.init_participant_connections( + participant.borrow().id(), + ctx, + ); }); Box::new(fut) } diff --git a/src/turn/repo.rs b/src/turn/repo.rs index 79f0e8511..f2954a081 100644 --- a/src/turn/repo.rs +++ b/src/turn/repo.rs @@ -95,10 +95,7 @@ impl TurnDatabase { let mut delete_keys = Vec::with_capacity(users.len()); for user in users { - delete_keys.push(format!( - "turn/realm/medea/user/{}/key", - user - )); + delete_keys.push(format!("turn/realm/medea/user/{}/key", user)); } self.pool.run(|connection| { From eb57310232f532d04b4e14c21fb555fe8cd001a4 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 28 Jun 2019 15:38:27 +0300 Subject: [PATCH 212/735] Fix some borrowing errors --- src/media/peer.rs | 2 +- src/signalling/control/member.rs | 20 ++++++++++++++++++-- src/signalling/control/publish_endpoint.rs | 5 +++-- src/signalling/endpoints_manager.rs | 9 ++++++--- src/signalling/members_manager.rs | 22 ++++++++++------------ src/signalling/room.rs | 2 +- 6 files changed, 39 insertions(+), 21 deletions(-) diff --git a/src/media/peer.rs b/src/media/peer.rs index 10a5f883f..30284a397 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -258,7 +258,7 @@ impl Peer { partner_peer: &mut Peer, tracks_count: &mut Counter, member_id: &MemberId, - endpoints_manager: &mut EndpointsManager, + endpoints_manager: &EndpointsManager, ) { let partner_id = self.partner_member_id(); let self_id = self.id(); diff --git a/src/signalling/control/member.rs b/src/signalling/control/member.rs index 777a4895c..5a8672468 100644 --- a/src/signalling/control/member.rs +++ b/src/signalling/control/member.rs @@ -1,6 +1,10 @@ use crate::api::client::rpc_connection::RpcConnection; pub use crate::api::control::MemberId; +use medea_client_api_proto::Event; +use crate::api::client::rpc_connection::EventMessage; +use failure::Fail; +use futures::Future; #[derive(Debug)] pub struct Member { @@ -9,9 +13,21 @@ pub struct Member { connection: Option>, } +#[derive(Debug, Fail)] +pub enum MemberError { + #[fail(display = "Rpc connection is empty.")] + RpcConnectionEmpty +} + impl Member { - pub fn connection(&self) -> Option<&Box> { - self.connection.as_ref() + pub fn close_connection(&mut self) -> Result>, MemberError> { + let connection = self.connection.as_mut().ok_or(MemberError::RpcConnectionEmpty)?; + Ok(connection.close()) + } + + pub fn send_event(&mut self, event: EventMessage) -> Result>, MemberError>{ + let connection = self.connection.as_mut().ok_or(MemberError::RpcConnectionEmpty)?; + Ok(connection.send_event(event)) } pub fn take_connection(&mut self) -> Option> { diff --git a/src/signalling/control/publish_endpoint.rs b/src/signalling/control/publish_endpoint.rs index 9e158b1a4..a7e0c1324 100644 --- a/src/signalling/control/publish_endpoint.rs +++ b/src/signalling/control/publish_endpoint.rs @@ -27,8 +27,9 @@ impl WebRtcPublishEndpoint { self.sinks.push(id); } - pub fn sinks(&self) -> Vec<&PlayerEndpointId> { - self.sinks.iter().collect() + // TODO: clone + pub fn sinks(&self) -> Vec { + self.sinks.iter().cloned().collect() } pub fn owner(&self) -> &MemberId { diff --git a/src/signalling/endpoints_manager.rs b/src/signalling/endpoints_manager.rs index cc87aac66..ae3ff20b7 100644 --- a/src/signalling/endpoints_manager.rs +++ b/src/signalling/endpoints_manager.rs @@ -42,14 +42,17 @@ impl EndpointsManager { // TODO: rename pub fn get_publish_sinks( - &mut self, + &self, member_id: &MemberId, partner_id: &MemberId, ) -> Vec>> { + // TODO: useless clone. Maybe fix?? self.get_publishers_by_member_id(member_id) .into_iter() - .flat_map(|(_, p)| p.borrow().sinks().into_iter()) - .filter_map(|id| self.get_receiver_by_id(id)) + .flat_map(|(_, p)| { + p.borrow().sinks().into_iter() + }) + .filter_map(|id| self.get_receiver_by_id(&id)) .collect() } diff --git a/src/signalling/members_manager.rs b/src/signalling/members_manager.rs index 1569a2310..8c8aca915 100644 --- a/src/signalling/members_manager.rs +++ b/src/signalling/members_manager.rs @@ -147,15 +147,12 @@ impl MembersManager { ) -> impl Future { let member = self.get_participant_by_id(&participant_id).unwrap(); - match member.borrow().connection() { - Some(conn) => { - Either::A(conn.send_event(EventMessage::from(event)).map_err( - move |_| RoomError::UnableToSendEvent(participant_id), - )) - } - None => Either::B(future::err(RoomError::ConnectionNotExists( - participant_id, - ))), + if member.borrow().is_connected() { + Either::A(member.borrow_mut().send_event(EventMessage::from(event)).unwrap().map_err( + move |_| RoomError::UnableToSendEvent(participant_id), + )) + } else { + Either::B(future::err(RoomError::ConnectionNotExists(participant_id))) } } @@ -179,7 +176,7 @@ impl MembersManager { }; // lookup previous participant connection - if let Some(mut connection) = participant.borrow().connection() { + if participant.borrow().is_connected() { debug!( "Closing old RpcConnection for participant {}", participant_id @@ -192,8 +189,9 @@ impl MembersManager { { ctx.cancel_future(handler); } + let member_clone = Rc::clone(&participant); Box::new(wrap_future( - connection.close().then(move |_| Ok(participant)), + participant.borrow_mut().close_connection().unwrap().then(move |_| Ok(member_clone)), )) } else { Box::new( @@ -280,7 +278,7 @@ impl MembersManager { }); let mut close_fut = Vec::new(); - for (id, participant) in self.participants { + for (id, participant) in &self.participants { close_fut.push( participant.borrow_mut().take_connection().unwrap().close(), ); diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 455735d9e..e613d0457 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -392,7 +392,7 @@ impl Room { // Create all connected publish endpoints. for (_, publish) in participant_publishers { for receiver in publish.borrow().sinks() { - let q = self.pipeline.get_receiver_by_id(receiver); + let q = self.pipeline.get_receiver_by_id(&receiver); let receiver = unit_option_unwrap!( q, ctx, From 8f56adcc757f6eb312823c5cc21efc838112e080 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 28 Jun 2019 15:45:18 +0300 Subject: [PATCH 213/735] Fix another borrowing errors --- src/signalling/control/member.rs | 8 ++++---- src/signalling/control/play_endpoint.rs | 8 ++++---- src/signalling/control/publish_endpoint.rs | 8 ++++---- src/signalling/endpoints_manager.rs | 12 ++++++------ src/signalling/pipeline.rs | 4 ++-- src/signalling/room.rs | 9 +++++---- 6 files changed, 25 insertions(+), 24 deletions(-) diff --git a/src/signalling/control/member.rs b/src/signalling/control/member.rs index 5a8672468..b3bae6472 100644 --- a/src/signalling/control/member.rs +++ b/src/signalling/control/member.rs @@ -34,12 +34,12 @@ impl Member { self.connection.take() } - pub fn id(&self) -> &MemberId { - &self.id + pub fn id(&self) -> MemberId { + self.id.clone() } - pub fn credentials(&self) -> &str { - &self.credentials + pub fn credentials(&self) -> String { + self.credentials.clone() } pub fn set_connection(&mut self, connection: Box) { diff --git a/src/signalling/control/play_endpoint.rs b/src/signalling/control/play_endpoint.rs index 4f1e2a5c4..4005c8a16 100644 --- a/src/signalling/control/play_endpoint.rs +++ b/src/signalling/control/play_endpoint.rs @@ -22,8 +22,8 @@ impl WebRtcPlayEndpoint { &self.src } - pub fn owner(&self) -> &MemberId { - &self.owner + pub fn owner(&self) -> MemberId { + self.owner.clone() } pub fn is_connected(&self) -> bool { @@ -34,8 +34,8 @@ impl WebRtcPlayEndpoint { self.peer_id = Some(peer_id) } - pub fn peer_id(&self) -> &Option { - &self.peer_id + pub fn peer_id(&self) -> Option { + self.peer_id.clone() } pub fn reset(&mut self) { diff --git a/src/signalling/control/publish_endpoint.rs b/src/signalling/control/publish_endpoint.rs index a7e0c1324..a66ebafd9 100644 --- a/src/signalling/control/publish_endpoint.rs +++ b/src/signalling/control/publish_endpoint.rs @@ -32,12 +32,12 @@ impl WebRtcPublishEndpoint { self.sinks.iter().cloned().collect() } - pub fn owner(&self) -> &MemberId { - &self.owner + pub fn owner(&self) -> MemberId { + self.owner.clone() } - pub fn peer_ids(&self) -> &HashSet { - &self.peer_ids + pub fn peer_ids(&self) -> HashSet { + self.peer_ids.clone() } pub fn reset(&mut self) { diff --git a/src/signalling/endpoints_manager.rs b/src/signalling/endpoints_manager.rs index ae3ff20b7..490e42ddc 100644 --- a/src/signalling/endpoints_manager.rs +++ b/src/signalling/endpoints_manager.rs @@ -68,22 +68,22 @@ impl EndpointsManager { pub fn get_publishers_by_member_id( &self, id: &MemberId, - ) -> HashMap<&PublishEndpointId, Rc>> { + ) -> HashMap>> { self.publishers .iter() - .map(|(id, p)| (id, p.clone())) - .filter(|(_, p)| p.borrow().owner() == id) + .map(|(id, p)| (id.clone(), p.clone())) + .filter(|(_, p)| &p.borrow().owner() == id) .collect() } pub fn get_receivers_by_member_id( &self, id: &MemberId, - ) -> HashMap<&PlayEndpointId, Rc>> { + ) -> HashMap>> { self.receivers .iter() - .map(|(id, p)| (id, Rc::clone(p))) - .filter(|(_, p)| p.borrow().owner() == id) + .map(|(id, p)| (id.clone(), Rc::clone(p))) + .filter(|(_, p)| &p.borrow().owner() == id) .collect() } diff --git a/src/signalling/pipeline.rs b/src/signalling/pipeline.rs index ce3a241af..791816c5a 100644 --- a/src/signalling/pipeline.rs +++ b/src/signalling/pipeline.rs @@ -118,7 +118,7 @@ impl Pipeline { pub fn get_publishers_by_member_id( &self, id: &MemberId, - ) -> HashMap<&PublishEndpointId, Rc>> { + ) -> HashMap>> { self.endpoints.get_publishers_by_member_id(id) } @@ -129,7 +129,7 @@ impl Pipeline { pub fn get_receivers_by_member_id( &self, id: &MemberId, - ) -> HashMap<&PlayEndpointId, Rc>> { + ) -> HashMap>> { self.endpoints.get_receivers_by_member_id(id) } diff --git a/src/signalling/room.rs b/src/signalling/room.rs index e613d0457..f9911f45e 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -402,12 +402,12 @@ impl Room { if self .pipeline - .is_member_has_connection(receiver.borrow().owner()) + .is_member_has_connection(&receiver.borrow().owner()) && !receiver.borrow().is_connected() { self.connect_participants( member_id, - receiver.borrow().owner(), + &receiver.borrow().owner(), ctx, ); } @@ -426,7 +426,8 @@ impl Room { "Empty weak pointer for play's publisher. {:?}.", play, ); - play_publisher.borrow().owner() + let q = play_publisher.borrow().owner(); + q }; if self.pipeline.is_member_has_connection(&plays_publisher_id) @@ -606,7 +607,7 @@ impl Handler for Room { }) .map(move |participant, room, ctx| { room.init_participant_connections( - participant.borrow().id(), + &participant.borrow().id(), ctx, ); }); From 9920856eb42ad7f9a3c206b44fbe071e3e3c6a48 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 28 Jun 2019 15:58:27 +0300 Subject: [PATCH 214/735] Yay! Fixed all errors --- src/signalling/control/member.rs | 3 +-- src/signalling/members_manager.rs | 20 ++++++++++++-------- src/signalling/peers.rs | 5 ----- src/signalling/pipeline.rs | 2 ++ src/turn/repo.rs | 1 - 5 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/signalling/control/member.rs b/src/signalling/control/member.rs index b3bae6472..27ff8cf75 100644 --- a/src/signalling/control/member.rs +++ b/src/signalling/control/member.rs @@ -1,8 +1,7 @@ use crate::api::client::rpc_connection::RpcConnection; +use crate::api::client::rpc_connection::EventMessage; pub use crate::api::control::MemberId; -use medea_client_api_proto::Event; -use crate::api::client::rpc_connection::EventMessage; use failure::Fail; use futures::Future; diff --git a/src/signalling/members_manager.rs b/src/signalling/members_manager.rs index 8c8aca915..402b52651 100644 --- a/src/signalling/members_manager.rs +++ b/src/signalling/members_manager.rs @@ -156,11 +156,21 @@ impl MembersManager { } } + pub fn cancel_close_connection(&mut self, ctx: &mut Context, member_id: &MemberId) { + // cancel RpcConnection close task, since connection is + // reestablished + if let Some(handler) = + self.drop_connection_tasks.remove(member_id) + { + ctx.cancel_future(handler); + } + } + /// Saves provided [`RpcConnection`], registers [`ICEUser`]. /// If [`Member`] already has any other [`RpcConnection`], /// then it will be closed. pub fn connection_established( - &mut self, + &self, ctx: &mut Context, pipeline: &Pipeline, participant_id: MemberId, @@ -182,13 +192,7 @@ impl MembersManager { participant_id ); - // cancel RpcConnection close task, since connection is - // reestablished - if let Some(handler) = - self.drop_connection_tasks.remove(&participant_id) - { - ctx.cancel_future(handler); - } + let member_clone = Rc::clone(&participant); Box::new(wrap_future( participant.borrow_mut().close_connection().unwrap().then(move |_| Ok(member_clone)), diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index 669d77684..8ac39e0a5 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -98,11 +98,6 @@ impl PeerRepository { first_member_id.clone(), ); - let first_publishers = - endpoints_manager.get_publishers_by_member_id(first_member_id); - let second_publishers = - endpoints_manager.get_publishers_by_member_id(second_member_id); - first_peer.add_publish_endpoints( &mut second_peer, &mut self.tracks_count, diff --git a/src/signalling/pipeline.rs b/src/signalling/pipeline.rs index 791816c5a..03753e1a8 100644 --- a/src/signalling/pipeline.rs +++ b/src/signalling/pipeline.rs @@ -156,6 +156,8 @@ impl Pipeline { id: MemberId, connection: Box, ) -> ActFuture>, MemberServiceErr> { + // TODO: Maybe this is bad. + self.members.cancel_close_connection(ctx, &id); self.members .connection_established(ctx, &self, id, connection) } diff --git a/src/turn/repo.rs b/src/turn/repo.rs index f2954a081..42e045c96 100644 --- a/src/turn/repo.rs +++ b/src/turn/repo.rs @@ -11,7 +11,6 @@ use redis::{ConnectionInfo, RedisError}; use tokio::prelude::*; use crate::{log::prelude::*, media::IceUser}; -use std::{cell::RefCell, rc::Rc}; #[derive(Fail, Debug)] pub enum TurnDatabaseErr { From db3f1342758dcf7433deb47a61f655278c07d876 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 28 Jun 2019 19:44:02 +0300 Subject: [PATCH 215/735] Revert implementation through a flat structure (7ca8af5..HEAD) --- Cargo.lock | 12 +- Cargo.toml | 2 +- src/api/client/rpc_connection.rs | 2 +- src/api/client/server.rs | 2 +- src/media/peer.rs | 133 +++---- src/signalling/control/endpoint.rs | 301 +++++++++++++++ src/signalling/control/member.rs | 55 --- src/signalling/control/mod.rs | 10 +- src/signalling/control/participant.rs | 429 +++++++++++++++++++++ src/signalling/control/play_endpoint.rs | 52 --- src/signalling/control/publish_endpoint.rs | 56 --- src/signalling/endpoints_manager.rs | 156 -------- src/signalling/members_manager.rs | 293 -------------- src/signalling/mod.rs | 4 +- src/signalling/participants.rs | 331 ++++++++++++++++ src/signalling/peers.rs | 34 +- src/signalling/pipeline.rs | 219 ----------- src/signalling/room.rs | 204 +++++----- src/turn/repo.rs | 7 +- src/turn/service.rs | 16 +- 20 files changed, 1281 insertions(+), 1037 deletions(-) create mode 100644 src/signalling/control/endpoint.rs delete mode 100644 src/signalling/control/member.rs create mode 100644 src/signalling/control/participant.rs delete mode 100644 src/signalling/control/play_endpoint.rs delete mode 100644 src/signalling/control/publish_endpoint.rs delete mode 100644 src/signalling/endpoints_manager.rs delete mode 100644 src/signalling/members_manager.rs create mode 100644 src/signalling/participants.rs delete mode 100644 src/signalling/pipeline.rs diff --git a/Cargo.lock b/Cargo.lock index 6866ecfd7..0405f165f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -896,6 +896,15 @@ dependencies = [ "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "hashbrown" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "hashbrown" version = "0.3.1" @@ -1136,7 +1145,7 @@ dependencies = [ "dotenv 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "hashbrown 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "macro-attr 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "medea-client-api-proto 0.1.0-dev", @@ -2691,6 +2700,7 @@ dependencies = [ "checksum futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)" = "a2037ec1c6c1c4f79557762eab1f7eae1f64f6cb418ace90fae88f0942b60139" "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" "checksum h2 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)" = "69b2a5a3092cbebbc951fe55408402e696ee2ed09019137d1800fc2c411265d2" +"checksum hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3bae29b6653b3412c2e71e9d486db9f9df5d701941d86683005efb9f2d28e3da" "checksum hashbrown 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "29fba9abe4742d586dfd0c06ae4f7e73a1c2d86b856933509b269d82cdf06e18" "checksum hashbrown 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e1de41fb8dba9714efd92241565cdff73f78508c95697dd56787d3cba27e2353" "checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" diff --git a/Cargo.toml b/Cargo.toml index c9658dfc6..d07f5f272 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,7 +34,7 @@ config = "0.9" dotenv = "0.13" failure = "0.1" futures = "0.1" -hashbrown = "0.5" +hashbrown = "0.1" humantime = "1.2" macro-attr = "0.2" medea-client-api-proto = { path = "proto/client-api", features = ["medea"] } diff --git a/src/api/client/rpc_connection.rs b/src/api/client/rpc_connection.rs index 75aedd535..5992e9c79 100644 --- a/src/api/client/rpc_connection.rs +++ b/src/api/client/rpc_connection.rs @@ -50,7 +50,7 @@ pub struct Authorize { #[derive(Debug)] pub enum AuthorizationError { /// Authorizing [`Participant`] does not exists in the [`Room`]. - MemberNotExists, + ParticipantNotExists, /// Provided credentials are invalid. InvalidCredentials, } diff --git a/src/api/client/server.rs b/src/api/client/server.rs index 968d4c61b..b91c22864 100644 --- a/src/api/client/server.rs +++ b/src/api/client/server.rs @@ -63,7 +63,7 @@ fn ws_index( &r, payload, ), - Err(AuthorizationError::MemberNotExists) => { + Err(AuthorizationError::ParticipantNotExists) => { Ok(HttpResponse::NotFound().into()) } Err(AuthorizationError::InvalidCredentials) => { diff --git a/src/media/peer.rs b/src/media/peer.rs index 30284a397..d853b7890 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -15,8 +15,12 @@ use medea_macro::enum_delegate; use crate::{ api::control::MemberId, + log::prelude::*, media::{MediaTrack, TrackId}, - signalling::{endpoints_manager::EndpointsManager, peers::Counter}, + signalling::{ + control::endpoint::{Id as EndpointId, WebRtcPublishEndpoint}, + peers::Counter, + }, }; /// Newly initialized [`Peer`] ready to signalling. @@ -257,88 +261,61 @@ impl Peer { &mut self, partner_peer: &mut Peer, tracks_count: &mut Counter, - member_id: &MemberId, - endpoints_manager: &EndpointsManager, + publish_endpoints: HashMap>, ) { let partner_id = self.partner_member_id(); let self_id = self.id(); - let mut publish_endpoints = - endpoints_manager.get_publishers_by_member_id(member_id); publish_endpoints - .iter_mut() - .for_each(|(_, e)| e.borrow_mut().add_peer_id(self_id)); - - // pub fn get_publish_sinks(&mut self, member_id; &MemberId, partner_id: - // &MemberId) -> Vec<&mut WebRtcPlayEndpoint> - let mut publish_sinks = - endpoints_manager.get_publish_sinks(member_id, &partner_id); - - for sink in publish_sinks { - let track_audio = Rc::new(MediaTrack::new( - tracks_count.next_id(), - MediaType::Audio(AudioSettings {}), - )); - let track_video = Rc::new(MediaTrack::new( - tracks_count.next_id(), - MediaType::Video(VideoSettings {}), - )); - - self.add_sender(track_video.clone()); - self.add_sender(track_audio.clone()); - - partner_peer.add_receiver(track_video); - partner_peer.add_receiver(track_audio); - - sink.borrow_mut().set_peer_id(partner_peer.id()); - } - - // publish_endpoints - // .into_iter() - // .map(|(m, e)| { - // e.add_peer_id(self_id); - // (m, e) - // }) - // .flat_map(|(_m, e)| { - // e.sinks() - // .iter() - // .filter_map(|e: &PlayerId| { - // endpoints_manager.get_mut_receiver_by_id(e) - //// if play.is_none() { - //// warn!( - //// "Empty weak pointer of publisher's - //// play \ endpoint. {:?}.", - //// e - //// ); - //// } - //// play.map(|play| (e, play)) - // }) - // .map(|p| { - // let owner_id = p.owner(); - // (p, owner_id) - // }) - // .filter(|(e, owner_id)| { - // **owner_id == partner_id && !e.is_connected() - // }) - // }) - // .for_each(|(e, _)| { - // let track_audio = Rc::new(MediaTrack::new( - // tracks_count.next_id(), - // MediaType::Audio(AudioSettings {}), - // )); - // let track_video = Rc::new(MediaTrack::new( - // tracks_count.next_id(), - // MediaType::Video(VideoSettings {}), - // )); - // - // self.add_sender(track_video.clone()); - // self.add_sender(track_audio.clone()); - // - // partner_peer.add_receiver(track_video); - // partner_peer.add_receiver(track_audio); - // - // e.set_peer_id(partner_peer.id()); - // }); + .into_iter() + .flat_map(|(_m, e)| { + e.add_peer_id(self_id); + e.receivers() + .into_iter() + .filter_map(|e| { + let upgraded_play = e.upgrade(); + if upgraded_play.is_none() { + warn!( + "Empty weak pointer of publisher's play \ + endpoint. {:?}.", + e + ); + } + upgraded_play + }) + .filter_map(|p| { + let owner = p.owner().upgrade(); + if owner.is_none() { + warn!( + "Empty weak pointer for publisher's play's \ + owner participant. {:?}.", + p + ); + } + owner.map(|owner| (p, owner)) + }) + .filter(|(e, owner)| { + owner.id() == partner_id && !e.is_connected() + }) + }) + .for_each(|(e, _)| { + let track_audio = Rc::new(MediaTrack::new( + tracks_count.next_id(), + MediaType::Audio(AudioSettings {}), + )); + let track_video = Rc::new(MediaTrack::new( + tracks_count.next_id(), + MediaType::Video(VideoSettings {}), + )); + + self.add_sender(track_video.clone()); + self.add_sender(track_audio.clone()); + + partner_peer.add_receiver(track_video); + partner_peer.add_receiver(track_audio); + + e.connect(partner_peer.id()); + }); } /// Transition new [`Peer`] into state of waiting for local description. diff --git a/src/signalling/control/endpoint.rs b/src/signalling/control/endpoint.rs new file mode 100644 index 000000000..33ca78451 --- /dev/null +++ b/src/signalling/control/endpoint.rs @@ -0,0 +1,301 @@ +//! Signalling representation of endpoints. + +use std::{cell::RefCell, fmt::Display, rc::Weak}; + +use hashbrown::HashSet; + +use crate::{ + api::control::endpoint::{P2pMode, SrcUri}, + media::PeerId, +}; + +use super::participant::Participant; + +/// ID of endpoint. +#[derive(Clone, Debug, Eq, Hash, PartialEq)] +pub struct Id(pub String); + +impl Display for Id { + fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(fmt, "{}", self.0) + } +} + +#[derive(Debug, Clone)] +struct WebRtcPlayEndpointInner { + /// ID of this [`WebRtcPlayEndpoint`]. + id: Id, + + /// Source URI of [`WebRtcPublishEndpoint`] from which this + /// [`WebRtcPlayEndpoint`] receive data. + src: SrcUri, + + /// Publisher [`WebRtcPublishEndpoint`] from which this + /// [`WebRtcPlayEndpoint`] receive data. + publisher: Weak, + + /// Owner [`Participant`] of this [`WebRtcPlayEndpoint`]. + owner: Weak, + + /// [`PeerId`] of [`Peer`] created for this [`WebRtcPlayEndpoint`]. + /// + /// Currently this field used for detecting status of this + /// [`WebRtcPlayEndpoint`] connection. + /// + /// In future this may be used for removing [`WebRtcPlayEndpoint`] + /// and related peer. + peer_id: Option, +} + +impl WebRtcPlayEndpointInner { + fn src(&self) -> SrcUri { + self.src.clone() + } + + fn owner(&self) -> Weak { + Weak::clone(&self.owner) + } + + fn publisher(&self) -> Weak { + self.publisher.clone() + } + + fn is_connected(&self) -> bool { + self.peer_id.is_some() + } + + fn set_peer_id(&mut self, peer_id: PeerId) { + self.peer_id = Some(peer_id) + } + + fn peer_id(&self) -> Option { + self.peer_id + } + + fn reset(&mut self) { + self.peer_id = None + } +} + +impl Drop for WebRtcPlayEndpointInner { + fn drop(&mut self) { + if let Some(receiver_publisher) = self.publisher().upgrade() { + receiver_publisher.remove_empty_weaks_from_receivers(); + } + } +} + +/// Signalling representation of `WebRtcPlayEndpoint`. +#[allow(clippy::module_name_repetitions)] +#[derive(Debug)] +pub struct WebRtcPlayEndpoint(RefCell); + +impl WebRtcPlayEndpoint { + /// Create new [`WebRtcPlayEndpoint`]. + pub fn new( + id: Id, + src: SrcUri, + publisher: Weak, + owner: Weak, + ) -> Self { + Self(RefCell::new(WebRtcPlayEndpointInner { + id, + src, + publisher, + owner, + peer_id: None, + })) + } + + /// Returns [`SrcUri`] of this [`WebRtcPlayEndpoint`]. + pub fn src(&self) -> SrcUri { + self.0.borrow().src() + } + + /// Returns owner [`Participant`] of this [`WebRtcPlayEndpoint`]. + pub fn owner(&self) -> Weak { + self.0.borrow().owner() + } + + /// Returns publisher's [`WebRtcPublishEndpoint`]. + pub fn publisher(&self) -> Weak { + self.0.borrow().publisher() + } + + /// Check that peer connection established for this [`WebRtcPlayEndpoint`]. + pub fn is_connected(&self) -> bool { + self.0.borrow().is_connected() + } + + /// Save [`PeerId`] of this [`WebRtcPlayEndpoint`]. + pub fn connect(&self, peer_id: PeerId) { + self.0.borrow_mut().set_peer_id(peer_id); + } + + /// Return [`PeerId`] of [`Peer`] of this [`WebRtcPlayEndpoint`]. + pub fn peer_id(&self) -> Option { + self.0.borrow().peer_id() + } + + /// Reset state of this [`WebRtcPlayEndpoint`]. + /// + /// Atm this only reset peer_id. + pub fn reset(&self) { + self.0.borrow_mut().reset() + } + + /// Returns ID of this [`WebRtcPlayEndpoint`]. + pub fn id(&self) -> Id { + self.0.borrow().id.clone() + } +} + +#[derive(Debug, Clone)] +struct WebRtcPublishEndpointInner { + /// ID of this [`WebRtcPublishEndpoint`]. + id: Id, + + /// P2P connection mode for this [`WebRtcPublishEndpoint`]. + p2p: P2pMode, + + /// All receivers of this [`WebRtcPublishEndpoint`]. + receivers: Vec>, + + /// Owner [`Participant`] of this [`WebRtcPublishEndpoint`]. + owner: Weak, + + /// [`PeerId`] of all [`Peer`]s created for this [`WebRtcPublishEndpoint`]. + /// + /// Currently this field used for nothing but in future this may be used + /// while removing [`WebRtcPublishEndpoint`] for removing all [`Peer`]s of + /// this [`WebRtcPublishEndpoint`]. + peer_ids: HashSet, +} + +impl Drop for WebRtcPublishEndpointInner { + fn drop(&mut self) { + for receiver in self.receivers().iter().filter_map(|r| Weak::upgrade(r)) + { + if let Some(receiver_owner) = receiver.owner().upgrade() { + receiver_owner.remove_receiver(&receiver.id()) + } + } + } +} + +impl WebRtcPublishEndpointInner { + fn add_receiver(&mut self, receiver: Weak) { + self.receivers.push(receiver); + } + + fn receivers(&self) -> Vec> { + self.receivers.clone() + } + + fn owner(&self) -> Weak { + Weak::clone(&self.owner) + } + + fn add_peer_id(&mut self, peer_id: PeerId) { + self.peer_ids.insert(peer_id); + } + + fn peer_ids(&self) -> HashSet { + self.peer_ids.clone() + } + + fn reset(&mut self) { + self.peer_ids = HashSet::new() + } + + #[allow(clippy::trivially_copy_pass_by_ref)] + fn remove_peer_id(&mut self, peer_id: &PeerId) { + self.peer_ids.remove(peer_id); + } + + fn remove_peer_ids(&mut self, peer_ids: &[PeerId]) { + for peer_id in peer_ids { + self.remove_peer_id(peer_id) + } + } +} + +/// Signalling representation of `WebRtcPublishEndpoint`. +#[allow(clippy::module_name_repetitions)] +#[derive(Debug)] +pub struct WebRtcPublishEndpoint(RefCell); + +impl WebRtcPublishEndpoint { + /// Create new [`WebRtcPublishEndpoint`]. + pub fn new( + id: Id, + p2p: P2pMode, + receivers: Vec>, + owner: Weak, + ) -> Self { + Self(RefCell::new(WebRtcPublishEndpointInner { + id, + p2p, + receivers, + owner, + peer_ids: HashSet::new(), + })) + } + + /// Add receiver for this [`WebRtcPublishEndpoint`]. + pub fn add_receiver(&self, receiver: Weak) { + self.0.borrow_mut().add_receiver(receiver) + } + + /// Returns all receivers of this [`WebRtcPublishEndpoint`]. + pub fn receivers(&self) -> Vec> { + self.0.borrow().receivers() + } + + /// Returns owner [`Participant`] of this [`WebRtcPublishEndpoint`]. + pub fn owner(&self) -> Weak { + self.0.borrow().owner() + } + + /// Add [`PeerId`] of this [`WebRtcPublishEndpoint`]. + pub fn add_peer_id(&self, peer_id: PeerId) { + self.0.borrow_mut().add_peer_id(peer_id) + } + + /// Returns all [`PeerId`] of this [`WebRtcPublishEndpoint`]. + pub fn peer_ids(&self) -> HashSet { + self.0.borrow().peer_ids() + } + + /// Reset state of this [`WebRtcPublishEndpoint`]. + /// + /// Atm this only reset peer_ids. + pub fn reset(&self) { + self.0.borrow_mut().reset() + } + + /// Remove [`PeerId`] from peer_ids. + #[allow(clippy::trivially_copy_pass_by_ref)] + pub fn remove_peer_id(&self, peer_id: &PeerId) { + self.0.borrow_mut().remove_peer_id(peer_id) + } + + /// Remove all [`PeerId`]s related to this [`WebRtcPublishEndpoint`]. + pub fn remove_peer_ids(&self, peer_ids: &[PeerId]) { + self.0.borrow_mut().remove_peer_ids(peer_ids) + } + + /// Returns ID of this [`WebRtcPublishEndpoint`]. + pub fn id(&self) -> Id { + self.0.borrow().id.clone() + } + + /// Remove all empty Weak pointers from receivers of this + /// [`WebRtcPublishEndpoint`]. + pub fn remove_empty_weaks_from_receivers(&self) { + self.0 + .borrow_mut() + .receivers + .retain(|e| e.upgrade().is_some()); + } +} diff --git a/src/signalling/control/member.rs b/src/signalling/control/member.rs deleted file mode 100644 index 27ff8cf75..000000000 --- a/src/signalling/control/member.rs +++ /dev/null @@ -1,55 +0,0 @@ -use crate::api::client::rpc_connection::RpcConnection; -use crate::api::client::rpc_connection::EventMessage; - -pub use crate::api::control::MemberId; -use failure::Fail; -use futures::Future; - -#[derive(Debug)] -pub struct Member { - id: MemberId, - credentials: String, - connection: Option>, -} - -#[derive(Debug, Fail)] -pub enum MemberError { - #[fail(display = "Rpc connection is empty.")] - RpcConnectionEmpty -} - -impl Member { - pub fn close_connection(&mut self) -> Result>, MemberError> { - let connection = self.connection.as_mut().ok_or(MemberError::RpcConnectionEmpty)?; - Ok(connection.close()) - } - - pub fn send_event(&mut self, event: EventMessage) -> Result>, MemberError>{ - let connection = self.connection.as_mut().ok_or(MemberError::RpcConnectionEmpty)?; - Ok(connection.send_event(event)) - } - - pub fn take_connection(&mut self) -> Option> { - self.connection.take() - } - - pub fn id(&self) -> MemberId { - self.id.clone() - } - - pub fn credentials(&self) -> String { - self.credentials.clone() - } - - pub fn set_connection(&mut self, connection: Box) { - self.connection = Some(connection) - } - - pub fn remove_connection(&mut self) { - self.connection = None; - } - - pub fn is_connected(&self) -> bool { - self.connection.is_some() - } -} diff --git a/src/signalling/control/mod.rs b/src/signalling/control/mod.rs index 5084d1d2b..6e59c0562 100644 --- a/src/signalling/control/mod.rs +++ b/src/signalling/control/mod.rs @@ -1,5 +1,9 @@ //! Signalling representation of control spec. -pub mod member; -pub mod play_endpoint; -pub mod publish_endpoint; +pub mod endpoint; +pub mod participant; + +#[doc(inline)] +pub use self::participant::{ + parse_participants, Participant, ParticipantsLoadError, +}; diff --git a/src/signalling/control/participant.rs b/src/signalling/control/participant.rs new file mode 100644 index 000000000..5cbbc7533 --- /dev/null +++ b/src/signalling/control/participant.rs @@ -0,0 +1,429 @@ +//! [`Participant`] is member of [`Room`] with [`RpcConnection`]. + +use std::{cell::RefCell, convert::TryFrom as _, rc::Rc}; + +use failure::Fail; +use hashbrown::HashMap; +use medea_client_api_proto::IceServer; + +use crate::{ + api::control::{ + MemberId as ParticipantId, MemberSpec, RoomSpec, TryFromElementError, + }, + log::prelude::*, + media::{IceUser, PeerId}, +}; + +use super::endpoint::{ + Id as EndpointId, WebRtcPlayEndpoint, WebRtcPublishEndpoint, +}; + +/// Errors which may occur while loading [`Participant`]s from [`RoomSpec`]. +#[derive(Debug, Fail)] +pub enum ParticipantsLoadError { + /// Errors that can occur when we try transform some spec from [`Element`]. + #[fail(display = "TryFromElementError: {}", _0)] + TryFromError(TryFromElementError), + + /// [`Participant`] not found. + #[fail(display = "Member with id '{}' not found.", _0)] + ParticipantNotFound(ParticipantId), + + /// [`Endpoint`] not found. + #[fail(display = "Endpoint with id '{}' not found.", _0)] + EndpointNotFound(String), +} + +impl From for ParticipantsLoadError { + fn from(err: TryFromElementError) -> Self { + ParticipantsLoadError::TryFromError(err) + } +} + +/// [`Participant`] is member of [`Room`] with [`RpcConnection`]. +#[derive(Debug)] +pub struct Participant(RefCell); + +#[allow(clippy::module_name_repetitions)] +#[derive(Debug)] +struct ParticipantInner { + id: ParticipantId, + + /// All [`WebRtcPublishEndpoint`]s of this [`Participant`]. + publishers: HashMap>, + + /// All [`WebRtcPlayEndpoint`]s of this [`Participant`]. + receivers: HashMap>, + + /// Credentials for this [`Participant`]. + credentials: String, + + /// [`IceUser`] of this [`Participant`]. + ice_user: Option, +} + +impl Participant { + /// Create new empty [`Participant`]. + /// + /// To fill this [`Participant`], you need to call the [`Participant::load`] + /// function. + fn new(id: ParticipantId, credentials: String) -> Self { + Self(RefCell::new(ParticipantInner { + id, + publishers: HashMap::new(), + receivers: HashMap::new(), + credentials, + ice_user: None, + })) + } + + /// Load all publishers and receivers of this [`Participant`]. + fn load( + &self, + room_spec: &RoomSpec, + store: &HashMap>, + ) -> Result<(), ParticipantsLoadError> { + let this_member_spec = MemberSpec::try_from( + room_spec.pipeline.get(&self.id().0).map_or( + Err(ParticipantsLoadError::ParticipantNotFound(self.id())), + Ok, + )?, + )?; + + let this_member = store.get(&self.id()).map_or( + Err(ParticipantsLoadError::ParticipantNotFound(self.id())), + Ok, + )?; + + for (spec_play_name, spec_play_endpoint) in + this_member_spec.play_endpoints() + { + let publisher_id = + ParticipantId(spec_play_endpoint.src.member_id.to_string()); + let publisher_participant = store.get(&publisher_id).map_or( + Err(ParticipantsLoadError::ParticipantNotFound(publisher_id)), + Ok, + )?; + let publisher_spec = MemberSpec::try_from( + room_spec + .pipeline + .get(&spec_play_endpoint.src.member_id.to_string()) + .map_or( + Err(ParticipantsLoadError::ParticipantNotFound( + spec_play_endpoint.src.member_id.clone(), + )), + Ok, + )?, + )?; + + let publisher_endpoint = *publisher_spec + .publish_endpoints() + .get(&spec_play_endpoint.src.endpoint_id) + .map_or( + Err(ParticipantsLoadError::EndpointNotFound( + spec_play_endpoint.src.endpoint_id.clone(), + )), + Ok, + )?; + + if let Some(publisher) = publisher_participant.get_publisher_by_id( + &EndpointId(spec_play_endpoint.src.endpoint_id.to_string()), + ) { + let new_play_endpoint_id = + EndpointId(spec_play_name.to_string()); + let new_play_endpoint = Rc::new(WebRtcPlayEndpoint::new( + new_play_endpoint_id.clone(), + spec_play_endpoint.src.clone(), + Rc::downgrade(&publisher), + Rc::downgrade(&this_member), + )); + + self.insert_receiver(Rc::clone(&new_play_endpoint)); + + publisher.add_receiver(Rc::downgrade(&new_play_endpoint)); + } else { + let new_publish_id = + EndpointId(spec_play_endpoint.src.endpoint_id.to_string()); + let new_publish = Rc::new(WebRtcPublishEndpoint::new( + new_publish_id.clone(), + publisher_endpoint.p2p.clone(), + Vec::new(), + Rc::downgrade(&publisher_participant), + )); + + let new_self_play_id = EndpointId(spec_play_name.to_string()); + let new_self_play = Rc::new(WebRtcPlayEndpoint::new( + new_self_play_id.clone(), + spec_play_endpoint.src.clone(), + Rc::downgrade(&new_publish), + Rc::downgrade(&this_member), + )); + + new_publish.add_receiver(Rc::downgrade(&new_self_play)); + + publisher_participant.insert_publisher(new_publish); + + self.insert_receiver(new_self_play); + } + } + + // This is necessary to create [`WebRtcPublishEndpoint`], + // to which none [`WebRtcPlayEndpoint`] refers. + this_member_spec.publish_endpoints().into_iter().for_each( + |(name, e)| { + let endpoint_id = EndpointId(name.clone()); + if self.publishers().get(&endpoint_id).is_none() { + self.insert_publisher(Rc::new(WebRtcPublishEndpoint::new( + endpoint_id, + e.p2p.clone(), + Vec::new(), + Rc::downgrade(&this_member), + ))); + } + }, + ); + + Ok(()) + } + + /// Notify [`Participant`] that some [`Peer`]s removed. + /// + /// All [`PeerId`]s related to this [`Participant`] will be removed. + pub fn peers_removed(&self, peer_ids: &[PeerId]) { + self.publishers() + .into_iter() + .for_each(|(_, p)| p.remove_peer_ids(peer_ids)); + + self.receivers() + .into_iter() + .filter_map(|(_, p)| p.peer_id().map(|id| (id, p))) + .filter(|(id, _)| peer_ids.contains(&id)) + .for_each(|(_, p)| p.reset()); + } + + /// Returns list of [`IceServer`] for this [`Participant`]. + pub fn servers_list(&self) -> Option> { + self.0.borrow().ice_user.as_ref().map(IceUser::servers_list) + } + + /// Returns and set to `None` [`IceUser`] of this [`Participant`]. + pub fn take_ice_user(&self) -> Option { + self.0.borrow_mut().ice_user.take() + } + + /// Replace and return [`IceUser`] of this [`Participant`]. + pub fn replace_ice_user(&self, new_ice_user: IceUser) -> Option { + self.0.borrow_mut().ice_user.replace(new_ice_user) + } + + /// Returns [`ParticipantId`] of this [`Participant`]. + pub fn id(&self) -> ParticipantId { + self.0.borrow().id.clone() + } + + /// Returns credentials of this [`Participant`]. + pub fn credentials(&self) -> String { + self.0.borrow().credentials.clone() + } + + /// Returns all publishers of this [`Participant`]. + pub fn publishers(&self) -> HashMap> { + self.0.borrow().publishers.clone() + } + + /// Returns all receivers of this [`Participant`]. + pub fn receivers(&self) -> HashMap> { + self.0.borrow().receivers.clone() + } + + /// Insert receiver into this [`Participant`]. + pub fn insert_receiver(&self, endpoint: Rc) { + self.0 + .borrow_mut() + .receivers + .insert(endpoint.id(), endpoint); + } + + /// Insert publisher into this [`Participant`]. + pub fn insert_publisher(&self, endpoint: Rc) { + self.0 + .borrow_mut() + .publishers + .insert(endpoint.id(), endpoint); + } + + /// Lookup [`WebRtcPublishEndpoint`] publisher by [`EndpointId`]. + pub fn get_publisher_by_id( + &self, + id: &EndpointId, + ) -> Option> { + self.0.borrow().publishers.get(id).cloned() + } + + /// Lookup [`WebRtcPlayEndpoint`] receiver by [`EndpointId`]. + pub fn get_receiver_by_id( + &self, + id: &EndpointId, + ) -> Option> { + self.0.borrow().receivers.get(id).cloned() + } + + /// Remove receiver [`WebRtcPlayEndpoint`] from this [`Participant`]. + pub fn remove_receiver(&self, id: &EndpointId) { + self.0.borrow_mut().receivers.remove(id); + } + + /// Remove receiver [`WebRtcPublishEndpoint`] from this [`Participant`]. + pub fn remove_publisher(&self, id: &EndpointId) { + self.0.borrow_mut().publishers.remove(id); + } +} + +/// Creates all empty [`Participant`] from [`RoomSpec`] and then +/// load all related to this [`Participant`]s receivers and publishers. +/// +/// Returns store of all [`Participant`]s loaded from [`RoomSpec`]. +pub fn parse_participants( + room_spec: &RoomSpec, +) -> Result>, ParticipantsLoadError> { + let members = room_spec.members()?; + let mut participants = HashMap::new(); + + for (id, member) in &members { + participants.insert( + id.clone(), + Rc::new(Participant::new( + id.clone(), + member.credentials().to_string(), + )), + ); + } + + for (_, participant) in &participants { + participant.load(room_spec, &participants)?; + } + + debug!( + "Created ParticipantService with participants: {:?}.", + participants + .iter() + .map(|(id, p)| { + format!( + "{{ id: {}, receivers: {:?}, publishers: {:?} }};", + id, + p.receivers() + .into_iter() + .map(|(id, _)| id.to_string()) + .collect::>(), + p.publishers() + .into_iter() + .map(|(id, _)| id.to_string()) + .collect::>() + ) + }) + .collect::>() + ); + + Ok(participants) +} + +#[cfg(test)] +mod participant_loading_tests { + use std::rc::Rc; + + use crate::api::control::Element; + + use super::*; + + #[test] + pub fn load_store() { + let spec = r#" + kind: Room + id: test-call + spec: + pipeline: + caller: + kind: Member + credentials: test + spec: + pipeline: + publish: + kind: WebRtcPublishEndpoint + spec: + p2p: Always + some-member: + kind: Member + credentials: test + spec: + pipeline: + publish: + kind: WebRtcPublishEndpoint + spec: + p2p: Always + responder: + kind: Member + credentials: test + spec: + pipeline: + play: + kind: WebRtcPlayEndpoint + spec: + src: "local://test-call/caller/publish" + play2: + kind: WebRtcPlayEndpoint + spec: + src: "local://test-call/some-member/publish" + "#; + let room_element: Element = serde_yaml::from_str(&spec).unwrap(); + let room_spec = RoomSpec::try_from(&room_element).unwrap(); + let store = parse_participants(&room_spec).unwrap(); + + let caller = store.get(&ParticipantId("caller".to_string())).unwrap(); + let responder = + store.get(&ParticipantId("responder".to_string())).unwrap(); + + let caller_publish_endpoint = caller + .get_publisher_by_id(&EndpointId("publish".to_string())) + .unwrap(); + let responder_play_endpoint = responder + .get_receiver_by_id(&EndpointId("play".to_string())) + .unwrap(); + + let is_caller_has_responder_in_receivers = caller_publish_endpoint + .receivers() + .into_iter() + .map(|p| p.upgrade().unwrap()) + .filter(|p| Rc::ptr_eq(p, &responder_play_endpoint)) + .count() + == 1; + assert!(is_caller_has_responder_in_receivers); + + assert!(Rc::ptr_eq( + &responder_play_endpoint.publisher().upgrade().unwrap(), + &caller_publish_endpoint + )); + + let some_participant = store + .get(&ParticipantId("some-member".to_string())) + .unwrap(); + assert!(some_participant.receivers().is_empty()); + assert_eq!(some_participant.publishers().len(), 1); + + let responder_play2_endpoint = responder + .get_receiver_by_id(&EndpointId("play2".to_string())) + .unwrap(); + let some_participant_publisher = some_participant + .get_publisher_by_id(&EndpointId("publish".to_string())) + .unwrap(); + assert_eq!(some_participant_publisher.receivers().len(), 1); + let is_some_participant_has_responder_in_receivers = + some_participant_publisher + .receivers() + .into_iter() + .map(|p| p.upgrade().unwrap()) + .filter(|p| Rc::ptr_eq(p, &responder_play2_endpoint)) + .count() + == 1; + assert!(is_some_participant_has_responder_in_receivers); + } +} diff --git a/src/signalling/control/play_endpoint.rs b/src/signalling/control/play_endpoint.rs deleted file mode 100644 index 4005c8a16..000000000 --- a/src/signalling/control/play_endpoint.rs +++ /dev/null @@ -1,52 +0,0 @@ -use super::publish_endpoint::Id as PublishEndpointId; -use crate::{ - api::control::MemberId, - media::{IceUser, PeerId}, -}; -use std::rc::Rc; - -#[derive(Clone, Debug, Eq, Hash, PartialEq)] -pub struct Id(String); - -#[derive(Debug)] -pub struct WebRtcPlayEndpoint { - id: Id, - src: PublishEndpointId, - owner: MemberId, - ice_user: Option>, - peer_id: Option, -} - -impl WebRtcPlayEndpoint { - pub fn src(&self) -> &PublishEndpointId { - &self.src - } - - pub fn owner(&self) -> MemberId { - self.owner.clone() - } - - pub fn is_connected(&self) -> bool { - self.peer_id.is_some() - } - - pub fn set_peer_id(&mut self, peer_id: PeerId) { - self.peer_id = Some(peer_id) - } - - pub fn peer_id(&self) -> Option { - self.peer_id.clone() - } - - pub fn reset(&mut self) { - self.peer_id = None; - } - - pub fn take_ice_user(&mut self) -> Option> { - self.ice_user.take() - } - - pub fn set_ice_user(&mut self, user: Rc) { - self.ice_user = Some(user); - } -} diff --git a/src/signalling/control/publish_endpoint.rs b/src/signalling/control/publish_endpoint.rs deleted file mode 100644 index a66ebafd9..000000000 --- a/src/signalling/control/publish_endpoint.rs +++ /dev/null @@ -1,56 +0,0 @@ -use super::play_endpoint::Id as PlayerEndpointId; -use crate::{ - api::control::MemberId, - media::{IceUser, PeerId}, -}; -use hashbrown::HashSet; -use std::rc::Rc; - -#[derive(Clone, Debug, Eq, Hash, PartialEq)] -pub struct Id(String); - -#[derive(Debug)] -pub struct WebRtcPublishEndpoint { - id: Id, - sinks: Vec, - owner: MemberId, - ice_user: Option>, - peer_ids: HashSet, -} - -impl WebRtcPublishEndpoint { - pub fn add_peer_id(&mut self, peer_id: PeerId) { - self.peer_ids.insert(peer_id); - } - - pub fn add_sink(&mut self, id: PlayerEndpointId) { - self.sinks.push(id); - } - - // TODO: clone - pub fn sinks(&self) -> Vec { - self.sinks.iter().cloned().collect() - } - - pub fn owner(&self) -> MemberId { - self.owner.clone() - } - - pub fn peer_ids(&self) -> HashSet { - self.peer_ids.clone() - } - - pub fn reset(&mut self) { - self.peer_ids = HashSet::new(); - } - - pub fn remove_peer_id(&mut self, peer_id: &PeerId) -> bool { - self.peer_ids.remove(peer_id) - } - - pub fn remove_peer_ids(&mut self, peer_ids: &[PeerId]) { - for peer_id in peer_ids { - self.remove_peer_id(peer_id); - } - } -} diff --git a/src/signalling/endpoints_manager.rs b/src/signalling/endpoints_manager.rs deleted file mode 100644 index 490e42ddc..000000000 --- a/src/signalling/endpoints_manager.rs +++ /dev/null @@ -1,156 +0,0 @@ -use super::control::{ - play_endpoint::{Id as PlayEndpointId, WebRtcPlayEndpoint}, - publish_endpoint::{Id as PublishEndpointId, WebRtcPublishEndpoint}, -}; -use crate::{ - api::{ - client::rpc_connection::ClosedReason, - control::{MemberId, RoomSpec}, - }, - media::{IceUser, PeerId}, - signalling::room::Room, -}; -use actix::Context; -use hashbrown::HashMap; -use medea_client_api_proto::IceServer; -use std::{cell::RefCell, rc::Rc}; - -#[derive(Debug)] -pub struct EndpointsManager { - ice_users: HashMap>>, - publishers: HashMap>>, - receivers: HashMap>>, -} - -impl EndpointsManager { - pub fn new(spec: &RoomSpec) -> Self { - // TODO - Self { - ice_users: HashMap::new(), - publishers: HashMap::new(), - receivers: HashMap::new(), - } - } - - pub fn connection_closed( - &mut self, - ctx: &mut Context, - participant_id: MemberId, - reason: &ClosedReason, - ) { - } - - // TODO: rename - pub fn get_publish_sinks( - &self, - member_id: &MemberId, - partner_id: &MemberId, - ) -> Vec>> { - // TODO: useless clone. Maybe fix?? - self.get_publishers_by_member_id(member_id) - .into_iter() - .flat_map(|(_, p)| { - p.borrow().sinks().into_iter() - }) - .filter_map(|id| self.get_receiver_by_id(&id)) - .collect() - } - - pub fn take_ice_users( - &mut self, - ) -> HashMap>> { - let mut ice_users = HashMap::new(); - std::mem::swap(&mut self.ice_users, &mut ice_users); - - ice_users - } - - pub fn get_publishers_by_member_id( - &self, - id: &MemberId, - ) -> HashMap>> { - self.publishers - .iter() - .map(|(id, p)| (id.clone(), p.clone())) - .filter(|(_, p)| &p.borrow().owner() == id) - .collect() - } - - pub fn get_receivers_by_member_id( - &self, - id: &MemberId, - ) -> HashMap>> { - self.receivers - .iter() - .map(|(id, p)| (id.clone(), Rc::clone(p))) - .filter(|(_, p)| &p.borrow().owner() == id) - .collect() - } - - pub fn take_ice_user_by_member_id( - &mut self, - member_id: &MemberId, - ) -> Option>> { - self.ice_users.remove(member_id) - } - - pub fn replace_ice_user( - &mut self, - member_id: MemberId, - mut new_ice_user: Rc>, - ) -> Option>> { - self.ice_users.insert(member_id.clone(), new_ice_user) - } - - pub fn peers_removed(&mut self, peer_ids: &[PeerId]) { - self.publishers - .iter() - .for_each(|(_, p)| p.borrow_mut().remove_peer_ids(peer_ids)); - - self.receivers - .iter() - .filter_map(|(_, p)| p.borrow().peer_id().map(|id| (id, p))) - .filter(|(id, _)| peer_ids.contains(&id)) - .for_each(|(_, p)| p.borrow_mut().reset()); - } - - pub fn get_servers_list_by_member_id( - &self, - member_id: &MemberId, - ) -> Option> { - self.ice_users - .get(member_id) - .as_ref() - .map(|u| u.borrow().servers_list()) - } - - pub fn insert_receiver( - &mut self, - id: PlayEndpointId, - receiver: WebRtcPlayEndpoint, - ) { - self.receivers.insert(id, Rc::new(RefCell::new(receiver))); - } - - pub fn insert_publisher( - &mut self, - id: PublishEndpointId, - publisher: WebRtcPublishEndpoint, - ) { - self.publishers.insert(id, Rc::new(RefCell::new(publisher))); - } - - pub fn get_publisher_by_id( - &self, - id: &PublishEndpointId, - ) -> Option>> { - self.publishers.get(id).map(Rc::clone) - } - - pub fn get_receiver_by_id( - &self, - id: &PlayEndpointId, - ) -> Option>> { - self.receivers.get(id).map(Rc::clone) - } -} diff --git a/src/signalling/members_manager.rs b/src/signalling/members_manager.rs deleted file mode 100644 index 402b52651..000000000 --- a/src/signalling/members_manager.rs +++ /dev/null @@ -1,293 +0,0 @@ -//! [`Member`] is member with [`RpcConnection`]. [`MemberService`] -//! stores [`Member`]s and associated [`RpcConnection`]s, handles -//! [`RpcConnection`] authorization, establishment, message sending, Turn -//! credentials management. - -use std::{ - rc::Rc, - time::{Duration, Instant}, -}; - -use actix::{ - fut::wrap_future, ActorFuture, AsyncContext, Context, MailboxError, - SpawnHandle, -}; -use failure::Fail; -use futures::{ - future::{self, join_all, Either}, - Future, -}; -use hashbrown::HashMap; -use medea_client_api_proto::Event; - -use crate::{ - api::{ - client::rpc_connection::{ - AuthorizationError, ClosedReason, EventMessage, RpcConnection, - RpcConnectionClosed, - }, - control::{MemberId, RoomId, RoomSpec}, - }, - log::prelude::*, - media::IceUser, - signalling::{ - control::member::Member, - pipeline::Pipeline, - room::{ActFuture, RoomError}, - Room, - }, - turn::{TurnServiceErr, UnreachablePolicy}, -}; -use std::cell::RefCell; - -#[derive(Fail, Debug)] -#[allow(clippy::module_name_repetitions)] -pub enum MemberServiceErr { - #[fail(display = "TurnService Error in MemberService: {}", _0)] - TurnServiceErr(TurnServiceErr), - #[fail(display = "Mailbox error when accessing MemberService: {}", _0)] - MailBoxErr(MailboxError), - #[fail(display = "Member with Id [{}] was not found", _0)] - MemberNotFound(MemberId), -} - -impl From for MemberServiceErr { - fn from(err: TurnServiceErr) -> Self { - MemberServiceErr::TurnServiceErr(err) - } -} - -impl From for MemberServiceErr { - fn from(err: MailboxError) -> Self { - MemberServiceErr::MailBoxErr(err) - } -} - -/// [`Member`] is member of [`Room`] with [`RpcConnection`]. -/// [`MemberService`] stores [`Member`]s and associated -/// [`RpcConnection`]s, handles [`RpcConnection`] authorization, establishment, -/// message sending. -#[derive(Debug)] -pub struct MembersManager { - /// [`Room`]s id from which this [`MemberService`] was created. - room_id: RoomId, - - /// [`Member`]s which currently are present in this [`Room`]. - participants: HashMap>>, - - /// Timeout for close [`RpcConnection`] after receiving - /// [`RpcConnectionClosed`] message. - reconnect_timeout: Duration, - - /// Stores [`RpcConnection`] drop tasks. - /// If [`RpcConnection`] is lost, [`Room`] waits for connection_timeout - /// before dropping it irrevocably in case it gets reestablished. - drop_connection_tasks: HashMap, -} - -impl MembersManager { - /// Create new [`MemberService`] from [`RoomSpec`]. - pub fn new( - room_spec: &RoomSpec, - reconnect_timeout: Duration, - ) -> Result { - Ok(Self { - room_id: room_spec.id().clone(), - participants: HashMap::new(), // TODO - reconnect_timeout, - drop_connection_tasks: HashMap::new(), - }) - } - - /// Lookup [`Member`] by provided id. - pub fn get_participant_by_id( - &self, - id: &MemberId, - ) -> Option>> { - self.participants.get(id).map(Rc::clone) - } - - /// Lookup [`Member`] by provided id and credentials. Returns - /// [`Err(AuthorizationError::MemberNotExists)`] if lookup by - /// [`MemberId`] failed. Returns - /// [`Err(AuthorizationError::InvalidCredentials)`] if [`Member`] - /// was found, but incorrect credentials was provided. - pub fn get_participant_by_id_and_credentials( - &self, - participant_id: &MemberId, - credentials: &str, - ) -> Result>, AuthorizationError> { - match self.get_participant_by_id(participant_id) { - Some(participant) => { - if participant.borrow().credentials() == credentials { - Ok(participant) - } else { - Err(AuthorizationError::InvalidCredentials) - } - } - None => Err(AuthorizationError::MemberNotExists), - } - } - - /// Checks if [`Member`] has **active** [`RcpConnection`]. - pub fn participant_has_connection( - &self, - participant_id: &MemberId, - ) -> bool { - let member = self.participants.get(participant_id).unwrap(); - member.borrow().is_connected() - && !self.drop_connection_tasks.contains_key(participant_id) - } - - /// Send [`Event`] to specified remote [`Member`]. - pub fn send_event_to_participant( - &mut self, - participant_id: MemberId, - event: Event, - ) -> impl Future { - let member = self.get_participant_by_id(&participant_id).unwrap(); - - if member.borrow().is_connected() { - Either::A(member.borrow_mut().send_event(EventMessage::from(event)).unwrap().map_err( - move |_| RoomError::UnableToSendEvent(participant_id), - )) - } else { - Either::B(future::err(RoomError::ConnectionNotExists(participant_id))) - } - } - - pub fn cancel_close_connection(&mut self, ctx: &mut Context, member_id: &MemberId) { - // cancel RpcConnection close task, since connection is - // reestablished - if let Some(handler) = - self.drop_connection_tasks.remove(member_id) - { - ctx.cancel_future(handler); - } - } - - /// Saves provided [`RpcConnection`], registers [`ICEUser`]. - /// If [`Member`] already has any other [`RpcConnection`], - /// then it will be closed. - pub fn connection_established( - &self, - ctx: &mut Context, - pipeline: &Pipeline, - participant_id: MemberId, - con: Box, - ) -> ActFuture>, MemberServiceErr> { - let participant = match self.get_participant_by_id(&participant_id) { - None => { - return Box::new(wrap_future(future::err( - MemberServiceErr::MemberNotFound(participant_id), - ))); - } - Some(participant) => participant, - }; - - // lookup previous participant connection - if participant.borrow().is_connected() { - debug!( - "Closing old RpcConnection for participant {}", - participant_id - ); - - - let member_clone = Rc::clone(&participant); - Box::new(wrap_future( - participant.borrow_mut().close_connection().unwrap().then(move |_| Ok(member_clone)), - )) - } else { - Box::new( - wrap_future(pipeline.create_turn( - participant_id.clone(), - self.room_id.clone(), - UnreachablePolicy::ReturnErr, - )) - .map_err(|err, _: &mut Room, _| MemberServiceErr::from(err)) - .and_then( - move |ice: IceUser, room: &mut Room, _| { - room.pipeline.insert_connection(&participant_id, con); - room.pipeline.replace_ice_user( - &participant_id, - Rc::new(RefCell::new(ice)), - ); - - wrap_future(future::ok(participant)) - }, - ), - ) - } - } - - /// Insert new [`RpcConnection`] into this [`MemberService`]. - pub fn insert_connection( - &mut self, - participant_id: &MemberId, - conn: Box, - ) { - if let Some(member) = self.participants.get_mut(&participant_id) { - member.borrow_mut().set_connection(conn); - } - } - - /// If [`ClosedReason::Closed`], then removes [`RpcConnection`] associated - /// with specified user [`Member`] from the storage and closes the - /// room. If [`ClosedReason::Lost`], then creates delayed task that - /// emits [`ClosedReason::Closed`]. - // TODO: Dont close the room. It is being closed atm, because we have - // no way to handle absence of RpcConnection. - pub fn connection_closed( - &mut self, - ctx: &mut Context, - member_id: &MemberId, - reason: &ClosedReason, - ) { - let member_id = member_id.clone(); // TODO: temp - let closed_at = Instant::now(); - match reason { - ClosedReason::Closed => { - let member = self.participants.get(&member_id).unwrap(); - member.borrow_mut().remove_connection(); - - // ctx.notify(CloseRoom {}) - } - ClosedReason::Lost => { - self.drop_connection_tasks.insert( - member_id.clone(), - ctx.run_later(self.reconnect_timeout, move |_, ctx| { - info!( - "Member {} connection lost at {:?}. Room will be \ - stopped.", - &member_id, closed_at - ); - ctx.notify(RpcConnectionClosed { - member_id: member_id.clone(), - reason: ClosedReason::Closed, - }) - }), - ); - } - } - } - - /// Cancels all connection close tasks, closes all [`RpcConnection`]s, - pub fn drop_connections( - &mut self, - ctx: &mut Context, - ) -> impl Future { - // canceling all drop_connection_tasks - self.drop_connection_tasks.drain().for_each(|(_, handle)| { - ctx.cancel_future(handle); - }); - - let mut close_fut = Vec::new(); - for (id, participant) in &self.participants { - close_fut.push( - participant.borrow_mut().take_connection().unwrap().close(), - ); - } - - join_all(close_fut).map(|_| ()) - } -} diff --git a/src/signalling/mod.rs b/src/signalling/mod.rs index 37ef7eec4..2b8f6a1ab 100644 --- a/src/signalling/mod.rs +++ b/src/signalling/mod.rs @@ -1,8 +1,6 @@ pub mod control; -pub mod endpoints_manager; -pub mod members_manager; +pub mod participants; pub mod peers; -pub mod pipeline; pub mod room; pub mod room_repo; diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs new file mode 100644 index 000000000..74721ca42 --- /dev/null +++ b/src/signalling/participants.rs @@ -0,0 +1,331 @@ +//! [`Participant`] is member with [`RpcConnection`]. [`ParticipantService`] +//! stores [`Participant`]s and associated [`RpcConnection`]s, handles +//! [`RpcConnection`] authorization, establishment, message sending, Turn +//! credentials management. + +use std::{ + rc::Rc, + time::{Duration, Instant}, +}; + +use actix::{ + fut::wrap_future, ActorFuture, AsyncContext, Context, MailboxError, + SpawnHandle, +}; +use failure::Fail; +use futures::{ + future::{self, join_all, Either}, + Future, +}; +use hashbrown::HashMap; +use medea_client_api_proto::Event; + +use crate::{ + api::{ + client::rpc_connection::{ + AuthorizationError, ClosedReason, EventMessage, RpcConnection, + RpcConnectionClosed, + }, + control::{MemberId as ParticipantId, RoomId, RoomSpec}, + }, + log::prelude::*, + media::IceUser, + signalling::{ + control::{parse_participants, Participant, ParticipantsLoadError}, + room::{ActFuture, RoomError}, + Room, + }, + turn::{TurnAuthService, TurnServiceErr, UnreachablePolicy}, +}; + +#[derive(Fail, Debug)] +#[allow(clippy::module_name_repetitions)] +pub enum ParticipantServiceErr { + #[fail(display = "TurnService Error in ParticipantService: {}", _0)] + TurnServiceErr(TurnServiceErr), + #[fail( + display = "Mailbox error when accessing ParticipantService: {}", + _0 + )] + MailBoxErr(MailboxError), + #[fail(display = "Participant with Id [{}] was not found", _0)] + ParticipantNotFound(ParticipantId), +} + +impl From for ParticipantServiceErr { + fn from(err: TurnServiceErr) -> Self { + ParticipantServiceErr::TurnServiceErr(err) + } +} + +impl From for ParticipantServiceErr { + fn from(err: MailboxError) -> Self { + ParticipantServiceErr::MailBoxErr(err) + } +} + +/// [`Participant`] is member of [`Room`] with [`RpcConnection`]. +/// [`ParticipantService`] stores [`Participant`]s and associated +/// [`RpcConnection`]s, handles [`RpcConnection`] authorization, establishment, +/// message sending. +#[derive(Debug)] +pub struct ParticipantService { + /// [`Room`]s id from which this [`ParticipantService`] was created. + room_id: RoomId, + + /// [`Participant`]s which currently are present in this [`Room`]. + participants: HashMap>, + + /// Service for managing authorization on Turn server. + turn: Box, + + /// Established [`RpcConnection`]s of [`Participants`]s in this [`Room`]. + // TODO: Replace Box> with enum, + // as the set of all possible RpcConnection types is not closed. + connections: HashMap>, + + /// Timeout for close [`RpcConnection`] after receiving + /// [`RpcConnectionClosed`] message. + reconnect_timeout: Duration, + + /// Stores [`RpcConnection`] drop tasks. + /// If [`RpcConnection`] is lost, [`Room`] waits for connection_timeout + /// before dropping it irrevocably in case it gets reestablished. + drop_connection_tasks: HashMap, +} + +impl ParticipantService { + /// Create new [`ParticipantService`] from [`RoomSpec`]. + pub fn new( + room_spec: &RoomSpec, + reconnect_timeout: Duration, + turn: Box, + ) -> Result { + Ok(Self { + room_id: room_spec.id().clone(), + participants: parse_participants(room_spec)?, + turn, + connections: HashMap::new(), + reconnect_timeout, + drop_connection_tasks: HashMap::new(), + }) + } + + /// Lookup [`Participant`] by provided id. + pub fn get_participant_by_id( + &self, + id: &ParticipantId, + ) -> Option> { + self.participants.get(id).cloned() + } + + /// Lookup [`Participant`] by provided id and credentials. Returns + /// [`Err(AuthorizationError::ParticipantNotExists)`] if lookup by + /// [`ParticipantId`] failed. Returns + /// [`Err(AuthorizationError::InvalidCredentials)`] if [`Participant`] + /// was found, but incorrect credentials was provided. + pub fn get_participant_by_id_and_credentials( + &self, + participant_id: &ParticipantId, + credentials: &str, + ) -> Result, AuthorizationError> { + match self.get_participant_by_id(participant_id) { + Some(participant) => { + if participant.credentials().eq(credentials) { + Ok(participant.clone()) + } else { + Err(AuthorizationError::InvalidCredentials) + } + } + None => Err(AuthorizationError::ParticipantNotExists), + } + } + + /// Checks if [`Participant`] has **active** [`RcpConnection`]. + pub fn participant_has_connection( + &self, + participant_id: &ParticipantId, + ) -> bool { + self.connections.contains_key(participant_id) + && !self.drop_connection_tasks.contains_key(participant_id) + } + + /// Send [`Event`] to specified remote [`Participant`]. + pub fn send_event_to_participant( + &mut self, + participant_id: ParticipantId, + event: Event, + ) -> impl Future { + match self.connections.get(&participant_id) { + Some(conn) => { + Either::A(conn.send_event(EventMessage::from(event)).map_err( + move |_| RoomError::UnableToSendEvent(participant_id), + )) + } + None => Either::B(future::err(RoomError::ConnectionNotExists( + participant_id, + ))), + } + } + + /// Saves provided [`RpcConnection`], registers [`ICEUser`]. + /// If [`Participant`] already has any other [`RpcConnection`], + /// then it will be closed. + pub fn connection_established( + &mut self, + ctx: &mut Context, + participant_id: ParticipantId, + con: Box, + ) -> ActFuture, ParticipantServiceErr> { + let participant = match self.get_participant_by_id(&participant_id) { + None => { + return Box::new(wrap_future(future::err( + ParticipantServiceErr::ParticipantNotFound(participant_id), + ))); + } + Some(participant) => participant, + }; + + // lookup previous participant connection + if let Some(mut connection) = self.connections.remove(&participant_id) { + debug!( + "Closing old RpcConnection for participant {}", + participant_id + ); + + // cancel RpcConnection close task, since connection is + // reestablished + if let Some(handler) = + self.drop_connection_tasks.remove(&participant_id) + { + ctx.cancel_future(handler); + } + Box::new(wrap_future( + connection.close().then(move |_| Ok(participant)), + )) + } else { + Box::new( + wrap_future(self.turn.create( + participant_id.clone(), + self.room_id.clone(), + UnreachablePolicy::ReturnErr, + )) + .map_err(|err, _: &mut Room, _| { + ParticipantServiceErr::from(err) + }) + .and_then( + move |ice: IceUser, room: &mut Room, _| { + room.participants + .insert_connection(participant_id.clone(), con); + participant.replace_ice_user(ice); + + wrap_future(future::ok(participant)) + }, + ), + ) + } + } + + /// Insert new [`RpcConnection`] into this [`ParticipantService`]. + fn insert_connection( + &mut self, + participant_id: ParticipantId, + conn: Box, + ) { + self.connections.insert(participant_id, conn); + } + + /// If [`ClosedReason::Closed`], then removes [`RpcConnection`] associated + /// with specified user [`Participant`] from the storage and closes the + /// room. If [`ClosedReason::Lost`], then creates delayed task that + /// emits [`ClosedReason::Closed`]. + // TODO: Dont close the room. It is being closed atm, because we have + // no way to handle absence of RpcConnection. + pub fn connection_closed( + &mut self, + ctx: &mut Context, + participant_id: ParticipantId, + reason: &ClosedReason, + ) { + let closed_at = Instant::now(); + match reason { + ClosedReason::Closed => { + self.connections.remove(&participant_id); + + ctx.spawn(wrap_future( + self.delete_ice_user(&participant_id).map_err(|err| { + error!("Error deleting IceUser {:?}", err) + }), + )); + // ctx.notify(CloseRoom {}) + } + ClosedReason::Lost => { + self.drop_connection_tasks.insert( + participant_id.clone(), + ctx.run_later(self.reconnect_timeout, move |_, ctx| { + info!( + "Member {} connection lost at {:?}. Room will be \ + stopped.", + &participant_id, closed_at + ); + ctx.notify(RpcConnectionClosed { + member_id: participant_id, + reason: ClosedReason::Closed, + }) + }), + ); + } + } + } + + /// Deletes [`IceUser`] associated with provided [`Member`]. + fn delete_ice_user( + &mut self, + participant_id: &ParticipantId, + ) -> Box> { + match self.get_participant_by_id(&participant_id) { + Some(participant) => match participant.take_ice_user() { + Some(ice_user) => self.turn.delete(vec![ice_user]), + None => Box::new(future::ok(())), + }, + None => Box::new(future::ok(())), + } + } + + /// Cancels all connection close tasks, closes all [`RpcConnection`]s, + pub fn drop_connections( + &mut self, + ctx: &mut Context, + ) -> impl Future { + // canceling all drop_connection_tasks + self.drop_connection_tasks.drain().for_each(|(_, handle)| { + ctx.cancel_future(handle); + }); + + // closing all RpcConnection's + let mut close_fut = self.connections.drain().fold( + vec![], + |mut futures, (_, mut connection)| { + futures.push(connection.close()); + futures + }, + ); + + // deleting all IceUsers + let remove_ice_users = Box::new({ + let mut room_users = Vec::with_capacity(self.participants.len()); + + self.participants.iter().for_each(|(_, data)| { + if let Some(ice_user) = data.take_ice_user() { + room_users.push(ice_user); + } + }); + self.turn + .delete(room_users) + .map_err(|err| error!("Error removing IceUsers {:?}", err)) + }); + close_fut.push(remove_ice_users); + + join_all(close_fut).map(|_| ()) + } +} diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index 8ac39e0a5..9d2de975c 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -13,14 +13,14 @@ use crate::{ log::prelude::*, media::{Peer, PeerId, PeerStateMachine}, signalling::{ - endpoints_manager::EndpointsManager, + control::participant::Participant, room::{PeersRemoved, Room, RoomError}, }, }; #[derive(Debug)] pub struct PeerRepository { - /// [`Peer`]s of [`Member`]s in this [`Room`]. + /// [`Peer`]s of [`Participant`]s in this [`Room`]. peers: HashMap, /// Count of [`Peer`]s in this [`Room`]. @@ -69,46 +69,44 @@ impl PeerRepository { .ok_or_else(|| RoomError::PeerNotFound(peer_id)) } - /// Create and interconnect [`Peer`]s based on [`Member`]. + /// Create and interconnect [`Peer`]s based on [`Participant`]. /// /// Returns IDs of created [`Peer`]s. `(first_peer_id, second_peer_id)`. pub fn create_peers( &mut self, - first_member_id: &MemberId, - second_member_id: &MemberId, - endpoints_manager: &mut EndpointsManager, + first_member: &Participant, + second_member: &Participant, ) -> (u64, u64) { debug!( "Created peer between {} and {}.", - first_member_id, second_member_id + first_member.id(), + second_member.id() ); let first_peer_id = self.peers_count.next_id(); let second_peer_id = self.peers_count.next_id(); let mut first_peer = Peer::new( first_peer_id, - first_member_id.clone(), + first_member.id().clone(), second_peer_id, - second_member_id.clone(), + second_member.id().clone(), ); let mut second_peer = Peer::new( second_peer_id, - second_member_id.clone(), + second_member.id().clone(), first_peer_id, - first_member_id.clone(), + first_member.id().clone(), ); first_peer.add_publish_endpoints( &mut second_peer, &mut self.tracks_count, - first_member_id, - endpoints_manager, + first_member.publishers(), ); second_peer.add_publish_endpoints( &mut first_peer, &mut self.tracks_count, - second_member_id, - endpoints_manager, + second_member.publishers(), ); self.add_peer(first_peer); @@ -132,7 +130,7 @@ impl PeerRepository { } } - /// Returns all [`Peer`]s of specified [`Member`]. + /// Returns all [`Peer`]s of specified [`Participant`]. pub fn get_peers_by_member_id( &self, member_id: &MemberId, @@ -164,10 +162,10 @@ impl PeerRepository { } } - /// Close all related to disconnected [`Member`] [`Peer`]s and partner + /// Close all related to disconnected [`Participant`] [`Peer`]s and partner /// [`Peer`]s. /// - /// Send [`Event::PeersRemoved`] to all affected [`Member`]s. + /// Send [`Event::PeersRemoved`] to all affected [`Participant`]s. pub fn connection_closed( &mut self, member_id: &MemberId, diff --git a/src/signalling/pipeline.rs b/src/signalling/pipeline.rs deleted file mode 100644 index 03753e1a8..000000000 --- a/src/signalling/pipeline.rs +++ /dev/null @@ -1,219 +0,0 @@ -use super::{ - endpoints_manager::EndpointsManager, members_manager::MembersManager, - peers::PeerRepository, -}; -use crate::{ - api::{ - client::rpc_connection::{ - AuthorizationError, ClosedReason, RpcConnection, - }, - control::{MemberId, RoomId, RoomSpec}, - }, - log::prelude::*, - media::{IceUser, PeerId}, - signalling::{ - control::{ - member::Member, - play_endpoint::{Id as PlayEndpointId, WebRtcPlayEndpoint}, - publish_endpoint::{ - Id as PublishEndpointId, WebRtcPublishEndpoint, - }, - }, - members_manager::MemberServiceErr, - room::{ActFuture, Room, RoomError}, - }, - turn::{service::TurnAuthService, TurnServiceErr, UnreachablePolicy}, -}; -use actix::{fut::wrap_future, AsyncContext, Context}; -use futures::{ - future::{self, join_all, Either}, - Future, -}; -use hashbrown::HashMap; -use medea_client_api_proto::{Event, IceServer}; -use std::{cell::RefCell, rc::Rc, time::Duration}; - -#[derive(Debug)] -pub struct Pipeline { - turn: Box, - members: MembersManager, - endpoints: EndpointsManager, - peers: PeerRepository, -} - -impl Pipeline { - pub fn new( - turn: Box, - reconnect_timeout: Duration, - spec: &RoomSpec, - ) -> Self { - Self { - turn, - members: MembersManager::new(spec, reconnect_timeout).unwrap(), - endpoints: EndpointsManager::new(spec), - peers: PeerRepository::from(HashMap::new()), - } - } - - pub fn is_member_has_connection(&self, id: &MemberId) -> bool { - self.members - .get_participant_by_id(id) - .unwrap() - .borrow() - .is_connected() - } - - pub fn send_event_to_participant( - &mut self, - member_id: MemberId, - event: Event, - ) -> impl Future { - self.members.send_event_to_participant(member_id, event) - } - - pub fn get_member_by_id( - &self, - id: &MemberId, - ) -> Option>> { - self.members.get_participant_by_id(id) - } - - pub fn get_member_by_id_and_credentials( - &self, - id: &MemberId, - credentials: &str, - ) -> Result>, AuthorizationError> { - self.members - .get_participant_by_id_and_credentials(id, credentials) - } - - pub fn connection_closed( - &mut self, - ctx: &mut Context, - member_id: MemberId, - close_reason: ClosedReason, - ) { - ctx.spawn(wrap_future( - self.delete_ice_user(&member_id) - .map_err(|err| error!("Error deleting IceUser {:?}", err)), - )); - self.members - .connection_closed(ctx, &member_id, &close_reason); - } - - pub fn delete_ice_user( - &mut self, - member_id: &MemberId, - ) -> Box> { - let ice_user = self.endpoints.take_ice_user_by_member_id(member_id); - match self.get_member_by_id(member_id) { - Some(participant) => match ice_user { - Some(ice_user) => self.turn.delete(vec![ice_user]), - None => Box::new(future::ok(())), - }, - None => Box::new(future::ok(())), - } - } - - pub fn get_publishers_by_member_id( - &self, - id: &MemberId, - ) -> HashMap>> { - self.endpoints.get_publishers_by_member_id(id) - } - - pub fn endpoints_manager(&mut self) -> &mut EndpointsManager { - &mut self.endpoints - } - - pub fn get_receivers_by_member_id( - &self, - id: &MemberId, - ) -> HashMap>> { - self.endpoints.get_receivers_by_member_id(id) - } - - pub fn create_turn( - &self, - member_id: MemberId, - room_id: RoomId, - policy: UnreachablePolicy, - ) -> Box> { - self.turn.create(member_id, room_id, policy) - } - - pub fn replace_ice_user( - &mut self, - member_id: &MemberId, - ice_user: Rc>, - ) -> Option>> { - self.endpoints.replace_ice_user(member_id.clone(), ice_user) - } - - pub fn connection_established( - &mut self, - ctx: &mut Context, - id: MemberId, - connection: Box, - ) -> ActFuture>, MemberServiceErr> { - // TODO: Maybe this is bad. - self.members.cancel_close_connection(ctx, &id); - self.members - .connection_established(ctx, &self, id, connection) - } - - pub fn get_ice_servers(&self, id: &MemberId) -> Option> { - self.endpoints.get_servers_list_by_member_id(id) - } - - pub fn peers_removed(&mut self, peers_id: &[PeerId]) { - self.endpoints.peers_removed(peers_id) - } - - pub fn get_receiver_by_id( - &self, - id: &PlayEndpointId, - ) -> Option>> { - self.endpoints.get_receiver_by_id(id) - } - - pub fn get_publisher_by_id( - &self, - id: &PublishEndpointId, - ) -> Option>> { - self.endpoints.get_publisher_by_id(id) - } - - fn test( - &mut self, - ice_users: Vec>>, - ) -> impl Future { - self.turn.delete(ice_users).map_err(|_| ()) - } - - pub fn drop_connections( - &mut self, - ctx: &mut Context, - ) -> impl Future { - let mut fut = Vec::new(); - - fut.push(Either::A(self.members.drop_connections(ctx))); - let ice_users = self.endpoints.take_ice_users(); - let ice_users: Vec>> = ice_users - .into_iter() - .map(|(_, ice_user)| ice_user) - .collect(); - - fut.push(Either::B(self.test(ice_users))); - - join_all(fut).map(|_| ()) - } - - pub fn insert_connection( - &mut self, - member_id: &MemberId, - connection: Box, - ) { - self.members.insert_connection(member_id, connection); - } -} diff --git a/src/signalling/room.rs b/src/signalling/room.rs index f9911f45e..beb8d6eed 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -1,5 +1,5 @@ //! Room definitions and implementations. Room is responsible for media -//! connection establishment between concrete [`Member`]s. +//! connection establishment between concrete [`Participant`]s. use std::time::Duration; @@ -18,7 +18,7 @@ use crate::{ AuthorizationError, Authorize, ClosedReason, CommandMessage, RpcConnectionClosed, RpcConnectionEstablished, }, - control::{RoomId, RoomSpec, TryFromElementError}, + control::{MemberId, RoomId, RoomSpec, TryFromElementError}, }, log::prelude::*, media::{ @@ -26,7 +26,9 @@ use crate::{ WaitLocalHaveRemote, WaitLocalSdp, WaitRemoteSdp, }, signalling::{ - control::member::MemberId, peers::PeerRepository, pipeline::Pipeline, + control::participant::{Participant, ParticipantsLoadError}, + participants::ParticipantService, + peers::PeerRepository, }, turn::TurnAuthService, }; @@ -139,24 +141,25 @@ impl From for RoomError { } } -// impl From for RoomError { -// fn from(err: MembersLoadError) -> Self { -// RoomError::BadRoomSpec(format!( -// "Error while loading room spec. {}", -// err -// )) -// } -//} +impl From for RoomError { + fn from(err: ParticipantsLoadError) -> Self { + RoomError::BadRoomSpec(format!( + "Error while loading room spec. {}", + err + )) + } +} -/// Media server room with its [`Member`]s. +/// Media server room with its [`Participant`]s. #[derive(Debug)] pub struct Room { id: RoomId, - /// [`Peer`]s of [`Member`]s in this [`Room`]. - peers: PeerRepository, + /// [`RpcConnection`]s of [`Participant`]s in this [`Room`]. + pub participants: ParticipantService, - pub pipeline: Pipeline, + /// [`Peer`]s of [`Participant`]s in this [`Room`]. + peers: PeerRepository, } impl Room { @@ -172,7 +175,11 @@ impl Room { Ok(Self { id: room_spec.id().clone(), peers: PeerRepository::from(HashMap::new()), - pipeline: Pipeline::new(turn, reconnect_timeout, room_spec), + participants: ParticipantService::new( + room_spec, + reconnect_timeout, + turn, + )?, }) } @@ -212,12 +219,12 @@ impl Room { let sender = sender.start(); let member_id = sender.member_id(); - self.pipeline.get_ice_servers(&member_id); let ice_servers = self - .pipeline - .get_ice_servers(&member_id) + .participants + .get_participant_by_id(&member_id) + .ok_or_else(|| RoomError::MemberNotFound(member_id.clone()))? + .servers_list() .ok_or_else(|| RoomError::NoTurnCredentials(member_id.clone()))?; - let peer_created = Event::PeerCreated { peer_id: sender.id(), sdp_offer: None, @@ -226,18 +233,18 @@ impl Room { }; self.peers.add_peer(sender); Ok(Box::new(wrap_future( - self.pipeline + self.participants .send_event_to_participant(member_id, peer_created), ))) } - /// Sends [`Event::PeersRemoved`] to [`Member`]. + /// Sends [`Event::PeersRemoved`] to [`Participant`]. fn send_peers_removed( &mut self, member_id: MemberId, peers: Vec, ) -> ActFuture<(), RoomError> { - Box::new(wrap_future(self.pipeline.send_event_to_participant( + Box::new(wrap_future(self.participants.send_event_to_participant( member_id, Event::PeersRemoved { peer_ids: peers }, ))) @@ -261,11 +268,11 @@ impl Room { let to_peer = to_peer.set_remote_sdp(sdp_offer.clone()); let to_member_id = to_peer.member_id(); - - // TODO: better error let ice_servers = self - .pipeline - .get_ice_servers(&to_member_id) + .participants + .get_participant_by_id(&to_member_id) + .ok_or_else(|| RoomError::MemberNotFound(to_member_id.clone()))? + .servers_list() .ok_or_else(|| { RoomError::NoTurnCredentials(to_member_id.clone()) })?; @@ -281,7 +288,8 @@ impl Room { self.peers.add_peer(to_peer); Ok(Box::new(wrap_future( - self.pipeline.send_event_to_participant(to_member_id, event), + self.participants + .send_event_to_participant(to_member_id, event), ))) } @@ -313,7 +321,8 @@ impl Room { self.peers.add_peer(to_peer); Ok(Box::new(wrap_future( - self.pipeline.send_event_to_participant(to_member_id, event), + self.participants + .send_event_to_participant(to_member_id, event), ))) } @@ -350,96 +359,107 @@ impl Room { }; Ok(Box::new(wrap_future( - self.pipeline.send_event_to_participant(to_member_id, event), + self.participants + .send_event_to_participant(to_member_id, event), ))) } - /// Create [`Peer`]s between [`Member`]s and interconnect it by control + /// Create [`Peer`]s between [`Participant`]s and interconnect it by control /// API spec. fn connect_participants( &mut self, - first_member: &MemberId, - second_member: &MemberId, + first_member: &Participant, + second_member: &Participant, ctx: &mut ::Context, ) { debug!( "Created peer member {} with member {}", - first_member, second_member + first_member.id(), + second_member.id() ); - let (first_peer_id, second_peer_id) = self.peers.create_peers( - first_member, - second_member, - self.pipeline.endpoints_manager(), - ); + let (first_peer_id, second_peer_id) = + self.peers.create_peers(first_member, second_member); self.connect_peers(ctx, first_peer_id, second_peer_id); } - /// Create and interconnect all [`Peer`]s between connected [`Member`] - /// and all available at this moment [`Member`]. + /// Create and interconnect all [`Peer`]s between connected [`Participant`] + /// and all available at this moment [`Participant`]. /// /// Availability is determines by checking [`RpcConnection`] of all - /// [`Member`]s from [`WebRtcPlayEndpoint`]s and from receivers of - /// connected [`Member`]. + /// [`Participant`]s from [`WebRtcPlayEndpoint`]s and from receivers of + /// connected [`Participant`]. fn init_participant_connections( &mut self, - member_id: &MemberId, + participant: &Participant, ctx: &mut ::Context, ) { - let participant_publishers = - self.pipeline.get_publishers_by_member_id(member_id); // Create all connected publish endpoints. - for (_, publish) in participant_publishers { - for receiver in publish.borrow().sinks() { - let q = self.pipeline.get_receiver_by_id(&receiver); + for (_, publish) in participant.publishers() { + for receiver in publish.receivers() { let receiver = unit_option_unwrap!( - q, + receiver.upgrade(), ctx, "Empty weak pointer for publisher receiver. {:?}.", publish, ); + let receiver_owner = unit_option_unwrap!( + receiver.owner().upgrade(), + ctx, + "Empty weak pointer for publisher's receiver's owner. \ + {:?}.", + receiver, + ); + if self - .pipeline - .is_member_has_connection(&receiver.borrow().owner()) - && !receiver.borrow().is_connected() + .participants + .participant_has_connection(&receiver_owner.id()) + && !receiver.is_connected() { self.connect_participants( - member_id, - &receiver.borrow().owner(), + &participant, + &receiver_owner, ctx, ); } } } - let member_receivers = - self.pipeline.get_receivers_by_member_id(member_id); // Create all connected play's receivers peers. - for (_, play) in member_receivers { - let plays_publisher_id = { - let q = self.pipeline.get_publisher_by_id(play.borrow().src()); + for (_, play) in participant.receivers() { + let plays_publisher_participant = { let play_publisher = unit_option_unwrap!( - q, + play.publisher().upgrade(), ctx, "Empty weak pointer for play's publisher. {:?}.", play, ); - let q = play_publisher.borrow().owner(); - q + unit_option_unwrap!( + play_publisher.owner().upgrade(), + ctx, + "Empty weak pointer for play's publisher owner. {:?}.", + play_publisher, + ) }; - if self.pipeline.is_member_has_connection(&plays_publisher_id) - && !play.borrow().is_connected() + if self + .participants + .participant_has_connection(&plays_publisher_participant.id()) + && !play.is_connected() { - self.connect_participants(member_id, &plays_publisher_id, ctx); + self.connect_participants( + &participant, + &plays_publisher_participant, + ctx, + ); } } } /// Check state of interconnected [`Peer`]s and sends [`Event`] about - /// [`Peer`] created to remote [`Member`]. + /// [`Peer`] created to remote [`Participant`]. fn connect_peers( &mut self, ctx: &mut Context, @@ -488,13 +508,16 @@ impl Handler for Room { msg: Authorize, _ctx: &mut Self::Context, ) -> Self::Result { - self.pipeline - .get_member_by_id_and_credentials(&msg.member_id, &msg.credentials) + self.participants + .get_participant_by_id_and_credentials( + &msg.member_id, + &msg.credentials, + ) .map(|_| ()) } } -/// Signal of removing [`Member`]'s [`Peer`]s. +/// Signal of removing [`Participant`]'s [`Peer`]s. #[derive(Debug, Message)] #[rtype(result = "Result<(), ()>")] pub struct PeersRemoved { @@ -505,9 +528,9 @@ pub struct PeersRemoved { impl Handler for Room { type Result = ActFuture<(), ()>; - /// Send [`Event::PeersRemoved`] to remote [`Member`]. + /// Send [`Event::PeersRemoved`] to remote [`Participant`]. /// - /// Delete all removed [`PeerId`]s from all [`Member`]'s + /// Delete all removed [`PeerId`]s from all [`Participant`]'s /// endpoints. #[allow(clippy::single_match_else)] fn handle( @@ -519,7 +542,19 @@ impl Handler for Room { "Peers {:?} removed for member '{}'.", msg.peers_id, msg.member_id ); - self.pipeline.peers_removed(&msg.peers_id); + if let Some(participant) = + self.participants.get_participant_by_id(&msg.member_id) + { + participant.peers_removed(&msg.peers_id); + } else { + error!( + "Participant with id {} for which received \ + Event::PeersRemoved not found. Closing room.", + msg.member_id + ); + ctx.notify(CloseRoom {}); + return Box::new(wrap_future(future::err(()))); + } Box::new( self.send_peers_removed(msg.member_id, msg.peers_id) @@ -587,9 +622,9 @@ impl Handler for Room { impl Handler for Room { type Result = ActFuture<(), ()>; - /// Saves new [`RpcConnection`] in [`MemberService`], initiates media + /// Saves new [`RpcConnection`] in [`ParticipantService`], initiates media /// establishment between members. - /// Create and interconnect all available [`Member`]'s [`Peer`]s. + /// Create and interconnect all available [`Participant`]'s [`Peer`]s. fn handle( &mut self, msg: RpcConnectionEstablished, @@ -600,16 +635,13 @@ impl Handler for Room { let member_id = msg.member_id; let fut = self - .pipeline + .participants .connection_established(ctx, member_id.clone(), msg.connection) .map_err(|err, _, _| { error!("RpcConnectionEstablished error {:?}", err) }) .map(move |participant, room, ctx| { - room.init_participant_connections( - &participant.borrow().id(), - ctx, - ); + room.init_participant_connections(&participant, ctx); }); Box::new(fut) } @@ -624,7 +656,7 @@ pub struct CloseRoom {} impl Handler for Room { type Result = (); - /// Sends to remote [`Member`] the [`Event`] about [`Peer`] removed. + /// Sends to remote [`Participant`] the [`Event`] about [`Peer`] removed. /// Closes all active [`RpcConnection`]s. fn handle( &mut self, @@ -632,7 +664,7 @@ impl Handler for Room { ctx: &mut Self::Context, ) -> Self::Result { info!("Closing Room [id = {:?}]", self.id); - let drop_fut = self.pipeline.drop_connections(ctx); + let drop_fut = self.participants.drop_connections(ctx); ctx.wait(wrap_future(drop_fut)); } } @@ -640,8 +672,8 @@ impl Handler for Room { impl Handler for Room { type Result = (); - /// Passes message to [`MemberService`] to cleanup stored connections. - /// Remove all related for disconnected [`Member`] [`Peer`]s. + /// Passes message to [`ParticipantService`] to cleanup stored connections. + /// Remove all related for disconnected [`Participant`] [`Peer`]s. fn handle(&mut self, msg: RpcConnectionClosed, ctx: &mut Self::Context) { info!( "RpcConnectionClosed for member {}, reason {:?}", @@ -652,7 +684,7 @@ impl Handler for Room { self.peers.connection_closed(&msg.member_id, ctx); } - self.pipeline - .connection_closed(ctx, msg.member_id, msg.reason); + self.participants + .connection_closed(ctx, msg.member_id, &msg.reason); } } diff --git a/src/turn/repo.rs b/src/turn/repo.rs index 42e045c96..1b7044fe8 100644 --- a/src/turn/repo.rs +++ b/src/turn/repo.rs @@ -83,18 +83,17 @@ impl TurnDatabase { }) } - // TODO: explain username - /// Deletes batch of provided [`IceUser`]s. pub fn remove( &mut self, - users: &[String], + users: &[IceUser], ) -> impl Future> { debug!("Remove ICE users: {:?}", users); let mut delete_keys = Vec::with_capacity(users.len()); for user in users { - delete_keys.push(format!("turn/realm/medea/user/{}/key", user)); + delete_keys + .push(format!("turn/realm/medea/user/{}/key", user.user())); } self.pool.run(|connection| { diff --git a/src/turn/service.rs b/src/turn/service.rs index 829f91a0f..300e07f63 100644 --- a/src/turn/service.rs +++ b/src/turn/service.rs @@ -17,7 +17,6 @@ use crate::{ media::IceUser, turn::repo::{TurnDatabase, TurnDatabaseErr}, }; -use std::{cell::RefCell, rc::Rc}; static TURN_PASS_LEN: usize = 16; @@ -35,7 +34,7 @@ pub trait TurnAuthService: fmt::Debug + Send { /// Deletes batch of [`IceUser`]s. fn delete( &self, - users: Vec>>, + users: Vec, ) -> Box>; } @@ -68,14 +67,11 @@ impl TurnAuthService for Addr { /// Sends [`DeleteRoom`] to [`Service`]. fn delete( &self, - users: Vec>>, + users: Vec, ) -> Box> { // leave only non static users - let users: Vec = users - .into_iter() - .filter(|u| !u.borrow().is_static()) - .map(|u| u.borrow().user().to_string()) - .collect(); + let users: Vec = + users.into_iter().filter(|u| !u.is_static()).collect(); if users.is_empty() { Box::new(futures::future::ok(())) @@ -260,7 +256,7 @@ impl Handler for Service { /// Deletes all users from given room in redis. #[derive(Debug, Message)] #[rtype(result = "Result<(), TurnServiceErr>")] -struct DeleteIceUsers(Vec); +struct DeleteIceUsers(Vec); impl Handler for Service { type Result = ActFuture<(), TurnServiceErr>; @@ -307,7 +303,7 @@ pub mod test { fn delete( &self, - _: Vec>>, + _: Vec, ) -> Box> { Box::new(future::ok(())) } From 6a97191c6d0605660f45efaad3f07b3e0d0689d6 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 28 Jun 2019 20:07:27 +0300 Subject: [PATCH 216/735] Unwrap Weaks in Endpoints --- src/media/peer.rs | 33 +-------- src/signalling/control/endpoint.rs | 48 ++++++++---- src/signalling/control/participant.rs | 4 +- src/signalling/room.rs | 102 +------------------------- 4 files changed, 41 insertions(+), 146 deletions(-) diff --git a/src/media/peer.rs b/src/media/peer.rs index d853b7890..a756cfe95 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -15,7 +15,6 @@ use medea_macro::enum_delegate; use crate::{ api::control::MemberId, - log::prelude::*, media::{MediaTrack, TrackId}, signalling::{ control::endpoint::{Id as EndpointId, WebRtcPublishEndpoint}, @@ -270,35 +269,11 @@ impl Peer { .into_iter() .flat_map(|(_m, e)| { e.add_peer_id(self_id); - e.receivers() - .into_iter() - .filter_map(|e| { - let upgraded_play = e.upgrade(); - if upgraded_play.is_none() { - warn!( - "Empty weak pointer of publisher's play \ - endpoint. {:?}.", - e - ); - } - upgraded_play - }) - .filter_map(|p| { - let owner = p.owner().upgrade(); - if owner.is_none() { - warn!( - "Empty weak pointer for publisher's play's \ - owner participant. {:?}.", - p - ); - } - owner.map(|owner| (p, owner)) - }) - .filter(|(e, owner)| { - owner.id() == partner_id && !e.is_connected() - }) + e.receivers().into_iter().filter(|e| { + e.owner().id() == partner_id && !e.is_connected() + }) }) - .for_each(|(e, _)| { + .for_each(|e| { let track_audio = Rc::new(MediaTrack::new( tracks_count.next_id(), MediaType::Audio(AudioSettings {}), diff --git a/src/signalling/control/endpoint.rs b/src/signalling/control/endpoint.rs index 33ca78451..c2ee9eeb7 100644 --- a/src/signalling/control/endpoint.rs +++ b/src/signalling/control/endpoint.rs @@ -1,6 +1,10 @@ //! Signalling representation of endpoints. -use std::{cell::RefCell, fmt::Display, rc::Weak}; +use std::{ + cell::RefCell, + fmt::Display, + rc::{Rc, Weak}, +}; use hashbrown::HashSet; @@ -52,12 +56,16 @@ impl WebRtcPlayEndpointInner { self.src.clone() } - fn owner(&self) -> Weak { + fn owner(&self) -> Rc { + Weak::upgrade(&self.owner).unwrap() + } + + fn weak_owner(&self) -> Weak { Weak::clone(&self.owner) } - fn publisher(&self) -> Weak { - self.publisher.clone() + fn publisher(&self) -> Rc { + Weak::upgrade(&self.publisher).unwrap() } fn is_connected(&self) -> bool { @@ -79,7 +87,7 @@ impl WebRtcPlayEndpointInner { impl Drop for WebRtcPlayEndpointInner { fn drop(&mut self) { - if let Some(receiver_publisher) = self.publisher().upgrade() { + if let Some(receiver_publisher) = self.publisher.upgrade() { receiver_publisher.remove_empty_weaks_from_receivers(); } } @@ -113,12 +121,17 @@ impl WebRtcPlayEndpoint { } /// Returns owner [`Participant`] of this [`WebRtcPlayEndpoint`]. - pub fn owner(&self) -> Weak { + pub fn owner(&self) -> Rc { self.0.borrow().owner() } + // TODO: explain this + pub fn weak_owner(&self) -> Weak { + self.0.borrow().weak_owner() + } + /// Returns publisher's [`WebRtcPublishEndpoint`]. - pub fn publisher(&self) -> Weak { + pub fn publisher(&self) -> Rc { self.0.borrow().publisher() } @@ -174,9 +187,9 @@ struct WebRtcPublishEndpointInner { impl Drop for WebRtcPublishEndpointInner { fn drop(&mut self) { - for receiver in self.receivers().iter().filter_map(|r| Weak::upgrade(r)) - { - if let Some(receiver_owner) = receiver.owner().upgrade() { + // TODO: add comments + for receiver in self.receivers.iter().filter_map(|r| Weak::upgrade(r)) { + if let Some(receiver_owner) = receiver.weak_owner().upgrade() { receiver_owner.remove_receiver(&receiver.id()) } } @@ -188,12 +201,15 @@ impl WebRtcPublishEndpointInner { self.receivers.push(receiver); } - fn receivers(&self) -> Vec> { - self.receivers.clone() + fn receivers(&self) -> Vec> { + self.receivers + .iter() + .map(|p| Weak::upgrade(p).unwrap()) + .collect() } - fn owner(&self) -> Weak { - Weak::clone(&self.owner) + fn owner(&self) -> Rc { + Weak::upgrade(&self.owner).unwrap() } fn add_peer_id(&mut self, peer_id: PeerId) { @@ -248,12 +264,12 @@ impl WebRtcPublishEndpoint { } /// Returns all receivers of this [`WebRtcPublishEndpoint`]. - pub fn receivers(&self) -> Vec> { + pub fn receivers(&self) -> Vec> { self.0.borrow().receivers() } /// Returns owner [`Participant`] of this [`WebRtcPublishEndpoint`]. - pub fn owner(&self) -> Weak { + pub fn owner(&self) -> Rc { self.0.borrow().owner() } diff --git a/src/signalling/control/participant.rs b/src/signalling/control/participant.rs index 5cbbc7533..1f9cf74fa 100644 --- a/src/signalling/control/participant.rs +++ b/src/signalling/control/participant.rs @@ -392,14 +392,13 @@ mod participant_loading_tests { let is_caller_has_responder_in_receivers = caller_publish_endpoint .receivers() .into_iter() - .map(|p| p.upgrade().unwrap()) .filter(|p| Rc::ptr_eq(p, &responder_play_endpoint)) .count() == 1; assert!(is_caller_has_responder_in_receivers); assert!(Rc::ptr_eq( - &responder_play_endpoint.publisher().upgrade().unwrap(), + &responder_play_endpoint.publisher(), &caller_publish_endpoint )); @@ -420,7 +419,6 @@ mod participant_loading_tests { some_participant_publisher .receivers() .into_iter() - .map(|p| p.upgrade().unwrap()) .filter(|p| Rc::ptr_eq(p, &responder_play2_endpoint)) .count() == 1; diff --git a/src/signalling/room.rs b/src/signalling/room.rs index beb8d6eed..bd205706a 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -37,74 +37,6 @@ use crate::{ pub type ActFuture = Box>; -/// Macro for unwrapping Option. -/// -/// If [`Option::None`] then `error!` with provided message will be -/// called, [`CloseRoom`] emitted to [`Room`] context and function -/// will be returned with provided return expression. -/// -/// You can use `format!` syntax in this macro to provide some debug info. -/// -/// ## Usage -/// ```ignore -/// option_unwrap!( -/// foo.some_weak_pointer().upgrade(), // Some Option type -/// ctx, // Context of Room -/// (), // This will be returned from function in None case -/// "Empty Weak pointer for bar with ID {}", // Error message -/// foo.id(), // format! syntax -/// ); -/// ``` -macro_rules! option_unwrap { - ($e:expr, $ctx:expr, $ret:expr, $msg:expr, $( $x:expr ),* $(,)?) => { - if let Some(e) = $e { - e - } else { - error!( - "[ROOM]: {} Room will be closed.", - format!($msg, $( $x, )*) - ); - $ctx.notify(CloseRoom {}); - return $ret; - } - }; - - ($e:expr, $ctx:expr, $ret:expr, $msg:expr $(,)?) => { - if let Some(e) = $e { - e - } else { - error!("[ROOM]: {} Room will be closed.", $msg); - $ctx.notify(CloseRoom {}); - return $ret; - } - }; -} - -/// Macro for unwrapping Option that work similar as [`option_unwrap!`], but -/// always return `()` when None case happened. This will close Room when -/// `Option::None`. -/// -/// Read more info in [`option_unwrap!`] docs. -/// -/// ## Usage -/// ```ignore -/// unit_option_unwrap!( -/// foo.some_weak_pointer().upgrade(), // Some Option type -/// ctx, // Context of Room -/// "Empty Weak pointer for bar with ID {}", // Error message -/// foo.id(), // format! syntax -/// ); -/// ``` -macro_rules! unit_option_unwrap { - ($e:expr, $ctx:expr, $msg:tt, $( $x:expr ),* $(,)?) => { - option_unwrap!($e, $ctx, (), $msg, $( $x, )*); - }; - - ($e:expr, $ctx:expr, $msg:expr $(,)?) => { - option_unwrap!($e, $ctx, (), $msg); - }; -} - #[allow(clippy::module_name_repetitions)] #[derive(Debug, Fail)] pub enum RoomError { @@ -398,20 +330,7 @@ impl Room { // Create all connected publish endpoints. for (_, publish) in participant.publishers() { for receiver in publish.receivers() { - let receiver = unit_option_unwrap!( - receiver.upgrade(), - ctx, - "Empty weak pointer for publisher receiver. {:?}.", - publish, - ); - - let receiver_owner = unit_option_unwrap!( - receiver.owner().upgrade(), - ctx, - "Empty weak pointer for publisher's receiver's owner. \ - {:?}.", - receiver, - ); + let receiver_owner = receiver.owner(); if self .participants @@ -429,29 +348,16 @@ impl Room { // Create all connected play's receivers peers. for (_, play) in participant.receivers() { - let plays_publisher_participant = { - let play_publisher = unit_option_unwrap!( - play.publisher().upgrade(), - ctx, - "Empty weak pointer for play's publisher. {:?}.", - play, - ); - unit_option_unwrap!( - play_publisher.owner().upgrade(), - ctx, - "Empty weak pointer for play's publisher owner. {:?}.", - play_publisher, - ) - }; + let plays_publisher_owner = play.publisher().owner(); if self .participants - .participant_has_connection(&plays_publisher_participant.id()) + .participant_has_connection(&plays_publisher_owner.id()) && !play.is_connected() { self.connect_participants( &participant, - &plays_publisher_participant, + &plays_publisher_owner, ctx, ); } From bdd3a8c06ab4dc1e558746e13c6ae690bbb28935 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 1 Jul 2019 13:01:28 +0300 Subject: [PATCH 217/735] Add unit tests for removing endpoints --- src/api/control/member.rs | 6 ++ src/signalling/control/endpoint.rs | 6 ++ src/signalling/control/participant.rs | 87 ++++++++++++++++++++------- 3 files changed, 76 insertions(+), 23 deletions(-) diff --git a/src/api/control/member.rs b/src/api/control/member.rs index e0b743998..961e31598 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -21,6 +21,12 @@ impl Display for Id { } } +impl From for Id { + fn from(s: String) -> Self { + Self(s) + } +} + /// Newtype for [`Element::Member`] variant. #[allow(clippy::module_name_repetitions)] #[derive(Clone, Debug)] diff --git a/src/signalling/control/endpoint.rs b/src/signalling/control/endpoint.rs index c2ee9eeb7..29f94057d 100644 --- a/src/signalling/control/endpoint.rs +++ b/src/signalling/control/endpoint.rs @@ -25,6 +25,12 @@ impl Display for Id { } } +impl From for Id { + fn from(s: String) -> Self { + Self(s) + } +} + #[derive(Debug, Clone)] struct WebRtcPlayEndpointInner { /// ID of this [`WebRtcPlayEndpoint`]. diff --git a/src/signalling/control/participant.rs b/src/signalling/control/participant.rs index 1f9cf74fa..33f595ff4 100644 --- a/src/signalling/control/participant.rs +++ b/src/signalling/control/participant.rs @@ -328,16 +328,14 @@ pub fn parse_participants( } #[cfg(test)] -mod participant_loading_tests { +mod tests { use std::rc::Rc; - use crate::api::control::Element; + use crate::api::control::{Element, MemberId}; use super::*; - #[test] - pub fn load_store() { - let spec = r#" + const TEST_SPEC: &str = r#" kind: Room id: test-call spec: @@ -374,20 +372,29 @@ mod participant_loading_tests { spec: src: "local://test-call/some-member/publish" "#; - let room_element: Element = serde_yaml::from_str(&spec).unwrap(); + + #[inline] + fn id>(s: &str) -> T { + T::from(s.to_string()) + } + + fn get_test_store() -> HashMap> { + let room_element: Element = serde_yaml::from_str(TEST_SPEC).unwrap(); let room_spec = RoomSpec::try_from(&room_element).unwrap(); - let store = parse_participants(&room_spec).unwrap(); + parse_participants(&room_spec).unwrap() + } - let caller = store.get(&ParticipantId("caller".to_string())).unwrap(); - let responder = - store.get(&ParticipantId("responder".to_string())).unwrap(); + #[test] + pub fn load_store() { + let store = get_test_store(); - let caller_publish_endpoint = caller - .get_publisher_by_id(&EndpointId("publish".to_string())) - .unwrap(); - let responder_play_endpoint = responder - .get_receiver_by_id(&EndpointId("play".to_string())) - .unwrap(); + let caller = store.get(&id("caller")).unwrap(); + let responder = store.get(&id("responder")).unwrap(); + + let caller_publish_endpoint = + caller.get_publisher_by_id(&id("publish")).unwrap(); + let responder_play_endpoint = + responder.get_receiver_by_id(&id("play")).unwrap(); let is_caller_has_responder_in_receivers = caller_publish_endpoint .receivers() @@ -402,17 +409,14 @@ mod participant_loading_tests { &caller_publish_endpoint )); - let some_participant = store - .get(&ParticipantId("some-member".to_string())) - .unwrap(); + let some_participant = store.get(&id("some-member")).unwrap(); assert!(some_participant.receivers().is_empty()); assert_eq!(some_participant.publishers().len(), 1); - let responder_play2_endpoint = responder - .get_receiver_by_id(&EndpointId("play2".to_string())) - .unwrap(); + let responder_play2_endpoint = + responder.get_receiver_by_id(&id("play2")).unwrap(); let some_participant_publisher = some_participant - .get_publisher_by_id(&EndpointId("publish".to_string())) + .get_publisher_by_id(&id("publish")) .unwrap(); assert_eq!(some_participant_publisher.receivers().len(), 1); let is_some_participant_has_responder_in_receivers = @@ -424,4 +428,41 @@ mod participant_loading_tests { == 1; assert!(is_some_participant_has_responder_in_receivers); } + + #[test] + fn publisher_delete_all_their_players() { + let store = get_test_store(); + + let caller = store.get(&id("caller")).unwrap(); + let some_member = store.get(&id("some-member")).unwrap(); + let responder = store.get(&id("responder")).unwrap(); + + caller.remove_publisher(&id("publish")); + assert_eq!(responder.receivers().len(), 1); + + some_member.remove_publisher(&id("publish")); + assert_eq!(responder.receivers().len(), 0); + } + + #[test] + fn player_delete_self_from_publisher_sink() { + let store = get_test_store(); + + let caller = store.get(&id("caller")).unwrap(); + let some_member = store.get(&id("some-member")).unwrap(); + let responder = store.get(&id("responder")).unwrap(); + + let caller_publisher = + caller.get_publisher_by_id(&id("publish")).unwrap(); + let some_member_publisher = + some_member.get_publisher_by_id(&id("publish")).unwrap(); + + responder.remove_receiver(&id("play")); + assert_eq!(caller_publisher.receivers().len(), 0); + assert_eq!(some_member_publisher.receivers().len(), 1); + + responder.remove_receiver(&id("play2")); + assert_eq!(caller_publisher.receivers().len(), 0); + assert_eq!(some_member_publisher.receivers().len(), 0); + } } From d4e7f60810e08cc77f47a47b5bf4373f717e17b1 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 1 Jul 2019 13:14:58 +0300 Subject: [PATCH 218/735] Rename Participant to Member --- src/api/client/rpc_connection.rs | 18 ++-- src/api/client/server.rs | 2 +- src/api/client/session.rs | 6 +- src/media/peer.rs | 6 +- src/signalling/control/endpoint.rs | 30 +++---- src/signalling/control/mod.rs | 4 +- src/signalling/control/participant.rs | 116 ++++++++++++-------------- src/signalling/participants.rs | 69 ++++++++------- src/signalling/peers.rs | 16 ++-- src/signalling/room.rs | 46 +++++----- 10 files changed, 151 insertions(+), 162 deletions(-) diff --git a/src/api/client/rpc_connection.rs b/src/api/client/rpc_connection.rs index 5992e9c79..208f8850d 100644 --- a/src/api/client/rpc_connection.rs +++ b/src/api/client/rpc_connection.rs @@ -22,14 +22,14 @@ macro_attr! { pub struct EventMessage(Event); } -/// Abstraction over RPC connection with some remote [`Participant`]. +/// Abstraction over RPC connection with some remote [`Member`]. pub trait RpcConnection: fmt::Debug + Send { /// Closes [`RpcConnection`]. /// No [`RpcConnectionClosed`] signals should be emitted. /// Always returns success. fn close(&mut self) -> Box>; - /// Sends [`Event`] to remote [`Participant`]. + /// Sends [`Event`] to remote [`Member`]. fn send_event( &self, msg: EventMessage, @@ -40,7 +40,7 @@ pub trait RpcConnection: fmt::Debug + Send { #[derive(Debug, Message)] #[rtype(result = "Result<(), AuthorizationError>")] pub struct Authorize { - /// ID of [`Participant`] to authorize [`RpcConnection`] for. + /// ID of [`Member`] to authorize [`RpcConnection`] for. pub member_id: MemberId, /// Credentials to authorize [`RpcConnection`] with. pub credentials: String, // TODO: &str when futures will allow references @@ -49,30 +49,30 @@ pub struct Authorize { /// Error of authorization [`RpcConnection`] in [`Room`]. #[derive(Debug)] pub enum AuthorizationError { - /// Authorizing [`Participant`] does not exists in the [`Room`]. - ParticipantNotExists, + /// Authorizing [`Member`] does not exists in the [`Room`]. + MemberNotExists, /// Provided credentials are invalid. InvalidCredentials, } /// Signal of new [`RpcConnection`] being established with specified -/// [`Participant`]. Transport should consider dropping connection if message +/// [`Member`]. Transport should consider dropping connection if message /// result is err. #[derive(Debug, Message)] #[rtype(result = "Result<(), ()>")] #[allow(clippy::module_name_repetitions)] pub struct RpcConnectionEstablished { - /// ID of [`Participant`] that establishes [`RpcConnection`]. + /// ID of [`Member`] that establishes [`RpcConnection`]. pub member_id: MemberId, /// Established [`RpcConnection`]. pub connection: Box, } -/// Signal of existing [`RpcConnection`] of specified [`Participant`] being +/// Signal of existing [`RpcConnection`] of specified [`Member`] being /// closed. #[derive(Debug, Message)] #[allow(clippy::module_name_repetitions)] pub struct RpcConnectionClosed { - /// ID of [`Participant`] which [`RpcConnection`] is closed. + /// ID of [`Member`] which [`RpcConnection`] is closed. pub member_id: MemberId, /// Reason of why [`RpcConnection`] is closed. pub reason: ClosedReason, diff --git a/src/api/client/server.rs b/src/api/client/server.rs index b91c22864..968d4c61b 100644 --- a/src/api/client/server.rs +++ b/src/api/client/server.rs @@ -63,7 +63,7 @@ fn ws_index( &r, payload, ), - Err(AuthorizationError::ParticipantNotExists) => { + Err(AuthorizationError::MemberNotExists) => { Ok(HttpResponse::NotFound().into()) } Err(AuthorizationError::InvalidCredentials) => { diff --git a/src/api/client/session.rs b/src/api/client/session.rs index ea4340576..b0e2e93dc 100644 --- a/src/api/client/session.rs +++ b/src/api/client/session.rs @@ -26,10 +26,10 @@ use crate::{ #[derive(Debug)] #[allow(clippy::module_name_repetitions)] pub struct WsSession { - /// ID of [`Participant`] that WebSocket connection is associated with. + /// ID of [`Member`] that WebSocket connection is associated with. member_id: MemberId, - /// [`Room`] that [`Participant`] is associated with. + /// [`Room`] that [`Member`] is associated with. room: Addr, /// Timeout of receiving any messages from client. @@ -48,7 +48,7 @@ pub struct WsSession { } impl WsSession { - /// Creates new [`WsSession`] for specified [`Participant`]. + /// Creates new [`WsSession`] for specified [`Member`]. pub fn new( member_id: MemberId, room: Addr, diff --git a/src/media/peer.rs b/src/media/peer.rs index a756cfe95..8fdb5b1b1 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -163,7 +163,7 @@ pub struct Peer { } impl Peer { - /// Returns ID of [`Participant`] associated with this [`Peer`]. + /// Returns ID of [`Member`] associated with this [`Peer`]. pub fn member_id(&self) -> MemberId { self.context.member_id.clone() } @@ -178,7 +178,7 @@ impl Peer { self.context.partner_peer } - /// Returns ID of interconnected [`Participant`]. + /// Returns ID of interconnected [`Member`]. pub fn partner_member_id(&self) -> MemberId { self.context.partner_member.clone() } @@ -229,7 +229,7 @@ impl Peer { } impl Peer { - /// Creates new [`Peer`] for [`Participant`]. + /// Creates new [`Peer`] for [`Member`]. pub fn new( id: Id, member_id: MemberId, diff --git a/src/signalling/control/endpoint.rs b/src/signalling/control/endpoint.rs index 29f94057d..c69248ec6 100644 --- a/src/signalling/control/endpoint.rs +++ b/src/signalling/control/endpoint.rs @@ -13,7 +13,7 @@ use crate::{ media::PeerId, }; -use super::participant::Participant; +use super::participant::Member; /// ID of endpoint. #[derive(Clone, Debug, Eq, Hash, PartialEq)] @@ -44,8 +44,8 @@ struct WebRtcPlayEndpointInner { /// [`WebRtcPlayEndpoint`] receive data. publisher: Weak, - /// Owner [`Participant`] of this [`WebRtcPlayEndpoint`]. - owner: Weak, + /// Owner [`Member`] of this [`WebRtcPlayEndpoint`]. + owner: Weak, /// [`PeerId`] of [`Peer`] created for this [`WebRtcPlayEndpoint`]. /// @@ -62,11 +62,11 @@ impl WebRtcPlayEndpointInner { self.src.clone() } - fn owner(&self) -> Rc { + fn owner(&self) -> Rc { Weak::upgrade(&self.owner).unwrap() } - fn weak_owner(&self) -> Weak { + fn weak_owner(&self) -> Weak { Weak::clone(&self.owner) } @@ -110,7 +110,7 @@ impl WebRtcPlayEndpoint { id: Id, src: SrcUri, publisher: Weak, - owner: Weak, + owner: Weak, ) -> Self { Self(RefCell::new(WebRtcPlayEndpointInner { id, @@ -126,13 +126,13 @@ impl WebRtcPlayEndpoint { self.0.borrow().src() } - /// Returns owner [`Participant`] of this [`WebRtcPlayEndpoint`]. - pub fn owner(&self) -> Rc { + /// Returns owner [`Member`] of this [`WebRtcPlayEndpoint`]. + pub fn owner(&self) -> Rc { self.0.borrow().owner() } // TODO: explain this - pub fn weak_owner(&self) -> Weak { + pub fn weak_owner(&self) -> Weak { self.0.borrow().weak_owner() } @@ -180,8 +180,8 @@ struct WebRtcPublishEndpointInner { /// All receivers of this [`WebRtcPublishEndpoint`]. receivers: Vec>, - /// Owner [`Participant`] of this [`WebRtcPublishEndpoint`]. - owner: Weak, + /// Owner [`Member`] of this [`WebRtcPublishEndpoint`]. + owner: Weak, /// [`PeerId`] of all [`Peer`]s created for this [`WebRtcPublishEndpoint`]. /// @@ -214,7 +214,7 @@ impl WebRtcPublishEndpointInner { .collect() } - fn owner(&self) -> Rc { + fn owner(&self) -> Rc { Weak::upgrade(&self.owner).unwrap() } @@ -253,7 +253,7 @@ impl WebRtcPublishEndpoint { id: Id, p2p: P2pMode, receivers: Vec>, - owner: Weak, + owner: Weak, ) -> Self { Self(RefCell::new(WebRtcPublishEndpointInner { id, @@ -274,8 +274,8 @@ impl WebRtcPublishEndpoint { self.0.borrow().receivers() } - /// Returns owner [`Participant`] of this [`WebRtcPublishEndpoint`]. - pub fn owner(&self) -> Rc { + /// Returns owner [`Member`] of this [`WebRtcPublishEndpoint`]. + pub fn owner(&self) -> Rc { self.0.borrow().owner() } diff --git a/src/signalling/control/mod.rs b/src/signalling/control/mod.rs index 6e59c0562..8d99e8543 100644 --- a/src/signalling/control/mod.rs +++ b/src/signalling/control/mod.rs @@ -4,6 +4,4 @@ pub mod endpoint; pub mod participant; #[doc(inline)] -pub use self::participant::{ - parse_participants, Participant, ParticipantsLoadError, -}; +pub use self::participant::{parse_participants, Member, MembersLoadError}; diff --git a/src/signalling/control/participant.rs b/src/signalling/control/participant.rs index 33f595ff4..3b5845c94 100644 --- a/src/signalling/control/participant.rs +++ b/src/signalling/control/participant.rs @@ -1,4 +1,4 @@ -//! [`Participant`] is member of [`Room`] with [`RpcConnection`]. +//! [`Member`] is member of [`Room`] with [`RpcConnection`]. use std::{cell::RefCell, convert::TryFrom as _, rc::Rc}; @@ -7,9 +7,7 @@ use hashbrown::HashMap; use medea_client_api_proto::IceServer; use crate::{ - api::control::{ - MemberId as ParticipantId, MemberSpec, RoomSpec, TryFromElementError, - }, + api::control::{MemberId, MemberSpec, RoomSpec, TryFromElementError}, log::prelude::*, media::{IceUser, PeerId}, }; @@ -18,57 +16,57 @@ use super::endpoint::{ Id as EndpointId, WebRtcPlayEndpoint, WebRtcPublishEndpoint, }; -/// Errors which may occur while loading [`Participant`]s from [`RoomSpec`]. +/// Errors which may occur while loading [`Member`]s from [`RoomSpec`]. #[derive(Debug, Fail)] -pub enum ParticipantsLoadError { +pub enum MembersLoadError { /// Errors that can occur when we try transform some spec from [`Element`]. #[fail(display = "TryFromElementError: {}", _0)] TryFromError(TryFromElementError), - /// [`Participant`] not found. + /// [`Member`] not found. #[fail(display = "Member with id '{}' not found.", _0)] - ParticipantNotFound(ParticipantId), + MemberNotFound(MemberId), /// [`Endpoint`] not found. #[fail(display = "Endpoint with id '{}' not found.", _0)] EndpointNotFound(String), } -impl From for ParticipantsLoadError { +impl From for MembersLoadError { fn from(err: TryFromElementError) -> Self { - ParticipantsLoadError::TryFromError(err) + MembersLoadError::TryFromError(err) } } -/// [`Participant`] is member of [`Room`] with [`RpcConnection`]. +/// [`Member`] is member of [`Room`] with [`RpcConnection`]. #[derive(Debug)] -pub struct Participant(RefCell); +pub struct Member(RefCell); #[allow(clippy::module_name_repetitions)] #[derive(Debug)] -struct ParticipantInner { - id: ParticipantId, +struct MemberInner { + id: MemberId, - /// All [`WebRtcPublishEndpoint`]s of this [`Participant`]. + /// All [`WebRtcPublishEndpoint`]s of this [`Member`]. publishers: HashMap>, - /// All [`WebRtcPlayEndpoint`]s of this [`Participant`]. + /// All [`WebRtcPlayEndpoint`]s of this [`Member`]. receivers: HashMap>, - /// Credentials for this [`Participant`]. + /// Credentials for this [`Member`]. credentials: String, - /// [`IceUser`] of this [`Participant`]. + /// [`IceUser`] of this [`Member`]. ice_user: Option, } -impl Participant { - /// Create new empty [`Participant`]. +impl Member { + /// Create new empty [`Member`]. /// - /// To fill this [`Participant`], you need to call the [`Participant::load`] + /// To fill this [`Member`], you need to call the [`Member::load`] /// function. - fn new(id: ParticipantId, credentials: String) -> Self { - Self(RefCell::new(ParticipantInner { + fn new(id: MemberId, credentials: String) -> Self { + Self(RefCell::new(MemberInner { id, publishers: HashMap::new(), receivers: HashMap::new(), @@ -77,31 +75,30 @@ impl Participant { })) } - /// Load all publishers and receivers of this [`Participant`]. + /// Load all publishers and receivers of this [`Member`]. fn load( &self, room_spec: &RoomSpec, - store: &HashMap>, - ) -> Result<(), ParticipantsLoadError> { + store: &HashMap>, + ) -> Result<(), MembersLoadError> { let this_member_spec = MemberSpec::try_from( - room_spec.pipeline.get(&self.id().0).map_or( - Err(ParticipantsLoadError::ParticipantNotFound(self.id())), - Ok, - )?, + room_spec + .pipeline + .get(&self.id().0) + .map_or(Err(MembersLoadError::MemberNotFound(self.id())), Ok)?, )?; - let this_member = store.get(&self.id()).map_or( - Err(ParticipantsLoadError::ParticipantNotFound(self.id())), - Ok, - )?; + let this_member = store + .get(&self.id()) + .map_or(Err(MembersLoadError::MemberNotFound(self.id())), Ok)?; for (spec_play_name, spec_play_endpoint) in this_member_spec.play_endpoints() { let publisher_id = - ParticipantId(spec_play_endpoint.src.member_id.to_string()); + MemberId(spec_play_endpoint.src.member_id.to_string()); let publisher_participant = store.get(&publisher_id).map_or( - Err(ParticipantsLoadError::ParticipantNotFound(publisher_id)), + Err(MembersLoadError::MemberNotFound(publisher_id)), Ok, )?; let publisher_spec = MemberSpec::try_from( @@ -109,7 +106,7 @@ impl Participant { .pipeline .get(&spec_play_endpoint.src.member_id.to_string()) .map_or( - Err(ParticipantsLoadError::ParticipantNotFound( + Err(MembersLoadError::MemberNotFound( spec_play_endpoint.src.member_id.clone(), )), Ok, @@ -120,7 +117,7 @@ impl Participant { .publish_endpoints() .get(&spec_play_endpoint.src.endpoint_id) .map_or( - Err(ParticipantsLoadError::EndpointNotFound( + Err(MembersLoadError::EndpointNotFound( spec_play_endpoint.src.endpoint_id.clone(), )), Ok, @@ -186,9 +183,9 @@ impl Participant { Ok(()) } - /// Notify [`Participant`] that some [`Peer`]s removed. + /// Notify [`Member`] that some [`Peer`]s removed. /// - /// All [`PeerId`]s related to this [`Participant`] will be removed. + /// All [`PeerId`]s related to this [`Member`] will be removed. pub fn peers_removed(&self, peer_ids: &[PeerId]) { self.publishers() .into_iter() @@ -201,42 +198,42 @@ impl Participant { .for_each(|(_, p)| p.reset()); } - /// Returns list of [`IceServer`] for this [`Participant`]. + /// Returns list of [`IceServer`] for this [`Member`]. pub fn servers_list(&self) -> Option> { self.0.borrow().ice_user.as_ref().map(IceUser::servers_list) } - /// Returns and set to `None` [`IceUser`] of this [`Participant`]. + /// Returns and set to `None` [`IceUser`] of this [`Member`]. pub fn take_ice_user(&self) -> Option { self.0.borrow_mut().ice_user.take() } - /// Replace and return [`IceUser`] of this [`Participant`]. + /// Replace and return [`IceUser`] of this [`Member`]. pub fn replace_ice_user(&self, new_ice_user: IceUser) -> Option { self.0.borrow_mut().ice_user.replace(new_ice_user) } - /// Returns [`ParticipantId`] of this [`Participant`]. - pub fn id(&self) -> ParticipantId { + /// Returns [`MemberId`] of this [`Member`]. + pub fn id(&self) -> MemberId { self.0.borrow().id.clone() } - /// Returns credentials of this [`Participant`]. + /// Returns credentials of this [`Member`]. pub fn credentials(&self) -> String { self.0.borrow().credentials.clone() } - /// Returns all publishers of this [`Participant`]. + /// Returns all publishers of this [`Member`]. pub fn publishers(&self) -> HashMap> { self.0.borrow().publishers.clone() } - /// Returns all receivers of this [`Participant`]. + /// Returns all receivers of this [`Member`]. pub fn receivers(&self) -> HashMap> { self.0.borrow().receivers.clone() } - /// Insert receiver into this [`Participant`]. + /// Insert receiver into this [`Member`]. pub fn insert_receiver(&self, endpoint: Rc) { self.0 .borrow_mut() @@ -244,7 +241,7 @@ impl Participant { .insert(endpoint.id(), endpoint); } - /// Insert publisher into this [`Participant`]. + /// Insert publisher into this [`Member`]. pub fn insert_publisher(&self, endpoint: Rc) { self.0 .borrow_mut() @@ -268,34 +265,31 @@ impl Participant { self.0.borrow().receivers.get(id).cloned() } - /// Remove receiver [`WebRtcPlayEndpoint`] from this [`Participant`]. + /// Remove receiver [`WebRtcPlayEndpoint`] from this [`Member`]. pub fn remove_receiver(&self, id: &EndpointId) { self.0.borrow_mut().receivers.remove(id); } - /// Remove receiver [`WebRtcPublishEndpoint`] from this [`Participant`]. + /// Remove receiver [`WebRtcPublishEndpoint`] from this [`Member`]. pub fn remove_publisher(&self, id: &EndpointId) { self.0.borrow_mut().publishers.remove(id); } } -/// Creates all empty [`Participant`] from [`RoomSpec`] and then -/// load all related to this [`Participant`]s receivers and publishers. +/// Creates all empty [`Member`] from [`RoomSpec`] and then +/// load all related to this [`Member`]s receivers and publishers. /// -/// Returns store of all [`Participant`]s loaded from [`RoomSpec`]. +/// Returns store of all [`Member`]s loaded from [`RoomSpec`]. pub fn parse_participants( room_spec: &RoomSpec, -) -> Result>, ParticipantsLoadError> { +) -> Result>, MembersLoadError> { let members = room_spec.members()?; let mut participants = HashMap::new(); for (id, member) in &members { participants.insert( id.clone(), - Rc::new(Participant::new( - id.clone(), - member.credentials().to_string(), - )), + Rc::new(Member::new(id.clone(), member.credentials().to_string())), ); } @@ -378,7 +372,7 @@ mod tests { T::from(s.to_string()) } - fn get_test_store() -> HashMap> { + fn get_test_store() -> HashMap> { let room_element: Element = serde_yaml::from_str(TEST_SPEC).unwrap(); let room_spec = RoomSpec::try_from(&room_element).unwrap(); parse_participants(&room_spec).unwrap() diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 74721ca42..7aed53064 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -1,5 +1,5 @@ -//! [`Participant`] is member with [`RpcConnection`]. [`ParticipantService`] -//! stores [`Participant`]s and associated [`RpcConnection`]s, handles +//! [`Member`] is member with [`RpcConnection`]. [`MemberService`] +//! stores [`Member`]s and associated [`RpcConnection`]s, handles //! [`RpcConnection`] authorization, establishment, message sending, Turn //! credentials management. @@ -26,12 +26,12 @@ use crate::{ AuthorizationError, ClosedReason, EventMessage, RpcConnection, RpcConnectionClosed, }, - control::{MemberId as ParticipantId, RoomId, RoomSpec}, + control::{MemberId, RoomId, RoomSpec}, }, log::prelude::*, media::IceUser, signalling::{ - control::{parse_participants, Participant, ParticipantsLoadError}, + control::{parse_participants, Member, MembersLoadError}, room::{ActFuture, RoomError}, Room, }, @@ -49,7 +49,7 @@ pub enum ParticipantServiceErr { )] MailBoxErr(MailboxError), #[fail(display = "Participant with Id [{}] was not found", _0)] - ParticipantNotFound(ParticipantId), + ParticipantNotFound(MemberId), } impl From for ParticipantServiceErr { @@ -64,8 +64,8 @@ impl From for ParticipantServiceErr { } } -/// [`Participant`] is member of [`Room`] with [`RpcConnection`]. -/// [`ParticipantService`] stores [`Participant`]s and associated +/// [`Member`] is member of [`Room`] with [`RpcConnection`]. +/// [`ParticipantService`] stores [`Member`]s and associated /// [`RpcConnection`]s, handles [`RpcConnection`] authorization, establishment, /// message sending. #[derive(Debug)] @@ -73,16 +73,16 @@ pub struct ParticipantService { /// [`Room`]s id from which this [`ParticipantService`] was created. room_id: RoomId, - /// [`Participant`]s which currently are present in this [`Room`]. - participants: HashMap>, + /// [`Member`]s which currently are present in this [`Room`]. + participants: HashMap>, /// Service for managing authorization on Turn server. turn: Box, - /// Established [`RpcConnection`]s of [`Participants`]s in this [`Room`]. + /// Established [`RpcConnection`]s of [`Members`]s in this [`Room`]. // TODO: Replace Box> with enum, // as the set of all possible RpcConnection types is not closed. - connections: HashMap>, + connections: HashMap>, /// Timeout for close [`RpcConnection`] after receiving /// [`RpcConnectionClosed`] message. @@ -91,7 +91,7 @@ pub struct ParticipantService { /// Stores [`RpcConnection`] drop tasks. /// If [`RpcConnection`] is lost, [`Room`] waits for connection_timeout /// before dropping it irrevocably in case it gets reestablished. - drop_connection_tasks: HashMap, + drop_connection_tasks: HashMap, } impl ParticipantService { @@ -100,7 +100,7 @@ impl ParticipantService { room_spec: &RoomSpec, reconnect_timeout: Duration, turn: Box, - ) -> Result { + ) -> Result { Ok(Self { room_id: room_spec.id().clone(), participants: parse_participants(room_spec)?, @@ -111,24 +111,21 @@ impl ParticipantService { }) } - /// Lookup [`Participant`] by provided id. - pub fn get_participant_by_id( - &self, - id: &ParticipantId, - ) -> Option> { + /// Lookup [`Member`] by provided id. + pub fn get_participant_by_id(&self, id: &MemberId) -> Option> { self.participants.get(id).cloned() } - /// Lookup [`Participant`] by provided id and credentials. Returns - /// [`Err(AuthorizationError::ParticipantNotExists)`] if lookup by - /// [`ParticipantId`] failed. Returns - /// [`Err(AuthorizationError::InvalidCredentials)`] if [`Participant`] + /// Lookup [`Member`] by provided id and credentials. Returns + /// [`Err(AuthorizationError::MemberNotExists)`] if lookup by + /// [`MemberId`] failed. Returns + /// [`Err(AuthorizationError::InvalidCredentials)`] if [`Member`] /// was found, but incorrect credentials was provided. pub fn get_participant_by_id_and_credentials( &self, - participant_id: &ParticipantId, + participant_id: &MemberId, credentials: &str, - ) -> Result, AuthorizationError> { + ) -> Result, AuthorizationError> { match self.get_participant_by_id(participant_id) { Some(participant) => { if participant.credentials().eq(credentials) { @@ -137,23 +134,23 @@ impl ParticipantService { Err(AuthorizationError::InvalidCredentials) } } - None => Err(AuthorizationError::ParticipantNotExists), + None => Err(AuthorizationError::MemberNotExists), } } - /// Checks if [`Participant`] has **active** [`RcpConnection`]. + /// Checks if [`Member`] has **active** [`RcpConnection`]. pub fn participant_has_connection( &self, - participant_id: &ParticipantId, + participant_id: &MemberId, ) -> bool { self.connections.contains_key(participant_id) && !self.drop_connection_tasks.contains_key(participant_id) } - /// Send [`Event`] to specified remote [`Participant`]. + /// Send [`Event`] to specified remote [`Member`]. pub fn send_event_to_participant( &mut self, - participant_id: ParticipantId, + participant_id: MemberId, event: Event, ) -> impl Future { match self.connections.get(&participant_id) { @@ -169,14 +166,14 @@ impl ParticipantService { } /// Saves provided [`RpcConnection`], registers [`ICEUser`]. - /// If [`Participant`] already has any other [`RpcConnection`], + /// If [`Member`] already has any other [`RpcConnection`], /// then it will be closed. pub fn connection_established( &mut self, ctx: &mut Context, - participant_id: ParticipantId, + participant_id: MemberId, con: Box, - ) -> ActFuture, ParticipantServiceErr> { + ) -> ActFuture, ParticipantServiceErr> { let participant = match self.get_participant_by_id(&participant_id) { None => { return Box::new(wrap_future(future::err( @@ -229,14 +226,14 @@ impl ParticipantService { /// Insert new [`RpcConnection`] into this [`ParticipantService`]. fn insert_connection( &mut self, - participant_id: ParticipantId, + participant_id: MemberId, conn: Box, ) { self.connections.insert(participant_id, conn); } /// If [`ClosedReason::Closed`], then removes [`RpcConnection`] associated - /// with specified user [`Participant`] from the storage and closes the + /// with specified user [`Member`] from the storage and closes the /// room. If [`ClosedReason::Lost`], then creates delayed task that /// emits [`ClosedReason::Closed`]. // TODO: Dont close the room. It is being closed atm, because we have @@ -244,7 +241,7 @@ impl ParticipantService { pub fn connection_closed( &mut self, ctx: &mut Context, - participant_id: ParticipantId, + participant_id: MemberId, reason: &ClosedReason, ) { let closed_at = Instant::now(); @@ -281,7 +278,7 @@ impl ParticipantService { /// Deletes [`IceUser`] associated with provided [`Member`]. fn delete_ice_user( &mut self, - participant_id: &ParticipantId, + participant_id: &MemberId, ) -> Box> { match self.get_participant_by_id(&participant_id) { Some(participant) => match participant.take_ice_user() { diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index 9d2de975c..d98763dc5 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -13,14 +13,14 @@ use crate::{ log::prelude::*, media::{Peer, PeerId, PeerStateMachine}, signalling::{ - control::participant::Participant, + control::participant::Member, room::{PeersRemoved, Room, RoomError}, }, }; #[derive(Debug)] pub struct PeerRepository { - /// [`Peer`]s of [`Participant`]s in this [`Room`]. + /// [`Peer`]s of [`Member`]s in this [`Room`]. peers: HashMap, /// Count of [`Peer`]s in this [`Room`]. @@ -69,13 +69,13 @@ impl PeerRepository { .ok_or_else(|| RoomError::PeerNotFound(peer_id)) } - /// Create and interconnect [`Peer`]s based on [`Participant`]. + /// Create and interconnect [`Peer`]s based on [`Member`]. /// /// Returns IDs of created [`Peer`]s. `(first_peer_id, second_peer_id)`. pub fn create_peers( &mut self, - first_member: &Participant, - second_member: &Participant, + first_member: &Member, + second_member: &Member, ) -> (u64, u64) { debug!( "Created peer between {} and {}.", @@ -130,7 +130,7 @@ impl PeerRepository { } } - /// Returns all [`Peer`]s of specified [`Participant`]. + /// Returns all [`Peer`]s of specified [`Member`]. pub fn get_peers_by_member_id( &self, member_id: &MemberId, @@ -162,10 +162,10 @@ impl PeerRepository { } } - /// Close all related to disconnected [`Participant`] [`Peer`]s and partner + /// Close all related to disconnected [`Member`] [`Peer`]s and partner /// [`Peer`]s. /// - /// Send [`Event::PeersRemoved`] to all affected [`Participant`]s. + /// Send [`Event::PeersRemoved`] to all affected [`Member`]s. pub fn connection_closed( &mut self, member_id: &MemberId, diff --git a/src/signalling/room.rs b/src/signalling/room.rs index bd205706a..8768e2c84 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -1,5 +1,5 @@ //! Room definitions and implementations. Room is responsible for media -//! connection establishment between concrete [`Participant`]s. +//! connection establishment between concrete [`Member`]s. use std::time::Duration; @@ -26,7 +26,7 @@ use crate::{ WaitLocalHaveRemote, WaitLocalSdp, WaitRemoteSdp, }, signalling::{ - control::participant::{Participant, ParticipantsLoadError}, + control::participant::{Member, MembersLoadError}, participants::ParticipantService, peers::PeerRepository, }, @@ -73,8 +73,8 @@ impl From for RoomError { } } -impl From for RoomError { - fn from(err: ParticipantsLoadError) -> Self { +impl From for RoomError { + fn from(err: MembersLoadError) -> Self { RoomError::BadRoomSpec(format!( "Error while loading room spec. {}", err @@ -82,15 +82,15 @@ impl From for RoomError { } } -/// Media server room with its [`Participant`]s. +/// Media server room with its [`Member`]s. #[derive(Debug)] pub struct Room { id: RoomId, - /// [`RpcConnection`]s of [`Participant`]s in this [`Room`]. + /// [`RpcConnection`]s of [`Member`]s in this [`Room`]. pub participants: ParticipantService, - /// [`Peer`]s of [`Participant`]s in this [`Room`]. + /// [`Peer`]s of [`Member`]s in this [`Room`]. peers: PeerRepository, } @@ -170,7 +170,7 @@ impl Room { ))) } - /// Sends [`Event::PeersRemoved`] to [`Participant`]. + /// Sends [`Event::PeersRemoved`] to [`Member`]. fn send_peers_removed( &mut self, member_id: MemberId, @@ -296,12 +296,12 @@ impl Room { ))) } - /// Create [`Peer`]s between [`Participant`]s and interconnect it by control + /// Create [`Peer`]s between [`Member`]s and interconnect it by control /// API spec. fn connect_participants( &mut self, - first_member: &Participant, - second_member: &Participant, + first_member: &Member, + second_member: &Member, ctx: &mut ::Context, ) { debug!( @@ -316,15 +316,15 @@ impl Room { self.connect_peers(ctx, first_peer_id, second_peer_id); } - /// Create and interconnect all [`Peer`]s between connected [`Participant`] - /// and all available at this moment [`Participant`]. + /// Create and interconnect all [`Peer`]s between connected [`Member`] + /// and all available at this moment [`Member`]. /// /// Availability is determines by checking [`RpcConnection`] of all - /// [`Participant`]s from [`WebRtcPlayEndpoint`]s and from receivers of - /// connected [`Participant`]. + /// [`Member`]s from [`WebRtcPlayEndpoint`]s and from receivers of + /// connected [`Member`]. fn init_participant_connections( &mut self, - participant: &Participant, + participant: &Member, ctx: &mut ::Context, ) { // Create all connected publish endpoints. @@ -365,7 +365,7 @@ impl Room { } /// Check state of interconnected [`Peer`]s and sends [`Event`] about - /// [`Peer`] created to remote [`Participant`]. + /// [`Peer`] created to remote [`Member`]. fn connect_peers( &mut self, ctx: &mut Context, @@ -423,7 +423,7 @@ impl Handler for Room { } } -/// Signal of removing [`Participant`]'s [`Peer`]s. +/// Signal of removing [`Member`]'s [`Peer`]s. #[derive(Debug, Message)] #[rtype(result = "Result<(), ()>")] pub struct PeersRemoved { @@ -434,9 +434,9 @@ pub struct PeersRemoved { impl Handler for Room { type Result = ActFuture<(), ()>; - /// Send [`Event::PeersRemoved`] to remote [`Participant`]. + /// Send [`Event::PeersRemoved`] to remote [`Member`]. /// - /// Delete all removed [`PeerId`]s from all [`Participant`]'s + /// Delete all removed [`PeerId`]s from all [`Member`]'s /// endpoints. #[allow(clippy::single_match_else)] fn handle( @@ -530,7 +530,7 @@ impl Handler for Room { /// Saves new [`RpcConnection`] in [`ParticipantService`], initiates media /// establishment between members. - /// Create and interconnect all available [`Participant`]'s [`Peer`]s. + /// Create and interconnect all available [`Member`]'s [`Peer`]s. fn handle( &mut self, msg: RpcConnectionEstablished, @@ -562,7 +562,7 @@ pub struct CloseRoom {} impl Handler for Room { type Result = (); - /// Sends to remote [`Participant`] the [`Event`] about [`Peer`] removed. + /// Sends to remote [`Member`] the [`Event`] about [`Peer`] removed. /// Closes all active [`RpcConnection`]s. fn handle( &mut self, @@ -579,7 +579,7 @@ impl Handler for Room { type Result = (); /// Passes message to [`ParticipantService`] to cleanup stored connections. - /// Remove all related for disconnected [`Participant`] [`Peer`]s. + /// Remove all related for disconnected [`Member`] [`Peer`]s. fn handle(&mut self, msg: RpcConnectionClosed, ctx: &mut Self::Context) { info!( "RpcConnectionClosed for member {}, reason {:?}", From 28234e53d8e58a230e0341edcd15246a61a5acef Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 1 Jul 2019 13:27:41 +0300 Subject: [PATCH 219/735] Replace participant with member --- src/signalling/control/endpoint.rs | 2 +- .../control/{participant.rs => member.rs} | 56 +++++---- src/signalling/control/mod.rs | 4 +- src/signalling/participants.rs | 107 ++++++++---------- src/signalling/peers.rs | 2 +- src/signalling/room.rs | 81 +++++-------- 6 files changed, 110 insertions(+), 142 deletions(-) rename src/signalling/control/{participant.rs => member.rs} (91%) diff --git a/src/signalling/control/endpoint.rs b/src/signalling/control/endpoint.rs index c69248ec6..cb00796dc 100644 --- a/src/signalling/control/endpoint.rs +++ b/src/signalling/control/endpoint.rs @@ -13,7 +13,7 @@ use crate::{ media::PeerId, }; -use super::participant::Member; +use super::member::Member; /// ID of endpoint. #[derive(Clone, Debug, Eq, Hash, PartialEq)] diff --git a/src/signalling/control/participant.rs b/src/signalling/control/member.rs similarity index 91% rename from src/signalling/control/participant.rs rename to src/signalling/control/member.rs index 3b5845c94..fbe2eaf09 100644 --- a/src/signalling/control/participant.rs +++ b/src/signalling/control/member.rs @@ -97,7 +97,7 @@ impl Member { { let publisher_id = MemberId(spec_play_endpoint.src.member_id.to_string()); - let publisher_participant = store.get(&publisher_id).map_or( + let publisher_member = store.get(&publisher_id).map_or( Err(MembersLoadError::MemberNotFound(publisher_id)), Ok, )?; @@ -123,7 +123,7 @@ impl Member { Ok, )?; - if let Some(publisher) = publisher_participant.get_publisher_by_id( + if let Some(publisher) = publisher_member.get_publisher_by_id( &EndpointId(spec_play_endpoint.src.endpoint_id.to_string()), ) { let new_play_endpoint_id = @@ -145,7 +145,7 @@ impl Member { new_publish_id.clone(), publisher_endpoint.p2p.clone(), Vec::new(), - Rc::downgrade(&publisher_participant), + Rc::downgrade(&publisher_member), )); let new_self_play_id = EndpointId(spec_play_name.to_string()); @@ -158,7 +158,7 @@ impl Member { new_publish.add_receiver(Rc::downgrade(&new_self_play)); - publisher_participant.insert_publisher(new_publish); + publisher_member.insert_publisher(new_publish); self.insert_receiver(new_self_play); } @@ -280,26 +280,26 @@ impl Member { /// load all related to this [`Member`]s receivers and publishers. /// /// Returns store of all [`Member`]s loaded from [`RoomSpec`]. -pub fn parse_participants( +pub fn parse_members( room_spec: &RoomSpec, ) -> Result>, MembersLoadError> { - let members = room_spec.members()?; - let mut participants = HashMap::new(); + let members_spec = room_spec.members()?; + let mut members = HashMap::new(); - for (id, member) in &members { - participants.insert( + for (id, member) in &members_spec { + members.insert( id.clone(), Rc::new(Member::new(id.clone(), member.credentials().to_string())), ); } - for (_, participant) in &participants { - participant.load(room_spec, &participants)?; + for (_, member) in &members { + member.load(room_spec, &members)?; } debug!( "Created ParticipantService with participants: {:?}.", - participants + members .iter() .map(|(id, p)| { format!( @@ -318,7 +318,7 @@ pub fn parse_participants( .collect::>() ); - Ok(participants) + Ok(members) } #[cfg(test)] @@ -375,7 +375,7 @@ mod tests { fn get_test_store() -> HashMap> { let room_element: Element = serde_yaml::from_str(TEST_SPEC).unwrap(); let room_spec = RoomSpec::try_from(&room_element).unwrap(); - parse_participants(&room_spec).unwrap() + parse_members(&room_spec).unwrap() } #[test] @@ -403,24 +403,22 @@ mod tests { &caller_publish_endpoint )); - let some_participant = store.get(&id("some-member")).unwrap(); - assert!(some_participant.receivers().is_empty()); - assert_eq!(some_participant.publishers().len(), 1); + let some_member = store.get(&id("some-member")).unwrap(); + assert!(some_member.receivers().is_empty()); + assert_eq!(some_member.publishers().len(), 1); let responder_play2_endpoint = responder.get_receiver_by_id(&id("play2")).unwrap(); - let some_participant_publisher = some_participant - .get_publisher_by_id(&id("publish")) - .unwrap(); - assert_eq!(some_participant_publisher.receivers().len(), 1); - let is_some_participant_has_responder_in_receivers = - some_participant_publisher - .receivers() - .into_iter() - .filter(|p| Rc::ptr_eq(p, &responder_play2_endpoint)) - .count() - == 1; - assert!(is_some_participant_has_responder_in_receivers); + let some_member_publisher = + some_member.get_publisher_by_id(&id("publish")).unwrap(); + assert_eq!(some_member_publisher.receivers().len(), 1); + let is_some_member_has_responder_in_receivers = some_member_publisher + .receivers() + .into_iter() + .filter(|p| Rc::ptr_eq(p, &responder_play2_endpoint)) + .count() + == 1; + assert!(is_some_member_has_responder_in_receivers); } #[test] diff --git a/src/signalling/control/mod.rs b/src/signalling/control/mod.rs index 8d99e8543..d1ca7fa6f 100644 --- a/src/signalling/control/mod.rs +++ b/src/signalling/control/mod.rs @@ -1,7 +1,7 @@ //! Signalling representation of control spec. pub mod endpoint; -pub mod participant; +pub mod member; #[doc(inline)] -pub use self::participant::{parse_participants, Member, MembersLoadError}; +pub use self::member::{parse_members, Member, MembersLoadError}; diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 7aed53064..736ecb848 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -31,7 +31,7 @@ use crate::{ log::prelude::*, media::IceUser, signalling::{ - control::{parse_participants, Member, MembersLoadError}, + control::{parse_members, Member, MembersLoadError}, room::{ActFuture, RoomError}, Room, }, @@ -74,7 +74,7 @@ pub struct ParticipantService { room_id: RoomId, /// [`Member`]s which currently are present in this [`Room`]. - participants: HashMap>, + members: HashMap>, /// Service for managing authorization on Turn server. turn: Box, @@ -103,7 +103,7 @@ impl ParticipantService { ) -> Result { Ok(Self { room_id: room_spec.id().clone(), - participants: parse_participants(room_spec)?, + members: parse_members(room_spec)?, turn, connections: HashMap::new(), reconnect_timeout, @@ -112,8 +112,8 @@ impl ParticipantService { } /// Lookup [`Member`] by provided id. - pub fn get_participant_by_id(&self, id: &MemberId) -> Option> { - self.participants.get(id).cloned() + pub fn get_member_by_id(&self, id: &MemberId) -> Option> { + self.members.get(id).cloned() } /// Lookup [`Member`] by provided id and credentials. Returns @@ -121,15 +121,15 @@ impl ParticipantService { /// [`MemberId`] failed. Returns /// [`Err(AuthorizationError::InvalidCredentials)`] if [`Member`] /// was found, but incorrect credentials was provided. - pub fn get_participant_by_id_and_credentials( + pub fn get_member_by_id_and_credentials( &self, - participant_id: &MemberId, + member_id: &MemberId, credentials: &str, ) -> Result, AuthorizationError> { - match self.get_participant_by_id(participant_id) { - Some(participant) => { - if participant.credentials().eq(credentials) { - Ok(participant.clone()) + match self.get_member_by_id(member_id) { + Some(member) => { + if member.credentials().eq(credentials) { + Ok(member.clone()) } else { Err(AuthorizationError::InvalidCredentials) } @@ -139,28 +139,24 @@ impl ParticipantService { } /// Checks if [`Member`] has **active** [`RcpConnection`]. - pub fn participant_has_connection( - &self, - participant_id: &MemberId, - ) -> bool { - self.connections.contains_key(participant_id) - && !self.drop_connection_tasks.contains_key(participant_id) + pub fn member_has_connection(&self, member_id: &MemberId) -> bool { + self.connections.contains_key(member_id) + && !self.drop_connection_tasks.contains_key(member_id) } /// Send [`Event`] to specified remote [`Member`]. - pub fn send_event_to_participant( + pub fn send_event_to_member( &mut self, - participant_id: MemberId, + member_id: MemberId, event: Event, ) -> impl Future { - match self.connections.get(&participant_id) { - Some(conn) => { - Either::A(conn.send_event(EventMessage::from(event)).map_err( - move |_| RoomError::UnableToSendEvent(participant_id), - )) - } + match self.connections.get(&member_id) { + Some(conn) => Either::A( + conn.send_event(EventMessage::from(event)) + .map_err(move |_| RoomError::UnableToSendEvent(member_id)), + ), None => Either::B(future::err(RoomError::ConnectionNotExists( - participant_id, + member_id, ))), } } @@ -171,39 +167,33 @@ impl ParticipantService { pub fn connection_established( &mut self, ctx: &mut Context, - participant_id: MemberId, + member_id: MemberId, con: Box, ) -> ActFuture, ParticipantServiceErr> { - let participant = match self.get_participant_by_id(&participant_id) { + let member = match self.get_member_by_id(&member_id) { None => { return Box::new(wrap_future(future::err( - ParticipantServiceErr::ParticipantNotFound(participant_id), + ParticipantServiceErr::ParticipantNotFound(member_id), ))); } - Some(participant) => participant, + Some(member) => member, }; - // lookup previous participant connection - if let Some(mut connection) = self.connections.remove(&participant_id) { - debug!( - "Closing old RpcConnection for participant {}", - participant_id - ); + // lookup previous member connection + if let Some(mut connection) = self.connections.remove(&member_id) { + debug!("Closing old RpcConnection for participant {}", member_id); // cancel RpcConnection close task, since connection is // reestablished - if let Some(handler) = - self.drop_connection_tasks.remove(&participant_id) + if let Some(handler) = self.drop_connection_tasks.remove(&member_id) { ctx.cancel_future(handler); } - Box::new(wrap_future( - connection.close().then(move |_| Ok(participant)), - )) + Box::new(wrap_future(connection.close().then(move |_| Ok(member)))) } else { Box::new( wrap_future(self.turn.create( - participant_id.clone(), + member_id.clone(), self.room_id.clone(), UnreachablePolicy::ReturnErr, )) @@ -212,11 +202,10 @@ impl ParticipantService { }) .and_then( move |ice: IceUser, room: &mut Room, _| { - room.participants - .insert_connection(participant_id.clone(), con); - participant.replace_ice_user(ice); + room.members.insert_connection(member_id.clone(), con); + member.replace_ice_user(ice); - wrap_future(future::ok(participant)) + wrap_future(future::ok(member)) }, ), ) @@ -226,10 +215,10 @@ impl ParticipantService { /// Insert new [`RpcConnection`] into this [`ParticipantService`]. fn insert_connection( &mut self, - participant_id: MemberId, + member_id: MemberId, conn: Box, ) { - self.connections.insert(participant_id, conn); + self.connections.insert(member_id, conn); } /// If [`ClosedReason::Closed`], then removes [`RpcConnection`] associated @@ -241,16 +230,16 @@ impl ParticipantService { pub fn connection_closed( &mut self, ctx: &mut Context, - participant_id: MemberId, + member_id: MemberId, reason: &ClosedReason, ) { let closed_at = Instant::now(); match reason { ClosedReason::Closed => { - self.connections.remove(&participant_id); + self.connections.remove(&member_id); ctx.spawn(wrap_future( - self.delete_ice_user(&participant_id).map_err(|err| { + self.delete_ice_user(&member_id).map_err(|err| { error!("Error deleting IceUser {:?}", err) }), )); @@ -258,15 +247,15 @@ impl ParticipantService { } ClosedReason::Lost => { self.drop_connection_tasks.insert( - participant_id.clone(), + member_id.clone(), ctx.run_later(self.reconnect_timeout, move |_, ctx| { info!( "Member {} connection lost at {:?}. Room will be \ stopped.", - &participant_id, closed_at + &member_id, closed_at ); ctx.notify(RpcConnectionClosed { - member_id: participant_id, + member_id, reason: ClosedReason::Closed, }) }), @@ -278,10 +267,10 @@ impl ParticipantService { /// Deletes [`IceUser`] associated with provided [`Member`]. fn delete_ice_user( &mut self, - participant_id: &MemberId, + member_id: &MemberId, ) -> Box> { - match self.get_participant_by_id(&participant_id) { - Some(participant) => match participant.take_ice_user() { + match self.get_member_by_id(&member_id) { + Some(member) => match member.take_ice_user() { Some(ice_user) => self.turn.delete(vec![ice_user]), None => Box::new(future::ok(())), }, @@ -310,9 +299,9 @@ impl ParticipantService { // deleting all IceUsers let remove_ice_users = Box::new({ - let mut room_users = Vec::with_capacity(self.participants.len()); + let mut room_users = Vec::with_capacity(self.members.len()); - self.participants.iter().for_each(|(_, data)| { + self.members.iter().for_each(|(_, data)| { if let Some(ice_user) = data.take_ice_user() { room_users.push(ice_user); } diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index d98763dc5..ebcd8f547 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -13,7 +13,7 @@ use crate::{ log::prelude::*, media::{Peer, PeerId, PeerStateMachine}, signalling::{ - control::participant::Member, + control::member::Member, room::{PeersRemoved, Room, RoomError}, }, }; diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 8768e2c84..8321adc8f 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -26,7 +26,7 @@ use crate::{ WaitLocalHaveRemote, WaitLocalSdp, WaitRemoteSdp, }, signalling::{ - control::participant::{Member, MembersLoadError}, + control::member::{Member, MembersLoadError}, participants::ParticipantService, peers::PeerRepository, }, @@ -88,7 +88,7 @@ pub struct Room { id: RoomId, /// [`RpcConnection`]s of [`Member`]s in this [`Room`]. - pub participants: ParticipantService, + pub members: ParticipantService, /// [`Peer`]s of [`Member`]s in this [`Room`]. peers: PeerRepository, @@ -107,7 +107,7 @@ impl Room { Ok(Self { id: room_spec.id().clone(), peers: PeerRepository::from(HashMap::new()), - participants: ParticipantService::new( + members: ParticipantService::new( room_spec, reconnect_timeout, turn, @@ -152,8 +152,8 @@ impl Room { let sender = sender.start(); let member_id = sender.member_id(); let ice_servers = self - .participants - .get_participant_by_id(&member_id) + .members + .get_member_by_id(&member_id) .ok_or_else(|| RoomError::MemberNotFound(member_id.clone()))? .servers_list() .ok_or_else(|| RoomError::NoTurnCredentials(member_id.clone()))?; @@ -165,8 +165,7 @@ impl Room { }; self.peers.add_peer(sender); Ok(Box::new(wrap_future( - self.participants - .send_event_to_participant(member_id, peer_created), + self.members.send_event_to_member(member_id, peer_created), ))) } @@ -176,7 +175,7 @@ impl Room { member_id: MemberId, peers: Vec, ) -> ActFuture<(), RoomError> { - Box::new(wrap_future(self.participants.send_event_to_participant( + Box::new(wrap_future(self.members.send_event_to_member( member_id, Event::PeersRemoved { peer_ids: peers }, ))) @@ -201,8 +200,8 @@ impl Room { let to_member_id = to_peer.member_id(); let ice_servers = self - .participants - .get_participant_by_id(&to_member_id) + .members + .get_member_by_id(&to_member_id) .ok_or_else(|| RoomError::MemberNotFound(to_member_id.clone()))? .servers_list() .ok_or_else(|| { @@ -220,8 +219,7 @@ impl Room { self.peers.add_peer(to_peer); Ok(Box::new(wrap_future( - self.participants - .send_event_to_participant(to_member_id, event), + self.members.send_event_to_member(to_member_id, event), ))) } @@ -253,8 +251,7 @@ impl Room { self.peers.add_peer(to_peer); Ok(Box::new(wrap_future( - self.participants - .send_event_to_participant(to_member_id, event), + self.members.send_event_to_member(to_member_id, event), ))) } @@ -291,14 +288,13 @@ impl Room { }; Ok(Box::new(wrap_future( - self.participants - .send_event_to_participant(to_member_id, event), + self.members.send_event_to_member(to_member_id, event), ))) } /// Create [`Peer`]s between [`Member`]s and interconnect it by control /// API spec. - fn connect_participants( + fn connect_members( &mut self, first_member: &Member, second_member: &Member, @@ -322,44 +318,34 @@ impl Room { /// Availability is determines by checking [`RpcConnection`] of all /// [`Member`]s from [`WebRtcPlayEndpoint`]s and from receivers of /// connected [`Member`]. - fn init_participant_connections( + fn init_member_connections( &mut self, - participant: &Member, + member: &Member, ctx: &mut ::Context, ) { // Create all connected publish endpoints. - for (_, publish) in participant.publishers() { + for (_, publish) in member.publishers() { for receiver in publish.receivers() { let receiver_owner = receiver.owner(); - if self - .participants - .participant_has_connection(&receiver_owner.id()) + if self.members.member_has_connection(&receiver_owner.id()) && !receiver.is_connected() { - self.connect_participants( - &participant, - &receiver_owner, - ctx, - ); + self.connect_members(&member, &receiver_owner, ctx); } } } // Create all connected play's receivers peers. - for (_, play) in participant.receivers() { + for (_, play) in member.receivers() { let plays_publisher_owner = play.publisher().owner(); if self - .participants - .participant_has_connection(&plays_publisher_owner.id()) + .members + .member_has_connection(&plays_publisher_owner.id()) && !play.is_connected() { - self.connect_participants( - &participant, - &plays_publisher_owner, - ctx, - ); + self.connect_members(&member, &plays_publisher_owner, ctx); } } } @@ -414,11 +400,8 @@ impl Handler for Room { msg: Authorize, _ctx: &mut Self::Context, ) -> Self::Result { - self.participants - .get_participant_by_id_and_credentials( - &msg.member_id, - &msg.credentials, - ) + self.members + .get_member_by_id_and_credentials(&msg.member_id, &msg.credentials) .map(|_| ()) } } @@ -448,10 +431,8 @@ impl Handler for Room { "Peers {:?} removed for member '{}'.", msg.peers_id, msg.member_id ); - if let Some(participant) = - self.participants.get_participant_by_id(&msg.member_id) - { - participant.peers_removed(&msg.peers_id); + if let Some(member) = self.members.get_member_by_id(&msg.member_id) { + member.peers_removed(&msg.peers_id); } else { error!( "Participant with id {} for which received \ @@ -541,13 +522,13 @@ impl Handler for Room { let member_id = msg.member_id; let fut = self - .participants + .members .connection_established(ctx, member_id.clone(), msg.connection) .map_err(|err, _, _| { error!("RpcConnectionEstablished error {:?}", err) }) - .map(move |participant, room, ctx| { - room.init_participant_connections(&participant, ctx); + .map(move |member, room, ctx| { + room.init_member_connections(&member, ctx); }); Box::new(fut) } @@ -570,7 +551,7 @@ impl Handler for Room { ctx: &mut Self::Context, ) -> Self::Result { info!("Closing Room [id = {:?}]", self.id); - let drop_fut = self.participants.drop_connections(ctx); + let drop_fut = self.members.drop_connections(ctx); ctx.wait(wrap_future(drop_fut)); } } @@ -590,7 +571,7 @@ impl Handler for Room { self.peers.connection_closed(&msg.member_id, ctx); } - self.participants + self.members .connection_closed(ctx, msg.member_id, &msg.reason); } } From 88d587764118a88c90e3a7de86b999b95660b062 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 1 Jul 2019 14:22:16 +0300 Subject: [PATCH 220/735] Rename receivers to sinks --- src/media/peer.rs | 2 +- src/signalling/control/endpoint.rs | 41 ++++++++++++++---------------- src/signalling/control/member.rs | 18 ++++++------- src/signalling/room.rs | 2 +- 4 files changed, 30 insertions(+), 33 deletions(-) diff --git a/src/media/peer.rs b/src/media/peer.rs index 8fdb5b1b1..919929559 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -269,7 +269,7 @@ impl Peer { .into_iter() .flat_map(|(_m, e)| { e.add_peer_id(self_id); - e.receivers().into_iter().filter(|e| { + e.sinks().into_iter().filter(|e| { e.owner().id() == partner_id && !e.is_connected() }) }) diff --git a/src/signalling/control/endpoint.rs b/src/signalling/control/endpoint.rs index cb00796dc..f08928c51 100644 --- a/src/signalling/control/endpoint.rs +++ b/src/signalling/control/endpoint.rs @@ -94,7 +94,7 @@ impl WebRtcPlayEndpointInner { impl Drop for WebRtcPlayEndpointInner { fn drop(&mut self) { if let Some(receiver_publisher) = self.publisher.upgrade() { - receiver_publisher.remove_empty_weaks_from_receivers(); + receiver_publisher.remove_empty_weaks_from_sinks(); } } } @@ -177,8 +177,8 @@ struct WebRtcPublishEndpointInner { /// P2P connection mode for this [`WebRtcPublishEndpoint`]. p2p: P2pMode, - /// All receivers of this [`WebRtcPublishEndpoint`]. - receivers: Vec>, + /// All sinks of this [`WebRtcPublishEndpoint`]. + sinks: Vec>, /// Owner [`Member`] of this [`WebRtcPublishEndpoint`]. owner: Weak, @@ -194,7 +194,7 @@ struct WebRtcPublishEndpointInner { impl Drop for WebRtcPublishEndpointInner { fn drop(&mut self) { // TODO: add comments - for receiver in self.receivers.iter().filter_map(|r| Weak::upgrade(r)) { + for receiver in self.sinks.iter().filter_map(|r| Weak::upgrade(r)) { if let Some(receiver_owner) = receiver.weak_owner().upgrade() { receiver_owner.remove_receiver(&receiver.id()) } @@ -203,12 +203,12 @@ impl Drop for WebRtcPublishEndpointInner { } impl WebRtcPublishEndpointInner { - fn add_receiver(&mut self, receiver: Weak) { - self.receivers.push(receiver); + fn add_sinks(&mut self, sink: Weak) { + self.sinks.push(sink); } - fn receivers(&self) -> Vec> { - self.receivers + fn sinks(&self) -> Vec> { + self.sinks .iter() .map(|p| Weak::upgrade(p).unwrap()) .collect() @@ -252,26 +252,26 @@ impl WebRtcPublishEndpoint { pub fn new( id: Id, p2p: P2pMode, - receivers: Vec>, + sinks: Vec>, owner: Weak, ) -> Self { Self(RefCell::new(WebRtcPublishEndpointInner { id, p2p, - receivers, + sinks, owner, peer_ids: HashSet::new(), })) } - /// Add receiver for this [`WebRtcPublishEndpoint`]. - pub fn add_receiver(&self, receiver: Weak) { - self.0.borrow_mut().add_receiver(receiver) + /// Add sink for this [`WebRtcPublishEndpoint`]. + pub fn add_sink(&self, sink: Weak) { + self.0.borrow_mut().add_sinks(sink) } - /// Returns all receivers of this [`WebRtcPublishEndpoint`]. - pub fn receivers(&self) -> Vec> { - self.0.borrow().receivers() + /// Returns all sinks of this [`WebRtcPublishEndpoint`]. + pub fn sinks(&self) -> Vec> { + self.0.borrow().sinks() } /// Returns owner [`Member`] of this [`WebRtcPublishEndpoint`]. @@ -312,12 +312,9 @@ impl WebRtcPublishEndpoint { self.0.borrow().id.clone() } - /// Remove all empty Weak pointers from receivers of this + /// Remove all empty Weak pointers from sinks of this /// [`WebRtcPublishEndpoint`]. - pub fn remove_empty_weaks_from_receivers(&self) { - self.0 - .borrow_mut() - .receivers - .retain(|e| e.upgrade().is_some()); + pub fn remove_empty_weaks_from_sinks(&self) { + self.0.borrow_mut().sinks.retain(|e| e.upgrade().is_some()); } } diff --git a/src/signalling/control/member.rs b/src/signalling/control/member.rs index fbe2eaf09..6a6b67067 100644 --- a/src/signalling/control/member.rs +++ b/src/signalling/control/member.rs @@ -137,7 +137,7 @@ impl Member { self.insert_receiver(Rc::clone(&new_play_endpoint)); - publisher.add_receiver(Rc::downgrade(&new_play_endpoint)); + publisher.add_sink(Rc::downgrade(&new_play_endpoint)); } else { let new_publish_id = EndpointId(spec_play_endpoint.src.endpoint_id.to_string()); @@ -156,7 +156,7 @@ impl Member { Rc::downgrade(&this_member), )); - new_publish.add_receiver(Rc::downgrade(&new_self_play)); + new_publish.add_sink(Rc::downgrade(&new_self_play)); publisher_member.insert_publisher(new_publish); @@ -391,7 +391,7 @@ mod tests { responder.get_receiver_by_id(&id("play")).unwrap(); let is_caller_has_responder_in_receivers = caller_publish_endpoint - .receivers() + .sinks() .into_iter() .filter(|p| Rc::ptr_eq(p, &responder_play_endpoint)) .count() @@ -411,9 +411,9 @@ mod tests { responder.get_receiver_by_id(&id("play2")).unwrap(); let some_member_publisher = some_member.get_publisher_by_id(&id("publish")).unwrap(); - assert_eq!(some_member_publisher.receivers().len(), 1); + assert_eq!(some_member_publisher.sinks().len(), 1); let is_some_member_has_responder_in_receivers = some_member_publisher - .receivers() + .sinks() .into_iter() .filter(|p| Rc::ptr_eq(p, &responder_play2_endpoint)) .count() @@ -450,11 +450,11 @@ mod tests { some_member.get_publisher_by_id(&id("publish")).unwrap(); responder.remove_receiver(&id("play")); - assert_eq!(caller_publisher.receivers().len(), 0); - assert_eq!(some_member_publisher.receivers().len(), 1); + assert_eq!(caller_publisher.sinks().len(), 0); + assert_eq!(some_member_publisher.sinks().len(), 1); responder.remove_receiver(&id("play2")); - assert_eq!(caller_publisher.receivers().len(), 0); - assert_eq!(some_member_publisher.receivers().len(), 0); + assert_eq!(caller_publisher.sinks().len(), 0); + assert_eq!(some_member_publisher.sinks().len(), 0); } } diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 8321adc8f..c2c51519d 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -325,7 +325,7 @@ impl Room { ) { // Create all connected publish endpoints. for (_, publish) in member.publishers() { - for receiver in publish.receivers() { + for receiver in publish.sinks() { let receiver_owner = receiver.owner(); if self.members.member_has_connection(&receiver_owner.id()) From 8d33501f5463a78d1da85029da434807aec482e6 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 1 Jul 2019 14:28:54 +0300 Subject: [PATCH 221/735] Add some docs --- src/signalling/control/endpoint.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/signalling/control/endpoint.rs b/src/signalling/control/endpoint.rs index f08928c51..4ba3861c2 100644 --- a/src/signalling/control/endpoint.rs +++ b/src/signalling/control/endpoint.rs @@ -127,16 +127,21 @@ impl WebRtcPlayEndpoint { } /// Returns owner [`Member`] of this [`WebRtcPlayEndpoint`]. + /// + /// __This function will panic if pointer is empty.__ pub fn owner(&self) -> Rc { self.0.borrow().owner() } - // TODO: explain this + /// Returns `Weak` pointer to owner [`Member`] of this + /// [`WebRtcPlayEndpoint`]. pub fn weak_owner(&self) -> Weak { self.0.borrow().weak_owner() } /// Returns publisher's [`WebRtcPublishEndpoint`]. + /// + /// __This function will panic if pointer is empty.__ pub fn publisher(&self) -> Rc { self.0.borrow().publisher() } @@ -193,7 +198,6 @@ struct WebRtcPublishEndpointInner { impl Drop for WebRtcPublishEndpointInner { fn drop(&mut self) { - // TODO: add comments for receiver in self.sinks.iter().filter_map(|r| Weak::upgrade(r)) { if let Some(receiver_owner) = receiver.weak_owner().upgrade() { receiver_owner.remove_receiver(&receiver.id()) @@ -270,11 +274,15 @@ impl WebRtcPublishEndpoint { } /// Returns all sinks of this [`WebRtcPublishEndpoint`]. + /// + /// __This function will panic if meet empty pointer.__ pub fn sinks(&self) -> Vec> { self.0.borrow().sinks() } /// Returns owner [`Member`] of this [`WebRtcPublishEndpoint`]. + /// + /// __This function will panic if pointer is empty.__ pub fn owner(&self) -> Rc { self.0.borrow().owner() } From bfbc2c5a70fce60f16b71eee8253f905bf068806 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 1 Jul 2019 14:34:29 +0300 Subject: [PATCH 222/735] Add docs to Makefile --- Makefile | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 77d1f530c..9b90e4b83 100644 --- a/Makefile +++ b/Makefile @@ -149,11 +149,8 @@ endif # Run Rust e2e tests of project. # If logs set to "yes" then medea print all logs to stdout. # -# Defaults: -# dockerized=yes logs=no -# # Usage: -# make test.e2e [dockerized=(yes|no)] [logs=(yes|no)] +# make test.e2e [dockerized=(YES|no)] [logs=(yes|NO)] [coturn=(YES|no)] medea-env = RUST_BACKTRACE=1 \ MEDEA_SERVER.BIND_PORT=8081 \ From f69d9852692d97f4b4d76bdb1317fe0d7363921d Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 1 Jul 2019 14:50:12 +0300 Subject: [PATCH 223/735] Some fixes --- src/api/client/server.rs | 4 ++-- src/signalling/participants.rs | 11 +++++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/api/client/server.rs b/src/api/client/server.rs index 968d4c61b..f607661b9 100644 --- a/src/api/client/server.rs +++ b/src/api/client/server.rs @@ -39,7 +39,7 @@ struct RequestParams { /// Handles all HTTP requests, performs WebSocket handshake (upgrade) and starts /// new [`WsSession`] for WebSocket connection. fn ws_index( - r: HttpRequest, + request: HttpRequest, info: Path, state: Data, payload: Payload, @@ -60,7 +60,7 @@ fn ws_index( room, state.config.idle_timeout, ), - &r, + &request, payload, ), Err(AuthorizationError::MemberNotExists) => { diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 736ecb848..227fb4c52 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -1,5 +1,5 @@ -//! [`Member`] is member with [`RpcConnection`]. [`MemberService`] -//! stores [`Member`]s and associated [`RpcConnection`]s, handles +//! Participant is [`Member`] with [`RpcConnection`]. [`ParticipantService`] +//! stores [`Members`] and associated [`RpcConnection`]s, handles //! [`RpcConnection`] authorization, establishment, message sending, Turn //! credentials management. @@ -64,10 +64,9 @@ impl From for ParticipantServiceErr { } } -/// [`Member`] is member of [`Room`] with [`RpcConnection`]. -/// [`ParticipantService`] stores [`Member`]s and associated -/// [`RpcConnection`]s, handles [`RpcConnection`] authorization, establishment, -/// message sending. +/// Participant is [`Member`] with [`RpcConnection`]. [`ParticipantService`] +/// stores [`Member`]s and associated [`RpcConnection`]s, handles +/// [`RpcConnection`] authorization, establishment, message sending. #[derive(Debug)] pub struct ParticipantService { /// [`Room`]s id from which this [`ParticipantService`] was created. From 4ca6ac49aedb6b4a7a091fa4b91f4ae55f0a4f0e Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 3 Jul 2019 12:33:45 +0300 Subject: [PATCH 224/735] Separate endpoints and move their into separate path --- src/media/peer.rs | 4 +- src/signalling/control/member.rs | 45 +++-- src/signalling/control/mod.rs | 1 - src/signalling/elements/endpoints/mod.rs | 1 + .../elements/endpoints/webrtc/mod.rs | 7 + .../endpoints/webrtc/play_endpoint.rs | 173 ++++++++++++++++++ .../endpoints/webrtc/publish_endpoint.rs} | 153 +--------------- src/signalling/elements/mod.rs | 1 + src/signalling/mod.rs | 1 + 9 files changed, 215 insertions(+), 171 deletions(-) create mode 100644 src/signalling/elements/endpoints/mod.rs create mode 100644 src/signalling/elements/endpoints/webrtc/mod.rs create mode 100644 src/signalling/elements/endpoints/webrtc/play_endpoint.rs rename src/signalling/{control/endpoint.rs => elements/endpoints/webrtc/publish_endpoint.rs} (55%) create mode 100644 src/signalling/elements/mod.rs diff --git a/src/media/peer.rs b/src/media/peer.rs index 919929559..7cc2e8db8 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -17,7 +17,7 @@ use crate::{ api::control::MemberId, media::{MediaTrack, TrackId}, signalling::{ - control::endpoint::{Id as EndpointId, WebRtcPublishEndpoint}, + elements::endpoints::webrtc::{WebRtcPublishEndpoint, WebRtcPublishId}, peers::Counter, }, }; @@ -260,7 +260,7 @@ impl Peer { &mut self, partner_peer: &mut Peer, tracks_count: &mut Counter, - publish_endpoints: HashMap>, + publish_endpoints: HashMap>, ) { let partner_id = self.partner_member_id(); let self_id = self.id(); diff --git a/src/signalling/control/member.rs b/src/signalling/control/member.rs index 6a6b67067..a1e911cee 100644 --- a/src/signalling/control/member.rs +++ b/src/signalling/control/member.rs @@ -10,10 +10,10 @@ use crate::{ api::control::{MemberId, MemberSpec, RoomSpec, TryFromElementError}, log::prelude::*, media::{IceUser, PeerId}, -}; - -use super::endpoint::{ - Id as EndpointId, WebRtcPlayEndpoint, WebRtcPublishEndpoint, + signalling::elements::endpoints::webrtc::{ + WebRtcPlayEndpoint, WebRtcPlayId, WebRtcPublishEndpoint, + WebRtcPublishId, + }, }; /// Errors which may occur while loading [`Member`]s from [`RoomSpec`]. @@ -48,10 +48,10 @@ struct MemberInner { id: MemberId, /// All [`WebRtcPublishEndpoint`]s of this [`Member`]. - publishers: HashMap>, + publishers: HashMap>, /// All [`WebRtcPlayEndpoint`]s of this [`Member`]. - receivers: HashMap>, + receivers: HashMap>, /// Credentials for this [`Member`]. credentials: String, @@ -123,11 +123,13 @@ impl Member { Ok, )?; - if let Some(publisher) = publisher_member.get_publisher_by_id( - &EndpointId(spec_play_endpoint.src.endpoint_id.to_string()), - ) { + if let Some(publisher) = + publisher_member.get_publisher_by_id(&WebRtcPublishId( + spec_play_endpoint.src.endpoint_id.to_string(), + )) + { let new_play_endpoint_id = - EndpointId(spec_play_name.to_string()); + WebRtcPlayId(spec_play_name.to_string()); let new_play_endpoint = Rc::new(WebRtcPlayEndpoint::new( new_play_endpoint_id.clone(), spec_play_endpoint.src.clone(), @@ -139,8 +141,9 @@ impl Member { publisher.add_sink(Rc::downgrade(&new_play_endpoint)); } else { - let new_publish_id = - EndpointId(spec_play_endpoint.src.endpoint_id.to_string()); + let new_publish_id = WebRtcPublishId( + spec_play_endpoint.src.endpoint_id.to_string(), + ); let new_publish = Rc::new(WebRtcPublishEndpoint::new( new_publish_id.clone(), publisher_endpoint.p2p.clone(), @@ -148,7 +151,7 @@ impl Member { Rc::downgrade(&publisher_member), )); - let new_self_play_id = EndpointId(spec_play_name.to_string()); + let new_self_play_id = WebRtcPlayId(spec_play_name.to_string()); let new_self_play = Rc::new(WebRtcPlayEndpoint::new( new_self_play_id.clone(), spec_play_endpoint.src.clone(), @@ -168,7 +171,7 @@ impl Member { // to which none [`WebRtcPlayEndpoint`] refers. this_member_spec.publish_endpoints().into_iter().for_each( |(name, e)| { - let endpoint_id = EndpointId(name.clone()); + let endpoint_id = WebRtcPublishId(name.clone()); if self.publishers().get(&endpoint_id).is_none() { self.insert_publisher(Rc::new(WebRtcPublishEndpoint::new( endpoint_id, @@ -224,12 +227,14 @@ impl Member { } /// Returns all publishers of this [`Member`]. - pub fn publishers(&self) -> HashMap> { + pub fn publishers( + &self, + ) -> HashMap> { self.0.borrow().publishers.clone() } /// Returns all receivers of this [`Member`]. - pub fn receivers(&self) -> HashMap> { + pub fn receivers(&self) -> HashMap> { self.0.borrow().receivers.clone() } @@ -252,7 +257,7 @@ impl Member { /// Lookup [`WebRtcPublishEndpoint`] publisher by [`EndpointId`]. pub fn get_publisher_by_id( &self, - id: &EndpointId, + id: &WebRtcPublishId, ) -> Option> { self.0.borrow().publishers.get(id).cloned() } @@ -260,18 +265,18 @@ impl Member { /// Lookup [`WebRtcPlayEndpoint`] receiver by [`EndpointId`]. pub fn get_receiver_by_id( &self, - id: &EndpointId, + id: &WebRtcPlayId, ) -> Option> { self.0.borrow().receivers.get(id).cloned() } /// Remove receiver [`WebRtcPlayEndpoint`] from this [`Member`]. - pub fn remove_receiver(&self, id: &EndpointId) { + pub fn remove_receiver(&self, id: &WebRtcPlayId) { self.0.borrow_mut().receivers.remove(id); } /// Remove receiver [`WebRtcPublishEndpoint`] from this [`Member`]. - pub fn remove_publisher(&self, id: &EndpointId) { + pub fn remove_publisher(&self, id: &WebRtcPublishId) { self.0.borrow_mut().publishers.remove(id); } } diff --git a/src/signalling/control/mod.rs b/src/signalling/control/mod.rs index d1ca7fa6f..fe423410e 100644 --- a/src/signalling/control/mod.rs +++ b/src/signalling/control/mod.rs @@ -1,6 +1,5 @@ //! Signalling representation of control spec. -pub mod endpoint; pub mod member; #[doc(inline)] diff --git a/src/signalling/elements/endpoints/mod.rs b/src/signalling/elements/endpoints/mod.rs new file mode 100644 index 000000000..c050ca143 --- /dev/null +++ b/src/signalling/elements/endpoints/mod.rs @@ -0,0 +1 @@ +pub mod webrtc; diff --git a/src/signalling/elements/endpoints/webrtc/mod.rs b/src/signalling/elements/endpoints/webrtc/mod.rs new file mode 100644 index 000000000..53ad4caab --- /dev/null +++ b/src/signalling/elements/endpoints/webrtc/mod.rs @@ -0,0 +1,7 @@ +pub mod play_endpoint; +pub mod publish_endpoint; + +#[doc(inline)] +pub use play_endpoint::{WebRtcPlayEndpoint, WebRtcPlayId}; +#[doc(inline)] +pub use publish_endpoint::{WebRtcPublishEndpoint, WebRtcPublishId}; diff --git a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs new file mode 100644 index 000000000..0e66836cb --- /dev/null +++ b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs @@ -0,0 +1,173 @@ +use std::{ + cell::RefCell, + fmt::Display, + rc::{Rc, Weak}, +}; + +use crate::{ + api::control::endpoint::SrcUri, media::PeerId, + signalling::control::member::Member, +}; + +use super::publish_endpoint::WebRtcPublishEndpoint; + +pub use Id as WebRtcPlayId; + +/// ID of endpoint. +#[derive(Clone, Debug, Eq, Hash, PartialEq)] +pub struct Id(pub String); + +impl Display for Id { + fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(fmt, "{}", self.0) + } +} + +impl From for Id { + fn from(s: String) -> Self { + Self(s) + } +} + +#[derive(Debug, Clone)] +struct WebRtcPlayEndpointInner { + /// ID of this [`WebRtcPlayEndpoint`]. + id: Id, + + /// Source URI of [`WebRtcPublishEndpoint`] from which this + /// [`WebRtcPlayEndpoint`] receive data. + src: SrcUri, + + /// Publisher [`WebRtcPublishEndpoint`] from which this + /// [`WebRtcPlayEndpoint`] receive data. + publisher: Weak, + + /// Owner [`Member`] of this [`WebRtcPlayEndpoint`]. + owner: Weak, + + /// [`PeerId`] of [`Peer`] created for this [`WebRtcPlayEndpoint`]. + /// + /// Currently this field used for detecting status of this + /// [`WebRtcPlayEndpoint`] connection. + /// + /// In future this may be used for removing [`WebRtcPlayEndpoint`] + /// and related peer. + peer_id: Option, +} + +impl WebRtcPlayEndpointInner { + fn src(&self) -> SrcUri { + self.src.clone() + } + + fn owner(&self) -> Rc { + Weak::upgrade(&self.owner).unwrap() + } + + fn weak_owner(&self) -> Weak { + Weak::clone(&self.owner) + } + + fn publisher(&self) -> Rc { + Weak::upgrade(&self.publisher).unwrap() + } + + fn is_connected(&self) -> bool { + self.peer_id.is_some() + } + + fn set_peer_id(&mut self, peer_id: PeerId) { + self.peer_id = Some(peer_id) + } + + fn peer_id(&self) -> Option { + self.peer_id + } + + fn reset(&mut self) { + self.peer_id = None + } +} + +impl Drop for WebRtcPlayEndpointInner { + fn drop(&mut self) { + if let Some(receiver_publisher) = self.publisher.upgrade() { + receiver_publisher.remove_empty_weaks_from_sinks(); + } + } +} + +/// Signalling representation of `WebRtcPlayEndpoint`. +#[allow(clippy::module_name_repetitions)] +#[derive(Debug)] +pub struct WebRtcPlayEndpoint(RefCell); + +impl WebRtcPlayEndpoint { + /// Create new [`WebRtcPlayEndpoint`]. + pub fn new( + id: Id, + src: SrcUri, + publisher: Weak, + owner: Weak, + ) -> Self { + Self(RefCell::new(WebRtcPlayEndpointInner { + id, + src, + publisher, + owner, + peer_id: None, + })) + } + + /// Returns [`SrcUri`] of this [`WebRtcPlayEndpoint`]. + pub fn src(&self) -> SrcUri { + self.0.borrow().src() + } + + /// Returns owner [`Member`] of this [`WebRtcPlayEndpoint`]. + /// + /// __This function will panic if pointer is empty.__ + pub fn owner(&self) -> Rc { + self.0.borrow().owner() + } + + /// Returns `Weak` pointer to owner [`Member`] of this + /// [`WebRtcPlayEndpoint`]. + pub fn weak_owner(&self) -> Weak { + self.0.borrow().weak_owner() + } + + /// Returns publisher's [`WebRtcPublishEndpoint`]. + /// + /// __This function will panic if pointer is empty.__ + pub fn publisher(&self) -> Rc { + self.0.borrow().publisher() + } + + /// Check that peer connection established for this [`WebRtcPlayEndpoint`]. + pub fn is_connected(&self) -> bool { + self.0.borrow().is_connected() + } + + /// Save [`PeerId`] of this [`WebRtcPlayEndpoint`]. + pub fn connect(&self, peer_id: PeerId) { + self.0.borrow_mut().set_peer_id(peer_id); + } + + /// Return [`PeerId`] of [`Peer`] of this [`WebRtcPlayEndpoint`]. + pub fn peer_id(&self) -> Option { + self.0.borrow().peer_id() + } + + /// Reset state of this [`WebRtcPlayEndpoint`]. + /// + /// Atm this only reset peer_id. + pub fn reset(&self) { + self.0.borrow_mut().reset() + } + + /// Returns ID of this [`WebRtcPlayEndpoint`]. + pub fn id(&self) -> Id { + self.0.borrow().id.clone() + } +} diff --git a/src/signalling/control/endpoint.rs b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs similarity index 55% rename from src/signalling/control/endpoint.rs rename to src/signalling/elements/endpoints/webrtc/publish_endpoint.rs index 4ba3861c2..c35f7ae55 100644 --- a/src/signalling/control/endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs @@ -1,5 +1,3 @@ -//! Signalling representation of endpoints. - use std::{ cell::RefCell, fmt::Display, @@ -9,11 +7,13 @@ use std::{ use hashbrown::HashSet; use crate::{ - api::control::endpoint::{P2pMode, SrcUri}, - media::PeerId, + api::control::endpoint::P2pMode, media::PeerId, + signalling::control::member::Member, }; -use super::member::Member; +use super::play_endpoint::WebRtcPlayEndpoint; + +pub use Id as WebRtcPublishId; /// ID of endpoint. #[derive(Clone, Debug, Eq, Hash, PartialEq)] @@ -31,149 +31,6 @@ impl From for Id { } } -#[derive(Debug, Clone)] -struct WebRtcPlayEndpointInner { - /// ID of this [`WebRtcPlayEndpoint`]. - id: Id, - - /// Source URI of [`WebRtcPublishEndpoint`] from which this - /// [`WebRtcPlayEndpoint`] receive data. - src: SrcUri, - - /// Publisher [`WebRtcPublishEndpoint`] from which this - /// [`WebRtcPlayEndpoint`] receive data. - publisher: Weak, - - /// Owner [`Member`] of this [`WebRtcPlayEndpoint`]. - owner: Weak, - - /// [`PeerId`] of [`Peer`] created for this [`WebRtcPlayEndpoint`]. - /// - /// Currently this field used for detecting status of this - /// [`WebRtcPlayEndpoint`] connection. - /// - /// In future this may be used for removing [`WebRtcPlayEndpoint`] - /// and related peer. - peer_id: Option, -} - -impl WebRtcPlayEndpointInner { - fn src(&self) -> SrcUri { - self.src.clone() - } - - fn owner(&self) -> Rc { - Weak::upgrade(&self.owner).unwrap() - } - - fn weak_owner(&self) -> Weak { - Weak::clone(&self.owner) - } - - fn publisher(&self) -> Rc { - Weak::upgrade(&self.publisher).unwrap() - } - - fn is_connected(&self) -> bool { - self.peer_id.is_some() - } - - fn set_peer_id(&mut self, peer_id: PeerId) { - self.peer_id = Some(peer_id) - } - - fn peer_id(&self) -> Option { - self.peer_id - } - - fn reset(&mut self) { - self.peer_id = None - } -} - -impl Drop for WebRtcPlayEndpointInner { - fn drop(&mut self) { - if let Some(receiver_publisher) = self.publisher.upgrade() { - receiver_publisher.remove_empty_weaks_from_sinks(); - } - } -} - -/// Signalling representation of `WebRtcPlayEndpoint`. -#[allow(clippy::module_name_repetitions)] -#[derive(Debug)] -pub struct WebRtcPlayEndpoint(RefCell); - -impl WebRtcPlayEndpoint { - /// Create new [`WebRtcPlayEndpoint`]. - pub fn new( - id: Id, - src: SrcUri, - publisher: Weak, - owner: Weak, - ) -> Self { - Self(RefCell::new(WebRtcPlayEndpointInner { - id, - src, - publisher, - owner, - peer_id: None, - })) - } - - /// Returns [`SrcUri`] of this [`WebRtcPlayEndpoint`]. - pub fn src(&self) -> SrcUri { - self.0.borrow().src() - } - - /// Returns owner [`Member`] of this [`WebRtcPlayEndpoint`]. - /// - /// __This function will panic if pointer is empty.__ - pub fn owner(&self) -> Rc { - self.0.borrow().owner() - } - - /// Returns `Weak` pointer to owner [`Member`] of this - /// [`WebRtcPlayEndpoint`]. - pub fn weak_owner(&self) -> Weak { - self.0.borrow().weak_owner() - } - - /// Returns publisher's [`WebRtcPublishEndpoint`]. - /// - /// __This function will panic if pointer is empty.__ - pub fn publisher(&self) -> Rc { - self.0.borrow().publisher() - } - - /// Check that peer connection established for this [`WebRtcPlayEndpoint`]. - pub fn is_connected(&self) -> bool { - self.0.borrow().is_connected() - } - - /// Save [`PeerId`] of this [`WebRtcPlayEndpoint`]. - pub fn connect(&self, peer_id: PeerId) { - self.0.borrow_mut().set_peer_id(peer_id); - } - - /// Return [`PeerId`] of [`Peer`] of this [`WebRtcPlayEndpoint`]. - pub fn peer_id(&self) -> Option { - self.0.borrow().peer_id() - } - - /// Reset state of this [`WebRtcPlayEndpoint`]. - /// - /// Atm this only reset peer_id. - pub fn reset(&self) { - self.0.borrow_mut().reset() - } - - /// Returns ID of this [`WebRtcPlayEndpoint`]. - pub fn id(&self) -> Id { - self.0.borrow().id.clone() - } -} - #[derive(Debug, Clone)] struct WebRtcPublishEndpointInner { /// ID of this [`WebRtcPublishEndpoint`]. diff --git a/src/signalling/elements/mod.rs b/src/signalling/elements/mod.rs new file mode 100644 index 000000000..c4b360f4b --- /dev/null +++ b/src/signalling/elements/mod.rs @@ -0,0 +1 @@ +pub mod endpoints; diff --git a/src/signalling/mod.rs b/src/signalling/mod.rs index 2b8f6a1ab..27f712cea 100644 --- a/src/signalling/mod.rs +++ b/src/signalling/mod.rs @@ -1,4 +1,5 @@ pub mod control; +pub mod elements; pub mod participants; pub mod peers; pub mod room; From 86f9df32ff7616ec573ffafcc12a42c3d6601cf6 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 3 Jul 2019 12:49:06 +0300 Subject: [PATCH 225/735] Rename publisher into srcs and receivers into sinks --- src/signalling/control/member.rs | 125 ++++++++---------- .../endpoints/webrtc/publish_endpoint.rs | 2 +- src/signalling/peers.rs | 4 +- src/signalling/room.rs | 4 +- 4 files changed, 63 insertions(+), 72 deletions(-) diff --git a/src/signalling/control/member.rs b/src/signalling/control/member.rs index a1e911cee..84f0a469c 100644 --- a/src/signalling/control/member.rs +++ b/src/signalling/control/member.rs @@ -48,10 +48,10 @@ struct MemberInner { id: MemberId, /// All [`WebRtcPublishEndpoint`]s of this [`Member`]. - publishers: HashMap>, + srcs: HashMap>, /// All [`WebRtcPlayEndpoint`]s of this [`Member`]. - receivers: HashMap>, + sinks: HashMap>, /// Credentials for this [`Member`]. credentials: String, @@ -68,14 +68,14 @@ impl Member { fn new(id: MemberId, credentials: String) -> Self { Self(RefCell::new(MemberInner { id, - publishers: HashMap::new(), - receivers: HashMap::new(), + srcs: HashMap::new(), + sinks: HashMap::new(), credentials, ice_user: None, })) } - /// Load all publishers and receivers of this [`Member`]. + /// Load all srcs and sinks of this [`Member`]. fn load( &self, room_spec: &RoomSpec, @@ -124,7 +124,7 @@ impl Member { )?; if let Some(publisher) = - publisher_member.get_publisher_by_id(&WebRtcPublishId( + publisher_member.get_src_by_id(&WebRtcPublishId( spec_play_endpoint.src.endpoint_id.to_string(), )) { @@ -137,7 +137,7 @@ impl Member { Rc::downgrade(&this_member), )); - self.insert_receiver(Rc::clone(&new_play_endpoint)); + self.insert_sink(Rc::clone(&new_play_endpoint)); publisher.add_sink(Rc::downgrade(&new_play_endpoint)); } else { @@ -161,9 +161,9 @@ impl Member { new_publish.add_sink(Rc::downgrade(&new_self_play)); - publisher_member.insert_publisher(new_publish); + publisher_member.insert_src(new_publish); - self.insert_receiver(new_self_play); + self.insert_sink(new_self_play); } } @@ -172,8 +172,8 @@ impl Member { this_member_spec.publish_endpoints().into_iter().for_each( |(name, e)| { let endpoint_id = WebRtcPublishId(name.clone()); - if self.publishers().get(&endpoint_id).is_none() { - self.insert_publisher(Rc::new(WebRtcPublishEndpoint::new( + if self.srcs().get(&endpoint_id).is_none() { + self.insert_src(Rc::new(WebRtcPublishEndpoint::new( endpoint_id, e.p2p.clone(), Vec::new(), @@ -190,11 +190,11 @@ impl Member { /// /// All [`PeerId`]s related to this [`Member`] will be removed. pub fn peers_removed(&self, peer_ids: &[PeerId]) { - self.publishers() + self.srcs() .into_iter() .for_each(|(_, p)| p.remove_peer_ids(peer_ids)); - self.receivers() + self.sinks() .into_iter() .filter_map(|(_, p)| p.peer_id().map(|id| (id, p))) .filter(|(id, _)| peer_ids.contains(&id)) @@ -227,62 +227,54 @@ impl Member { } /// Returns all publishers of this [`Member`]. - pub fn publishers( - &self, - ) -> HashMap> { - self.0.borrow().publishers.clone() + pub fn srcs(&self) -> HashMap> { + self.0.borrow().srcs.clone() } - /// Returns all receivers of this [`Member`]. - pub fn receivers(&self) -> HashMap> { - self.0.borrow().receivers.clone() + /// Returns all sinks endpoints of this [`Member`]. + pub fn sinks(&self) -> HashMap> { + self.0.borrow().sinks.clone() } - /// Insert receiver into this [`Member`]. - pub fn insert_receiver(&self, endpoint: Rc) { - self.0 - .borrow_mut() - .receivers - .insert(endpoint.id(), endpoint); + /// Insert sink endpoint into this [`Member`]. + pub fn insert_sink(&self, endpoint: Rc) { + self.0.borrow_mut().sinks.insert(endpoint.id(), endpoint); } - /// Insert publisher into this [`Member`]. - pub fn insert_publisher(&self, endpoint: Rc) { - self.0 - .borrow_mut() - .publishers - .insert(endpoint.id(), endpoint); + /// Insert source endpoint into this [`Member`]. + pub fn insert_src(&self, endpoint: Rc) { + self.0.borrow_mut().srcs.insert(endpoint.id(), endpoint); } - /// Lookup [`WebRtcPublishEndpoint`] publisher by [`EndpointId`]. - pub fn get_publisher_by_id( + /// Lookup [`WebRtcPublishEndpoint`] source endpoint by [`EndpointId`]. + pub fn get_src_by_id( &self, id: &WebRtcPublishId, ) -> Option> { - self.0.borrow().publishers.get(id).cloned() + self.0.borrow().srcs.get(id).cloned() } - /// Lookup [`WebRtcPlayEndpoint`] receiver by [`EndpointId`]. - pub fn get_receiver_by_id( + /// Lookup [`WebRtcPlayEndpoint`] sink endpoint by [`EndpointId`]. + pub fn get_sink_by_id( &self, id: &WebRtcPlayId, ) -> Option> { - self.0.borrow().receivers.get(id).cloned() + self.0.borrow().sinks.get(id).cloned() } - /// Remove receiver [`WebRtcPlayEndpoint`] from this [`Member`]. - pub fn remove_receiver(&self, id: &WebRtcPlayId) { - self.0.borrow_mut().receivers.remove(id); + /// Remove sink [`WebRtcPlayEndpoint`] from this [`Member`]. + pub fn remove_sink(&self, id: &WebRtcPlayId) { + self.0.borrow_mut().sinks.remove(id); } - /// Remove receiver [`WebRtcPublishEndpoint`] from this [`Member`]. - pub fn remove_publisher(&self, id: &WebRtcPublishId) { - self.0.borrow_mut().publishers.remove(id); + /// Remove source [`WebRtcPublishEndpoint`] from this [`Member`]. + pub fn remove_src(&self, id: &WebRtcPublishId) { + self.0.borrow_mut().srcs.remove(id); } } /// Creates all empty [`Member`] from [`RoomSpec`] and then -/// load all related to this [`Member`]s receivers and publishers. +/// load all related to this [`Member`]s srcs and sinks endpoints. /// /// Returns store of all [`Member`]s loaded from [`RoomSpec`]. pub fn parse_members( @@ -308,13 +300,13 @@ pub fn parse_members( .iter() .map(|(id, p)| { format!( - "{{ id: {}, receivers: {:?}, publishers: {:?} }};", + "{{ id: {}, sinks: {:?}, srcs: {:?} }};", id, - p.receivers() + p.sinks() .into_iter() .map(|(id, _)| id.to_string()) .collect::>(), - p.publishers() + p.srcs() .into_iter() .map(|(id, _)| id.to_string()) .collect::>() @@ -391,17 +383,17 @@ mod tests { let responder = store.get(&id("responder")).unwrap(); let caller_publish_endpoint = - caller.get_publisher_by_id(&id("publish")).unwrap(); + caller.get_src_by_id(&id("publish")).unwrap(); let responder_play_endpoint = - responder.get_receiver_by_id(&id("play")).unwrap(); + responder.get_sink_by_id(&id("play")).unwrap(); - let is_caller_has_responder_in_receivers = caller_publish_endpoint + let is_caller_has_responder_in_sinks = caller_publish_endpoint .sinks() .into_iter() .filter(|p| Rc::ptr_eq(p, &responder_play_endpoint)) .count() == 1; - assert!(is_caller_has_responder_in_receivers); + assert!(is_caller_has_responder_in_sinks); assert!(Rc::ptr_eq( &responder_play_endpoint.publisher(), @@ -409,21 +401,21 @@ mod tests { )); let some_member = store.get(&id("some-member")).unwrap(); - assert!(some_member.receivers().is_empty()); - assert_eq!(some_member.publishers().len(), 1); + assert!(some_member.sinks().is_empty()); + assert_eq!(some_member.srcs().len(), 1); let responder_play2_endpoint = - responder.get_receiver_by_id(&id("play2")).unwrap(); + responder.get_sink_by_id(&id("play2")).unwrap(); let some_member_publisher = - some_member.get_publisher_by_id(&id("publish")).unwrap(); + some_member.get_src_by_id(&id("publish")).unwrap(); assert_eq!(some_member_publisher.sinks().len(), 1); - let is_some_member_has_responder_in_receivers = some_member_publisher + let is_some_member_has_responder_in_sinks = some_member_publisher .sinks() .into_iter() .filter(|p| Rc::ptr_eq(p, &responder_play2_endpoint)) .count() == 1; - assert!(is_some_member_has_responder_in_receivers); + assert!(is_some_member_has_responder_in_sinks); } #[test] @@ -434,11 +426,11 @@ mod tests { let some_member = store.get(&id("some-member")).unwrap(); let responder = store.get(&id("responder")).unwrap(); - caller.remove_publisher(&id("publish")); - assert_eq!(responder.receivers().len(), 1); + caller.remove_src(&id("publish")); + assert_eq!(responder.sinks().len(), 1); - some_member.remove_publisher(&id("publish")); - assert_eq!(responder.receivers().len(), 0); + some_member.remove_src(&id("publish")); + assert_eq!(responder.sinks().len(), 0); } #[test] @@ -449,16 +441,15 @@ mod tests { let some_member = store.get(&id("some-member")).unwrap(); let responder = store.get(&id("responder")).unwrap(); - let caller_publisher = - caller.get_publisher_by_id(&id("publish")).unwrap(); + let caller_publisher = caller.get_src_by_id(&id("publish")).unwrap(); let some_member_publisher = - some_member.get_publisher_by_id(&id("publish")).unwrap(); + some_member.get_src_by_id(&id("publish")).unwrap(); - responder.remove_receiver(&id("play")); + responder.remove_sink(&id("play")); assert_eq!(caller_publisher.sinks().len(), 0); assert_eq!(some_member_publisher.sinks().len(), 1); - responder.remove_receiver(&id("play2")); + responder.remove_sink(&id("play2")); assert_eq!(caller_publisher.sinks().len(), 0); assert_eq!(some_member_publisher.sinks().len(), 0); } diff --git a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs index c35f7ae55..9f5e54e68 100644 --- a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs @@ -57,7 +57,7 @@ impl Drop for WebRtcPublishEndpointInner { fn drop(&mut self) { for receiver in self.sinks.iter().filter_map(|r| Weak::upgrade(r)) { if let Some(receiver_owner) = receiver.weak_owner().upgrade() { - receiver_owner.remove_receiver(&receiver.id()) + receiver_owner.remove_sink(&receiver.id()) } } } diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index ebcd8f547..fb7d4c918 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -101,12 +101,12 @@ impl PeerRepository { first_peer.add_publish_endpoints( &mut second_peer, &mut self.tracks_count, - first_member.publishers(), + first_member.srcs(), ); second_peer.add_publish_endpoints( &mut first_peer, &mut self.tracks_count, - second_member.publishers(), + second_member.srcs(), ); self.add_peer(first_peer); diff --git a/src/signalling/room.rs b/src/signalling/room.rs index c2c51519d..8d290f635 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -324,7 +324,7 @@ impl Room { ctx: &mut ::Context, ) { // Create all connected publish endpoints. - for (_, publish) in member.publishers() { + for (_, publish) in member.srcs() { for receiver in publish.sinks() { let receiver_owner = receiver.owner(); @@ -337,7 +337,7 @@ impl Room { } // Create all connected play's receivers peers. - for (_, play) in member.receivers() { + for (_, play) in member.sinks() { let plays_publisher_owner = play.publisher().owner(); if self From 8295d6441860fcd55b4143eb48d9c0553a38f302 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 3 Jul 2019 12:54:25 +0300 Subject: [PATCH 226/735] Rename WebRtcPlayEndpoint::publisher into src --- src/signalling/control/member.rs | 2 +- .../endpoints/webrtc/play_endpoint.rs | 30 +++++++++---------- src/signalling/room.rs | 2 +- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/signalling/control/member.rs b/src/signalling/control/member.rs index 84f0a469c..f220acfd0 100644 --- a/src/signalling/control/member.rs +++ b/src/signalling/control/member.rs @@ -396,7 +396,7 @@ mod tests { assert!(is_caller_has_responder_in_sinks); assert!(Rc::ptr_eq( - &responder_play_endpoint.publisher(), + &responder_play_endpoint.src(), &caller_publish_endpoint )); diff --git a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs index 0e66836cb..3a250f887 100644 --- a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs @@ -36,11 +36,11 @@ struct WebRtcPlayEndpointInner { /// Source URI of [`WebRtcPublishEndpoint`] from which this /// [`WebRtcPlayEndpoint`] receive data. - src: SrcUri, + src_uri: SrcUri, /// Publisher [`WebRtcPublishEndpoint`] from which this /// [`WebRtcPlayEndpoint`] receive data. - publisher: Weak, + src: Weak, /// Owner [`Member`] of this [`WebRtcPlayEndpoint`]. owner: Weak, @@ -56,8 +56,8 @@ struct WebRtcPlayEndpointInner { } impl WebRtcPlayEndpointInner { - fn src(&self) -> SrcUri { - self.src.clone() + fn src_uri(&self) -> SrcUri { + self.src_uri.clone() } fn owner(&self) -> Rc { @@ -68,8 +68,8 @@ impl WebRtcPlayEndpointInner { Weak::clone(&self.owner) } - fn publisher(&self) -> Rc { - Weak::upgrade(&self.publisher).unwrap() + fn src(&self) -> Rc { + Weak::upgrade(&self.src).unwrap() } fn is_connected(&self) -> bool { @@ -91,7 +91,7 @@ impl WebRtcPlayEndpointInner { impl Drop for WebRtcPlayEndpointInner { fn drop(&mut self) { - if let Some(receiver_publisher) = self.publisher.upgrade() { + if let Some(receiver_publisher) = self.src.upgrade() { receiver_publisher.remove_empty_weaks_from_sinks(); } } @@ -106,22 +106,22 @@ impl WebRtcPlayEndpoint { /// Create new [`WebRtcPlayEndpoint`]. pub fn new( id: Id, - src: SrcUri, + src_uri: SrcUri, publisher: Weak, owner: Weak, ) -> Self { Self(RefCell::new(WebRtcPlayEndpointInner { id, - src, - publisher, + src_uri, + src: publisher, owner, peer_id: None, })) } /// Returns [`SrcUri`] of this [`WebRtcPlayEndpoint`]. - pub fn src(&self) -> SrcUri { - self.0.borrow().src() + pub fn src_uri(&self) -> SrcUri { + self.0.borrow().src_uri() } /// Returns owner [`Member`] of this [`WebRtcPlayEndpoint`]. @@ -137,11 +137,11 @@ impl WebRtcPlayEndpoint { self.0.borrow().weak_owner() } - /// Returns publisher's [`WebRtcPublishEndpoint`]. + /// Returns source's [`WebRtcPublishEndpoint`]. /// /// __This function will panic if pointer is empty.__ - pub fn publisher(&self) -> Rc { - self.0.borrow().publisher() + pub fn src(&self) -> Rc { + self.0.borrow().src() } /// Check that peer connection established for this [`WebRtcPlayEndpoint`]. diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 8d290f635..504641ef2 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -338,7 +338,7 @@ impl Room { // Create all connected play's receivers peers. for (_, play) in member.sinks() { - let plays_publisher_owner = play.publisher().owner(); + let plays_publisher_owner = play.src().owner(); if self .members From fd81e671a83b37a7400126d451ce688932342125 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 3 Jul 2019 13:16:01 +0300 Subject: [PATCH 227/735] Use newtype_derive --- src/api/control/member.rs | 31 ++++++++++--------- .../endpoints/webrtc/play_endpoint.rs | 22 +++++-------- .../endpoints/webrtc/publish_endpoint.rs | 21 ++++--------- 3 files changed, 29 insertions(+), 45 deletions(-) diff --git a/src/api/control/member.rs b/src/api/control/member.rs index 961e31598..530a22da8 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -1,8 +1,10 @@ //! Member definitions and implementations. -use std::{convert::TryFrom, fmt::Display}; +use std::convert::TryFrom; use hashbrown::HashMap; +use macro_attr::*; +use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; use serde::Deserialize; use super::{ @@ -11,20 +13,19 @@ use super::{ Element, TryFromElementError, }; -/// ID of `Member`. -#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq)] -pub struct Id(pub String); - -impl Display for Id { - fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(fmt, "{}", self.0) - } -} - -impl From for Id { - fn from(s: String) -> Self { - Self(s) - } +macro_attr! { + /// ID of `Member`. + #[derive( + Clone, + Debug, + Deserialize, + Eq, + Hash, + PartialEq, + NewtypeFrom!, + NewtypeDisplay! + )] + pub struct Id(pub String); } /// Newtype for [`Element::Member`] variant. diff --git a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs index 3a250f887..d605acff1 100644 --- a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs @@ -1,9 +1,11 @@ use std::{ cell::RefCell, - fmt::Display, rc::{Rc, Weak}, }; +use macro_attr::*; +use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; + use crate::{ api::control::endpoint::SrcUri, media::PeerId, signalling::control::member::Member, @@ -13,20 +15,10 @@ use super::publish_endpoint::WebRtcPublishEndpoint; pub use Id as WebRtcPlayId; -/// ID of endpoint. -#[derive(Clone, Debug, Eq, Hash, PartialEq)] -pub struct Id(pub String); - -impl Display for Id { - fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(fmt, "{}", self.0) - } -} - -impl From for Id { - fn from(s: String) -> Self { - Self(s) - } +macro_attr! { + /// ID of endpoint. + #[derive(Clone, Debug, Eq, Hash, PartialEq, NewtypeFrom!, NewtypeDisplay!)] + pub struct Id(pub String); } #[derive(Debug, Clone)] diff --git a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs index 9f5e54e68..bb8e90aed 100644 --- a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs @@ -1,10 +1,11 @@ use std::{ cell::RefCell, - fmt::Display, rc::{Rc, Weak}, }; use hashbrown::HashSet; +use macro_attr::*; +use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; use crate::{ api::control::endpoint::P2pMode, media::PeerId, @@ -15,20 +16,10 @@ use super::play_endpoint::WebRtcPlayEndpoint; pub use Id as WebRtcPublishId; -/// ID of endpoint. -#[derive(Clone, Debug, Eq, Hash, PartialEq)] -pub struct Id(pub String); - -impl Display for Id { - fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(fmt, "{}", self.0) - } -} - -impl From for Id { - fn from(s: String) -> Self { - Self(s) - } +macro_attr! { + /// ID of endpoint. + #[derive(Clone, Debug, Eq, Hash, PartialEq, NewtypeFrom!, NewtypeDisplay!)] + pub struct Id(pub String); } #[derive(Debug, Clone)] From 16397f37a67fd12b1d5bbbedfdc084fd9f15fc20 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 3 Jul 2019 14:13:13 +0300 Subject: [PATCH 228/735] Some fix for member connect --- src/signalling/room.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 504641ef2..93625fefd 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -2,6 +2,7 @@ //! connection establishment between concrete [`Member`]s. use std::time::Duration; +use std::collections::HashSet; use actix::{ fut::wrap_future, Actor, ActorFuture, AsyncContext, Context, Handler, @@ -9,7 +10,7 @@ use actix::{ }; use failure::Fail; use futures::future; -use hashbrown::HashMap; +use hashbrown::{HashMap}; use medea_client_api_proto::{Command, Event, IceCandidate}; use crate::{ @@ -323,6 +324,8 @@ impl Room { member: &Member, ctx: &mut ::Context, ) { + let mut to_connect = HashMap::new(); + // Create all connected publish endpoints. for (_, publish) in member.srcs() { for receiver in publish.sinks() { @@ -331,7 +334,8 @@ impl Room { if self.members.member_has_connection(&receiver_owner.id()) && !receiver.is_connected() { - self.connect_members(&member, &receiver_owner, ctx); + to_connect.insert(receiver_owner.id(), receiver_owner); +// self.connect_members(&member, &receiver_owner, ctx); } } } @@ -345,9 +349,14 @@ impl Room { .member_has_connection(&plays_publisher_owner.id()) && !play.is_connected() { - self.connect_members(&member, &plays_publisher_owner, ctx); + to_connect.insert(plays_publisher_owner.id(), plays_publisher_owner); +// self.connect_members(&member, &plays_publisher_owner, ctx); } } + + for (_, member_to_connect) in to_connect { + self.connect_members(&member, &member_to_connect, ctx); + } } /// Check state of interconnected [`Peer`]s and sends [`Event`] about From 22ddb8782ef8e789776580dba74c0a1a59cdc998 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 3 Jul 2019 17:04:31 +0300 Subject: [PATCH 229/735] New implementation of peer creation --- src/media/peer.rs | 57 +++++++++-------------------- src/signalling/peers.rs | 51 ++++++++++++++++---------- src/signalling/room.rs | 81 +++++++++++++++++++++++++++++++---------- 3 files changed, 111 insertions(+), 78 deletions(-) diff --git a/src/media/peer.rs b/src/media/peer.rs index 7cc2e8db8..e3c331d2e 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -16,10 +16,7 @@ use medea_macro::enum_delegate; use crate::{ api::control::MemberId, media::{MediaTrack, TrackId}, - signalling::{ - elements::endpoints::webrtc::{WebRtcPublishEndpoint, WebRtcPublishId}, - peers::Counter, - }, + signalling::peers::Counter, }; /// Newly initialized [`Peer`] ready to signalling. @@ -252,45 +249,27 @@ impl Peer { } } - /// Add all publish endpoints to this [`Peer`]. - /// - /// This also create [`Peer`]s for [`WebRtcPlayEndpoint`]s that - /// receive something from us. - pub fn add_publish_endpoints( + /// Add `send` tracks to self and add `recv` for this `send` + /// to `partner_peer`. + pub fn add_publisher( &mut self, partner_peer: &mut Peer, tracks_count: &mut Counter, - publish_endpoints: HashMap>, ) { - let partner_id = self.partner_member_id(); - let self_id = self.id(); - - publish_endpoints - .into_iter() - .flat_map(|(_m, e)| { - e.add_peer_id(self_id); - e.sinks().into_iter().filter(|e| { - e.owner().id() == partner_id && !e.is_connected() - }) - }) - .for_each(|e| { - let track_audio = Rc::new(MediaTrack::new( - tracks_count.next_id(), - MediaType::Audio(AudioSettings {}), - )); - let track_video = Rc::new(MediaTrack::new( - tracks_count.next_id(), - MediaType::Video(VideoSettings {}), - )); - - self.add_sender(track_video.clone()); - self.add_sender(track_audio.clone()); - - partner_peer.add_receiver(track_video); - partner_peer.add_receiver(track_audio); - - e.connect(partner_peer.id()); - }); + let track_audio = Rc::new(MediaTrack::new( + tracks_count.next_id(), + MediaType::Audio(AudioSettings {}), + )); + let track_video = Rc::new(MediaTrack::new( + tracks_count.next_id(), + MediaType::Video(VideoSettings {}), + )); + + self.add_sender(track_video.clone()); + self.add_sender(track_audio.clone()); + + partner_peer.add_receiver(track_video); + partner_peer.add_receiver(track_audio); } /// Transition new [`Peer`] into state of waiting for local description. diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index fb7d4c918..07dfeeef1 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -11,7 +11,7 @@ use hashbrown::HashMap; use crate::{ api::control::MemberId, log::prelude::*, - media::{Peer, PeerId, PeerStateMachine}, + media::{New, Peer, PeerId, PeerStateMachine}, signalling::{ control::member::Member, room::{PeersRemoved, Room, RoomError}, @@ -69,14 +69,12 @@ impl PeerRepository { .ok_or_else(|| RoomError::PeerNotFound(peer_id)) } - /// Create and interconnect [`Peer`]s based on [`Member`]. - /// - /// Returns IDs of created [`Peer`]s. `(first_peer_id, second_peer_id)`. + /// Create interconnected [`Peer`]s for provided [`Member`]s. pub fn create_peers( &mut self, first_member: &Member, second_member: &Member, - ) -> (u64, u64) { + ) -> (Peer, Peer) { debug!( "Created peer between {} and {}.", first_member.id(), @@ -85,34 +83,47 @@ impl PeerRepository { let first_peer_id = self.peers_count.next_id(); let second_peer_id = self.peers_count.next_id(); - let mut first_peer = Peer::new( + let first_peer = Peer::new( first_peer_id, first_member.id().clone(), second_peer_id, second_member.id().clone(), ); - let mut second_peer = Peer::new( + let second_peer = Peer::new( second_peer_id, second_member.id().clone(), first_peer_id, first_member.id().clone(), ); - first_peer.add_publish_endpoints( - &mut second_peer, - &mut self.tracks_count, - first_member.srcs(), - ); - second_peer.add_publish_endpoints( - &mut first_peer, - &mut self.tracks_count, - second_member.srcs(), - ); + (first_peer, second_peer) + } + + /// Returns mutable reference to track counter. + pub fn get_tracks_counter(&mut self) -> &mut Counter { + &mut self.tracks_count + } - self.add_peer(first_peer); - self.add_peer(second_peer); + /// Lookup [`Peer`] of [`Member`] with ID `member_id` which + /// connected with `partner_member_id`. + /// + /// Return Some(peer_id, partner_peer_id) if that [`Peer`] found. + /// + /// Return None if that [`Peer`] not found. + pub fn get_peer_by_members_ids( + &self, + member_id: &MemberId, + partner_member_id: &MemberId, + ) -> Option<(PeerId, PeerId)> { + for (_, peer) in &self.peers { + if &peer.member_id() == member_id + && &peer.partner_member_id() == partner_member_id + { + return Some((peer.id(), peer.partner_peer_id())); + } + } - (first_peer_id, second_peer_id) + None } /// Returns borrowed [`Peer`] by its ID. diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 504641ef2..93ccfd3c5 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -1,7 +1,7 @@ //! Room definitions and implementations. Room is responsible for media //! connection establishment between concrete [`Member`]s. -use std::time::Duration; +use std::{rc::Rc, time::Duration}; use actix::{ fut::wrap_future, Actor, ActorFuture, AsyncContext, Context, Handler, @@ -27,6 +27,9 @@ use crate::{ }, signalling::{ control::member::{Member, MembersLoadError}, + elements::endpoints::webrtc::{ + WebRtcPlayEndpoint, WebRtcPublishEndpoint, + }, participants::ParticipantService, peers::PeerRepository, }, @@ -292,24 +295,51 @@ impl Room { ))) } - /// Create [`Peer`]s between [`Member`]s and interconnect it by control - /// API spec. - fn connect_members( + fn connect_endpoints( &mut self, - first_member: &Member, - second_member: &Member, - ctx: &mut ::Context, - ) { - debug!( - "Created peer member {} with member {}", - first_member.id(), - second_member.id() - ); + src: &Rc, + sink: &Rc, + ) -> Option<(PeerId, PeerId)> { + let src_owner = src.owner(); + let sink_owner = sink.owner(); + + if let Some((src_peer_id, sink_peer_id)) = self + .peers + .get_peer_by_members_ids(&src_owner.id(), &sink_owner.id()) + { + let mut src_peer: Peer = + self.peers.take_inner_peer(src_peer_id).unwrap(); + let mut sink_peer: Peer = + self.peers.take_inner_peer(sink_peer_id).unwrap(); + + src_peer + .add_publisher(&mut sink_peer, self.peers.get_tracks_counter()); + + src.add_peer_id(src_peer_id); + sink.connect(sink_peer_id); + + self.peers.add_peer(src_peer); + self.peers.add_peer(sink_peer); + } else { + let (mut src_peer, mut sink_peer) = + self.peers.create_peers(&src_owner, &sink_owner); + + src_peer + .add_publisher(&mut sink_peer, self.peers.get_tracks_counter()); - let (first_peer_id, second_peer_id) = - self.peers.create_peers(first_member, second_member); + src.add_peer_id(src_peer.id()); + sink.connect(sink_peer.id()); - self.connect_peers(ctx, first_peer_id, second_peer_id); + let src_peer_id = src_peer.id(); + let sink_peer_id = sink_peer.id(); + + self.peers.add_peer(src_peer); + self.peers.add_peer(sink_peer); + + return Some((src_peer_id, sink_peer_id)); + }; + + None } /// Create and interconnect all [`Peer`]s between connected [`Member`] @@ -323,6 +353,8 @@ impl Room { member: &Member, ctx: &mut ::Context, ) { + let mut created_peers: Vec<(PeerId, PeerId)> = Vec::new(); + // Create all connected publish endpoints. for (_, publish) in member.srcs() { for receiver in publish.sinks() { @@ -331,23 +363,34 @@ impl Room { if self.members.member_has_connection(&receiver_owner.id()) && !receiver.is_connected() { - self.connect_members(&member, &receiver_owner, ctx); + if let Some(p) = self.connect_endpoints(&publish, &receiver) + { + created_peers.push(p) + } } } } // Create all connected play's receivers peers. for (_, play) in member.sinks() { - let plays_publisher_owner = play.src().owner(); + let plays_publisher = play.src(); + let plays_publisher_owner = plays_publisher.owner(); if self .members .member_has_connection(&plays_publisher_owner.id()) && !play.is_connected() { - self.connect_members(&member, &plays_publisher_owner, ctx); + if let Some(p) = self.connect_endpoints(&plays_publisher, &play) + { + created_peers.push(p); + } } } + + for (first_peer_id, second_peer_id) in created_peers { + self.connect_peers(ctx, first_peer_id, second_peer_id); + } } /// Check state of interconnected [`Peer`]s and sends [`Event`] about From 35a5b23f48bf29212f652fee6266401aab88597c Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 3 Jul 2019 17:20:23 +0300 Subject: [PATCH 230/735] Add some docs and TODO --- src/signalling/room.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 93ccfd3c5..12f687999 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -295,6 +295,14 @@ impl Room { ))) } + /// Create [`Peer`] for endpoints if [`Peer`] between endpoint's members + /// not exist. + /// + /// Add `send` track to source member's [`Peer`] and `recv` to + /// sink member's [`Peer`]. + /// + /// __This will panic if provide endpoints with already interconnected + /// [`Peer`]s!__ fn connect_endpoints( &mut self, src: &Rc, @@ -307,6 +315,9 @@ impl Room { .peers .get_peer_by_members_ids(&src_owner.id(), &sink_owner.id()) { + // TODO: when dynamic patching of [`Room`] will be done then we need + // rewrite this code to updating [`Peer`]s in not + // [`Peer`] state. let mut src_peer: Peer = self.peers.take_inner_peer(src_peer_id).unwrap(); let mut sink_peer: Peer = From 0be5b8d74732cc80b85b3c78691d19d820590c29 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 3 Jul 2019 17:25:51 +0300 Subject: [PATCH 231/735] Add module docs --- src/signalling/elements/endpoints/mod.rs | 2 ++ src/signalling/elements/endpoints/webrtc/mod.rs | 2 ++ src/signalling/elements/endpoints/webrtc/play_endpoint.rs | 2 ++ src/signalling/elements/endpoints/webrtc/publish_endpoint.rs | 2 ++ src/signalling/elements/mod.rs | 2 ++ 5 files changed, 10 insertions(+) diff --git a/src/signalling/elements/endpoints/mod.rs b/src/signalling/elements/endpoints/mod.rs index c050ca143..cadc86a3c 100644 --- a/src/signalling/elements/endpoints/mod.rs +++ b/src/signalling/elements/endpoints/mod.rs @@ -1 +1,3 @@ +//! Medea endpoints implementations. + pub mod webrtc; diff --git a/src/signalling/elements/endpoints/webrtc/mod.rs b/src/signalling/elements/endpoints/webrtc/mod.rs index 53ad4caab..aacfc952b 100644 --- a/src/signalling/elements/endpoints/webrtc/mod.rs +++ b/src/signalling/elements/endpoints/webrtc/mod.rs @@ -1,3 +1,5 @@ +//! WebRTC related endpoints. + pub mod play_endpoint; pub mod publish_endpoint; diff --git a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs index d605acff1..414f3736e 100644 --- a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs @@ -1,3 +1,5 @@ +//! [`WebRtcPlayEndpoint`] implementation. + use std::{ cell::RefCell, rc::{Rc, Weak}, diff --git a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs index bb8e90aed..badae59b5 100644 --- a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs @@ -1,3 +1,5 @@ +//! [`WebRtcPublishEndpoint`] implementation. + use std::{ cell::RefCell, rc::{Rc, Weak}, diff --git a/src/signalling/elements/mod.rs b/src/signalling/elements/mod.rs index c4b360f4b..f306d3095 100644 --- a/src/signalling/elements/mod.rs +++ b/src/signalling/elements/mod.rs @@ -1 +1,3 @@ +//! Elements of Medea. + pub mod endpoints; From 75fe13642a51a8b44f5d76cf21c4626996e93a90 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 3 Jul 2019 17:31:24 +0300 Subject: [PATCH 232/735] Move Member into elements module --- src/signalling/control/mod.rs | 6 ------ src/signalling/elements/endpoints/webrtc/play_endpoint.rs | 3 +-- .../elements/endpoints/webrtc/publish_endpoint.rs | 2 +- src/signalling/{control => elements}/member.rs | 8 ++++---- src/signalling/elements/mod.rs | 4 ++++ src/signalling/mod.rs | 1 - src/signalling/participants.rs | 2 +- src/signalling/peers.rs | 2 +- src/signalling/room.rs | 6 +++--- 9 files changed, 15 insertions(+), 19 deletions(-) delete mode 100644 src/signalling/control/mod.rs rename src/signalling/{control => elements}/member.rs (99%) diff --git a/src/signalling/control/mod.rs b/src/signalling/control/mod.rs deleted file mode 100644 index fe423410e..000000000 --- a/src/signalling/control/mod.rs +++ /dev/null @@ -1,6 +0,0 @@ -//! Signalling representation of control spec. - -pub mod member; - -#[doc(inline)] -pub use self::member::{parse_members, Member, MembersLoadError}; diff --git a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs index 414f3736e..36033b29e 100644 --- a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs @@ -9,8 +9,7 @@ use macro_attr::*; use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; use crate::{ - api::control::endpoint::SrcUri, media::PeerId, - signalling::control::member::Member, + api::control::endpoint::SrcUri, media::PeerId, signalling::elements::Member, }; use super::publish_endpoint::WebRtcPublishEndpoint; diff --git a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs index badae59b5..a39e3108d 100644 --- a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs @@ -11,7 +11,7 @@ use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; use crate::{ api::control::endpoint::P2pMode, media::PeerId, - signalling::control::member::Member, + signalling::elements::Member, }; use super::play_endpoint::WebRtcPlayEndpoint; diff --git a/src/signalling/control/member.rs b/src/signalling/elements/member.rs similarity index 99% rename from src/signalling/control/member.rs rename to src/signalling/elements/member.rs index f220acfd0..9f994e60b 100644 --- a/src/signalling/control/member.rs +++ b/src/signalling/elements/member.rs @@ -10,10 +10,10 @@ use crate::{ api::control::{MemberId, MemberSpec, RoomSpec, TryFromElementError}, log::prelude::*, media::{IceUser, PeerId}, - signalling::elements::endpoints::webrtc::{ - WebRtcPlayEndpoint, WebRtcPlayId, WebRtcPublishEndpoint, - WebRtcPublishId, - }, +}; + +use super::endpoints::webrtc::{ + WebRtcPlayEndpoint, WebRtcPlayId, WebRtcPublishEndpoint, WebRtcPublishId, }; /// Errors which may occur while loading [`Member`]s from [`RoomSpec`]. diff --git a/src/signalling/elements/mod.rs b/src/signalling/elements/mod.rs index f306d3095..3a402d298 100644 --- a/src/signalling/elements/mod.rs +++ b/src/signalling/elements/mod.rs @@ -1,3 +1,7 @@ //! Elements of Medea. pub mod endpoints; +pub mod member; + +#[doc(inline)] +pub use self::member::{parse_members, Member, MembersLoadError}; diff --git a/src/signalling/mod.rs b/src/signalling/mod.rs index 27f712cea..e5d46b817 100644 --- a/src/signalling/mod.rs +++ b/src/signalling/mod.rs @@ -1,4 +1,3 @@ -pub mod control; pub mod elements; pub mod participants; pub mod peers; diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 227fb4c52..4509d8a42 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -31,7 +31,7 @@ use crate::{ log::prelude::*, media::IceUser, signalling::{ - control::{parse_members, Member, MembersLoadError}, + elements::{parse_members, Member, MembersLoadError}, room::{ActFuture, RoomError}, Room, }, diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index 07dfeeef1..d3b60a2a4 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -13,7 +13,7 @@ use crate::{ log::prelude::*, media::{New, Peer, PeerId, PeerStateMachine}, signalling::{ - control::member::Member, + elements::Member, room::{PeersRemoved, Room, RoomError}, }, }; diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 12f687999..bc27a05bf 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -26,9 +26,9 @@ use crate::{ WaitLocalHaveRemote, WaitLocalSdp, WaitRemoteSdp, }, signalling::{ - control::member::{Member, MembersLoadError}, - elements::endpoints::webrtc::{ - WebRtcPlayEndpoint, WebRtcPublishEndpoint, + elements::{ + endpoints::webrtc::{WebRtcPlayEndpoint, WebRtcPublishEndpoint}, + Member, MembersLoadError, }, participants::ParticipantService, peers::PeerRepository, From 8e44dae6486439d42ff03e1492cd7af916749b88 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 3 Jul 2019 17:37:33 +0300 Subject: [PATCH 233/735] Minor fixes --- src/signalling/elements/endpoints/webrtc/play_endpoint.rs | 2 +- src/signalling/room.rs | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs index 36033b29e..8c984aa1b 100644 --- a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs @@ -143,7 +143,7 @@ impl WebRtcPlayEndpoint { } /// Save [`PeerId`] of this [`WebRtcPlayEndpoint`]. - pub fn connect(&self, peer_id: PeerId) { + pub fn set_peer_id(&self, peer_id: PeerId) { self.0.borrow_mut().set_peer_id(peer_id); } diff --git a/src/signalling/room.rs b/src/signalling/room.rs index bc27a05bf..5a74fa775 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -301,6 +301,8 @@ impl Room { /// Add `send` track to source member's [`Peer`] and `recv` to /// sink member's [`Peer`]. /// + /// Returns [`PeerId`]s of newly created [`Peer`] if some created. + /// /// __This will panic if provide endpoints with already interconnected /// [`Peer`]s!__ fn connect_endpoints( @@ -327,7 +329,7 @@ impl Room { .add_publisher(&mut sink_peer, self.peers.get_tracks_counter()); src.add_peer_id(src_peer_id); - sink.connect(sink_peer_id); + sink.set_peer_id(sink_peer_id); self.peers.add_peer(src_peer); self.peers.add_peer(sink_peer); @@ -339,7 +341,7 @@ impl Room { .add_publisher(&mut sink_peer, self.peers.get_tracks_counter()); src.add_peer_id(src_peer.id()); - sink.connect(sink_peer.id()); + sink.set_peer_id(sink_peer.id()); let src_peer_id = src_peer.id(); let sink_peer_id = sink_peer.id(); From 3f1ab3a1e974dd3e44b0a5db0eed289ead818c9b Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 3 Jul 2019 17:49:18 +0300 Subject: [PATCH 234/735] Use newtype_derive for RoomId --- src/api/control/room.rs | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/api/control/room.rs b/src/api/control/room.rs index 8a075f12f..ab67c6c4f 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -1,8 +1,10 @@ //! Room definitions and implementations. -use std::{convert::TryFrom, fmt::Display}; +use std::convert::TryFrom; use hashbrown::HashMap; +use macro_attr::*; +use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; use serde::Deserialize; use super::{ @@ -10,14 +12,19 @@ use super::{ TryFromElementError, }; -/// ID of [`Room`]. -#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq)] -pub struct Id(pub String); - -impl Display for Id { - fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(fmt, "{}", self.0) - } +macro_attr! { + /// ID of [`Room`]. + #[derive( + Clone, + Debug, + Deserialize, + Eq, + Hash, + PartialEq, + NewtypeFrom!, + NewtypeDisplay!, + )] + pub struct Id(pub String); } /// [`crate::signalling::room::Room`] specification. From 9dbf08b572ac0dd8c9f8849121b3999745b6d2e1 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 4 Jul 2019 12:53:31 +0300 Subject: [PATCH 235/735] gRPC basic structure --- Cargo.lock | 191 + Cargo.toml | 6 + build.rs | 10 + src/api/grpc/mod.rs | 2 + src/api/grpc/protos/control.proto | 138 + src/api/grpc/protos/control.rs | 6339 +++++++++++++++++++++++++++ src/api/grpc/protos/control_grpc.rs | 155 + src/api/grpc/protos/mod.rs | 2 + src/api/grpc/server.rs | 99 + src/api/mod.rs | 1 + src/main.rs | 5 +- src/signalling/room_repo.rs | 6 +- 12 files changed, 6952 insertions(+), 2 deletions(-) create mode 100644 build.rs create mode 100644 src/api/grpc/mod.rs create mode 100644 src/api/grpc/protos/control.proto create mode 100644 src/api/grpc/protos/control.rs create mode 100644 src/api/grpc/protos/control_grpc.rs create mode 100644 src/api/grpc/protos/mod.rs create mode 100644 src/api/grpc/server.rs diff --git a/Cargo.lock b/Cargo.lock index 0405f165f..80e14fb7d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -513,6 +513,15 @@ dependencies = [ "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "c2-chacha" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ppv-lite86 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "cc" version = "1.0.37" @@ -542,6 +551,14 @@ dependencies = [ "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "cmake" +version = "0.1.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "combine" version = "3.8.1" @@ -879,6 +896,47 @@ name = "gcc" version = "0.3.55" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "getrandom" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "grpcio" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "grpcio-sys 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf 2.7.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "grpcio-compiler" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "protobuf 2.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf-codegen 2.7.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "grpcio-sys" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", + "cmake 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "h2" version = "0.1.24" @@ -1056,6 +1114,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "lazy_static" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "spin 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "libc" @@ -1145,12 +1206,15 @@ dependencies = [ "dotenv 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "grpcio 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "macro-attr 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "medea-client-api-proto 0.1.0-dev", "medea-macro 0.1.0-dev", "newtype_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf 2.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "protoc-grpcio 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "redis 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1416,6 +1480,16 @@ name = "percent-encoding" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "pkg-config" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "ppv-lite86" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "proc-macro2" version = "0.4.30" @@ -1424,6 +1498,40 @@ dependencies = [ "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "protobuf" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "protobuf-codegen" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "protobuf 2.7.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "protoc" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "protoc-grpcio" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "grpcio-compiler 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf 2.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf-codegen 2.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "protoc 2.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "quick-error" version = "1.2.2" @@ -1476,6 +1584,18 @@ dependencies = [ "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "rand" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "getrandom 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_chacha 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "rand_chacha" version = "0.1.1" @@ -1485,6 +1605,16 @@ dependencies = [ "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "rand_chacha" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "c2-chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "rand_core" version = "0.3.1" @@ -1498,6 +1628,14 @@ name = "rand_core" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "rand_core" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "getrandom 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "rand_hc" version = "0.1.0" @@ -1506,6 +1644,14 @@ dependencies = [ "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "rand_isaac" version = "0.1.1" @@ -1639,6 +1785,14 @@ dependencies = [ "ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "remove_dir_all" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "resolv-conf" version = "0.6.2" @@ -1967,6 +2121,11 @@ name = "sourcefile" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "spin" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "stable_deref_trait" version = "1.1.1" @@ -2006,6 +2165,19 @@ name = "take_mut" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "tempfile" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", + "remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "term" version = "0.5.2" @@ -2656,10 +2828,12 @@ dependencies = [ "checksum bumpalo 2.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "84dca3afd8e01b9526818b7963e5b4916063b3cdf9f10cf6b73ef0bd0ec37aa5" "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" "checksum bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" +"checksum c2-chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7d64d04786e0f528460fc884753cf8dddcc466be308f6026f8e355c41a0e4101" "checksum cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)" = "39f75544d7bbaf57560d2168f28fd649ff9c76153874db88bdbdfd839b1a7e7d" "checksum cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b486ce3ccf7ffd79fdeb678eac06a9e6c09fc88d33836340becb8fffe87c5e33" "checksum chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "77d81f58b7301084de3b958691458a53c3f7e0b1d702f77e550b6a88e3a88abe" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" +"checksum cmake 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "2ca4386c8954b76a8415b63959337d940d724b336cabd3afe189c2b51a7e1ff0" "checksum combine 3.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "da3da6baa321ec19e1cc41d31bf599f00c783d0517095cdaf0332e3fe8d20680" "checksum config 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "f9107d78ed62b3fa5a86e7d18e647abed48cfd8f8fab6c72f4cdb982d196f7e6" "checksum console_error_panic_hook 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "b8d976903543e0c48546a91908f21588a680a8c8f984df9a5d69feccb2b2a211" @@ -2699,6 +2873,10 @@ dependencies = [ "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" "checksum futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)" = "a2037ec1c6c1c4f79557762eab1f7eae1f64f6cb418ace90fae88f0942b60139" "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" +"checksum getrandom 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "e65cce4e5084b14874c4e7097f38cab54f47ee554f9194673456ea379dcc4c55" +"checksum grpcio 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c02fb3c9c44615973814c838f75d7898695d4d4b97a3e8cf52e9ccca30664b6f" +"checksum grpcio-compiler 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "373a14f0f994d4c235770f4bb5558be00626844db130a82a70142b8fc5996fc3" +"checksum grpcio-sys 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "9d8d3b6d1a70b9dcb2545d1aff5b2c74652cb635f6ab6426be8fd201e9566b7e" "checksum h2 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)" = "69b2a5a3092cbebbc951fe55408402e696ee2ed09019137d1800fc2c411265d2" "checksum hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3bae29b6653b3412c2e71e9d486db9f9df5d701941d86683005efb9f2d28e3da" "checksum hashbrown 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "29fba9abe4742d586dfd0c06ae4f7e73a1c2d86b856933509b269d82cdf06e18" @@ -2755,16 +2933,26 @@ dependencies = [ "checksum parking_lot_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "94c8c7923936b28d546dfd14d4472eaf34c99b14e1c973a32b3e6d4eb04298c9" "checksum parking_lot_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cb88cb1cb3790baa6776844f968fea3be44956cf184fa1be5a03341f5491278c" "checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" +"checksum pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "676e8eb2b1b4c9043511a9b7bea0915320d7e502b0a079fb03f9635a5252b18c" +"checksum ppv-lite86 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e3cbf9f658cdb5000fcf6f362b8ea2ba154b9f146a61c7a20d647034c6b6561b" "checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" +"checksum protobuf 2.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5f00e4a3cb64ecfeac2c0a73c74c68ae3439d7a6bead3870be56ad5dd2620a6f" +"checksum protobuf-codegen 2.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d2c6e555166cdb646306f599da020e01548e9f4d6ec2fd39802c6db2347cbd3e" +"checksum protoc 2.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f26e88abedb402073b87981faecc3b973dd5b19b7002821ed47c457bc5b367a4" +"checksum protoc-grpcio 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a9798b534614b71d780778b1508410826073b5a1ca111a090f1f3fd3ac663ef6" "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" "checksum quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)" = "faf4799c5d274f3868a4aae320a0a182cbd2baee377b378f080e16a23e9d80db" "checksum rand 0.3.23 (registry+https://github.com/rust-lang/crates.io-index)" = "64ac302d8f83c0c1974bf758f6b041c6c8ada916fbb44a609158ca8b064cc76c" "checksum rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" "checksum rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" +"checksum rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d47eab0e83d9693d40f825f86948aa16eff6750ead4bdffc4ab95b8b3a7f052c" "checksum rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" +"checksum rand_chacha 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e193067942ef6f485a349a113329140d0ab9e2168ce92274499bb0e9a4190d9d" "checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" "checksum rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0e7a549d590831370895ab7ba4ea0c1b6b011d106b5ff2da6eee112615e6dc0" +"checksum rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "615e683324e75af5d43d8f7a39ffe3ee4a9dc42c5c701167a71dc59c3a493aca" "checksum rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" +"checksum rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" "checksum rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" "checksum rand_jitter 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" "checksum rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" @@ -2779,6 +2967,7 @@ dependencies = [ "checksum regex 1.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "0b2f0808e7d7e4fb1cb07feb6ff2f4bc827938f24f8c2e6a3beb7370af544bdd" "checksum regex-syntax 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "f9ec002c35e86791825ed294b50008eea9ddfc8def4420124fbc6b08db834957" "checksum regex-syntax 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)" = "9d76410686f9e3a17f06128962e0ecc5755870bb890c34820c7af7f1db2e1d48" +"checksum remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e" "checksum resolv-conf 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b263b4aa1b5de9ffc0054a2386f96992058bb6870aab516f8cdeb8a667d56dcb" "checksum rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)" = "f76d05d3993fd5f4af9434e8e436db163a12a9d40e1a58a726f27a01dfd12a2a" "checksum rust-ini 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3e52c148ef37f8c375d49d5a73aa70713125b7f19095948a923f80afdeb22ec2" @@ -2820,11 +3009,13 @@ dependencies = [ "checksum smart-default 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5a9dbd5f03d04e80355cbbe3ce5cf1f65c421eac575402e3d4d6e95d5a44edaa" "checksum socket2 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "4e626972d3593207547f14bf5fc9efa4d0e7283deb73fef1dff313dae9ab8878" "checksum sourcefile 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4bf77cb82ba8453b42b6ae1d692e4cdc92f9a47beaf89a847c8be83f4e328ad3" +"checksum spin 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44363f6f51401c34e7be73db0db371c04705d35efbe9f7d6082e03a921a32c55" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" "checksum string 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0bbfb8937e38e34c3444ff00afb28b0811d9554f15c5ad64d12b0308d1d1995" "checksum syn 0.15.38 (registry+https://github.com/rust-lang/crates.io-index)" = "37ea458a750f59ab679b47fef9b6722c586c5742f4cfe18a120bbc807e5e01fd" "checksum synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f" "checksum take_mut 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f764005d11ee5f36500a149ace24e00e3da98b0158b3e2d53a7495660d3f4d60" +"checksum tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" "checksum term 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "edd106a334b7657c10b7c540a0106114feadeb4dc314513e97df481d5d966f42" "checksum termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "96d6098003bde162e4277c70665bd87c326f5a0c3f3fbfb285787fa482d54e6e" "checksum termion 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6a8fb22f7cde82c8220e5aeacb3258ed7ce996142c77cba193f203515e26c330" diff --git a/Cargo.toml b/Cargo.toml index d07f5f272..3c479fdcf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,6 +8,7 @@ homepage = "https://github.com/instrumentisto/medea" # documentation = "https://docs.rs/medea" readme = "README.md" repository = "https://github.com/instrumentisto/medea" +build = "build.rs" [workspace] members = [ @@ -34,12 +35,14 @@ config = "0.9" dotenv = "0.13" failure = "0.1" futures = "0.1" +grpcio = "0.4" hashbrown = "0.1" humantime = "1.2" macro-attr = "0.2" medea-client-api-proto = { path = "proto/client-api", features = ["medea"] } medea-macro = { path = "crates/medea-macro" } newtype_derive = "0.1" +protobuf = "2.7" rand = "0.6" redis = "0.10" rust-crypto = "0.2" @@ -65,3 +68,6 @@ actix-http-test = "0.2" serial_test = "0.2" serial_test_derive = "0.2" actix-codec = "0.1.2" + +[build-dependencies] +protoc-grpcio = "0.3" diff --git a/build.rs b/build.rs new file mode 100644 index 000000000..7e436cdbd --- /dev/null +++ b/build.rs @@ -0,0 +1,10 @@ +fn main() { + let proto_root = "src/api/grpc/protos"; + println!("cargo:rerun-if-changed={}", proto_root); + protoc_grpcio::compile_grpc_protos( + &["control.proto"], + &[proto_root], + &proto_root, + ) + .expect("Failed to compile gRPC definitions!"); +} diff --git a/src/api/grpc/mod.rs b/src/api/grpc/mod.rs new file mode 100644 index 000000000..47c576ee3 --- /dev/null +++ b/src/api/grpc/mod.rs @@ -0,0 +1,2 @@ +pub mod protos; +pub mod server; diff --git a/src/api/grpc/protos/control.proto b/src/api/grpc/protos/control.proto new file mode 100644 index 000000000..fcc37451f --- /dev/null +++ b/src/api/grpc/protos/control.proto @@ -0,0 +1,138 @@ +syntax = "proto2"; + +import "google/protobuf/any.proto"; + +package medea; + +service ControlApi { + rpc Create (CreateRequest) returns (Response); + rpc Apply (ApplyRequest) returns (Response); + rpc Delete (IdRequest) returns (Response); + rpc Get (IdRequest) returns (GetResponse); +} +message CreateRequest { + required string id = 1; + oneof el { + Hub hub = 2; + FileRecorder file_recorder = 3; + Member member = 4; + Relay relay = 5; + Room room = 6; + WebRtcPlayEndpoint webrtc_play = 7; + WebRtcPublishEndpoint webrtc_pub = 8; + } +} +message ApplyRequest { + required string id = 1; + oneof el { + Hub hub = 2; + FileRecorder file_recorder = 3; + Member member = 4; + Relay relay = 5; + Room room = 6; + WebRtcPlayEndpoint webrtc_play = 7; + WebRtcPublishEndpoint webrtc_pub = 8; + } + optional Policy policy = 9 [default = APPLY]; + + enum Policy { + APPLY = 1; + APPEND = 2; + } +} +message IdRequest { + repeated string id = 1; +} +message Response { + map sid = 1; + optional Error error = 2; +} +message GetResponse { + map elements = 1; + optional Error error = 2; +} +message Error { + required uint32 status = 1; + required uint32 code = 2; + required string text = 3; + optional string doc = 4; + required string element = 5; + optional google.protobuf.Any details = 6; + repeated string backtrace = 7; +} + +message Element { + oneof el { + Hub hub = 2; + FileRecorder file_recorder = 3; + Member member = 4; + Relay relay = 5; + Room room = 6; + WebRtcPlayEndpoint webrtc_play = 7; + WebRtcPublishEndpoint webrtc_pub = 8; + } +} + +message Room { + map pipeline = 1; + + message Element { + oneof el { + Hub hub = 1; + FileRecorder file_recorder = 2; + Member member = 3; + Relay relay = 4; + WebRtcPlayEndpoint webrtc_play = 5; + WebRtcPublishEndpoint webrtc_pub = 6; + } + } +} + +message Member { + optional string on_join = 1; + optional string on_leave = 2; + map pipeline = 3; + + message Element { + oneof el { + Hub hub = 1; + FileRecorder file_recorder = 2; + Relay relay = 3; + WebRtcPlayEndpoint webrtc_play = 4; + WebRtcPublishEndpoint webrtc_pub = 5; + } + } +} + +message WebRtcPublishEndpoint { + optional P2P p2p = 1 [default = NEVER]; + optional string dst = 2; + optional string on_start = 3; + optional string on_stop = 4; + + enum P2P { + NEVER = 0; + IF_POSSIBLE = 1; + ALWAYS = 2; + } +} + +message WebRtcPlayEndpoint { + required string src = 1; + optional string on_start = 2; + optional string on_stop = 3; +} + +message Hub {} + +message FileRecorder { + required string src = 1; + required string dst = 2; + optional string on_start = 3; + optional string on_stop = 4; +} + +message Relay { + required string src = 1; + optional string dst = 2; +} diff --git a/src/api/grpc/protos/control.rs b/src/api/grpc/protos/control.rs new file mode 100644 index 000000000..c59804e01 --- /dev/null +++ b/src/api/grpc/protos/control.rs @@ -0,0 +1,6339 @@ +// This file is generated by rust-protobuf 2.7.0. Do not edit +// @generated + +// https://github.com/Manishearth/rust-clippy/issues/702 +#![allow(unknown_lints)] +#![allow(clippy::all)] + +#![cfg_attr(rustfmt, rustfmt_skip)] + +#![allow(box_pointers)] +#![allow(dead_code)] +#![allow(missing_docs)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] +#![allow(non_upper_case_globals)] +#![allow(trivial_casts)] +#![allow(unsafe_code)] +#![allow(unused_imports)] +#![allow(unused_results)] +//! Generated file from `control.proto` + +use protobuf::Message as Message_imported_for_functions; +use protobuf::ProtobufEnum as ProtobufEnum_imported_for_functions; + +/// Generated files are compatible only with the same version +/// of protobuf runtime. +const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_7_0; + +#[derive(PartialEq,Clone,Default)] +pub struct CreateRequest { + // message fields + id: ::protobuf::SingularField<::std::string::String>, + // message oneof groups + pub el: ::std::option::Option, + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a CreateRequest { + fn default() -> &'a CreateRequest { + ::default_instance() + } +} + +#[derive(Clone,PartialEq,Debug)] +pub enum CreateRequest_oneof_el { + hub(Hub), + file_recorder(FileRecorder), + member(Member), + relay(Relay), + room(Room), + webrtc_play(WebRtcPlayEndpoint), + webrtc_pub(WebRtcPublishEndpoint), +} + +impl CreateRequest { + pub fn new() -> CreateRequest { + ::std::default::Default::default() + } + + // required string id = 1; + + + pub fn get_id(&self) -> &str { + match self.id.as_ref() { + Some(v) => &v, + None => "", + } + } + pub fn clear_id(&mut self) { + self.id.clear(); + } + + pub fn has_id(&self) -> bool { + self.id.is_some() + } + + // Param is passed by value, moved + pub fn set_id(&mut self, v: ::std::string::String) { + self.id = ::protobuf::SingularField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_id(&mut self) -> &mut ::std::string::String { + if self.id.is_none() { + self.id.set_default(); + } + self.id.as_mut().unwrap() + } + + // Take field + pub fn take_id(&mut self) -> ::std::string::String { + self.id.take().unwrap_or_else(|| ::std::string::String::new()) + } + + // optional .medea.Hub hub = 2; + + + pub fn get_hub(&self) -> &Hub { + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::hub(ref v)) => v, + _ => Hub::default_instance(), + } + } + pub fn clear_hub(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_hub(&self) -> bool { + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::hub(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_hub(&mut self, v: Hub) { + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::hub(v)) + } + + // Mutable pointer to the field. + pub fn mut_hub(&mut self) -> &mut Hub { + if let ::std::option::Option::Some(CreateRequest_oneof_el::hub(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::hub(Hub::new())); + } + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::hub(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_hub(&mut self) -> Hub { + if self.has_hub() { + match self.el.take() { + ::std::option::Option::Some(CreateRequest_oneof_el::hub(v)) => v, + _ => panic!(), + } + } else { + Hub::new() + } + } + + // optional .medea.FileRecorder file_recorder = 3; + + + pub fn get_file_recorder(&self) -> &FileRecorder { + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::file_recorder(ref v)) => v, + _ => FileRecorder::default_instance(), + } + } + pub fn clear_file_recorder(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_file_recorder(&self) -> bool { + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::file_recorder(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_file_recorder(&mut self, v: FileRecorder) { + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::file_recorder(v)) + } + + // Mutable pointer to the field. + pub fn mut_file_recorder(&mut self) -> &mut FileRecorder { + if let ::std::option::Option::Some(CreateRequest_oneof_el::file_recorder(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::file_recorder(FileRecorder::new())); + } + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::file_recorder(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_file_recorder(&mut self) -> FileRecorder { + if self.has_file_recorder() { + match self.el.take() { + ::std::option::Option::Some(CreateRequest_oneof_el::file_recorder(v)) => v, + _ => panic!(), + } + } else { + FileRecorder::new() + } + } + + // optional .medea.Member member = 4; + + + pub fn get_member(&self) -> &Member { + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::member(ref v)) => v, + _ => Member::default_instance(), + } + } + pub fn clear_member(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_member(&self) -> bool { + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::member(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_member(&mut self, v: Member) { + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::member(v)) + } + + // Mutable pointer to the field. + pub fn mut_member(&mut self) -> &mut Member { + if let ::std::option::Option::Some(CreateRequest_oneof_el::member(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::member(Member::new())); + } + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::member(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_member(&mut self) -> Member { + if self.has_member() { + match self.el.take() { + ::std::option::Option::Some(CreateRequest_oneof_el::member(v)) => v, + _ => panic!(), + } + } else { + Member::new() + } + } + + // optional .medea.Relay relay = 5; + + + pub fn get_relay(&self) -> &Relay { + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::relay(ref v)) => v, + _ => Relay::default_instance(), + } + } + pub fn clear_relay(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_relay(&self) -> bool { + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::relay(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_relay(&mut self, v: Relay) { + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::relay(v)) + } + + // Mutable pointer to the field. + pub fn mut_relay(&mut self) -> &mut Relay { + if let ::std::option::Option::Some(CreateRequest_oneof_el::relay(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::relay(Relay::new())); + } + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::relay(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_relay(&mut self) -> Relay { + if self.has_relay() { + match self.el.take() { + ::std::option::Option::Some(CreateRequest_oneof_el::relay(v)) => v, + _ => panic!(), + } + } else { + Relay::new() + } + } + + // optional .medea.Room room = 6; + + + pub fn get_room(&self) -> &Room { + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::room(ref v)) => v, + _ => Room::default_instance(), + } + } + pub fn clear_room(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_room(&self) -> bool { + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::room(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_room(&mut self, v: Room) { + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::room(v)) + } + + // Mutable pointer to the field. + pub fn mut_room(&mut self) -> &mut Room { + if let ::std::option::Option::Some(CreateRequest_oneof_el::room(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::room(Room::new())); + } + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::room(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_room(&mut self) -> Room { + if self.has_room() { + match self.el.take() { + ::std::option::Option::Some(CreateRequest_oneof_el::room(v)) => v, + _ => panic!(), + } + } else { + Room::new() + } + } + + // optional .medea.WebRtcPlayEndpoint webrtc_play = 7; + + + pub fn get_webrtc_play(&self) -> &WebRtcPlayEndpoint { + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_play(ref v)) => v, + _ => WebRtcPlayEndpoint::default_instance(), + } + } + pub fn clear_webrtc_play(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_webrtc_play(&self) -> bool { + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_play(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_webrtc_play(&mut self, v: WebRtcPlayEndpoint) { + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_play(v)) + } + + // Mutable pointer to the field. + pub fn mut_webrtc_play(&mut self) -> &mut WebRtcPlayEndpoint { + if let ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_play(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_play(WebRtcPlayEndpoint::new())); + } + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_play(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_webrtc_play(&mut self) -> WebRtcPlayEndpoint { + if self.has_webrtc_play() { + match self.el.take() { + ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_play(v)) => v, + _ => panic!(), + } + } else { + WebRtcPlayEndpoint::new() + } + } + + // optional .medea.WebRtcPublishEndpoint webrtc_pub = 8; + + + pub fn get_webrtc_pub(&self) -> &WebRtcPublishEndpoint { + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_pub(ref v)) => v, + _ => WebRtcPublishEndpoint::default_instance(), + } + } + pub fn clear_webrtc_pub(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_webrtc_pub(&self) -> bool { + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_pub(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_webrtc_pub(&mut self, v: WebRtcPublishEndpoint) { + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_pub(v)) + } + + // Mutable pointer to the field. + pub fn mut_webrtc_pub(&mut self) -> &mut WebRtcPublishEndpoint { + if let ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_pub(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_pub(WebRtcPublishEndpoint::new())); + } + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_pub(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_webrtc_pub(&mut self) -> WebRtcPublishEndpoint { + if self.has_webrtc_pub() { + match self.el.take() { + ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_pub(v)) => v, + _ => panic!(), + } + } else { + WebRtcPublishEndpoint::new() + } + } +} + +impl ::protobuf::Message for CreateRequest { + fn is_initialized(&self) -> bool { + if self.id.is_none() { + return false; + } + if let Some(CreateRequest_oneof_el::hub(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(CreateRequest_oneof_el::file_recorder(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(CreateRequest_oneof_el::member(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(CreateRequest_oneof_el::relay(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(CreateRequest_oneof_el::room(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(CreateRequest_oneof_el::webrtc_play(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(CreateRequest_oneof_el::webrtc_pub(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.id)?; + }, + 2 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::hub(is.read_message()?)); + }, + 3 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::file_recorder(is.read_message()?)); + }, + 4 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::member(is.read_message()?)); + }, + 5 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::relay(is.read_message()?)); + }, + 6 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::room(is.read_message()?)); + }, + 7 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_play(is.read_message()?)); + }, + 8 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_pub(is.read_message()?)); + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if let Some(ref v) = self.id.as_ref() { + my_size += ::protobuf::rt::string_size(1, &v); + } + if let ::std::option::Option::Some(ref v) = self.el { + match v { + &CreateRequest_oneof_el::hub(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &CreateRequest_oneof_el::file_recorder(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &CreateRequest_oneof_el::member(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &CreateRequest_oneof_el::relay(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &CreateRequest_oneof_el::room(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &CreateRequest_oneof_el::webrtc_play(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &CreateRequest_oneof_el::webrtc_pub(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + }; + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + if let Some(ref v) = self.id.as_ref() { + os.write_string(1, &v)?; + } + if let ::std::option::Option::Some(ref v) = self.el { + match v { + &CreateRequest_oneof_el::hub(ref v) => { + os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &CreateRequest_oneof_el::file_recorder(ref v) => { + os.write_tag(3, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &CreateRequest_oneof_el::member(ref v) => { + os.write_tag(4, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &CreateRequest_oneof_el::relay(ref v) => { + os.write_tag(5, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &CreateRequest_oneof_el::room(ref v) => { + os.write_tag(6, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &CreateRequest_oneof_el::webrtc_play(ref v) => { + os.write_tag(7, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &CreateRequest_oneof_el::webrtc_pub(ref v) => { + os.write_tag(8, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + }; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> CreateRequest { + CreateRequest::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "id", + |m: &CreateRequest| { &m.id }, + |m: &mut CreateRequest| { &mut m.id }, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Hub>( + "hub", + CreateRequest::has_hub, + CreateRequest::get_hub, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, FileRecorder>( + "file_recorder", + CreateRequest::has_file_recorder, + CreateRequest::get_file_recorder, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Member>( + "member", + CreateRequest::has_member, + CreateRequest::get_member, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Relay>( + "relay", + CreateRequest::has_relay, + CreateRequest::get_relay, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Room>( + "room", + CreateRequest::has_room, + CreateRequest::get_room, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPlayEndpoint>( + "webrtc_play", + CreateRequest::has_webrtc_play, + CreateRequest::get_webrtc_play, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPublishEndpoint>( + "webrtc_pub", + CreateRequest::has_webrtc_pub, + CreateRequest::get_webrtc_pub, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "CreateRequest", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static CreateRequest { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const CreateRequest, + }; + unsafe { + instance.get(CreateRequest::new) + } + } +} + +impl ::protobuf::Clear for CreateRequest { + fn clear(&mut self) { + self.id.clear(); + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for CreateRequest { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for CreateRequest { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct ApplyRequest { + // message fields + id: ::protobuf::SingularField<::std::string::String>, + policy: ::std::option::Option, + // message oneof groups + pub el: ::std::option::Option, + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a ApplyRequest { + fn default() -> &'a ApplyRequest { + ::default_instance() + } +} + +#[derive(Clone,PartialEq,Debug)] +pub enum ApplyRequest_oneof_el { + hub(Hub), + file_recorder(FileRecorder), + member(Member), + relay(Relay), + room(Room), + webrtc_play(WebRtcPlayEndpoint), + webrtc_pub(WebRtcPublishEndpoint), +} + +impl ApplyRequest { + pub fn new() -> ApplyRequest { + ::std::default::Default::default() + } + + // required string id = 1; + + + pub fn get_id(&self) -> &str { + match self.id.as_ref() { + Some(v) => &v, + None => "", + } + } + pub fn clear_id(&mut self) { + self.id.clear(); + } + + pub fn has_id(&self) -> bool { + self.id.is_some() + } + + // Param is passed by value, moved + pub fn set_id(&mut self, v: ::std::string::String) { + self.id = ::protobuf::SingularField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_id(&mut self) -> &mut ::std::string::String { + if self.id.is_none() { + self.id.set_default(); + } + self.id.as_mut().unwrap() + } + + // Take field + pub fn take_id(&mut self) -> ::std::string::String { + self.id.take().unwrap_or_else(|| ::std::string::String::new()) + } + + // optional .medea.Hub hub = 2; + + + pub fn get_hub(&self) -> &Hub { + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::hub(ref v)) => v, + _ => Hub::default_instance(), + } + } + pub fn clear_hub(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_hub(&self) -> bool { + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::hub(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_hub(&mut self, v: Hub) { + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::hub(v)) + } + + // Mutable pointer to the field. + pub fn mut_hub(&mut self) -> &mut Hub { + if let ::std::option::Option::Some(ApplyRequest_oneof_el::hub(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::hub(Hub::new())); + } + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::hub(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_hub(&mut self) -> Hub { + if self.has_hub() { + match self.el.take() { + ::std::option::Option::Some(ApplyRequest_oneof_el::hub(v)) => v, + _ => panic!(), + } + } else { + Hub::new() + } + } + + // optional .medea.FileRecorder file_recorder = 3; + + + pub fn get_file_recorder(&self) -> &FileRecorder { + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::file_recorder(ref v)) => v, + _ => FileRecorder::default_instance(), + } + } + pub fn clear_file_recorder(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_file_recorder(&self) -> bool { + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::file_recorder(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_file_recorder(&mut self, v: FileRecorder) { + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::file_recorder(v)) + } + + // Mutable pointer to the field. + pub fn mut_file_recorder(&mut self) -> &mut FileRecorder { + if let ::std::option::Option::Some(ApplyRequest_oneof_el::file_recorder(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::file_recorder(FileRecorder::new())); + } + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::file_recorder(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_file_recorder(&mut self) -> FileRecorder { + if self.has_file_recorder() { + match self.el.take() { + ::std::option::Option::Some(ApplyRequest_oneof_el::file_recorder(v)) => v, + _ => panic!(), + } + } else { + FileRecorder::new() + } + } + + // optional .medea.Member member = 4; + + + pub fn get_member(&self) -> &Member { + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::member(ref v)) => v, + _ => Member::default_instance(), + } + } + pub fn clear_member(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_member(&self) -> bool { + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::member(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_member(&mut self, v: Member) { + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::member(v)) + } + + // Mutable pointer to the field. + pub fn mut_member(&mut self) -> &mut Member { + if let ::std::option::Option::Some(ApplyRequest_oneof_el::member(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::member(Member::new())); + } + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::member(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_member(&mut self) -> Member { + if self.has_member() { + match self.el.take() { + ::std::option::Option::Some(ApplyRequest_oneof_el::member(v)) => v, + _ => panic!(), + } + } else { + Member::new() + } + } + + // optional .medea.Relay relay = 5; + + + pub fn get_relay(&self) -> &Relay { + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::relay(ref v)) => v, + _ => Relay::default_instance(), + } + } + pub fn clear_relay(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_relay(&self) -> bool { + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::relay(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_relay(&mut self, v: Relay) { + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::relay(v)) + } + + // Mutable pointer to the field. + pub fn mut_relay(&mut self) -> &mut Relay { + if let ::std::option::Option::Some(ApplyRequest_oneof_el::relay(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::relay(Relay::new())); + } + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::relay(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_relay(&mut self) -> Relay { + if self.has_relay() { + match self.el.take() { + ::std::option::Option::Some(ApplyRequest_oneof_el::relay(v)) => v, + _ => panic!(), + } + } else { + Relay::new() + } + } + + // optional .medea.Room room = 6; + + + pub fn get_room(&self) -> &Room { + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::room(ref v)) => v, + _ => Room::default_instance(), + } + } + pub fn clear_room(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_room(&self) -> bool { + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::room(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_room(&mut self, v: Room) { + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::room(v)) + } + + // Mutable pointer to the field. + pub fn mut_room(&mut self) -> &mut Room { + if let ::std::option::Option::Some(ApplyRequest_oneof_el::room(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::room(Room::new())); + } + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::room(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_room(&mut self) -> Room { + if self.has_room() { + match self.el.take() { + ::std::option::Option::Some(ApplyRequest_oneof_el::room(v)) => v, + _ => panic!(), + } + } else { + Room::new() + } + } + + // optional .medea.WebRtcPlayEndpoint webrtc_play = 7; + + + pub fn get_webrtc_play(&self) -> &WebRtcPlayEndpoint { + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(ref v)) => v, + _ => WebRtcPlayEndpoint::default_instance(), + } + } + pub fn clear_webrtc_play(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_webrtc_play(&self) -> bool { + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_webrtc_play(&mut self, v: WebRtcPlayEndpoint) { + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(v)) + } + + // Mutable pointer to the field. + pub fn mut_webrtc_play(&mut self) -> &mut WebRtcPlayEndpoint { + if let ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(WebRtcPlayEndpoint::new())); + } + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_webrtc_play(&mut self) -> WebRtcPlayEndpoint { + if self.has_webrtc_play() { + match self.el.take() { + ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(v)) => v, + _ => panic!(), + } + } else { + WebRtcPlayEndpoint::new() + } + } + + // optional .medea.WebRtcPublishEndpoint webrtc_pub = 8; + + + pub fn get_webrtc_pub(&self) -> &WebRtcPublishEndpoint { + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(ref v)) => v, + _ => WebRtcPublishEndpoint::default_instance(), + } + } + pub fn clear_webrtc_pub(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_webrtc_pub(&self) -> bool { + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_webrtc_pub(&mut self, v: WebRtcPublishEndpoint) { + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(v)) + } + + // Mutable pointer to the field. + pub fn mut_webrtc_pub(&mut self) -> &mut WebRtcPublishEndpoint { + if let ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(WebRtcPublishEndpoint::new())); + } + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_webrtc_pub(&mut self) -> WebRtcPublishEndpoint { + if self.has_webrtc_pub() { + match self.el.take() { + ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(v)) => v, + _ => panic!(), + } + } else { + WebRtcPublishEndpoint::new() + } + } + + // optional .medea.ApplyRequest.Policy policy = 9; + + + pub fn get_policy(&self) -> ApplyRequest_Policy { + self.policy.unwrap_or(ApplyRequest_Policy::APPLY) + } + pub fn clear_policy(&mut self) { + self.policy = ::std::option::Option::None; + } + + pub fn has_policy(&self) -> bool { + self.policy.is_some() + } + + // Param is passed by value, moved + pub fn set_policy(&mut self, v: ApplyRequest_Policy) { + self.policy = ::std::option::Option::Some(v); + } +} + +impl ::protobuf::Message for ApplyRequest { + fn is_initialized(&self) -> bool { + if self.id.is_none() { + return false; + } + if let Some(ApplyRequest_oneof_el::hub(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(ApplyRequest_oneof_el::file_recorder(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(ApplyRequest_oneof_el::member(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(ApplyRequest_oneof_el::relay(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(ApplyRequest_oneof_el::room(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(ApplyRequest_oneof_el::webrtc_play(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(ApplyRequest_oneof_el::webrtc_pub(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.id)?; + }, + 2 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::hub(is.read_message()?)); + }, + 3 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::file_recorder(is.read_message()?)); + }, + 4 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::member(is.read_message()?)); + }, + 5 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::relay(is.read_message()?)); + }, + 6 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::room(is.read_message()?)); + }, + 7 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(is.read_message()?)); + }, + 8 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(is.read_message()?)); + }, + 9 => { + ::protobuf::rt::read_proto2_enum_with_unknown_fields_into(wire_type, is, &mut self.policy, 9, &mut self.unknown_fields)? + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if let Some(ref v) = self.id.as_ref() { + my_size += ::protobuf::rt::string_size(1, &v); + } + if let Some(v) = self.policy { + my_size += ::protobuf::rt::enum_size(9, v); + } + if let ::std::option::Option::Some(ref v) = self.el { + match v { + &ApplyRequest_oneof_el::hub(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &ApplyRequest_oneof_el::file_recorder(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &ApplyRequest_oneof_el::member(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &ApplyRequest_oneof_el::relay(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &ApplyRequest_oneof_el::room(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &ApplyRequest_oneof_el::webrtc_play(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &ApplyRequest_oneof_el::webrtc_pub(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + }; + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + if let Some(ref v) = self.id.as_ref() { + os.write_string(1, &v)?; + } + if let Some(v) = self.policy { + os.write_enum(9, v.value())?; + } + if let ::std::option::Option::Some(ref v) = self.el { + match v { + &ApplyRequest_oneof_el::hub(ref v) => { + os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &ApplyRequest_oneof_el::file_recorder(ref v) => { + os.write_tag(3, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &ApplyRequest_oneof_el::member(ref v) => { + os.write_tag(4, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &ApplyRequest_oneof_el::relay(ref v) => { + os.write_tag(5, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &ApplyRequest_oneof_el::room(ref v) => { + os.write_tag(6, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &ApplyRequest_oneof_el::webrtc_play(ref v) => { + os.write_tag(7, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &ApplyRequest_oneof_el::webrtc_pub(ref v) => { + os.write_tag(8, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + }; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> ApplyRequest { + ApplyRequest::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "id", + |m: &ApplyRequest| { &m.id }, + |m: &mut ApplyRequest| { &mut m.id }, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Hub>( + "hub", + ApplyRequest::has_hub, + ApplyRequest::get_hub, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, FileRecorder>( + "file_recorder", + ApplyRequest::has_file_recorder, + ApplyRequest::get_file_recorder, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Member>( + "member", + ApplyRequest::has_member, + ApplyRequest::get_member, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Relay>( + "relay", + ApplyRequest::has_relay, + ApplyRequest::get_relay, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Room>( + "room", + ApplyRequest::has_room, + ApplyRequest::get_room, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPlayEndpoint>( + "webrtc_play", + ApplyRequest::has_webrtc_play, + ApplyRequest::get_webrtc_play, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPublishEndpoint>( + "webrtc_pub", + ApplyRequest::has_webrtc_pub, + ApplyRequest::get_webrtc_pub, + )); + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeEnum>( + "policy", + |m: &ApplyRequest| { &m.policy }, + |m: &mut ApplyRequest| { &mut m.policy }, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "ApplyRequest", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static ApplyRequest { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ApplyRequest, + }; + unsafe { + instance.get(ApplyRequest::new) + } + } +} + +impl ::protobuf::Clear for ApplyRequest { + fn clear(&mut self) { + self.id.clear(); + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.policy = ::std::option::Option::None; + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for ApplyRequest { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for ApplyRequest { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(Clone,PartialEq,Eq,Debug,Hash)] +pub enum ApplyRequest_Policy { + APPLY = 1, + APPEND = 2, +} + +impl ::protobuf::ProtobufEnum for ApplyRequest_Policy { + fn value(&self) -> i32 { + *self as i32 + } + + fn from_i32(value: i32) -> ::std::option::Option { + match value { + 1 => ::std::option::Option::Some(ApplyRequest_Policy::APPLY), + 2 => ::std::option::Option::Some(ApplyRequest_Policy::APPEND), + _ => ::std::option::Option::None + } + } + + fn values() -> &'static [Self] { + static values: &'static [ApplyRequest_Policy] = &[ + ApplyRequest_Policy::APPLY, + ApplyRequest_Policy::APPEND, + ]; + values + } + + fn enum_descriptor_static() -> &'static ::protobuf::reflect::EnumDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::EnumDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::EnumDescriptor, + }; + unsafe { + descriptor.get(|| { + ::protobuf::reflect::EnumDescriptor::new("ApplyRequest_Policy", file_descriptor_proto()) + }) + } + } +} + +impl ::std::marker::Copy for ApplyRequest_Policy { +} + +// Note, `Default` is implemented although default value is not 0 +impl ::std::default::Default for ApplyRequest_Policy { + fn default() -> Self { + ApplyRequest_Policy::APPLY + } +} + +impl ::protobuf::reflect::ProtobufValue for ApplyRequest_Policy { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Enum(self.descriptor()) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct IdRequest { + // message fields + id: ::protobuf::RepeatedField<::std::string::String>, + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a IdRequest { + fn default() -> &'a IdRequest { + ::default_instance() + } +} + +impl IdRequest { + pub fn new() -> IdRequest { + ::std::default::Default::default() + } + + // repeated string id = 1; + + + pub fn get_id(&self) -> &[::std::string::String] { + &self.id + } + pub fn clear_id(&mut self) { + self.id.clear(); + } + + // Param is passed by value, moved + pub fn set_id(&mut self, v: ::protobuf::RepeatedField<::std::string::String>) { + self.id = v; + } + + // Mutable pointer to the field. + pub fn mut_id(&mut self) -> &mut ::protobuf::RepeatedField<::std::string::String> { + &mut self.id + } + + // Take field + pub fn take_id(&mut self) -> ::protobuf::RepeatedField<::std::string::String> { + ::std::mem::replace(&mut self.id, ::protobuf::RepeatedField::new()) + } +} + +impl ::protobuf::Message for IdRequest { + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_repeated_string_into(wire_type, is, &mut self.id)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + for value in &self.id { + my_size += ::protobuf::rt::string_size(1, &value); + }; + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + for v in &self.id { + os.write_string(1, &v)?; + }; + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> IdRequest { + IdRequest::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "id", + |m: &IdRequest| { &m.id }, + |m: &mut IdRequest| { &mut m.id }, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "IdRequest", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static IdRequest { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const IdRequest, + }; + unsafe { + instance.get(IdRequest::new) + } + } +} + +impl ::protobuf::Clear for IdRequest { + fn clear(&mut self) { + self.id.clear(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for IdRequest { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for IdRequest { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct Response { + // message fields + pub sid: ::std::collections::HashMap<::std::string::String, ::std::string::String>, + error: ::protobuf::SingularPtrField, + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a Response { + fn default() -> &'a Response { + ::default_instance() + } +} + +impl Response { + pub fn new() -> Response { + ::std::default::Default::default() + } + + // repeated .medea.Response.SidEntry sid = 1; + + + pub fn get_sid(&self) -> &::std::collections::HashMap<::std::string::String, ::std::string::String> { + &self.sid + } + pub fn clear_sid(&mut self) { + self.sid.clear(); + } + + // Param is passed by value, moved + pub fn set_sid(&mut self, v: ::std::collections::HashMap<::std::string::String, ::std::string::String>) { + self.sid = v; + } + + // Mutable pointer to the field. + pub fn mut_sid(&mut self) -> &mut ::std::collections::HashMap<::std::string::String, ::std::string::String> { + &mut self.sid + } + + // Take field + pub fn take_sid(&mut self) -> ::std::collections::HashMap<::std::string::String, ::std::string::String> { + ::std::mem::replace(&mut self.sid, ::std::collections::HashMap::new()) + } + + // optional .medea.Error error = 2; + + + pub fn get_error(&self) -> &Error { + self.error.as_ref().unwrap_or_else(|| Error::default_instance()) + } + pub fn clear_error(&mut self) { + self.error.clear(); + } + + pub fn has_error(&self) -> bool { + self.error.is_some() + } + + // Param is passed by value, moved + pub fn set_error(&mut self, v: Error) { + self.error = ::protobuf::SingularPtrField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_error(&mut self) -> &mut Error { + if self.error.is_none() { + self.error.set_default(); + } + self.error.as_mut().unwrap() + } + + // Take field + pub fn take_error(&mut self) -> Error { + self.error.take().unwrap_or_else(|| Error::new()) + } +} + +impl ::protobuf::Message for Response { + fn is_initialized(&self) -> bool { + for v in &self.error { + if !v.is_initialized() { + return false; + } + }; + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_map_into::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeString>(wire_type, is, &mut self.sid)?; + }, + 2 => { + ::protobuf::rt::read_singular_message_into(wire_type, is, &mut self.error)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + my_size += ::protobuf::rt::compute_map_size::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeString>(1, &self.sid); + if let Some(ref v) = self.error.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + ::protobuf::rt::write_map_with_cached_sizes::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeString>(1, &self.sid, os)?; + if let Some(ref v) = self.error.as_ref() { + os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> Response { + Response::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_map_accessor::<_, ::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeString>( + "sid", + |m: &Response| { &m.sid }, + |m: &mut Response| { &mut m.sid }, + )); + fields.push(::protobuf::reflect::accessor::make_singular_ptr_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( + "error", + |m: &Response| { &m.error }, + |m: &mut Response| { &mut m.error }, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "Response", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static Response { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const Response, + }; + unsafe { + instance.get(Response::new) + } + } +} + +impl ::protobuf::Clear for Response { + fn clear(&mut self) { + self.sid.clear(); + self.error.clear(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for Response { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for Response { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct GetResponse { + // message fields + pub elements: ::std::collections::HashMap<::std::string::String, Element>, + error: ::protobuf::SingularPtrField, + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a GetResponse { + fn default() -> &'a GetResponse { + ::default_instance() + } +} + +impl GetResponse { + pub fn new() -> GetResponse { + ::std::default::Default::default() + } + + // repeated .medea.GetResponse.ElementsEntry elements = 1; + + + pub fn get_elements(&self) -> &::std::collections::HashMap<::std::string::String, Element> { + &self.elements + } + pub fn clear_elements(&mut self) { + self.elements.clear(); + } + + // Param is passed by value, moved + pub fn set_elements(&mut self, v: ::std::collections::HashMap<::std::string::String, Element>) { + self.elements = v; + } + + // Mutable pointer to the field. + pub fn mut_elements(&mut self) -> &mut ::std::collections::HashMap<::std::string::String, Element> { + &mut self.elements + } + + // Take field + pub fn take_elements(&mut self) -> ::std::collections::HashMap<::std::string::String, Element> { + ::std::mem::replace(&mut self.elements, ::std::collections::HashMap::new()) + } + + // optional .medea.Error error = 2; + + + pub fn get_error(&self) -> &Error { + self.error.as_ref().unwrap_or_else(|| Error::default_instance()) + } + pub fn clear_error(&mut self) { + self.error.clear(); + } + + pub fn has_error(&self) -> bool { + self.error.is_some() + } + + // Param is passed by value, moved + pub fn set_error(&mut self, v: Error) { + self.error = ::protobuf::SingularPtrField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_error(&mut self) -> &mut Error { + if self.error.is_none() { + self.error.set_default(); + } + self.error.as_mut().unwrap() + } + + // Take field + pub fn take_error(&mut self) -> Error { + self.error.take().unwrap_or_else(|| Error::new()) + } +} + +impl ::protobuf::Message for GetResponse { + fn is_initialized(&self) -> bool { + for v in &self.error { + if !v.is_initialized() { + return false; + } + }; + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_map_into::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(wire_type, is, &mut self.elements)?; + }, + 2 => { + ::protobuf::rt::read_singular_message_into(wire_type, is, &mut self.error)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + my_size += ::protobuf::rt::compute_map_size::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(1, &self.elements); + if let Some(ref v) = self.error.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + ::protobuf::rt::write_map_with_cached_sizes::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(1, &self.elements, os)?; + if let Some(ref v) = self.error.as_ref() { + os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> GetResponse { + GetResponse::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_map_accessor::<_, ::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>( + "elements", + |m: &GetResponse| { &m.elements }, + |m: &mut GetResponse| { &mut m.elements }, + )); + fields.push(::protobuf::reflect::accessor::make_singular_ptr_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( + "error", + |m: &GetResponse| { &m.error }, + |m: &mut GetResponse| { &mut m.error }, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "GetResponse", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static GetResponse { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const GetResponse, + }; + unsafe { + instance.get(GetResponse::new) + } + } +} + +impl ::protobuf::Clear for GetResponse { + fn clear(&mut self) { + self.elements.clear(); + self.error.clear(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for GetResponse { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for GetResponse { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct Error { + // message fields + status: ::std::option::Option, + code: ::std::option::Option, + text: ::protobuf::SingularField<::std::string::String>, + doc: ::protobuf::SingularField<::std::string::String>, + element: ::protobuf::SingularField<::std::string::String>, + details: ::protobuf::SingularPtrField<::protobuf::well_known_types::Any>, + backtrace: ::protobuf::RepeatedField<::std::string::String>, + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a Error { + fn default() -> &'a Error { + ::default_instance() + } +} + +impl Error { + pub fn new() -> Error { + ::std::default::Default::default() + } + + // required uint32 status = 1; + + + pub fn get_status(&self) -> u32 { + self.status.unwrap_or(0) + } + pub fn clear_status(&mut self) { + self.status = ::std::option::Option::None; + } + + pub fn has_status(&self) -> bool { + self.status.is_some() + } + + // Param is passed by value, moved + pub fn set_status(&mut self, v: u32) { + self.status = ::std::option::Option::Some(v); + } + + // required uint32 code = 2; + + + pub fn get_code(&self) -> u32 { + self.code.unwrap_or(0) + } + pub fn clear_code(&mut self) { + self.code = ::std::option::Option::None; + } + + pub fn has_code(&self) -> bool { + self.code.is_some() + } + + // Param is passed by value, moved + pub fn set_code(&mut self, v: u32) { + self.code = ::std::option::Option::Some(v); + } + + // required string text = 3; + + + pub fn get_text(&self) -> &str { + match self.text.as_ref() { + Some(v) => &v, + None => "", + } + } + pub fn clear_text(&mut self) { + self.text.clear(); + } + + pub fn has_text(&self) -> bool { + self.text.is_some() + } + + // Param is passed by value, moved + pub fn set_text(&mut self, v: ::std::string::String) { + self.text = ::protobuf::SingularField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_text(&mut self) -> &mut ::std::string::String { + if self.text.is_none() { + self.text.set_default(); + } + self.text.as_mut().unwrap() + } + + // Take field + pub fn take_text(&mut self) -> ::std::string::String { + self.text.take().unwrap_or_else(|| ::std::string::String::new()) + } + + // optional string doc = 4; + + + pub fn get_doc(&self) -> &str { + match self.doc.as_ref() { + Some(v) => &v, + None => "", + } + } + pub fn clear_doc(&mut self) { + self.doc.clear(); + } + + pub fn has_doc(&self) -> bool { + self.doc.is_some() + } + + // Param is passed by value, moved + pub fn set_doc(&mut self, v: ::std::string::String) { + self.doc = ::protobuf::SingularField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_doc(&mut self) -> &mut ::std::string::String { + if self.doc.is_none() { + self.doc.set_default(); + } + self.doc.as_mut().unwrap() + } + + // Take field + pub fn take_doc(&mut self) -> ::std::string::String { + self.doc.take().unwrap_or_else(|| ::std::string::String::new()) + } + + // required string element = 5; + + + pub fn get_element(&self) -> &str { + match self.element.as_ref() { + Some(v) => &v, + None => "", + } + } + pub fn clear_element(&mut self) { + self.element.clear(); + } + + pub fn has_element(&self) -> bool { + self.element.is_some() + } + + // Param is passed by value, moved + pub fn set_element(&mut self, v: ::std::string::String) { + self.element = ::protobuf::SingularField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_element(&mut self) -> &mut ::std::string::String { + if self.element.is_none() { + self.element.set_default(); + } + self.element.as_mut().unwrap() + } + + // Take field + pub fn take_element(&mut self) -> ::std::string::String { + self.element.take().unwrap_or_else(|| ::std::string::String::new()) + } + + // optional .google.protobuf.Any details = 6; + + + pub fn get_details(&self) -> &::protobuf::well_known_types::Any { + self.details.as_ref().unwrap_or_else(|| ::protobuf::well_known_types::Any::default_instance()) + } + pub fn clear_details(&mut self) { + self.details.clear(); + } + + pub fn has_details(&self) -> bool { + self.details.is_some() + } + + // Param is passed by value, moved + pub fn set_details(&mut self, v: ::protobuf::well_known_types::Any) { + self.details = ::protobuf::SingularPtrField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_details(&mut self) -> &mut ::protobuf::well_known_types::Any { + if self.details.is_none() { + self.details.set_default(); + } + self.details.as_mut().unwrap() + } + + // Take field + pub fn take_details(&mut self) -> ::protobuf::well_known_types::Any { + self.details.take().unwrap_or_else(|| ::protobuf::well_known_types::Any::new()) + } + + // repeated string backtrace = 7; + + + pub fn get_backtrace(&self) -> &[::std::string::String] { + &self.backtrace + } + pub fn clear_backtrace(&mut self) { + self.backtrace.clear(); + } + + // Param is passed by value, moved + pub fn set_backtrace(&mut self, v: ::protobuf::RepeatedField<::std::string::String>) { + self.backtrace = v; + } + + // Mutable pointer to the field. + pub fn mut_backtrace(&mut self) -> &mut ::protobuf::RepeatedField<::std::string::String> { + &mut self.backtrace + } + + // Take field + pub fn take_backtrace(&mut self) -> ::protobuf::RepeatedField<::std::string::String> { + ::std::mem::replace(&mut self.backtrace, ::protobuf::RepeatedField::new()) + } +} + +impl ::protobuf::Message for Error { + fn is_initialized(&self) -> bool { + if self.status.is_none() { + return false; + } + if self.code.is_none() { + return false; + } + if self.text.is_none() { + return false; + } + if self.element.is_none() { + return false; + } + for v in &self.details { + if !v.is_initialized() { + return false; + } + }; + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + if wire_type != ::protobuf::wire_format::WireTypeVarint { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + let tmp = is.read_uint32()?; + self.status = ::std::option::Option::Some(tmp); + }, + 2 => { + if wire_type != ::protobuf::wire_format::WireTypeVarint { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + let tmp = is.read_uint32()?; + self.code = ::std::option::Option::Some(tmp); + }, + 3 => { + ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.text)?; + }, + 4 => { + ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.doc)?; + }, + 5 => { + ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.element)?; + }, + 6 => { + ::protobuf::rt::read_singular_message_into(wire_type, is, &mut self.details)?; + }, + 7 => { + ::protobuf::rt::read_repeated_string_into(wire_type, is, &mut self.backtrace)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if let Some(v) = self.status { + my_size += ::protobuf::rt::value_size(1, v, ::protobuf::wire_format::WireTypeVarint); + } + if let Some(v) = self.code { + my_size += ::protobuf::rt::value_size(2, v, ::protobuf::wire_format::WireTypeVarint); + } + if let Some(ref v) = self.text.as_ref() { + my_size += ::protobuf::rt::string_size(3, &v); + } + if let Some(ref v) = self.doc.as_ref() { + my_size += ::protobuf::rt::string_size(4, &v); + } + if let Some(ref v) = self.element.as_ref() { + my_size += ::protobuf::rt::string_size(5, &v); + } + if let Some(ref v) = self.details.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + } + for value in &self.backtrace { + my_size += ::protobuf::rt::string_size(7, &value); + }; + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + if let Some(v) = self.status { + os.write_uint32(1, v)?; + } + if let Some(v) = self.code { + os.write_uint32(2, v)?; + } + if let Some(ref v) = self.text.as_ref() { + os.write_string(3, &v)?; + } + if let Some(ref v) = self.doc.as_ref() { + os.write_string(4, &v)?; + } + if let Some(ref v) = self.element.as_ref() { + os.write_string(5, &v)?; + } + if let Some(ref v) = self.details.as_ref() { + os.write_tag(6, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + } + for v in &self.backtrace { + os.write_string(7, &v)?; + }; + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> Error { + Error::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeUint32>( + "status", + |m: &Error| { &m.status }, + |m: &mut Error| { &mut m.status }, + )); + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeUint32>( + "code", + |m: &Error| { &m.code }, + |m: &mut Error| { &mut m.code }, + )); + fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "text", + |m: &Error| { &m.text }, + |m: &mut Error| { &mut m.text }, + )); + fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "doc", + |m: &Error| { &m.doc }, + |m: &mut Error| { &mut m.doc }, + )); + fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "element", + |m: &Error| { &m.element }, + |m: &mut Error| { &mut m.element }, + )); + fields.push(::protobuf::reflect::accessor::make_singular_ptr_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage<::protobuf::well_known_types::Any>>( + "details", + |m: &Error| { &m.details }, + |m: &mut Error| { &mut m.details }, + )); + fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "backtrace", + |m: &Error| { &m.backtrace }, + |m: &mut Error| { &mut m.backtrace }, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "Error", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static Error { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const Error, + }; + unsafe { + instance.get(Error::new) + } + } +} + +impl ::protobuf::Clear for Error { + fn clear(&mut self) { + self.status = ::std::option::Option::None; + self.code = ::std::option::Option::None; + self.text.clear(); + self.doc.clear(); + self.element.clear(); + self.details.clear(); + self.backtrace.clear(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for Error { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for Error { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct Element { + // message oneof groups + pub el: ::std::option::Option, + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a Element { + fn default() -> &'a Element { + ::default_instance() + } +} + +#[derive(Clone,PartialEq,Debug)] +pub enum Element_oneof_el { + hub(Hub), + file_recorder(FileRecorder), + member(Member), + relay(Relay), + room(Room), + webrtc_play(WebRtcPlayEndpoint), + webrtc_pub(WebRtcPublishEndpoint), +} + +impl Element { + pub fn new() -> Element { + ::std::default::Default::default() + } + + // optional .medea.Hub hub = 2; + + + pub fn get_hub(&self) -> &Hub { + match self.el { + ::std::option::Option::Some(Element_oneof_el::hub(ref v)) => v, + _ => Hub::default_instance(), + } + } + pub fn clear_hub(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_hub(&self) -> bool { + match self.el { + ::std::option::Option::Some(Element_oneof_el::hub(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_hub(&mut self, v: Hub) { + self.el = ::std::option::Option::Some(Element_oneof_el::hub(v)) + } + + // Mutable pointer to the field. + pub fn mut_hub(&mut self) -> &mut Hub { + if let ::std::option::Option::Some(Element_oneof_el::hub(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Element_oneof_el::hub(Hub::new())); + } + match self.el { + ::std::option::Option::Some(Element_oneof_el::hub(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_hub(&mut self) -> Hub { + if self.has_hub() { + match self.el.take() { + ::std::option::Option::Some(Element_oneof_el::hub(v)) => v, + _ => panic!(), + } + } else { + Hub::new() + } + } + + // optional .medea.FileRecorder file_recorder = 3; + + + pub fn get_file_recorder(&self) -> &FileRecorder { + match self.el { + ::std::option::Option::Some(Element_oneof_el::file_recorder(ref v)) => v, + _ => FileRecorder::default_instance(), + } + } + pub fn clear_file_recorder(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_file_recorder(&self) -> bool { + match self.el { + ::std::option::Option::Some(Element_oneof_el::file_recorder(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_file_recorder(&mut self, v: FileRecorder) { + self.el = ::std::option::Option::Some(Element_oneof_el::file_recorder(v)) + } + + // Mutable pointer to the field. + pub fn mut_file_recorder(&mut self) -> &mut FileRecorder { + if let ::std::option::Option::Some(Element_oneof_el::file_recorder(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Element_oneof_el::file_recorder(FileRecorder::new())); + } + match self.el { + ::std::option::Option::Some(Element_oneof_el::file_recorder(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_file_recorder(&mut self) -> FileRecorder { + if self.has_file_recorder() { + match self.el.take() { + ::std::option::Option::Some(Element_oneof_el::file_recorder(v)) => v, + _ => panic!(), + } + } else { + FileRecorder::new() + } + } + + // optional .medea.Member member = 4; + + + pub fn get_member(&self) -> &Member { + match self.el { + ::std::option::Option::Some(Element_oneof_el::member(ref v)) => v, + _ => Member::default_instance(), + } + } + pub fn clear_member(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_member(&self) -> bool { + match self.el { + ::std::option::Option::Some(Element_oneof_el::member(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_member(&mut self, v: Member) { + self.el = ::std::option::Option::Some(Element_oneof_el::member(v)) + } + + // Mutable pointer to the field. + pub fn mut_member(&mut self) -> &mut Member { + if let ::std::option::Option::Some(Element_oneof_el::member(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Element_oneof_el::member(Member::new())); + } + match self.el { + ::std::option::Option::Some(Element_oneof_el::member(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_member(&mut self) -> Member { + if self.has_member() { + match self.el.take() { + ::std::option::Option::Some(Element_oneof_el::member(v)) => v, + _ => panic!(), + } + } else { + Member::new() + } + } + + // optional .medea.Relay relay = 5; + + + pub fn get_relay(&self) -> &Relay { + match self.el { + ::std::option::Option::Some(Element_oneof_el::relay(ref v)) => v, + _ => Relay::default_instance(), + } + } + pub fn clear_relay(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_relay(&self) -> bool { + match self.el { + ::std::option::Option::Some(Element_oneof_el::relay(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_relay(&mut self, v: Relay) { + self.el = ::std::option::Option::Some(Element_oneof_el::relay(v)) + } + + // Mutable pointer to the field. + pub fn mut_relay(&mut self) -> &mut Relay { + if let ::std::option::Option::Some(Element_oneof_el::relay(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Element_oneof_el::relay(Relay::new())); + } + match self.el { + ::std::option::Option::Some(Element_oneof_el::relay(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_relay(&mut self) -> Relay { + if self.has_relay() { + match self.el.take() { + ::std::option::Option::Some(Element_oneof_el::relay(v)) => v, + _ => panic!(), + } + } else { + Relay::new() + } + } + + // optional .medea.Room room = 6; + + + pub fn get_room(&self) -> &Room { + match self.el { + ::std::option::Option::Some(Element_oneof_el::room(ref v)) => v, + _ => Room::default_instance(), + } + } + pub fn clear_room(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_room(&self) -> bool { + match self.el { + ::std::option::Option::Some(Element_oneof_el::room(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_room(&mut self, v: Room) { + self.el = ::std::option::Option::Some(Element_oneof_el::room(v)) + } + + // Mutable pointer to the field. + pub fn mut_room(&mut self) -> &mut Room { + if let ::std::option::Option::Some(Element_oneof_el::room(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Element_oneof_el::room(Room::new())); + } + match self.el { + ::std::option::Option::Some(Element_oneof_el::room(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_room(&mut self) -> Room { + if self.has_room() { + match self.el.take() { + ::std::option::Option::Some(Element_oneof_el::room(v)) => v, + _ => panic!(), + } + } else { + Room::new() + } + } + + // optional .medea.WebRtcPlayEndpoint webrtc_play = 7; + + + pub fn get_webrtc_play(&self) -> &WebRtcPlayEndpoint { + match self.el { + ::std::option::Option::Some(Element_oneof_el::webrtc_play(ref v)) => v, + _ => WebRtcPlayEndpoint::default_instance(), + } + } + pub fn clear_webrtc_play(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_webrtc_play(&self) -> bool { + match self.el { + ::std::option::Option::Some(Element_oneof_el::webrtc_play(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_webrtc_play(&mut self, v: WebRtcPlayEndpoint) { + self.el = ::std::option::Option::Some(Element_oneof_el::webrtc_play(v)) + } + + // Mutable pointer to the field. + pub fn mut_webrtc_play(&mut self) -> &mut WebRtcPlayEndpoint { + if let ::std::option::Option::Some(Element_oneof_el::webrtc_play(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Element_oneof_el::webrtc_play(WebRtcPlayEndpoint::new())); + } + match self.el { + ::std::option::Option::Some(Element_oneof_el::webrtc_play(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_webrtc_play(&mut self) -> WebRtcPlayEndpoint { + if self.has_webrtc_play() { + match self.el.take() { + ::std::option::Option::Some(Element_oneof_el::webrtc_play(v)) => v, + _ => panic!(), + } + } else { + WebRtcPlayEndpoint::new() + } + } + + // optional .medea.WebRtcPublishEndpoint webrtc_pub = 8; + + + pub fn get_webrtc_pub(&self) -> &WebRtcPublishEndpoint { + match self.el { + ::std::option::Option::Some(Element_oneof_el::webrtc_pub(ref v)) => v, + _ => WebRtcPublishEndpoint::default_instance(), + } + } + pub fn clear_webrtc_pub(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_webrtc_pub(&self) -> bool { + match self.el { + ::std::option::Option::Some(Element_oneof_el::webrtc_pub(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_webrtc_pub(&mut self, v: WebRtcPublishEndpoint) { + self.el = ::std::option::Option::Some(Element_oneof_el::webrtc_pub(v)) + } + + // Mutable pointer to the field. + pub fn mut_webrtc_pub(&mut self) -> &mut WebRtcPublishEndpoint { + if let ::std::option::Option::Some(Element_oneof_el::webrtc_pub(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Element_oneof_el::webrtc_pub(WebRtcPublishEndpoint::new())); + } + match self.el { + ::std::option::Option::Some(Element_oneof_el::webrtc_pub(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_webrtc_pub(&mut self) -> WebRtcPublishEndpoint { + if self.has_webrtc_pub() { + match self.el.take() { + ::std::option::Option::Some(Element_oneof_el::webrtc_pub(v)) => v, + _ => panic!(), + } + } else { + WebRtcPublishEndpoint::new() + } + } +} + +impl ::protobuf::Message for Element { + fn is_initialized(&self) -> bool { + if let Some(Element_oneof_el::hub(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(Element_oneof_el::file_recorder(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(Element_oneof_el::member(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(Element_oneof_el::relay(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(Element_oneof_el::room(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(Element_oneof_el::webrtc_play(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(Element_oneof_el::webrtc_pub(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 2 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Element_oneof_el::hub(is.read_message()?)); + }, + 3 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Element_oneof_el::file_recorder(is.read_message()?)); + }, + 4 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Element_oneof_el::member(is.read_message()?)); + }, + 5 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Element_oneof_el::relay(is.read_message()?)); + }, + 6 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Element_oneof_el::room(is.read_message()?)); + }, + 7 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Element_oneof_el::webrtc_play(is.read_message()?)); + }, + 8 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Element_oneof_el::webrtc_pub(is.read_message()?)); + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if let ::std::option::Option::Some(ref v) = self.el { + match v { + &Element_oneof_el::hub(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &Element_oneof_el::file_recorder(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &Element_oneof_el::member(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &Element_oneof_el::relay(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &Element_oneof_el::room(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &Element_oneof_el::webrtc_play(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &Element_oneof_el::webrtc_pub(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + }; + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + if let ::std::option::Option::Some(ref v) = self.el { + match v { + &Element_oneof_el::hub(ref v) => { + os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &Element_oneof_el::file_recorder(ref v) => { + os.write_tag(3, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &Element_oneof_el::member(ref v) => { + os.write_tag(4, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &Element_oneof_el::relay(ref v) => { + os.write_tag(5, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &Element_oneof_el::room(ref v) => { + os.write_tag(6, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &Element_oneof_el::webrtc_play(ref v) => { + os.write_tag(7, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &Element_oneof_el::webrtc_pub(ref v) => { + os.write_tag(8, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + }; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> Element { + Element::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Hub>( + "hub", + Element::has_hub, + Element::get_hub, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, FileRecorder>( + "file_recorder", + Element::has_file_recorder, + Element::get_file_recorder, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Member>( + "member", + Element::has_member, + Element::get_member, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Relay>( + "relay", + Element::has_relay, + Element::get_relay, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Room>( + "room", + Element::has_room, + Element::get_room, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPlayEndpoint>( + "webrtc_play", + Element::has_webrtc_play, + Element::get_webrtc_play, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPublishEndpoint>( + "webrtc_pub", + Element::has_webrtc_pub, + Element::get_webrtc_pub, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "Element", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static Element { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const Element, + }; + unsafe { + instance.get(Element::new) + } + } +} + +impl ::protobuf::Clear for Element { + fn clear(&mut self) { + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for Element { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for Element { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct Room { + // message fields + pub pipeline: ::std::collections::HashMap<::std::string::String, Room_Element>, + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a Room { + fn default() -> &'a Room { + ::default_instance() + } +} + +impl Room { + pub fn new() -> Room { + ::std::default::Default::default() + } + + // repeated .medea.Room.PipelineEntry pipeline = 1; + + + pub fn get_pipeline(&self) -> &::std::collections::HashMap<::std::string::String, Room_Element> { + &self.pipeline + } + pub fn clear_pipeline(&mut self) { + self.pipeline.clear(); + } + + // Param is passed by value, moved + pub fn set_pipeline(&mut self, v: ::std::collections::HashMap<::std::string::String, Room_Element>) { + self.pipeline = v; + } + + // Mutable pointer to the field. + pub fn mut_pipeline(&mut self) -> &mut ::std::collections::HashMap<::std::string::String, Room_Element> { + &mut self.pipeline + } + + // Take field + pub fn take_pipeline(&mut self) -> ::std::collections::HashMap<::std::string::String, Room_Element> { + ::std::mem::replace(&mut self.pipeline, ::std::collections::HashMap::new()) + } +} + +impl ::protobuf::Message for Room { + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_map_into::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(wire_type, is, &mut self.pipeline)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + my_size += ::protobuf::rt::compute_map_size::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(1, &self.pipeline); + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + ::protobuf::rt::write_map_with_cached_sizes::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(1, &self.pipeline, os)?; + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> Room { + Room::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_map_accessor::<_, ::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>( + "pipeline", + |m: &Room| { &m.pipeline }, + |m: &mut Room| { &mut m.pipeline }, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "Room", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static Room { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const Room, + }; + unsafe { + instance.get(Room::new) + } + } +} + +impl ::protobuf::Clear for Room { + fn clear(&mut self) { + self.pipeline.clear(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for Room { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for Room { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct Room_Element { + // message oneof groups + pub el: ::std::option::Option, + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a Room_Element { + fn default() -> &'a Room_Element { + ::default_instance() + } +} + +#[derive(Clone,PartialEq,Debug)] +pub enum Room_Element_oneof_el { + hub(Hub), + file_recorder(FileRecorder), + member(Member), + relay(Relay), + webrtc_play(WebRtcPlayEndpoint), + webrtc_pub(WebRtcPublishEndpoint), +} + +impl Room_Element { + pub fn new() -> Room_Element { + ::std::default::Default::default() + } + + // optional .medea.Hub hub = 1; + + + pub fn get_hub(&self) -> &Hub { + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::hub(ref v)) => v, + _ => Hub::default_instance(), + } + } + pub fn clear_hub(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_hub(&self) -> bool { + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::hub(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_hub(&mut self, v: Hub) { + self.el = ::std::option::Option::Some(Room_Element_oneof_el::hub(v)) + } + + // Mutable pointer to the field. + pub fn mut_hub(&mut self) -> &mut Hub { + if let ::std::option::Option::Some(Room_Element_oneof_el::hub(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Room_Element_oneof_el::hub(Hub::new())); + } + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::hub(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_hub(&mut self) -> Hub { + if self.has_hub() { + match self.el.take() { + ::std::option::Option::Some(Room_Element_oneof_el::hub(v)) => v, + _ => panic!(), + } + } else { + Hub::new() + } + } + + // optional .medea.FileRecorder file_recorder = 2; + + + pub fn get_file_recorder(&self) -> &FileRecorder { + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::file_recorder(ref v)) => v, + _ => FileRecorder::default_instance(), + } + } + pub fn clear_file_recorder(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_file_recorder(&self) -> bool { + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::file_recorder(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_file_recorder(&mut self, v: FileRecorder) { + self.el = ::std::option::Option::Some(Room_Element_oneof_el::file_recorder(v)) + } + + // Mutable pointer to the field. + pub fn mut_file_recorder(&mut self) -> &mut FileRecorder { + if let ::std::option::Option::Some(Room_Element_oneof_el::file_recorder(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Room_Element_oneof_el::file_recorder(FileRecorder::new())); + } + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::file_recorder(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_file_recorder(&mut self) -> FileRecorder { + if self.has_file_recorder() { + match self.el.take() { + ::std::option::Option::Some(Room_Element_oneof_el::file_recorder(v)) => v, + _ => panic!(), + } + } else { + FileRecorder::new() + } + } + + // optional .medea.Member member = 3; + + + pub fn get_member(&self) -> &Member { + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::member(ref v)) => v, + _ => Member::default_instance(), + } + } + pub fn clear_member(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_member(&self) -> bool { + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::member(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_member(&mut self, v: Member) { + self.el = ::std::option::Option::Some(Room_Element_oneof_el::member(v)) + } + + // Mutable pointer to the field. + pub fn mut_member(&mut self) -> &mut Member { + if let ::std::option::Option::Some(Room_Element_oneof_el::member(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Room_Element_oneof_el::member(Member::new())); + } + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::member(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_member(&mut self) -> Member { + if self.has_member() { + match self.el.take() { + ::std::option::Option::Some(Room_Element_oneof_el::member(v)) => v, + _ => panic!(), + } + } else { + Member::new() + } + } + + // optional .medea.Relay relay = 4; + + + pub fn get_relay(&self) -> &Relay { + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::relay(ref v)) => v, + _ => Relay::default_instance(), + } + } + pub fn clear_relay(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_relay(&self) -> bool { + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::relay(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_relay(&mut self, v: Relay) { + self.el = ::std::option::Option::Some(Room_Element_oneof_el::relay(v)) + } + + // Mutable pointer to the field. + pub fn mut_relay(&mut self) -> &mut Relay { + if let ::std::option::Option::Some(Room_Element_oneof_el::relay(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Room_Element_oneof_el::relay(Relay::new())); + } + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::relay(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_relay(&mut self) -> Relay { + if self.has_relay() { + match self.el.take() { + ::std::option::Option::Some(Room_Element_oneof_el::relay(v)) => v, + _ => panic!(), + } + } else { + Relay::new() + } + } + + // optional .medea.WebRtcPlayEndpoint webrtc_play = 5; + + + pub fn get_webrtc_play(&self) -> &WebRtcPlayEndpoint { + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(ref v)) => v, + _ => WebRtcPlayEndpoint::default_instance(), + } + } + pub fn clear_webrtc_play(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_webrtc_play(&self) -> bool { + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_webrtc_play(&mut self, v: WebRtcPlayEndpoint) { + self.el = ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(v)) + } + + // Mutable pointer to the field. + pub fn mut_webrtc_play(&mut self) -> &mut WebRtcPlayEndpoint { + if let ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(WebRtcPlayEndpoint::new())); + } + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_webrtc_play(&mut self) -> WebRtcPlayEndpoint { + if self.has_webrtc_play() { + match self.el.take() { + ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(v)) => v, + _ => panic!(), + } + } else { + WebRtcPlayEndpoint::new() + } + } + + // optional .medea.WebRtcPublishEndpoint webrtc_pub = 6; + + + pub fn get_webrtc_pub(&self) -> &WebRtcPublishEndpoint { + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(ref v)) => v, + _ => WebRtcPublishEndpoint::default_instance(), + } + } + pub fn clear_webrtc_pub(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_webrtc_pub(&self) -> bool { + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_webrtc_pub(&mut self, v: WebRtcPublishEndpoint) { + self.el = ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(v)) + } + + // Mutable pointer to the field. + pub fn mut_webrtc_pub(&mut self) -> &mut WebRtcPublishEndpoint { + if let ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(WebRtcPublishEndpoint::new())); + } + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_webrtc_pub(&mut self) -> WebRtcPublishEndpoint { + if self.has_webrtc_pub() { + match self.el.take() { + ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(v)) => v, + _ => panic!(), + } + } else { + WebRtcPublishEndpoint::new() + } + } +} + +impl ::protobuf::Message for Room_Element { + fn is_initialized(&self) -> bool { + if let Some(Room_Element_oneof_el::hub(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(Room_Element_oneof_el::file_recorder(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(Room_Element_oneof_el::member(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(Room_Element_oneof_el::relay(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(Room_Element_oneof_el::webrtc_play(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(Room_Element_oneof_el::webrtc_pub(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Room_Element_oneof_el::hub(is.read_message()?)); + }, + 2 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Room_Element_oneof_el::file_recorder(is.read_message()?)); + }, + 3 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Room_Element_oneof_el::member(is.read_message()?)); + }, + 4 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Room_Element_oneof_el::relay(is.read_message()?)); + }, + 5 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(is.read_message()?)); + }, + 6 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(is.read_message()?)); + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if let ::std::option::Option::Some(ref v) = self.el { + match v { + &Room_Element_oneof_el::hub(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &Room_Element_oneof_el::file_recorder(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &Room_Element_oneof_el::member(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &Room_Element_oneof_el::relay(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &Room_Element_oneof_el::webrtc_play(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &Room_Element_oneof_el::webrtc_pub(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + }; + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + if let ::std::option::Option::Some(ref v) = self.el { + match v { + &Room_Element_oneof_el::hub(ref v) => { + os.write_tag(1, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &Room_Element_oneof_el::file_recorder(ref v) => { + os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &Room_Element_oneof_el::member(ref v) => { + os.write_tag(3, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &Room_Element_oneof_el::relay(ref v) => { + os.write_tag(4, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &Room_Element_oneof_el::webrtc_play(ref v) => { + os.write_tag(5, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &Room_Element_oneof_el::webrtc_pub(ref v) => { + os.write_tag(6, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + }; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> Room_Element { + Room_Element::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Hub>( + "hub", + Room_Element::has_hub, + Room_Element::get_hub, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, FileRecorder>( + "file_recorder", + Room_Element::has_file_recorder, + Room_Element::get_file_recorder, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Member>( + "member", + Room_Element::has_member, + Room_Element::get_member, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Relay>( + "relay", + Room_Element::has_relay, + Room_Element::get_relay, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPlayEndpoint>( + "webrtc_play", + Room_Element::has_webrtc_play, + Room_Element::get_webrtc_play, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPublishEndpoint>( + "webrtc_pub", + Room_Element::has_webrtc_pub, + Room_Element::get_webrtc_pub, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "Room_Element", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static Room_Element { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const Room_Element, + }; + unsafe { + instance.get(Room_Element::new) + } + } +} + +impl ::protobuf::Clear for Room_Element { + fn clear(&mut self) { + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for Room_Element { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for Room_Element { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct Member { + // message fields + on_join: ::protobuf::SingularField<::std::string::String>, + on_leave: ::protobuf::SingularField<::std::string::String>, + pub pipeline: ::std::collections::HashMap<::std::string::String, Member_Element>, + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a Member { + fn default() -> &'a Member { + ::default_instance() + } +} + +impl Member { + pub fn new() -> Member { + ::std::default::Default::default() + } + + // optional string on_join = 1; + + + pub fn get_on_join(&self) -> &str { + match self.on_join.as_ref() { + Some(v) => &v, + None => "", + } + } + pub fn clear_on_join(&mut self) { + self.on_join.clear(); + } + + pub fn has_on_join(&self) -> bool { + self.on_join.is_some() + } + + // Param is passed by value, moved + pub fn set_on_join(&mut self, v: ::std::string::String) { + self.on_join = ::protobuf::SingularField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_on_join(&mut self) -> &mut ::std::string::String { + if self.on_join.is_none() { + self.on_join.set_default(); + } + self.on_join.as_mut().unwrap() + } + + // Take field + pub fn take_on_join(&mut self) -> ::std::string::String { + self.on_join.take().unwrap_or_else(|| ::std::string::String::new()) + } + + // optional string on_leave = 2; + + + pub fn get_on_leave(&self) -> &str { + match self.on_leave.as_ref() { + Some(v) => &v, + None => "", + } + } + pub fn clear_on_leave(&mut self) { + self.on_leave.clear(); + } + + pub fn has_on_leave(&self) -> bool { + self.on_leave.is_some() + } + + // Param is passed by value, moved + pub fn set_on_leave(&mut self, v: ::std::string::String) { + self.on_leave = ::protobuf::SingularField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_on_leave(&mut self) -> &mut ::std::string::String { + if self.on_leave.is_none() { + self.on_leave.set_default(); + } + self.on_leave.as_mut().unwrap() + } + + // Take field + pub fn take_on_leave(&mut self) -> ::std::string::String { + self.on_leave.take().unwrap_or_else(|| ::std::string::String::new()) + } + + // repeated .medea.Member.PipelineEntry pipeline = 3; + + + pub fn get_pipeline(&self) -> &::std::collections::HashMap<::std::string::String, Member_Element> { + &self.pipeline + } + pub fn clear_pipeline(&mut self) { + self.pipeline.clear(); + } + + // Param is passed by value, moved + pub fn set_pipeline(&mut self, v: ::std::collections::HashMap<::std::string::String, Member_Element>) { + self.pipeline = v; + } + + // Mutable pointer to the field. + pub fn mut_pipeline(&mut self) -> &mut ::std::collections::HashMap<::std::string::String, Member_Element> { + &mut self.pipeline + } + + // Take field + pub fn take_pipeline(&mut self) -> ::std::collections::HashMap<::std::string::String, Member_Element> { + ::std::mem::replace(&mut self.pipeline, ::std::collections::HashMap::new()) + } +} + +impl ::protobuf::Message for Member { + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.on_join)?; + }, + 2 => { + ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.on_leave)?; + }, + 3 => { + ::protobuf::rt::read_map_into::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(wire_type, is, &mut self.pipeline)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if let Some(ref v) = self.on_join.as_ref() { + my_size += ::protobuf::rt::string_size(1, &v); + } + if let Some(ref v) = self.on_leave.as_ref() { + my_size += ::protobuf::rt::string_size(2, &v); + } + my_size += ::protobuf::rt::compute_map_size::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(3, &self.pipeline); + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + if let Some(ref v) = self.on_join.as_ref() { + os.write_string(1, &v)?; + } + if let Some(ref v) = self.on_leave.as_ref() { + os.write_string(2, &v)?; + } + ::protobuf::rt::write_map_with_cached_sizes::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(3, &self.pipeline, os)?; + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> Member { + Member::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "on_join", + |m: &Member| { &m.on_join }, + |m: &mut Member| { &mut m.on_join }, + )); + fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "on_leave", + |m: &Member| { &m.on_leave }, + |m: &mut Member| { &mut m.on_leave }, + )); + fields.push(::protobuf::reflect::accessor::make_map_accessor::<_, ::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>( + "pipeline", + |m: &Member| { &m.pipeline }, + |m: &mut Member| { &mut m.pipeline }, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "Member", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static Member { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const Member, + }; + unsafe { + instance.get(Member::new) + } + } +} + +impl ::protobuf::Clear for Member { + fn clear(&mut self) { + self.on_join.clear(); + self.on_leave.clear(); + self.pipeline.clear(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for Member { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for Member { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct Member_Element { + // message oneof groups + pub el: ::std::option::Option, + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a Member_Element { + fn default() -> &'a Member_Element { + ::default_instance() + } +} + +#[derive(Clone,PartialEq,Debug)] +pub enum Member_Element_oneof_el { + hub(Hub), + file_recorder(FileRecorder), + relay(Relay), + webrtc_play(WebRtcPlayEndpoint), + webrtc_pub(WebRtcPublishEndpoint), +} + +impl Member_Element { + pub fn new() -> Member_Element { + ::std::default::Default::default() + } + + // optional .medea.Hub hub = 1; + + + pub fn get_hub(&self) -> &Hub { + match self.el { + ::std::option::Option::Some(Member_Element_oneof_el::hub(ref v)) => v, + _ => Hub::default_instance(), + } + } + pub fn clear_hub(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_hub(&self) -> bool { + match self.el { + ::std::option::Option::Some(Member_Element_oneof_el::hub(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_hub(&mut self, v: Hub) { + self.el = ::std::option::Option::Some(Member_Element_oneof_el::hub(v)) + } + + // Mutable pointer to the field. + pub fn mut_hub(&mut self) -> &mut Hub { + if let ::std::option::Option::Some(Member_Element_oneof_el::hub(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Member_Element_oneof_el::hub(Hub::new())); + } + match self.el { + ::std::option::Option::Some(Member_Element_oneof_el::hub(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_hub(&mut self) -> Hub { + if self.has_hub() { + match self.el.take() { + ::std::option::Option::Some(Member_Element_oneof_el::hub(v)) => v, + _ => panic!(), + } + } else { + Hub::new() + } + } + + // optional .medea.FileRecorder file_recorder = 2; + + + pub fn get_file_recorder(&self) -> &FileRecorder { + match self.el { + ::std::option::Option::Some(Member_Element_oneof_el::file_recorder(ref v)) => v, + _ => FileRecorder::default_instance(), + } + } + pub fn clear_file_recorder(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_file_recorder(&self) -> bool { + match self.el { + ::std::option::Option::Some(Member_Element_oneof_el::file_recorder(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_file_recorder(&mut self, v: FileRecorder) { + self.el = ::std::option::Option::Some(Member_Element_oneof_el::file_recorder(v)) + } + + // Mutable pointer to the field. + pub fn mut_file_recorder(&mut self) -> &mut FileRecorder { + if let ::std::option::Option::Some(Member_Element_oneof_el::file_recorder(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Member_Element_oneof_el::file_recorder(FileRecorder::new())); + } + match self.el { + ::std::option::Option::Some(Member_Element_oneof_el::file_recorder(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_file_recorder(&mut self) -> FileRecorder { + if self.has_file_recorder() { + match self.el.take() { + ::std::option::Option::Some(Member_Element_oneof_el::file_recorder(v)) => v, + _ => panic!(), + } + } else { + FileRecorder::new() + } + } + + // optional .medea.Relay relay = 3; + + + pub fn get_relay(&self) -> &Relay { + match self.el { + ::std::option::Option::Some(Member_Element_oneof_el::relay(ref v)) => v, + _ => Relay::default_instance(), + } + } + pub fn clear_relay(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_relay(&self) -> bool { + match self.el { + ::std::option::Option::Some(Member_Element_oneof_el::relay(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_relay(&mut self, v: Relay) { + self.el = ::std::option::Option::Some(Member_Element_oneof_el::relay(v)) + } + + // Mutable pointer to the field. + pub fn mut_relay(&mut self) -> &mut Relay { + if let ::std::option::Option::Some(Member_Element_oneof_el::relay(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Member_Element_oneof_el::relay(Relay::new())); + } + match self.el { + ::std::option::Option::Some(Member_Element_oneof_el::relay(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_relay(&mut self) -> Relay { + if self.has_relay() { + match self.el.take() { + ::std::option::Option::Some(Member_Element_oneof_el::relay(v)) => v, + _ => panic!(), + } + } else { + Relay::new() + } + } + + // optional .medea.WebRtcPlayEndpoint webrtc_play = 4; + + + pub fn get_webrtc_play(&self) -> &WebRtcPlayEndpoint { + match self.el { + ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(ref v)) => v, + _ => WebRtcPlayEndpoint::default_instance(), + } + } + pub fn clear_webrtc_play(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_webrtc_play(&self) -> bool { + match self.el { + ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_webrtc_play(&mut self, v: WebRtcPlayEndpoint) { + self.el = ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(v)) + } + + // Mutable pointer to the field. + pub fn mut_webrtc_play(&mut self) -> &mut WebRtcPlayEndpoint { + if let ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(WebRtcPlayEndpoint::new())); + } + match self.el { + ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_webrtc_play(&mut self) -> WebRtcPlayEndpoint { + if self.has_webrtc_play() { + match self.el.take() { + ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(v)) => v, + _ => panic!(), + } + } else { + WebRtcPlayEndpoint::new() + } + } + + // optional .medea.WebRtcPublishEndpoint webrtc_pub = 5; + + + pub fn get_webrtc_pub(&self) -> &WebRtcPublishEndpoint { + match self.el { + ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(ref v)) => v, + _ => WebRtcPublishEndpoint::default_instance(), + } + } + pub fn clear_webrtc_pub(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_webrtc_pub(&self) -> bool { + match self.el { + ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_webrtc_pub(&mut self, v: WebRtcPublishEndpoint) { + self.el = ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(v)) + } + + // Mutable pointer to the field. + pub fn mut_webrtc_pub(&mut self) -> &mut WebRtcPublishEndpoint { + if let ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(WebRtcPublishEndpoint::new())); + } + match self.el { + ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_webrtc_pub(&mut self) -> WebRtcPublishEndpoint { + if self.has_webrtc_pub() { + match self.el.take() { + ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(v)) => v, + _ => panic!(), + } + } else { + WebRtcPublishEndpoint::new() + } + } +} + +impl ::protobuf::Message for Member_Element { + fn is_initialized(&self) -> bool { + if let Some(Member_Element_oneof_el::hub(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(Member_Element_oneof_el::file_recorder(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(Member_Element_oneof_el::relay(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(Member_Element_oneof_el::webrtc_play(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(Member_Element_oneof_el::webrtc_pub(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Member_Element_oneof_el::hub(is.read_message()?)); + }, + 2 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Member_Element_oneof_el::file_recorder(is.read_message()?)); + }, + 3 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Member_Element_oneof_el::relay(is.read_message()?)); + }, + 4 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(is.read_message()?)); + }, + 5 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(is.read_message()?)); + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if let ::std::option::Option::Some(ref v) = self.el { + match v { + &Member_Element_oneof_el::hub(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &Member_Element_oneof_el::file_recorder(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &Member_Element_oneof_el::relay(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &Member_Element_oneof_el::webrtc_play(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &Member_Element_oneof_el::webrtc_pub(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + }; + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + if let ::std::option::Option::Some(ref v) = self.el { + match v { + &Member_Element_oneof_el::hub(ref v) => { + os.write_tag(1, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &Member_Element_oneof_el::file_recorder(ref v) => { + os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &Member_Element_oneof_el::relay(ref v) => { + os.write_tag(3, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &Member_Element_oneof_el::webrtc_play(ref v) => { + os.write_tag(4, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &Member_Element_oneof_el::webrtc_pub(ref v) => { + os.write_tag(5, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + }; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> Member_Element { + Member_Element::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Hub>( + "hub", + Member_Element::has_hub, + Member_Element::get_hub, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, FileRecorder>( + "file_recorder", + Member_Element::has_file_recorder, + Member_Element::get_file_recorder, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Relay>( + "relay", + Member_Element::has_relay, + Member_Element::get_relay, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPlayEndpoint>( + "webrtc_play", + Member_Element::has_webrtc_play, + Member_Element::get_webrtc_play, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPublishEndpoint>( + "webrtc_pub", + Member_Element::has_webrtc_pub, + Member_Element::get_webrtc_pub, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "Member_Element", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static Member_Element { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const Member_Element, + }; + unsafe { + instance.get(Member_Element::new) + } + } +} + +impl ::protobuf::Clear for Member_Element { + fn clear(&mut self) { + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for Member_Element { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for Member_Element { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct WebRtcPublishEndpoint { + // message fields + p2p: ::std::option::Option, + dst: ::protobuf::SingularField<::std::string::String>, + on_start: ::protobuf::SingularField<::std::string::String>, + on_stop: ::protobuf::SingularField<::std::string::String>, + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a WebRtcPublishEndpoint { + fn default() -> &'a WebRtcPublishEndpoint { + ::default_instance() + } +} + +impl WebRtcPublishEndpoint { + pub fn new() -> WebRtcPublishEndpoint { + ::std::default::Default::default() + } + + // optional .medea.WebRtcPublishEndpoint.P2P p2p = 1; + + + pub fn get_p2p(&self) -> WebRtcPublishEndpoint_P2P { + self.p2p.unwrap_or(WebRtcPublishEndpoint_P2P::NEVER) + } + pub fn clear_p2p(&mut self) { + self.p2p = ::std::option::Option::None; + } + + pub fn has_p2p(&self) -> bool { + self.p2p.is_some() + } + + // Param is passed by value, moved + pub fn set_p2p(&mut self, v: WebRtcPublishEndpoint_P2P) { + self.p2p = ::std::option::Option::Some(v); + } + + // optional string dst = 2; + + + pub fn get_dst(&self) -> &str { + match self.dst.as_ref() { + Some(v) => &v, + None => "", + } + } + pub fn clear_dst(&mut self) { + self.dst.clear(); + } + + pub fn has_dst(&self) -> bool { + self.dst.is_some() + } + + // Param is passed by value, moved + pub fn set_dst(&mut self, v: ::std::string::String) { + self.dst = ::protobuf::SingularField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_dst(&mut self) -> &mut ::std::string::String { + if self.dst.is_none() { + self.dst.set_default(); + } + self.dst.as_mut().unwrap() + } + + // Take field + pub fn take_dst(&mut self) -> ::std::string::String { + self.dst.take().unwrap_or_else(|| ::std::string::String::new()) + } + + // optional string on_start = 3; + + + pub fn get_on_start(&self) -> &str { + match self.on_start.as_ref() { + Some(v) => &v, + None => "", + } + } + pub fn clear_on_start(&mut self) { + self.on_start.clear(); + } + + pub fn has_on_start(&self) -> bool { + self.on_start.is_some() + } + + // Param is passed by value, moved + pub fn set_on_start(&mut self, v: ::std::string::String) { + self.on_start = ::protobuf::SingularField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_on_start(&mut self) -> &mut ::std::string::String { + if self.on_start.is_none() { + self.on_start.set_default(); + } + self.on_start.as_mut().unwrap() + } + + // Take field + pub fn take_on_start(&mut self) -> ::std::string::String { + self.on_start.take().unwrap_or_else(|| ::std::string::String::new()) + } + + // optional string on_stop = 4; + + + pub fn get_on_stop(&self) -> &str { + match self.on_stop.as_ref() { + Some(v) => &v, + None => "", + } + } + pub fn clear_on_stop(&mut self) { + self.on_stop.clear(); + } + + pub fn has_on_stop(&self) -> bool { + self.on_stop.is_some() + } + + // Param is passed by value, moved + pub fn set_on_stop(&mut self, v: ::std::string::String) { + self.on_stop = ::protobuf::SingularField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_on_stop(&mut self) -> &mut ::std::string::String { + if self.on_stop.is_none() { + self.on_stop.set_default(); + } + self.on_stop.as_mut().unwrap() + } + + // Take field + pub fn take_on_stop(&mut self) -> ::std::string::String { + self.on_stop.take().unwrap_or_else(|| ::std::string::String::new()) + } +} + +impl ::protobuf::Message for WebRtcPublishEndpoint { + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_proto2_enum_with_unknown_fields_into(wire_type, is, &mut self.p2p, 1, &mut self.unknown_fields)? + }, + 2 => { + ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.dst)?; + }, + 3 => { + ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.on_start)?; + }, + 4 => { + ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.on_stop)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if let Some(v) = self.p2p { + my_size += ::protobuf::rt::enum_size(1, v); + } + if let Some(ref v) = self.dst.as_ref() { + my_size += ::protobuf::rt::string_size(2, &v); + } + if let Some(ref v) = self.on_start.as_ref() { + my_size += ::protobuf::rt::string_size(3, &v); + } + if let Some(ref v) = self.on_stop.as_ref() { + my_size += ::protobuf::rt::string_size(4, &v); + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + if let Some(v) = self.p2p { + os.write_enum(1, v.value())?; + } + if let Some(ref v) = self.dst.as_ref() { + os.write_string(2, &v)?; + } + if let Some(ref v) = self.on_start.as_ref() { + os.write_string(3, &v)?; + } + if let Some(ref v) = self.on_stop.as_ref() { + os.write_string(4, &v)?; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> WebRtcPublishEndpoint { + WebRtcPublishEndpoint::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeEnum>( + "p2p", + |m: &WebRtcPublishEndpoint| { &m.p2p }, + |m: &mut WebRtcPublishEndpoint| { &mut m.p2p }, + )); + fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "dst", + |m: &WebRtcPublishEndpoint| { &m.dst }, + |m: &mut WebRtcPublishEndpoint| { &mut m.dst }, + )); + fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "on_start", + |m: &WebRtcPublishEndpoint| { &m.on_start }, + |m: &mut WebRtcPublishEndpoint| { &mut m.on_start }, + )); + fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "on_stop", + |m: &WebRtcPublishEndpoint| { &m.on_stop }, + |m: &mut WebRtcPublishEndpoint| { &mut m.on_stop }, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "WebRtcPublishEndpoint", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static WebRtcPublishEndpoint { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const WebRtcPublishEndpoint, + }; + unsafe { + instance.get(WebRtcPublishEndpoint::new) + } + } +} + +impl ::protobuf::Clear for WebRtcPublishEndpoint { + fn clear(&mut self) { + self.p2p = ::std::option::Option::None; + self.dst.clear(); + self.on_start.clear(); + self.on_stop.clear(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for WebRtcPublishEndpoint { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for WebRtcPublishEndpoint { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(Clone,PartialEq,Eq,Debug,Hash)] +pub enum WebRtcPublishEndpoint_P2P { + NEVER = 0, + IF_POSSIBLE = 1, + ALWAYS = 2, +} + +impl ::protobuf::ProtobufEnum for WebRtcPublishEndpoint_P2P { + fn value(&self) -> i32 { + *self as i32 + } + + fn from_i32(value: i32) -> ::std::option::Option { + match value { + 0 => ::std::option::Option::Some(WebRtcPublishEndpoint_P2P::NEVER), + 1 => ::std::option::Option::Some(WebRtcPublishEndpoint_P2P::IF_POSSIBLE), + 2 => ::std::option::Option::Some(WebRtcPublishEndpoint_P2P::ALWAYS), + _ => ::std::option::Option::None + } + } + + fn values() -> &'static [Self] { + static values: &'static [WebRtcPublishEndpoint_P2P] = &[ + WebRtcPublishEndpoint_P2P::NEVER, + WebRtcPublishEndpoint_P2P::IF_POSSIBLE, + WebRtcPublishEndpoint_P2P::ALWAYS, + ]; + values + } + + fn enum_descriptor_static() -> &'static ::protobuf::reflect::EnumDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::EnumDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::EnumDescriptor, + }; + unsafe { + descriptor.get(|| { + ::protobuf::reflect::EnumDescriptor::new("WebRtcPublishEndpoint_P2P", file_descriptor_proto()) + }) + } + } +} + +impl ::std::marker::Copy for WebRtcPublishEndpoint_P2P { +} + +impl ::std::default::Default for WebRtcPublishEndpoint_P2P { + fn default() -> Self { + WebRtcPublishEndpoint_P2P::NEVER + } +} + +impl ::protobuf::reflect::ProtobufValue for WebRtcPublishEndpoint_P2P { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Enum(self.descriptor()) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct WebRtcPlayEndpoint { + // message fields + src: ::protobuf::SingularField<::std::string::String>, + on_start: ::protobuf::SingularField<::std::string::String>, + on_stop: ::protobuf::SingularField<::std::string::String>, + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a WebRtcPlayEndpoint { + fn default() -> &'a WebRtcPlayEndpoint { + ::default_instance() + } +} + +impl WebRtcPlayEndpoint { + pub fn new() -> WebRtcPlayEndpoint { + ::std::default::Default::default() + } + + // required string src = 1; + + + pub fn get_src(&self) -> &str { + match self.src.as_ref() { + Some(v) => &v, + None => "", + } + } + pub fn clear_src(&mut self) { + self.src.clear(); + } + + pub fn has_src(&self) -> bool { + self.src.is_some() + } + + // Param is passed by value, moved + pub fn set_src(&mut self, v: ::std::string::String) { + self.src = ::protobuf::SingularField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_src(&mut self) -> &mut ::std::string::String { + if self.src.is_none() { + self.src.set_default(); + } + self.src.as_mut().unwrap() + } + + // Take field + pub fn take_src(&mut self) -> ::std::string::String { + self.src.take().unwrap_or_else(|| ::std::string::String::new()) + } + + // optional string on_start = 2; + + + pub fn get_on_start(&self) -> &str { + match self.on_start.as_ref() { + Some(v) => &v, + None => "", + } + } + pub fn clear_on_start(&mut self) { + self.on_start.clear(); + } + + pub fn has_on_start(&self) -> bool { + self.on_start.is_some() + } + + // Param is passed by value, moved + pub fn set_on_start(&mut self, v: ::std::string::String) { + self.on_start = ::protobuf::SingularField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_on_start(&mut self) -> &mut ::std::string::String { + if self.on_start.is_none() { + self.on_start.set_default(); + } + self.on_start.as_mut().unwrap() + } + + // Take field + pub fn take_on_start(&mut self) -> ::std::string::String { + self.on_start.take().unwrap_or_else(|| ::std::string::String::new()) + } + + // optional string on_stop = 3; + + + pub fn get_on_stop(&self) -> &str { + match self.on_stop.as_ref() { + Some(v) => &v, + None => "", + } + } + pub fn clear_on_stop(&mut self) { + self.on_stop.clear(); + } + + pub fn has_on_stop(&self) -> bool { + self.on_stop.is_some() + } + + // Param is passed by value, moved + pub fn set_on_stop(&mut self, v: ::std::string::String) { + self.on_stop = ::protobuf::SingularField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_on_stop(&mut self) -> &mut ::std::string::String { + if self.on_stop.is_none() { + self.on_stop.set_default(); + } + self.on_stop.as_mut().unwrap() + } + + // Take field + pub fn take_on_stop(&mut self) -> ::std::string::String { + self.on_stop.take().unwrap_or_else(|| ::std::string::String::new()) + } +} + +impl ::protobuf::Message for WebRtcPlayEndpoint { + fn is_initialized(&self) -> bool { + if self.src.is_none() { + return false; + } + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.src)?; + }, + 2 => { + ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.on_start)?; + }, + 3 => { + ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.on_stop)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if let Some(ref v) = self.src.as_ref() { + my_size += ::protobuf::rt::string_size(1, &v); + } + if let Some(ref v) = self.on_start.as_ref() { + my_size += ::protobuf::rt::string_size(2, &v); + } + if let Some(ref v) = self.on_stop.as_ref() { + my_size += ::protobuf::rt::string_size(3, &v); + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + if let Some(ref v) = self.src.as_ref() { + os.write_string(1, &v)?; + } + if let Some(ref v) = self.on_start.as_ref() { + os.write_string(2, &v)?; + } + if let Some(ref v) = self.on_stop.as_ref() { + os.write_string(3, &v)?; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> WebRtcPlayEndpoint { + WebRtcPlayEndpoint::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "src", + |m: &WebRtcPlayEndpoint| { &m.src }, + |m: &mut WebRtcPlayEndpoint| { &mut m.src }, + )); + fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "on_start", + |m: &WebRtcPlayEndpoint| { &m.on_start }, + |m: &mut WebRtcPlayEndpoint| { &mut m.on_start }, + )); + fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "on_stop", + |m: &WebRtcPlayEndpoint| { &m.on_stop }, + |m: &mut WebRtcPlayEndpoint| { &mut m.on_stop }, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "WebRtcPlayEndpoint", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static WebRtcPlayEndpoint { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const WebRtcPlayEndpoint, + }; + unsafe { + instance.get(WebRtcPlayEndpoint::new) + } + } +} + +impl ::protobuf::Clear for WebRtcPlayEndpoint { + fn clear(&mut self) { + self.src.clear(); + self.on_start.clear(); + self.on_stop.clear(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for WebRtcPlayEndpoint { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for WebRtcPlayEndpoint { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct Hub { + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a Hub { + fn default() -> &'a Hub { + ::default_instance() + } +} + +impl Hub { + pub fn new() -> Hub { + ::std::default::Default::default() + } +} + +impl ::protobuf::Message for Hub { + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> Hub { + Hub::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let fields = ::std::vec::Vec::new(); + ::protobuf::reflect::MessageDescriptor::new::( + "Hub", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static Hub { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const Hub, + }; + unsafe { + instance.get(Hub::new) + } + } +} + +impl ::protobuf::Clear for Hub { + fn clear(&mut self) { + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for Hub { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for Hub { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct FileRecorder { + // message fields + src: ::protobuf::SingularField<::std::string::String>, + dst: ::protobuf::SingularField<::std::string::String>, + on_start: ::protobuf::SingularField<::std::string::String>, + on_stop: ::protobuf::SingularField<::std::string::String>, + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a FileRecorder { + fn default() -> &'a FileRecorder { + ::default_instance() + } +} + +impl FileRecorder { + pub fn new() -> FileRecorder { + ::std::default::Default::default() + } + + // required string src = 1; + + + pub fn get_src(&self) -> &str { + match self.src.as_ref() { + Some(v) => &v, + None => "", + } + } + pub fn clear_src(&mut self) { + self.src.clear(); + } + + pub fn has_src(&self) -> bool { + self.src.is_some() + } + + // Param is passed by value, moved + pub fn set_src(&mut self, v: ::std::string::String) { + self.src = ::protobuf::SingularField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_src(&mut self) -> &mut ::std::string::String { + if self.src.is_none() { + self.src.set_default(); + } + self.src.as_mut().unwrap() + } + + // Take field + pub fn take_src(&mut self) -> ::std::string::String { + self.src.take().unwrap_or_else(|| ::std::string::String::new()) + } + + // required string dst = 2; + + + pub fn get_dst(&self) -> &str { + match self.dst.as_ref() { + Some(v) => &v, + None => "", + } + } + pub fn clear_dst(&mut self) { + self.dst.clear(); + } + + pub fn has_dst(&self) -> bool { + self.dst.is_some() + } + + // Param is passed by value, moved + pub fn set_dst(&mut self, v: ::std::string::String) { + self.dst = ::protobuf::SingularField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_dst(&mut self) -> &mut ::std::string::String { + if self.dst.is_none() { + self.dst.set_default(); + } + self.dst.as_mut().unwrap() + } + + // Take field + pub fn take_dst(&mut self) -> ::std::string::String { + self.dst.take().unwrap_or_else(|| ::std::string::String::new()) + } + + // optional string on_start = 3; + + + pub fn get_on_start(&self) -> &str { + match self.on_start.as_ref() { + Some(v) => &v, + None => "", + } + } + pub fn clear_on_start(&mut self) { + self.on_start.clear(); + } + + pub fn has_on_start(&self) -> bool { + self.on_start.is_some() + } + + // Param is passed by value, moved + pub fn set_on_start(&mut self, v: ::std::string::String) { + self.on_start = ::protobuf::SingularField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_on_start(&mut self) -> &mut ::std::string::String { + if self.on_start.is_none() { + self.on_start.set_default(); + } + self.on_start.as_mut().unwrap() + } + + // Take field + pub fn take_on_start(&mut self) -> ::std::string::String { + self.on_start.take().unwrap_or_else(|| ::std::string::String::new()) + } + + // optional string on_stop = 4; + + + pub fn get_on_stop(&self) -> &str { + match self.on_stop.as_ref() { + Some(v) => &v, + None => "", + } + } + pub fn clear_on_stop(&mut self) { + self.on_stop.clear(); + } + + pub fn has_on_stop(&self) -> bool { + self.on_stop.is_some() + } + + // Param is passed by value, moved + pub fn set_on_stop(&mut self, v: ::std::string::String) { + self.on_stop = ::protobuf::SingularField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_on_stop(&mut self) -> &mut ::std::string::String { + if self.on_stop.is_none() { + self.on_stop.set_default(); + } + self.on_stop.as_mut().unwrap() + } + + // Take field + pub fn take_on_stop(&mut self) -> ::std::string::String { + self.on_stop.take().unwrap_or_else(|| ::std::string::String::new()) + } +} + +impl ::protobuf::Message for FileRecorder { + fn is_initialized(&self) -> bool { + if self.src.is_none() { + return false; + } + if self.dst.is_none() { + return false; + } + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.src)?; + }, + 2 => { + ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.dst)?; + }, + 3 => { + ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.on_start)?; + }, + 4 => { + ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.on_stop)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if let Some(ref v) = self.src.as_ref() { + my_size += ::protobuf::rt::string_size(1, &v); + } + if let Some(ref v) = self.dst.as_ref() { + my_size += ::protobuf::rt::string_size(2, &v); + } + if let Some(ref v) = self.on_start.as_ref() { + my_size += ::protobuf::rt::string_size(3, &v); + } + if let Some(ref v) = self.on_stop.as_ref() { + my_size += ::protobuf::rt::string_size(4, &v); + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + if let Some(ref v) = self.src.as_ref() { + os.write_string(1, &v)?; + } + if let Some(ref v) = self.dst.as_ref() { + os.write_string(2, &v)?; + } + if let Some(ref v) = self.on_start.as_ref() { + os.write_string(3, &v)?; + } + if let Some(ref v) = self.on_stop.as_ref() { + os.write_string(4, &v)?; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> FileRecorder { + FileRecorder::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "src", + |m: &FileRecorder| { &m.src }, + |m: &mut FileRecorder| { &mut m.src }, + )); + fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "dst", + |m: &FileRecorder| { &m.dst }, + |m: &mut FileRecorder| { &mut m.dst }, + )); + fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "on_start", + |m: &FileRecorder| { &m.on_start }, + |m: &mut FileRecorder| { &mut m.on_start }, + )); + fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "on_stop", + |m: &FileRecorder| { &m.on_stop }, + |m: &mut FileRecorder| { &mut m.on_stop }, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "FileRecorder", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static FileRecorder { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const FileRecorder, + }; + unsafe { + instance.get(FileRecorder::new) + } + } +} + +impl ::protobuf::Clear for FileRecorder { + fn clear(&mut self) { + self.src.clear(); + self.dst.clear(); + self.on_start.clear(); + self.on_stop.clear(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for FileRecorder { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for FileRecorder { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct Relay { + // message fields + src: ::protobuf::SingularField<::std::string::String>, + dst: ::protobuf::SingularField<::std::string::String>, + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a Relay { + fn default() -> &'a Relay { + ::default_instance() + } +} + +impl Relay { + pub fn new() -> Relay { + ::std::default::Default::default() + } + + // required string src = 1; + + + pub fn get_src(&self) -> &str { + match self.src.as_ref() { + Some(v) => &v, + None => "", + } + } + pub fn clear_src(&mut self) { + self.src.clear(); + } + + pub fn has_src(&self) -> bool { + self.src.is_some() + } + + // Param is passed by value, moved + pub fn set_src(&mut self, v: ::std::string::String) { + self.src = ::protobuf::SingularField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_src(&mut self) -> &mut ::std::string::String { + if self.src.is_none() { + self.src.set_default(); + } + self.src.as_mut().unwrap() + } + + // Take field + pub fn take_src(&mut self) -> ::std::string::String { + self.src.take().unwrap_or_else(|| ::std::string::String::new()) + } + + // optional string dst = 2; + + + pub fn get_dst(&self) -> &str { + match self.dst.as_ref() { + Some(v) => &v, + None => "", + } + } + pub fn clear_dst(&mut self) { + self.dst.clear(); + } + + pub fn has_dst(&self) -> bool { + self.dst.is_some() + } + + // Param is passed by value, moved + pub fn set_dst(&mut self, v: ::std::string::String) { + self.dst = ::protobuf::SingularField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_dst(&mut self) -> &mut ::std::string::String { + if self.dst.is_none() { + self.dst.set_default(); + } + self.dst.as_mut().unwrap() + } + + // Take field + pub fn take_dst(&mut self) -> ::std::string::String { + self.dst.take().unwrap_or_else(|| ::std::string::String::new()) + } +} + +impl ::protobuf::Message for Relay { + fn is_initialized(&self) -> bool { + if self.src.is_none() { + return false; + } + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.src)?; + }, + 2 => { + ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.dst)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if let Some(ref v) = self.src.as_ref() { + my_size += ::protobuf::rt::string_size(1, &v); + } + if let Some(ref v) = self.dst.as_ref() { + my_size += ::protobuf::rt::string_size(2, &v); + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + if let Some(ref v) = self.src.as_ref() { + os.write_string(1, &v)?; + } + if let Some(ref v) = self.dst.as_ref() { + os.write_string(2, &v)?; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> Relay { + Relay::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "src", + |m: &Relay| { &m.src }, + |m: &mut Relay| { &mut m.src }, + )); + fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "dst", + |m: &Relay| { &m.dst }, + |m: &mut Relay| { &mut m.dst }, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "Relay", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static Relay { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const Relay, + }; + unsafe { + instance.get(Relay::new) + } + } +} + +impl ::protobuf::Clear for Relay { + fn clear(&mut self) { + self.src.clear(); + self.dst.clear(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for Relay { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for Relay { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +static file_descriptor_proto_data: &'static [u8] = b"\ + \n\rcontrol.proto\x12\x05medea\x1a\x19google/protobuf/any.proto\"\xf0\ + \x02\n\rCreateRequest\x12\x0e\n\x02id\x18\x01\x20\x02(\tR\x02id\x12\x1e\ + \n\x03hub\x18\x02\x20\x01(\x0b2\n.medea.HubH\0R\x03hub\x12:\n\rfile_reco\ + rder\x18\x03\x20\x01(\x0b2\x13.medea.FileRecorderH\0R\x0cfileRecorder\ + \x12'\n\x06member\x18\x04\x20\x01(\x0b2\r.medea.MemberH\0R\x06member\x12\ + $\n\x05relay\x18\x05\x20\x01(\x0b2\x0c.medea.RelayH\0R\x05relay\x12!\n\ + \x04room\x18\x06\x20\x01(\x0b2\x0b.medea.RoomH\0R\x04room\x12<\n\x0bwebr\ + tc_play\x18\x07\x20\x01(\x0b2\x19.medea.WebRtcPlayEndpointH\0R\nwebrtcPl\ + ay\x12=\n\nwebrtc_pub\x18\x08\x20\x01(\x0b2\x1c.medea.WebRtcPublishEndpo\ + intH\0R\twebrtcPubB\x04\n\x02el\"\xcb\x03\n\x0cApplyRequest\x12\x0e\n\ + \x02id\x18\x01\x20\x02(\tR\x02id\x12\x1e\n\x03hub\x18\x02\x20\x01(\x0b2\ + \n.medea.HubH\0R\x03hub\x12:\n\rfile_recorder\x18\x03\x20\x01(\x0b2\x13.\ + medea.FileRecorderH\0R\x0cfileRecorder\x12'\n\x06member\x18\x04\x20\x01(\ + \x0b2\r.medea.MemberH\0R\x06member\x12$\n\x05relay\x18\x05\x20\x01(\x0b2\ + \x0c.medea.RelayH\0R\x05relay\x12!\n\x04room\x18\x06\x20\x01(\x0b2\x0b.m\ + edea.RoomH\0R\x04room\x12<\n\x0bwebrtc_play\x18\x07\x20\x01(\x0b2\x19.me\ + dea.WebRtcPlayEndpointH\0R\nwebrtcPlay\x12=\n\nwebrtc_pub\x18\x08\x20\ + \x01(\x0b2\x1c.medea.WebRtcPublishEndpointH\0R\twebrtcPub\x129\n\x06poli\ + cy\x18\t\x20\x01(\x0e2\x1a.medea.ApplyRequest.Policy:\x05APPLYR\x06polic\ + y\"\x1f\n\x06Policy\x12\t\n\x05APPLY\x10\x01\x12\n\n\x06APPEND\x10\x02B\ + \x04\n\x02el\"\x1b\n\tIdRequest\x12\x0e\n\x02id\x18\x01\x20\x03(\tR\x02i\ + d\"\x92\x01\n\x08Response\x12*\n\x03sid\x18\x01\x20\x03(\x0b2\x18.medea.\ + Response.SidEntryR\x03sid\x12\"\n\x05error\x18\x02\x20\x01(\x0b2\x0c.med\ + ea.ErrorR\x05error\x1a6\n\x08SidEntry\x12\x10\n\x03key\x18\x01\x20\x01(\ + \tR\x03key\x12\x14\n\x05value\x18\x02\x20\x01(\tR\x05value:\x028\x01\"\ + \xbc\x01\n\x0bGetResponse\x12<\n\x08elements\x18\x01\x20\x03(\x0b2\x20.m\ + edea.GetResponse.ElementsEntryR\x08elements\x12\"\n\x05error\x18\x02\x20\ + \x01(\x0b2\x0c.medea.ErrorR\x05error\x1aK\n\rElementsEntry\x12\x10\n\x03\ + key\x18\x01\x20\x01(\tR\x03key\x12$\n\x05value\x18\x02\x20\x01(\x0b2\x0e\ + .medea.ElementR\x05value:\x028\x01\"\xc1\x01\n\x05Error\x12\x16\n\x06sta\ + tus\x18\x01\x20\x02(\rR\x06status\x12\x12\n\x04code\x18\x02\x20\x02(\rR\ + \x04code\x12\x12\n\x04text\x18\x03\x20\x02(\tR\x04text\x12\x10\n\x03doc\ + \x18\x04\x20\x01(\tR\x03doc\x12\x18\n\x07element\x18\x05\x20\x02(\tR\x07\ + element\x12.\n\x07details\x18\x06\x20\x01(\x0b2\x14.google.protobuf.AnyR\ + \x07details\x12\x1c\n\tbacktrace\x18\x07\x20\x03(\tR\tbacktrace\"\xda\ + \x02\n\x07Element\x12\x1e\n\x03hub\x18\x02\x20\x01(\x0b2\n.medea.HubH\0R\ + \x03hub\x12:\n\rfile_recorder\x18\x03\x20\x01(\x0b2\x13.medea.FileRecord\ + erH\0R\x0cfileRecorder\x12'\n\x06member\x18\x04\x20\x01(\x0b2\r.medea.Me\ + mberH\0R\x06member\x12$\n\x05relay\x18\x05\x20\x01(\x0b2\x0c.medea.Relay\ + H\0R\x05relay\x12!\n\x04room\x18\x06\x20\x01(\x0b2\x0b.medea.RoomH\0R\ + \x04room\x12<\n\x0bwebrtc_play\x18\x07\x20\x01(\x0b2\x19.medea.WebRtcPla\ + yEndpointH\0R\nwebrtcPlay\x12=\n\nwebrtc_pub\x18\x08\x20\x01(\x0b2\x1c.m\ + edea.WebRtcPublishEndpointH\0R\twebrtcPubB\x04\n\x02el\"\xc9\x03\n\x04Ro\ + om\x125\n\x08pipeline\x18\x01\x20\x03(\x0b2\x19.medea.Room.PipelineEntry\ + R\x08pipeline\x1aP\n\rPipelineEntry\x12\x10\n\x03key\x18\x01\x20\x01(\tR\ + \x03key\x12)\n\x05value\x18\x02\x20\x01(\x0b2\x13.medea.Room.ElementR\ + \x05value:\x028\x01\x1a\xb7\x02\n\x07Element\x12\x1e\n\x03hub\x18\x01\ + \x20\x01(\x0b2\n.medea.HubH\0R\x03hub\x12:\n\rfile_recorder\x18\x02\x20\ + \x01(\x0b2\x13.medea.FileRecorderH\0R\x0cfileRecorder\x12'\n\x06member\ + \x18\x03\x20\x01(\x0b2\r.medea.MemberH\0R\x06member\x12$\n\x05relay\x18\ + \x04\x20\x01(\x0b2\x0c.medea.RelayH\0R\x05relay\x12<\n\x0bwebrtc_play\ + \x18\x05\x20\x01(\x0b2\x19.medea.WebRtcPlayEndpointH\0R\nwebrtcPlay\x12=\ + \n\nwebrtc_pub\x18\x06\x20\x01(\x0b2\x1c.medea.WebRtcPublishEndpointH\0R\ + \twebrtcPubB\x04\n\x02el\"\xda\x03\n\x06Member\x12\x17\n\x07on_join\x18\ + \x01\x20\x01(\tR\x06onJoin\x12\x19\n\x08on_leave\x18\x02\x20\x01(\tR\x07\ + onLeave\x127\n\x08pipeline\x18\x03\x20\x03(\x0b2\x1b.medea.Member.Pipeli\ + neEntryR\x08pipeline\x1aR\n\rPipelineEntry\x12\x10\n\x03key\x18\x01\x20\ + \x01(\tR\x03key\x12+\n\x05value\x18\x02\x20\x01(\x0b2\x15.medea.Member.E\ + lementR\x05value:\x028\x01\x1a\x8e\x02\n\x07Element\x12\x1e\n\x03hub\x18\ + \x01\x20\x01(\x0b2\n.medea.HubH\0R\x03hub\x12:\n\rfile_recorder\x18\x02\ + \x20\x01(\x0b2\x13.medea.FileRecorderH\0R\x0cfileRecorder\x12$\n\x05rela\ + y\x18\x03\x20\x01(\x0b2\x0c.medea.RelayH\0R\x05relay\x12<\n\x0bwebrtc_pl\ + ay\x18\x04\x20\x01(\x0b2\x19.medea.WebRtcPlayEndpointH\0R\nwebrtcPlay\ + \x12=\n\nwebrtc_pub\x18\x05\x20\x01(\x0b2\x1c.medea.WebRtcPublishEndpoin\ + tH\0R\twebrtcPubB\x04\n\x02el\"\xc7\x01\n\x15WebRtcPublishEndpoint\x129\ + \n\x03p2p\x18\x01\x20\x01(\x0e2\x20.medea.WebRtcPublishEndpoint.P2P:\x05\ + NEVERR\x03p2p\x12\x10\n\x03dst\x18\x02\x20\x01(\tR\x03dst\x12\x19\n\x08o\ + n_start\x18\x03\x20\x01(\tR\x07onStart\x12\x17\n\x07on_stop\x18\x04\x20\ + \x01(\tR\x06onStop\"-\n\x03P2P\x12\t\n\x05NEVER\x10\0\x12\x0f\n\x0bIF_PO\ + SSIBLE\x10\x01\x12\n\n\x06ALWAYS\x10\x02\"Z\n\x12WebRtcPlayEndpoint\x12\ + \x10\n\x03src\x18\x01\x20\x02(\tR\x03src\x12\x19\n\x08on_start\x18\x02\ + \x20\x01(\tR\x07onStart\x12\x17\n\x07on_stop\x18\x03\x20\x01(\tR\x06onSt\ + op\"\x05\n\x03Hub\"f\n\x0cFileRecorder\x12\x10\n\x03src\x18\x01\x20\x02(\ + \tR\x03src\x12\x10\n\x03dst\x18\x02\x20\x02(\tR\x03dst\x12\x19\n\x08on_s\ + tart\x18\x03\x20\x01(\tR\x07onStart\x12\x17\n\x07on_stop\x18\x04\x20\x01\ + (\tR\x06onStop\"+\n\x05Relay\x12\x10\n\x03src\x18\x01\x20\x02(\tR\x03src\ + \x12\x10\n\x03dst\x18\x02\x20\x01(\tR\x03dst2\xc6\x01\n\nControlApi\x12/\ + \n\x06Create\x12\x14.medea.CreateRequest\x1a\x0f.medea.Response\x12-\n\ + \x05Apply\x12\x13.medea.ApplyRequest\x1a\x0f.medea.Response\x12+\n\x06De\ + lete\x12\x10.medea.IdRequest\x1a\x0f.medea.Response\x12+\n\x03Get\x12\ + \x10.medea.IdRequest\x1a\x12.medea.GetResponse\ +"; + +static mut file_descriptor_proto_lazy: ::protobuf::lazy::Lazy<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::descriptor::FileDescriptorProto, +}; + +fn parse_descriptor_proto() -> ::protobuf::descriptor::FileDescriptorProto { + ::protobuf::parse_from_bytes(file_descriptor_proto_data).unwrap() +} + +pub fn file_descriptor_proto() -> &'static ::protobuf::descriptor::FileDescriptorProto { + unsafe { + file_descriptor_proto_lazy.get(|| { + parse_descriptor_proto() + }) + } +} diff --git a/src/api/grpc/protos/control_grpc.rs b/src/api/grpc/protos/control_grpc.rs new file mode 100644 index 000000000..200c56a85 --- /dev/null +++ b/src/api/grpc/protos/control_grpc.rs @@ -0,0 +1,155 @@ +// This file is generated. Do not edit +// @generated + +// https://github.com/Manishearth/rust-clippy/issues/702 +#![allow(unknown_lints)] +#![allow(clippy::all)] + +#![cfg_attr(rustfmt, rustfmt_skip)] + +#![allow(box_pointers)] +#![allow(dead_code)] +#![allow(missing_docs)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] +#![allow(non_upper_case_globals)] +#![allow(trivial_casts)] +#![allow(unsafe_code)] +#![allow(unused_imports)] +#![allow(unused_results)] + +const METHOD_CONTROL_API_CREATE: ::grpcio::Method = ::grpcio::Method { + ty: ::grpcio::MethodType::Unary, + name: "/medea.ControlApi/Create", + req_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, + resp_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, +}; + +const METHOD_CONTROL_API_APPLY: ::grpcio::Method = ::grpcio::Method { + ty: ::grpcio::MethodType::Unary, + name: "/medea.ControlApi/Apply", + req_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, + resp_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, +}; + +const METHOD_CONTROL_API_DELETE: ::grpcio::Method = ::grpcio::Method { + ty: ::grpcio::MethodType::Unary, + name: "/medea.ControlApi/Delete", + req_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, + resp_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, +}; + +const METHOD_CONTROL_API_GET: ::grpcio::Method = ::grpcio::Method { + ty: ::grpcio::MethodType::Unary, + name: "/medea.ControlApi/Get", + req_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, + resp_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, +}; + +#[derive(Clone)] +pub struct ControlApiClient { + client: ::grpcio::Client, +} + +impl ControlApiClient { + pub fn new(channel: ::grpcio::Channel) -> Self { + ControlApiClient { + client: ::grpcio::Client::new(channel), + } + } + + pub fn create_opt(&self, req: &super::control::CreateRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result { + self.client.unary_call(&METHOD_CONTROL_API_CREATE, req, opt) + } + + pub fn create(&self, req: &super::control::CreateRequest) -> ::grpcio::Result { + self.create_opt(req, ::grpcio::CallOption::default()) + } + + pub fn create_async_opt(&self, req: &super::control::CreateRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { + self.client.unary_call_async(&METHOD_CONTROL_API_CREATE, req, opt) + } + + pub fn create_async(&self, req: &super::control::CreateRequest) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { + self.create_async_opt(req, ::grpcio::CallOption::default()) + } + + pub fn apply_opt(&self, req: &super::control::ApplyRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result { + self.client.unary_call(&METHOD_CONTROL_API_APPLY, req, opt) + } + + pub fn apply(&self, req: &super::control::ApplyRequest) -> ::grpcio::Result { + self.apply_opt(req, ::grpcio::CallOption::default()) + } + + pub fn apply_async_opt(&self, req: &super::control::ApplyRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { + self.client.unary_call_async(&METHOD_CONTROL_API_APPLY, req, opt) + } + + pub fn apply_async(&self, req: &super::control::ApplyRequest) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { + self.apply_async_opt(req, ::grpcio::CallOption::default()) + } + + pub fn delete_opt(&self, req: &super::control::IdRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result { + self.client.unary_call(&METHOD_CONTROL_API_DELETE, req, opt) + } + + pub fn delete(&self, req: &super::control::IdRequest) -> ::grpcio::Result { + self.delete_opt(req, ::grpcio::CallOption::default()) + } + + pub fn delete_async_opt(&self, req: &super::control::IdRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { + self.client.unary_call_async(&METHOD_CONTROL_API_DELETE, req, opt) + } + + pub fn delete_async(&self, req: &super::control::IdRequest) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { + self.delete_async_opt(req, ::grpcio::CallOption::default()) + } + + pub fn get_opt(&self, req: &super::control::IdRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result { + self.client.unary_call(&METHOD_CONTROL_API_GET, req, opt) + } + + pub fn get(&self, req: &super::control::IdRequest) -> ::grpcio::Result { + self.get_opt(req, ::grpcio::CallOption::default()) + } + + pub fn get_async_opt(&self, req: &super::control::IdRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { + self.client.unary_call_async(&METHOD_CONTROL_API_GET, req, opt) + } + + pub fn get_async(&self, req: &super::control::IdRequest) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { + self.get_async_opt(req, ::grpcio::CallOption::default()) + } + pub fn spawn(&self, f: F) where F: ::futures::Future + Send + 'static { + self.client.spawn(f) + } +} + +pub trait ControlApi { + fn create(&mut self, ctx: ::grpcio::RpcContext, req: super::control::CreateRequest, sink: ::grpcio::UnarySink); + fn apply(&mut self, ctx: ::grpcio::RpcContext, req: super::control::ApplyRequest, sink: ::grpcio::UnarySink); + fn delete(&mut self, ctx: ::grpcio::RpcContext, req: super::control::IdRequest, sink: ::grpcio::UnarySink); + fn get(&mut self, ctx: ::grpcio::RpcContext, req: super::control::IdRequest, sink: ::grpcio::UnarySink); +} + +pub fn create_control_api(s: S) -> ::grpcio::Service { + let mut builder = ::grpcio::ServiceBuilder::new(); + let mut instance = s.clone(); + builder = builder.add_unary_handler(&METHOD_CONTROL_API_CREATE, move |ctx, req, resp| { + instance.create(ctx, req, resp) + }); + let mut instance = s.clone(); + builder = builder.add_unary_handler(&METHOD_CONTROL_API_APPLY, move |ctx, req, resp| { + instance.apply(ctx, req, resp) + }); + let mut instance = s.clone(); + builder = builder.add_unary_handler(&METHOD_CONTROL_API_DELETE, move |ctx, req, resp| { + instance.delete(ctx, req, resp) + }); + let mut instance = s.clone(); + builder = builder.add_unary_handler(&METHOD_CONTROL_API_GET, move |ctx, req, resp| { + instance.get(ctx, req, resp) + }); + builder.build() +} diff --git a/src/api/grpc/protos/mod.rs b/src/api/grpc/protos/mod.rs new file mode 100644 index 000000000..3053d7002 --- /dev/null +++ b/src/api/grpc/protos/mod.rs @@ -0,0 +1,2 @@ +pub mod control; +pub mod control_grpc; diff --git a/src/api/grpc/server.rs b/src/api/grpc/server.rs new file mode 100644 index 000000000..54cdc4d2d --- /dev/null +++ b/src/api/grpc/server.rs @@ -0,0 +1,99 @@ +use std::sync::Arc; + +use actix::{Actor, Addr, Arbiter, Context}; +use futures::future::Future; +use grpcio::{Environment, RpcContext, Server, ServerBuilder, UnarySink}; + +use crate::{ + api::{ + control::RoomId, + grpc::protos::control::{ + ApplyRequest, CreateRequest, GetResponse, IdRequest, Response, + }, + }, + log::prelude::*, + signalling::room_repo::RoomsRepository, +}; + +use super::protos::control_grpc::{create_control_api, ControlApi}; + +#[derive(Clone)] +struct ControlApiService { + room_repository: RoomsRepository, +} + +impl ControlApi for ControlApiService { + fn create( + &mut self, + ctx: RpcContext, + req: CreateRequest, + sink: UnarySink, + ) { + self.room_repository + .remove(&RoomId("pub-sub-video-call".to_string())); + debug!("{:?}", self.room_repository); + } + + fn apply( + &mut self, + ctx: RpcContext, + req: ApplyRequest, + sink: UnarySink, + ) { + unimplemented!() + } + + fn delete( + &mut self, + ctx: RpcContext, + req: IdRequest, + sink: UnarySink, + ) { + unimplemented!() + } + + fn get( + &mut self, + ctx: RpcContext, + req: IdRequest, + sink: UnarySink, + ) { + unimplemented!() + } +} + +#[allow(clippy::module_name_repetitions)] +pub struct GrpcServer { + server: Server, +} + +impl Actor for GrpcServer { + type Context = Context; + + fn started(&mut self, ctx: &mut Self::Context) { + debug!("Start gRPC server."); + self.server.start(); + } + + fn stopped(&mut self, ctx: &mut Self::Context) { + debug!("Shutdown gRPC."); + self.server.shutdown().wait(); + } +} + +pub fn run(room_repo: RoomsRepository) -> Addr { + let service = create_control_api(ControlApiService { + room_repository: room_repo, + }); + let env = Arc::new(Environment::new(1)); + + let mut server = ServerBuilder::new(env) + .register_service(service) + .bind("127.0.0.1", 50_051) + .build() + .unwrap(); + + GrpcServer::start_in_arbiter(&Arbiter::new(), move |_| GrpcServer { + server, + }) +} diff --git a/src/api/mod.rs b/src/api/mod.rs index 1c66e73e5..35620ff67 100644 --- a/src/api/mod.rs +++ b/src/api/mod.rs @@ -2,3 +2,4 @@ pub mod client; pub mod control; +pub mod grpc; diff --git a/src/main.rs b/src/main.rs index de26a57d2..4f4ccfa0b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,6 +8,8 @@ use medea::{ start_static_rooms, }; +use medea::api::grpc; + fn main() -> Result<(), Error> { dotenv::dotenv().ok(); let logger = log::new_dual_logger(std::io::stdout(), std::io::stderr()); @@ -25,7 +27,8 @@ fn main() -> Result<(), Error> { rooms.iter().map(|(id, _)| &id.0).collect::>() ); let room_repo = RoomsRepository::new(rooms); - server::run(room_repo, config); + server::run(room_repo.clone(), config); + let addr = grpc::server::run(room_repo); let _ = sys.run(); diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs index 6f628dca5..296f75aa1 100644 --- a/src/signalling/room_repo.rs +++ b/src/signalling/room_repo.rs @@ -8,7 +8,7 @@ use hashbrown::HashMap; use crate::{api::control::RoomId, signalling::Room}; /// Repository that stores [`Room`]s addresses. -#[derive(Clone, Default)] +#[derive(Clone, Default, Debug)] pub struct RoomsRepository { // TODO: Use crossbeam's concurrent hashmap when its done. // [Tracking](https://github.com/crossbeam-rs/rfcs/issues/32). @@ -28,4 +28,8 @@ impl RoomsRepository { let rooms = self.rooms.lock().unwrap(); rooms.get(id).cloned() } + + pub fn remove(&self, id: &RoomId) { + self.rooms.lock().unwrap().remove(id); + } } From b3164e68c5cd4b3a55a7eafdaa7f62b4a2812e56 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 4 Jul 2019 13:51:12 +0300 Subject: [PATCH 236/735] Ugly absraction over DTOs --- src/api/control/endpoint.rs | 47 ++++++++++++------- src/api/control/member.rs | 26 ++++------ src/api/control/mod.rs | 7 +-- src/api/control/model/endpoint/mod.rs | 1 + src/api/control/model/endpoint/webrtc/mod.rs | 5 ++ .../model/endpoint/webrtc/play_endpoint.rs | 35 ++++++++++++++ .../model/endpoint/webrtc/publish_endpoint.rs | 28 +++++++++++ src/api/control/model/member.rs | 46 ++++++++++++++++++ src/api/control/model/mod.rs | 3 ++ src/api/control/model/room.rs | 28 +++++++++++ .../endpoints/webrtc/play_endpoint.rs | 17 +++---- .../endpoints/webrtc/publish_endpoint.rs | 6 +-- src/signalling/elements/member.rs | 4 +- 13 files changed, 199 insertions(+), 54 deletions(-) create mode 100644 src/api/control/model/endpoint/mod.rs create mode 100644 src/api/control/model/endpoint/webrtc/mod.rs create mode 100644 src/api/control/model/endpoint/webrtc/play_endpoint.rs create mode 100644 src/api/control/model/endpoint/webrtc/publish_endpoint.rs create mode 100644 src/api/control/model/member.rs create mode 100644 src/api/control/model/mod.rs create mode 100644 src/api/control/model/room.rs diff --git a/src/api/control/endpoint.rs b/src/api/control/endpoint.rs index 1139b37d0..20059d6c3 100644 --- a/src/api/control/endpoint.rs +++ b/src/api/control/endpoint.rs @@ -7,16 +7,17 @@ use serde::{ Deserialize, }; -use crate::api::control::MemberId; +use crate::api::control::model::{endpoint::webrtc::*, member::MemberId}; use super::{Element, TryFromElementError}; +use crate::api::control::model::room::RoomId; /// [`Endpoint`] represents a media element that one or more media data streams /// flow through. #[derive(Debug)] pub enum Endpoint { - WebRtcPublish(WebRtcPublishEndpoint), - WebRtcPlay(WebRtcPlayEndpoint), + WebRtcPublish(SerdeWebRtcPublishEndpoint), + WebRtcPlay(SerdeWebRtcPlayEndpoint), } impl TryFrom<&Element> for Endpoint { @@ -46,7 +47,7 @@ pub enum P2pMode { /// WebRTC. #[allow(clippy::module_name_repetitions)] #[derive(Clone, Deserialize, Debug)] -pub struct WebRtcPublishEndpoint { +pub struct SerdeWebRtcPublishEndpoint { /// Peer-to-peer mode. pub p2p: P2pMode, } @@ -54,25 +55,39 @@ pub struct WebRtcPublishEndpoint { /// Media element which is able to play media data for client via WebRTC. #[allow(clippy::module_name_repetitions)] #[derive(Clone, Deserialize, Debug)] -pub struct WebRtcPlayEndpoint { +pub struct SerdeWebRtcPlayEndpoint { /// Source URI in format `local://{room_id}/{member_id}/{endpoint_id}`. - pub src: SrcUri, + pub src: SerdeSrcUri, } /// Special uri with pattern `local://{room_id}/{member_id}/{endpoint_id}`. #[derive(Clone, Debug)] -pub struct SrcUri { +pub struct SerdeSrcUri { /// ID of [`Room`] - pub room_id: String, + pub room_id: RoomId, /// ID of `Member` pub member_id: MemberId, /// Control ID of [`Endpoint`] - pub endpoint_id: String, + pub endpoint_id: WebRtcPublishId, +} + +impl SrcUri for SerdeSrcUri { + fn room_id(&self) -> &RoomId { + &self.room_id + } + + fn member_id(&self) -> &MemberId { + &self.member_id + } + + fn endpoint_id(&self) -> &WebRtcPublishId { + &self.endpoint_id + } } /// Serde deserializer for [`SrcUri`]. /// Deserialize URIs with pattern `local://{room_id}/{member_id}/{endpoint_id}`. -impl<'de> Deserialize<'de> for SrcUri { +impl<'de> Deserialize<'de> for SerdeSrcUri { fn deserialize(deserializer: D) -> Result where D: Deserializer<'de>, @@ -80,7 +95,7 @@ impl<'de> Deserialize<'de> for SrcUri { struct SrcUriVisitor; impl<'de> Visitor<'de> for SrcUriVisitor { - type Value = SrcUri; + type Value = SerdeSrcUri; fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { formatter.write_str( @@ -88,7 +103,7 @@ impl<'de> Deserialize<'de> for SrcUri { ) } - fn visit_str(self, value: &str) -> Result + fn visit_str(self, value: &str) -> Result where E: de::Error, { @@ -145,10 +160,10 @@ impl<'de> Deserialize<'de> for SrcUri { ))); } - Ok(SrcUri { - room_id, + Ok(SerdeSrcUri { + room_id: RoomId(room_id), member_id: MemberId(member_id), - endpoint_id, + endpoint_id: WebRtcPublishId(endpoint_id), }) } } @@ -165,7 +180,7 @@ mod src_uri_deserialization_tests { #[derive(Deserialize)] struct SrcUriTest { - src: SrcUri, + src: SerdeSrcUri, } #[test] diff --git a/src/api/control/member.rs b/src/api/control/member.rs index 530a22da8..3f50eee11 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -8,25 +8,13 @@ use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; use serde::Deserialize; use super::{ - endpoint::{WebRtcPlayEndpoint, WebRtcPublishEndpoint}, + endpoint::{SerdeWebRtcPlayEndpoint, SerdeWebRtcPublishEndpoint}, pipeline::Pipeline, Element, TryFromElementError, }; -macro_attr! { - /// ID of `Member`. - #[derive( - Clone, - Debug, - Deserialize, - Eq, - Hash, - PartialEq, - NewtypeFrom!, - NewtypeDisplay! - )] - pub struct Id(pub String); -} +use crate::api::control::model::endpoint::webrtc::WebRtcPublishId; +pub use crate::api::control::model::member::Id; /// Newtype for [`Element::Member`] variant. #[allow(clippy::module_name_repetitions)] @@ -41,7 +29,7 @@ pub struct MemberSpec { impl MemberSpec { /// Returns all [`WebRtcPlayEndpoint`]s of this [`MemberSpec`]. - pub fn play_endpoints(&self) -> HashMap<&String, &WebRtcPlayEndpoint> { + pub fn play_endpoints(&self) -> HashMap<&String, &SerdeWebRtcPlayEndpoint> { self.pipeline .iter() .filter_map(|(id, e)| match e { @@ -54,11 +42,13 @@ impl MemberSpec { /// Returns all [`WebRtcPublishEndpoint`]s of this [`MemberSpec`]. pub fn publish_endpoints( &self, - ) -> HashMap<&String, &WebRtcPublishEndpoint> { + ) -> HashMap { self.pipeline .iter() .filter_map(|(id, e)| match e { - Element::WebRtcPublishEndpoint { spec } => Some((id, spec)), + Element::WebRtcPublishEndpoint { spec } => { + Some((WebRtcPublishId(id.clone()), spec)) + } _ => None, }) .collect() diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index a93966747..d55dd05bc 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -2,6 +2,7 @@ pub mod endpoint; pub mod member; +pub mod model; pub mod pipeline; pub mod room; @@ -11,7 +12,7 @@ use failure::{Error, Fail}; use serde::Deserialize; use self::{ - endpoint::{WebRtcPlayEndpoint, WebRtcPublishEndpoint}, + endpoint::{SerdeWebRtcPlayEndpoint, SerdeWebRtcPublishEndpoint}, pipeline::Pipeline, }; @@ -48,11 +49,11 @@ pub enum Element { /// Represent [`WebRtcPublishEndpoint`]. /// Can transform into [`Endpoint`] enum by `Endpoint::try_from`. - WebRtcPublishEndpoint { spec: WebRtcPublishEndpoint }, + WebRtcPublishEndpoint { spec: SerdeWebRtcPublishEndpoint }, /// Represent [`WebRtcPlayEndpoint`]. /// Can transform into [`Endpoint`] enum by `Endpoint::try_from`. - WebRtcPlayEndpoint { spec: WebRtcPlayEndpoint }, + WebRtcPlayEndpoint { spec: SerdeWebRtcPlayEndpoint }, } /// Load [`RoomSpec`] from file with YAML format. diff --git a/src/api/control/model/endpoint/mod.rs b/src/api/control/model/endpoint/mod.rs new file mode 100644 index 000000000..c050ca143 --- /dev/null +++ b/src/api/control/model/endpoint/mod.rs @@ -0,0 +1 @@ +pub mod webrtc; diff --git a/src/api/control/model/endpoint/webrtc/mod.rs b/src/api/control/model/endpoint/webrtc/mod.rs new file mode 100644 index 000000000..f96677705 --- /dev/null +++ b/src/api/control/model/endpoint/webrtc/mod.rs @@ -0,0 +1,5 @@ +pub mod play_endpoint; +pub mod publish_endpoint; + +pub use play_endpoint::{SrcUri, WebRtcPlayEndpoint, WebRtcPlayId}; +pub use publish_endpoint::{WebRtcPublishEndpoint, WebRtcPublishId}; diff --git a/src/api/control/model/endpoint/webrtc/play_endpoint.rs b/src/api/control/model/endpoint/webrtc/play_endpoint.rs new file mode 100644 index 000000000..c9a9a77c4 --- /dev/null +++ b/src/api/control/model/endpoint/webrtc/play_endpoint.rs @@ -0,0 +1,35 @@ +use crate::api::control::model::{ + endpoint::webrtc::publish_endpoint::WebRtcPublishId, member::MemberId, + room::RoomId, +}; +use macro_attr::*; +use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; +use serde::Deserialize; + +pub use Id as WebRtcPlayId; +macro_attr! { + /// ID of [`Room`]. + #[derive( + Clone, + Debug, + Deserialize, + Eq, + Hash, + PartialEq, + NewtypeFrom!, + NewtypeDisplay!, + )] + pub struct Id(pub String); +} + +pub trait SrcUri { + fn room_id(&self) -> &RoomId; + + fn member_id(&self) -> &MemberId; + + fn endpoint_id(&self) -> &WebRtcPublishId; +} + +pub trait WebRtcPlayEndpoint { + fn src(&self) -> Box<&dyn SrcUri>; +} diff --git a/src/api/control/model/endpoint/webrtc/publish_endpoint.rs b/src/api/control/model/endpoint/webrtc/publish_endpoint.rs new file mode 100644 index 000000000..e55fd816c --- /dev/null +++ b/src/api/control/model/endpoint/webrtc/publish_endpoint.rs @@ -0,0 +1,28 @@ +use macro_attr::*; +use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; +use serde::Deserialize; + +macro_attr! { + /// ID of [`Room`]. + #[derive( + Clone, + Debug, + Deserialize, + Eq, + Hash, + PartialEq, + NewtypeFrom!, + NewtypeDisplay!, + )] + pub struct Id(pub String); +} + +pub use Id as WebRtcPublishId; + +pub enum P2pMode { + Always, +} + +pub trait WebRtcPublishEndpoint { + fn p2p(&self) -> &P2pMode; +} diff --git a/src/api/control/model/member.rs b/src/api/control/model/member.rs new file mode 100644 index 000000000..21d24b721 --- /dev/null +++ b/src/api/control/model/member.rs @@ -0,0 +1,46 @@ +use super::endpoint::webrtc::*; +use hashbrown::HashMap; +use macro_attr::*; +use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; +use serde::Deserialize; + +macro_attr! { + /// ID of [`Room`]. + #[derive( + Clone, + Debug, + Deserialize, + Eq, + Hash, + PartialEq, + NewtypeFrom!, + NewtypeDisplay!, + )] + pub struct Id(pub String); +} + +pub use Id as MemberId; + +pub trait MemberSpec { + fn webrtc_play_endpoints( + &self, + ) -> HashMap>; + + fn webrtc_publish_endpoints( + &self, + ) -> HashMap>; + + fn credentials(&self) -> &String; + + fn id(&self) -> &MemberId; + + fn get_webrtc_play_by_id( + &self, + id: WebRtcPlayId, + ) -> Option>; + + fn get_webrtc_publish_by_id( + &self, + id: WebRtcPublishId, + ) -> Option>; +} diff --git a/src/api/control/model/mod.rs b/src/api/control/model/mod.rs new file mode 100644 index 000000000..25a88313b --- /dev/null +++ b/src/api/control/model/mod.rs @@ -0,0 +1,3 @@ +pub mod endpoint; +pub mod member; +pub mod room; diff --git a/src/api/control/model/room.rs b/src/api/control/model/room.rs new file mode 100644 index 000000000..bdee172f8 --- /dev/null +++ b/src/api/control/model/room.rs @@ -0,0 +1,28 @@ +use crate::api::control::model::member::{MemberId, MemberSpec}; +use hashbrown::HashMap; +use macro_attr::*; +use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; +use serde::Deserialize; + +macro_attr! { + /// ID of [`Room`]. + #[derive( + Clone, + Debug, + Deserialize, + Eq, + Hash, + PartialEq, + NewtypeFrom!, + NewtypeDisplay!, + )] + pub struct Id(pub String); +} + +pub use Id as RoomId; + +pub trait RoomSpec { + fn members(&self) -> HashMap>; + + fn id(&self) -> &Id; +} diff --git a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs index 8c984aa1b..5eeb81e9f 100644 --- a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs @@ -9,18 +9,15 @@ use macro_attr::*; use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; use crate::{ - api::control::endpoint::SrcUri, media::PeerId, signalling::elements::Member, + api::control::endpoint::SerdeSrcUri, media::PeerId, + signalling::elements::Member, }; use super::publish_endpoint::WebRtcPublishEndpoint; pub use Id as WebRtcPlayId; -macro_attr! { - /// ID of endpoint. - #[derive(Clone, Debug, Eq, Hash, PartialEq, NewtypeFrom!, NewtypeDisplay!)] - pub struct Id(pub String); -} +pub use crate::api::control::model::endpoint::webrtc::play_endpoint::Id; #[derive(Debug, Clone)] struct WebRtcPlayEndpointInner { @@ -29,7 +26,7 @@ struct WebRtcPlayEndpointInner { /// Source URI of [`WebRtcPublishEndpoint`] from which this /// [`WebRtcPlayEndpoint`] receive data. - src_uri: SrcUri, + src_uri: SerdeSrcUri, /// Publisher [`WebRtcPublishEndpoint`] from which this /// [`WebRtcPlayEndpoint`] receive data. @@ -49,7 +46,7 @@ struct WebRtcPlayEndpointInner { } impl WebRtcPlayEndpointInner { - fn src_uri(&self) -> SrcUri { + fn src_uri(&self) -> SerdeSrcUri { self.src_uri.clone() } @@ -99,7 +96,7 @@ impl WebRtcPlayEndpoint { /// Create new [`WebRtcPlayEndpoint`]. pub fn new( id: Id, - src_uri: SrcUri, + src_uri: SerdeSrcUri, publisher: Weak, owner: Weak, ) -> Self { @@ -113,7 +110,7 @@ impl WebRtcPlayEndpoint { } /// Returns [`SrcUri`] of this [`WebRtcPlayEndpoint`]. - pub fn src_uri(&self) -> SrcUri { + pub fn src_uri(&self) -> SerdeSrcUri { self.0.borrow().src_uri() } diff --git a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs index a39e3108d..4ac003de5 100644 --- a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs @@ -18,11 +18,7 @@ use super::play_endpoint::WebRtcPlayEndpoint; pub use Id as WebRtcPublishId; -macro_attr! { - /// ID of endpoint. - #[derive(Clone, Debug, Eq, Hash, PartialEq, NewtypeFrom!, NewtypeDisplay!)] - pub struct Id(pub String); -} +pub use crate::api::control::model::endpoint::webrtc::publish_endpoint::Id; #[derive(Debug, Clone)] struct WebRtcPublishEndpointInner { diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index 9f994e60b..f6cb4d8ae 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -118,7 +118,7 @@ impl Member { .get(&spec_play_endpoint.src.endpoint_id) .map_or( Err(MembersLoadError::EndpointNotFound( - spec_play_endpoint.src.endpoint_id.clone(), + spec_play_endpoint.src.endpoint_id.clone().0, // TODO: tmp )), Ok, )?; @@ -171,7 +171,7 @@ impl Member { // to which none [`WebRtcPlayEndpoint`] refers. this_member_spec.publish_endpoints().into_iter().for_each( |(name, e)| { - let endpoint_id = WebRtcPublishId(name.clone()); + let endpoint_id = WebRtcPublishId(name.clone().0); // TODO: tmp if self.srcs().get(&endpoint_id).is_none() { self.insert_src(Rc::new(WebRtcPublishEndpoint::new( endpoint_id, From 33ab295e38a95706904343563c2776588fac2060 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 4 Jul 2019 14:18:15 +0300 Subject: [PATCH 237/735] Ugly implementation of elements traits for serde structs --- src/api/control/endpoint.rs | 12 ++++ src/api/control/member.rs | 71 +++++++++++++++++-- src/api/control/mod.rs | 12 ++-- .../model/endpoint/webrtc/publish_endpoint.rs | 7 +- src/api/control/model/room.rs | 2 +- src/api/control/room.rs | 58 +++++++++------ src/signalling/elements/member.rs | 14 ++-- src/signalling/participants.rs | 4 +- src/signalling/room.rs | 4 +- 9 files changed, 138 insertions(+), 46 deletions(-) diff --git a/src/api/control/endpoint.rs b/src/api/control/endpoint.rs index 20059d6c3..ca131bec3 100644 --- a/src/api/control/endpoint.rs +++ b/src/api/control/endpoint.rs @@ -52,6 +52,12 @@ pub struct SerdeWebRtcPublishEndpoint { pub p2p: P2pMode, } +impl WebRtcPublishEndpoint for SerdeWebRtcPublishEndpoint { + fn p2p(&self) -> &P2pMode { + &self.p2p + } +} + /// Media element which is able to play media data for client via WebRTC. #[allow(clippy::module_name_repetitions)] #[derive(Clone, Deserialize, Debug)] @@ -60,6 +66,12 @@ pub struct SerdeWebRtcPlayEndpoint { pub src: SerdeSrcUri, } +impl WebRtcPlayEndpoint for SerdeWebRtcPlayEndpoint { + fn src(&self) -> Box<&SrcUri> { + Box::new(&self.src) + } +} + /// Special uri with pattern `local://{room_id}/{member_id}/{endpoint_id}`. #[derive(Clone, Debug)] pub struct SerdeSrcUri { diff --git a/src/api/control/member.rs b/src/api/control/member.rs index 3f50eee11..9148b8647 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -13,13 +13,22 @@ use super::{ Element, TryFromElementError, }; -use crate::api::control::model::endpoint::webrtc::WebRtcPublishId; pub use crate::api::control::model::member::Id; +use crate::api::control::{ + model::{ + endpoint::webrtc::{ + WebRtcPlayEndpoint, WebRtcPlayId, WebRtcPublishEndpoint, + WebRtcPublishId, + }, + member::MemberSpec, + }, + MemberId, +}; /// Newtype for [`Element::Member`] variant. #[allow(clippy::module_name_repetitions)] #[derive(Clone, Debug)] -pub struct MemberSpec { +pub struct SerdeMemberSpec { /// Spec of this `Member`. pipeline: Pipeline, @@ -27,7 +36,7 @@ pub struct MemberSpec { credentials: String, } -impl MemberSpec { +impl SerdeMemberSpec { /// Returns all [`WebRtcPlayEndpoint`]s of this [`MemberSpec`]. pub fn play_endpoints(&self) -> HashMap<&String, &SerdeWebRtcPlayEndpoint> { self.pipeline @@ -59,7 +68,61 @@ impl MemberSpec { } } -impl TryFrom<&Element> for MemberSpec { +impl MemberSpec for SerdeMemberSpec { + fn webrtc_play_endpoints( + &self, + ) -> HashMap> { + self.pipeline + .iter() + .filter_map(|(id, e)| match e { + Element::WebRtcPlayEndpoint { spec } => Some(( + WebRtcPlayId(id.clone()), + Box::new(spec as &WebRtcPlayEndpoint), + )), + _ => None, + }) + .collect() + } + + fn webrtc_publish_endpoints( + &self, + ) -> HashMap> { + self.pipeline + .iter() + .filter_map(|(id, e)| match e { + Element::WebRtcPublishEndpoint { spec } => Some(( + WebRtcPublishId(id.clone()), + Box::new(spec as &WebRtcPublishEndpoint), + )), + _ => None, + }) + .collect() + } + + fn credentials(&self) -> &String { + &self.credentials + } + + fn id(&self) -> &MemberId { + self.id() + } + + fn get_webrtc_play_by_id( + &self, + id: WebRtcPlayId, + ) -> Option> { + unimplemented!() + } + + fn get_webrtc_publish_by_id( + &self, + id: WebRtcPublishId, + ) -> Option> { + unimplemented!() + } +} + +impl TryFrom<&Element> for SerdeMemberSpec { type Error = TryFromElementError; fn try_from(from: &Element) -> Result { diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index d55dd05bc..3374ba6c1 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -18,8 +18,8 @@ use self::{ pub use self::{ endpoint::Endpoint, - member::{Id as MemberId, MemberSpec}, - room::{Id as RoomId, RoomSpec}, + member::{Id as MemberId, SerdeMemberSpec}, + room::{Id as RoomId, SerdeRoomSpec}, }; /// Errors that can occur when we try transform some spec from [`Element`]. @@ -57,12 +57,14 @@ pub enum Element { } /// Load [`RoomSpec`] from file with YAML format. -pub fn load_from_yaml_file>(path: P) -> Result { +pub fn load_from_yaml_file>( + path: P, +) -> Result { let mut file = File::open(path)?; let mut buf = String::new(); file.read_to_string(&mut buf)?; let parsed: Element = serde_yaml::from_str(&buf)?; - let room = RoomSpec::try_from(&parsed)?; + let room = SerdeRoomSpec::try_from(&parsed)?; Ok(room) } @@ -70,7 +72,7 @@ pub fn load_from_yaml_file>(path: P) -> Result { /// Load all [`RoomSpec`] from YAML files from provided path. pub fn load_static_specs_from_dir>( path: P, -) -> Result, Error> { +) -> Result, Error> { let mut specs = Vec::new(); for entry in std::fs::read_dir(path)? { let entry = entry?; diff --git a/src/api/control/model/endpoint/webrtc/publish_endpoint.rs b/src/api/control/model/endpoint/webrtc/publish_endpoint.rs index e55fd816c..bd4be70e7 100644 --- a/src/api/control/model/endpoint/webrtc/publish_endpoint.rs +++ b/src/api/control/model/endpoint/webrtc/publish_endpoint.rs @@ -1,6 +1,7 @@ +use crate::api::control::endpoint::P2pMode; use macro_attr::*; use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; -use serde::Deserialize; +use serde::Deserialize; // TODO: temp macro_attr! { /// ID of [`Room`]. @@ -19,10 +20,6 @@ macro_attr! { pub use Id as WebRtcPublishId; -pub enum P2pMode { - Always, -} - pub trait WebRtcPublishEndpoint { fn p2p(&self) -> &P2pMode; } diff --git a/src/api/control/model/room.rs b/src/api/control/model/room.rs index bdee172f8..73a32a2f8 100644 --- a/src/api/control/model/room.rs +++ b/src/api/control/model/room.rs @@ -22,7 +22,7 @@ macro_attr! { pub use Id as RoomId; pub trait RoomSpec { - fn members(&self) -> HashMap>; + fn members(&self) -> HashMap<&MemberId, Box<&dyn MemberSpec>>; fn id(&self) -> &Id; } diff --git a/src/api/control/room.rs b/src/api/control/room.rs index ab67c6c4f..ed87d260f 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -8,42 +8,31 @@ use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; use serde::Deserialize; use super::{ - member::MemberSpec, pipeline::Pipeline, Element, MemberId, + member::SerdeMemberSpec, pipeline::Pipeline, Element, MemberId, TryFromElementError, }; +use crate::api::control::model::{member::MemberSpec, room::RoomSpec}; -macro_attr! { - /// ID of [`Room`]. - #[derive( - Clone, - Debug, - Deserialize, - Eq, - Hash, - PartialEq, - NewtypeFrom!, - NewtypeDisplay!, - )] - pub struct Id(pub String); -} +pub use crate::api::control::model::room::Id; +pub use Id as RoomId; /// [`crate::signalling::room::Room`] specification. /// Newtype for [`Element::Room`] #[allow(clippy::module_name_repetitions)] #[derive(Clone, Debug)] -pub struct RoomSpec { +pub struct SerdeRoomSpec { pub id: Id, pub pipeline: Pipeline, } -impl RoomSpec { +impl SerdeRoomSpec { /// Returns all [`MemberSpec`]s of this [`RoomSpec`]. pub fn members( &self, - ) -> Result, TryFromElementError> { - let mut members: HashMap = HashMap::new(); + ) -> Result, TryFromElementError> { + let mut members: HashMap = HashMap::new(); for (control_id, element) in self.pipeline.iter() { - let member_spec = MemberSpec::try_from(element)?; + let member_spec = SerdeMemberSpec::try_from(element)?; let member_id = MemberId(control_id.clone()); members.insert(member_id.clone(), member_spec); @@ -58,7 +47,34 @@ impl RoomSpec { } } -impl TryFrom<&Element> for RoomSpec { +struct ParsedSerdeRoomSpec { + id: Id, + members: HashMap, +} + +impl ParsedSerdeRoomSpec { + pub fn new(room_spec: &SerdeRoomSpec) -> Result { + Ok(Self { + id: room_spec.id.clone(), + members: room_spec.members()?, + }) + } +} + +impl RoomSpec for ParsedSerdeRoomSpec { + fn members(&self) -> HashMap<&MemberId, Box<&MemberSpec>> { + self.members + .iter() + .map(|(id, member)| (id, Box::new(member as &MemberSpec))) + .collect() + } + + fn id(&self) -> &Id { + &self.id + } +} + +impl TryFrom<&Element> for SerdeRoomSpec { type Error = TryFromElementError; fn try_from(from: &Element) -> Result { diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index f6cb4d8ae..392354ddf 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -7,7 +7,9 @@ use hashbrown::HashMap; use medea_client_api_proto::IceServer; use crate::{ - api::control::{MemberId, MemberSpec, RoomSpec, TryFromElementError}, + api::control::{ + MemberId, SerdeMemberSpec, SerdeRoomSpec, TryFromElementError, + }, log::prelude::*, media::{IceUser, PeerId}, }; @@ -78,10 +80,10 @@ impl Member { /// Load all srcs and sinks of this [`Member`]. fn load( &self, - room_spec: &RoomSpec, + room_spec: &SerdeRoomSpec, store: &HashMap>, ) -> Result<(), MembersLoadError> { - let this_member_spec = MemberSpec::try_from( + let this_member_spec = SerdeMemberSpec::try_from( room_spec .pipeline .get(&self.id().0) @@ -101,7 +103,7 @@ impl Member { Err(MembersLoadError::MemberNotFound(publisher_id)), Ok, )?; - let publisher_spec = MemberSpec::try_from( + let publisher_spec = SerdeMemberSpec::try_from( room_spec .pipeline .get(&spec_play_endpoint.src.member_id.to_string()) @@ -278,7 +280,7 @@ impl Member { /// /// Returns store of all [`Member`]s loaded from [`RoomSpec`]. pub fn parse_members( - room_spec: &RoomSpec, + room_spec: &SerdeRoomSpec, ) -> Result>, MembersLoadError> { let members_spec = room_spec.members()?; let mut members = HashMap::new(); @@ -371,7 +373,7 @@ mod tests { fn get_test_store() -> HashMap> { let room_element: Element = serde_yaml::from_str(TEST_SPEC).unwrap(); - let room_spec = RoomSpec::try_from(&room_element).unwrap(); + let room_spec = SerdeRoomSpec::try_from(&room_element).unwrap(); parse_members(&room_spec).unwrap() } diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 4509d8a42..a538539a9 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -26,7 +26,7 @@ use crate::{ AuthorizationError, ClosedReason, EventMessage, RpcConnection, RpcConnectionClosed, }, - control::{MemberId, RoomId, RoomSpec}, + control::{MemberId, RoomId, SerdeRoomSpec}, }, log::prelude::*, media::IceUser, @@ -96,7 +96,7 @@ pub struct ParticipantService { impl ParticipantService { /// Create new [`ParticipantService`] from [`RoomSpec`]. pub fn new( - room_spec: &RoomSpec, + room_spec: &SerdeRoomSpec, reconnect_timeout: Duration, turn: Box, ) -> Result { diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 5a74fa775..d71064766 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -18,7 +18,7 @@ use crate::{ AuthorizationError, Authorize, ClosedReason, CommandMessage, RpcConnectionClosed, RpcConnectionEstablished, }, - control::{MemberId, RoomId, RoomSpec, TryFromElementError}, + control::{MemberId, RoomId, SerdeRoomSpec, TryFromElementError}, }, log::prelude::*, media::{ @@ -103,7 +103,7 @@ impl Room { /// Returns [`RoomError::BadRoomSpec`] when error while [`Element`] /// transformation happens. pub fn new( - room_spec: &RoomSpec, + room_spec: &SerdeRoomSpec, reconnect_timeout: Duration, turn: Box, ) -> Result { From d1021f93bd18785d01375e7cc3407fdb56e90a4b Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 4 Jul 2019 15:15:35 +0300 Subject: [PATCH 238/735] Migrate to signalling::Member::load to trait use --- src/api/control/endpoint.rs | 18 +--- src/api/control/member.rs | 27 +++-- src/api/control/model/endpoint/webrtc/mod.rs | 3 +- .../model/endpoint/webrtc/play_endpoint.rs | 20 ++-- src/api/control/model/member.rs | 8 +- src/api/control/model/room.rs | 2 + src/api/control/room.rs | 6 +- .../endpoints/webrtc/play_endpoint.rs | 7 +- src/signalling/elements/member.rs | 98 ++++++++++++------- 9 files changed, 110 insertions(+), 79 deletions(-) diff --git a/src/api/control/endpoint.rs b/src/api/control/endpoint.rs index ca131bec3..e67f01bbb 100644 --- a/src/api/control/endpoint.rs +++ b/src/api/control/endpoint.rs @@ -67,8 +67,8 @@ pub struct SerdeWebRtcPlayEndpoint { } impl WebRtcPlayEndpoint for SerdeWebRtcPlayEndpoint { - fn src(&self) -> Box<&SrcUri> { - Box::new(&self.src) + fn src(&self) -> &SrcUri { + &self.src } } @@ -83,20 +83,6 @@ pub struct SerdeSrcUri { pub endpoint_id: WebRtcPublishId, } -impl SrcUri for SerdeSrcUri { - fn room_id(&self) -> &RoomId { - &self.room_id - } - - fn member_id(&self) -> &MemberId { - &self.member_id - } - - fn endpoint_id(&self) -> &WebRtcPublishId { - &self.endpoint_id - } -} - /// Serde deserializer for [`SrcUri`]. /// Deserialize URIs with pattern `local://{room_id}/{member_id}/{endpoint_id}`. impl<'de> Deserialize<'de> for SerdeSrcUri { diff --git a/src/api/control/member.rs b/src/api/control/member.rs index 9148b8647..12487273b 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -22,7 +22,7 @@ use crate::api::control::{ }, member::MemberSpec, }, - MemberId, + Endpoint, MemberId, }; /// Newtype for [`Element::Member`] variant. @@ -109,16 +109,29 @@ impl MemberSpec for SerdeMemberSpec { fn get_webrtc_play_by_id( &self, - id: WebRtcPlayId, - ) -> Option> { - unimplemented!() + id: &WebRtcPlayId, + ) -> Option> { + let element = self.pipeline.get(&id.0)?; + + if let Some(endpoint) = Endpoint::try_from(element).ok() { + if let Endpoint::WebRtcPlay(e) = endpoint { + return Some(Box::new(e) as Box); + } + } + None } fn get_webrtc_publish_by_id( &self, - id: WebRtcPublishId, - ) -> Option> { - unimplemented!() + id: &WebRtcPublishId, + ) -> Option> { + let element = self.pipeline.get(&id.0)?; + if let Some(endpoint) = Endpoint::try_from(element).ok() { + if let Endpoint::WebRtcPublish(e) = endpoint { + return Some(Box::new(e) as Box); + } + } + None } } diff --git a/src/api/control/model/endpoint/webrtc/mod.rs b/src/api/control/model/endpoint/webrtc/mod.rs index f96677705..d62bc2e28 100644 --- a/src/api/control/model/endpoint/webrtc/mod.rs +++ b/src/api/control/model/endpoint/webrtc/mod.rs @@ -1,5 +1,6 @@ pub mod play_endpoint; pub mod publish_endpoint; -pub use play_endpoint::{SrcUri, WebRtcPlayEndpoint, WebRtcPlayId}; +pub use crate::api::control::endpoint::SerdeSrcUri as SrcUri; +pub use play_endpoint::{WebRtcPlayEndpoint, WebRtcPlayId}; pub use publish_endpoint::{WebRtcPublishEndpoint, WebRtcPublishId}; diff --git a/src/api/control/model/endpoint/webrtc/play_endpoint.rs b/src/api/control/model/endpoint/webrtc/play_endpoint.rs index c9a9a77c4..fce08f9b0 100644 --- a/src/api/control/model/endpoint/webrtc/play_endpoint.rs +++ b/src/api/control/model/endpoint/webrtc/play_endpoint.rs @@ -1,11 +1,15 @@ -use crate::api::control::model::{ - endpoint::webrtc::publish_endpoint::WebRtcPublishId, member::MemberId, - room::RoomId, +use crate::api::control::{ + endpoint::SerdeSrcUri, + model::{ + endpoint::webrtc::publish_endpoint::WebRtcPublishId, member::MemberId, + room::RoomId, + }, }; use macro_attr::*; use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; use serde::Deserialize; +use std::fmt::Debug; pub use Id as WebRtcPlayId; macro_attr! { /// ID of [`Room`]. @@ -22,14 +26,6 @@ macro_attr! { pub struct Id(pub String); } -pub trait SrcUri { - fn room_id(&self) -> &RoomId; - - fn member_id(&self) -> &MemberId; - - fn endpoint_id(&self) -> &WebRtcPublishId; -} - pub trait WebRtcPlayEndpoint { - fn src(&self) -> Box<&dyn SrcUri>; + fn src(&self) -> &SerdeSrcUri; } diff --git a/src/api/control/model/member.rs b/src/api/control/model/member.rs index 21d24b721..23d62f300 100644 --- a/src/api/control/model/member.rs +++ b/src/api/control/model/member.rs @@ -36,11 +36,11 @@ pub trait MemberSpec { fn get_webrtc_play_by_id( &self, - id: WebRtcPlayId, - ) -> Option>; + id: &WebRtcPlayId, + ) -> Option>; fn get_webrtc_publish_by_id( &self, - id: WebRtcPublishId, - ) -> Option>; + id: &WebRtcPublishId, + ) -> Option>; } diff --git a/src/api/control/model/room.rs b/src/api/control/model/room.rs index 73a32a2f8..52adc940b 100644 --- a/src/api/control/model/room.rs +++ b/src/api/control/model/room.rs @@ -25,4 +25,6 @@ pub trait RoomSpec { fn members(&self) -> HashMap<&MemberId, Box<&dyn MemberSpec>>; fn id(&self) -> &Id; + + fn get_member_by_id(&self, id: &MemberId) -> Option>; } diff --git a/src/api/control/room.rs b/src/api/control/room.rs index ed87d260f..c42b770e0 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -47,7 +47,7 @@ impl SerdeRoomSpec { } } -struct ParsedSerdeRoomSpec { +pub struct ParsedSerdeRoomSpec { id: Id, members: HashMap, } @@ -72,6 +72,10 @@ impl RoomSpec for ParsedSerdeRoomSpec { fn id(&self) -> &Id { &self.id } + + fn get_member_by_id(&self, id: &MemberId) -> Option> { + self.members.get(id).map(|m| Box::new(m as &MemberSpec)) + } } impl TryFrom<&Element> for SerdeRoomSpec { diff --git a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs index 5eeb81e9f..809016613 100644 --- a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs @@ -18,6 +18,7 @@ use super::publish_endpoint::WebRtcPublishEndpoint; pub use Id as WebRtcPlayId; pub use crate::api::control::model::endpoint::webrtc::play_endpoint::Id; +use crate::api::control::model::endpoint::webrtc::SrcUri; #[derive(Debug, Clone)] struct WebRtcPlayEndpointInner { @@ -26,7 +27,7 @@ struct WebRtcPlayEndpointInner { /// Source URI of [`WebRtcPublishEndpoint`] from which this /// [`WebRtcPlayEndpoint`] receive data. - src_uri: SerdeSrcUri, + src_uri: SrcUri, /// Publisher [`WebRtcPublishEndpoint`] from which this /// [`WebRtcPlayEndpoint`] receive data. @@ -96,7 +97,7 @@ impl WebRtcPlayEndpoint { /// Create new [`WebRtcPlayEndpoint`]. pub fn new( id: Id, - src_uri: SerdeSrcUri, + src_uri: SrcUri, publisher: Weak, owner: Weak, ) -> Self { @@ -110,7 +111,7 @@ impl WebRtcPlayEndpoint { } /// Returns [`SrcUri`] of this [`WebRtcPlayEndpoint`]. - pub fn src_uri(&self) -> SerdeSrcUri { + pub fn src_uri(&self) -> SrcUri { self.0.borrow().src_uri() } diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index 392354ddf..2183ac516 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -17,6 +17,7 @@ use crate::{ use super::endpoints::webrtc::{ WebRtcPlayEndpoint, WebRtcPlayId, WebRtcPublishEndpoint, WebRtcPublishId, }; +use crate::api::control::{model::room::RoomSpec, room::ParsedSerdeRoomSpec}; /// Errors which may occur while loading [`Member`]s from [`RoomSpec`]. #[derive(Debug, Fail)] @@ -80,61 +81,85 @@ impl Member { /// Load all srcs and sinks of this [`Member`]. fn load( &self, - room_spec: &SerdeRoomSpec, + room_spec: Box<&dyn RoomSpec>, store: &HashMap>, ) -> Result<(), MembersLoadError> { - let this_member_spec = SerdeMemberSpec::try_from( - room_spec - .pipeline - .get(&self.id().0) - .map_or(Err(MembersLoadError::MemberNotFound(self.id())), Ok)?, - )?; + // let this_member_spec = SerdeMemberSpec::try_from( + // room_spec + // .get_member_by_id(&self.id()) + // + // .map_or(Err(MembersLoadError::MemberNotFound(self.id())), Ok)?, + // )?; + + let this_member_spec = room_spec + .get_member_by_id(&self.id()) + .map_or(Err(MembersLoadError::MemberNotFound(self.id())), Ok)?; let this_member = store .get(&self.id()) .map_or(Err(MembersLoadError::MemberNotFound(self.id())), Ok)?; for (spec_play_name, spec_play_endpoint) in - this_member_spec.play_endpoints() + this_member_spec.webrtc_play_endpoints() { let publisher_id = - MemberId(spec_play_endpoint.src.member_id.to_string()); + MemberId(spec_play_endpoint.src().member_id.to_string()); let publisher_member = store.get(&publisher_id).map_or( Err(MembersLoadError::MemberNotFound(publisher_id)), Ok, )?; - let publisher_spec = SerdeMemberSpec::try_from( - room_spec - .pipeline - .get(&spec_play_endpoint.src.member_id.to_string()) - .map_or( - Err(MembersLoadError::MemberNotFound( - spec_play_endpoint.src.member_id.clone(), - )), - Ok, - )?, - )?; + // let publisher_spec = SerdeMemberSpec::try_from( + // room_spec + // .pipeline + // + // .get(&spec_play_endpoint.src().member_id.to_string()) + // .map_or( + // Err(MembersLoadError::MemberNotFound( + // + // spec_play_endpoint.src().member_id.clone(), + // )), + // Ok, + // )?, + // )?; + + let publisher_spec = room_spec + .get_member_by_id(&spec_play_endpoint.src().member_id) + .map_or( + Err(MembersLoadError::MemberNotFound( + spec_play_endpoint.src().member_id.clone(), + )), + Ok, + )?; - let publisher_endpoint = *publisher_spec - .publish_endpoints() - .get(&spec_play_endpoint.src.endpoint_id) + let publisher_endpoint = publisher_spec.get_webrtc_publish_by_id(&spec_play_endpoint.src().endpoint_id) .map_or( Err(MembersLoadError::EndpointNotFound( - spec_play_endpoint.src.endpoint_id.clone().0, // TODO: tmp + spec_play_endpoint.src().endpoint_id.clone().0, // TODO: tmp )), Ok, )?; + // let publisher_endpoint = publisher_spec + // .webrtc_publish_endpoints() + // .get(&spec_play_endpoint.src().endpoint_id) + // .map_or( + // Err(MembersLoadError::EndpointNotFound( + // + // spec_play_endpoint.src().endpoint_id.clone().0, // TODO: tmp + // )), + // Ok, + // )?; + if let Some(publisher) = publisher_member.get_src_by_id(&WebRtcPublishId( - spec_play_endpoint.src.endpoint_id.to_string(), + spec_play_endpoint.src().endpoint_id.to_string(), )) { let new_play_endpoint_id = WebRtcPlayId(spec_play_name.to_string()); let new_play_endpoint = Rc::new(WebRtcPlayEndpoint::new( new_play_endpoint_id.clone(), - spec_play_endpoint.src.clone(), + spec_play_endpoint.src().clone(), Rc::downgrade(&publisher), Rc::downgrade(&this_member), )); @@ -144,11 +169,11 @@ impl Member { publisher.add_sink(Rc::downgrade(&new_play_endpoint)); } else { let new_publish_id = WebRtcPublishId( - spec_play_endpoint.src.endpoint_id.to_string(), + spec_play_endpoint.src().endpoint_id.to_string(), ); let new_publish = Rc::new(WebRtcPublishEndpoint::new( new_publish_id.clone(), - publisher_endpoint.p2p.clone(), + publisher_endpoint.p2p().clone(), Vec::new(), Rc::downgrade(&publisher_member), )); @@ -156,7 +181,7 @@ impl Member { let new_self_play_id = WebRtcPlayId(spec_play_name.to_string()); let new_self_play = Rc::new(WebRtcPlayEndpoint::new( new_self_play_id.clone(), - spec_play_endpoint.src.clone(), + spec_play_endpoint.src().clone(), Rc::downgrade(&new_publish), Rc::downgrade(&this_member), )); @@ -171,19 +196,20 @@ impl Member { // This is necessary to create [`WebRtcPublishEndpoint`], // to which none [`WebRtcPlayEndpoint`] refers. - this_member_spec.publish_endpoints().into_iter().for_each( - |(name, e)| { + this_member_spec + .webrtc_publish_endpoints() + .into_iter() + .for_each(|(name, e)| { let endpoint_id = WebRtcPublishId(name.clone().0); // TODO: tmp if self.srcs().get(&endpoint_id).is_none() { self.insert_src(Rc::new(WebRtcPublishEndpoint::new( endpoint_id, - e.p2p.clone(), + e.p2p().clone(), Vec::new(), Rc::downgrade(&this_member), ))); } - }, - ); + }); Ok(()) } @@ -292,8 +318,10 @@ pub fn parse_members( ); } + let spec = ParsedSerdeRoomSpec::new(&room_spec)?; + for (_, member) in &members { - member.load(room_spec, &members)?; + member.load(Box::new(&spec as &RoomSpec), &members)?; } debug!( From 2c11077d188f4342bea1081f8be7aeb42b5ee626 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 4 Jul 2019 15:30:23 +0300 Subject: [PATCH 239/735] Move serde DTOs into serde module --- src/api/client/rpc_connection.rs | 2 +- src/api/client/server.rs | 2 +- src/api/client/session.rs | 2 +- src/api/control/mod.rs | 84 +------------------ src/api/control/model/endpoint/webrtc/mod.rs | 2 +- .../model/endpoint/webrtc/play_endpoint.rs | 8 +- .../model/endpoint/webrtc/publish_endpoint.rs | 2 +- src/api/control/model/mod.rs | 4 + src/api/control/{ => serde}/endpoint.rs | 0 src/api/control/{ => serde}/member.rs | 3 +- src/api/control/serde/mod.rs | 83 ++++++++++++++++++ src/api/control/{ => serde}/pipeline.rs | 2 +- src/api/control/{ => serde}/room.rs | 0 src/api/grpc/server.rs | 2 +- src/lib.rs | 2 +- src/media/ice_user.rs | 2 +- src/media/peer.rs | 2 +- .../endpoints/webrtc/play_endpoint.rs | 2 +- .../endpoints/webrtc/publish_endpoint.rs | 2 +- src/signalling/elements/member.rs | 16 ++-- src/signalling/participants.rs | 5 +- src/signalling/peers.rs | 2 +- src/signalling/room.rs | 5 +- src/signalling/room_repo.rs | 2 +- src/turn/service.rs | 2 +- 25 files changed, 125 insertions(+), 113 deletions(-) rename src/api/control/{ => serde}/endpoint.rs (100%) rename src/api/control/{ => serde}/member.rs (99%) create mode 100644 src/api/control/serde/mod.rs rename src/api/control/{ => serde}/pipeline.rs (95%) rename src/api/control/{ => serde}/room.rs (100%) diff --git a/src/api/client/rpc_connection.rs b/src/api/client/rpc_connection.rs index 208f8850d..f2288cd3a 100644 --- a/src/api/client/rpc_connection.rs +++ b/src/api/client/rpc_connection.rs @@ -8,7 +8,7 @@ use macro_attr::*; use medea_client_api_proto::{Command, Event}; use newtype_derive::NewtypeFrom; -use crate::api::control::MemberId; +use crate::api::control::serde::MemberId; macro_attr! { /// Wrapper [`Command`] for implements actix [`Message`]. diff --git a/src/api/client/server.rs b/src/api/client/server.rs index f607661b9..4389422f2 100644 --- a/src/api/client/server.rs +++ b/src/api/client/server.rs @@ -18,7 +18,7 @@ use crate::{ rpc_connection::{AuthorizationError, Authorize}, session::WsSession, }, - control::{MemberId, RoomId}, + control::model::{MemberId, RoomId}, }, conf::{Conf, Rpc}, log::prelude::*, diff --git a/src/api/client/session.rs b/src/api/client/session.rs index b0e2e93dc..c1c9d3921 100644 --- a/src/api/client/session.rs +++ b/src/api/client/session.rs @@ -16,7 +16,7 @@ use crate::{ ClosedReason, CommandMessage, EventMessage, RpcConnection, RpcConnectionClosed, RpcConnectionEstablished, }, - control::MemberId, + control::model::MemberId, }, log::prelude::*, signalling::Room, diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index 3374ba6c1..78807a2ab 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -1,84 +1,2 @@ -//! Implementation of Control API. - -pub mod endpoint; -pub mod member; pub mod model; -pub mod pipeline; -pub mod room; - -use std::{convert::TryFrom as _, fs::File, io::Read as _, path::Path}; - -use failure::{Error, Fail}; -use serde::Deserialize; - -use self::{ - endpoint::{SerdeWebRtcPlayEndpoint, SerdeWebRtcPublishEndpoint}, - pipeline::Pipeline, -}; - -pub use self::{ - endpoint::Endpoint, - member::{Id as MemberId, SerdeMemberSpec}, - room::{Id as RoomId, SerdeRoomSpec}, -}; - -/// Errors that can occur when we try transform some spec from [`Element`]. -/// This error used in all [`TryFrom`] of Control API. -#[allow(clippy::pub_enum_variant_names)] -#[derive(Debug, Fail)] -pub enum TryFromElementError { - #[fail(display = "Element is not Endpoint")] - NotEndpoint, - #[fail(display = "Element is not Room")] - NotRoom, - #[fail(display = "Element is not Member")] - NotMember, -} - -/// Entity for parsing Control API request. -#[derive(Clone, Deserialize, Debug)] -#[serde(tag = "kind")] -pub enum Element { - /// Represent [`RoomSpec`]. - /// Can transform into [`RoomSpec`] by `RoomSpec::try_from`. - Room { id: RoomId, spec: Pipeline }, - - /// Represent [`MemberSpec`]. - /// Can transform into [`MemberSpec`] by `MemberSpec::try_from`. - Member { spec: Pipeline, credentials: String }, - - /// Represent [`WebRtcPublishEndpoint`]. - /// Can transform into [`Endpoint`] enum by `Endpoint::try_from`. - WebRtcPublishEndpoint { spec: SerdeWebRtcPublishEndpoint }, - - /// Represent [`WebRtcPlayEndpoint`]. - /// Can transform into [`Endpoint`] enum by `Endpoint::try_from`. - WebRtcPlayEndpoint { spec: SerdeWebRtcPlayEndpoint }, -} - -/// Load [`RoomSpec`] from file with YAML format. -pub fn load_from_yaml_file>( - path: P, -) -> Result { - let mut file = File::open(path)?; - let mut buf = String::new(); - file.read_to_string(&mut buf)?; - let parsed: Element = serde_yaml::from_str(&buf)?; - let room = SerdeRoomSpec::try_from(&parsed)?; - - Ok(room) -} - -/// Load all [`RoomSpec`] from YAML files from provided path. -pub fn load_static_specs_from_dir>( - path: P, -) -> Result, Error> { - let mut specs = Vec::new(); - for entry in std::fs::read_dir(path)? { - let entry = entry?; - let spec = load_from_yaml_file(entry.path())?; - specs.push(spec) - } - - Ok(specs) -} +pub mod serde; diff --git a/src/api/control/model/endpoint/webrtc/mod.rs b/src/api/control/model/endpoint/webrtc/mod.rs index d62bc2e28..1afc6c06b 100644 --- a/src/api/control/model/endpoint/webrtc/mod.rs +++ b/src/api/control/model/endpoint/webrtc/mod.rs @@ -1,6 +1,6 @@ pub mod play_endpoint; pub mod publish_endpoint; -pub use crate::api::control::endpoint::SerdeSrcUri as SrcUri; +pub use crate::api::control::serde::endpoint::SerdeSrcUri as SrcUri; pub use play_endpoint::{WebRtcPlayEndpoint, WebRtcPlayId}; pub use publish_endpoint::{WebRtcPublishEndpoint, WebRtcPublishId}; diff --git a/src/api/control/model/endpoint/webrtc/play_endpoint.rs b/src/api/control/model/endpoint/webrtc/play_endpoint.rs index fce08f9b0..287522e5f 100644 --- a/src/api/control/model/endpoint/webrtc/play_endpoint.rs +++ b/src/api/control/model/endpoint/webrtc/play_endpoint.rs @@ -1,10 +1,8 @@ use crate::api::control::{ - endpoint::SerdeSrcUri, - model::{ - endpoint::webrtc::publish_endpoint::WebRtcPublishId, member::MemberId, - room::RoomId, - }, + model::{MemberId, RoomId, WebRtcPublishId}, + serde::endpoint::SerdeSrcUri, }; + use macro_attr::*; use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; use serde::Deserialize; diff --git a/src/api/control/model/endpoint/webrtc/publish_endpoint.rs b/src/api/control/model/endpoint/webrtc/publish_endpoint.rs index bd4be70e7..478718296 100644 --- a/src/api/control/model/endpoint/webrtc/publish_endpoint.rs +++ b/src/api/control/model/endpoint/webrtc/publish_endpoint.rs @@ -1,4 +1,4 @@ -use crate::api::control::endpoint::P2pMode; +use crate::api::control::serde::endpoint::P2pMode; use macro_attr::*; use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; use serde::Deserialize; // TODO: temp diff --git a/src/api/control/model/mod.rs b/src/api/control/model/mod.rs index 25a88313b..f5a177be5 100644 --- a/src/api/control/model/mod.rs +++ b/src/api/control/model/mod.rs @@ -1,3 +1,7 @@ pub mod endpoint; pub mod member; pub mod room; + +pub use endpoint::webrtc::{WebRtcPlayId, WebRtcPublishId}; +pub use member::Id as MemberId; +pub use room::Id as RoomId; diff --git a/src/api/control/endpoint.rs b/src/api/control/serde/endpoint.rs similarity index 100% rename from src/api/control/endpoint.rs rename to src/api/control/serde/endpoint.rs diff --git a/src/api/control/member.rs b/src/api/control/serde/member.rs similarity index 99% rename from src/api/control/member.rs rename to src/api/control/serde/member.rs index 12487273b..2e71a775a 100644 --- a/src/api/control/member.rs +++ b/src/api/control/serde/member.rs @@ -21,8 +21,9 @@ use crate::api::control::{ WebRtcPublishId, }, member::MemberSpec, + MemberId, }, - Endpoint, MemberId, + serde::Endpoint, }; /// Newtype for [`Element::Member`] variant. diff --git a/src/api/control/serde/mod.rs b/src/api/control/serde/mod.rs new file mode 100644 index 000000000..04ea96c84 --- /dev/null +++ b/src/api/control/serde/mod.rs @@ -0,0 +1,83 @@ +//! Implementation of Control API. + +pub mod endpoint; +pub mod member; +pub mod pipeline; +pub mod room; + +use std::{convert::TryFrom as _, fs::File, io::Read as _, path::Path}; + +use failure::{Error, Fail}; +use serde::Deserialize; + +use self::{ + endpoint::{SerdeWebRtcPlayEndpoint, SerdeWebRtcPublishEndpoint}, + pipeline::Pipeline, +}; + +pub use self::{ + endpoint::Endpoint, + member::{Id as MemberId, SerdeMemberSpec}, + room::{Id as RoomId, SerdeRoomSpec}, +}; + +/// Errors that can occur when we try transform some spec from [`Element`]. +/// This error used in all [`TryFrom`] of Control API. +#[allow(clippy::pub_enum_variant_names)] +#[derive(Debug, Fail)] +pub enum TryFromElementError { + #[fail(display = "Element is not Endpoint")] + NotEndpoint, + #[fail(display = "Element is not Room")] + NotRoom, + #[fail(display = "Element is not Member")] + NotMember, +} + +/// Entity for parsing Control API request. +#[derive(Clone, Deserialize, Debug)] +#[serde(tag = "kind")] +pub enum Element { + /// Represent [`RoomSpec`]. + /// Can transform into [`RoomSpec`] by `RoomSpec::try_from`. + Room { id: RoomId, spec: Pipeline }, + + /// Represent [`MemberSpec`]. + /// Can transform into [`MemberSpec`] by `MemberSpec::try_from`. + Member { spec: Pipeline, credentials: String }, + + /// Represent [`WebRtcPublishEndpoint`]. + /// Can transform into [`Endpoint`] enum by `Endpoint::try_from`. + WebRtcPublishEndpoint { spec: SerdeWebRtcPublishEndpoint }, + + /// Represent [`WebRtcPlayEndpoint`]. + /// Can transform into [`Endpoint`] enum by `Endpoint::try_from`. + WebRtcPlayEndpoint { spec: SerdeWebRtcPlayEndpoint }, +} + +/// Load [`RoomSpec`] from file with YAML format. +pub fn load_from_yaml_file>( + path: P, +) -> Result { + let mut file = File::open(path)?; + let mut buf = String::new(); + file.read_to_string(&mut buf)?; + let parsed: Element = serde_yaml::from_str(&buf)?; + let room = SerdeRoomSpec::try_from(&parsed)?; + + Ok(room) +} + +/// Load all [`RoomSpec`] from YAML files from provided path. +pub fn load_static_specs_from_dir>( + path: P, +) -> Result, Error> { + let mut specs = Vec::new(); + for entry in std::fs::read_dir(path)? { + let entry = entry?; + let spec = load_from_yaml_file(entry.path())?; + specs.push(spec) + } + + Ok(specs) +} diff --git a/src/api/control/pipeline.rs b/src/api/control/serde/pipeline.rs similarity index 95% rename from src/api/control/pipeline.rs rename to src/api/control/serde/pipeline.rs index 1456ae7d2..73a4041e5 100644 --- a/src/api/control/pipeline.rs +++ b/src/api/control/serde/pipeline.rs @@ -10,7 +10,7 @@ use std::{ use serde::Deserialize; -use crate::api::control::Element; +use crate::api::control::serde::Element; /// Entity that represents some pipeline of spec. #[derive(Clone, Deserialize, Debug)] diff --git a/src/api/control/room.rs b/src/api/control/serde/room.rs similarity index 100% rename from src/api/control/room.rs rename to src/api/control/serde/room.rs diff --git a/src/api/grpc/server.rs b/src/api/grpc/server.rs index 54cdc4d2d..d335d5aca 100644 --- a/src/api/grpc/server.rs +++ b/src/api/grpc/server.rs @@ -6,7 +6,7 @@ use grpcio::{Environment, RpcContext, Server, ServerBuilder, UnarySink}; use crate::{ api::{ - control::RoomId, + control::model::RoomId, grpc::protos::control::{ ApplyRequest, CreateRequest, GetResponse, IdRequest, Response, }, diff --git a/src/lib.rs b/src/lib.rs index 0773fcbf4..e2d179760 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -14,7 +14,7 @@ use failure::Fail; use hashbrown::HashMap; use crate::{ - api::control::{load_static_specs_from_dir, RoomId}, + api::control::serde::{load_static_specs_from_dir, RoomId}, conf::Conf, signalling::{room::RoomError, Room}, turn::service, diff --git a/src/media/ice_user.rs b/src/media/ice_user.rs index 1c18da31d..b22ce6d1b 100644 --- a/src/media/ice_user.rs +++ b/src/media/ice_user.rs @@ -2,7 +2,7 @@ use std::net::SocketAddr; use medea_client_api_proto::IceServer; -use crate::api::control::RoomId; +use crate::api::control::serde::RoomId; /// Credentials on Turn server. #[derive(Clone, Debug)] diff --git a/src/media/peer.rs b/src/media/peer.rs index e3c331d2e..6fb7574b8 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -14,7 +14,7 @@ use medea_client_api_proto::{ use medea_macro::enum_delegate; use crate::{ - api::control::MemberId, + api::control::serde::MemberId, media::{MediaTrack, TrackId}, signalling::peers::Counter, }; diff --git a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs index 809016613..fc2ac0600 100644 --- a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs @@ -9,7 +9,7 @@ use macro_attr::*; use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; use crate::{ - api::control::endpoint::SerdeSrcUri, media::PeerId, + api::control::serde::endpoint::SerdeSrcUri, media::PeerId, signalling::elements::Member, }; diff --git a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs index 4ac003de5..733e2db24 100644 --- a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs @@ -10,7 +10,7 @@ use macro_attr::*; use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; use crate::{ - api::control::endpoint::P2pMode, media::PeerId, + api::control::serde::endpoint::P2pMode, media::PeerId, signalling::elements::Member, }; diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index 2183ac516..3fdc0fc88 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -7,7 +7,7 @@ use hashbrown::HashMap; use medea_client_api_proto::IceServer; use crate::{ - api::control::{ + api::control::serde::{ MemberId, SerdeMemberSpec, SerdeRoomSpec, TryFromElementError, }, log::prelude::*, @@ -17,7 +17,9 @@ use crate::{ use super::endpoints::webrtc::{ WebRtcPlayEndpoint, WebRtcPlayId, WebRtcPublishEndpoint, WebRtcPublishId, }; -use crate::api::control::{model::room::RoomSpec, room::ParsedSerdeRoomSpec}; +use crate::api::control::{ + model::room::RoomSpec, serde::room::ParsedSerdeRoomSpec, +}; /// Errors which may occur while loading [`Member`]s from [`RoomSpec`]. #[derive(Debug, Fail)] @@ -87,7 +89,7 @@ impl Member { // let this_member_spec = SerdeMemberSpec::try_from( // room_spec // .get_member_by_id(&self.id()) - // + // // .map_or(Err(MembersLoadError::MemberNotFound(self.id())), Ok)?, // )?; @@ -111,11 +113,11 @@ impl Member { // let publisher_spec = SerdeMemberSpec::try_from( // room_spec // .pipeline - // + // // .get(&spec_play_endpoint.src().member_id.to_string()) // .map_or( // Err(MembersLoadError::MemberNotFound( - // + // // spec_play_endpoint.src().member_id.clone(), // )), // Ok, @@ -144,7 +146,7 @@ impl Member { // .get(&spec_play_endpoint.src().endpoint_id) // .map_or( // Err(MembersLoadError::EndpointNotFound( - // + // // spec_play_endpoint.src().endpoint_id.clone().0, // TODO: tmp // )), // Ok, @@ -352,7 +354,7 @@ pub fn parse_members( mod tests { use std::rc::Rc; - use crate::api::control::{Element, MemberId}; + use crate::api::control::serde::{Element, MemberId}; use super::*; diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index a538539a9..9bc928db3 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -26,7 +26,10 @@ use crate::{ AuthorizationError, ClosedReason, EventMessage, RpcConnection, RpcConnectionClosed, }, - control::{MemberId, RoomId, SerdeRoomSpec}, + control::{ + model::{MemberId, RoomId}, + serde::SerdeRoomSpec, + }, }, log::prelude::*, media::IceUser, diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index d3b60a2a4..f2bcbc75c 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -9,7 +9,7 @@ use actix::{AsyncContext as _, Context}; use hashbrown::HashMap; use crate::{ - api::control::MemberId, + api::control::serde::MemberId, log::prelude::*, media::{New, Peer, PeerId, PeerStateMachine}, signalling::{ diff --git a/src/signalling/room.rs b/src/signalling/room.rs index d71064766..acb49d65e 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -18,7 +18,10 @@ use crate::{ AuthorizationError, Authorize, ClosedReason, CommandMessage, RpcConnectionClosed, RpcConnectionEstablished, }, - control::{MemberId, RoomId, SerdeRoomSpec, TryFromElementError}, + control::{ + model::{MemberId, RoomId}, + serde::{SerdeRoomSpec, TryFromElementError}, + }, }, log::prelude::*, media::{ diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs index 296f75aa1..71e85818d 100644 --- a/src/signalling/room_repo.rs +++ b/src/signalling/room_repo.rs @@ -5,7 +5,7 @@ use std::sync::{Arc, Mutex}; use actix::Addr; use hashbrown::HashMap; -use crate::{api::control::RoomId, signalling::Room}; +use crate::{api::control::serde::RoomId, signalling::Room}; /// Repository that stores [`Room`]s addresses. #[derive(Clone, Default, Debug)] diff --git a/src/turn/service.rs b/src/turn/service.rs index 300e07f63..e293a6d1b 100644 --- a/src/turn/service.rs +++ b/src/turn/service.rs @@ -12,7 +12,7 @@ use rand::{distributions::Alphanumeric, Rng}; use redis::ConnectionInfo; use crate::{ - api::control::{MemberId, RoomId}, + api::control::serde::{MemberId, RoomId}, conf::Conf, media::IceUser, turn::repo::{TurnDatabase, TurnDatabaseErr}, From 110ee97efc05be13c2934d455b5034738680eb41 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 4 Jul 2019 15:37:29 +0300 Subject: [PATCH 240/735] Use model ID everywhere --- src/api/client/rpc_connection.rs | 2 +- src/api/control/serde/member.rs | 3 +-- src/api/control/serde/mod.rs | 5 ++--- src/api/control/serde/room.rs | 10 +++++----- src/lib.rs | 2 +- src/media/ice_user.rs | 2 +- src/media/peer.rs | 2 +- src/signalling/elements/member.rs | 5 +++-- src/signalling/peers.rs | 2 +- src/signalling/room_repo.rs | 2 +- src/turn/service.rs | 2 +- 11 files changed, 18 insertions(+), 19 deletions(-) diff --git a/src/api/client/rpc_connection.rs b/src/api/client/rpc_connection.rs index f2288cd3a..3ce1115de 100644 --- a/src/api/client/rpc_connection.rs +++ b/src/api/client/rpc_connection.rs @@ -8,7 +8,7 @@ use macro_attr::*; use medea_client_api_proto::{Command, Event}; use newtype_derive::NewtypeFrom; -use crate::api::control::serde::MemberId; +use crate::api::control::model::MemberId; macro_attr! { /// Wrapper [`Command`] for implements actix [`Message`]. diff --git a/src/api/control/serde/member.rs b/src/api/control/serde/member.rs index 2e71a775a..17107df8e 100644 --- a/src/api/control/serde/member.rs +++ b/src/api/control/serde/member.rs @@ -13,14 +13,13 @@ use super::{ Element, TryFromElementError, }; -pub use crate::api::control::model::member::Id; use crate::api::control::{ model::{ endpoint::webrtc::{ WebRtcPlayEndpoint, WebRtcPlayId, WebRtcPublishEndpoint, WebRtcPublishId, }, - member::MemberSpec, + member::{Id, MemberSpec}, MemberId, }, serde::Endpoint, diff --git a/src/api/control/serde/mod.rs b/src/api/control/serde/mod.rs index 04ea96c84..7f2f4e327 100644 --- a/src/api/control/serde/mod.rs +++ b/src/api/control/serde/mod.rs @@ -14,11 +14,10 @@ use self::{ endpoint::{SerdeWebRtcPlayEndpoint, SerdeWebRtcPublishEndpoint}, pipeline::Pipeline, }; +use super::model::RoomId; pub use self::{ - endpoint::Endpoint, - member::{Id as MemberId, SerdeMemberSpec}, - room::{Id as RoomId, SerdeRoomSpec}, + endpoint::Endpoint, member::SerdeMemberSpec, room::SerdeRoomSpec, }; /// Errors that can occur when we try transform some spec from [`Element`]. diff --git a/src/api/control/serde/room.rs b/src/api/control/serde/room.rs index c42b770e0..18ab6cc98 100644 --- a/src/api/control/serde/room.rs +++ b/src/api/control/serde/room.rs @@ -8,13 +8,13 @@ use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; use serde::Deserialize; use super::{ - member::SerdeMemberSpec, pipeline::Pipeline, Element, MemberId, - TryFromElementError, + member::SerdeMemberSpec, pipeline::Pipeline, Element, TryFromElementError, +}; +use crate::api::control::model::{ + member::MemberSpec, room::RoomSpec, MemberId, }; -use crate::api::control::model::{member::MemberSpec, room::RoomSpec}; -pub use crate::api::control::model::room::Id; -pub use Id as RoomId; +use crate::api::control::model::room::Id; /// [`crate::signalling::room::Room`] specification. /// Newtype for [`Element::Room`] diff --git a/src/lib.rs b/src/lib.rs index e2d179760..1a6d4587e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -14,7 +14,7 @@ use failure::Fail; use hashbrown::HashMap; use crate::{ - api::control::serde::{load_static_specs_from_dir, RoomId}, + api::control::{model::RoomId, serde::load_static_specs_from_dir}, conf::Conf, signalling::{room::RoomError, Room}, turn::service, diff --git a/src/media/ice_user.rs b/src/media/ice_user.rs index b22ce6d1b..73db4a965 100644 --- a/src/media/ice_user.rs +++ b/src/media/ice_user.rs @@ -2,7 +2,7 @@ use std::net::SocketAddr; use medea_client_api_proto::IceServer; -use crate::api::control::serde::RoomId; +use crate::api::control::model::RoomId; /// Credentials on Turn server. #[derive(Clone, Debug)] diff --git a/src/media/peer.rs b/src/media/peer.rs index 6fb7574b8..119e22e84 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -14,7 +14,7 @@ use medea_client_api_proto::{ use medea_macro::enum_delegate; use crate::{ - api::control::serde::MemberId, + api::control::model::MemberId, media::{MediaTrack, TrackId}, signalling::peers::Counter, }; diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index 3fdc0fc88..7c42fdef6 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -7,8 +7,9 @@ use hashbrown::HashMap; use medea_client_api_proto::IceServer; use crate::{ - api::control::serde::{ - MemberId, SerdeMemberSpec, SerdeRoomSpec, TryFromElementError, + api::control::{ + model::MemberId, + serde::{SerdeMemberSpec, SerdeRoomSpec, TryFromElementError}, }, log::prelude::*, media::{IceUser, PeerId}, diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index f2bcbc75c..680e50a98 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -9,7 +9,7 @@ use actix::{AsyncContext as _, Context}; use hashbrown::HashMap; use crate::{ - api::control::serde::MemberId, + api::control::model::MemberId, log::prelude::*, media::{New, Peer, PeerId, PeerStateMachine}, signalling::{ diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs index 71e85818d..e1c66c4c4 100644 --- a/src/signalling/room_repo.rs +++ b/src/signalling/room_repo.rs @@ -5,7 +5,7 @@ use std::sync::{Arc, Mutex}; use actix::Addr; use hashbrown::HashMap; -use crate::{api::control::serde::RoomId, signalling::Room}; +use crate::{api::control::model::RoomId, signalling::Room}; /// Repository that stores [`Room`]s addresses. #[derive(Clone, Default, Debug)] diff --git a/src/turn/service.rs b/src/turn/service.rs index e293a6d1b..3f11d681a 100644 --- a/src/turn/service.rs +++ b/src/turn/service.rs @@ -12,7 +12,7 @@ use rand::{distributions::Alphanumeric, Rng}; use redis::ConnectionInfo; use crate::{ - api::control::serde::{MemberId, RoomId}, + api::control::model::{MemberId, RoomId}, conf::Conf, media::IceUser, turn::repo::{TurnDatabase, TurnDatabaseErr}, From bebfcf5f0c6f2197e47adf43d4cca0dfde2e22ca Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 4 Jul 2019 17:15:23 +0300 Subject: [PATCH 241/735] Partially implement protobuf DTOs --- src/api/control/mod.rs | 1 + .../model/endpoint/webrtc/play_endpoint.rs | 2 +- .../model/endpoint/webrtc/publish_endpoint.rs | 2 +- src/api/control/model/member.rs | 4 +- src/api/control/model/room.rs | 2 +- src/api/control/protobuf/member.rs | 86 +++++++++++++++++++ src/api/control/protobuf/mod.rs | 4 + src/api/control/protobuf/room.rs | 41 +++++++++ .../control/protobuf/webrtc_play_endpoint.rs | 33 +++++++ .../protobuf/webrtc_publish_endpoint.rs | 24 ++++++ src/api/control/serde/endpoint.rs | 8 +- src/api/control/serde/member.rs | 8 +- src/api/control/serde/room.rs | 6 +- 13 files changed, 206 insertions(+), 15 deletions(-) create mode 100644 src/api/control/protobuf/member.rs create mode 100644 src/api/control/protobuf/mod.rs create mode 100644 src/api/control/protobuf/room.rs create mode 100644 src/api/control/protobuf/webrtc_play_endpoint.rs create mode 100644 src/api/control/protobuf/webrtc_publish_endpoint.rs diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index 78807a2ab..463b57ba2 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -1,2 +1,3 @@ pub mod model; +pub mod protobuf; pub mod serde; diff --git a/src/api/control/model/endpoint/webrtc/play_endpoint.rs b/src/api/control/model/endpoint/webrtc/play_endpoint.rs index 287522e5f..383fb648a 100644 --- a/src/api/control/model/endpoint/webrtc/play_endpoint.rs +++ b/src/api/control/model/endpoint/webrtc/play_endpoint.rs @@ -25,5 +25,5 @@ macro_attr! { } pub trait WebRtcPlayEndpoint { - fn src(&self) -> &SerdeSrcUri; + fn src(&self) -> SerdeSrcUri; } diff --git a/src/api/control/model/endpoint/webrtc/publish_endpoint.rs b/src/api/control/model/endpoint/webrtc/publish_endpoint.rs index 478718296..f79e95e7e 100644 --- a/src/api/control/model/endpoint/webrtc/publish_endpoint.rs +++ b/src/api/control/model/endpoint/webrtc/publish_endpoint.rs @@ -21,5 +21,5 @@ macro_attr! { pub use Id as WebRtcPublishId; pub trait WebRtcPublishEndpoint { - fn p2p(&self) -> &P2pMode; + fn p2p(&self) -> P2pMode; } diff --git a/src/api/control/model/member.rs b/src/api/control/model/member.rs index 23d62f300..37a2c2e24 100644 --- a/src/api/control/model/member.rs +++ b/src/api/control/model/member.rs @@ -24,11 +24,11 @@ pub use Id as MemberId; pub trait MemberSpec { fn webrtc_play_endpoints( &self, - ) -> HashMap>; + ) -> HashMap>; fn webrtc_publish_endpoints( &self, - ) -> HashMap>; + ) -> HashMap>; fn credentials(&self) -> &String; diff --git a/src/api/control/model/room.rs b/src/api/control/model/room.rs index 52adc940b..0cb13b89e 100644 --- a/src/api/control/model/room.rs +++ b/src/api/control/model/room.rs @@ -22,7 +22,7 @@ macro_attr! { pub use Id as RoomId; pub trait RoomSpec { - fn members(&self) -> HashMap<&MemberId, Box<&dyn MemberSpec>>; + fn members(&self) -> HashMap>; fn id(&self) -> &Id; diff --git a/src/api/control/protobuf/member.rs b/src/api/control/protobuf/member.rs new file mode 100644 index 000000000..b04d2054f --- /dev/null +++ b/src/api/control/protobuf/member.rs @@ -0,0 +1,86 @@ +use crate::{ + api::{ + control::{ + model::{ + endpoint::webrtc::{WebRtcPlayEndpoint, WebRtcPublishEndpoint}, + member::MemberSpec, + MemberId, RoomId, + }, + protobuf::{ + webrtc_play_endpoint::GrpcWebRtcPlayEndpoint, + webrtc_publish_endpoint::GrpcWebRtcPublishEndpoint, + }, + }, + grpc::protos::control::Member, + }, + signalling::elements::endpoints::webrtc::{WebRtcPlayId, WebRtcPublishId}, +}; +use hashbrown::HashMap; + +pub struct GrpcMember(pub Member); + +impl MemberSpec for GrpcMember { + fn webrtc_play_endpoints( + &self, + ) -> HashMap> { + self.0 + .get_pipeline() + .iter() + .filter_map(|(id, element)| { + if element.has_webrtc_play() { + let endpoint = element.get_webrtc_play().clone(); + Some(( + WebRtcPlayId(id.clone()), + Box::new(GrpcWebRtcPlayEndpoint(endpoint)) + as Box, + )) + } else { + None + } + }) + .collect() + } + + fn webrtc_publish_endpoints( + &self, + ) -> HashMap> { + self.0 + .get_pipeline() + .iter() + .filter_map(|(id, element)| { + if element.has_webrtc_pub() { + let endpoint = element.get_webrtc_pub().clone(); + Some(( + WebRtcPublishId(id.clone()), + Box::new(GrpcWebRtcPublishEndpoint(endpoint)) + as Box, + )) + } else { + None + } + }) + .collect() + } + + fn credentials(&self) -> &String { + unimplemented!() + } + + fn id(&self) -> &MemberId { + unimplemented!() + } + + fn get_webrtc_play_by_id( + &self, + id: &WebRtcPlayId, + ) -> Option> { + unimplemented!() + } + + fn get_webrtc_publish_by_id( + &self, + id: &WebRtcPublishId, + ) -> Option> { + unimplemented!() + } +} diff --git a/src/api/control/protobuf/mod.rs b/src/api/control/protobuf/mod.rs new file mode 100644 index 000000000..399f7b3f2 --- /dev/null +++ b/src/api/control/protobuf/mod.rs @@ -0,0 +1,4 @@ +pub mod member; +pub mod room; +pub mod webrtc_play_endpoint; +pub mod webrtc_publish_endpoint; diff --git a/src/api/control/protobuf/room.rs b/src/api/control/protobuf/room.rs new file mode 100644 index 000000000..9dbf0b852 --- /dev/null +++ b/src/api/control/protobuf/room.rs @@ -0,0 +1,41 @@ +use super::member::GrpcMember; +use crate::api::{ + control::model::{member::MemberSpec, room::RoomSpec, MemberId, RoomId}, + grpc::protos::control::CreateRequest, +}; +use hashbrown::HashMap; + +struct CreateRequestSpec(CreateRequest); + +impl RoomSpec for CreateRequestSpec { + fn members(&self) -> HashMap> { + if self.0.has_room() { + let member = self.0.get_room(); + member + .get_pipeline() + .iter() + .filter_map(|(id, e)| { + if e.has_member() { + let member = e.get_member(); + return Some(( + MemberId(id.clone()), + Box::new(GrpcMember(member.clone())) + as Box, + )); + } + None + }) + .collect() + } else { + HashMap::new() + } + } + + fn id(&self) -> &RoomId { + unimplemented!() + } + + fn get_member_by_id(&self, id: &MemberId) -> Option> { + unimplemented!() + } +} diff --git a/src/api/control/protobuf/webrtc_play_endpoint.rs b/src/api/control/protobuf/webrtc_play_endpoint.rs new file mode 100644 index 000000000..b88312f4d --- /dev/null +++ b/src/api/control/protobuf/webrtc_play_endpoint.rs @@ -0,0 +1,33 @@ +use crate::{ + api::{ + control::{ + model::{ + endpoint::webrtc::{WebRtcPlayEndpoint, WebRtcPublishEndpoint}, + member::MemberSpec, + MemberId, RoomId, + }, + serde::endpoint::SerdeSrcUri, + }, + grpc::protos::control::WebRtcPlayEndpoint as WebRtcPlayEndpointDto, + }, + signalling::elements::endpoints::webrtc::{WebRtcPlayId, WebRtcPublishId}, +}; +use hashbrown::HashMap; + +pub struct GrpcWebRtcPlayEndpoint(pub WebRtcPlayEndpointDto); + +impl WebRtcPlayEndpoint for GrpcWebRtcPlayEndpoint { + fn src(&self) -> SerdeSrcUri { + if self.0.has_src() { + let src = self.0.get_src(); + SerdeSrcUri { + endpoint_id: WebRtcPublishId("".to_string()), + member_id: MemberId("".to_string()), + room_id: RoomId("".to_string()), + } + } else { + // TODO: do something with it. + unimplemented!("TODO") + } + } +} diff --git a/src/api/control/protobuf/webrtc_publish_endpoint.rs b/src/api/control/protobuf/webrtc_publish_endpoint.rs new file mode 100644 index 000000000..7ad4fc2d6 --- /dev/null +++ b/src/api/control/protobuf/webrtc_publish_endpoint.rs @@ -0,0 +1,24 @@ +use crate::{ + api::{ + control::{ + model::{ + endpoint::webrtc::{WebRtcPlayEndpoint, WebRtcPublishEndpoint}, + member::MemberSpec, + MemberId, RoomId, + }, + serde::endpoint::{P2pMode, SerdeSrcUri}, + }, + grpc::protos::control::WebRtcPublishEndpoint as WebRtcPublishEndpointDto, + }, + signalling::elements::endpoints::webrtc::{WebRtcPlayId, WebRtcPublishId}, +}; +use hashbrown::HashMap; + +pub struct GrpcWebRtcPublishEndpoint(pub WebRtcPublishEndpointDto); + +impl WebRtcPublishEndpoint for GrpcWebRtcPublishEndpoint { + fn p2p(&self) -> P2pMode { + // TODO: implement me. + P2pMode::Always + } +} diff --git a/src/api/control/serde/endpoint.rs b/src/api/control/serde/endpoint.rs index e67f01bbb..d6fb382b2 100644 --- a/src/api/control/serde/endpoint.rs +++ b/src/api/control/serde/endpoint.rs @@ -53,8 +53,8 @@ pub struct SerdeWebRtcPublishEndpoint { } impl WebRtcPublishEndpoint for SerdeWebRtcPublishEndpoint { - fn p2p(&self) -> &P2pMode { - &self.p2p + fn p2p(&self) -> P2pMode { + self.p2p.clone() } } @@ -67,8 +67,8 @@ pub struct SerdeWebRtcPlayEndpoint { } impl WebRtcPlayEndpoint for SerdeWebRtcPlayEndpoint { - fn src(&self) -> &SrcUri { - &self.src + fn src(&self) -> SrcUri { + self.src.clone() } } diff --git a/src/api/control/serde/member.rs b/src/api/control/serde/member.rs index 17107df8e..df484301e 100644 --- a/src/api/control/serde/member.rs +++ b/src/api/control/serde/member.rs @@ -71,13 +71,13 @@ impl SerdeMemberSpec { impl MemberSpec for SerdeMemberSpec { fn webrtc_play_endpoints( &self, - ) -> HashMap> { + ) -> HashMap> { self.pipeline .iter() .filter_map(|(id, e)| match e { Element::WebRtcPlayEndpoint { spec } => Some(( WebRtcPlayId(id.clone()), - Box::new(spec as &WebRtcPlayEndpoint), + Box::new(spec.clone()) as Box, )), _ => None, }) @@ -86,13 +86,13 @@ impl MemberSpec for SerdeMemberSpec { fn webrtc_publish_endpoints( &self, - ) -> HashMap> { + ) -> HashMap> { self.pipeline .iter() .filter_map(|(id, e)| match e { Element::WebRtcPublishEndpoint { spec } => Some(( WebRtcPublishId(id.clone()), - Box::new(spec as &WebRtcPublishEndpoint), + Box::new(spec.clone()) as Box, )), _ => None, }) diff --git a/src/api/control/serde/room.rs b/src/api/control/serde/room.rs index 18ab6cc98..57cea412d 100644 --- a/src/api/control/serde/room.rs +++ b/src/api/control/serde/room.rs @@ -62,10 +62,12 @@ impl ParsedSerdeRoomSpec { } impl RoomSpec for ParsedSerdeRoomSpec { - fn members(&self) -> HashMap<&MemberId, Box<&MemberSpec>> { + fn members(&self) -> HashMap> { self.members .iter() - .map(|(id, member)| (id, Box::new(member as &MemberSpec))) + .map(|(id, member)| { + (id.clone(), Box::new(member.clone()) as Box) + }) .collect() } From 387c331b17444bde52c5230270d43af091488f37 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 4 Jul 2019 17:21:31 +0300 Subject: [PATCH 242/735] Implement convertation of protobuf P2p to interior P2p --- .../protobuf/webrtc_publish_endpoint.rs | 18 +++++++++++++++--- src/api/control/serde/endpoint.rs | 2 ++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/api/control/protobuf/webrtc_publish_endpoint.rs b/src/api/control/protobuf/webrtc_publish_endpoint.rs index 7ad4fc2d6..578a791b3 100644 --- a/src/api/control/protobuf/webrtc_publish_endpoint.rs +++ b/src/api/control/protobuf/webrtc_publish_endpoint.rs @@ -8,7 +8,10 @@ use crate::{ }, serde::endpoint::{P2pMode, SerdeSrcUri}, }, - grpc::protos::control::WebRtcPublishEndpoint as WebRtcPublishEndpointDto, + grpc::protos::control::{ + WebRtcPublishEndpoint as WebRtcPublishEndpointDto, + WebRtcPublishEndpoint_P2P, + }, }, signalling::elements::endpoints::webrtc::{WebRtcPlayId, WebRtcPublishId}, }; @@ -18,7 +21,16 @@ pub struct GrpcWebRtcPublishEndpoint(pub WebRtcPublishEndpointDto); impl WebRtcPublishEndpoint for GrpcWebRtcPublishEndpoint { fn p2p(&self) -> P2pMode { - // TODO: implement me. - P2pMode::Always + if self.0.has_p2p() { + let p2p = self.0.get_p2p(); + match p2p { + WebRtcPublishEndpoint_P2P::ALWAYS => P2pMode::Always, + WebRtcPublishEndpoint_P2P::NEVER => P2pMode::Never, + WebRtcPublishEndpoint_P2P::IF_POSSIBLE => P2pMode::IfPossible, + } + } else { + // TODO: do with me something + unimplemented!() + } } } diff --git a/src/api/control/serde/endpoint.rs b/src/api/control/serde/endpoint.rs index d6fb382b2..132223462 100644 --- a/src/api/control/serde/endpoint.rs +++ b/src/api/control/serde/endpoint.rs @@ -41,6 +41,8 @@ impl TryFrom<&Element> for Endpoint { pub enum P2pMode { /// Always connect peer-to-peer. Always, + Never, + IfPossible, } /// Media element which is able to publish media data for another client via From 16886aef68313856168031b73cf53ea93cb8af83 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 4 Jul 2019 17:29:27 +0300 Subject: [PATCH 243/735] Implement get endpoints by id --- src/api/control/protobuf/member.rs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/api/control/protobuf/member.rs b/src/api/control/protobuf/member.rs index b04d2054f..8c8abca5f 100644 --- a/src/api/control/protobuf/member.rs +++ b/src/api/control/protobuf/member.rs @@ -63,6 +63,7 @@ impl MemberSpec for GrpcMember { } fn credentials(&self) -> &String { + // TODO: deal with it unimplemented!() } @@ -74,13 +75,27 @@ impl MemberSpec for GrpcMember { &self, id: &WebRtcPlayId, ) -> Option> { - unimplemented!() + let element = self.0.pipeline.get(&id.0)?; + if element.has_webrtc_play() { + let play = element.get_webrtc_play().clone(); + let play = GrpcWebRtcPlayEndpoint(play); + Some(Box::new(play) as Box) + } else { + None + } } fn get_webrtc_publish_by_id( &self, id: &WebRtcPublishId, ) -> Option> { - unimplemented!() + let element = self.0.pipeline.get(&id.0)?; + if element.has_webrtc_pub() { + let publish = element.get_webrtc_pub().clone(); + let play = GrpcWebRtcPublishEndpoint(publish); + Some(Box::new(play) as Box) + } else { + None + } } } From f7f1d9a35b8def5dd60987e9a03fe6c74362b52b Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 4 Jul 2019 17:44:40 +0300 Subject: [PATCH 244/735] Fix warnings, fmt --- .../model/endpoint/webrtc/play_endpoint.rs | 7 ++-- src/api/control/protobuf/member.rs | 5 +-- src/api/control/protobuf/room.rs | 9 ++++-- .../control/protobuf/webrtc_play_endpoint.rs | 11 ++----- .../protobuf/webrtc_publish_endpoint.rs | 24 +++++--------- src/api/control/serde/endpoint.rs | 5 +-- src/api/control/serde/member.rs | 20 ++++++------ src/api/control/serde/room.rs | 14 ++++---- src/api/grpc/server.rs | 32 +++++++++---------- src/main.rs | 2 +- .../endpoints/webrtc/play_endpoint.rs | 3 -- .../endpoints/webrtc/publish_endpoint.rs | 2 -- src/signalling/elements/member.rs | 11 ++++--- 13 files changed, 63 insertions(+), 82 deletions(-) diff --git a/src/api/control/model/endpoint/webrtc/play_endpoint.rs b/src/api/control/model/endpoint/webrtc/play_endpoint.rs index 383fb648a..936a851a7 100644 --- a/src/api/control/model/endpoint/webrtc/play_endpoint.rs +++ b/src/api/control/model/endpoint/webrtc/play_endpoint.rs @@ -1,14 +1,11 @@ -use crate::api::control::{ - model::{MemberId, RoomId, WebRtcPublishId}, - serde::endpoint::SerdeSrcUri, -}; +use crate::api::control::serde::endpoint::SerdeSrcUri; use macro_attr::*; use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; use serde::Deserialize; -use std::fmt::Debug; pub use Id as WebRtcPlayId; + macro_attr! { /// ID of [`Room`]. #[derive( diff --git a/src/api/control/protobuf/member.rs b/src/api/control/protobuf/member.rs index 8c8abca5f..bcd543523 100644 --- a/src/api/control/protobuf/member.rs +++ b/src/api/control/protobuf/member.rs @@ -1,10 +1,12 @@ +use hashbrown::HashMap; + use crate::{ api::{ control::{ model::{ endpoint::webrtc::{WebRtcPlayEndpoint, WebRtcPublishEndpoint}, member::MemberSpec, - MemberId, RoomId, + MemberId, }, protobuf::{ webrtc_play_endpoint::GrpcWebRtcPlayEndpoint, @@ -15,7 +17,6 @@ use crate::{ }, signalling::elements::endpoints::webrtc::{WebRtcPlayId, WebRtcPublishId}, }; -use hashbrown::HashMap; pub struct GrpcMember(pub Member); diff --git a/src/api/control/protobuf/room.rs b/src/api/control/protobuf/room.rs index 9dbf0b852..a06eb44ea 100644 --- a/src/api/control/protobuf/room.rs +++ b/src/api/control/protobuf/room.rs @@ -1,10 +1,13 @@ -use super::member::GrpcMember; +use hashbrown::HashMap; + use crate::api::{ control::model::{member::MemberSpec, room::RoomSpec, MemberId, RoomId}, grpc::protos::control::CreateRequest, }; -use hashbrown::HashMap; +use super::member::GrpcMember; + +#[allow(dead_code)] struct CreateRequestSpec(CreateRequest); impl RoomSpec for CreateRequestSpec { @@ -35,7 +38,7 @@ impl RoomSpec for CreateRequestSpec { unimplemented!() } - fn get_member_by_id(&self, id: &MemberId) -> Option> { + fn get_member_by_id(&self, _id: &MemberId) -> Option> { unimplemented!() } } diff --git a/src/api/control/protobuf/webrtc_play_endpoint.rs b/src/api/control/protobuf/webrtc_play_endpoint.rs index b88312f4d..0e9556d03 100644 --- a/src/api/control/protobuf/webrtc_play_endpoint.rs +++ b/src/api/control/protobuf/webrtc_play_endpoint.rs @@ -1,25 +1,20 @@ use crate::{ api::{ control::{ - model::{ - endpoint::webrtc::{WebRtcPlayEndpoint, WebRtcPublishEndpoint}, - member::MemberSpec, - MemberId, RoomId, - }, + model::{endpoint::webrtc::WebRtcPlayEndpoint, MemberId, RoomId}, serde::endpoint::SerdeSrcUri, }, grpc::protos::control::WebRtcPlayEndpoint as WebRtcPlayEndpointDto, }, - signalling::elements::endpoints::webrtc::{WebRtcPlayId, WebRtcPublishId}, + signalling::elements::endpoints::webrtc::WebRtcPublishId, }; -use hashbrown::HashMap; pub struct GrpcWebRtcPlayEndpoint(pub WebRtcPlayEndpointDto); impl WebRtcPlayEndpoint for GrpcWebRtcPlayEndpoint { fn src(&self) -> SerdeSrcUri { if self.0.has_src() { - let src = self.0.get_src(); + let _src = self.0.get_src(); SerdeSrcUri { endpoint_id: WebRtcPublishId("".to_string()), member_id: MemberId("".to_string()), diff --git a/src/api/control/protobuf/webrtc_publish_endpoint.rs b/src/api/control/protobuf/webrtc_publish_endpoint.rs index 578a791b3..a79c4dc15 100644 --- a/src/api/control/protobuf/webrtc_publish_endpoint.rs +++ b/src/api/control/protobuf/webrtc_publish_endpoint.rs @@ -1,21 +1,13 @@ -use crate::{ - api::{ - control::{ - model::{ - endpoint::webrtc::{WebRtcPlayEndpoint, WebRtcPublishEndpoint}, - member::MemberSpec, - MemberId, RoomId, - }, - serde::endpoint::{P2pMode, SerdeSrcUri}, - }, - grpc::protos::control::{ - WebRtcPublishEndpoint as WebRtcPublishEndpointDto, - WebRtcPublishEndpoint_P2P, - }, +use crate::api::{ + control::{ + model::endpoint::webrtc::WebRtcPublishEndpoint, + serde::endpoint::P2pMode, + }, + grpc::protos::control::{ + WebRtcPublishEndpoint as WebRtcPublishEndpointDto, + WebRtcPublishEndpoint_P2P, }, - signalling::elements::endpoints::webrtc::{WebRtcPlayId, WebRtcPublishId}, }; -use hashbrown::HashMap; pub struct GrpcWebRtcPublishEndpoint(pub WebRtcPublishEndpointDto); diff --git a/src/api/control/serde/endpoint.rs b/src/api/control/serde/endpoint.rs index 132223462..e84a2389a 100644 --- a/src/api/control/serde/endpoint.rs +++ b/src/api/control/serde/endpoint.rs @@ -7,10 +7,11 @@ use serde::{ Deserialize, }; -use crate::api::control::model::{endpoint::webrtc::*, member::MemberId}; +use crate::api::control::model::{ + endpoint::webrtc::*, member::MemberId, room::RoomId, +}; use super::{Element, TryFromElementError}; -use crate::api::control::model::room::RoomId; /// [`Endpoint`] represents a media element that one or more media data streams /// flow through. diff --git a/src/api/control/serde/member.rs b/src/api/control/serde/member.rs index df484301e..f8acd0000 100644 --- a/src/api/control/serde/member.rs +++ b/src/api/control/serde/member.rs @@ -3,15 +3,6 @@ use std::convert::TryFrom; use hashbrown::HashMap; -use macro_attr::*; -use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; -use serde::Deserialize; - -use super::{ - endpoint::{SerdeWebRtcPlayEndpoint, SerdeWebRtcPublishEndpoint}, - pipeline::Pipeline, - Element, TryFromElementError, -}; use crate::api::control::{ model::{ @@ -19,12 +10,18 @@ use crate::api::control::{ WebRtcPlayEndpoint, WebRtcPlayId, WebRtcPublishEndpoint, WebRtcPublishId, }, - member::{Id, MemberSpec}, + member::MemberSpec, MemberId, }, serde::Endpoint, }; +use super::{ + endpoint::{SerdeWebRtcPlayEndpoint, SerdeWebRtcPublishEndpoint}, + pipeline::Pipeline, + Element, TryFromElementError, +}; + /// Newtype for [`Element::Member`] variant. #[allow(clippy::module_name_repetitions)] #[derive(Clone, Debug)] @@ -104,7 +101,8 @@ impl MemberSpec for SerdeMemberSpec { } fn id(&self) -> &MemberId { - self.id() + // TODO: maybe delete this func??? + unimplemented!() } fn get_webrtc_play_by_id( diff --git a/src/api/control/serde/room.rs b/src/api/control/serde/room.rs index 57cea412d..6c2d9e115 100644 --- a/src/api/control/serde/room.rs +++ b/src/api/control/serde/room.rs @@ -3,18 +3,16 @@ use std::convert::TryFrom; use hashbrown::HashMap; -use macro_attr::*; -use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; -use serde::Deserialize; -use super::{ - member::SerdeMemberSpec, pipeline::Pipeline, Element, TryFromElementError, -}; use crate::api::control::model::{ - member::MemberSpec, room::RoomSpec, MemberId, + member::MemberSpec, + room::{Id, RoomSpec}, + MemberId, }; -use crate::api::control::model::room::Id; +use super::{ + member::SerdeMemberSpec, pipeline::Pipeline, Element, TryFromElementError, +}; /// [`crate::signalling::room::Room`] specification. /// Newtype for [`Element::Room`] diff --git a/src/api/grpc/server.rs b/src/api/grpc/server.rs index d335d5aca..e9cf1ce59 100644 --- a/src/api/grpc/server.rs +++ b/src/api/grpc/server.rs @@ -25,9 +25,9 @@ struct ControlApiService { impl ControlApi for ControlApiService { fn create( &mut self, - ctx: RpcContext, - req: CreateRequest, - sink: UnarySink, + _ctx: RpcContext, + _req: CreateRequest, + _sink: UnarySink, ) { self.room_repository .remove(&RoomId("pub-sub-video-call".to_string())); @@ -36,27 +36,27 @@ impl ControlApi for ControlApiService { fn apply( &mut self, - ctx: RpcContext, - req: ApplyRequest, - sink: UnarySink, + _ctx: RpcContext, + _req: ApplyRequest, + _sink: UnarySink, ) { unimplemented!() } fn delete( &mut self, - ctx: RpcContext, - req: IdRequest, - sink: UnarySink, + _ctx: RpcContext, + _req: IdRequest, + _sink: UnarySink, ) { unimplemented!() } fn get( &mut self, - ctx: RpcContext, - req: IdRequest, - sink: UnarySink, + _ctx: RpcContext, + _req: IdRequest, + _sink: UnarySink, ) { unimplemented!() } @@ -70,14 +70,14 @@ pub struct GrpcServer { impl Actor for GrpcServer { type Context = Context; - fn started(&mut self, ctx: &mut Self::Context) { + fn started(&mut self, _ctx: &mut Self::Context) { debug!("Start gRPC server."); self.server.start(); } - fn stopped(&mut self, ctx: &mut Self::Context) { + fn stopped(&mut self, _ctx: &mut Self::Context) { debug!("Shutdown gRPC."); - self.server.shutdown().wait(); + self.server.shutdown().wait().unwrap(); } } @@ -87,7 +87,7 @@ pub fn run(room_repo: RoomsRepository) -> Addr { }); let env = Arc::new(Environment::new(1)); - let mut server = ServerBuilder::new(env) + let server = ServerBuilder::new(env) .register_service(service) .bind("127.0.0.1", 50_051) .build() diff --git a/src/main.rs b/src/main.rs index 4f4ccfa0b..980035565 100644 --- a/src/main.rs +++ b/src/main.rs @@ -28,7 +28,7 @@ fn main() -> Result<(), Error> { ); let room_repo = RoomsRepository::new(rooms); server::run(room_repo.clone(), config); - let addr = grpc::server::run(room_repo); + let _addr = grpc::server::run(room_repo); let _ = sys.run(); diff --git a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs index fc2ac0600..166f40c34 100644 --- a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs @@ -5,9 +5,6 @@ use std::{ rc::{Rc, Weak}, }; -use macro_attr::*; -use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; - use crate::{ api::control::serde::endpoint::SerdeSrcUri, media::PeerId, signalling::elements::Member, diff --git a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs index 733e2db24..9911de5eb 100644 --- a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs @@ -6,8 +6,6 @@ use std::{ }; use hashbrown::HashSet; -use macro_attr::*; -use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; use crate::{ api::control::serde::endpoint::P2pMode, media::PeerId, diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index 7c42fdef6..b506184d2 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -1,6 +1,6 @@ //! [`Member`] is member of [`Room`] with [`RpcConnection`]. -use std::{cell::RefCell, convert::TryFrom as _, rc::Rc}; +use std::{cell::RefCell, rc::Rc}; use failure::Fail; use hashbrown::HashMap; @@ -9,7 +9,7 @@ use medea_client_api_proto::IceServer; use crate::{ api::control::{ model::MemberId, - serde::{SerdeMemberSpec, SerdeRoomSpec, TryFromElementError}, + serde::{SerdeRoomSpec, TryFromElementError}, }, log::prelude::*, media::{IceUser, PeerId}, @@ -133,11 +133,12 @@ impl Member { )), Ok, )?; - - let publisher_endpoint = publisher_spec.get_webrtc_publish_by_id(&spec_play_endpoint.src().endpoint_id) + // TODO: Maybe use EndpointId in MembersLoadError::EndpointNotFound? + let publisher_endpoint = publisher_spec + .get_webrtc_publish_by_id(&spec_play_endpoint.src().endpoint_id) .map_or( Err(MembersLoadError::EndpointNotFound( - spec_play_endpoint.src().endpoint_id.clone().0, // TODO: tmp + spec_play_endpoint.src().endpoint_id.clone().0, )), Ok, )?; From 0e4c449889398e93cd6a99d942c521725d306752 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 4 Jul 2019 17:52:50 +0300 Subject: [PATCH 245/735] Add SrcUri protobuf implementation --- .../control/protobuf/webrtc_play_endpoint.rs | 52 ++++++++++++++++--- 1 file changed, 46 insertions(+), 6 deletions(-) diff --git a/src/api/control/protobuf/webrtc_play_endpoint.rs b/src/api/control/protobuf/webrtc_play_endpoint.rs index 0e9556d03..d873efdcf 100644 --- a/src/api/control/protobuf/webrtc_play_endpoint.rs +++ b/src/api/control/protobuf/webrtc_play_endpoint.rs @@ -14,15 +14,55 @@ pub struct GrpcWebRtcPlayEndpoint(pub WebRtcPlayEndpointDto); impl WebRtcPlayEndpoint for GrpcWebRtcPlayEndpoint { fn src(&self) -> SerdeSrcUri { if self.0.has_src() { - let _src = self.0.get_src(); - SerdeSrcUri { - endpoint_id: WebRtcPublishId("".to_string()), - member_id: MemberId("".to_string()), - room_id: RoomId("".to_string()), - } + let src = self.0.get_src(); + parse_src_uri(src) } else { // TODO: do something with it. unimplemented!("TODO") } } } + +// TODO: use already done implementation from serde DTO +// share this with serde deseralizer. +fn parse_src_uri(value: &str) -> SerdeSrcUri { + let protocol_name: String = value.chars().take(8).collect(); + if protocol_name != "local://" { + panic!() + } + + let uri_body = value.chars().skip(8).collect::(); + let mut uri_body_splitted: Vec<&str> = + uri_body.rsplit('/').collect(); + let uri_body_splitted_len = uri_body_splitted.len(); + if uri_body_splitted_len != 3 { + let error_msg = if uri_body_splitted_len == 0 { + "room_id, member_id, endpoint_id" + } else if uri_body_splitted_len == 1 { + "member_id, endpoint_id" + } else if uri_body_splitted_len == 2 { + "endpoint_id" + } else { + panic!() + }; + panic!() + } + let room_id = uri_body_splitted.pop().unwrap().to_string(); + if room_id.is_empty() { + panic!() + } + let member_id = uri_body_splitted.pop().unwrap().to_string(); + if member_id.is_empty() { + panic!() + } + let endpoint_id = uri_body_splitted.pop().unwrap().to_string(); + if endpoint_id.is_empty() { + panic!() + } + + SerdeSrcUri { + room_id: RoomId(room_id), + member_id: MemberId(member_id), + endpoint_id: WebRtcPublishId(endpoint_id), + } +} From c6d96be0594c5f76c8b68cf01417c325736de84b Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 4 Jul 2019 18:01:40 +0300 Subject: [PATCH 246/735] Implement all protobuf parsing --- src/api/control/model/member.rs | 2 -- src/api/control/model/room.rs | 4 ++-- src/api/control/protobuf/member.rs | 5 ---- src/api/control/protobuf/room.rs | 24 +++++++++++++++---- .../control/protobuf/webrtc_play_endpoint.rs | 5 ++-- src/api/control/serde/member.rs | 6 ----- src/api/control/serde/room.rs | 10 ++++---- 7 files changed, 30 insertions(+), 26 deletions(-) diff --git a/src/api/control/model/member.rs b/src/api/control/model/member.rs index 37a2c2e24..19d49ffbf 100644 --- a/src/api/control/model/member.rs +++ b/src/api/control/model/member.rs @@ -32,8 +32,6 @@ pub trait MemberSpec { fn credentials(&self) -> &String; - fn id(&self) -> &MemberId; - fn get_webrtc_play_by_id( &self, id: &WebRtcPlayId, diff --git a/src/api/control/model/room.rs b/src/api/control/model/room.rs index 0cb13b89e..03e0a9610 100644 --- a/src/api/control/model/room.rs +++ b/src/api/control/model/room.rs @@ -24,7 +24,7 @@ pub use Id as RoomId; pub trait RoomSpec { fn members(&self) -> HashMap>; - fn id(&self) -> &Id; + fn id(&self) -> Id; - fn get_member_by_id(&self, id: &MemberId) -> Option>; + fn get_member_by_id(&self, id: &MemberId) -> Option>; } diff --git a/src/api/control/protobuf/member.rs b/src/api/control/protobuf/member.rs index bcd543523..4451a7bbb 100644 --- a/src/api/control/protobuf/member.rs +++ b/src/api/control/protobuf/member.rs @@ -6,7 +6,6 @@ use crate::{ model::{ endpoint::webrtc::{WebRtcPlayEndpoint, WebRtcPublishEndpoint}, member::MemberSpec, - MemberId, }, protobuf::{ webrtc_play_endpoint::GrpcWebRtcPlayEndpoint, @@ -68,10 +67,6 @@ impl MemberSpec for GrpcMember { unimplemented!() } - fn id(&self) -> &MemberId { - unimplemented!() - } - fn get_webrtc_play_by_id( &self, id: &WebRtcPlayId, diff --git a/src/api/control/protobuf/room.rs b/src/api/control/protobuf/room.rs index a06eb44ea..7cb196acb 100644 --- a/src/api/control/protobuf/room.rs +++ b/src/api/control/protobuf/room.rs @@ -34,11 +34,27 @@ impl RoomSpec for CreateRequestSpec { } } - fn id(&self) -> &RoomId { - unimplemented!() + fn id(&self) -> RoomId { + if self.0.has_id() { + RoomId(self.0.get_id().to_string()) + } else { + panic!() + } } - fn get_member_by_id(&self, _id: &MemberId) -> Option> { - unimplemented!() + fn get_member_by_id(&self, id: &MemberId) -> Option> { + if self.0.has_room() { + let room = self.0.get_room(); + let element = room.pipeline.get(&id.0)?; + if element.has_member() { + let member = element.get_member().clone(); + let member = GrpcMember(member); + Some(Box::new(member) as Box) + } else { + None + } + } else { + panic!() + } } } diff --git a/src/api/control/protobuf/webrtc_play_endpoint.rs b/src/api/control/protobuf/webrtc_play_endpoint.rs index d873efdcf..011924b14 100644 --- a/src/api/control/protobuf/webrtc_play_endpoint.rs +++ b/src/api/control/protobuf/webrtc_play_endpoint.rs @@ -32,11 +32,10 @@ fn parse_src_uri(value: &str) -> SerdeSrcUri { } let uri_body = value.chars().skip(8).collect::(); - let mut uri_body_splitted: Vec<&str> = - uri_body.rsplit('/').collect(); + let mut uri_body_splitted: Vec<&str> = uri_body.rsplit('/').collect(); let uri_body_splitted_len = uri_body_splitted.len(); if uri_body_splitted_len != 3 { - let error_msg = if uri_body_splitted_len == 0 { + let _error_msg = if uri_body_splitted_len == 0 { "room_id, member_id, endpoint_id" } else if uri_body_splitted_len == 1 { "member_id, endpoint_id" diff --git a/src/api/control/serde/member.rs b/src/api/control/serde/member.rs index f8acd0000..ab8bbc00e 100644 --- a/src/api/control/serde/member.rs +++ b/src/api/control/serde/member.rs @@ -11,7 +11,6 @@ use crate::api::control::{ WebRtcPublishId, }, member::MemberSpec, - MemberId, }, serde::Endpoint, }; @@ -100,11 +99,6 @@ impl MemberSpec for SerdeMemberSpec { &self.credentials } - fn id(&self) -> &MemberId { - // TODO: maybe delete this func??? - unimplemented!() - } - fn get_webrtc_play_by_id( &self, id: &WebRtcPlayId, diff --git a/src/api/control/serde/room.rs b/src/api/control/serde/room.rs index 6c2d9e115..9838b7c23 100644 --- a/src/api/control/serde/room.rs +++ b/src/api/control/serde/room.rs @@ -69,12 +69,14 @@ impl RoomSpec for ParsedSerdeRoomSpec { .collect() } - fn id(&self) -> &Id { - &self.id + fn id(&self) -> Id { + self.id.clone() } - fn get_member_by_id(&self, id: &MemberId) -> Option> { - self.members.get(id).map(|m| Box::new(m as &MemberSpec)) + fn get_member_by_id(&self, id: &MemberId) -> Option> { + self.members + .get(id) + .map(|m| Box::new(m.clone()) as Box) } } From e91a583e20fcaee9816a9d8a94b87b83515d1af6 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 4 Jul 2019 18:11:35 +0300 Subject: [PATCH 247/735] Some setup for dynamic creating room --- src/lib.rs | 6 +++++- src/signalling/elements/member.rs | 10 +++++----- src/signalling/participants.rs | 3 ++- src/signalling/room.rs | 3 ++- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 1a6d4587e..5c3504a45 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -19,6 +19,8 @@ use crate::{ signalling::{room::RoomError, Room}, turn::service, }; +use crate::api::control::serde::room::ParsedSerdeRoomSpec; +use crate::api::control::model::room::RoomSpec; /// Errors which can happen while server starting. #[derive(Debug, Fail)] @@ -82,7 +84,9 @@ pub fn start_static_rooms( let room_id = spec.id().clone(); let rpc_reconnect_timeout = config.rpc.reconnect_timeout; let room = Room::start_in_arbiter(&arbiter, move |_| { - Room::new(&spec, rpc_reconnect_timeout, turn_auth_service) + let parsed_spec = ParsedSerdeRoomSpec::new(&spec).unwrap(); + let parsed_spec = Box::new(&parsed_spec as &RoomSpec); + Room::new(&parsed_spec, rpc_reconnect_timeout, turn_auth_service) .unwrap() }); rooms.insert(room_id, room); diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index b506184d2..af260313f 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -84,7 +84,7 @@ impl Member { /// Load all srcs and sinks of this [`Member`]. fn load( &self, - room_spec: Box<&dyn RoomSpec>, + room_spec: &Box<&dyn RoomSpec>, store: &HashMap>, ) -> Result<(), MembersLoadError> { // let this_member_spec = SerdeMemberSpec::try_from( @@ -310,9 +310,9 @@ impl Member { /// /// Returns store of all [`Member`]s loaded from [`RoomSpec`]. pub fn parse_members( - room_spec: &SerdeRoomSpec, + room_spec: &Box<&dyn RoomSpec>, ) -> Result>, MembersLoadError> { - let members_spec = room_spec.members()?; + let members_spec = room_spec.members(); let mut members = HashMap::new(); for (id, member) in &members_spec { @@ -322,10 +322,10 @@ pub fn parse_members( ); } - let spec = ParsedSerdeRoomSpec::new(&room_spec)?; +// let spec = ParsedSerdeRoomSpec::new(&room_spec)?; for (_, member) in &members { - member.load(Box::new(&spec as &RoomSpec), &members)?; + member.load(room_spec, &members)?; } debug!( diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 9bc928db3..ddd53f562 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -40,6 +40,7 @@ use crate::{ }, turn::{TurnAuthService, TurnServiceErr, UnreachablePolicy}, }; +use crate::api::control::model::room::RoomSpec; #[derive(Fail, Debug)] #[allow(clippy::module_name_repetitions)] @@ -99,7 +100,7 @@ pub struct ParticipantService { impl ParticipantService { /// Create new [`ParticipantService`] from [`RoomSpec`]. pub fn new( - room_spec: &SerdeRoomSpec, + room_spec: &Box<&dyn RoomSpec>, reconnect_timeout: Duration, turn: Box, ) -> Result { diff --git a/src/signalling/room.rs b/src/signalling/room.rs index acb49d65e..5bd8a6afb 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -38,6 +38,7 @@ use crate::{ }, turn::TurnAuthService, }; +use crate::api::control::model::room::RoomSpec; /// Ergonomic type alias for using [`ActorFuture`] for [`Room`]. pub type ActFuture = @@ -106,7 +107,7 @@ impl Room { /// Returns [`RoomError::BadRoomSpec`] when error while [`Element`] /// transformation happens. pub fn new( - room_spec: &SerdeRoomSpec, + room_spec: &Box<&dyn RoomSpec>, reconnect_timeout: Duration, turn: Box, ) -> Result { From b381bd3d86dd4bff79da8af3bdb0dd72af355661 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 4 Jul 2019 18:20:59 +0300 Subject: [PATCH 248/735] Fix tests --- src/api/client/rpc_connection.rs | 2 +- src/api/client/server.rs | 12 +++++++++--- src/api/control/serde/endpoint.rs | 14 ++++++++------ src/lib.rs | 15 ++++++++++----- src/signalling/elements/member.rs | 7 +++++-- src/signalling/participants.rs | 3 +-- src/signalling/room.rs | 3 +-- 7 files changed, 35 insertions(+), 21 deletions(-) diff --git a/src/api/client/rpc_connection.rs b/src/api/client/rpc_connection.rs index 3ce1115de..7c185732f 100644 --- a/src/api/client/rpc_connection.rs +++ b/src/api/client/rpc_connection.rs @@ -107,7 +107,7 @@ pub mod test { ClosedReason, CommandMessage, EventMessage, RpcConnection, RpcConnectionClosed, RpcConnectionEstablished, }, - control::MemberId, + control::model::MemberId, }, signalling::Room, }; diff --git a/src/api/client/server.rs b/src/api/client/server.rs index 4389422f2..bc17af458 100644 --- a/src/api/client/server.rs +++ b/src/api/client/server.rs @@ -126,15 +126,21 @@ mod test { }; use super::*; + use crate::api::control::{ + model::room::RoomSpec, serde::room::ParsedSerdeRoomSpec, + }; /// Creates [`RoomsRepository`] for tests filled with a single [`Room`]. fn room(conf: Rpc) -> RoomsRepository { - let room_spec = - control::load_from_yaml_file("tests/specs/pub_sub_video_call.yml") - .unwrap(); + let room_spec = control::serde::load_from_yaml_file( + "tests/specs/pub_sub_video_call.yml", + ) + .unwrap(); let room_id = room_spec.id.clone(); let client_room = Room::start_in_arbiter(&Arbiter::new(), move |_| { + let room_spec = ParsedSerdeRoomSpec::new(&room_spec).unwrap(); + let room_spec = Box::new(&room_spec as &RoomSpec); let client_room = Room::new( &room_spec, conf.reconnect_timeout, diff --git a/src/api/control/serde/endpoint.rs b/src/api/control/serde/endpoint.rs index e84a2389a..1c2b77e70 100644 --- a/src/api/control/serde/endpoint.rs +++ b/src/api/control/serde/endpoint.rs @@ -184,6 +184,11 @@ mod src_uri_deserialization_tests { src: SerdeSrcUri, } + #[inline] + fn id>(s: &str) -> T { + T::from(s.to_string()) + } + #[test] fn deserialize() { let valid_json_uri = @@ -191,12 +196,9 @@ mod src_uri_deserialization_tests { let local_uri: SrcUriTest = serde_json::from_str(valid_json_uri).unwrap(); - assert_eq!( - local_uri.src.member_id, - MemberId(String::from("member_id")) - ); - assert_eq!(local_uri.src.room_id, String::from("room_id")); - assert_eq!(local_uri.src.endpoint_id, String::from("endpoint_id")); + assert_eq!(local_uri.src.member_id, id("member_id")); + assert_eq!(local_uri.src.room_id, id("room_id")); + assert_eq!(local_uri.src.endpoint_id, id("endpoint_id")); } #[test] diff --git a/src/lib.rs b/src/lib.rs index 5c3504a45..f78046bd9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -14,13 +14,14 @@ use failure::Fail; use hashbrown::HashMap; use crate::{ - api::control::{model::RoomId, serde::load_static_specs_from_dir}, + api::control::{ + model::{room::RoomSpec, RoomId}, + serde::{load_static_specs_from_dir, room::ParsedSerdeRoomSpec}, + }, conf::Conf, signalling::{room::RoomError, Room}, turn::service, }; -use crate::api::control::serde::room::ParsedSerdeRoomSpec; -use crate::api::control::model::room::RoomSpec; /// Errors which can happen while server starting. #[derive(Debug, Fail)] @@ -86,8 +87,12 @@ pub fn start_static_rooms( let room = Room::start_in_arbiter(&arbiter, move |_| { let parsed_spec = ParsedSerdeRoomSpec::new(&spec).unwrap(); let parsed_spec = Box::new(&parsed_spec as &RoomSpec); - Room::new(&parsed_spec, rpc_reconnect_timeout, turn_auth_service) - .unwrap() + Room::new( + &parsed_spec, + rpc_reconnect_timeout, + turn_auth_service, + ) + .unwrap() }); rooms.insert(room_id, room); } diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index af260313f..71119d1c4 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -322,7 +322,7 @@ pub fn parse_members( ); } -// let spec = ParsedSerdeRoomSpec::new(&room_spec)?; + // let spec = ParsedSerdeRoomSpec::new(&room_spec)?; for (_, member) in &members { member.load(room_spec, &members)?; @@ -356,7 +356,8 @@ pub fn parse_members( mod tests { use std::rc::Rc; - use crate::api::control::serde::{Element, MemberId}; + use crate::api::control::{model::MemberId, serde::Element}; + use std::convert::TryFrom as _; use super::*; @@ -406,6 +407,8 @@ mod tests { fn get_test_store() -> HashMap> { let room_element: Element = serde_yaml::from_str(TEST_SPEC).unwrap(); let room_spec = SerdeRoomSpec::try_from(&room_element).unwrap(); + let room_spec = ParsedSerdeRoomSpec::new(&room_spec).unwrap(); + let room_spec = Box::new(&room_spec as &RoomSpec); parse_members(&room_spec).unwrap() } diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index ddd53f562..7d5557cc2 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -27,7 +27,7 @@ use crate::{ RpcConnectionClosed, }, control::{ - model::{MemberId, RoomId}, + model::{room::RoomSpec, MemberId, RoomId}, serde::SerdeRoomSpec, }, }, @@ -40,7 +40,6 @@ use crate::{ }, turn::{TurnAuthService, TurnServiceErr, UnreachablePolicy}, }; -use crate::api::control::model::room::RoomSpec; #[derive(Fail, Debug)] #[allow(clippy::module_name_repetitions)] diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 5bd8a6afb..40ee93b4a 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -19,7 +19,7 @@ use crate::{ RpcConnectionClosed, RpcConnectionEstablished, }, control::{ - model::{MemberId, RoomId}, + model::{room::RoomSpec, MemberId, RoomId}, serde::{SerdeRoomSpec, TryFromElementError}, }, }, @@ -38,7 +38,6 @@ use crate::{ }, turn::TurnAuthService, }; -use crate::api::control::model::room::RoomSpec; /// Ergonomic type alias for using [`ActorFuture`] for [`Room`]. pub type ActFuture = From e0d50de18de0632f7dd457d1be4e6cd3cd75a64b Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 4 Jul 2019 18:35:37 +0300 Subject: [PATCH 249/735] Add dynamic creating room --- src/api/control/protobuf/room.rs | 2 +- src/api/grpc/server.rs | 26 +++++++++++++++++++++++--- src/signalling/room_repo.rs | 4 ++++ 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/api/control/protobuf/room.rs b/src/api/control/protobuf/room.rs index 7cb196acb..b3260f2ce 100644 --- a/src/api/control/protobuf/room.rs +++ b/src/api/control/protobuf/room.rs @@ -8,7 +8,7 @@ use crate::api::{ use super::member::GrpcMember; #[allow(dead_code)] -struct CreateRequestSpec(CreateRequest); +pub struct CreateRequestSpec(pub CreateRequest); impl RoomSpec for CreateRequestSpec { fn members(&self) -> HashMap> { diff --git a/src/api/grpc/server.rs b/src/api/grpc/server.rs index e9cf1ce59..2e788303a 100644 --- a/src/api/grpc/server.rs +++ b/src/api/grpc/server.rs @@ -16,6 +16,12 @@ use crate::{ }; use super::protos::control_grpc::{create_control_api, ControlApi}; +use crate::{ + api::control::{model::room::RoomSpec, protobuf::room::CreateRequestSpec}, + conf::Conf, + signalling::Room, +}; +use std::time::Duration; #[derive(Clone)] struct ControlApiService { @@ -26,11 +32,25 @@ impl ControlApi for ControlApiService { fn create( &mut self, _ctx: RpcContext, - _req: CreateRequest, + req: CreateRequest, _sink: UnarySink, ) { - self.room_repository - .remove(&RoomId("pub-sub-video-call".to_string())); + // TODO + let room_id = RoomId(req.get_id().to_string()); + + let room = Room::start_in_arbiter(&Arbiter::new(), |_| { + let room_spec = CreateRequestSpec(req); + let room_spec = Box::new(&room_spec as &RoomSpec); + + let turn_auth_service = + crate::turn::service::new_turn_auth_service(&Conf::default()) + .expect("Unable to start turn service"); + Room::new(&room_spec, Duration::from_secs(10), turn_auth_service) + .unwrap() + }); + + self.room_repository.add(room_id, room); + debug!("{:?}", self.room_repository); } diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs index e1c66c4c4..526b4700a 100644 --- a/src/signalling/room_repo.rs +++ b/src/signalling/room_repo.rs @@ -32,4 +32,8 @@ impl RoomsRepository { pub fn remove(&self, id: &RoomId) { self.rooms.lock().unwrap().remove(id); } + + pub fn add(&self, id: RoomId, room: Addr) { + self.rooms.lock().unwrap().insert(id, room); + } } From 96d7f0624ef6cf400c5319a08ee281540638827f Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 4 Jul 2019 18:49:10 +0300 Subject: [PATCH 250/735] Fix warns --- src/signalling/elements/member.rs | 17 +++++++---------- src/signalling/participants.rs | 5 +---- src/signalling/room.rs | 2 +- 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index 71119d1c4..778458cda 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -7,10 +7,7 @@ use hashbrown::HashMap; use medea_client_api_proto::IceServer; use crate::{ - api::control::{ - model::MemberId, - serde::{SerdeRoomSpec, TryFromElementError}, - }, + api::control::{model::MemberId, serde::TryFromElementError}, log::prelude::*, media::{IceUser, PeerId}, }; @@ -18,9 +15,7 @@ use crate::{ use super::endpoints::webrtc::{ WebRtcPlayEndpoint, WebRtcPlayId, WebRtcPublishEndpoint, WebRtcPublishId, }; -use crate::api::control::{ - model::room::RoomSpec, serde::room::ParsedSerdeRoomSpec, -}; +use crate::api::control::model::room::RoomSpec; /// Errors which may occur while loading [`Member`]s from [`RoomSpec`]. #[derive(Debug, Fail)] @@ -354,10 +349,12 @@ pub fn parse_members( #[cfg(test)] mod tests { - use std::rc::Rc; + use std::{convert::TryFrom as _, rc::Rc}; - use crate::api::control::{model::MemberId, serde::Element}; - use std::convert::TryFrom as _; + use crate::api::control::{ + model::MemberId, + serde::{room::ParsedSerdeRoomSpec, Element, SerdeRoomSpec}, + }; use super::*; diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 7d5557cc2..9bf129b8a 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -26,10 +26,7 @@ use crate::{ AuthorizationError, ClosedReason, EventMessage, RpcConnection, RpcConnectionClosed, }, - control::{ - model::{room::RoomSpec, MemberId, RoomId}, - serde::SerdeRoomSpec, - }, + control::model::{room::RoomSpec, MemberId, RoomId}, }, log::prelude::*, media::IceUser, diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 40ee93b4a..f61fe32e7 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -20,7 +20,7 @@ use crate::{ }, control::{ model::{room::RoomSpec, MemberId, RoomId}, - serde::{SerdeRoomSpec, TryFromElementError}, + serde::TryFromElementError, }, }, log::prelude::*, From 375730c5bae3a899c4c126fe515fea66746d049e Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 4 Jul 2019 18:58:39 +0300 Subject: [PATCH 251/735] Add credentials for member to protobuf --- src/api/control/model/member.rs | 2 +- src/api/control/protobuf/member.rs | 10 ++- src/api/control/serde/member.rs | 2 +- src/api/grpc/protos/control.proto | 3 +- src/api/grpc/protos/control.rs | 116 +++++++++++++++++++++-------- 5 files changed, 97 insertions(+), 36 deletions(-) diff --git a/src/api/control/model/member.rs b/src/api/control/model/member.rs index 19d49ffbf..bfff0fa0a 100644 --- a/src/api/control/model/member.rs +++ b/src/api/control/model/member.rs @@ -30,7 +30,7 @@ pub trait MemberSpec { &self, ) -> HashMap>; - fn credentials(&self) -> &String; + fn credentials(&self) -> &str; fn get_webrtc_play_by_id( &self, diff --git a/src/api/control/protobuf/member.rs b/src/api/control/protobuf/member.rs index 4451a7bbb..575ffa724 100644 --- a/src/api/control/protobuf/member.rs +++ b/src/api/control/protobuf/member.rs @@ -62,9 +62,13 @@ impl MemberSpec for GrpcMember { .collect() } - fn credentials(&self) -> &String { - // TODO: deal with it - unimplemented!() + fn credentials(&self) -> &str { + if self.0.has_credentials() { + self.0.get_credentials() + } else { + // TODO: deal with it + unimplemented!() + } } fn get_webrtc_play_by_id( diff --git a/src/api/control/serde/member.rs b/src/api/control/serde/member.rs index ab8bbc00e..3e7a09545 100644 --- a/src/api/control/serde/member.rs +++ b/src/api/control/serde/member.rs @@ -95,7 +95,7 @@ impl MemberSpec for SerdeMemberSpec { .collect() } - fn credentials(&self) -> &String { + fn credentials(&self) -> &str { &self.credentials } diff --git a/src/api/grpc/protos/control.proto b/src/api/grpc/protos/control.proto index fcc37451f..55d26d2d4 100644 --- a/src/api/grpc/protos/control.proto +++ b/src/api/grpc/protos/control.proto @@ -91,7 +91,8 @@ message Room { message Member { optional string on_join = 1; optional string on_leave = 2; - map pipeline = 3; + required string credentials = 3; + map pipeline = 4; message Element { oneof el { diff --git a/src/api/grpc/protos/control.rs b/src/api/grpc/protos/control.rs index c59804e01..e154cccfa 100644 --- a/src/api/grpc/protos/control.rs +++ b/src/api/grpc/protos/control.rs @@ -4091,6 +4091,7 @@ pub struct Member { // message fields on_join: ::protobuf::SingularField<::std::string::String>, on_leave: ::protobuf::SingularField<::std::string::String>, + credentials: ::protobuf::SingularField<::std::string::String>, pub pipeline: ::std::collections::HashMap<::std::string::String, Member_Element>, // special fields pub unknown_fields: ::protobuf::UnknownFields, @@ -4180,7 +4181,43 @@ impl Member { self.on_leave.take().unwrap_or_else(|| ::std::string::String::new()) } - // repeated .medea.Member.PipelineEntry pipeline = 3; + // required string credentials = 3; + + + pub fn get_credentials(&self) -> &str { + match self.credentials.as_ref() { + Some(v) => &v, + None => "", + } + } + pub fn clear_credentials(&mut self) { + self.credentials.clear(); + } + + pub fn has_credentials(&self) -> bool { + self.credentials.is_some() + } + + // Param is passed by value, moved + pub fn set_credentials(&mut self, v: ::std::string::String) { + self.credentials = ::protobuf::SingularField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_credentials(&mut self) -> &mut ::std::string::String { + if self.credentials.is_none() { + self.credentials.set_default(); + } + self.credentials.as_mut().unwrap() + } + + // Take field + pub fn take_credentials(&mut self) -> ::std::string::String { + self.credentials.take().unwrap_or_else(|| ::std::string::String::new()) + } + + // repeated .medea.Member.PipelineEntry pipeline = 4; pub fn get_pipeline(&self) -> &::std::collections::HashMap<::std::string::String, Member_Element> { @@ -4208,6 +4245,9 @@ impl Member { impl ::protobuf::Message for Member { fn is_initialized(&self) -> bool { + if self.credentials.is_none() { + return false; + } true } @@ -4222,6 +4262,9 @@ impl ::protobuf::Message for Member { ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.on_leave)?; }, 3 => { + ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.credentials)?; + }, + 4 => { ::protobuf::rt::read_map_into::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(wire_type, is, &mut self.pipeline)?; }, _ => { @@ -4242,7 +4285,10 @@ impl ::protobuf::Message for Member { if let Some(ref v) = self.on_leave.as_ref() { my_size += ::protobuf::rt::string_size(2, &v); } - my_size += ::protobuf::rt::compute_map_size::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(3, &self.pipeline); + if let Some(ref v) = self.credentials.as_ref() { + my_size += ::protobuf::rt::string_size(3, &v); + } + my_size += ::protobuf::rt::compute_map_size::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(4, &self.pipeline); my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); self.cached_size.set(my_size); my_size @@ -4255,7 +4301,10 @@ impl ::protobuf::Message for Member { if let Some(ref v) = self.on_leave.as_ref() { os.write_string(2, &v)?; } - ::protobuf::rt::write_map_with_cached_sizes::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(3, &self.pipeline, os)?; + if let Some(ref v) = self.credentials.as_ref() { + os.write_string(3, &v)?; + } + ::protobuf::rt::write_map_with_cached_sizes::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(4, &self.pipeline, os)?; os.write_unknown_fields(self.get_unknown_fields())?; ::std::result::Result::Ok(()) } @@ -4308,6 +4357,11 @@ impl ::protobuf::Message for Member { |m: &Member| { &m.on_leave }, |m: &mut Member| { &mut m.on_leave }, )); + fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "credentials", + |m: &Member| { &m.credentials }, + |m: &mut Member| { &mut m.credentials }, + )); fields.push(::protobuf::reflect::accessor::make_map_accessor::<_, ::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>( "pipeline", |m: &Member| { &m.pipeline }, @@ -4337,6 +4391,7 @@ impl ::protobuf::Clear for Member { fn clear(&mut self) { self.on_join.clear(); self.on_leave.clear(); + self.credentials.clear(); self.pipeline.clear(); self.unknown_fields.clear(); } @@ -6291,34 +6346,35 @@ static file_descriptor_proto_data: &'static [u8] = b"\ \x04\x20\x01(\x0b2\x0c.medea.RelayH\0R\x05relay\x12<\n\x0bwebrtc_play\ \x18\x05\x20\x01(\x0b2\x19.medea.WebRtcPlayEndpointH\0R\nwebrtcPlay\x12=\ \n\nwebrtc_pub\x18\x06\x20\x01(\x0b2\x1c.medea.WebRtcPublishEndpointH\0R\ - \twebrtcPubB\x04\n\x02el\"\xda\x03\n\x06Member\x12\x17\n\x07on_join\x18\ + \twebrtcPubB\x04\n\x02el\"\xfc\x03\n\x06Member\x12\x17\n\x07on_join\x18\ \x01\x20\x01(\tR\x06onJoin\x12\x19\n\x08on_leave\x18\x02\x20\x01(\tR\x07\ - onLeave\x127\n\x08pipeline\x18\x03\x20\x03(\x0b2\x1b.medea.Member.Pipeli\ - neEntryR\x08pipeline\x1aR\n\rPipelineEntry\x12\x10\n\x03key\x18\x01\x20\ - \x01(\tR\x03key\x12+\n\x05value\x18\x02\x20\x01(\x0b2\x15.medea.Member.E\ - lementR\x05value:\x028\x01\x1a\x8e\x02\n\x07Element\x12\x1e\n\x03hub\x18\ - \x01\x20\x01(\x0b2\n.medea.HubH\0R\x03hub\x12:\n\rfile_recorder\x18\x02\ - \x20\x01(\x0b2\x13.medea.FileRecorderH\0R\x0cfileRecorder\x12$\n\x05rela\ - y\x18\x03\x20\x01(\x0b2\x0c.medea.RelayH\0R\x05relay\x12<\n\x0bwebrtc_pl\ - ay\x18\x04\x20\x01(\x0b2\x19.medea.WebRtcPlayEndpointH\0R\nwebrtcPlay\ - \x12=\n\nwebrtc_pub\x18\x05\x20\x01(\x0b2\x1c.medea.WebRtcPublishEndpoin\ - tH\0R\twebrtcPubB\x04\n\x02el\"\xc7\x01\n\x15WebRtcPublishEndpoint\x129\ - \n\x03p2p\x18\x01\x20\x01(\x0e2\x20.medea.WebRtcPublishEndpoint.P2P:\x05\ - NEVERR\x03p2p\x12\x10\n\x03dst\x18\x02\x20\x01(\tR\x03dst\x12\x19\n\x08o\ - n_start\x18\x03\x20\x01(\tR\x07onStart\x12\x17\n\x07on_stop\x18\x04\x20\ - \x01(\tR\x06onStop\"-\n\x03P2P\x12\t\n\x05NEVER\x10\0\x12\x0f\n\x0bIF_PO\ - SSIBLE\x10\x01\x12\n\n\x06ALWAYS\x10\x02\"Z\n\x12WebRtcPlayEndpoint\x12\ - \x10\n\x03src\x18\x01\x20\x02(\tR\x03src\x12\x19\n\x08on_start\x18\x02\ - \x20\x01(\tR\x07onStart\x12\x17\n\x07on_stop\x18\x03\x20\x01(\tR\x06onSt\ - op\"\x05\n\x03Hub\"f\n\x0cFileRecorder\x12\x10\n\x03src\x18\x01\x20\x02(\ - \tR\x03src\x12\x10\n\x03dst\x18\x02\x20\x02(\tR\x03dst\x12\x19\n\x08on_s\ - tart\x18\x03\x20\x01(\tR\x07onStart\x12\x17\n\x07on_stop\x18\x04\x20\x01\ - (\tR\x06onStop\"+\n\x05Relay\x12\x10\n\x03src\x18\x01\x20\x02(\tR\x03src\ - \x12\x10\n\x03dst\x18\x02\x20\x01(\tR\x03dst2\xc6\x01\n\nControlApi\x12/\ - \n\x06Create\x12\x14.medea.CreateRequest\x1a\x0f.medea.Response\x12-\n\ - \x05Apply\x12\x13.medea.ApplyRequest\x1a\x0f.medea.Response\x12+\n\x06De\ - lete\x12\x10.medea.IdRequest\x1a\x0f.medea.Response\x12+\n\x03Get\x12\ - \x10.medea.IdRequest\x1a\x12.medea.GetResponse\ + onLeave\x12\x20\n\x0bcredentials\x18\x03\x20\x02(\tR\x0bcredentials\x127\ + \n\x08pipeline\x18\x04\x20\x03(\x0b2\x1b.medea.Member.PipelineEntryR\x08\ + pipeline\x1aR\n\rPipelineEntry\x12\x10\n\x03key\x18\x01\x20\x01(\tR\x03k\ + ey\x12+\n\x05value\x18\x02\x20\x01(\x0b2\x15.medea.Member.ElementR\x05va\ + lue:\x028\x01\x1a\x8e\x02\n\x07Element\x12\x1e\n\x03hub\x18\x01\x20\x01(\ + \x0b2\n.medea.HubH\0R\x03hub\x12:\n\rfile_recorder\x18\x02\x20\x01(\x0b2\ + \x13.medea.FileRecorderH\0R\x0cfileRecorder\x12$\n\x05relay\x18\x03\x20\ + \x01(\x0b2\x0c.medea.RelayH\0R\x05relay\x12<\n\x0bwebrtc_play\x18\x04\ + \x20\x01(\x0b2\x19.medea.WebRtcPlayEndpointH\0R\nwebrtcPlay\x12=\n\nwebr\ + tc_pub\x18\x05\x20\x01(\x0b2\x1c.medea.WebRtcPublishEndpointH\0R\twebrtc\ + PubB\x04\n\x02el\"\xc7\x01\n\x15WebRtcPublishEndpoint\x129\n\x03p2p\x18\ + \x01\x20\x01(\x0e2\x20.medea.WebRtcPublishEndpoint.P2P:\x05NEVERR\x03p2p\ + \x12\x10\n\x03dst\x18\x02\x20\x01(\tR\x03dst\x12\x19\n\x08on_start\x18\ + \x03\x20\x01(\tR\x07onStart\x12\x17\n\x07on_stop\x18\x04\x20\x01(\tR\x06\ + onStop\"-\n\x03P2P\x12\t\n\x05NEVER\x10\0\x12\x0f\n\x0bIF_POSSIBLE\x10\ + \x01\x12\n\n\x06ALWAYS\x10\x02\"Z\n\x12WebRtcPlayEndpoint\x12\x10\n\x03s\ + rc\x18\x01\x20\x02(\tR\x03src\x12\x19\n\x08on_start\x18\x02\x20\x01(\tR\ + \x07onStart\x12\x17\n\x07on_stop\x18\x03\x20\x01(\tR\x06onStop\"\x05\n\ + \x03Hub\"f\n\x0cFileRecorder\x12\x10\n\x03src\x18\x01\x20\x02(\tR\x03src\ + \x12\x10\n\x03dst\x18\x02\x20\x02(\tR\x03dst\x12\x19\n\x08on_start\x18\ + \x03\x20\x01(\tR\x07onStart\x12\x17\n\x07on_stop\x18\x04\x20\x01(\tR\x06\ + onStop\"+\n\x05Relay\x12\x10\n\x03src\x18\x01\x20\x02(\tR\x03src\x12\x10\ + \n\x03dst\x18\x02\x20\x01(\tR\x03dst2\xc6\x01\n\nControlApi\x12/\n\x06Cr\ + eate\x12\x14.medea.CreateRequest\x1a\x0f.medea.Response\x12-\n\x05Apply\ + \x12\x13.medea.ApplyRequest\x1a\x0f.medea.Response\x12+\n\x06Delete\x12\ + \x10.medea.IdRequest\x1a\x0f.medea.Response\x12+\n\x03Get\x12\x10.medea.\ + IdRequest\x1a\x12.medea.GetResponse\ "; static mut file_descriptor_proto_lazy: ::protobuf::lazy::Lazy<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::lazy::Lazy { From 32f657757ed4e3e381fa674829f23cd0638dcff6 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 4 Jul 2019 19:13:46 +0300 Subject: [PATCH 252/735] Add gRPC configuration --- config.toml | 14 ++++++++++++++ src/api/grpc/server.rs | 13 ++++++++++--- src/conf/grpc.rs | 16 ++++++++++++++++ src/conf/mod.rs | 4 ++++ src/main.rs | 4 ++-- 5 files changed, 46 insertions(+), 5 deletions(-) create mode 100644 src/conf/grpc.rs diff --git a/config.toml b/config.toml index 0442888d4..a68752fad 100644 --- a/config.toml +++ b/config.toml @@ -80,3 +80,17 @@ static_specs_path = "dev/specs" # # Default: # connection_timeout = "5s" + + + + +[grpc] +# IP address to bind gRPC server to. +# +# Default: +# bind_ip = "0.0.0.0" + +# Port to bind gRPC server to. +# +# Default: +# bind_port = 50_051 diff --git a/src/api/grpc/server.rs b/src/api/grpc/server.rs index 2e788303a..e2cfbf90b 100644 --- a/src/api/grpc/server.rs +++ b/src/api/grpc/server.rs @@ -26,6 +26,7 @@ use std::time::Duration; #[derive(Clone)] struct ControlApiService { room_repository: RoomsRepository, + config: Conf, } impl ControlApi for ControlApiService { @@ -91,8 +92,8 @@ impl Actor for GrpcServer { type Context = Context; fn started(&mut self, _ctx: &mut Self::Context) { - debug!("Start gRPC server."); self.server.start(); + debug!("gRPC server started."); } fn stopped(&mut self, _ctx: &mut Self::Context) { @@ -101,15 +102,21 @@ impl Actor for GrpcServer { } } -pub fn run(room_repo: RoomsRepository) -> Addr { +pub fn run(room_repo: RoomsRepository, conf: Conf) -> Addr { + let bind_ip = conf.grpc.bind_ip.clone().to_string(); + let bind_port = conf.grpc.bind_port; + let service = create_control_api(ControlApiService { + config: conf, room_repository: room_repo, }); let env = Arc::new(Environment::new(1)); + info!("Starting gRPC server on {}:{}", bind_ip, bind_port); + let server = ServerBuilder::new(env) .register_service(service) - .bind("127.0.0.1", 50_051) + .bind(bind_ip, bind_port) .build() .unwrap(); diff --git a/src/conf/grpc.rs b/src/conf/grpc.rs new file mode 100644 index 000000000..6c5551c2a --- /dev/null +++ b/src/conf/grpc.rs @@ -0,0 +1,16 @@ +use std::net::{IpAddr, Ipv4Addr}; + +use serde::{Deserialize, Serialize}; +use smart_default::SmartDefault; + +#[derive(Clone, Debug, Deserialize, Serialize, SmartDefault)] +#[serde(default)] +pub struct Grpc { + /// IP address to bind gRPC server to. Defaults to `0.0.0.0`. + #[default(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)))] + pub bind_ip: IpAddr, + + /// Port to bind gRPC server to. Defaults to `8080`. + #[default(50_051)] + pub bind_port: u16, +} diff --git a/src/conf/mod.rs b/src/conf/mod.rs index 51c12230e..cda2908fa 100644 --- a/src/conf/mod.rs +++ b/src/conf/mod.rs @@ -1,5 +1,6 @@ //! Provides application configuration options. +pub mod grpc; pub mod rpc; pub mod server; pub mod turn; @@ -11,6 +12,7 @@ use failure::Error; use serde::{Deserialize, Serialize}; pub use self::{ + grpc::Grpc, rpc::Rpc, server::Server, turn::{Redis, Turn}, @@ -33,6 +35,8 @@ pub struct Conf { pub server: Server, /// TURN server settings. pub turn: Turn, + + pub grpc: Grpc, } impl Conf { diff --git a/src/main.rs b/src/main.rs index 980035565..bf9b914ee 100644 --- a/src/main.rs +++ b/src/main.rs @@ -27,8 +27,8 @@ fn main() -> Result<(), Error> { rooms.iter().map(|(id, _)| &id.0).collect::>() ); let room_repo = RoomsRepository::new(rooms); - server::run(room_repo.clone(), config); - let _addr = grpc::server::run(room_repo); + server::run(room_repo.clone(), config.clone()); + let _addr = grpc::server::run(room_repo, config); let _ = sys.run(); From 1a32960cae6266f44503a549c989644aa7991a60 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 4 Jul 2019 19:22:53 +0300 Subject: [PATCH 253/735] Add completion queue count config --- config.toml | 5 +++++ src/api/grpc/server.rs | 3 ++- src/conf/grpc.rs | 4 ++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/config.toml b/config.toml index a68752fad..f05c4129c 100644 --- a/config.toml +++ b/config.toml @@ -94,3 +94,8 @@ static_specs_path = "dev/specs" # # Default: # bind_port = 50_051 + +# Completion queue count of gRPC server. +# +# Default: +# completion_queue_count = 2 diff --git a/src/api/grpc/server.rs b/src/api/grpc/server.rs index e2cfbf90b..b1f2992d4 100644 --- a/src/api/grpc/server.rs +++ b/src/api/grpc/server.rs @@ -105,12 +105,13 @@ impl Actor for GrpcServer { pub fn run(room_repo: RoomsRepository, conf: Conf) -> Addr { let bind_ip = conf.grpc.bind_ip.clone().to_string(); let bind_port = conf.grpc.bind_port; + let cq_count = conf.grpc.completion_queue_count; let service = create_control_api(ControlApiService { config: conf, room_repository: room_repo, }); - let env = Arc::new(Environment::new(1)); + let env = Arc::new(Environment::new(cq_count)); info!("Starting gRPC server on {}:{}", bind_ip, bind_port); diff --git a/src/conf/grpc.rs b/src/conf/grpc.rs index 6c5551c2a..b745af41b 100644 --- a/src/conf/grpc.rs +++ b/src/conf/grpc.rs @@ -13,4 +13,8 @@ pub struct Grpc { /// Port to bind gRPC server to. Defaults to `8080`. #[default(50_051)] pub bind_port: u16, + + /// Completion queue count of gRPC server. Defaults to `2`. + #[default(2)] + pub completion_queue_count: usize, } From 76f2be4d7df1b2f5df3ed0ad1ba3f41d7fb49034 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 4 Jul 2019 19:33:13 +0300 Subject: [PATCH 254/735] Minor refactor --- src/api/client/server.rs | 4 +-- src/api/control/protobuf/member.rs | 18 ++++++------ src/api/control/protobuf/room.rs | 6 ++-- .../control/protobuf/webrtc_play_endpoint.rs | 6 ++-- .../protobuf/webrtc_publish_endpoint.rs | 6 ++-- src/api/control/serde/endpoint.rs | 20 ++++++------- src/api/control/serde/member.rs | 26 +++++++++-------- src/api/control/serde/mod.rs | 17 ++++++----- src/api/control/serde/room.rs | 29 +++++++++++-------- src/api/grpc/server.rs | 16 +++++----- src/lib.rs | 4 +-- src/signalling/elements/member.rs | 6 ++-- 12 files changed, 83 insertions(+), 75 deletions(-) diff --git a/src/api/client/server.rs b/src/api/client/server.rs index bc17af458..a583442d7 100644 --- a/src/api/client/server.rs +++ b/src/api/client/server.rs @@ -127,7 +127,7 @@ mod test { use super::*; use crate::api::control::{ - model::room::RoomSpec, serde::room::ParsedSerdeRoomSpec, + model::room::RoomSpec, serde::room::SerdeRoomSpecImpl, }; /// Creates [`RoomsRepository`] for tests filled with a single [`Room`]. @@ -139,7 +139,7 @@ mod test { let room_id = room_spec.id.clone(); let client_room = Room::start_in_arbiter(&Arbiter::new(), move |_| { - let room_spec = ParsedSerdeRoomSpec::new(&room_spec).unwrap(); + let room_spec = SerdeRoomSpecImpl::new(&room_spec).unwrap(); let room_spec = Box::new(&room_spec as &RoomSpec); let client_room = Room::new( &room_spec, diff --git a/src/api/control/protobuf/member.rs b/src/api/control/protobuf/member.rs index 575ffa724..01371a9ec 100644 --- a/src/api/control/protobuf/member.rs +++ b/src/api/control/protobuf/member.rs @@ -8,18 +8,18 @@ use crate::{ member::MemberSpec, }, protobuf::{ - webrtc_play_endpoint::GrpcWebRtcPlayEndpoint, - webrtc_publish_endpoint::GrpcWebRtcPublishEndpoint, + webrtc_play_endpoint::GrpcWebRtcPlayEndpointSpecImpl, + webrtc_publish_endpoint::GrpcWebRtcPublishEndpointSpecImpl, }, }, - grpc::protos::control::Member, + grpc::protos::control::Member as MemberProto, }, signalling::elements::endpoints::webrtc::{WebRtcPlayId, WebRtcPublishId}, }; -pub struct GrpcMember(pub Member); +pub struct GrpcMemberSpecImpl(pub MemberProto); -impl MemberSpec for GrpcMember { +impl MemberSpec for GrpcMemberSpecImpl { fn webrtc_play_endpoints( &self, ) -> HashMap> { @@ -31,7 +31,7 @@ impl MemberSpec for GrpcMember { let endpoint = element.get_webrtc_play().clone(); Some(( WebRtcPlayId(id.clone()), - Box::new(GrpcWebRtcPlayEndpoint(endpoint)) + Box::new(GrpcWebRtcPlayEndpointSpecImpl(endpoint)) as Box, )) } else { @@ -52,7 +52,7 @@ impl MemberSpec for GrpcMember { let endpoint = element.get_webrtc_pub().clone(); Some(( WebRtcPublishId(id.clone()), - Box::new(GrpcWebRtcPublishEndpoint(endpoint)) + Box::new(GrpcWebRtcPublishEndpointSpecImpl(endpoint)) as Box, )) } else { @@ -78,7 +78,7 @@ impl MemberSpec for GrpcMember { let element = self.0.pipeline.get(&id.0)?; if element.has_webrtc_play() { let play = element.get_webrtc_play().clone(); - let play = GrpcWebRtcPlayEndpoint(play); + let play = GrpcWebRtcPlayEndpointSpecImpl(play); Some(Box::new(play) as Box) } else { None @@ -92,7 +92,7 @@ impl MemberSpec for GrpcMember { let element = self.0.pipeline.get(&id.0)?; if element.has_webrtc_pub() { let publish = element.get_webrtc_pub().clone(); - let play = GrpcWebRtcPublishEndpoint(publish); + let play = GrpcWebRtcPublishEndpointSpecImpl(publish); Some(Box::new(play) as Box) } else { None diff --git a/src/api/control/protobuf/room.rs b/src/api/control/protobuf/room.rs index b3260f2ce..81b735db0 100644 --- a/src/api/control/protobuf/room.rs +++ b/src/api/control/protobuf/room.rs @@ -5,7 +5,7 @@ use crate::api::{ grpc::protos::control::CreateRequest, }; -use super::member::GrpcMember; +use super::member::GrpcMemberSpecImpl; #[allow(dead_code)] pub struct CreateRequestSpec(pub CreateRequest); @@ -22,7 +22,7 @@ impl RoomSpec for CreateRequestSpec { let member = e.get_member(); return Some(( MemberId(id.clone()), - Box::new(GrpcMember(member.clone())) + Box::new(GrpcMemberSpecImpl(member.clone())) as Box, )); } @@ -48,7 +48,7 @@ impl RoomSpec for CreateRequestSpec { let element = room.pipeline.get(&id.0)?; if element.has_member() { let member = element.get_member().clone(); - let member = GrpcMember(member); + let member = GrpcMemberSpecImpl(member); Some(Box::new(member) as Box) } else { None diff --git a/src/api/control/protobuf/webrtc_play_endpoint.rs b/src/api/control/protobuf/webrtc_play_endpoint.rs index 011924b14..56c73dd7c 100644 --- a/src/api/control/protobuf/webrtc_play_endpoint.rs +++ b/src/api/control/protobuf/webrtc_play_endpoint.rs @@ -4,14 +4,14 @@ use crate::{ model::{endpoint::webrtc::WebRtcPlayEndpoint, MemberId, RoomId}, serde::endpoint::SerdeSrcUri, }, - grpc::protos::control::WebRtcPlayEndpoint as WebRtcPlayEndpointDto, + grpc::protos::control::WebRtcPlayEndpoint as WebRtcPlayEndpointProto, }, signalling::elements::endpoints::webrtc::WebRtcPublishId, }; -pub struct GrpcWebRtcPlayEndpoint(pub WebRtcPlayEndpointDto); +pub struct GrpcWebRtcPlayEndpointSpecImpl(pub WebRtcPlayEndpointProto); -impl WebRtcPlayEndpoint for GrpcWebRtcPlayEndpoint { +impl WebRtcPlayEndpoint for GrpcWebRtcPlayEndpointSpecImpl { fn src(&self) -> SerdeSrcUri { if self.0.has_src() { let src = self.0.get_src(); diff --git a/src/api/control/protobuf/webrtc_publish_endpoint.rs b/src/api/control/protobuf/webrtc_publish_endpoint.rs index a79c4dc15..59bc3fc55 100644 --- a/src/api/control/protobuf/webrtc_publish_endpoint.rs +++ b/src/api/control/protobuf/webrtc_publish_endpoint.rs @@ -4,14 +4,14 @@ use crate::api::{ serde::endpoint::P2pMode, }, grpc::protos::control::{ - WebRtcPublishEndpoint as WebRtcPublishEndpointDto, + WebRtcPublishEndpoint as WebRtcPublishEndpointProto, WebRtcPublishEndpoint_P2P, }, }; -pub struct GrpcWebRtcPublishEndpoint(pub WebRtcPublishEndpointDto); +pub struct GrpcWebRtcPublishEndpointSpecImpl(pub WebRtcPublishEndpointProto); -impl WebRtcPublishEndpoint for GrpcWebRtcPublishEndpoint { +impl WebRtcPublishEndpoint for GrpcWebRtcPublishEndpointSpecImpl { fn p2p(&self) -> P2pMode { if self.0.has_p2p() { let p2p = self.0.get_p2p(); diff --git a/src/api/control/serde/endpoint.rs b/src/api/control/serde/endpoint.rs index 1c2b77e70..c01837642 100644 --- a/src/api/control/serde/endpoint.rs +++ b/src/api/control/serde/endpoint.rs @@ -16,21 +16,21 @@ use super::{Element, TryFromElementError}; /// [`Endpoint`] represents a media element that one or more media data streams /// flow through. #[derive(Debug)] -pub enum Endpoint { - WebRtcPublish(SerdeWebRtcPublishEndpoint), - WebRtcPlay(SerdeWebRtcPlayEndpoint), +pub enum SerdeEndpoint { + WebRtcPublish(SerdeWebRtcPublishEndpointImpl), + WebRtcPlay(SerdeWebRtcPlayEndpointImpl), } -impl TryFrom<&Element> for Endpoint { +impl TryFrom<&Element> for SerdeEndpoint { type Error = TryFromElementError; fn try_from(from: &Element) -> Result { match from { Element::WebRtcPlayEndpoint { spec } => { - Ok(Endpoint::WebRtcPlay(spec.clone())) + Ok(SerdeEndpoint::WebRtcPlay(spec.clone())) } Element::WebRtcPublishEndpoint { spec } => { - Ok(Endpoint::WebRtcPublish(spec.clone())) + Ok(SerdeEndpoint::WebRtcPublish(spec.clone())) } _ => Err(TryFromElementError::NotEndpoint), } @@ -50,12 +50,12 @@ pub enum P2pMode { /// WebRTC. #[allow(clippy::module_name_repetitions)] #[derive(Clone, Deserialize, Debug)] -pub struct SerdeWebRtcPublishEndpoint { +pub struct SerdeWebRtcPublishEndpointImpl { /// Peer-to-peer mode. pub p2p: P2pMode, } -impl WebRtcPublishEndpoint for SerdeWebRtcPublishEndpoint { +impl WebRtcPublishEndpoint for SerdeWebRtcPublishEndpointImpl { fn p2p(&self) -> P2pMode { self.p2p.clone() } @@ -64,12 +64,12 @@ impl WebRtcPublishEndpoint for SerdeWebRtcPublishEndpoint { /// Media element which is able to play media data for client via WebRTC. #[allow(clippy::module_name_repetitions)] #[derive(Clone, Deserialize, Debug)] -pub struct SerdeWebRtcPlayEndpoint { +pub struct SerdeWebRtcPlayEndpointImpl { /// Source URI in format `local://{room_id}/{member_id}/{endpoint_id}`. pub src: SerdeSrcUri, } -impl WebRtcPlayEndpoint for SerdeWebRtcPlayEndpoint { +impl WebRtcPlayEndpoint for SerdeWebRtcPlayEndpointImpl { fn src(&self) -> SrcUri { self.src.clone() } diff --git a/src/api/control/serde/member.rs b/src/api/control/serde/member.rs index 3e7a09545..0e149f7ea 100644 --- a/src/api/control/serde/member.rs +++ b/src/api/control/serde/member.rs @@ -12,11 +12,11 @@ use crate::api::control::{ }, member::MemberSpec, }, - serde::Endpoint, + serde::SerdeEndpoint, }; use super::{ - endpoint::{SerdeWebRtcPlayEndpoint, SerdeWebRtcPublishEndpoint}, + endpoint::{SerdeWebRtcPlayEndpointImpl, SerdeWebRtcPublishEndpointImpl}, pipeline::Pipeline, Element, TryFromElementError, }; @@ -24,7 +24,7 @@ use super::{ /// Newtype for [`Element::Member`] variant. #[allow(clippy::module_name_repetitions)] #[derive(Clone, Debug)] -pub struct SerdeMemberSpec { +pub struct SerdeMemberSpecImpl { /// Spec of this `Member`. pipeline: Pipeline, @@ -32,9 +32,11 @@ pub struct SerdeMemberSpec { credentials: String, } -impl SerdeMemberSpec { +impl SerdeMemberSpecImpl { /// Returns all [`WebRtcPlayEndpoint`]s of this [`MemberSpec`]. - pub fn play_endpoints(&self) -> HashMap<&String, &SerdeWebRtcPlayEndpoint> { + pub fn play_endpoints( + &self, + ) -> HashMap<&String, &SerdeWebRtcPlayEndpointImpl> { self.pipeline .iter() .filter_map(|(id, e)| match e { @@ -47,7 +49,7 @@ impl SerdeMemberSpec { /// Returns all [`WebRtcPublishEndpoint`]s of this [`MemberSpec`]. pub fn publish_endpoints( &self, - ) -> HashMap { + ) -> HashMap { self.pipeline .iter() .filter_map(|(id, e)| match e { @@ -64,7 +66,7 @@ impl SerdeMemberSpec { } } -impl MemberSpec for SerdeMemberSpec { +impl MemberSpec for SerdeMemberSpecImpl { fn webrtc_play_endpoints( &self, ) -> HashMap> { @@ -105,8 +107,8 @@ impl MemberSpec for SerdeMemberSpec { ) -> Option> { let element = self.pipeline.get(&id.0)?; - if let Some(endpoint) = Endpoint::try_from(element).ok() { - if let Endpoint::WebRtcPlay(e) = endpoint { + if let Some(endpoint) = SerdeEndpoint::try_from(element).ok() { + if let SerdeEndpoint::WebRtcPlay(e) = endpoint { return Some(Box::new(e) as Box); } } @@ -118,8 +120,8 @@ impl MemberSpec for SerdeMemberSpec { id: &WebRtcPublishId, ) -> Option> { let element = self.pipeline.get(&id.0)?; - if let Some(endpoint) = Endpoint::try_from(element).ok() { - if let Endpoint::WebRtcPublish(e) = endpoint { + if let Some(endpoint) = SerdeEndpoint::try_from(element).ok() { + if let SerdeEndpoint::WebRtcPublish(e) = endpoint { return Some(Box::new(e) as Box); } } @@ -127,7 +129,7 @@ impl MemberSpec for SerdeMemberSpec { } } -impl TryFrom<&Element> for SerdeMemberSpec { +impl TryFrom<&Element> for SerdeMemberSpecImpl { type Error = TryFromElementError; fn try_from(from: &Element) -> Result { diff --git a/src/api/control/serde/mod.rs b/src/api/control/serde/mod.rs index 7f2f4e327..6c8403c2f 100644 --- a/src/api/control/serde/mod.rs +++ b/src/api/control/serde/mod.rs @@ -11,13 +11,14 @@ use failure::{Error, Fail}; use serde::Deserialize; use self::{ - endpoint::{SerdeWebRtcPlayEndpoint, SerdeWebRtcPublishEndpoint}, + endpoint::{SerdeWebRtcPlayEndpointImpl, SerdeWebRtcPublishEndpointImpl}, pipeline::Pipeline, }; use super::model::RoomId; pub use self::{ - endpoint::Endpoint, member::SerdeMemberSpec, room::SerdeRoomSpec, + endpoint::SerdeEndpoint, member::SerdeMemberSpecImpl, + room::SerdeRoomSpecDto, }; /// Errors that can occur when we try transform some spec from [`Element`]. @@ -47,22 +48,24 @@ pub enum Element { /// Represent [`WebRtcPublishEndpoint`]. /// Can transform into [`Endpoint`] enum by `Endpoint::try_from`. - WebRtcPublishEndpoint { spec: SerdeWebRtcPublishEndpoint }, + WebRtcPublishEndpoint { + spec: SerdeWebRtcPublishEndpointImpl, + }, /// Represent [`WebRtcPlayEndpoint`]. /// Can transform into [`Endpoint`] enum by `Endpoint::try_from`. - WebRtcPlayEndpoint { spec: SerdeWebRtcPlayEndpoint }, + WebRtcPlayEndpoint { spec: SerdeWebRtcPlayEndpointImpl }, } /// Load [`RoomSpec`] from file with YAML format. pub fn load_from_yaml_file>( path: P, -) -> Result { +) -> Result { let mut file = File::open(path)?; let mut buf = String::new(); file.read_to_string(&mut buf)?; let parsed: Element = serde_yaml::from_str(&buf)?; - let room = SerdeRoomSpec::try_from(&parsed)?; + let room = SerdeRoomSpecDto::try_from(&parsed)?; Ok(room) } @@ -70,7 +73,7 @@ pub fn load_from_yaml_file>( /// Load all [`RoomSpec`] from YAML files from provided path. pub fn load_static_specs_from_dir>( path: P, -) -> Result, Error> { +) -> Result, Error> { let mut specs = Vec::new(); for entry in std::fs::read_dir(path)? { let entry = entry?; diff --git a/src/api/control/serde/room.rs b/src/api/control/serde/room.rs index 9838b7c23..a93cfbe0c 100644 --- a/src/api/control/serde/room.rs +++ b/src/api/control/serde/room.rs @@ -11,26 +11,29 @@ use crate::api::control::model::{ }; use super::{ - member::SerdeMemberSpec, pipeline::Pipeline, Element, TryFromElementError, + member::SerdeMemberSpecImpl, pipeline::Pipeline, Element, + TryFromElementError, }; /// [`crate::signalling::room::Room`] specification. /// Newtype for [`Element::Room`] #[allow(clippy::module_name_repetitions)] #[derive(Clone, Debug)] -pub struct SerdeRoomSpec { +pub struct SerdeRoomSpecDto { pub id: Id, pub pipeline: Pipeline, } -impl SerdeRoomSpec { +impl SerdeRoomSpecDto { /// Returns all [`MemberSpec`]s of this [`RoomSpec`]. pub fn members( &self, - ) -> Result, TryFromElementError> { - let mut members: HashMap = HashMap::new(); + ) -> Result, TryFromElementError> + { + let mut members: HashMap = + HashMap::new(); for (control_id, element) in self.pipeline.iter() { - let member_spec = SerdeMemberSpec::try_from(element)?; + let member_spec = SerdeMemberSpecImpl::try_from(element)?; let member_id = MemberId(control_id.clone()); members.insert(member_id.clone(), member_spec); @@ -45,13 +48,15 @@ impl SerdeRoomSpec { } } -pub struct ParsedSerdeRoomSpec { +pub struct SerdeRoomSpecImpl { id: Id, - members: HashMap, + members: HashMap, } -impl ParsedSerdeRoomSpec { - pub fn new(room_spec: &SerdeRoomSpec) -> Result { +impl SerdeRoomSpecImpl { + pub fn new( + room_spec: &SerdeRoomSpecDto, + ) -> Result { Ok(Self { id: room_spec.id.clone(), members: room_spec.members()?, @@ -59,7 +64,7 @@ impl ParsedSerdeRoomSpec { } } -impl RoomSpec for ParsedSerdeRoomSpec { +impl RoomSpec for SerdeRoomSpecImpl { fn members(&self) -> HashMap> { self.members .iter() @@ -80,7 +85,7 @@ impl RoomSpec for ParsedSerdeRoomSpec { } } -impl TryFrom<&Element> for SerdeRoomSpec { +impl TryFrom<&Element> for SerdeRoomSpecDto { type Error = TryFromElementError; fn try_from(from: &Element) -> Result { diff --git a/src/api/grpc/server.rs b/src/api/grpc/server.rs index b1f2992d4..9cd1cac76 100644 --- a/src/api/grpc/server.rs +++ b/src/api/grpc/server.rs @@ -1,4 +1,4 @@ -use std::sync::Arc; +use std::{sync::Arc, time::Duration}; use actix::{Actor, Addr, Arbiter, Context}; use futures::future::Future; @@ -6,22 +6,20 @@ use grpcio::{Environment, RpcContext, Server, ServerBuilder, UnarySink}; use crate::{ api::{ - control::model::RoomId, + control::{ + model::{room::RoomSpec, RoomId}, + protobuf::room::CreateRequestSpec, + }, grpc::protos::control::{ ApplyRequest, CreateRequest, GetResponse, IdRequest, Response, }, }, + conf::Conf, log::prelude::*, - signalling::room_repo::RoomsRepository, + signalling::{room_repo::RoomsRepository, Room}, }; use super::protos::control_grpc::{create_control_api, ControlApi}; -use crate::{ - api::control::{model::room::RoomSpec, protobuf::room::CreateRequestSpec}, - conf::Conf, - signalling::Room, -}; -use std::time::Duration; #[derive(Clone)] struct ControlApiService { diff --git a/src/lib.rs b/src/lib.rs index f78046bd9..fca4de90e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -16,7 +16,7 @@ use hashbrown::HashMap; use crate::{ api::control::{ model::{room::RoomSpec, RoomId}, - serde::{load_static_specs_from_dir, room::ParsedSerdeRoomSpec}, + serde::{load_static_specs_from_dir, room::SerdeRoomSpecImpl}, }, conf::Conf, signalling::{room::RoomError, Room}, @@ -85,7 +85,7 @@ pub fn start_static_rooms( let room_id = spec.id().clone(); let rpc_reconnect_timeout = config.rpc.reconnect_timeout; let room = Room::start_in_arbiter(&arbiter, move |_| { - let parsed_spec = ParsedSerdeRoomSpec::new(&spec).unwrap(); + let parsed_spec = SerdeRoomSpecImpl::new(&spec).unwrap(); let parsed_spec = Box::new(&parsed_spec as &RoomSpec); Room::new( &parsed_spec, diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index 778458cda..551fa55cf 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -353,7 +353,7 @@ mod tests { use crate::api::control::{ model::MemberId, - serde::{room::ParsedSerdeRoomSpec, Element, SerdeRoomSpec}, + serde::{room::SerdeRoomSpecImpl, Element, SerdeRoomSpecDto}, }; use super::*; @@ -403,8 +403,8 @@ mod tests { fn get_test_store() -> HashMap> { let room_element: Element = serde_yaml::from_str(TEST_SPEC).unwrap(); - let room_spec = SerdeRoomSpec::try_from(&room_element).unwrap(); - let room_spec = ParsedSerdeRoomSpec::new(&room_spec).unwrap(); + let room_spec = SerdeRoomSpecDto::try_from(&room_element).unwrap(); + let room_spec = SerdeRoomSpecImpl::new(&room_spec).unwrap(); let room_spec = Box::new(&room_spec as &RoomSpec); parse_members(&room_spec).unwrap() } From db2b84df2d64e2ccecafe866c9f8c9c986bad136 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 4 Jul 2019 19:36:07 +0300 Subject: [PATCH 255/735] Fix test --- src/api/client/server.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/api/client/server.rs b/src/api/client/server.rs index a583442d7..f729e70cd 100644 --- a/src/api/client/server.rs +++ b/src/api/client/server.rs @@ -119,9 +119,7 @@ mod test { use futures::{future::IntoFuture as _, sink::Sink as _, Stream as _}; use crate::{ - api::control, - conf::{Conf, Server, Turn}, - signalling::Room, + api::control, conf::Conf, signalling::Room, turn::new_turn_auth_service_mock, }; @@ -182,8 +180,7 @@ mod test { idle_timeout: Duration::new(2, 0), reconnect_timeout: Default::default(), }, - turn: Turn::default(), - server: Server::default(), + ..Default::default() }; let mut server = ws_server(conf.clone()); From 4e568266c93ff98d03816337ea7643691c814bd1 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 4 Jul 2019 19:49:55 +0300 Subject: [PATCH 256/735] Load awc crate from crates.io, update crates --- Cargo.lock | 450 ++++++++++++++++++++++++----------------------------- Cargo.toml | 5 +- 2 files changed, 206 insertions(+), 249 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 80e14fb7d..12ebe5be9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6,7 +6,7 @@ version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.1.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -14,21 +14,21 @@ name = "actix" version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "actix-http 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-http 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "actix-rt 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "actix_derive 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "hashbrown 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", @@ -41,7 +41,7 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -54,10 +54,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "actix-service 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-utils 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-utils 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", "either 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-current-thread 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -67,7 +67,7 @@ dependencies = [ [[package]] name = "actix-http" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -75,7 +75,7 @@ dependencies = [ "actix-server-config 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "actix-service 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "actix-threadpool 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-utils 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-utils 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "brotli2 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -85,14 +85,14 @@ dependencies = [ "copyless 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", "either 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "encoding 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", + "encoding_rs 0.8.17 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "flate2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "h2 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", + "h2 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "hashbrown 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", - "httparse 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "httparse 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -100,9 +100,9 @@ dependencies = [ "mime 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", "percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "serde_urlencoded 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", "sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -122,17 +122,17 @@ dependencies = [ "actix-rt 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "actix-server 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "actix-service 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-utils 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "awc 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-utils 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "awc 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "serde_urlencoded 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", "sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -149,9 +149,9 @@ dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", - "string 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", + "string 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -160,9 +160,9 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "actix-threadpool 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-current-thread 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -175,7 +175,7 @@ dependencies = [ "actix-rt 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "actix-server-config 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "actix-service 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", @@ -193,7 +193,7 @@ name = "actix-server-config" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -203,7 +203,7 @@ name = "actix-service" version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -212,7 +212,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -222,14 +222,14 @@ dependencies = [ [[package]] name = "actix-utils" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "actix-service 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "either 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-current-thread 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", @@ -237,32 +237,32 @@ dependencies = [ [[package]] name = "actix-web" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-http 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-http 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "actix-router 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "actix-rt 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "actix-server 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "actix-server-config 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "actix-service 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "actix-threadpool 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-utils 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-utils 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "actix-web-codegen 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "awc 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "awc 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", - "encoding 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "encoding_rs 0.8.17 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "hashbrown 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "mime 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "serde_urlencoded 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -270,15 +270,15 @@ dependencies = [ [[package]] name = "actix-web-actors" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "actix 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)", "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-http 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-web 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-http 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-web 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -287,7 +287,7 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.38 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -297,7 +297,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.38 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -315,7 +315,7 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -365,55 +365,32 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "awc" -version = "0.2.1" -source = "git+https://github.com/actix/actix-web#c0c71f82c00fdac964bcf588c2ea49c4c18d5de7" -dependencies = [ - "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-http 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-service 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", - "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "mime 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", - "percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_urlencoded 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "awc" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-http 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-http 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "actix-service 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "mime 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", "percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "serde_urlencoded 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "backtrace" -version = "0.3.31" +version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace-sys 0.1.30 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-demangle 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", @@ -421,7 +398,7 @@ dependencies = [ [[package]] name = "backtrace-sys" -version = "0.1.28" +version = "0.1.30" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", @@ -441,8 +418,8 @@ name = "bb8" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -452,9 +429,9 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bb8 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "redis 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -489,14 +466,9 @@ dependencies = [ "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "build_const" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "bumpalo" -version = "2.4.3" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -579,9 +551,9 @@ dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "nom 4.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "rust-ini 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", "serde-hjson 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "yaml-rust 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -605,14 +577,6 @@ name = "copyless" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "crc" -version = "1.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "build_const 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "crc32fast" version = "1.2.0" @@ -706,7 +670,7 @@ dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.38 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -717,9 +681,9 @@ dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.38 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -739,7 +703,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.1.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -809,6 +773,14 @@ name = "encoding_index_tests" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "encoding_rs" +version = "0.8.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "enum-as-inner" version = "0.2.1" @@ -816,18 +788,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.38 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "env_logger" -version = "0.6.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -836,7 +808,7 @@ name = "failure" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "backtrace 0.3.31 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace 0.3.32 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -847,7 +819,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.38 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)", "synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -859,7 +831,7 @@ dependencies = [ "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "miniz-sys 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "miniz_oxide_c_api 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "miniz_oxide_c_api 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -888,7 +860,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "futures" -version = "0.1.27" +version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -910,7 +882,7 @@ name = "grpcio" version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "grpcio-sys 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -939,18 +911,18 @@ dependencies = [ [[package]] name = "h2" -version = "0.1.24" +version = "0.1.25" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "string 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "string 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1002,7 +974,7 @@ dependencies = [ [[package]] name = "httparse" -version = "1.3.3" +version = "1.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1055,7 +1027,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1069,13 +1041,13 @@ name = "jason" version = "0.1.0-dev" dependencies = [ "console_error_panic_hook 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "js-sys 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", "macro-attr 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "medea-client-api-proto 0.1.0-dev", "newtype_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-futures 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-test 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1194,18 +1166,18 @@ version = "0.1.0-dev" dependencies = [ "actix 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)", "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-http 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-http 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "actix-http-test 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-web 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-web-actors 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "awc 0.2.1 (git+https://github.com/actix/actix-web)", + "actix-web 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-web-actors 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "awc 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "bb8 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "bb8-redis 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "config 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", "dotenv 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "grpcio 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1218,9 +1190,9 @@ dependencies = [ "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "redis 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", "serde-humantime 0.1.1 (git+https://github.com/tailhook/serde-humantime?branch=serde_wrapper)", - "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "serde_yaml 0.8.9 (registry+https://github.com/rust-lang/crates.io-index)", "serial_test 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "serial_test_derive 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1231,7 +1203,7 @@ dependencies = [ "slog-scope 4.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "slog-stdlog 3.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "smart-default 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1240,8 +1212,8 @@ name = "medea-client-api-proto" version = "0.1.0-dev" dependencies = [ "medea-macro 0.1.0-dev", - "serde 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1251,7 +1223,7 @@ dependencies = [ "Inflector 0.11.4 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.38 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1296,7 +1268,7 @@ dependencies = [ [[package]] name = "miniz_oxide" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1304,13 +1276,13 @@ dependencies = [ [[package]] name = "miniz_oxide_c_api" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", - "crc 1.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", - "miniz_oxide 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "miniz_oxide 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1469,7 +1441,7 @@ dependencies = [ "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1715,10 +1687,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "combine 3.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1726,7 +1698,7 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.1.54" +version = "0.1.56" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1734,7 +1706,7 @@ name = "redox_termios" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1745,7 +1717,7 @@ dependencies = [ "argon2rs 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1762,10 +1734,10 @@ dependencies = [ [[package]] name = "regex" -version = "1.1.7" +version = "1.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "aho-corasick 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", + "aho-corasick 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "regex-syntax 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1847,7 +1819,7 @@ dependencies = [ [[package]] name = "ryu" -version = "0.2.8" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1895,10 +1867,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde" -version = "1.0.93" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde_derive 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1909,7 +1881,7 @@ dependencies = [ "lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "linked-hash-map 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1919,27 +1891,27 @@ version = "0.1.1" source = "git+https://github.com/tailhook/serde-humantime?branch=serde_wrapper#36b86d5ca09db3caf2edb06e0d46b505d0915792" dependencies = [ "humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "serde_derive" -version = "1.0.93" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.38 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "serde_json" -version = "1.0.39" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "ryu 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", + "ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1957,7 +1929,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "dtoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1968,7 +1940,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "dtoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", "yaml-rust 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1986,7 +1958,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.38 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2052,8 +2024,8 @@ version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "slog 2.4.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2102,7 +2074,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.38 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2112,7 +2084,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2133,7 +2105,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "string" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2141,7 +2113,7 @@ dependencies = [ [[package]] name = "syn" -version = "0.15.38" +version = "0.15.39" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2156,7 +2128,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.38 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2173,7 +2145,7 @@ dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", "remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2203,7 +2175,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "numtoa 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2246,30 +2218,29 @@ version = "0.1.42" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "tokio" -version = "0.1.21" +version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-current-thread 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-fs 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-sync 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-threadpool 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-threadpool 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-trace-core 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-udp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-uds 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2280,7 +2251,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2289,17 +2260,17 @@ name = "tokio-current-thread" version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "tokio-executor" -version = "0.1.7" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2307,9 +2278,9 @@ name = "tokio-fs" version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-threadpool 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-threadpool 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2318,7 +2289,7 @@ version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2328,14 +2299,14 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-sync 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2345,12 +2316,12 @@ name = "tokio-signal" version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", "mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", "signal-hook 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2362,7 +2333,7 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2371,7 +2342,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2380,18 +2351,18 @@ dependencies = [ [[package]] name = "tokio-threadpool" -version = "0.1.14" +version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-deque 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2400,17 +2371,9 @@ version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "tokio-trace-core" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2419,7 +2382,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2433,7 +2396,7 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2449,7 +2412,7 @@ name = "toml" version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2460,14 +2423,14 @@ dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "enum-as-inner 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", "socket2 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2483,14 +2446,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "ipconfig 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "lru-cache 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "resolv-conf 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "trust-dns-proto 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2577,8 +2540,8 @@ name = "wasm-bindgen" version = "0.2.47" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-macro 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2587,12 +2550,12 @@ name = "wasm-bindgen-backend" version = "0.2.47" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bumpalo 2.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "bumpalo 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.38 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-shared 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2601,7 +2564,7 @@ name = "wasm-bindgen-futures" version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "js-sys 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2622,7 +2585,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.38 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-backend 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-shared 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2638,7 +2601,7 @@ version = "0.2.47" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "console_error_panic_hook 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "js-sys 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", "scoped-tls 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2665,7 +2628,7 @@ dependencies = [ "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.38 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-backend 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", "weedle 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2791,7 +2754,7 @@ dependencies = [ "checksum actix 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)" = "671ce3d27313f236827a5dd153a1073ad03ef31fc77f562020263e7830cf1ef7" "checksum actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9f2c11af4b06dc935d8e1b1491dad56bfb32febc49096a91e773f8535c176453" "checksum actix-connect 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d7fbab0d79b2f3415a79570e3db12eaa75c26239541e613b832655145a5e9488" -"checksum actix-http 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "81aa906e74d2cd5f219f596003b0fd94d05e75a4a448b12afea66e7658b6c9e1" +"checksum actix-http 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "29c11d33772c790e9aeb2e024834bc084f7496598482908e2424efd768c912b6" "checksum actix-http-test 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7e4ea476df1fe681a9bd2fcc37eff9393fad4a0430975e46d7c657907351f250" "checksum actix-router 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "23224bb527e204261d0291102cb9b52713084def67d94f7874923baefe04ccf7" "checksum actix-rt 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "61e09627004cb25149fd177c4a062d2061c4ec40aae5820ecd37a87195e759f8" @@ -2799,24 +2762,23 @@ dependencies = [ "checksum actix-server-config 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e78703f07d0bd08b426b482d53569d84f1e1929024f0431b3a5a2dc0c1c60e0f" "checksum actix-service 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "aaecc01bbc595ebd7a563a7d4f8a607d0b964bb55273c6f362b0b02c26508cf2" "checksum actix-threadpool 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1c29f7c554d56b3841f4bb85d5b3dee01ba536e1307679f56eb54de28aaec3fb" -"checksum actix-utils 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7ab47adc5e67fc83a0c58570b40531f09814a5daa969e0d913ebeab908a43508" -"checksum actix-web 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6478c837afbe528cfe468976e67b6b81a6330414b00234c4546a158f9f0739fc" -"checksum actix-web-actors 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9c54489d9bcfce84a5096ba47db6a4dd2cc493987e97a987a4c5a7519b31f26d" +"checksum actix-utils 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b307201d074c963041cd8858d6b6a82ca23369827d613da5d6e972de123d3c14" +"checksum actix-web 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d0dc7ab62d04b9eeb0f368ad9c6ee20c2e3541fb9a25a5eb727c9118b59e8ff2" +"checksum actix-web-actors 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8197aa04b8950ed9e37340cd46fe7ad3ccb8b1c4bbcef881ee5f6d149a425608" "checksum actix-web-codegen 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3fe9e3cdec1e645b675f354766e0688c5705021c85ab3cf739be1c8999b91c76" "checksum actix_derive 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0bf5f6d7bf2d220ae8b4a7ae02a572bb35b7c4806b24049af905ab8110de156c" "checksum adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7e522997b529f05601e05166c07ed17789691f562762c7f3b987263d2dedee5c" "checksum aho-corasick 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ca972c2ea5f742bfce5687b9aef75506a764f61d37f8f649047846a9686ddb66" -"checksum aho-corasick 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e6f484ae0c99fec2e858eb6134949117399f222608d84cadb3f58c1f97c2364c" +"checksum aho-corasick 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)" = "36b7aa1ccb7d7ea3f437cf025a2ab1c47cc6c1bc9fc84918ff449def12f5e282" "checksum arc-swap 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)" = "bc4662175ead9cd84451d5c35070517777949a2ed84551764129cedb88384841" "checksum argon2rs 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3f67b0b6a86dae6e67ff4ca2b6201396074996379fba2b92ff649126f37cb392" "checksum arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "92c7fb76bc8826a8b33b4ee5bb07a247a81e76764ab4d55e8f73e3a4d8808c71" "checksum ascii 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a5fc969a8ce2c9c0c4b0429bb8431544f6658283c8326ba5ff8c762b75369335" "checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" "checksum autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "0e49efa51329a5fd37e7c79db4621af617cd4e3e5bc224939808d076077077bf" -"checksum awc 0.2.1 (git+https://github.com/actix/actix-web)" = "" -"checksum awc 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c5133e9ca1d7f0560fb271f20286be3e896dac5736040a62a7ef1d62003160b6" -"checksum backtrace 0.3.31 (registry+https://github.com/rust-lang/crates.io-index)" = "e0f77aa27f55a4beb477ff6bc4d9bf72f90eb422b19c1d8e5a644b8aeb674d66" -"checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6" +"checksum awc 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4c4763e6aa29a801d761dc3464f081d439ea5249ba90c3c3bdfc8dd3f739d233" +"checksum backtrace 0.3.32 (registry+https://github.com/rust-lang/crates.io-index)" = "18b50f5258d1a9ad8396d2d345827875de4261b158124d4c819d9b351454fae5" +"checksum backtrace-sys 0.1.30 (registry+https://github.com/rust-lang/crates.io-index)" = "5b3a000b9c543553af61bc01cbfc403b04b5caa9e421033866f2e98061eb3e61" "checksum base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" "checksum bb8 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6ac04c3b2d3327a583c9a93b6c5ab4316e6609f5ec84b71b89ebe518e0edbad2" "checksum bb8-redis 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9817f38c173f0da1581b923b90e66750a090413ad67a20980d5ad64141bab476" @@ -2824,8 +2786,7 @@ dependencies = [ "checksum blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "5d6d530bdd2d52966a6d03b7a964add7ae1a288d25214066fd4b600f0f796400" "checksum brotli-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4445dea95f4c2b41cde57cc9fee236ae4dbae88d8fcbdb4750fc1bb5d86aaecd" "checksum brotli2 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0cb036c3eade309815c15ddbacec5b22c4d1f3983a774ab2eac2e3e9ea85568e" -"checksum build_const 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "39092a32794787acd8525ee150305ff051b0aa6cc2abaf193924f5ab05425f39" -"checksum bumpalo 2.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "84dca3afd8e01b9526818b7963e5b4916063b3cdf9f10cf6b73ef0bd0ec37aa5" +"checksum bumpalo 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2cd43d82f27d68911e6ee11ee791fb248f138f5d69424dc02e098d4f152b0b05" "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" "checksum bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" "checksum c2-chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7d64d04786e0f528460fc884753cf8dddcc466be308f6026f8e355c41a0e4101" @@ -2839,7 +2800,6 @@ dependencies = [ "checksum console_error_panic_hook 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "b8d976903543e0c48546a91908f21588a680a8c8f984df9a5d69feccb2b2a211" "checksum constant_time_eq 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8ff012e225ce166d4422e0e78419d901719760f62ae2b7969ca6b564d1b54a9e" "checksum copyless 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "6ff9c56c9fb2a49c05ef0e431485a22400af20d33226dc0764d891d09e724127" -"checksum crc 1.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d663548de7f5cca343f1e0a48d14dcfb0e9eb4e079ec58883b7251539fa10aeb" "checksum crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" "checksum crossbeam 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)" = "bd66663db5a988098a89599d4857919b3acf7f61402e61365acfd3919857b9be" "checksum crossbeam 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ad4c7ea749d9fb09e23c5cb17e3b70650860553a0e2744e38446b1803bf7db94" @@ -2862,8 +2822,9 @@ dependencies = [ "checksum encoding-index-singlebyte 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3351d5acffb224af9ca265f435b859c7c01537c0849754d3db3fdf2bfe2ae84a" "checksum encoding-index-tradchinese 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fd0e20d5688ce3cab59eb3ef3a2083a5c77bf496cb798dc6fcdb75f323890c18" "checksum encoding_index_tests 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "a246d82be1c9d791c5dfde9a2bd045fc3cbba3fa2b11ad558f27d01712f00569" +"checksum encoding_rs 0.8.17 (registry+https://github.com/rust-lang/crates.io-index)" = "4155785c79f2f6701f185eb2e6b4caf0555ec03477cb4c70db67b465311620ed" "checksum enum-as-inner 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3d58266c97445680766be408285e798d3401c6d4c378ec5552e78737e681e37d" -"checksum env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b61fa891024a945da30a9581546e8cfaf5602c7b3f4c137a2805cf388f92075a" +"checksum env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "aafcde04e90a5226a6443b7aabdb016ba2f8307c847d524724bd9b346dd1a2d3" "checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" "checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" "checksum flate2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "550934ad4808d5d39365e5d61727309bf18b3b02c6c56b729cb92e7dd84bc3d8" @@ -2871,20 +2832,20 @@ dependencies = [ "checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" "checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" -"checksum futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)" = "a2037ec1c6c1c4f79557762eab1f7eae1f64f6cb418ace90fae88f0942b60139" +"checksum futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "45dc39533a6cae6da2b56da48edae506bb767ec07370f86f70fc062e9d435869" "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" "checksum getrandom 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "e65cce4e5084b14874c4e7097f38cab54f47ee554f9194673456ea379dcc4c55" "checksum grpcio 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c02fb3c9c44615973814c838f75d7898695d4d4b97a3e8cf52e9ccca30664b6f" "checksum grpcio-compiler 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "373a14f0f994d4c235770f4bb5558be00626844db130a82a70142b8fc5996fc3" "checksum grpcio-sys 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "9d8d3b6d1a70b9dcb2545d1aff5b2c74652cb635f6ab6426be8fd201e9566b7e" -"checksum h2 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)" = "69b2a5a3092cbebbc951fe55408402e696ee2ed09019137d1800fc2c411265d2" +"checksum h2 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)" = "a539b63339fbbb00e081e84b6e11bd1d9634a82d91da2984a18ac74a8823f392" "checksum hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3bae29b6653b3412c2e71e9d486db9f9df5d701941d86683005efb9f2d28e3da" "checksum hashbrown 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "29fba9abe4742d586dfd0c06ae4f7e73a1c2d86b856933509b269d82cdf06e18" "checksum hashbrown 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e1de41fb8dba9714efd92241565cdff73f78508c95697dd56787d3cba27e2353" "checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" "checksum hostname 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "21ceb46a83a85e824ef93669c8b390009623863b5c195d1ba747292c0c72f94e" "checksum http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)" = "eed324f0f0daf6ec10c474f150505af2c143f251722bf9dbd1261bd1f2ee2c1a" -"checksum httparse 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e8734b0cfd3bc3e101ec59100e101c2eecd19282202e87808b3037b442777a83" +"checksum httparse 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "cd179ae861f0c2e53da70d892f5f3029f9594be0c41dc5269cd371691b1dc2f9" "checksum humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ca7e5f2e110db35f93b837c81797f3714500b81d517bf20c431b16d3ca4f114" "checksum idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e" "checksum indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7e81a7c05f79578dbc15793d8b619db9ba32b4577003ef3af1a91c416798c58d" @@ -2913,8 +2874,8 @@ dependencies = [ "checksum memory_units 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8452105ba047068f40ff7093dd1d9da90898e63dd61736462e9cdda6a90ad3c3" "checksum mime 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)" = "3e27ca21f40a310bd06d9031785f4801710d566c184a6e15bad4f1d9b65f9425" "checksum miniz-sys 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "1e9e3ae51cea1576ceba0dde3d484d30e6e5b86dee0b2d412fe3a16a15c98202" -"checksum miniz_oxide 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c468f2369f07d651a5d0bb2c9079f8488a66d5466efe42d0c5c6466edcb7f71e" -"checksum miniz_oxide_c_api 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b7fe927a42e3807ef71defb191dc87d4e24479b221e67015fe38ae2b7b447bab" +"checksum miniz_oxide 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b6c3756d66cf286314d5f7ebe74886188a9a92f5eee68b06f31ac2b4f314c99d" +"checksum miniz_oxide_c_api 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5b78ca5446dd9fe0dab00e058731b6b08a8c1d2b9cdb8efb10876e24e9ae2494" "checksum mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)" = "83f51996a3ed004ef184e16818edc51fadffe8e7ca68be67f9dee67d84d0ff23" "checksum mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)" = "966257a94e196b11bb43aca423754d87429960a768de9414f3691d6957abf125" "checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" @@ -2960,11 +2921,11 @@ dependencies = [ "checksum rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" "checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" "checksum redis 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b543b95de413ac964ca609e91fd9fd58419312e69988fb197f3ff8770312a1af" -"checksum redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)" = "12229c14a0f65c4f1cb046a3b52047cdd9da1f4b30f8a39c5063c8bae515e252" +"checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" "checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" "checksum redox_users 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3fe5204c3a17e97dde73f285d49be585df59ed84b50a872baf416e73b62c3828" "checksum regex 0.1.80 (registry+https://github.com/rust-lang/crates.io-index)" = "4fd4ace6a8cf7860714a2c2280d6c1f7e6a413486c13298bbc86fd3da019402f" -"checksum regex 1.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "0b2f0808e7d7e4fb1cb07feb6ff2f4bc827938f24f8c2e6a3beb7370af544bdd" +"checksum regex 1.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "1325e8a57b7da4cbcb38b3957112f729990bad0a18420e7e250ef6b1d9a15763" "checksum regex-syntax 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "f9ec002c35e86791825ed294b50008eea9ddfc8def4420124fbc6b08db834957" "checksum regex-syntax 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)" = "9d76410686f9e3a17f06128962e0ecc5755870bb890c34820c7af7f1db2e1d48" "checksum remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e" @@ -2975,7 +2936,7 @@ dependencies = [ "checksum rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda" "checksum rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "c5f5376ea5e30ce23c03eb77cbe4962b988deead10910c372b226388b594c084" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -"checksum ryu 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "b96a9549dc8d48f2c283938303c4b5a77aa29bfbc5b54b084fb1630408899a8f" +"checksum ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c92464b447c0ee8c4fb3824ecc8383b81717b9f1e74ba2e72540aef7b9f82997" "checksum scoped-tls 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2" "checksum scoped_threadpool 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "1d51f5df5af43ab3f1360b429fa5e0152ac5ce8c0bd6485cae490332e96846a8" "checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" @@ -2984,11 +2945,11 @@ dependencies = [ "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" "checksum serde 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)" = "9dad3f759919b92c3068c696c15c3d17238234498bbdcc80f2c469606f948ac8" -"checksum serde 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)" = "960e29cf7004b3b6e65fc5002981400eb3ccc017a08a2406940823e58e7179a9" +"checksum serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)" = "076a696fdea89c19d3baed462576b8f6d663064414b5c793642da8dfeb99475b" "checksum serde-hjson 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0b833c5ad67d52ced5f5938b2980f32a9c1c5ef047f0b4fb3127e7a423c76153" "checksum serde-humantime 0.1.1 (git+https://github.com/tailhook/serde-humantime?branch=serde_wrapper)" = "" -"checksum serde_derive 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)" = "c4cce6663696bd38272e90bf34a0267e1226156c33f52d3f3915a2dd5d802085" -"checksum serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)" = "5a23aa71d4a4d43fdbfaac00eff68ba8a06a51759a89ac3304323e800c4dd40d" +"checksum serde_derive 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)" = "ef45eb79d6463b22f5f9e16d283798b7c0175ba6050bc25c1a946c122727fe7b" +"checksum serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)" = "051c49229f282f7c6f3813f8286cc1e3323e8051823fce42c7ea80fe13521704" "checksum serde_test 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)" = "110b3dbdf8607ec493c22d5d947753282f3bae73c0f56d322af1e8c78e4c23d5" "checksum serde_urlencoded 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "642dd69105886af2efd227f75a520ec9b44a820d65bc133a9131f7d229fd165a" "checksum serde_yaml 0.8.9 (registry+https://github.com/rust-lang/crates.io-index)" = "38b08a9a90e5260fe01c6480ec7c811606df6d3a660415808c3c3fa8ed95b582" @@ -3011,8 +2972,8 @@ dependencies = [ "checksum sourcefile 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4bf77cb82ba8453b42b6ae1d692e4cdc92f9a47beaf89a847c8be83f4e328ad3" "checksum spin 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44363f6f51401c34e7be73db0db371c04705d35efbe9f7d6082e03a921a32c55" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" -"checksum string 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0bbfb8937e38e34c3444ff00afb28b0811d9554f15c5ad64d12b0308d1d1995" -"checksum syn 0.15.38 (registry+https://github.com/rust-lang/crates.io-index)" = "37ea458a750f59ab679b47fef9b6722c586c5742f4cfe18a120bbc807e5e01fd" +"checksum string 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d24114bfcceb867ca7f71a0d3fe45d45619ec47a6fbfa98cb14e14250bfa5d6d" +"checksum syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)" = "b4d960b829a55e56db167e861ddb43602c003c7be0bee1d345021703fac2fb7c" "checksum synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f" "checksum take_mut 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f764005d11ee5f36500a149ace24e00e3da98b0158b3e2d53a7495660d3f4d60" "checksum tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" @@ -3024,19 +2985,18 @@ dependencies = [ "checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" "checksum threadpool 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e2f0c90a5f3459330ac8bc0d2f879c693bb7a2f59689c1083fc4ef83834da865" "checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" -"checksum tokio 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)" = "ec2ffcf4bcfc641413fa0f1427bf8f91dfc78f56a6559cbf50e04837ae442a87" +"checksum tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)" = "5a09c0b5bb588872ab2f09afa13ee6e9dac11e10a0ec9e8e3ba39a5a5d530af6" "checksum tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5c501eceaf96f0e1793cf26beb63da3d11c738c4a943fdf3746d81d64684c39f" "checksum tokio-current-thread 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "d16217cad7f1b840c5a97dfb3c43b0c871fef423a6e8d2118c604e843662a443" -"checksum tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "83ea44c6c0773cc034771693711c35c677b4b5a4b21b9e7071704c54de7d555e" +"checksum tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "0f27ee0e6db01c5f0b2973824547ce7e637b2ed79b891a9677b0de9bd532b6ac" "checksum tokio-fs 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "3fe6dc22b08d6993916647d108a1a7d15b9cd29c4f4496c62b92c45b5041b7af" "checksum tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "5090db468dad16e1a7a54c8c67280c5e4b544f3d3e018f0b913b400261f85926" "checksum tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "6af16bfac7e112bea8b0442542161bfc41cbfa4466b580bdda7d18cb88b911ce" "checksum tokio-signal 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "dd6dc5276ea05ce379a16de90083ec80836440d5ef8a6a39545a3207373b8296" "checksum tokio-sync 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2162248ff317e2bc713b261f242b69dbb838b85248ed20bb21df56d60ea4cae7" "checksum tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1d14b10654be682ac43efee27401d792507e30fd8d26389e1da3b185de2e4119" -"checksum tokio-threadpool 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "72558af20be886ea124595ea0f806dd5703b8958e4705429dd58b3d8231f72f2" +"checksum tokio-threadpool 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "90ca01319dea1e376a001e8dc192d42ebde6dd532532a5bad988ac37db365b19" "checksum tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "f2106812d500ed25a4f38235b9cae8f78a09edf43203e16e59c3b769a342a60e" -"checksum tokio-trace-core 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a9c8a256d6956f7cb5e2bdfe8b1e8022f1a09206c6c2b1ba00f3b746b260c613" "checksum tokio-udp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "66268575b80f4a4a710ef83d087fdfeeabdce9b74c797535fbac18a2cb906e92" "checksum tokio-uds 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "037ffc3ba0e12a0ab4aca92e5234e0dedeb48fddf6ccd260f1f150a36a9f2445" "checksum toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "758664fc71a3a69038656bee8b6be6477d2a6c315a6b81f7081f591bffa4111f" diff --git a/Cargo.toml b/Cargo.toml index 3c479fdcf..bf3b70fe0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,10 +24,7 @@ lto = "thin" actix = "0.8" actix-web = "1.0" actix-web-actors = "1.0" -# TODO: use version from crates.io when commit -# https://github.com/actix/actix-web/commit/ff724e239db50210a9913de6e214be214f41befa#diff-c39fd968c2b6beb9a6960dd533618bcbR41 -# will be released in crates.io. -awc = { git = "https://github.com/actix/actix-web" } +awc = "0.2" bb8 = "0.3" bb8-redis = "0.3" chrono = "0.4" From 93ba192a8e9c3db97245807876cca612e1447c30 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 4 Jul 2019 20:02:49 +0300 Subject: [PATCH 257/735] P2pMode refactor --- src/api/control/model/endpoint/webrtc/mod.rs | 2 +- .../model/endpoint/webrtc/play_endpoint.rs | 4 ++-- .../model/endpoint/webrtc/publish_endpoint.rs | 22 ++++++++++++++++++- .../protobuf/webrtc_publish_endpoint.rs | 16 +++----------- src/api/control/serde/endpoint.rs | 9 -------- .../endpoints/webrtc/publish_endpoint.rs | 2 +- 6 files changed, 28 insertions(+), 27 deletions(-) diff --git a/src/api/control/model/endpoint/webrtc/mod.rs b/src/api/control/model/endpoint/webrtc/mod.rs index 1afc6c06b..06e3b3f69 100644 --- a/src/api/control/model/endpoint/webrtc/mod.rs +++ b/src/api/control/model/endpoint/webrtc/mod.rs @@ -3,4 +3,4 @@ pub mod publish_endpoint; pub use crate::api::control::serde::endpoint::SerdeSrcUri as SrcUri; pub use play_endpoint::{WebRtcPlayEndpoint, WebRtcPlayId}; -pub use publish_endpoint::{WebRtcPublishEndpoint, WebRtcPublishId}; +pub use publish_endpoint::{P2pMode, WebRtcPublishEndpoint, WebRtcPublishId}; diff --git a/src/api/control/model/endpoint/webrtc/play_endpoint.rs b/src/api/control/model/endpoint/webrtc/play_endpoint.rs index 936a851a7..8e7eaaf1b 100644 --- a/src/api/control/model/endpoint/webrtc/play_endpoint.rs +++ b/src/api/control/model/endpoint/webrtc/play_endpoint.rs @@ -1,9 +1,9 @@ -use crate::api::control::serde::endpoint::SerdeSrcUri; - use macro_attr::*; use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; use serde::Deserialize; +use crate::api::control::serde::endpoint::SerdeSrcUri; + pub use Id as WebRtcPlayId; macro_attr! { diff --git a/src/api/control/model/endpoint/webrtc/publish_endpoint.rs b/src/api/control/model/endpoint/webrtc/publish_endpoint.rs index f79e95e7e..d4cfce5e5 100644 --- a/src/api/control/model/endpoint/webrtc/publish_endpoint.rs +++ b/src/api/control/model/endpoint/webrtc/publish_endpoint.rs @@ -1,8 +1,9 @@ -use crate::api::control::serde::endpoint::P2pMode; use macro_attr::*; use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; use serde::Deserialize; // TODO: temp +use crate::api::grpc::protos::control::WebRtcPublishEndpoint_P2P; + macro_attr! { /// ID of [`Room`]. #[derive( @@ -23,3 +24,22 @@ pub use Id as WebRtcPublishId; pub trait WebRtcPublishEndpoint { fn p2p(&self) -> P2pMode; } + +/// Peer-to-peer mode of [`WebRtcPublishEndpoint`]. +#[derive(Clone, Deserialize, Debug)] +pub enum P2pMode { + /// Always connect peer-to-peer. + Always, + Never, + IfPossible, +} + +impl From for P2pMode { + fn from(from: WebRtcPublishEndpoint_P2P) -> Self { + match from { + WebRtcPublishEndpoint_P2P::ALWAYS => P2pMode::Always, + WebRtcPublishEndpoint_P2P::IF_POSSIBLE => P2pMode::IfPossible, + WebRtcPublishEndpoint_P2P::NEVER => P2pMode::Never, + } + } +} diff --git a/src/api/control/protobuf/webrtc_publish_endpoint.rs b/src/api/control/protobuf/webrtc_publish_endpoint.rs index 59bc3fc55..6036267bb 100644 --- a/src/api/control/protobuf/webrtc_publish_endpoint.rs +++ b/src/api/control/protobuf/webrtc_publish_endpoint.rs @@ -1,12 +1,6 @@ use crate::api::{ - control::{ - model::endpoint::webrtc::WebRtcPublishEndpoint, - serde::endpoint::P2pMode, - }, - grpc::protos::control::{ - WebRtcPublishEndpoint as WebRtcPublishEndpointProto, - WebRtcPublishEndpoint_P2P, - }, + control::model::endpoint::webrtc::{P2pMode, WebRtcPublishEndpoint}, + grpc::protos::control::WebRtcPublishEndpoint as WebRtcPublishEndpointProto, }; pub struct GrpcWebRtcPublishEndpointSpecImpl(pub WebRtcPublishEndpointProto); @@ -15,11 +9,7 @@ impl WebRtcPublishEndpoint for GrpcWebRtcPublishEndpointSpecImpl { fn p2p(&self) -> P2pMode { if self.0.has_p2p() { let p2p = self.0.get_p2p(); - match p2p { - WebRtcPublishEndpoint_P2P::ALWAYS => P2pMode::Always, - WebRtcPublishEndpoint_P2P::NEVER => P2pMode::Never, - WebRtcPublishEndpoint_P2P::IF_POSSIBLE => P2pMode::IfPossible, - } + P2pMode::from(p2p) } else { // TODO: do with me something unimplemented!() diff --git a/src/api/control/serde/endpoint.rs b/src/api/control/serde/endpoint.rs index c01837642..169dfaa2d 100644 --- a/src/api/control/serde/endpoint.rs +++ b/src/api/control/serde/endpoint.rs @@ -37,15 +37,6 @@ impl TryFrom<&Element> for SerdeEndpoint { } } -/// Peer-to-peer mode of [`WebRtcPublishEndpoint`]. -#[derive(Clone, Deserialize, Debug)] -pub enum P2pMode { - /// Always connect peer-to-peer. - Always, - Never, - IfPossible, -} - /// Media element which is able to publish media data for another client via /// WebRTC. #[allow(clippy::module_name_repetitions)] diff --git a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs index 9911de5eb..81e4850b7 100644 --- a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs @@ -8,7 +8,7 @@ use std::{ use hashbrown::HashSet; use crate::{ - api::control::serde::endpoint::P2pMode, media::PeerId, + api::control::model::endpoint::webrtc::P2pMode, media::PeerId, signalling::elements::Member, }; From 0e96f96d06c1c1fdba538e5735b56ba96ebc61cc Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 5 Jul 2019 12:37:52 +0300 Subject: [PATCH 258/735] gRPC client for creating new room --- src/bin/client.rs | 48 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 src/bin/client.rs diff --git a/src/bin/client.rs b/src/bin/client.rs new file mode 100644 index 000000000..03859ebb7 --- /dev/null +++ b/src/bin/client.rs @@ -0,0 +1,48 @@ +use medea::api::grpc::protos::control_grpc::ControlApiClient; +use medea::api::grpc::protos::control::{CreateRequest, Room, Member, WebRtcPlayEndpoint, WebRtcPublishEndpoint, Member_Element, WebRtcPublishEndpoint_P2P, Room_Element}; +use std::sync::Arc; +use grpcio::{EnvBuilder, ChannelBuilder}; +use std::collections::HashMap; + +fn main() { + let env = Arc::new(EnvBuilder::new().build()); + let ch = ChannelBuilder::new(env).connect("localhost:50051"); + let client = ControlApiClient::new(ch); + + let mut req = CreateRequest::new(); + let mut room = Room::new(); + let mut publisher = Member::new(); + let mut responder = Member::new(); + let mut play_endpoint = WebRtcPlayEndpoint::new(); + let mut publish_endpoint = WebRtcPublishEndpoint::new(); + + play_endpoint.set_src("local://grpc-test/publisher".to_string()); + let mut play_endpoint_element = Member_Element::new(); + play_endpoint_element.set_webrtc_play(play_endpoint); + let mut responder_pipeline = HashMap::new(); + responder_pipeline.insert("play".to_string(), play_endpoint_element); + responder.set_pipeline(responder_pipeline); + responder.set_credentials("test".to_string()); + + publish_endpoint.set_p2p(WebRtcPublishEndpoint_P2P::ALWAYS); + let mut publish_endpoint_element = Member_Element::new(); + publish_endpoint_element.set_webrtc_pub(publish_endpoint); + let mut publisher_pipeline = HashMap::new(); + publisher_pipeline.insert("publish".to_string(), publish_endpoint_element); + publisher.set_pipeline(publisher_pipeline); + publisher.set_credentials("test".to_string()); + + let mut publisher_member_element = Room_Element::new(); + publisher_member_element.set_member(publisher); + let mut responder_member_element = Room_Element::new(); + responder_member_element.set_member(responder); + let mut room_pipeline = HashMap::new(); + room_pipeline.insert("publisher".to_string(), publisher_member_element); + room_pipeline.insert("responder".to_string(), responder_member_element); + room.set_pipeline(room_pipeline); + req.set_room(room); + req.set_id("grpc-test".to_string()); + + let reply = client.create(&req).expect("rpc"); + println!("Receiver: {:?}", reply.get_sid()); +} From 0085fab57ecf50e9a1a3818fb526bb52c0ff0300 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 5 Jul 2019 13:10:04 +0300 Subject: [PATCH 259/735] Tmp --- src/api/grpc/server.rs | 22 +++++++++------------ src/main.rs | 7 +++++-- src/signalling/room_repo.rs | 38 ++++++++++++++++++++++++++++++++++++- 3 files changed, 51 insertions(+), 16 deletions(-) diff --git a/src/api/grpc/server.rs b/src/api/grpc/server.rs index 9cd1cac76..2e2b7ab1d 100644 --- a/src/api/grpc/server.rs +++ b/src/api/grpc/server.rs @@ -20,10 +20,11 @@ use crate::{ }; use super::protos::control_grpc::{create_control_api, ControlApi}; +use crate::signalling::room_repo::StartRoom; #[derive(Clone)] struct ControlApiService { - room_repository: RoomsRepository, + room_repository: Addr, config: Conf, } @@ -37,20 +38,15 @@ impl ControlApi for ControlApiService { // TODO let room_id = RoomId(req.get_id().to_string()); - let room = Room::start_in_arbiter(&Arbiter::new(), |_| { - let room_spec = CreateRequestSpec(req); - let room_spec = Box::new(&room_spec as &RoomSpec); + let msg = StartRoom { + room: CreateRequestSpec(req) + }; - let turn_auth_service = - crate::turn::service::new_turn_auth_service(&Conf::default()) - .expect("Unable to start turn service"); - Room::new(&room_spec, Duration::from_secs(10), turn_auth_service) - .unwrap() - }); + self.room_repository.do_send(msg); - self.room_repository.add(room_id, room); +// self.room_repository.add(room_id, room); - debug!("{:?}", self.room_repository); + //debug!("{:?}", self.room_repository); } fn apply( @@ -100,7 +96,7 @@ impl Actor for GrpcServer { } } -pub fn run(room_repo: RoomsRepository, conf: Conf) -> Addr { +pub fn run(room_repo: Addr, conf: Conf) -> Addr { let bind_ip = conf.grpc.bind_ip.clone().to_string(); let bind_port = conf.grpc.bind_port; let cq_count = conf.grpc.completion_queue_count; diff --git a/src/main.rs b/src/main.rs index bf9b914ee..acafe9898 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,4 @@ -use actix::System; +use actix::{System, Arbiter, Actor as _}; use failure::Error; use medea::{ api::client::server, @@ -28,7 +28,10 @@ fn main() -> Result<(), Error> { ); let room_repo = RoomsRepository::new(rooms); server::run(room_repo.clone(), config.clone()); - let _addr = grpc::server::run(room_repo, config); + let room_repo_addr = RoomsRepository::start_in_arbiter(&Arbiter::new(), move |_| { + room_repo + }); + let _addr = grpc::server::run(room_repo_addr, config); let _ = sys.run(); diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs index 526b4700a..a5c3cec33 100644 --- a/src/signalling/room_repo.rs +++ b/src/signalling/room_repo.rs @@ -2,10 +2,13 @@ use std::sync::{Arc, Mutex}; -use actix::Addr; +use actix::{Addr, Actor, Context, Message, Handler, Arbiter}; use hashbrown::HashMap; use crate::{api::control::model::RoomId, signalling::Room}; +use crate::api::control::model::room::RoomSpec; +use crate::conf::Conf; +use std::time::Duration; /// Repository that stores [`Room`]s addresses. #[derive(Clone, Default, Debug)] @@ -37,3 +40,36 @@ impl RoomsRepository { self.rooms.lock().unwrap().insert(id, room); } } + +impl Actor for RoomsRepository { + type Context = Context; +} + + +#[derive(Message)] +#[rtype(result = "()")] +pub struct StartRoom { + pub room: T, +} + +impl Handler> for RoomsRepository { + type Result = (); + + fn handle(&mut self, msg: StartRoom, ctx: &mut Self::Context) -> Self::Result { + let room_id = msg.room.id(); + + let turn_auth_service = + crate::turn::service::new_turn_auth_service(&Conf::default()) + .expect("Unable to start turn service"); + let room = Room::start_in_arbiter(&Arbiter::new(), move |_| { + let room = msg.room; + let room = Box::new(&room as &(RoomSpec)); + Room::new(&room, Duration::from_secs(10), turn_auth_service) + .unwrap() + }); + + self.rooms.lock().unwrap().insert(room_id, room); + } +} + + From 1fc51b4ea2f0cc7b8befc6708f7321855cc2aa34 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 5 Jul 2019 13:31:19 +0300 Subject: [PATCH 260/735] Fix starting new room --- src/bin/client.rs | 2 +- src/signalling/room_repo.rs | 9 ++++++--- src/turn/service.rs | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/bin/client.rs b/src/bin/client.rs index 03859ebb7..5eef497fa 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -16,7 +16,7 @@ fn main() { let mut play_endpoint = WebRtcPlayEndpoint::new(); let mut publish_endpoint = WebRtcPublishEndpoint::new(); - play_endpoint.set_src("local://grpc-test/publisher".to_string()); + play_endpoint.set_src("local://grpc-test/publisher/publish".to_string()); let mut play_endpoint_element = Member_Element::new(); play_endpoint_element.set_webrtc_play(play_endpoint); let mut responder_pipeline = HashMap::new(); diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs index a5c3cec33..c49ebd83b 100644 --- a/src/signalling/room_repo.rs +++ b/src/signalling/room_repo.rs @@ -58,9 +58,12 @@ impl Handler> for RoomsRepository { fn handle(&mut self, msg: StartRoom, ctx: &mut Self::Context) -> Self::Result { let room_id = msg.room.id(); - let turn_auth_service = - crate::turn::service::new_turn_auth_service(&Conf::default()) - .expect("Unable to start turn service"); + // TODO: don't use mock turn!!!! +// let turn_auth_service = +// crate::turn::service::new_turn_auth_service(&Conf::default()) +// .expect("Unable to start turn service"); + + let turn_auth_service = crate::turn::service::test::new_turn_auth_service_mock(); let room = Room::start_in_arbiter(&Arbiter::new(), move |_| { let room = msg.room; let room = Box::new(&room as &(RoomSpec)); diff --git a/src/turn/service.rs b/src/turn/service.rs index 3f11d681a..2c3bb02bd 100644 --- a/src/turn/service.rs +++ b/src/turn/service.rs @@ -276,7 +276,7 @@ impl Handler for Service { } } -#[cfg(test)] +// TODO: add cfg[test] here pub mod test { use futures::future; From 30b26b959d8cbd058a38ea0ecaa4563868799dd9 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 5 Jul 2019 13:34:52 +0300 Subject: [PATCH 261/735] Fix Makefile --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 9b90e4b83..2cfe45567 100644 --- a/Makefile +++ b/Makefile @@ -166,7 +166,7 @@ ifeq ($(dockerized),no) @make down.medea dockerized=no cargo build $(if $(call eq,$(release),yes),--release) - env $(medea-env) $(if $(call eq,$(logs),yes),,RUST_LOG=warn) cargo run $(if $(call eq,$(release),yes),--release) & + env $(medea-env) $(if $(call eq,$(logs),yes),,RUST_LOG=warn) cargo run --bin medea $(if $(call eq,$(release),yes),--release) & sleep 1 - cargo test --test e2e From fd476354fd2c055a4003a9774708fdfd0159cc02 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 5 Jul 2019 14:29:00 +0300 Subject: [PATCH 262/735] Add App, use real turn service in dynamic creating room --- src/api/grpc/server.rs | 13 +++++++------ src/lib.rs | 30 +++++++++++++++++++++++++----- src/main.rs | 9 ++++++--- src/signalling/participants.rs | 5 +++-- src/signalling/room.rs | 4 ++-- src/signalling/room_repo.rs | 11 +++++++---- src/turn/service.rs | 2 +- 7 files changed, 51 insertions(+), 23 deletions(-) diff --git a/src/api/grpc/server.rs b/src/api/grpc/server.rs index 2e2b7ab1d..2c7b6d11e 100644 --- a/src/api/grpc/server.rs +++ b/src/api/grpc/server.rs @@ -17,6 +17,7 @@ use crate::{ conf::Conf, log::prelude::*, signalling::{room_repo::RoomsRepository, Room}, + App, }; use super::protos::control_grpc::{create_control_api, ControlApi}; @@ -25,7 +26,7 @@ use crate::signalling::room_repo::StartRoom; #[derive(Clone)] struct ControlApiService { room_repository: Addr, - config: Conf, + config: Arc, } impl ControlApi for ControlApiService { @@ -96,13 +97,13 @@ impl Actor for GrpcServer { } } -pub fn run(room_repo: Addr, conf: Conf) -> Addr { - let bind_ip = conf.grpc.bind_ip.clone().to_string(); - let bind_port = conf.grpc.bind_port; - let cq_count = conf.grpc.completion_queue_count; +pub fn run(room_repo: Addr, app: Arc) -> Addr { + let bind_ip = app.config.grpc.bind_ip.clone().to_string(); + let bind_port = app.config.grpc.bind_port; + let cq_count = app.config.grpc.completion_queue_count; let service = create_control_api(ControlApiService { - config: conf, + config: app, room_repository: room_repo, }); let env = Arc::new(Environment::new(cq_count)); diff --git a/src/lib.rs b/src/lib.rs index fca4de90e..e7edb9415 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -23,6 +23,26 @@ use crate::{ turn::service, }; +use crate::turn::TurnAuthService; +use std::sync::Arc; + +#[derive(Debug)] +pub struct App { + config: Conf, + turn_service: Arc>, +} + +impl App { + pub fn new(config: Conf) -> Self { + let turn_auth_service = crate::turn::service::new_turn_auth_service(&config) + .expect("Unable to start turn service"); + Self { + config, + turn_service: Arc::new(turn_auth_service), + } + } +} + /// Errors which can happen while server starting. #[derive(Debug, Fail)] pub enum ServerStartError { @@ -62,9 +82,9 @@ impl From for ServerStartError { /// Returns [`ServerStartError::BadRoomSpec`] /// if some error happened while creating room from spec. pub fn start_static_rooms( - config: &Conf, + app: Arc, ) -> Result>, ServerStartError> { - if let Some(static_specs_path) = &config.server.static_specs_path { + if let Some(static_specs_path) = &app.config.server.static_specs_path { let room_specs = match load_static_specs_from_dir(static_specs_path) { Ok(r) => r, Err(e) => return Err(ServerStartError::LoadSpec(e)), @@ -79,18 +99,18 @@ pub fn start_static_rooms( )); } - let turn_auth_service = service::new_turn_auth_service(&config) + let turn_auth_service = service::new_turn_auth_service(&app.config) .expect("Unable to start turn service"); let room_id = spec.id().clone(); - let rpc_reconnect_timeout = config.rpc.reconnect_timeout; + let rpc_reconnect_timeout = app.config.rpc.reconnect_timeout; let room = Room::start_in_arbiter(&arbiter, move |_| { let parsed_spec = SerdeRoomSpecImpl::new(&spec).unwrap(); let parsed_spec = Box::new(&parsed_spec as &RoomSpec); Room::new( &parsed_spec, rpc_reconnect_timeout, - turn_auth_service, + Arc::new(turn_auth_service), // TODO: tmp ) .unwrap() }); diff --git a/src/main.rs b/src/main.rs index acafe9898..085c9726e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,6 +9,8 @@ use medea::{ }; use medea::api::grpc; +use medea::App; +use std::sync::Arc; fn main() -> Result<(), Error> { dotenv::dotenv().ok(); @@ -20,18 +22,19 @@ fn main() -> Result<(), Error> { let config = Conf::parse()?; info!("{:?}", config); + let app = Arc::new(App::new(config.clone())); - let rooms = start_static_rooms(&config)?; + let rooms = start_static_rooms(Arc::clone(&app))?; info!( "Loaded rooms: {:?}", rooms.iter().map(|(id, _)| &id.0).collect::>() ); - let room_repo = RoomsRepository::new(rooms); + let room_repo = RoomsRepository::new(rooms, Arc::clone(&app)); server::run(room_repo.clone(), config.clone()); let room_repo_addr = RoomsRepository::start_in_arbiter(&Arbiter::new(), move |_| { room_repo }); - let _addr = grpc::server::run(room_repo_addr, config); + let _addr = grpc::server::run(room_repo_addr, app); let _ = sys.run(); diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 9bf129b8a..ea9fc146f 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -37,6 +37,7 @@ use crate::{ }, turn::{TurnAuthService, TurnServiceErr, UnreachablePolicy}, }; +use std::sync::Arc; #[derive(Fail, Debug)] #[allow(clippy::module_name_repetitions)] @@ -76,7 +77,7 @@ pub struct ParticipantService { members: HashMap>, /// Service for managing authorization on Turn server. - turn: Box, + turn: Arc>, /// Established [`RpcConnection`]s of [`Members`]s in this [`Room`]. // TODO: Replace Box> with enum, @@ -98,7 +99,7 @@ impl ParticipantService { pub fn new( room_spec: &Box<&dyn RoomSpec>, reconnect_timeout: Duration, - turn: Box, + turn: Arc>, ) -> Result { Ok(Self { room_id: room_spec.id().clone(), diff --git a/src/signalling/room.rs b/src/signalling/room.rs index f61fe32e7..e03ac0fdd 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -1,7 +1,7 @@ //! Room definitions and implementations. Room is responsible for media //! connection establishment between concrete [`Member`]s. -use std::{rc::Rc, time::Duration}; +use std::{rc::Rc, time::Duration, sync::Arc}; use actix::{ fut::wrap_future, Actor, ActorFuture, AsyncContext, Context, Handler, @@ -108,7 +108,7 @@ impl Room { pub fn new( room_spec: &Box<&dyn RoomSpec>, reconnect_timeout: Duration, - turn: Box, + turn: Arc>, ) -> Result { Ok(Self { id: room_spec.id().clone(), diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs index c49ebd83b..d4b546669 100644 --- a/src/signalling/room_repo.rs +++ b/src/signalling/room_repo.rs @@ -9,20 +9,23 @@ use crate::{api::control::model::RoomId, signalling::Room}; use crate::api::control::model::room::RoomSpec; use crate::conf::Conf; use std::time::Duration; +use crate::App; /// Repository that stores [`Room`]s addresses. -#[derive(Clone, Default, Debug)] +#[derive(Clone, Debug)] pub struct RoomsRepository { // TODO: Use crossbeam's concurrent hashmap when its done. // [Tracking](https://github.com/crossbeam-rs/rfcs/issues/32). rooms: Arc>>>, + app: Arc, } impl RoomsRepository { /// Creates new [`Room`]s repository with passed-in [`Room`]s. - pub fn new(rooms: HashMap>) -> Self { + pub fn new(rooms: HashMap>, app: Arc) -> Self { Self { rooms: Arc::new(Mutex::new(rooms)), + app, } } @@ -62,12 +65,12 @@ impl Handler> for RoomsRepository { // let turn_auth_service = // crate::turn::service::new_turn_auth_service(&Conf::default()) // .expect("Unable to start turn service"); + let turn = Arc::clone(&self.app.turn_service); - let turn_auth_service = crate::turn::service::test::new_turn_auth_service_mock(); let room = Room::start_in_arbiter(&Arbiter::new(), move |_| { let room = msg.room; let room = Box::new(&room as &(RoomSpec)); - Room::new(&room, Duration::from_secs(10), turn_auth_service) + Room::new(&room, Duration::from_secs(10), turn) .unwrap() }); diff --git a/src/turn/service.rs b/src/turn/service.rs index 2c3bb02bd..4bd19777f 100644 --- a/src/turn/service.rs +++ b/src/turn/service.rs @@ -154,7 +154,7 @@ struct Service { #[allow(clippy::module_name_repetitions)] pub fn new_turn_auth_service( config: &Conf, -) -> Result, TurnServiceErr> { +) -> Result, TurnServiceErr> { let turn_db = TurnDatabase::new( config.turn.db.redis.connection_timeout, ConnectionInfo { From 3937138ac31a65aa9e2b9778c6a990ad411379a9 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 5 Jul 2019 14:55:52 +0300 Subject: [PATCH 263/735] Add response to Create new room --- src/api/grpc/server.rs | 32 +++++++++++++++++++++++++++----- src/signalling/room_repo.rs | 3 ++- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/src/api/grpc/server.rs b/src/api/grpc/server.rs index 2c7b6d11e..e7035a1ce 100644 --- a/src/api/grpc/server.rs +++ b/src/api/grpc/server.rs @@ -22,19 +22,20 @@ use crate::{ use super::protos::control_grpc::{create_control_api, ControlApi}; use crate::signalling::room_repo::StartRoom; +use std::collections::HashMap; #[derive(Clone)] struct ControlApiService { room_repository: Addr, - config: Arc, + app: Arc, } impl ControlApi for ControlApiService { fn create( &mut self, - _ctx: RpcContext, + ctx: RpcContext, req: CreateRequest, - _sink: UnarySink, + sink: UnarySink, ) { // TODO let room_id = RoomId(req.get_id().to_string()); @@ -43,7 +44,28 @@ impl ControlApi for ControlApiService { room: CreateRequestSpec(req) }; - self.room_repository.do_send(msg); + + let sid: HashMap = msg.room.members().iter() + .map(|(id, member)| { + let addr = &self.app.config.server.bind_ip; + let port = self.app.config.server.bind_port; + let base_uri = format!("{}:{}", addr, port); + + let uri = format!("wss://{}/{}/{}/{}", base_uri, &room_id, id, member.credentials()); + + (id.clone().to_string(), uri) + }) + .collect(); + + ctx.spawn(self.room_repository.send(msg) + .map_err(|e| ()) + .and_then(move |_| { + let mut res = Response::new(); + res.set_sid(sid); + sink.success(res) + .map_err(|_| ()) + }) + ); // self.room_repository.add(room_id, room); @@ -103,7 +125,7 @@ pub fn run(room_repo: Addr, app: Arc) -> Addr let cq_count = app.config.grpc.completion_queue_count; let service = create_control_api(ControlApiService { - config: app, + app: app, room_repository: room_repo, }); let env = Arc::new(Environment::new(cq_count)); diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs index d4b546669..1523f36eb 100644 --- a/src/signalling/room_repo.rs +++ b/src/signalling/room_repo.rs @@ -1,6 +1,7 @@ //! Repository that stores [`Room`]s addresses. use std::sync::{Arc, Mutex}; +use std::collections::HashMap as StdHashMap; use actix::{Addr, Actor, Context, Message, Handler, Arbiter}; use hashbrown::HashMap; @@ -48,7 +49,7 @@ impl Actor for RoomsRepository { type Context = Context; } - +// TODO: return sids. #[derive(Message)] #[rtype(result = "()")] pub struct StartRoom { From f5cb360032e190813f442cf6ec3f3d24bf1e569a Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 5 Jul 2019 15:00:22 +0300 Subject: [PATCH 264/735] Fmt --- src/api/grpc/server.rs | 37 +++++++++++++++++++++++-------------- src/bin/client.rs | 14 +++++++++----- src/lib.rs | 5 +++-- src/main.rs | 10 ++++------ src/signalling/room.rs | 2 +- src/signalling/room_repo.rs | 33 +++++++++++++++++---------------- 6 files changed, 57 insertions(+), 44 deletions(-) diff --git a/src/api/grpc/server.rs b/src/api/grpc/server.rs index e7035a1ce..9194ec2ff 100644 --- a/src/api/grpc/server.rs +++ b/src/api/grpc/server.rs @@ -41,35 +41,41 @@ impl ControlApi for ControlApiService { let room_id = RoomId(req.get_id().to_string()); let msg = StartRoom { - room: CreateRequestSpec(req) + room: CreateRequestSpec(req), }; - - let sid: HashMap = msg.room.members().iter() + let sid: HashMap = msg + .room + .members() + .iter() .map(|(id, member)| { let addr = &self.app.config.server.bind_ip; let port = self.app.config.server.bind_port; let base_uri = format!("{}:{}", addr, port); - let uri = format!("wss://{}/{}/{}/{}", base_uri, &room_id, id, member.credentials()); + let uri = format!( + "wss://{}/{}/{}/{}", + base_uri, + &room_id, + id, + member.credentials() + ); (id.clone().to_string(), uri) }) .collect(); - ctx.spawn(self.room_repository.send(msg) - .map_err(|e| ()) - .and_then(move |_| { + ctx.spawn(self.room_repository.send(msg).map_err(|e| ()).and_then( + move |_| { let mut res = Response::new(); res.set_sid(sid); - sink.success(res) - .map_err(|_| ()) - }) - ); + sink.success(res).map_err(|_| ()) + }, + )); -// self.room_repository.add(room_id, room); + // self.room_repository.add(room_id, room); - //debug!("{:?}", self.room_repository); + // debug!("{:?}", self.room_repository); } fn apply( @@ -119,7 +125,10 @@ impl Actor for GrpcServer { } } -pub fn run(room_repo: Addr, app: Arc) -> Addr { +pub fn run( + room_repo: Addr, + app: Arc, +) -> Addr { let bind_ip = app.config.grpc.bind_ip.clone().to_string(); let bind_port = app.config.grpc.bind_port; let cq_count = app.config.grpc.completion_queue_count; diff --git a/src/bin/client.rs b/src/bin/client.rs index 5eef497fa..9bde035be 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -1,8 +1,12 @@ -use medea::api::grpc::protos::control_grpc::ControlApiClient; -use medea::api::grpc::protos::control::{CreateRequest, Room, Member, WebRtcPlayEndpoint, WebRtcPublishEndpoint, Member_Element, WebRtcPublishEndpoint_P2P, Room_Element}; -use std::sync::Arc; -use grpcio::{EnvBuilder, ChannelBuilder}; -use std::collections::HashMap; +use grpcio::{ChannelBuilder, EnvBuilder}; +use medea::api::grpc::protos::{ + control::{ + CreateRequest, Member, Member_Element, Room, Room_Element, + WebRtcPlayEndpoint, WebRtcPublishEndpoint, WebRtcPublishEndpoint_P2P, + }, + control_grpc::ControlApiClient, +}; +use std::{collections::HashMap, sync::Arc}; fn main() { let env = Arc::new(EnvBuilder::new().build()); diff --git a/src/lib.rs b/src/lib.rs index e7edb9415..90064164d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -34,8 +34,9 @@ pub struct App { impl App { pub fn new(config: Conf) -> Self { - let turn_auth_service = crate::turn::service::new_turn_auth_service(&config) - .expect("Unable to start turn service"); + let turn_auth_service = + crate::turn::service::new_turn_auth_service(&config) + .expect("Unable to start turn service"); Self { config, turn_service: Arc::new(turn_auth_service), diff --git a/src/main.rs b/src/main.rs index 085c9726e..9b3bf008d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,4 @@ -use actix::{System, Arbiter, Actor as _}; +use actix::{Actor as _, Arbiter, System}; use failure::Error; use medea::{ api::client::server, @@ -8,8 +8,7 @@ use medea::{ start_static_rooms, }; -use medea::api::grpc; -use medea::App; +use medea::{api::grpc, App}; use std::sync::Arc; fn main() -> Result<(), Error> { @@ -31,9 +30,8 @@ fn main() -> Result<(), Error> { ); let room_repo = RoomsRepository::new(rooms, Arc::clone(&app)); server::run(room_repo.clone(), config.clone()); - let room_repo_addr = RoomsRepository::start_in_arbiter(&Arbiter::new(), move |_| { - room_repo - }); + let room_repo_addr = + RoomsRepository::start_in_arbiter(&Arbiter::new(), move |_| room_repo); let _addr = grpc::server::run(room_repo_addr, app); let _ = sys.run(); diff --git a/src/signalling/room.rs b/src/signalling/room.rs index e03ac0fdd..66b00d6a4 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -1,7 +1,7 @@ //! Room definitions and implementations. Room is responsible for media //! connection establishment between concrete [`Member`]s. -use std::{rc::Rc, time::Duration, sync::Arc}; +use std::{rc::Rc, sync::Arc, time::Duration}; use actix::{ fut::wrap_future, Actor, ActorFuture, AsyncContext, Context, Handler, diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs index 1523f36eb..073d1de96 100644 --- a/src/signalling/room_repo.rs +++ b/src/signalling/room_repo.rs @@ -1,16 +1,20 @@ //! Repository that stores [`Room`]s addresses. -use std::sync::{Arc, Mutex}; -use std::collections::HashMap as StdHashMap; +use std::{ + collections::HashMap as StdHashMap, + sync::{Arc, Mutex}, +}; -use actix::{Addr, Actor, Context, Message, Handler, Arbiter}; +use actix::{Actor, Addr, Arbiter, Context, Handler, Message}; use hashbrown::HashMap; -use crate::{api::control::model::RoomId, signalling::Room}; -use crate::api::control::model::room::RoomSpec; -use crate::conf::Conf; +use crate::{ + api::control::model::{room::RoomSpec, RoomId}, + conf::Conf, + signalling::Room, + App, +}; use std::time::Duration; -use crate::App; /// Repository that stores [`Room`]s addresses. #[derive(Clone, Debug)] @@ -59,24 +63,21 @@ pub struct StartRoom { impl Handler> for RoomsRepository { type Result = (); - fn handle(&mut self, msg: StartRoom, ctx: &mut Self::Context) -> Self::Result { + fn handle( + &mut self, + msg: StartRoom, + ctx: &mut Self::Context, + ) -> Self::Result { let room_id = msg.room.id(); - // TODO: don't use mock turn!!!! -// let turn_auth_service = -// crate::turn::service::new_turn_auth_service(&Conf::default()) -// .expect("Unable to start turn service"); let turn = Arc::clone(&self.app.turn_service); let room = Room::start_in_arbiter(&Arbiter::new(), move |_| { let room = msg.room; let room = Box::new(&room as &(RoomSpec)); - Room::new(&room, Duration::from_secs(10), turn) - .unwrap() + Room::new(&room, Duration::from_secs(10), turn).unwrap() }); self.rooms.lock().unwrap().insert(room_id, room); } } - - From c38a2b1bd43539be7f149870caf9c1e9f0a7e650 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 5 Jul 2019 15:15:00 +0300 Subject: [PATCH 265/735] Fix tests --- src/api/client/server.rs | 17 ++++++++++++----- src/lib.rs | 16 ++-------------- src/main.rs | 7 +++++-- src/turn/service.rs | 3 ++- 4 files changed, 21 insertions(+), 22 deletions(-) diff --git a/src/api/client/server.rs b/src/api/client/server.rs index f729e70cd..66677d58c 100644 --- a/src/api/client/server.rs +++ b/src/api/client/server.rs @@ -127,22 +127,29 @@ mod test { use crate::api::control::{ model::room::RoomSpec, serde::room::SerdeRoomSpecImpl, }; + use std::sync::Arc; /// Creates [`RoomsRepository`] for tests filled with a single [`Room`]. - fn room(conf: Rpc) -> RoomsRepository { + fn room(conf: Conf) -> RoomsRepository { let room_spec = control::serde::load_from_yaml_file( "tests/specs/pub_sub_video_call.yml", ) .unwrap(); + let app = Arc::new(crate::App { + config: conf, + turn_service: Arc::new(new_turn_auth_service_mock()), + }); + let app_cloned = Arc::clone(&app); + let room_id = room_spec.id.clone(); let client_room = Room::start_in_arbiter(&Arbiter::new(), move |_| { let room_spec = SerdeRoomSpecImpl::new(&room_spec).unwrap(); let room_spec = Box::new(&room_spec as &RoomSpec); let client_room = Room::new( &room_spec, - conf.reconnect_timeout, - new_turn_auth_service_mock(), + app.config.rpc.reconnect_timeout, + Arc::new(new_turn_auth_service_mock()), ) .unwrap(); client_room @@ -151,7 +158,7 @@ mod test { room_id => client_room, }; - RoomsRepository::new(room_hash_map) + RoomsRepository::new(room_hash_map, app_cloned) } /// Creates test WebSocket server of Client API which can handle requests. @@ -160,7 +167,7 @@ mod test { HttpService::new( App::new() .data(Context { - rooms: room(conf.rpc.clone()), + rooms: room(conf.clone()), config: conf.rpc.clone(), }) .service( diff --git a/src/lib.rs b/src/lib.rs index 90064164d..95eec0bff 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -28,20 +28,8 @@ use std::sync::Arc; #[derive(Debug)] pub struct App { - config: Conf, - turn_service: Arc>, -} - -impl App { - pub fn new(config: Conf) -> Self { - let turn_auth_service = - crate::turn::service::new_turn_auth_service(&config) - .expect("Unable to start turn service"); - Self { - config, - turn_service: Arc::new(turn_auth_service), - } - } + pub config: Conf, + pub turn_service: Arc>, } /// Errors which can happen while server starting. diff --git a/src/main.rs b/src/main.rs index 9b3bf008d..4be11d51e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,7 +8,7 @@ use medea::{ start_static_rooms, }; -use medea::{api::grpc, App}; +use medea::{api::grpc, turn::new_turn_auth_service, App}; use std::sync::Arc; fn main() -> Result<(), Error> { @@ -21,7 +21,10 @@ fn main() -> Result<(), Error> { let config = Conf::parse()?; info!("{:?}", config); - let app = Arc::new(App::new(config.clone())); + let app = Arc::new(App { + config: config.clone(), + turn_service: Arc::new(new_turn_auth_service(&config).unwrap()), + }); let rooms = start_static_rooms(Arc::clone(&app))?; info!( diff --git a/src/turn/service.rs b/src/turn/service.rs index 4bd19777f..5d30f2201 100644 --- a/src/turn/service.rs +++ b/src/turn/service.rs @@ -310,7 +310,8 @@ pub mod test { } #[allow(clippy::module_name_repetitions)] - pub fn new_turn_auth_service_mock() -> Box { + pub fn new_turn_auth_service_mock() -> Box + { Box::new(TurnAuthServiceMock {}) } From d4230f621e3805afa023f20515d529366092ced5 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 5 Jul 2019 16:55:50 +0300 Subject: [PATCH 266/735] Bad error handling for creating room --- src/api/grpc/server.rs | 24 +++++++++++++++++++----- src/bin/client.rs | 6 +++++- src/signalling/room_repo.rs | 12 +++++++++--- 3 files changed, 33 insertions(+), 9 deletions(-) diff --git a/src/api/grpc/server.rs b/src/api/grpc/server.rs index 9194ec2ff..fdefbad0a 100644 --- a/src/api/grpc/server.rs +++ b/src/api/grpc/server.rs @@ -21,7 +21,10 @@ use crate::{ }; use super::protos::control_grpc::{create_control_api, ControlApi}; -use crate::signalling::room_repo::StartRoom; +use crate::{ + api::grpc::protos::control::Error, signalling::room_repo::StartRoom, +}; +use futures::future::Either; use std::collections::HashMap; #[derive(Clone)] @@ -66,10 +69,21 @@ impl ControlApi for ControlApiService { .collect(); ctx.spawn(self.room_repository.send(msg).map_err(|e| ()).and_then( - move |_| { - let mut res = Response::new(); - res.set_sid(sid); - sink.success(res).map_err(|_| ()) + move |r| { + if r.is_ok() { + let mut res = Response::new(); + res.set_sid(sid); + Either::A(sink.success(res).map_err(|_| ())) + } else { + let mut res = Response::new(); + let mut error = Error::new(); + error.set_status(500); + error.set_code(500); + error.set_text(String::new()); + error.set_element(String::new()); + res.set_error(error); + Either::B(sink.success(res).map_err(|_| ())) + } }, )); diff --git a/src/bin/client.rs b/src/bin/client.rs index 9bde035be..d674a17d8 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -48,5 +48,9 @@ fn main() { req.set_id("grpc-test".to_string()); let reply = client.create(&req).expect("rpc"); - println!("Receiver: {:?}", reply.get_sid()); + if reply.has_error() { + println!("Error: {:?}", reply.get_error()); + } else { + println!("Receiver: {:?}", reply.get_sid()); + } } diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs index 073d1de96..dfb5e288a 100644 --- a/src/signalling/room_repo.rs +++ b/src/signalling/room_repo.rs @@ -11,7 +11,7 @@ use hashbrown::HashMap; use crate::{ api::control::model::{room::RoomSpec, RoomId}, conf::Conf, - signalling::Room, + signalling::{room::RoomError, Room}, App, }; use std::time::Duration; @@ -55,13 +55,13 @@ impl Actor for RoomsRepository { // TODO: return sids. #[derive(Message)] -#[rtype(result = "()")] +#[rtype(result = "Result<(), RoomError>")] pub struct StartRoom { pub room: T, } impl Handler> for RoomsRepository { - type Result = (); + type Result = Result<(), RoomError>; fn handle( &mut self, @@ -72,6 +72,11 @@ impl Handler> for RoomsRepository { let turn = Arc::clone(&self.app.turn_service); + { + let room = Box::new(&msg.room as &(RoomSpec)); + Room::new(&room, Duration::from_secs(10), Arc::clone(&turn))?; + } + let room = Room::start_in_arbiter(&Arbiter::new(), move |_| { let room = msg.room; let room = Box::new(&room as &(RoomSpec)); @@ -79,5 +84,6 @@ impl Handler> for RoomsRepository { }); self.rooms.lock().unwrap().insert(room_id, room); + Ok(()) } } From a33df44bc86da87f265b1f91335cd436ab8e01ba Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 5 Jul 2019 18:00:11 +0300 Subject: [PATCH 267/735] Add Delete room --- src/api/control/model/local_uri.rs | 210 +++++++++++++++++++++++++++++ src/api/control/model/mod.rs | 1 + src/api/grpc/server.rs | 24 +++- src/bin/client.rs | 11 +- src/signalling/room_repo.rs | 24 +++- 5 files changed, 263 insertions(+), 7 deletions(-) create mode 100644 src/api/control/model/local_uri.rs diff --git a/src/api/control/model/local_uri.rs b/src/api/control/model/local_uri.rs new file mode 100644 index 000000000..3e3da86d2 --- /dev/null +++ b/src/api/control/model/local_uri.rs @@ -0,0 +1,210 @@ +use std::fmt; + +use failure::Fail; +use macro_attr::*; +use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; +use serde::{ + de::{self, Deserializer, Error, Unexpected, Visitor}, + Deserialize, +}; + +use super::{MemberId, RoomId, WebRtcPublishId}; + +// TODO: Move into endpoint module and implement From<...Pub...> +// From<...Play...>. +macro_attr! { + /// ID of [`Room`]. + #[derive( + Clone, + Debug, + Deserialize, + Eq, + Hash, + PartialEq, + NewtypeFrom!, + NewtypeDisplay!, + )] + pub struct EndpointId(pub String); +} + +/// Special uri with pattern `local://{room_id}/{member_id}/{endpoint_id}`. +#[derive(Clone, Debug)] +// TODO: combine with SrcUri. +pub struct LocalUri { + /// ID of [`Room`] + pub room_id: Option, + /// ID of `Member` + pub member_id: Option, + /// Control ID of [`Endpoint`] + pub endpoint_id: Option, +} + +impl LocalUri { + pub fn is_room_id(&self) -> bool { + self.room_id.is_some() + && self.member_id.is_none() + && self.endpoint_id.is_none() + } + + pub fn is_member_id(&self) -> bool { + self.room_id.is_some() + && self.member_id.is_some() + && self.endpoint_id.is_none() + } + + pub fn is_endpoint_id(&self) -> bool { + self.room_id.is_some() + && self.member_id.is_some() + && self.endpoint_id.is_some() + } +} + +#[derive(Debug, Fail)] +pub enum ParseError { + #[fail(display = "Too many fields")] + TooManyFields, + #[fail(display = "Not local uri. {}", _0)] + NotLocalUri(String), +} + +pub fn parse_local_uri(text: &str) -> Result { + let protocol_name: String = text.chars().take(8).collect(); + if protocol_name != "local://" { + return Err(ParseError::NotLocalUri(protocol_name)); + } + + let uri_body = text.chars().skip(8).collect::(); + let mut uri_body_splitted: Vec<&str> = uri_body.rsplit('/').collect(); + let uri_body_splitted_len = uri_body_splitted.len(); + + if uri_body_splitted_len == 1 { + return Ok(LocalUri { + room_id: Some(RoomId(uri_body_splitted.pop().unwrap().to_string())), + member_id: None, + endpoint_id: None, + }); + } else if uri_body_splitted_len == 2 { + return Ok(LocalUri { + room_id: Some(RoomId(uri_body_splitted.pop().unwrap().to_string())), + member_id: Some(MemberId( + uri_body_splitted.pop().unwrap().to_string(), + )), + endpoint_id: None, + }); + } else if uri_body_splitted_len == 3 { + return Ok(LocalUri { + room_id: Some(RoomId(uri_body_splitted.pop().unwrap().to_string())), + member_id: Some(MemberId( + uri_body_splitted.pop().unwrap().to_string(), + )), + endpoint_id: Some(EndpointId( + uri_body_splitted.pop().unwrap().to_string(), + )), + }); + } else { + return Err(ParseError::TooManyFields); + } +} + +/// Serde deserializer for [`SrcUri`]. +/// Deserialize URIs with pattern `local://{room_id}/{member_id}/{endpoint_id}`. +impl<'de> Deserialize<'de> for LocalUri { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct SrcUriVisitor; + + impl<'de> Visitor<'de> for SrcUriVisitor { + type Value = LocalUri; + + fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str( + "Uri in format local://room_id/member_id/endpoint_id", + ) + } + + fn visit_str(self, value: &str) -> Result + where + E: de::Error, + { + match parse_local_uri(value) { + Ok(uri) => return Ok(uri), + Err(e) => match e { + ParseError::NotLocalUri(protocol_name) => { + Err(Error::invalid_value( + Unexpected::Str(&format!( + "{} in {}", + protocol_name, value + )), + &self, + )) + } + ParseError::TooManyFields => { + Err(Error::custom("Too many fields.")) + } + }, + } + } + } + + deserializer.deserialize_identifier(SrcUriVisitor) + } +} + +#[cfg(test)] +mod src_uri_deserialization_tests { + use serde::Deserialize; + + use super::*; + + #[derive(Deserialize)] + struct SrcUriTest { + src: LocalUri, + } + + #[inline] + fn id>(s: &str) -> T { + T::from(s.to_string()) + } + + #[test] + fn deserialize() { + let valid_json_uri = + r#"{ "src": "local://room_id/member_id/endpoint_id" }"#; + let local_uri: SrcUriTest = + serde_json::from_str(valid_json_uri).unwrap(); + + assert_eq!(local_uri.src.member_id, id("member_id")); + assert_eq!(local_uri.src.room_id, id("room_id")); + assert_eq!(local_uri.src.endpoint_id, id("endpoint_id")); + } + + #[test] + fn return_error_when_uri_not_local() { + let invalid_json_uri = + r#"{ "src": "not_local://room_id/member_id/endpoint_id" }"#; + match serde_json::from_str::(invalid_json_uri) { + Ok(_) => assert!(false), + Err(_) => assert!(true), + } + } + + #[test] + fn return_error_when_uri_is_not_full() { + let invalid_json_uri = r#"{ "src": "local://room_id/member_id" }"#; + match serde_json::from_str::(invalid_json_uri) { + Ok(_) => assert!(false), + Err(_) => assert!(true), + } + } + + #[test] + fn return_error_when_uri_have_empty_part() { + let invalid_json_uri = r#"{ "src": "local://room_id//endpoint_id" }"#; + match serde_json::from_str::(invalid_json_uri) { + Ok(_) => assert!(false), + Err(_) => assert!(true), + } + } +} diff --git a/src/api/control/model/mod.rs b/src/api/control/model/mod.rs index f5a177be5..506132e5a 100644 --- a/src/api/control/model/mod.rs +++ b/src/api/control/model/mod.rs @@ -1,4 +1,5 @@ pub mod endpoint; +pub mod local_uri; pub mod member; pub mod room; diff --git a/src/api/grpc/server.rs b/src/api/grpc/server.rs index fdefbad0a..93dd7cbba 100644 --- a/src/api/grpc/server.rs +++ b/src/api/grpc/server.rs @@ -22,7 +22,11 @@ use crate::{ use super::protos::control_grpc::{create_control_api, ControlApi}; use crate::{ - api::grpc::protos::control::Error, signalling::room_repo::StartRoom, + api::{ + control::model::local_uri::{parse_local_uri, LocalUri}, + grpc::protos::control::Error, + }, + signalling::room_repo::{DeleteRoom, StartRoom}, }; use futures::future::Either; use std::collections::HashMap; @@ -103,11 +107,21 @@ impl ControlApi for ControlApiService { fn delete( &mut self, - _ctx: RpcContext, - _req: IdRequest, - _sink: UnarySink, + ctx: RpcContext, + req: IdRequest, + sink: UnarySink, ) { - unimplemented!() + for id in req.get_id() { + let uri = parse_local_uri(id).unwrap(); // TODO + if uri.is_room_id() { + self.room_repository + .do_send(DeleteRoom(uri.room_id.unwrap())) + } + } + + let mut resp = Response::new(); + resp.set_sid(HashMap::new()); + ctx.spawn(sink.success(resp).map_err(|_| ())); } fn get( diff --git a/src/bin/client.rs b/src/bin/client.rs index d674a17d8..d4974b40f 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -1,11 +1,12 @@ use grpcio::{ChannelBuilder, EnvBuilder}; use medea::api::grpc::protos::{ control::{ - CreateRequest, Member, Member_Element, Room, Room_Element, + CreateRequest, IdRequest, Member, Member_Element, Room, Room_Element, WebRtcPlayEndpoint, WebRtcPublishEndpoint, WebRtcPublishEndpoint_P2P, }, control_grpc::ControlApiClient, }; +use protobuf::RepeatedField; use std::{collections::HashMap, sync::Arc}; fn main() { @@ -53,4 +54,12 @@ fn main() { } else { println!("Receiver: {:?}", reply.get_sid()); } + + let mut delete_request = IdRequest::new(); + let mut rooms = RepeatedField::new(); + rooms.push("local://pub-sub-video-call".to_string()); + delete_request.set_id(rooms); + + let reply = client.delete(&delete_request).expect("delete"); + println!("{:?}", reply); } diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs index dfb5e288a..aadd1a6ee 100644 --- a/src/signalling/room_repo.rs +++ b/src/signalling/room_repo.rs @@ -11,7 +11,10 @@ use hashbrown::HashMap; use crate::{ api::control::model::{room::RoomSpec, RoomId}, conf::Conf, - signalling::{room::RoomError, Room}, + signalling::{ + room::{CloseRoom, RoomError}, + Room, + }, App, }; use std::time::Duration; @@ -87,3 +90,22 @@ impl Handler> for RoomsRepository { Ok(()) } } + +#[derive(Message)] +#[rtype(result = "()")] +pub struct DeleteRoom(pub RoomId); + +impl Handler for RoomsRepository { + type Result = (); + + fn handle( + &mut self, + msg: DeleteRoom, + ctx: &mut Self::Context, + ) -> Self::Result { + if let Some(room) = self.rooms.lock().unwrap().get(&msg.0) { + room.do_send(CloseRoom {}); + self.rooms.lock().unwrap().remove(&msg.0); + } + } +} From b79d721ae9296b6c365c9f1c9f6321f976ed2f6e Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 5 Jul 2019 20:08:31 +0300 Subject: [PATCH 268/735] Revert control models --- src/api/client/rpc_connection.rs | 4 +- src/api/client/server.rs | 2 +- src/api/client/session.rs | 2 +- src/api/control/{serde => }/endpoint.rs | 95 +++++++---- src/api/control/member.rs | 149 ++++++++++++++++++ src/api/control/mod.rs | 84 +++++++++- src/api/control/model/member.rs | 14 -- src/api/control/model/room.rs | 14 -- src/api/control/{serde => }/pipeline.rs | 2 +- src/api/control/room.rs | 110 +++++++++++++ src/api/control/serde/member.rs | 144 ----------------- src/api/control/serde/mod.rs | 85 ---------- src/api/control/serde/room.rs | 100 ------------ src/lib.rs | 5 +- src/media/ice_user.rs | 2 +- src/media/peer.rs | 2 +- .../endpoints/webrtc/play_endpoint.rs | 15 +- .../endpoints/webrtc/publish_endpoint.rs | 10 +- src/signalling/elements/member.rs | 120 +++++--------- src/signalling/participants.rs | 9 +- src/signalling/peers.rs | 2 +- src/signalling/room.rs | 7 +- src/signalling/room_repo.rs | 2 +- src/turn/service.rs | 9 +- 24 files changed, 487 insertions(+), 501 deletions(-) rename src/api/control/{serde => }/endpoint.rs (79%) create mode 100644 src/api/control/member.rs rename src/api/control/{serde => }/pipeline.rs (95%) create mode 100644 src/api/control/room.rs delete mode 100644 src/api/control/serde/member.rs delete mode 100644 src/api/control/serde/mod.rs delete mode 100644 src/api/control/serde/room.rs diff --git a/src/api/client/rpc_connection.rs b/src/api/client/rpc_connection.rs index 7c185732f..208f8850d 100644 --- a/src/api/client/rpc_connection.rs +++ b/src/api/client/rpc_connection.rs @@ -8,7 +8,7 @@ use macro_attr::*; use medea_client_api_proto::{Command, Event}; use newtype_derive::NewtypeFrom; -use crate::api::control::model::MemberId; +use crate::api::control::MemberId; macro_attr! { /// Wrapper [`Command`] for implements actix [`Message`]. @@ -107,7 +107,7 @@ pub mod test { ClosedReason, CommandMessage, EventMessage, RpcConnection, RpcConnectionClosed, RpcConnectionEstablished, }, - control::model::MemberId, + control::MemberId, }, signalling::Room, }; diff --git a/src/api/client/server.rs b/src/api/client/server.rs index 66677d58c..55ef85c52 100644 --- a/src/api/client/server.rs +++ b/src/api/client/server.rs @@ -18,7 +18,7 @@ use crate::{ rpc_connection::{AuthorizationError, Authorize}, session::WsSession, }, - control::model::{MemberId, RoomId}, + control::{MemberId, RoomId}, }, conf::{Conf, Rpc}, log::prelude::*, diff --git a/src/api/client/session.rs b/src/api/client/session.rs index c1c9d3921..b0e2e93dc 100644 --- a/src/api/client/session.rs +++ b/src/api/client/session.rs @@ -16,7 +16,7 @@ use crate::{ ClosedReason, CommandMessage, EventMessage, RpcConnection, RpcConnectionClosed, RpcConnectionEstablished, }, - control::model::MemberId, + control::MemberId, }, log::prelude::*, signalling::Room, diff --git a/src/api/control/serde/endpoint.rs b/src/api/control/endpoint.rs similarity index 79% rename from src/api/control/serde/endpoint.rs rename to src/api/control/endpoint.rs index 169dfaa2d..5064036f8 100644 --- a/src/api/control/serde/endpoint.rs +++ b/src/api/control/endpoint.rs @@ -2,35 +2,72 @@ use std::{convert::TryFrom, fmt}; +use macro_attr::*; +use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; use serde::{ de::{self, Deserializer, Error, Unexpected, Visitor}, Deserialize, }; -use crate::api::control::model::{ - endpoint::webrtc::*, member::MemberId, room::RoomId, -}; +use super::{Element, TryFromElementError, RoomId, MemberId}; + +macro_attr! { + /// ID of [`Room`]. + #[derive( + Clone, + Debug, + Deserialize, + Eq, + Hash, + PartialEq, + NewtypeFrom!, + NewtypeDisplay!, + )] + pub struct WebRtcPublishId(pub String); +} -use super::{Element, TryFromElementError}; +macro_attr! { + /// ID of [`Room`]. + #[derive( + Clone, + Debug, + Deserialize, + Eq, + Hash, + PartialEq, + NewtypeFrom!, + NewtypeDisplay!, + )] + pub struct WebRtcPlayId(pub String); +} + +/// Peer-to-peer mode of [`WebRtcPublishEndpoint`]. +#[derive(Clone, Deserialize, Debug)] +pub enum P2pMode { + /// Always connect peer-to-peer. + Always, + Never, + IfPossible, +} /// [`Endpoint`] represents a media element that one or more media data streams /// flow through. #[derive(Debug)] -pub enum SerdeEndpoint { - WebRtcPublish(SerdeWebRtcPublishEndpointImpl), - WebRtcPlay(SerdeWebRtcPlayEndpointImpl), +pub enum Endpoint { + WebRtcPublish(WebRtcPublishEndpoint), + WebRtcPlay(WebRtcPlayEndpoint), } -impl TryFrom<&Element> for SerdeEndpoint { +impl TryFrom<&Element> for Endpoint { type Error = TryFromElementError; fn try_from(from: &Element) -> Result { match from { Element::WebRtcPlayEndpoint { spec } => { - Ok(SerdeEndpoint::WebRtcPlay(spec.clone())) + Ok(Endpoint::WebRtcPlay(spec.clone())) } Element::WebRtcPublishEndpoint { spec } => { - Ok(SerdeEndpoint::WebRtcPublish(spec.clone())) + Ok(Endpoint::WebRtcPublish(spec.clone())) } _ => Err(TryFromElementError::NotEndpoint), } @@ -41,34 +78,34 @@ impl TryFrom<&Element> for SerdeEndpoint { /// WebRTC. #[allow(clippy::module_name_repetitions)] #[derive(Clone, Deserialize, Debug)] -pub struct SerdeWebRtcPublishEndpointImpl { +pub struct WebRtcPublishEndpoint { /// Peer-to-peer mode. pub p2p: P2pMode, } -impl WebRtcPublishEndpoint for SerdeWebRtcPublishEndpointImpl { - fn p2p(&self) -> P2pMode { - self.p2p.clone() - } -} +// impl WebRtcPublishEndpoint for WebRtcPublishEndpoint { +// fn p2p(&self) -> P2pMode { +// self.p2p.clone() +// } +// } /// Media element which is able to play media data for client via WebRTC. #[allow(clippy::module_name_repetitions)] #[derive(Clone, Deserialize, Debug)] -pub struct SerdeWebRtcPlayEndpointImpl { +pub struct WebRtcPlayEndpoint { /// Source URI in format `local://{room_id}/{member_id}/{endpoint_id}`. - pub src: SerdeSrcUri, + pub src: SrcUri, } -impl WebRtcPlayEndpoint for SerdeWebRtcPlayEndpointImpl { - fn src(&self) -> SrcUri { - self.src.clone() - } -} +// impl WebRtcPlayEndpoint for WebRtcPlayEndpoint { +// fn src(&self) -> SrcUri { +// self.src.clone() +// } +// } /// Special uri with pattern `local://{room_id}/{member_id}/{endpoint_id}`. #[derive(Clone, Debug)] -pub struct SerdeSrcUri { +pub struct SrcUri { /// ID of [`Room`] pub room_id: RoomId, /// ID of `Member` @@ -79,7 +116,7 @@ pub struct SerdeSrcUri { /// Serde deserializer for [`SrcUri`]. /// Deserialize URIs with pattern `local://{room_id}/{member_id}/{endpoint_id}`. -impl<'de> Deserialize<'de> for SerdeSrcUri { +impl<'de> Deserialize<'de> for SrcUri { fn deserialize(deserializer: D) -> Result where D: Deserializer<'de>, @@ -87,7 +124,7 @@ impl<'de> Deserialize<'de> for SerdeSrcUri { struct SrcUriVisitor; impl<'de> Visitor<'de> for SrcUriVisitor { - type Value = SerdeSrcUri; + type Value = SrcUri; fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { formatter.write_str( @@ -95,7 +132,7 @@ impl<'de> Deserialize<'de> for SerdeSrcUri { ) } - fn visit_str(self, value: &str) -> Result + fn visit_str(self, value: &str) -> Result where E: de::Error, { @@ -152,7 +189,7 @@ impl<'de> Deserialize<'de> for SerdeSrcUri { ))); } - Ok(SerdeSrcUri { + Ok(SrcUri { room_id: RoomId(room_id), member_id: MemberId(member_id), endpoint_id: WebRtcPublishId(endpoint_id), @@ -172,7 +209,7 @@ mod src_uri_deserialization_tests { #[derive(Deserialize)] struct SrcUriTest { - src: SerdeSrcUri, + src: SrcUri, } #[inline] diff --git a/src/api/control/member.rs b/src/api/control/member.rs new file mode 100644 index 000000000..36cb2d31d --- /dev/null +++ b/src/api/control/member.rs @@ -0,0 +1,149 @@ +//! Member definitions and implementations. + +use std::convert::TryFrom; + +use hashbrown::HashMap; +use macro_attr::*; +use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; +use serde::Deserialize; + +use crate::api::control::endpoint::{ + WebRtcPlayEndpoint, WebRtcPlayId, WebRtcPublishEndpoint, WebRtcPublishId, +}; + +use super::{pipeline::Pipeline, Element, TryFromElementError}; + +macro_attr! { + /// ID of [`Room`]. + #[derive( + Clone, + Debug, + Deserialize, + Eq, + Hash, + PartialEq, + NewtypeFrom!, + NewtypeDisplay!, + )] + pub struct Id(pub String); +} + +/// Newtype for [`Element::Member`] variant. +#[allow(clippy::module_name_repetitions)] +#[derive(Clone, Debug)] +pub struct MemberSpec { + /// Spec of this `Member`. + pipeline: Pipeline, + + /// Credentials to authorize `Member` with. + credentials: String, +} + +impl MemberSpec { + /// Returns all [`WebRtcPlayEndpoint`]s of this [`MemberSpec`]. + pub fn play_endpoints(&self) -> HashMap<&String, &WebRtcPlayEndpoint> { + self.pipeline + .iter() + .filter_map(|(id, e)| match e { + Element::WebRtcPlayEndpoint { spec } => Some((id, spec)), + _ => None, + }) + .collect() + } + + /// Returns all [`WebRtcPublishEndpoint`]s of this [`MemberSpec`]. + pub fn publish_endpoints( + &self, + ) -> HashMap { + self.pipeline + .iter() + .filter_map(|(id, e)| match e { + Element::WebRtcPublishEndpoint { spec } => { + Some((WebRtcPublishId(id.clone()), spec)) + } + _ => None, + }) + .collect() + } + + pub fn credentials(&self) -> &str { + &self.credentials + } +} + +// impl MemberSpec for MemberSpec { +// fn webrtc_play_endpoints( +// &self, +// ) -> HashMap> { +// self.pipeline +// .iter() +// .filter_map(|(id, e)| match e { +// Element::WebRtcPlayEndpoint { spec } => Some(( +// WebRtcPlayId(id.clone()), +// Box::new(spec.clone()) as Box, +// )), +// _ => None, +// }) +// .collect() +// } +// +// fn webrtc_publish_endpoints( +// &self, +// ) -> HashMap> { +// self.pipeline +// .iter() +// .filter_map(|(id, e)| match e { +// Element::WebRtcPublishEndpoint { spec } => Some(( +// WebRtcPublishId(id.clone()), +// Box::new(spec.clone()) as Box, +// )), +// _ => None, +// }) +// .collect() +// } +// +// fn credentials(&self) -> &str { +// &self.credentials +// } +// +// fn get_webrtc_play_by_id( +// &self, +// id: &WebRtcPlayId, +// ) -> Option> { +// let element = self.pipeline.get(&id.0)?; +// +// if let Some(endpoint) = SerdeEndpoint::try_from(element).ok() { +// if let SerdeEndpoint::WebRtcPlay(e) = endpoint { +// return Some(Box::new(e) as Box); +// } +// } +// None +// } +// +// fn get_webrtc_publish_by_id( +// &self, +// id: &WebRtcPublishId, +// ) -> Option> { +// let element = self.pipeline.get(&id.0)?; +// if let Some(endpoint) = SerdeEndpoint::try_from(element).ok() { +// if let SerdeEndpoint::WebRtcPublish(e) = endpoint { +// return Some(Box::new(e) as Box); +// } +// } +// None +// } +// } + +impl TryFrom<&Element> for MemberSpec { + type Error = TryFromElementError; + + fn try_from(from: &Element) -> Result { + match from { + Element::Member { spec, credentials } => Ok(Self { + pipeline: spec.clone(), + credentials: credentials.clone(), + }), + _ => Err(TryFromElementError::NotMember), + } + } +} diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index 463b57ba2..a93966747 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -1,3 +1,81 @@ -pub mod model; -pub mod protobuf; -pub mod serde; +//! Implementation of Control API. + +pub mod endpoint; +pub mod member; +pub mod pipeline; +pub mod room; + +use std::{convert::TryFrom as _, fs::File, io::Read as _, path::Path}; + +use failure::{Error, Fail}; +use serde::Deserialize; + +use self::{ + endpoint::{WebRtcPlayEndpoint, WebRtcPublishEndpoint}, + pipeline::Pipeline, +}; + +pub use self::{ + endpoint::Endpoint, + member::{Id as MemberId, MemberSpec}, + room::{Id as RoomId, RoomSpec}, +}; + +/// Errors that can occur when we try transform some spec from [`Element`]. +/// This error used in all [`TryFrom`] of Control API. +#[allow(clippy::pub_enum_variant_names)] +#[derive(Debug, Fail)] +pub enum TryFromElementError { + #[fail(display = "Element is not Endpoint")] + NotEndpoint, + #[fail(display = "Element is not Room")] + NotRoom, + #[fail(display = "Element is not Member")] + NotMember, +} + +/// Entity for parsing Control API request. +#[derive(Clone, Deserialize, Debug)] +#[serde(tag = "kind")] +pub enum Element { + /// Represent [`RoomSpec`]. + /// Can transform into [`RoomSpec`] by `RoomSpec::try_from`. + Room { id: RoomId, spec: Pipeline }, + + /// Represent [`MemberSpec`]. + /// Can transform into [`MemberSpec`] by `MemberSpec::try_from`. + Member { spec: Pipeline, credentials: String }, + + /// Represent [`WebRtcPublishEndpoint`]. + /// Can transform into [`Endpoint`] enum by `Endpoint::try_from`. + WebRtcPublishEndpoint { spec: WebRtcPublishEndpoint }, + + /// Represent [`WebRtcPlayEndpoint`]. + /// Can transform into [`Endpoint`] enum by `Endpoint::try_from`. + WebRtcPlayEndpoint { spec: WebRtcPlayEndpoint }, +} + +/// Load [`RoomSpec`] from file with YAML format. +pub fn load_from_yaml_file>(path: P) -> Result { + let mut file = File::open(path)?; + let mut buf = String::new(); + file.read_to_string(&mut buf)?; + let parsed: Element = serde_yaml::from_str(&buf)?; + let room = RoomSpec::try_from(&parsed)?; + + Ok(room) +} + +/// Load all [`RoomSpec`] from YAML files from provided path. +pub fn load_static_specs_from_dir>( + path: P, +) -> Result, Error> { + let mut specs = Vec::new(); + for entry in std::fs::read_dir(path)? { + let entry = entry?; + let spec = load_from_yaml_file(entry.path())?; + specs.push(spec) + } + + Ok(specs) +} diff --git a/src/api/control/model/member.rs b/src/api/control/model/member.rs index bfff0fa0a..df66d85e5 100644 --- a/src/api/control/model/member.rs +++ b/src/api/control/model/member.rs @@ -4,20 +4,6 @@ use macro_attr::*; use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; use serde::Deserialize; -macro_attr! { - /// ID of [`Room`]. - #[derive( - Clone, - Debug, - Deserialize, - Eq, - Hash, - PartialEq, - NewtypeFrom!, - NewtypeDisplay!, - )] - pub struct Id(pub String); -} pub use Id as MemberId; diff --git a/src/api/control/model/room.rs b/src/api/control/model/room.rs index 03e0a9610..ce51ea9bf 100644 --- a/src/api/control/model/room.rs +++ b/src/api/control/model/room.rs @@ -4,20 +4,6 @@ use macro_attr::*; use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; use serde::Deserialize; -macro_attr! { - /// ID of [`Room`]. - #[derive( - Clone, - Debug, - Deserialize, - Eq, - Hash, - PartialEq, - NewtypeFrom!, - NewtypeDisplay!, - )] - pub struct Id(pub String); -} pub use Id as RoomId; diff --git a/src/api/control/serde/pipeline.rs b/src/api/control/pipeline.rs similarity index 95% rename from src/api/control/serde/pipeline.rs rename to src/api/control/pipeline.rs index 73a4041e5..1456ae7d2 100644 --- a/src/api/control/serde/pipeline.rs +++ b/src/api/control/pipeline.rs @@ -10,7 +10,7 @@ use std::{ use serde::Deserialize; -use crate::api::control::serde::Element; +use crate::api::control::Element; /// Entity that represents some pipeline of spec. #[derive(Clone, Deserialize, Debug)] diff --git a/src/api/control/room.rs b/src/api/control/room.rs new file mode 100644 index 000000000..b82dbbeb9 --- /dev/null +++ b/src/api/control/room.rs @@ -0,0 +1,110 @@ +//! Room definitions and implementations. + +use std::convert::TryFrom; + +use hashbrown::HashMap; +use macro_attr::*; +use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; +use serde::Deserialize; + +use super::{ + member::MemberSpec, pipeline::Pipeline, Element, MemberId, + TryFromElementError, +}; + +macro_attr! { + /// ID of [`Room`]. + #[derive( + Clone, + Debug, + Deserialize, + Eq, + Hash, + PartialEq, + NewtypeFrom!, + NewtypeDisplay!, + )] + pub struct Id(pub String); +} + +/// [`crate::signalling::room::Room`] specification. +/// Newtype for [`Element::Room`] +#[allow(clippy::module_name_repetitions)] +#[derive(Clone, Debug)] +pub struct RoomSpec { + pub id: Id, + pub pipeline: Pipeline, +} + +impl RoomSpec { + /// Returns all [`MemberSpec`]s of this [`RoomSpec`]. + pub fn members( + &self, + ) -> Result, TryFromElementError> { + let mut members: HashMap = HashMap::new(); + for (control_id, element) in self.pipeline.iter() { + let member_spec = MemberSpec::try_from(element)?; + let member_id = MemberId(control_id.clone()); + + members.insert(member_id.clone(), member_spec); + } + + Ok(members) + } + + /// Returns ID of this [`RoomSpec`] + pub fn id(&self) -> &Id { + &self.id + } +} + +// pub struct SerdeRoomSpecImpl { +// id: Id, +// members: HashMap, +// } +// +// impl SerdeRoomSpecImpl { +// pub fn new( +// room_spec: &SerdeRoomSpecDto, +// ) -> Result { +// Ok(Self { +// id: room_spec.id.clone(), +// members: room_spec.members()?, +// }) +// } +// } +// +// impl RoomSpec for SerdeRoomSpecImpl { +// fn members(&self) -> HashMap> { +// self.members +// .iter() +// .map(|(id, member)| { +// (id.clone(), Box::new(member.clone()) as Box) +// }) +// .collect() +// } +// +// fn id(&self) -> Id { +// self.id.clone() +// } +// +// fn get_member_by_id(&self, id: &MemberId) -> Option> { +// self.members +// .get(id) +// .map(|m| Box::new(m.clone()) as Box) +// } +// } + +impl TryFrom<&Element> for RoomSpec { + type Error = TryFromElementError; + + fn try_from(from: &Element) -> Result { + match from { + Element::Room { id, spec } => Ok(Self { + id: id.clone(), + pipeline: spec.clone(), + }), + _ => Err(TryFromElementError::NotRoom), + } + } +} diff --git a/src/api/control/serde/member.rs b/src/api/control/serde/member.rs deleted file mode 100644 index 0e149f7ea..000000000 --- a/src/api/control/serde/member.rs +++ /dev/null @@ -1,144 +0,0 @@ -//! Member definitions and implementations. - -use std::convert::TryFrom; - -use hashbrown::HashMap; - -use crate::api::control::{ - model::{ - endpoint::webrtc::{ - WebRtcPlayEndpoint, WebRtcPlayId, WebRtcPublishEndpoint, - WebRtcPublishId, - }, - member::MemberSpec, - }, - serde::SerdeEndpoint, -}; - -use super::{ - endpoint::{SerdeWebRtcPlayEndpointImpl, SerdeWebRtcPublishEndpointImpl}, - pipeline::Pipeline, - Element, TryFromElementError, -}; - -/// Newtype for [`Element::Member`] variant. -#[allow(clippy::module_name_repetitions)] -#[derive(Clone, Debug)] -pub struct SerdeMemberSpecImpl { - /// Spec of this `Member`. - pipeline: Pipeline, - - /// Credentials to authorize `Member` with. - credentials: String, -} - -impl SerdeMemberSpecImpl { - /// Returns all [`WebRtcPlayEndpoint`]s of this [`MemberSpec`]. - pub fn play_endpoints( - &self, - ) -> HashMap<&String, &SerdeWebRtcPlayEndpointImpl> { - self.pipeline - .iter() - .filter_map(|(id, e)| match e { - Element::WebRtcPlayEndpoint { spec } => Some((id, spec)), - _ => None, - }) - .collect() - } - - /// Returns all [`WebRtcPublishEndpoint`]s of this [`MemberSpec`]. - pub fn publish_endpoints( - &self, - ) -> HashMap { - self.pipeline - .iter() - .filter_map(|(id, e)| match e { - Element::WebRtcPublishEndpoint { spec } => { - Some((WebRtcPublishId(id.clone()), spec)) - } - _ => None, - }) - .collect() - } - - pub fn credentials(&self) -> &str { - &self.credentials - } -} - -impl MemberSpec for SerdeMemberSpecImpl { - fn webrtc_play_endpoints( - &self, - ) -> HashMap> { - self.pipeline - .iter() - .filter_map(|(id, e)| match e { - Element::WebRtcPlayEndpoint { spec } => Some(( - WebRtcPlayId(id.clone()), - Box::new(spec.clone()) as Box, - )), - _ => None, - }) - .collect() - } - - fn webrtc_publish_endpoints( - &self, - ) -> HashMap> { - self.pipeline - .iter() - .filter_map(|(id, e)| match e { - Element::WebRtcPublishEndpoint { spec } => Some(( - WebRtcPublishId(id.clone()), - Box::new(spec.clone()) as Box, - )), - _ => None, - }) - .collect() - } - - fn credentials(&self) -> &str { - &self.credentials - } - - fn get_webrtc_play_by_id( - &self, - id: &WebRtcPlayId, - ) -> Option> { - let element = self.pipeline.get(&id.0)?; - - if let Some(endpoint) = SerdeEndpoint::try_from(element).ok() { - if let SerdeEndpoint::WebRtcPlay(e) = endpoint { - return Some(Box::new(e) as Box); - } - } - None - } - - fn get_webrtc_publish_by_id( - &self, - id: &WebRtcPublishId, - ) -> Option> { - let element = self.pipeline.get(&id.0)?; - if let Some(endpoint) = SerdeEndpoint::try_from(element).ok() { - if let SerdeEndpoint::WebRtcPublish(e) = endpoint { - return Some(Box::new(e) as Box); - } - } - None - } -} - -impl TryFrom<&Element> for SerdeMemberSpecImpl { - type Error = TryFromElementError; - - fn try_from(from: &Element) -> Result { - match from { - Element::Member { spec, credentials } => Ok(Self { - pipeline: spec.clone(), - credentials: credentials.clone(), - }), - _ => Err(TryFromElementError::NotMember), - } - } -} diff --git a/src/api/control/serde/mod.rs b/src/api/control/serde/mod.rs deleted file mode 100644 index 6c8403c2f..000000000 --- a/src/api/control/serde/mod.rs +++ /dev/null @@ -1,85 +0,0 @@ -//! Implementation of Control API. - -pub mod endpoint; -pub mod member; -pub mod pipeline; -pub mod room; - -use std::{convert::TryFrom as _, fs::File, io::Read as _, path::Path}; - -use failure::{Error, Fail}; -use serde::Deserialize; - -use self::{ - endpoint::{SerdeWebRtcPlayEndpointImpl, SerdeWebRtcPublishEndpointImpl}, - pipeline::Pipeline, -}; -use super::model::RoomId; - -pub use self::{ - endpoint::SerdeEndpoint, member::SerdeMemberSpecImpl, - room::SerdeRoomSpecDto, -}; - -/// Errors that can occur when we try transform some spec from [`Element`]. -/// This error used in all [`TryFrom`] of Control API. -#[allow(clippy::pub_enum_variant_names)] -#[derive(Debug, Fail)] -pub enum TryFromElementError { - #[fail(display = "Element is not Endpoint")] - NotEndpoint, - #[fail(display = "Element is not Room")] - NotRoom, - #[fail(display = "Element is not Member")] - NotMember, -} - -/// Entity for parsing Control API request. -#[derive(Clone, Deserialize, Debug)] -#[serde(tag = "kind")] -pub enum Element { - /// Represent [`RoomSpec`]. - /// Can transform into [`RoomSpec`] by `RoomSpec::try_from`. - Room { id: RoomId, spec: Pipeline }, - - /// Represent [`MemberSpec`]. - /// Can transform into [`MemberSpec`] by `MemberSpec::try_from`. - Member { spec: Pipeline, credentials: String }, - - /// Represent [`WebRtcPublishEndpoint`]. - /// Can transform into [`Endpoint`] enum by `Endpoint::try_from`. - WebRtcPublishEndpoint { - spec: SerdeWebRtcPublishEndpointImpl, - }, - - /// Represent [`WebRtcPlayEndpoint`]. - /// Can transform into [`Endpoint`] enum by `Endpoint::try_from`. - WebRtcPlayEndpoint { spec: SerdeWebRtcPlayEndpointImpl }, -} - -/// Load [`RoomSpec`] from file with YAML format. -pub fn load_from_yaml_file>( - path: P, -) -> Result { - let mut file = File::open(path)?; - let mut buf = String::new(); - file.read_to_string(&mut buf)?; - let parsed: Element = serde_yaml::from_str(&buf)?; - let room = SerdeRoomSpecDto::try_from(&parsed)?; - - Ok(room) -} - -/// Load all [`RoomSpec`] from YAML files from provided path. -pub fn load_static_specs_from_dir>( - path: P, -) -> Result, Error> { - let mut specs = Vec::new(); - for entry in std::fs::read_dir(path)? { - let entry = entry?; - let spec = load_from_yaml_file(entry.path())?; - specs.push(spec) - } - - Ok(specs) -} diff --git a/src/api/control/serde/room.rs b/src/api/control/serde/room.rs deleted file mode 100644 index a93cfbe0c..000000000 --- a/src/api/control/serde/room.rs +++ /dev/null @@ -1,100 +0,0 @@ -//! Room definitions and implementations. - -use std::convert::TryFrom; - -use hashbrown::HashMap; - -use crate::api::control::model::{ - member::MemberSpec, - room::{Id, RoomSpec}, - MemberId, -}; - -use super::{ - member::SerdeMemberSpecImpl, pipeline::Pipeline, Element, - TryFromElementError, -}; - -/// [`crate::signalling::room::Room`] specification. -/// Newtype for [`Element::Room`] -#[allow(clippy::module_name_repetitions)] -#[derive(Clone, Debug)] -pub struct SerdeRoomSpecDto { - pub id: Id, - pub pipeline: Pipeline, -} - -impl SerdeRoomSpecDto { - /// Returns all [`MemberSpec`]s of this [`RoomSpec`]. - pub fn members( - &self, - ) -> Result, TryFromElementError> - { - let mut members: HashMap = - HashMap::new(); - for (control_id, element) in self.pipeline.iter() { - let member_spec = SerdeMemberSpecImpl::try_from(element)?; - let member_id = MemberId(control_id.clone()); - - members.insert(member_id.clone(), member_spec); - } - - Ok(members) - } - - /// Returns ID of this [`RoomSpec`] - pub fn id(&self) -> &Id { - &self.id - } -} - -pub struct SerdeRoomSpecImpl { - id: Id, - members: HashMap, -} - -impl SerdeRoomSpecImpl { - pub fn new( - room_spec: &SerdeRoomSpecDto, - ) -> Result { - Ok(Self { - id: room_spec.id.clone(), - members: room_spec.members()?, - }) - } -} - -impl RoomSpec for SerdeRoomSpecImpl { - fn members(&self) -> HashMap> { - self.members - .iter() - .map(|(id, member)| { - (id.clone(), Box::new(member.clone()) as Box) - }) - .collect() - } - - fn id(&self) -> Id { - self.id.clone() - } - - fn get_member_by_id(&self, id: &MemberId) -> Option> { - self.members - .get(id) - .map(|m| Box::new(m.clone()) as Box) - } -} - -impl TryFrom<&Element> for SerdeRoomSpecDto { - type Error = TryFromElementError; - - fn try_from(from: &Element) -> Result { - match from { - Element::Room { id, spec } => Ok(Self { - id: id.clone(), - pipeline: spec.clone(), - }), - _ => Err(TryFromElementError::NotRoom), - } - } -} diff --git a/src/lib.rs b/src/lib.rs index 95eec0bff..7c9f7d4c9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -14,10 +14,7 @@ use failure::Fail; use hashbrown::HashMap; use crate::{ - api::control::{ - model::{room::RoomSpec, RoomId}, - serde::{load_static_specs_from_dir, room::SerdeRoomSpecImpl}, - }, + api::control::{load_static_specs_from_dir, room::RoomSpec, RoomId}, conf::Conf, signalling::{room::RoomError, Room}, turn::service, diff --git a/src/media/ice_user.rs b/src/media/ice_user.rs index 73db4a965..1c18da31d 100644 --- a/src/media/ice_user.rs +++ b/src/media/ice_user.rs @@ -2,7 +2,7 @@ use std::net::SocketAddr; use medea_client_api_proto::IceServer; -use crate::api::control::model::RoomId; +use crate::api::control::RoomId; /// Credentials on Turn server. #[derive(Clone, Debug)] diff --git a/src/media/peer.rs b/src/media/peer.rs index 119e22e84..e3c331d2e 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -14,7 +14,7 @@ use medea_client_api_proto::{ use medea_macro::enum_delegate; use crate::{ - api::control::model::MemberId, + api::control::MemberId, media::{MediaTrack, TrackId}, signalling::peers::Counter, }; diff --git a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs index 166f40c34..8c984aa1b 100644 --- a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs @@ -5,17 +5,22 @@ use std::{ rc::{Rc, Weak}, }; +use macro_attr::*; +use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; + use crate::{ - api::control::serde::endpoint::SerdeSrcUri, media::PeerId, - signalling::elements::Member, + api::control::endpoint::SrcUri, media::PeerId, signalling::elements::Member, }; use super::publish_endpoint::WebRtcPublishEndpoint; pub use Id as WebRtcPlayId; -pub use crate::api::control::model::endpoint::webrtc::play_endpoint::Id; -use crate::api::control::model::endpoint::webrtc::SrcUri; +macro_attr! { + /// ID of endpoint. + #[derive(Clone, Debug, Eq, Hash, PartialEq, NewtypeFrom!, NewtypeDisplay!)] + pub struct Id(pub String); +} #[derive(Debug, Clone)] struct WebRtcPlayEndpointInner { @@ -44,7 +49,7 @@ struct WebRtcPlayEndpointInner { } impl WebRtcPlayEndpointInner { - fn src_uri(&self) -> SerdeSrcUri { + fn src_uri(&self) -> SrcUri { self.src_uri.clone() } diff --git a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs index 81e4850b7..a39e3108d 100644 --- a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs @@ -6,9 +6,11 @@ use std::{ }; use hashbrown::HashSet; +use macro_attr::*; +use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; use crate::{ - api::control::model::endpoint::webrtc::P2pMode, media::PeerId, + api::control::endpoint::P2pMode, media::PeerId, signalling::elements::Member, }; @@ -16,7 +18,11 @@ use super::play_endpoint::WebRtcPlayEndpoint; pub use Id as WebRtcPublishId; -pub use crate::api::control::model::endpoint::webrtc::publish_endpoint::Id; +macro_attr! { + /// ID of endpoint. + #[derive(Clone, Debug, Eq, Hash, PartialEq, NewtypeFrom!, NewtypeDisplay!)] + pub struct Id(pub String); +} #[derive(Debug, Clone)] struct WebRtcPublishEndpointInner { diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index 551fa55cf..9f994e60b 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -1,13 +1,13 @@ //! [`Member`] is member of [`Room`] with [`RpcConnection`]. -use std::{cell::RefCell, rc::Rc}; +use std::{cell::RefCell, convert::TryFrom as _, rc::Rc}; use failure::Fail; use hashbrown::HashMap; use medea_client_api_proto::IceServer; use crate::{ - api::control::{model::MemberId, serde::TryFromElementError}, + api::control::{MemberId, MemberSpec, RoomSpec, TryFromElementError}, log::prelude::*, media::{IceUser, PeerId}, }; @@ -15,7 +15,6 @@ use crate::{ use super::endpoints::webrtc::{ WebRtcPlayEndpoint, WebRtcPlayId, WebRtcPublishEndpoint, WebRtcPublishId, }; -use crate::api::control::model::room::RoomSpec; /// Errors which may occur while loading [`Member`]s from [`RoomSpec`]. #[derive(Debug, Fail)] @@ -79,86 +78,61 @@ impl Member { /// Load all srcs and sinks of this [`Member`]. fn load( &self, - room_spec: &Box<&dyn RoomSpec>, + room_spec: &RoomSpec, store: &HashMap>, ) -> Result<(), MembersLoadError> { - // let this_member_spec = SerdeMemberSpec::try_from( - // room_spec - // .get_member_by_id(&self.id()) - // - // .map_or(Err(MembersLoadError::MemberNotFound(self.id())), Ok)?, - // )?; - - let this_member_spec = room_spec - .get_member_by_id(&self.id()) - .map_or(Err(MembersLoadError::MemberNotFound(self.id())), Ok)?; + let this_member_spec = MemberSpec::try_from( + room_spec + .pipeline + .get(&self.id().0) + .map_or(Err(MembersLoadError::MemberNotFound(self.id())), Ok)?, + )?; let this_member = store .get(&self.id()) .map_or(Err(MembersLoadError::MemberNotFound(self.id())), Ok)?; for (spec_play_name, spec_play_endpoint) in - this_member_spec.webrtc_play_endpoints() + this_member_spec.play_endpoints() { let publisher_id = - MemberId(spec_play_endpoint.src().member_id.to_string()); + MemberId(spec_play_endpoint.src.member_id.to_string()); let publisher_member = store.get(&publisher_id).map_or( Err(MembersLoadError::MemberNotFound(publisher_id)), Ok, )?; - // let publisher_spec = SerdeMemberSpec::try_from( - // room_spec - // .pipeline - // - // .get(&spec_play_endpoint.src().member_id.to_string()) - // .map_or( - // Err(MembersLoadError::MemberNotFound( - // - // spec_play_endpoint.src().member_id.clone(), - // )), - // Ok, - // )?, - // )?; - - let publisher_spec = room_spec - .get_member_by_id(&spec_play_endpoint.src().member_id) - .map_or( - Err(MembersLoadError::MemberNotFound( - spec_play_endpoint.src().member_id.clone(), - )), - Ok, - )?; - // TODO: Maybe use EndpointId in MembersLoadError::EndpointNotFound? - let publisher_endpoint = publisher_spec - .get_webrtc_publish_by_id(&spec_play_endpoint.src().endpoint_id) + let publisher_spec = MemberSpec::try_from( + room_spec + .pipeline + .get(&spec_play_endpoint.src.member_id.to_string()) + .map_or( + Err(MembersLoadError::MemberNotFound( + spec_play_endpoint.src.member_id.clone(), + )), + Ok, + )?, + )?; + + let publisher_endpoint = *publisher_spec + .publish_endpoints() + .get(&spec_play_endpoint.src.endpoint_id) .map_or( Err(MembersLoadError::EndpointNotFound( - spec_play_endpoint.src().endpoint_id.clone().0, + spec_play_endpoint.src.endpoint_id.clone(), )), Ok, )?; - // let publisher_endpoint = publisher_spec - // .webrtc_publish_endpoints() - // .get(&spec_play_endpoint.src().endpoint_id) - // .map_or( - // Err(MembersLoadError::EndpointNotFound( - // - // spec_play_endpoint.src().endpoint_id.clone().0, // TODO: tmp - // )), - // Ok, - // )?; - if let Some(publisher) = publisher_member.get_src_by_id(&WebRtcPublishId( - spec_play_endpoint.src().endpoint_id.to_string(), + spec_play_endpoint.src.endpoint_id.to_string(), )) { let new_play_endpoint_id = WebRtcPlayId(spec_play_name.to_string()); let new_play_endpoint = Rc::new(WebRtcPlayEndpoint::new( new_play_endpoint_id.clone(), - spec_play_endpoint.src().clone(), + spec_play_endpoint.src.clone(), Rc::downgrade(&publisher), Rc::downgrade(&this_member), )); @@ -168,11 +142,11 @@ impl Member { publisher.add_sink(Rc::downgrade(&new_play_endpoint)); } else { let new_publish_id = WebRtcPublishId( - spec_play_endpoint.src().endpoint_id.to_string(), + spec_play_endpoint.src.endpoint_id.to_string(), ); let new_publish = Rc::new(WebRtcPublishEndpoint::new( new_publish_id.clone(), - publisher_endpoint.p2p().clone(), + publisher_endpoint.p2p.clone(), Vec::new(), Rc::downgrade(&publisher_member), )); @@ -180,7 +154,7 @@ impl Member { let new_self_play_id = WebRtcPlayId(spec_play_name.to_string()); let new_self_play = Rc::new(WebRtcPlayEndpoint::new( new_self_play_id.clone(), - spec_play_endpoint.src().clone(), + spec_play_endpoint.src.clone(), Rc::downgrade(&new_publish), Rc::downgrade(&this_member), )); @@ -195,20 +169,19 @@ impl Member { // This is necessary to create [`WebRtcPublishEndpoint`], // to which none [`WebRtcPlayEndpoint`] refers. - this_member_spec - .webrtc_publish_endpoints() - .into_iter() - .for_each(|(name, e)| { - let endpoint_id = WebRtcPublishId(name.clone().0); // TODO: tmp + this_member_spec.publish_endpoints().into_iter().for_each( + |(name, e)| { + let endpoint_id = WebRtcPublishId(name.clone()); if self.srcs().get(&endpoint_id).is_none() { self.insert_src(Rc::new(WebRtcPublishEndpoint::new( endpoint_id, - e.p2p().clone(), + e.p2p.clone(), Vec::new(), Rc::downgrade(&this_member), ))); } - }); + }, + ); Ok(()) } @@ -305,9 +278,9 @@ impl Member { /// /// Returns store of all [`Member`]s loaded from [`RoomSpec`]. pub fn parse_members( - room_spec: &Box<&dyn RoomSpec>, + room_spec: &RoomSpec, ) -> Result>, MembersLoadError> { - let members_spec = room_spec.members(); + let members_spec = room_spec.members()?; let mut members = HashMap::new(); for (id, member) in &members_spec { @@ -317,8 +290,6 @@ pub fn parse_members( ); } - // let spec = ParsedSerdeRoomSpec::new(&room_spec)?; - for (_, member) in &members { member.load(room_spec, &members)?; } @@ -349,12 +320,9 @@ pub fn parse_members( #[cfg(test)] mod tests { - use std::{convert::TryFrom as _, rc::Rc}; + use std::rc::Rc; - use crate::api::control::{ - model::MemberId, - serde::{room::SerdeRoomSpecImpl, Element, SerdeRoomSpecDto}, - }; + use crate::api::control::{Element, MemberId}; use super::*; @@ -403,9 +371,7 @@ mod tests { fn get_test_store() -> HashMap> { let room_element: Element = serde_yaml::from_str(TEST_SPEC).unwrap(); - let room_spec = SerdeRoomSpecDto::try_from(&room_element).unwrap(); - let room_spec = SerdeRoomSpecImpl::new(&room_spec).unwrap(); - let room_spec = Box::new(&room_spec as &RoomSpec); + let room_spec = RoomSpec::try_from(&room_element).unwrap(); parse_members(&room_spec).unwrap() } diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index ea9fc146f..4509d8a42 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -26,7 +26,7 @@ use crate::{ AuthorizationError, ClosedReason, EventMessage, RpcConnection, RpcConnectionClosed, }, - control::model::{room::RoomSpec, MemberId, RoomId}, + control::{MemberId, RoomId, RoomSpec}, }, log::prelude::*, media::IceUser, @@ -37,7 +37,6 @@ use crate::{ }, turn::{TurnAuthService, TurnServiceErr, UnreachablePolicy}, }; -use std::sync::Arc; #[derive(Fail, Debug)] #[allow(clippy::module_name_repetitions)] @@ -77,7 +76,7 @@ pub struct ParticipantService { members: HashMap>, /// Service for managing authorization on Turn server. - turn: Arc>, + turn: Box, /// Established [`RpcConnection`]s of [`Members`]s in this [`Room`]. // TODO: Replace Box> with enum, @@ -97,9 +96,9 @@ pub struct ParticipantService { impl ParticipantService { /// Create new [`ParticipantService`] from [`RoomSpec`]. pub fn new( - room_spec: &Box<&dyn RoomSpec>, + room_spec: &RoomSpec, reconnect_timeout: Duration, - turn: Arc>, + turn: Box, ) -> Result { Ok(Self { room_id: room_spec.id().clone(), diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index 680e50a98..d3b60a2a4 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -9,7 +9,7 @@ use actix::{AsyncContext as _, Context}; use hashbrown::HashMap; use crate::{ - api::control::model::MemberId, + api::control::MemberId, log::prelude::*, media::{New, Peer, PeerId, PeerStateMachine}, signalling::{ diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 66b00d6a4..4a244b878 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -18,10 +18,7 @@ use crate::{ AuthorizationError, Authorize, ClosedReason, CommandMessage, RpcConnectionClosed, RpcConnectionEstablished, }, - control::{ - model::{room::RoomSpec, MemberId, RoomId}, - serde::TryFromElementError, - }, + control::{room::RoomSpec, RoomId, TryFromElementError}, }, log::prelude::*, media::{ @@ -106,7 +103,7 @@ impl Room { /// Returns [`RoomError::BadRoomSpec`] when error while [`Element`] /// transformation happens. pub fn new( - room_spec: &Box<&dyn RoomSpec>, + room_spec: &RoomSpec, reconnect_timeout: Duration, turn: Arc>, ) -> Result { diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs index aadd1a6ee..fef474698 100644 --- a/src/signalling/room_repo.rs +++ b/src/signalling/room_repo.rs @@ -9,7 +9,7 @@ use actix::{Actor, Addr, Arbiter, Context, Handler, Message}; use hashbrown::HashMap; use crate::{ - api::control::model::{room::RoomSpec, RoomId}, + api::control::{room::RoomSpec, RoomId}, conf::Conf, signalling::{ room::{CloseRoom, RoomError}, diff --git a/src/turn/service.rs b/src/turn/service.rs index 5d30f2201..300e07f63 100644 --- a/src/turn/service.rs +++ b/src/turn/service.rs @@ -12,7 +12,7 @@ use rand::{distributions::Alphanumeric, Rng}; use redis::ConnectionInfo; use crate::{ - api::control::model::{MemberId, RoomId}, + api::control::{MemberId, RoomId}, conf::Conf, media::IceUser, turn::repo::{TurnDatabase, TurnDatabaseErr}, @@ -154,7 +154,7 @@ struct Service { #[allow(clippy::module_name_repetitions)] pub fn new_turn_auth_service( config: &Conf, -) -> Result, TurnServiceErr> { +) -> Result, TurnServiceErr> { let turn_db = TurnDatabase::new( config.turn.db.redis.connection_timeout, ConnectionInfo { @@ -276,7 +276,7 @@ impl Handler for Service { } } -// TODO: add cfg[test] here +#[cfg(test)] pub mod test { use futures::future; @@ -310,8 +310,7 @@ pub mod test { } #[allow(clippy::module_name_repetitions)] - pub fn new_turn_auth_service_mock() -> Box - { + pub fn new_turn_auth_service_mock() -> Box { Box::new(TurnAuthServiceMock {}) } From bded5cd3bac57c05c58a73241ad6a7fec43dffa7 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 8 Jul 2019 12:52:38 +0300 Subject: [PATCH 269/735] Implement TryFrom for all control elements --- src/api/control/endpoint.rs | 133 +++++++++++++++++++++++++++++++++++- src/api/control/member.rs | 48 +++++++++++-- src/api/control/mod.rs | 14 ++++ src/api/control/pipeline.rs | 4 ++ src/api/control/room.rs | 32 ++++++++- 5 files changed, 224 insertions(+), 7 deletions(-) diff --git a/src/api/control/endpoint.rs b/src/api/control/endpoint.rs index 5064036f8..2aa7c5568 100644 --- a/src/api/control/endpoint.rs +++ b/src/api/control/endpoint.rs @@ -9,7 +9,16 @@ use serde::{ Deserialize, }; -use super::{Element, TryFromElementError, RoomId, MemberId}; +use crate::api::grpc::protos::control::{ + Member_Element as MemberElementProto, + WebRtcPlayEndpoint as WebRtcPlayEndpointProto, + WebRtcPublishEndpoint as WebRtcPublishEndpointProto, + WebRtcPublishEndpoint_P2P as WebRtcPublishEndpointP2pProto, +}; + +use super::{ + Element, MemberId, RoomId, TryFromElementError, TryFromProtobufError, +}; macro_attr! { /// ID of [`Room`]. @@ -50,6 +59,20 @@ pub enum P2pMode { IfPossible, } +impl TryFrom for P2pMode { + type Error = TryFromProtobufError; + + fn try_from( + value: WebRtcPublishEndpointP2pProto, + ) -> Result { + match value { + WebRtcPublishEndpointP2pProto::ALWAYS => P2pMode::Always, + WebRtcPublishEndpointP2pProto::IF_POSSIBLE => P2pMode::IfPossible, + WebRtcPublishEndpointP2pProto::NEVER => P2pMode::Never, + } + } +} + /// [`Endpoint`] represents a media element that one or more media data streams /// flow through. #[derive(Debug)] @@ -58,6 +81,24 @@ pub enum Endpoint { WebRtcPlay(WebRtcPlayEndpoint), } +impl TryFrom<&MemberElementProto> for Endpoint { + type Error = TryFromProtobufError; + + fn try_from(value: &MemberElementProto) -> Result { + if value.has_webrtc_play() { + let play = WebRtcPlayEndpoint::try_from(value.get_webrtc_play())?; + return Endpoint::WebRtcPlay(play); + } else if value.has_webrtc_pub() { + let publish = + WebRtcPublishEndpoint::try_from(value.get_webrtc_pub())?; + return Endpoint::WebRtcPublish(publish); + } else { + // TODO + unimplemented!() + } + } +} + impl TryFrom<&Element> for Endpoint { type Error = TryFromElementError; @@ -83,6 +124,19 @@ pub struct WebRtcPublishEndpoint { pub p2p: P2pMode, } +impl TryFrom<&WebRtcPublishEndpointProto> for WebRtcPublishEndpoint { + type Error = TryFromProtobufError; + + fn try_from( + value: &WebRtcPublishEndpointProto, + ) -> Result { + // TODO: check for null + Self { + p2p: P2pMode::try_from(value.get_p2p())?, + } + } +} + // impl WebRtcPublishEndpoint for WebRtcPublishEndpoint { // fn p2p(&self) -> P2pMode { // self.p2p.clone() @@ -97,6 +151,16 @@ pub struct WebRtcPlayEndpoint { pub src: SrcUri, } +impl TryFrom<&WebRtcPlayEndpointProto> for WebRtcPlayEndpoint { + type Error = TryFromProtobufError; + + fn try_from(value: &WebRtcPlayEndpointProto) -> Result { + Self { + src: parse_src_uri(value.get_src())?, + } + } +} + // impl WebRtcPlayEndpoint for WebRtcPlayEndpoint { // fn src(&self) -> SrcUri { // self.src.clone() @@ -114,6 +178,73 @@ pub struct SrcUri { pub endpoint_id: WebRtcPublishId, } +// TODO +#[derive(Debug, Fail)] +pub enum SrcParseError { + #[fail(display = "Invalid value {}", _0)] + InvalidValue(String), + #[fail(display = "Custom error {}", _0)] + Custom(String), + #[fail(display = "Missing field {}", _0)] + MissingField(String), +} + +fn parse_src_uri(text: &str) -> Result { + let protocol_name: String = value.chars().take(8).collect(); + if protocol_name != "local://" { + return Err(SrcParseError::InvalidValue(format!( + "{} in {}", + protocol_name, value + ))); + } + + let uri_body = value.chars().skip(8).collect::(); + let mut uri_body_splitted: Vec<&str> = uri_body.rsplit('/').collect(); + let uri_body_splitted_len = uri_body_splitted.len(); + if uri_body_splitted_len != 3 { + let error_msg = if uri_body_splitted_len == 0 { + "room_id, member_id, endpoint_id" + } else if uri_body_splitted_len == 1 { + "member_id, endpoint_id" + } else if uri_body_splitted_len == 2 { + "endpoint_id" + } else { + return Err(SrcParseError::Custom(format!( + "Too many fields: {}. Expecting 3 fields, found {}.", + uri_body, uri_body_splitted_len + ))); + }; + return Err(Error::missing_field(error_msg)); + } + let room_id = uri_body_splitted.pop().unwrap().to_string(); + if room_id.is_empty() { + return Err(SrcParseError::Custom(format!( + "room_id in {} is empty!", + value + ))); + } + let member_id = uri_body_splitted.pop().unwrap().to_string(); + if member_id.is_empty() { + return Err(SrcParseError::Custom(format!( + "member_id in {} is empty!", + value + ))); + } + let endpoint_id = uri_body_splitted.pop().unwrap().to_string(); + if endpoint_id.is_empty() { + return Err(SrcParseError::Custom(format!( + "endpoint_id in {} is empty!", + value + ))); + } + + Ok(SrcUri { + room_id: RoomId(room_id), + member_id: MemberId(member_id), + endpoint_id: WebRtcPublishId(endpoint_id), + }) +} + /// Serde deserializer for [`SrcUri`]. /// Deserialize URIs with pattern `local://{room_id}/{member_id}/{endpoint_id}`. impl<'de> Deserialize<'de> for SrcUri { diff --git a/src/api/control/member.rs b/src/api/control/member.rs index 36cb2d31d..29e817c54 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -1,17 +1,24 @@ //! Member definitions and implementations. -use std::convert::TryFrom; +use std::{collections::HashMap as StdHashMap, convert::TryFrom}; use hashbrown::HashMap; use macro_attr::*; use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; use serde::Deserialize; -use crate::api::control::endpoint::{ - WebRtcPlayEndpoint, WebRtcPlayId, WebRtcPublishEndpoint, WebRtcPublishId, +use crate::api::{ + control::endpoint::{ + WebRtcPlayEndpoint, WebRtcPlayId, WebRtcPublishEndpoint, + WebRtcPublishId, + }, + grpc::protos::control::{ + Member as MemberProto, Member_Element as MemberElementProto, + }, }; use super::{pipeline::Pipeline, Element, TryFromElementError}; +use crate::api::control::{Endpoint, TryFromProtobufError}; macro_attr! { /// ID of [`Room`]. @@ -33,10 +40,12 @@ macro_attr! { #[derive(Clone, Debug)] pub struct MemberSpec { /// Spec of this `Member`. - pipeline: Pipeline, + // TODO: remove pub + pub pipeline: Pipeline, /// Credentials to authorize `Member` with. - credentials: String, + // TODO: remove pub + pub credentials: String, } impl MemberSpec { @@ -71,6 +80,35 @@ impl MemberSpec { } } +impl TryFrom<&MemberProto> for MemberSpec { + type Error = TryFromProtobufError; + + fn try_from(value: &MemberProto) -> Result { + let mut pipeline = StdHashMap::new(); + for (id, member_element) in value.get_pipeline() { + let endpoint = Endpoint::try_from(member_element)?; + // TODO: this is temporary + // Need rewrite element logic. + let element = match endpoint { + Endpoint::WebRtcPublish(e) => { + Element::WebRtcPublishEndpoint { spec: e } + } + Endpoint::WebRtcPlay(e) => { + Element::WebRtcPlayEndpoint { spec: e } + } + }; + pipeline.insert(id.clone(), element); + } + let pipeline = Pipeline::new(pipeline); + + Self { + pipeline, + // TODO: error + credentials: value.get_credentials().to_string(), + } + } +} + // impl MemberSpec for MemberSpec { // fn webrtc_play_endpoints( // &self, diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index a93966747..e6cf0cccd 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -20,6 +20,20 @@ pub use self::{ member::{Id as MemberId, MemberSpec}, room::{Id as RoomId, RoomSpec}, }; +use crate::api::control::endpoint::SrcParseError; + +#[derive(Debug, Fail)] +pub enum TryFromProtobufError { + #[fail(display = "Src uri parse error: {:?}", _0)] + SrcUriError(SrcParseError), +} + +// TODO: Maybe better way for do it??? +impl From for TryFromProtobufError { + fn from(from: SrcParseError) -> Self { + TryFromProtobufError::SrcUriError(from) + } +} /// Errors that can occur when we try transform some spec from [`Element`]. /// This error used in all [`TryFrom`] of Control API. diff --git a/src/api/control/pipeline.rs b/src/api/control/pipeline.rs index 1456ae7d2..e7a14519b 100644 --- a/src/api/control/pipeline.rs +++ b/src/api/control/pipeline.rs @@ -19,6 +19,10 @@ pub struct Pipeline { } impl Pipeline { + pub fn new(pipeline: HashMap) -> Self { + Self { pipeline } + } + pub fn iter(&self) -> impl Iterator { self.into_iter() } diff --git a/src/api/control/room.rs b/src/api/control/room.rs index b82dbbeb9..dbfab8daa 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -1,16 +1,21 @@ //! Room definitions and implementations. -use std::convert::TryFrom; +use std::{collections::HashMap as StdHashMap, convert::TryFrom}; use hashbrown::HashMap; use macro_attr::*; use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; use serde::Deserialize; +use crate::api::grpc::protos::control::{ + Room as RoomProto, Room_Element as RoomElementProto, +}; + use super::{ member::MemberSpec, pipeline::Pipeline, Element, MemberId, TryFromElementError, }; +use crate::api::control::TryFromProtobufError; macro_attr! { /// ID of [`Room`]. @@ -58,6 +63,31 @@ impl RoomSpec { } } +impl TryFrom<&RoomProto> for RoomSpec { + type Error = TryFromProtobufError; + + fn try_from(value: &RoomProto) -> Result { + let mut pipeline = StdHashMap::new(); + for (id, room_element) in value.get_pipeline() { + let member = MemberSpec::try_from(&room_element)?; + // TODO: temporary + let element = Element::Member { + spec: member.pipeline, + credentials: member.credentials, + }; + pipeline.insert(id.clone(), element); + } + + let pipeline = Pipeline::new(pipeline); + + Self { + pipeline, + // TODO: + id: Id("unimplemented".to_string()), + } + } +} + // pub struct SerdeRoomSpecImpl { // id: Id, // members: HashMap, From b9dba3cc68a923505a7dc8ee3e59eea46ebd0b82 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 8 Jul 2019 13:14:10 +0300 Subject: [PATCH 270/735] Fix errors --- src/api/control/endpoint.rs | 22 +++--- src/api/control/member.rs | 4 +- src/api/control/room.rs | 6 +- src/api/grpc/server.rs | 121 ++++++++++++++---------------- src/lib.rs | 16 ++-- src/main.rs | 2 +- src/signalling/elements/member.rs | 4 +- src/signalling/participants.rs | 5 +- src/signalling/room.rs | 2 +- src/signalling/room_repo.rs | 19 +++-- src/turn/service.rs | 2 +- 11 files changed, 99 insertions(+), 104 deletions(-) diff --git a/src/api/control/endpoint.rs b/src/api/control/endpoint.rs index 2aa7c5568..ee80b084f 100644 --- a/src/api/control/endpoint.rs +++ b/src/api/control/endpoint.rs @@ -2,6 +2,7 @@ use std::{convert::TryFrom, fmt}; +use failure::Fail; use macro_attr::*; use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; use serde::{ @@ -59,17 +60,18 @@ pub enum P2pMode { IfPossible, } +// TODO: use From impl TryFrom for P2pMode { type Error = TryFromProtobufError; fn try_from( value: WebRtcPublishEndpointP2pProto, ) -> Result { - match value { + Ok(match value { WebRtcPublishEndpointP2pProto::ALWAYS => P2pMode::Always, WebRtcPublishEndpointP2pProto::IF_POSSIBLE => P2pMode::IfPossible, WebRtcPublishEndpointP2pProto::NEVER => P2pMode::Never, - } + }) } } @@ -87,11 +89,11 @@ impl TryFrom<&MemberElementProto> for Endpoint { fn try_from(value: &MemberElementProto) -> Result { if value.has_webrtc_play() { let play = WebRtcPlayEndpoint::try_from(value.get_webrtc_play())?; - return Endpoint::WebRtcPlay(play); + return Ok(Endpoint::WebRtcPlay(play)); } else if value.has_webrtc_pub() { let publish = WebRtcPublishEndpoint::try_from(value.get_webrtc_pub())?; - return Endpoint::WebRtcPublish(publish); + return Ok(Endpoint::WebRtcPublish(publish)); } else { // TODO unimplemented!() @@ -131,9 +133,9 @@ impl TryFrom<&WebRtcPublishEndpointProto> for WebRtcPublishEndpoint { value: &WebRtcPublishEndpointProto, ) -> Result { // TODO: check for null - Self { + Ok(Self { p2p: P2pMode::try_from(value.get_p2p())?, - } + }) } } @@ -155,9 +157,9 @@ impl TryFrom<&WebRtcPlayEndpointProto> for WebRtcPlayEndpoint { type Error = TryFromProtobufError; fn try_from(value: &WebRtcPlayEndpointProto) -> Result { - Self { + Ok(Self { src: parse_src_uri(value.get_src())?, - } + }) } } @@ -189,7 +191,7 @@ pub enum SrcParseError { MissingField(String), } -fn parse_src_uri(text: &str) -> Result { +fn parse_src_uri(value: &str) -> Result { let protocol_name: String = value.chars().take(8).collect(); if protocol_name != "local://" { return Err(SrcParseError::InvalidValue(format!( @@ -214,7 +216,7 @@ fn parse_src_uri(text: &str) -> Result { uri_body, uri_body_splitted_len ))); }; - return Err(Error::missing_field(error_msg)); + return Err(SrcParseError::MissingField(error_msg.to_string())); } let room_id = uri_body_splitted.pop().unwrap().to_string(); if room_id.is_empty() { diff --git a/src/api/control/member.rs b/src/api/control/member.rs index 29e817c54..365449c42 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -101,11 +101,11 @@ impl TryFrom<&MemberProto> for MemberSpec { } let pipeline = Pipeline::new(pipeline); - Self { + Ok(Self { pipeline, // TODO: error credentials: value.get_credentials().to_string(), - } + }) } } diff --git a/src/api/control/room.rs b/src/api/control/room.rs index dbfab8daa..c67bf99d7 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -69,7 +69,7 @@ impl TryFrom<&RoomProto> for RoomSpec { fn try_from(value: &RoomProto) -> Result { let mut pipeline = StdHashMap::new(); for (id, room_element) in value.get_pipeline() { - let member = MemberSpec::try_from(&room_element)?; + let member = MemberSpec::try_from(room_element.get_member())?; // TODO: temporary let element = Element::Member { spec: member.pipeline, @@ -80,11 +80,11 @@ impl TryFrom<&RoomProto> for RoomSpec { let pipeline = Pipeline::new(pipeline); - Self { + Ok(Self { pipeline, // TODO: id: Id("unimplemented".to_string()), - } + }) } } diff --git a/src/api/grpc/server.rs b/src/api/grpc/server.rs index 93dd7cbba..686e3b1e9 100644 --- a/src/api/grpc/server.rs +++ b/src/api/grpc/server.rs @@ -1,4 +1,4 @@ -use std::{sync::Arc, time::Duration}; +use std::{convert::TryFrom, sync::Arc, time::Duration}; use actix::{Actor, Addr, Arbiter, Context}; use futures::future::Future; @@ -6,10 +6,7 @@ use grpcio::{Environment, RpcContext, Server, ServerBuilder, UnarySink}; use crate::{ api::{ - control::{ - model::{room::RoomSpec, RoomId}, - protobuf::room::CreateRequestSpec, - }, + control::{RoomId, RoomSpec}, grpc::protos::control::{ ApplyRequest, CreateRequest, GetResponse, IdRequest, Response, }, @@ -22,10 +19,7 @@ use crate::{ use super::protos::control_grpc::{create_control_api, ControlApi}; use crate::{ - api::{ - control::model::local_uri::{parse_local_uri, LocalUri}, - grpc::protos::control::Error, - }, + api::grpc::protos::control::Error, signalling::room_repo::{DeleteRoom, StartRoom}, }; use futures::future::Either; @@ -47,49 +41,50 @@ impl ControlApi for ControlApiService { // TODO let room_id = RoomId(req.get_id().to_string()); - let msg = StartRoom { - room: CreateRequestSpec(req), - }; - - let sid: HashMap = msg - .room - .members() - .iter() - .map(|(id, member)| { - let addr = &self.app.config.server.bind_ip; - let port = self.app.config.server.bind_port; - let base_uri = format!("{}:{}", addr, port); - - let uri = format!( - "wss://{}/{}/{}/{}", - base_uri, - &room_id, - id, - member.credentials() - ); - - (id.clone().to_string(), uri) - }) - .collect(); - - ctx.spawn(self.room_repository.send(msg).map_err(|e| ()).and_then( - move |r| { - if r.is_ok() { - let mut res = Response::new(); - res.set_sid(sid); - Either::A(sink.success(res).map_err(|_| ())) - } else { - let mut res = Response::new(); - let mut error = Error::new(); - error.set_status(500); - error.set_code(500); - error.set_text(String::new()); - error.set_element(String::new()); - res.set_error(error); - Either::B(sink.success(res).map_err(|_| ())) - } - }, - )); + let room = RoomSpec::try_from(req.get_room()).unwrap(); + + // let sid: HashMap = msg + // .room + // .members() + // .iter() + // .map(|(id, member)| { + // let addr = &self.app.config.server.bind_ip; + // let port = self.app.config.server.bind_port; + // let base_uri = format!("{}:{}", addr, port); + // + // let uri = format!( + // "wss://{}/{}/{}/{}", + // base_uri, + // &room_id, + // id, + // member.credentials() + // ); + // + // (id.clone().to_string(), uri) + // }) + // .collect(); + + ctx.spawn( + self.room_repository + .send(StartRoom(room_id, room)) + .map_err(|e| ()) + .and_then(move |r| { + if r.is_ok() { + let mut res = Response::new(); + res.set_sid(HashMap::new()); + Either::A(sink.success(res).map_err(|_| ())) + } else { + let mut res = Response::new(); + let mut error = Error::new(); + error.set_status(500); + error.set_code(500); + error.set_text(String::new()); + error.set_element(String::new()); + res.set_error(error); + Either::B(sink.success(res).map_err(|_| ())) + } + }), + ); // self.room_repository.add(room_id, room); @@ -111,17 +106,17 @@ impl ControlApi for ControlApiService { req: IdRequest, sink: UnarySink, ) { - for id in req.get_id() { - let uri = parse_local_uri(id).unwrap(); // TODO - if uri.is_room_id() { - self.room_repository - .do_send(DeleteRoom(uri.room_id.unwrap())) - } - } - - let mut resp = Response::new(); - resp.set_sid(HashMap::new()); - ctx.spawn(sink.success(resp).map_err(|_| ())); + // for id in req.get_id() { + // let uri = parse_local_uri(id).unwrap(); // TODO + // if uri.is_room_id() { + // self.room_repository + // .do_send(DeleteRoom(uri.room_id.unwrap())) + // } + // } + // + // let mut resp = Response::new(); + // resp.set_sid(HashMap::new()); + // ctx.spawn(sink.success(resp).map_err(|_| ())); } fn get( diff --git a/src/lib.rs b/src/lib.rs index 7c9f7d4c9..b3cd527c3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -14,7 +14,7 @@ use failure::Fail; use hashbrown::HashMap; use crate::{ - api::control::{load_static_specs_from_dir, room::RoomSpec, RoomId}, + api::control::{load_static_specs_from_dir, RoomId}, conf::Conf, signalling::{room::RoomError, Room}, turn::service, @@ -68,9 +68,9 @@ impl From for ServerStartError { /// Returns [`ServerStartError::BadRoomSpec`] /// if some error happened while creating room from spec. pub fn start_static_rooms( - app: Arc, + config: &Conf, ) -> Result>, ServerStartError> { - if let Some(static_specs_path) = &app.config.server.static_specs_path { + if let Some(static_specs_path) = &config.server.static_specs_path { let room_specs = match load_static_specs_from_dir(static_specs_path) { Ok(r) => r, Err(e) => return Err(ServerStartError::LoadSpec(e)), @@ -85,18 +85,16 @@ pub fn start_static_rooms( )); } - let turn_auth_service = service::new_turn_auth_service(&app.config) + let turn_auth_service = service::new_turn_auth_service(&config) .expect("Unable to start turn service"); let room_id = spec.id().clone(); - let rpc_reconnect_timeout = app.config.rpc.reconnect_timeout; + let rpc_reconnect_timeout = config.rpc.reconnect_timeout; let room = Room::start_in_arbiter(&arbiter, move |_| { - let parsed_spec = SerdeRoomSpecImpl::new(&spec).unwrap(); - let parsed_spec = Box::new(&parsed_spec as &RoomSpec); Room::new( - &parsed_spec, + &spec, rpc_reconnect_timeout, - Arc::new(turn_auth_service), // TODO: tmp + Arc::new(turn_auth_service), ) .unwrap() }); diff --git a/src/main.rs b/src/main.rs index 4be11d51e..e986a4089 100644 --- a/src/main.rs +++ b/src/main.rs @@ -26,7 +26,7 @@ fn main() -> Result<(), Error> { turn_service: Arc::new(new_turn_auth_service(&config).unwrap()), }); - let rooms = start_static_rooms(Arc::clone(&app))?; + let rooms = start_static_rooms(&app.config)?; info!( "Loaded rooms: {:?}", rooms.iter().map(|(id, _)| &id.0).collect::>() diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index 9f994e60b..d7997eb7a 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -118,7 +118,7 @@ impl Member { .get(&spec_play_endpoint.src.endpoint_id) .map_or( Err(MembersLoadError::EndpointNotFound( - spec_play_endpoint.src.endpoint_id.clone(), + spec_play_endpoint.src.endpoint_id.to_string(), )), Ok, )?; @@ -171,7 +171,7 @@ impl Member { // to which none [`WebRtcPlayEndpoint`] refers. this_member_spec.publish_endpoints().into_iter().for_each( |(name, e)| { - let endpoint_id = WebRtcPublishId(name.clone()); + let endpoint_id = WebRtcPublishId(name.to_string()); // TODO if self.srcs().get(&endpoint_id).is_none() { self.insert_src(Rc::new(WebRtcPublishEndpoint::new( endpoint_id, diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 4509d8a42..f0e0749d9 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -5,6 +5,7 @@ use std::{ rc::Rc, + sync::Arc, time::{Duration, Instant}, }; @@ -76,7 +77,7 @@ pub struct ParticipantService { members: HashMap>, /// Service for managing authorization on Turn server. - turn: Box, + turn: Arc>, /// Established [`RpcConnection`]s of [`Members`]s in this [`Room`]. // TODO: Replace Box> with enum, @@ -98,7 +99,7 @@ impl ParticipantService { pub fn new( room_spec: &RoomSpec, reconnect_timeout: Duration, - turn: Box, + turn: Arc>, ) -> Result { Ok(Self { room_id: room_spec.id().clone(), diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 4a244b878..1d06c7481 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -18,7 +18,7 @@ use crate::{ AuthorizationError, Authorize, ClosedReason, CommandMessage, RpcConnectionClosed, RpcConnectionEstablished, }, - control::{room::RoomSpec, RoomId, TryFromElementError}, + control::{room::RoomSpec, MemberId, RoomId, TryFromElementError}, }, log::prelude::*, media::{ diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs index fef474698..46ce5532f 100644 --- a/src/signalling/room_repo.rs +++ b/src/signalling/room_repo.rs @@ -59,30 +59,29 @@ impl Actor for RoomsRepository { // TODO: return sids. #[derive(Message)] #[rtype(result = "Result<(), RoomError>")] -pub struct StartRoom { - pub room: T, -} +pub struct StartRoom(pub RoomId, pub RoomSpec); -impl Handler> for RoomsRepository { +impl Handler for RoomsRepository { type Result = Result<(), RoomError>; fn handle( &mut self, - msg: StartRoom, + msg: StartRoom, ctx: &mut Self::Context, ) -> Self::Result { - let room_id = msg.room.id(); + let room_id = msg.0; + let room = msg.1; let turn = Arc::clone(&self.app.turn_service); + // TODO: spawn in current arbiter. { - let room = Box::new(&msg.room as &(RoomSpec)); - Room::new(&room, Duration::from_secs(10), Arc::clone(&turn))?; + // let room = Box::new(&msg.room as &(RoomSpec)); + // Room::new(&room, Duration::from_secs(10), + // Arc::clone(&turn))?; } let room = Room::start_in_arbiter(&Arbiter::new(), move |_| { - let room = msg.room; - let room = Box::new(&room as &(RoomSpec)); Room::new(&room, Duration::from_secs(10), turn).unwrap() }); diff --git a/src/turn/service.rs b/src/turn/service.rs index 300e07f63..39bd2ff22 100644 --- a/src/turn/service.rs +++ b/src/turn/service.rs @@ -154,7 +154,7 @@ struct Service { #[allow(clippy::module_name_repetitions)] pub fn new_turn_auth_service( config: &Conf, -) -> Result, TurnServiceErr> { +) -> Result, TurnServiceErr> { let turn_db = TurnDatabase::new( config.turn.db.redis.connection_timeout, ConnectionInfo { From 11f2f0f0982549b22b0024b4999138b1b657c190 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 8 Jul 2019 13:29:48 +0300 Subject: [PATCH 271/735] Add check for protobuf fields providing --- src/api/control/endpoint.rs | 21 ++++++++++++++------- src/api/control/member.rs | 4 ++++ src/api/control/mod.rs | 10 ++++++++++ src/api/control/room.rs | 3 +++ 4 files changed, 31 insertions(+), 7 deletions(-) diff --git a/src/api/control/endpoint.rs b/src/api/control/endpoint.rs index ee80b084f..195b133b4 100644 --- a/src/api/control/endpoint.rs +++ b/src/api/control/endpoint.rs @@ -132,10 +132,13 @@ impl TryFrom<&WebRtcPublishEndpointProto> for WebRtcPublishEndpoint { fn try_from( value: &WebRtcPublishEndpointProto, ) -> Result { - // TODO: check for null - Ok(Self { - p2p: P2pMode::try_from(value.get_p2p())?, - }) + if value.has_p2p() { + Ok(Self { + p2p: P2pMode::try_from(value.get_p2p())?, + }) + } else { + Err(TryFromProtobufError::P2pModeNotFound) + } } } @@ -157,9 +160,13 @@ impl TryFrom<&WebRtcPlayEndpointProto> for WebRtcPlayEndpoint { type Error = TryFromProtobufError; fn try_from(value: &WebRtcPlayEndpointProto) -> Result { - Ok(Self { - src: parse_src_uri(value.get_src())?, - }) + if value.has_src() { + Ok(Self { + src: parse_src_uri(value.get_src())?, + }) + } else { + Err(TryFromProtobufError::SrcUriNotFound) + } } } diff --git a/src/api/control/member.rs b/src/api/control/member.rs index 365449c42..edc69f4a5 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -101,6 +101,10 @@ impl TryFrom<&MemberProto> for MemberSpec { } let pipeline = Pipeline::new(pipeline); + if !value.has_credentials() { + return Err(TryFromProtobufError::MemberCredentialsNotFound); + } + Ok(Self { pipeline, // TODO: error diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index e6cf0cccd..f1e9a3e22 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -26,6 +26,16 @@ use crate::api::control::endpoint::SrcParseError; pub enum TryFromProtobufError { #[fail(display = "Src uri parse error: {:?}", _0)] SrcUriError(SrcParseError), + #[fail(display = "Src uri for publish endpoint not provided.")] + SrcUriNotFound, + #[fail(display = "Room element not provided.")] + RoomElementNotFound, + #[fail(display = "Member element not provided.")] + MemberElementNotFound, + #[fail(display = "P2p mode for play endpoint not provided.")] + P2pModeNotFound, + #[fail(display = "Credentials for member not provided.")] + MemberCredentialsNotFound, } // TODO: Maybe better way for do it??? diff --git a/src/api/control/room.rs b/src/api/control/room.rs index c67bf99d7..d82816649 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -69,6 +69,9 @@ impl TryFrom<&RoomProto> for RoomSpec { fn try_from(value: &RoomProto) -> Result { let mut pipeline = StdHashMap::new(); for (id, room_element) in value.get_pipeline() { + if !room_element.has_member() { + return Err(TryFromProtobufError::MemberElementNotFound); + } let member = MemberSpec::try_from(room_element.get_member())?; // TODO: temporary let element = Element::Member { From f8e349bffe24a45618e0151bb9a1c19b73ea4b3f Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 8 Jul 2019 13:31:31 +0300 Subject: [PATCH 272/735] Cleanup --- src/api/control/endpoint.rs | 12 - src/api/control/member.rs | 63 ------ src/api/control/model/endpoint/mod.rs | 1 - src/api/control/model/endpoint/webrtc/mod.rs | 6 - .../model/endpoint/webrtc/play_endpoint.rs | 26 --- .../model/endpoint/webrtc/publish_endpoint.rs | 45 ---- src/api/control/model/local_uri.rs | 210 ------------------ src/api/control/model/member.rs | 30 --- src/api/control/model/mod.rs | 8 - src/api/control/model/room.rs | 16 -- src/api/control/protobuf/member.rs | 101 --------- src/api/control/protobuf/mod.rs | 4 - src/api/control/protobuf/room.rs | 60 ----- .../control/protobuf/webrtc_play_endpoint.rs | 67 ------ .../protobuf/webrtc_publish_endpoint.rs | 18 -- src/api/control/room.rs | 37 --- 16 files changed, 704 deletions(-) delete mode 100644 src/api/control/model/endpoint/mod.rs delete mode 100644 src/api/control/model/endpoint/webrtc/mod.rs delete mode 100644 src/api/control/model/endpoint/webrtc/play_endpoint.rs delete mode 100644 src/api/control/model/endpoint/webrtc/publish_endpoint.rs delete mode 100644 src/api/control/model/local_uri.rs delete mode 100644 src/api/control/model/member.rs delete mode 100644 src/api/control/model/mod.rs delete mode 100644 src/api/control/model/room.rs delete mode 100644 src/api/control/protobuf/member.rs delete mode 100644 src/api/control/protobuf/mod.rs delete mode 100644 src/api/control/protobuf/room.rs delete mode 100644 src/api/control/protobuf/webrtc_play_endpoint.rs delete mode 100644 src/api/control/protobuf/webrtc_publish_endpoint.rs diff --git a/src/api/control/endpoint.rs b/src/api/control/endpoint.rs index 195b133b4..79cca8e68 100644 --- a/src/api/control/endpoint.rs +++ b/src/api/control/endpoint.rs @@ -142,12 +142,6 @@ impl TryFrom<&WebRtcPublishEndpointProto> for WebRtcPublishEndpoint { } } -// impl WebRtcPublishEndpoint for WebRtcPublishEndpoint { -// fn p2p(&self) -> P2pMode { -// self.p2p.clone() -// } -// } - /// Media element which is able to play media data for client via WebRTC. #[allow(clippy::module_name_repetitions)] #[derive(Clone, Deserialize, Debug)] @@ -170,12 +164,6 @@ impl TryFrom<&WebRtcPlayEndpointProto> for WebRtcPlayEndpoint { } } -// impl WebRtcPlayEndpoint for WebRtcPlayEndpoint { -// fn src(&self) -> SrcUri { -// self.src.clone() -// } -// } - /// Special uri with pattern `local://{room_id}/{member_id}/{endpoint_id}`. #[derive(Clone, Debug)] pub struct SrcUri { diff --git a/src/api/control/member.rs b/src/api/control/member.rs index edc69f4a5..23f480546 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -113,69 +113,6 @@ impl TryFrom<&MemberProto> for MemberSpec { } } -// impl MemberSpec for MemberSpec { -// fn webrtc_play_endpoints( -// &self, -// ) -> HashMap> { -// self.pipeline -// .iter() -// .filter_map(|(id, e)| match e { -// Element::WebRtcPlayEndpoint { spec } => Some(( -// WebRtcPlayId(id.clone()), -// Box::new(spec.clone()) as Box, -// )), -// _ => None, -// }) -// .collect() -// } -// -// fn webrtc_publish_endpoints( -// &self, -// ) -> HashMap> { -// self.pipeline -// .iter() -// .filter_map(|(id, e)| match e { -// Element::WebRtcPublishEndpoint { spec } => Some(( -// WebRtcPublishId(id.clone()), -// Box::new(spec.clone()) as Box, -// )), -// _ => None, -// }) -// .collect() -// } -// -// fn credentials(&self) -> &str { -// &self.credentials -// } -// -// fn get_webrtc_play_by_id( -// &self, -// id: &WebRtcPlayId, -// ) -> Option> { -// let element = self.pipeline.get(&id.0)?; -// -// if let Some(endpoint) = SerdeEndpoint::try_from(element).ok() { -// if let SerdeEndpoint::WebRtcPlay(e) = endpoint { -// return Some(Box::new(e) as Box); -// } -// } -// None -// } -// -// fn get_webrtc_publish_by_id( -// &self, -// id: &WebRtcPublishId, -// ) -> Option> { -// let element = self.pipeline.get(&id.0)?; -// if let Some(endpoint) = SerdeEndpoint::try_from(element).ok() { -// if let SerdeEndpoint::WebRtcPublish(e) = endpoint { -// return Some(Box::new(e) as Box); -// } -// } -// None -// } -// } - impl TryFrom<&Element> for MemberSpec { type Error = TryFromElementError; diff --git a/src/api/control/model/endpoint/mod.rs b/src/api/control/model/endpoint/mod.rs deleted file mode 100644 index c050ca143..000000000 --- a/src/api/control/model/endpoint/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod webrtc; diff --git a/src/api/control/model/endpoint/webrtc/mod.rs b/src/api/control/model/endpoint/webrtc/mod.rs deleted file mode 100644 index 06e3b3f69..000000000 --- a/src/api/control/model/endpoint/webrtc/mod.rs +++ /dev/null @@ -1,6 +0,0 @@ -pub mod play_endpoint; -pub mod publish_endpoint; - -pub use crate::api::control::serde::endpoint::SerdeSrcUri as SrcUri; -pub use play_endpoint::{WebRtcPlayEndpoint, WebRtcPlayId}; -pub use publish_endpoint::{P2pMode, WebRtcPublishEndpoint, WebRtcPublishId}; diff --git a/src/api/control/model/endpoint/webrtc/play_endpoint.rs b/src/api/control/model/endpoint/webrtc/play_endpoint.rs deleted file mode 100644 index 8e7eaaf1b..000000000 --- a/src/api/control/model/endpoint/webrtc/play_endpoint.rs +++ /dev/null @@ -1,26 +0,0 @@ -use macro_attr::*; -use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; -use serde::Deserialize; - -use crate::api::control::serde::endpoint::SerdeSrcUri; - -pub use Id as WebRtcPlayId; - -macro_attr! { - /// ID of [`Room`]. - #[derive( - Clone, - Debug, - Deserialize, - Eq, - Hash, - PartialEq, - NewtypeFrom!, - NewtypeDisplay!, - )] - pub struct Id(pub String); -} - -pub trait WebRtcPlayEndpoint { - fn src(&self) -> SerdeSrcUri; -} diff --git a/src/api/control/model/endpoint/webrtc/publish_endpoint.rs b/src/api/control/model/endpoint/webrtc/publish_endpoint.rs deleted file mode 100644 index d4cfce5e5..000000000 --- a/src/api/control/model/endpoint/webrtc/publish_endpoint.rs +++ /dev/null @@ -1,45 +0,0 @@ -use macro_attr::*; -use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; -use serde::Deserialize; // TODO: temp - -use crate::api::grpc::protos::control::WebRtcPublishEndpoint_P2P; - -macro_attr! { - /// ID of [`Room`]. - #[derive( - Clone, - Debug, - Deserialize, - Eq, - Hash, - PartialEq, - NewtypeFrom!, - NewtypeDisplay!, - )] - pub struct Id(pub String); -} - -pub use Id as WebRtcPublishId; - -pub trait WebRtcPublishEndpoint { - fn p2p(&self) -> P2pMode; -} - -/// Peer-to-peer mode of [`WebRtcPublishEndpoint`]. -#[derive(Clone, Deserialize, Debug)] -pub enum P2pMode { - /// Always connect peer-to-peer. - Always, - Never, - IfPossible, -} - -impl From for P2pMode { - fn from(from: WebRtcPublishEndpoint_P2P) -> Self { - match from { - WebRtcPublishEndpoint_P2P::ALWAYS => P2pMode::Always, - WebRtcPublishEndpoint_P2P::IF_POSSIBLE => P2pMode::IfPossible, - WebRtcPublishEndpoint_P2P::NEVER => P2pMode::Never, - } - } -} diff --git a/src/api/control/model/local_uri.rs b/src/api/control/model/local_uri.rs deleted file mode 100644 index 3e3da86d2..000000000 --- a/src/api/control/model/local_uri.rs +++ /dev/null @@ -1,210 +0,0 @@ -use std::fmt; - -use failure::Fail; -use macro_attr::*; -use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; -use serde::{ - de::{self, Deserializer, Error, Unexpected, Visitor}, - Deserialize, -}; - -use super::{MemberId, RoomId, WebRtcPublishId}; - -// TODO: Move into endpoint module and implement From<...Pub...> -// From<...Play...>. -macro_attr! { - /// ID of [`Room`]. - #[derive( - Clone, - Debug, - Deserialize, - Eq, - Hash, - PartialEq, - NewtypeFrom!, - NewtypeDisplay!, - )] - pub struct EndpointId(pub String); -} - -/// Special uri with pattern `local://{room_id}/{member_id}/{endpoint_id}`. -#[derive(Clone, Debug)] -// TODO: combine with SrcUri. -pub struct LocalUri { - /// ID of [`Room`] - pub room_id: Option, - /// ID of `Member` - pub member_id: Option, - /// Control ID of [`Endpoint`] - pub endpoint_id: Option, -} - -impl LocalUri { - pub fn is_room_id(&self) -> bool { - self.room_id.is_some() - && self.member_id.is_none() - && self.endpoint_id.is_none() - } - - pub fn is_member_id(&self) -> bool { - self.room_id.is_some() - && self.member_id.is_some() - && self.endpoint_id.is_none() - } - - pub fn is_endpoint_id(&self) -> bool { - self.room_id.is_some() - && self.member_id.is_some() - && self.endpoint_id.is_some() - } -} - -#[derive(Debug, Fail)] -pub enum ParseError { - #[fail(display = "Too many fields")] - TooManyFields, - #[fail(display = "Not local uri. {}", _0)] - NotLocalUri(String), -} - -pub fn parse_local_uri(text: &str) -> Result { - let protocol_name: String = text.chars().take(8).collect(); - if protocol_name != "local://" { - return Err(ParseError::NotLocalUri(protocol_name)); - } - - let uri_body = text.chars().skip(8).collect::(); - let mut uri_body_splitted: Vec<&str> = uri_body.rsplit('/').collect(); - let uri_body_splitted_len = uri_body_splitted.len(); - - if uri_body_splitted_len == 1 { - return Ok(LocalUri { - room_id: Some(RoomId(uri_body_splitted.pop().unwrap().to_string())), - member_id: None, - endpoint_id: None, - }); - } else if uri_body_splitted_len == 2 { - return Ok(LocalUri { - room_id: Some(RoomId(uri_body_splitted.pop().unwrap().to_string())), - member_id: Some(MemberId( - uri_body_splitted.pop().unwrap().to_string(), - )), - endpoint_id: None, - }); - } else if uri_body_splitted_len == 3 { - return Ok(LocalUri { - room_id: Some(RoomId(uri_body_splitted.pop().unwrap().to_string())), - member_id: Some(MemberId( - uri_body_splitted.pop().unwrap().to_string(), - )), - endpoint_id: Some(EndpointId( - uri_body_splitted.pop().unwrap().to_string(), - )), - }); - } else { - return Err(ParseError::TooManyFields); - } -} - -/// Serde deserializer for [`SrcUri`]. -/// Deserialize URIs with pattern `local://{room_id}/{member_id}/{endpoint_id}`. -impl<'de> Deserialize<'de> for LocalUri { - fn deserialize(deserializer: D) -> Result - where - D: Deserializer<'de>, - { - struct SrcUriVisitor; - - impl<'de> Visitor<'de> for SrcUriVisitor { - type Value = LocalUri; - - fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str( - "Uri in format local://room_id/member_id/endpoint_id", - ) - } - - fn visit_str(self, value: &str) -> Result - where - E: de::Error, - { - match parse_local_uri(value) { - Ok(uri) => return Ok(uri), - Err(e) => match e { - ParseError::NotLocalUri(protocol_name) => { - Err(Error::invalid_value( - Unexpected::Str(&format!( - "{} in {}", - protocol_name, value - )), - &self, - )) - } - ParseError::TooManyFields => { - Err(Error::custom("Too many fields.")) - } - }, - } - } - } - - deserializer.deserialize_identifier(SrcUriVisitor) - } -} - -#[cfg(test)] -mod src_uri_deserialization_tests { - use serde::Deserialize; - - use super::*; - - #[derive(Deserialize)] - struct SrcUriTest { - src: LocalUri, - } - - #[inline] - fn id>(s: &str) -> T { - T::from(s.to_string()) - } - - #[test] - fn deserialize() { - let valid_json_uri = - r#"{ "src": "local://room_id/member_id/endpoint_id" }"#; - let local_uri: SrcUriTest = - serde_json::from_str(valid_json_uri).unwrap(); - - assert_eq!(local_uri.src.member_id, id("member_id")); - assert_eq!(local_uri.src.room_id, id("room_id")); - assert_eq!(local_uri.src.endpoint_id, id("endpoint_id")); - } - - #[test] - fn return_error_when_uri_not_local() { - let invalid_json_uri = - r#"{ "src": "not_local://room_id/member_id/endpoint_id" }"#; - match serde_json::from_str::(invalid_json_uri) { - Ok(_) => assert!(false), - Err(_) => assert!(true), - } - } - - #[test] - fn return_error_when_uri_is_not_full() { - let invalid_json_uri = r#"{ "src": "local://room_id/member_id" }"#; - match serde_json::from_str::(invalid_json_uri) { - Ok(_) => assert!(false), - Err(_) => assert!(true), - } - } - - #[test] - fn return_error_when_uri_have_empty_part() { - let invalid_json_uri = r#"{ "src": "local://room_id//endpoint_id" }"#; - match serde_json::from_str::(invalid_json_uri) { - Ok(_) => assert!(false), - Err(_) => assert!(true), - } - } -} diff --git a/src/api/control/model/member.rs b/src/api/control/model/member.rs deleted file mode 100644 index df66d85e5..000000000 --- a/src/api/control/model/member.rs +++ /dev/null @@ -1,30 +0,0 @@ -use super::endpoint::webrtc::*; -use hashbrown::HashMap; -use macro_attr::*; -use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; -use serde::Deserialize; - - -pub use Id as MemberId; - -pub trait MemberSpec { - fn webrtc_play_endpoints( - &self, - ) -> HashMap>; - - fn webrtc_publish_endpoints( - &self, - ) -> HashMap>; - - fn credentials(&self) -> &str; - - fn get_webrtc_play_by_id( - &self, - id: &WebRtcPlayId, - ) -> Option>; - - fn get_webrtc_publish_by_id( - &self, - id: &WebRtcPublishId, - ) -> Option>; -} diff --git a/src/api/control/model/mod.rs b/src/api/control/model/mod.rs deleted file mode 100644 index 506132e5a..000000000 --- a/src/api/control/model/mod.rs +++ /dev/null @@ -1,8 +0,0 @@ -pub mod endpoint; -pub mod local_uri; -pub mod member; -pub mod room; - -pub use endpoint::webrtc::{WebRtcPlayId, WebRtcPublishId}; -pub use member::Id as MemberId; -pub use room::Id as RoomId; diff --git a/src/api/control/model/room.rs b/src/api/control/model/room.rs deleted file mode 100644 index ce51ea9bf..000000000 --- a/src/api/control/model/room.rs +++ /dev/null @@ -1,16 +0,0 @@ -use crate::api::control::model::member::{MemberId, MemberSpec}; -use hashbrown::HashMap; -use macro_attr::*; -use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; -use serde::Deserialize; - - -pub use Id as RoomId; - -pub trait RoomSpec { - fn members(&self) -> HashMap>; - - fn id(&self) -> Id; - - fn get_member_by_id(&self, id: &MemberId) -> Option>; -} diff --git a/src/api/control/protobuf/member.rs b/src/api/control/protobuf/member.rs deleted file mode 100644 index 01371a9ec..000000000 --- a/src/api/control/protobuf/member.rs +++ /dev/null @@ -1,101 +0,0 @@ -use hashbrown::HashMap; - -use crate::{ - api::{ - control::{ - model::{ - endpoint::webrtc::{WebRtcPlayEndpoint, WebRtcPublishEndpoint}, - member::MemberSpec, - }, - protobuf::{ - webrtc_play_endpoint::GrpcWebRtcPlayEndpointSpecImpl, - webrtc_publish_endpoint::GrpcWebRtcPublishEndpointSpecImpl, - }, - }, - grpc::protos::control::Member as MemberProto, - }, - signalling::elements::endpoints::webrtc::{WebRtcPlayId, WebRtcPublishId}, -}; - -pub struct GrpcMemberSpecImpl(pub MemberProto); - -impl MemberSpec for GrpcMemberSpecImpl { - fn webrtc_play_endpoints( - &self, - ) -> HashMap> { - self.0 - .get_pipeline() - .iter() - .filter_map(|(id, element)| { - if element.has_webrtc_play() { - let endpoint = element.get_webrtc_play().clone(); - Some(( - WebRtcPlayId(id.clone()), - Box::new(GrpcWebRtcPlayEndpointSpecImpl(endpoint)) - as Box, - )) - } else { - None - } - }) - .collect() - } - - fn webrtc_publish_endpoints( - &self, - ) -> HashMap> { - self.0 - .get_pipeline() - .iter() - .filter_map(|(id, element)| { - if element.has_webrtc_pub() { - let endpoint = element.get_webrtc_pub().clone(); - Some(( - WebRtcPublishId(id.clone()), - Box::new(GrpcWebRtcPublishEndpointSpecImpl(endpoint)) - as Box, - )) - } else { - None - } - }) - .collect() - } - - fn credentials(&self) -> &str { - if self.0.has_credentials() { - self.0.get_credentials() - } else { - // TODO: deal with it - unimplemented!() - } - } - - fn get_webrtc_play_by_id( - &self, - id: &WebRtcPlayId, - ) -> Option> { - let element = self.0.pipeline.get(&id.0)?; - if element.has_webrtc_play() { - let play = element.get_webrtc_play().clone(); - let play = GrpcWebRtcPlayEndpointSpecImpl(play); - Some(Box::new(play) as Box) - } else { - None - } - } - - fn get_webrtc_publish_by_id( - &self, - id: &WebRtcPublishId, - ) -> Option> { - let element = self.0.pipeline.get(&id.0)?; - if element.has_webrtc_pub() { - let publish = element.get_webrtc_pub().clone(); - let play = GrpcWebRtcPublishEndpointSpecImpl(publish); - Some(Box::new(play) as Box) - } else { - None - } - } -} diff --git a/src/api/control/protobuf/mod.rs b/src/api/control/protobuf/mod.rs deleted file mode 100644 index 399f7b3f2..000000000 --- a/src/api/control/protobuf/mod.rs +++ /dev/null @@ -1,4 +0,0 @@ -pub mod member; -pub mod room; -pub mod webrtc_play_endpoint; -pub mod webrtc_publish_endpoint; diff --git a/src/api/control/protobuf/room.rs b/src/api/control/protobuf/room.rs deleted file mode 100644 index 81b735db0..000000000 --- a/src/api/control/protobuf/room.rs +++ /dev/null @@ -1,60 +0,0 @@ -use hashbrown::HashMap; - -use crate::api::{ - control::model::{member::MemberSpec, room::RoomSpec, MemberId, RoomId}, - grpc::protos::control::CreateRequest, -}; - -use super::member::GrpcMemberSpecImpl; - -#[allow(dead_code)] -pub struct CreateRequestSpec(pub CreateRequest); - -impl RoomSpec for CreateRequestSpec { - fn members(&self) -> HashMap> { - if self.0.has_room() { - let member = self.0.get_room(); - member - .get_pipeline() - .iter() - .filter_map(|(id, e)| { - if e.has_member() { - let member = e.get_member(); - return Some(( - MemberId(id.clone()), - Box::new(GrpcMemberSpecImpl(member.clone())) - as Box, - )); - } - None - }) - .collect() - } else { - HashMap::new() - } - } - - fn id(&self) -> RoomId { - if self.0.has_id() { - RoomId(self.0.get_id().to_string()) - } else { - panic!() - } - } - - fn get_member_by_id(&self, id: &MemberId) -> Option> { - if self.0.has_room() { - let room = self.0.get_room(); - let element = room.pipeline.get(&id.0)?; - if element.has_member() { - let member = element.get_member().clone(); - let member = GrpcMemberSpecImpl(member); - Some(Box::new(member) as Box) - } else { - None - } - } else { - panic!() - } - } -} diff --git a/src/api/control/protobuf/webrtc_play_endpoint.rs b/src/api/control/protobuf/webrtc_play_endpoint.rs deleted file mode 100644 index 56c73dd7c..000000000 --- a/src/api/control/protobuf/webrtc_play_endpoint.rs +++ /dev/null @@ -1,67 +0,0 @@ -use crate::{ - api::{ - control::{ - model::{endpoint::webrtc::WebRtcPlayEndpoint, MemberId, RoomId}, - serde::endpoint::SerdeSrcUri, - }, - grpc::protos::control::WebRtcPlayEndpoint as WebRtcPlayEndpointProto, - }, - signalling::elements::endpoints::webrtc::WebRtcPublishId, -}; - -pub struct GrpcWebRtcPlayEndpointSpecImpl(pub WebRtcPlayEndpointProto); - -impl WebRtcPlayEndpoint for GrpcWebRtcPlayEndpointSpecImpl { - fn src(&self) -> SerdeSrcUri { - if self.0.has_src() { - let src = self.0.get_src(); - parse_src_uri(src) - } else { - // TODO: do something with it. - unimplemented!("TODO") - } - } -} - -// TODO: use already done implementation from serde DTO -// share this with serde deseralizer. -fn parse_src_uri(value: &str) -> SerdeSrcUri { - let protocol_name: String = value.chars().take(8).collect(); - if protocol_name != "local://" { - panic!() - } - - let uri_body = value.chars().skip(8).collect::(); - let mut uri_body_splitted: Vec<&str> = uri_body.rsplit('/').collect(); - let uri_body_splitted_len = uri_body_splitted.len(); - if uri_body_splitted_len != 3 { - let _error_msg = if uri_body_splitted_len == 0 { - "room_id, member_id, endpoint_id" - } else if uri_body_splitted_len == 1 { - "member_id, endpoint_id" - } else if uri_body_splitted_len == 2 { - "endpoint_id" - } else { - panic!() - }; - panic!() - } - let room_id = uri_body_splitted.pop().unwrap().to_string(); - if room_id.is_empty() { - panic!() - } - let member_id = uri_body_splitted.pop().unwrap().to_string(); - if member_id.is_empty() { - panic!() - } - let endpoint_id = uri_body_splitted.pop().unwrap().to_string(); - if endpoint_id.is_empty() { - panic!() - } - - SerdeSrcUri { - room_id: RoomId(room_id), - member_id: MemberId(member_id), - endpoint_id: WebRtcPublishId(endpoint_id), - } -} diff --git a/src/api/control/protobuf/webrtc_publish_endpoint.rs b/src/api/control/protobuf/webrtc_publish_endpoint.rs deleted file mode 100644 index 6036267bb..000000000 --- a/src/api/control/protobuf/webrtc_publish_endpoint.rs +++ /dev/null @@ -1,18 +0,0 @@ -use crate::api::{ - control::model::endpoint::webrtc::{P2pMode, WebRtcPublishEndpoint}, - grpc::protos::control::WebRtcPublishEndpoint as WebRtcPublishEndpointProto, -}; - -pub struct GrpcWebRtcPublishEndpointSpecImpl(pub WebRtcPublishEndpointProto); - -impl WebRtcPublishEndpoint for GrpcWebRtcPublishEndpointSpecImpl { - fn p2p(&self) -> P2pMode { - if self.0.has_p2p() { - let p2p = self.0.get_p2p(); - P2pMode::from(p2p) - } else { - // TODO: do with me something - unimplemented!() - } - } -} diff --git a/src/api/control/room.rs b/src/api/control/room.rs index d82816649..1896d1b4e 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -91,43 +91,6 @@ impl TryFrom<&RoomProto> for RoomSpec { } } -// pub struct SerdeRoomSpecImpl { -// id: Id, -// members: HashMap, -// } -// -// impl SerdeRoomSpecImpl { -// pub fn new( -// room_spec: &SerdeRoomSpecDto, -// ) -> Result { -// Ok(Self { -// id: room_spec.id.clone(), -// members: room_spec.members()?, -// }) -// } -// } -// -// impl RoomSpec for SerdeRoomSpecImpl { -// fn members(&self) -> HashMap> { -// self.members -// .iter() -// .map(|(id, member)| { -// (id.clone(), Box::new(member.clone()) as Box) -// }) -// .collect() -// } -// -// fn id(&self) -> Id { -// self.id.clone() -// } -// -// fn get_member_by_id(&self, id: &MemberId) -> Option> { -// self.members -// .get(id) -// .map(|m| Box::new(m.clone()) as Box) -// } -// } - impl TryFrom<&Element> for RoomSpec { type Error = TryFromElementError; From 082dec33672163fd7e49bf3cece419655e68a28c Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 8 Jul 2019 13:35:25 +0300 Subject: [PATCH 273/735] Fix warnings --- src/api/control/member.rs | 7 ++----- src/api/control/room.rs | 4 +--- src/api/grpc/server.rs | 16 +++++++--------- src/signalling/room_repo.rs | 10 +++------- 4 files changed, 13 insertions(+), 24 deletions(-) diff --git a/src/api/control/member.rs b/src/api/control/member.rs index 23f480546..47f88f799 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -9,12 +9,9 @@ use serde::Deserialize; use crate::api::{ control::endpoint::{ - WebRtcPlayEndpoint, WebRtcPlayId, WebRtcPublishEndpoint, - WebRtcPublishId, - }, - grpc::protos::control::{ - Member as MemberProto, Member_Element as MemberElementProto, + WebRtcPlayEndpoint, WebRtcPublishEndpoint, WebRtcPublishId, }, + grpc::protos::control::Member as MemberProto, }; use super::{pipeline::Pipeline, Element, TryFromElementError}; diff --git a/src/api/control/room.rs b/src/api/control/room.rs index 1896d1b4e..0f1fa135c 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -7,9 +7,7 @@ use macro_attr::*; use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; use serde::Deserialize; -use crate::api::grpc::protos::control::{ - Room as RoomProto, Room_Element as RoomElementProto, -}; +use crate::api::grpc::protos::control::Room as RoomProto; use super::{ member::MemberSpec, pipeline::Pipeline, Element, MemberId, diff --git a/src/api/grpc/server.rs b/src/api/grpc/server.rs index 686e3b1e9..cdd6d3b7e 100644 --- a/src/api/grpc/server.rs +++ b/src/api/grpc/server.rs @@ -1,4 +1,4 @@ -use std::{convert::TryFrom, sync::Arc, time::Duration}; +use std::{convert::TryFrom, sync::Arc}; use actix::{Actor, Addr, Arbiter, Context}; use futures::future::Future; @@ -11,16 +11,14 @@ use crate::{ ApplyRequest, CreateRequest, GetResponse, IdRequest, Response, }, }, - conf::Conf, log::prelude::*, - signalling::{room_repo::RoomsRepository, Room}, + signalling::room_repo::RoomsRepository, App, }; use super::protos::control_grpc::{create_control_api, ControlApi}; use crate::{ - api::grpc::protos::control::Error, - signalling::room_repo::{DeleteRoom, StartRoom}, + api::grpc::protos::control::Error, signalling::room_repo::StartRoom, }; use futures::future::Either; use std::collections::HashMap; @@ -67,7 +65,7 @@ impl ControlApi for ControlApiService { ctx.spawn( self.room_repository .send(StartRoom(room_id, room)) - .map_err(|e| ()) + .map_err(|e| error!("Start room mailbox error. {:?}", e)) .and_then(move |r| { if r.is_ok() { let mut res = Response::new(); @@ -102,9 +100,9 @@ impl ControlApi for ControlApiService { fn delete( &mut self, - ctx: RpcContext, - req: IdRequest, - sink: UnarySink, + _ctx: RpcContext, + _req: IdRequest, + _sink: UnarySink, ) { // for id in req.get_id() { // let uri = parse_local_uri(id).unwrap(); // TODO diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs index 46ce5532f..2e50ef03c 100644 --- a/src/signalling/room_repo.rs +++ b/src/signalling/room_repo.rs @@ -1,16 +1,12 @@ //! Repository that stores [`Room`]s addresses. -use std::{ - collections::HashMap as StdHashMap, - sync::{Arc, Mutex}, -}; +use std::sync::{Arc, Mutex}; use actix::{Actor, Addr, Arbiter, Context, Handler, Message}; use hashbrown::HashMap; use crate::{ api::control::{room::RoomSpec, RoomId}, - conf::Conf, signalling::{ room::{CloseRoom, RoomError}, Room, @@ -67,7 +63,7 @@ impl Handler for RoomsRepository { fn handle( &mut self, msg: StartRoom, - ctx: &mut Self::Context, + _ctx: &mut Self::Context, ) -> Self::Result { let room_id = msg.0; let room = msg.1; @@ -100,7 +96,7 @@ impl Handler for RoomsRepository { fn handle( &mut self, msg: DeleteRoom, - ctx: &mut Self::Context, + _ctx: &mut Self::Context, ) -> Self::Result { if let Some(room) = self.rooms.lock().unwrap().get(&msg.0) { room.do_send(CloseRoom {}); From 0ab8b0defef3a98b4cb99038e55f3d6d8825f776 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 8 Jul 2019 13:43:13 +0300 Subject: [PATCH 274/735] Fix id in RoomSpec --- src/api/control/room.rs | 77 ++++++++++++++++++++++++++--------------- src/api/grpc/server.rs | 6 ++-- 2 files changed, 54 insertions(+), 29 deletions(-) diff --git a/src/api/control/room.rs b/src/api/control/room.rs index 0f1fa135c..44ac52f76 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -40,6 +40,29 @@ pub struct RoomSpec { } impl RoomSpec { + pub fn try_from_protobuf( + id: Id, + proto: &RoomProto, + ) -> Result { + let mut pipeline = StdHashMap::new(); + for (id, room_element) in proto.get_pipeline() { + if !room_element.has_member() { + return Err(TryFromProtobufError::MemberElementNotFound); + } + let member = MemberSpec::try_from(room_element.get_member())?; + // TODO: temporary + let element = Element::Member { + spec: member.pipeline, + credentials: member.credentials, + }; + pipeline.insert(id.clone(), element); + } + + let pipeline = Pipeline::new(pipeline); + + Ok(Self { pipeline, id }) + } + /// Returns all [`MemberSpec`]s of this [`RoomSpec`]. pub fn members( &self, @@ -61,33 +84,33 @@ impl RoomSpec { } } -impl TryFrom<&RoomProto> for RoomSpec { - type Error = TryFromProtobufError; - - fn try_from(value: &RoomProto) -> Result { - let mut pipeline = StdHashMap::new(); - for (id, room_element) in value.get_pipeline() { - if !room_element.has_member() { - return Err(TryFromProtobufError::MemberElementNotFound); - } - let member = MemberSpec::try_from(room_element.get_member())?; - // TODO: temporary - let element = Element::Member { - spec: member.pipeline, - credentials: member.credentials, - }; - pipeline.insert(id.clone(), element); - } - - let pipeline = Pipeline::new(pipeline); - - Ok(Self { - pipeline, - // TODO: - id: Id("unimplemented".to_string()), - }) - } -} +// impl TryFrom<&RoomProto> for RoomSpec { +// type Error = TryFromProtobufError; +// +// fn try_from(value: &RoomProto) -> Result { +// let mut pipeline = StdHashMap::new(); +// for (id, room_element) in value.get_pipeline() { +// if !room_element.has_member() { +// return Err(TryFromProtobufError::MemberElementNotFound); +// } +// let member = MemberSpec::try_from(room_element.get_member())?; +// // TODO: temporary +// let element = Element::Member { +// spec: member.pipeline, +// credentials: member.credentials, +// }; +// pipeline.insert(id.clone(), element); +// } +// +// let pipeline = Pipeline::new(pipeline); +// +// Ok(Self { +// pipeline, +// // TODO: +// id: Id("unimplemented".to_string()), +// }) +// } +//} impl TryFrom<&Element> for RoomSpec { type Error = TryFromElementError; diff --git a/src/api/grpc/server.rs b/src/api/grpc/server.rs index cdd6d3b7e..d064b78c8 100644 --- a/src/api/grpc/server.rs +++ b/src/api/grpc/server.rs @@ -1,4 +1,4 @@ -use std::{convert::TryFrom, sync::Arc}; +use std::sync::Arc; use actix::{Actor, Addr, Arbiter, Context}; use futures::future::Future; @@ -39,7 +39,9 @@ impl ControlApi for ControlApiService { // TODO let room_id = RoomId(req.get_id().to_string()); - let room = RoomSpec::try_from(req.get_room()).unwrap(); + // TODO + let room = RoomSpec::try_from_protobuf(room_id.clone(), req.get_room()) + .unwrap(); // let sid: HashMap = msg // .room From 5490cc8868c4ffea774e6f5fe073716caee7afcd Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 8 Jul 2019 13:51:19 +0300 Subject: [PATCH 275/735] Start room in current arbiter --- src/lib.rs | 23 ++++++++++++----------- src/signalling/room_repo.rs | 21 ++++++++------------- 2 files changed, 20 insertions(+), 24 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index b3cd527c3..e6e745252 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -9,7 +9,7 @@ pub mod media; pub mod signalling; pub mod turn; -use actix::prelude::*; +use actix::{Actor as _, Addr}; use failure::Fail; use hashbrown::HashMap; @@ -76,7 +76,6 @@ pub fn start_static_rooms( Err(e) => return Err(ServerStartError::LoadSpec(e)), }; let mut rooms = HashMap::new(); - let arbiter = Arbiter::new(); for spec in room_specs { if rooms.contains_key(spec.id()) { @@ -90,15 +89,17 @@ pub fn start_static_rooms( let room_id = spec.id().clone(); let rpc_reconnect_timeout = config.rpc.reconnect_timeout; - let room = Room::start_in_arbiter(&arbiter, move |_| { - Room::new( - &spec, - rpc_reconnect_timeout, - Arc::new(turn_auth_service), - ) - .unwrap() - }); - rooms.insert(room_id, room); + + let room = Room::new( + &spec, + rpc_reconnect_timeout, + Arc::new(turn_auth_service), + ) + .unwrap(); + + let room_addr = room.start(); + + rooms.insert(room_id, room_addr); } Ok(rooms) diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs index 2e50ef03c..cc560ebf2 100644 --- a/src/signalling/room_repo.rs +++ b/src/signalling/room_repo.rs @@ -2,7 +2,7 @@ use std::sync::{Arc, Mutex}; -use actix::{Actor, Addr, Arbiter, Context, Handler, Message}; +use actix::{Actor, Addr, Context, Handler, Message}; use hashbrown::HashMap; use crate::{ @@ -13,7 +13,6 @@ use crate::{ }, App, }; -use std::time::Duration; /// Repository that stores [`Room`]s addresses. #[derive(Clone, Debug)] @@ -70,18 +69,14 @@ impl Handler for RoomsRepository { let turn = Arc::clone(&self.app.turn_service); - // TODO: spawn in current arbiter. - { - // let room = Box::new(&msg.room as &(RoomSpec)); - // Room::new(&room, Duration::from_secs(10), - // Arc::clone(&turn))?; - } - - let room = Room::start_in_arbiter(&Arbiter::new(), move |_| { - Room::new(&room, Duration::from_secs(10), turn).unwrap() - }); + let room = Room::new( + &room, + self.app.config.rpc.reconnect_timeout.clone(), + turn, + )?; + let room_addr = room.start(); - self.rooms.lock().unwrap().insert(room_id, room); + self.rooms.lock().unwrap().insert(room_id, room_addr); Ok(()) } } From f8b61f08477969fe1fc86f238ccfa23380e6d416 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 8 Jul 2019 13:58:05 +0300 Subject: [PATCH 276/735] Minor refactor --- src/api/control/endpoint.rs | 11 +++++++++++ src/api/control/member.rs | 28 ++++++++++++---------------- src/api/control/room.rs | 35 +---------------------------------- 3 files changed, 24 insertions(+), 50 deletions(-) diff --git a/src/api/control/endpoint.rs b/src/api/control/endpoint.rs index 79cca8e68..9645f9228 100644 --- a/src/api/control/endpoint.rs +++ b/src/api/control/endpoint.rs @@ -83,6 +83,17 @@ pub enum Endpoint { WebRtcPlay(WebRtcPlayEndpoint), } +impl Into for Endpoint { + fn into(self) -> Element { + match self { + Endpoint::WebRtcPublish(e) => { + Element::WebRtcPublishEndpoint { spec: e } + } + Endpoint::WebRtcPlay(e) => Element::WebRtcPlayEndpoint { spec: e }, + } + } +} + impl TryFrom<&MemberElementProto> for Endpoint { type Error = TryFromProtobufError; diff --git a/src/api/control/member.rs b/src/api/control/member.rs index 47f88f799..55b2b55cc 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -37,12 +37,19 @@ macro_attr! { #[derive(Clone, Debug)] pub struct MemberSpec { /// Spec of this `Member`. - // TODO: remove pub - pub pipeline: Pipeline, + pipeline: Pipeline, /// Credentials to authorize `Member` with. - // TODO: remove pub - pub credentials: String, + credentials: String, +} + +impl Into for MemberSpec { + fn into(self) -> Element { + Element::Member { + spec: self.pipeline, + credentials: self.credentials, + } + } } impl MemberSpec { @@ -84,17 +91,7 @@ impl TryFrom<&MemberProto> for MemberSpec { let mut pipeline = StdHashMap::new(); for (id, member_element) in value.get_pipeline() { let endpoint = Endpoint::try_from(member_element)?; - // TODO: this is temporary - // Need rewrite element logic. - let element = match endpoint { - Endpoint::WebRtcPublish(e) => { - Element::WebRtcPublishEndpoint { spec: e } - } - Endpoint::WebRtcPlay(e) => { - Element::WebRtcPlayEndpoint { spec: e } - } - }; - pipeline.insert(id.clone(), element); + pipeline.insert(id.clone(), endpoint.into()); } let pipeline = Pipeline::new(pipeline); @@ -104,7 +101,6 @@ impl TryFrom<&MemberProto> for MemberSpec { Ok(Self { pipeline, - // TODO: error credentials: value.get_credentials().to_string(), }) } diff --git a/src/api/control/room.rs b/src/api/control/room.rs index 44ac52f76..4e9cb6996 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -50,12 +50,7 @@ impl RoomSpec { return Err(TryFromProtobufError::MemberElementNotFound); } let member = MemberSpec::try_from(room_element.get_member())?; - // TODO: temporary - let element = Element::Member { - spec: member.pipeline, - credentials: member.credentials, - }; - pipeline.insert(id.clone(), element); + pipeline.insert(id.clone(), member.into()); } let pipeline = Pipeline::new(pipeline); @@ -84,34 +79,6 @@ impl RoomSpec { } } -// impl TryFrom<&RoomProto> for RoomSpec { -// type Error = TryFromProtobufError; -// -// fn try_from(value: &RoomProto) -> Result { -// let mut pipeline = StdHashMap::new(); -// for (id, room_element) in value.get_pipeline() { -// if !room_element.has_member() { -// return Err(TryFromProtobufError::MemberElementNotFound); -// } -// let member = MemberSpec::try_from(room_element.get_member())?; -// // TODO: temporary -// let element = Element::Member { -// spec: member.pipeline, -// credentials: member.credentials, -// }; -// pipeline.insert(id.clone(), element); -// } -// -// let pipeline = Pipeline::new(pipeline); -// -// Ok(Self { -// pipeline, -// // TODO: -// id: Id("unimplemented".to_string()), -// }) -// } -//} - impl TryFrom<&Element> for RoomSpec { type Error = TryFromElementError; From 4af9b38546029d4ea251e5cd9014e81fa50ddd01 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 8 Jul 2019 14:08:19 +0300 Subject: [PATCH 277/735] Move grpc into control module --- build.rs | 2 +- src/api/control/endpoint.rs | 2 +- src/api/{ => control}/grpc/mod.rs | 0 src/api/{ => control}/grpc/protos/control.proto | 0 src/api/{ => control}/grpc/protos/control.rs | 0 src/api/{ => control}/grpc/protos/control_grpc.rs | 0 src/api/{ => control}/grpc/protos/mod.rs | 0 src/api/{ => control}/grpc/server.rs | 7 ++++--- src/api/control/member.rs | 6 ++---- src/api/control/mod.rs | 1 + src/api/control/room.rs | 2 +- src/api/mod.rs | 1 - src/bin/client.rs | 2 +- src/main.rs | 2 +- 14 files changed, 12 insertions(+), 13 deletions(-) rename src/api/{ => control}/grpc/mod.rs (100%) rename src/api/{ => control}/grpc/protos/control.proto (100%) rename src/api/{ => control}/grpc/protos/control.rs (100%) rename src/api/{ => control}/grpc/protos/control_grpc.rs (100%) rename src/api/{ => control}/grpc/protos/mod.rs (100%) rename src/api/{ => control}/grpc/server.rs (97%) diff --git a/build.rs b/build.rs index 7e436cdbd..a5f03f581 100644 --- a/build.rs +++ b/build.rs @@ -1,5 +1,5 @@ fn main() { - let proto_root = "src/api/grpc/protos"; + let proto_root = "src/api/control/grpc/protos"; println!("cargo:rerun-if-changed={}", proto_root); protoc_grpcio::compile_grpc_protos( &["control.proto"], diff --git a/src/api/control/endpoint.rs b/src/api/control/endpoint.rs index 9645f9228..586f84cde 100644 --- a/src/api/control/endpoint.rs +++ b/src/api/control/endpoint.rs @@ -10,7 +10,7 @@ use serde::{ Deserialize, }; -use crate::api::grpc::protos::control::{ +use crate::api::control::grpc::protos::control::{ Member_Element as MemberElementProto, WebRtcPlayEndpoint as WebRtcPlayEndpointProto, WebRtcPublishEndpoint as WebRtcPublishEndpointProto, diff --git a/src/api/grpc/mod.rs b/src/api/control/grpc/mod.rs similarity index 100% rename from src/api/grpc/mod.rs rename to src/api/control/grpc/mod.rs diff --git a/src/api/grpc/protos/control.proto b/src/api/control/grpc/protos/control.proto similarity index 100% rename from src/api/grpc/protos/control.proto rename to src/api/control/grpc/protos/control.proto diff --git a/src/api/grpc/protos/control.rs b/src/api/control/grpc/protos/control.rs similarity index 100% rename from src/api/grpc/protos/control.rs rename to src/api/control/grpc/protos/control.rs diff --git a/src/api/grpc/protos/control_grpc.rs b/src/api/control/grpc/protos/control_grpc.rs similarity index 100% rename from src/api/grpc/protos/control_grpc.rs rename to src/api/control/grpc/protos/control_grpc.rs diff --git a/src/api/grpc/protos/mod.rs b/src/api/control/grpc/protos/mod.rs similarity index 100% rename from src/api/grpc/protos/mod.rs rename to src/api/control/grpc/protos/mod.rs diff --git a/src/api/grpc/server.rs b/src/api/control/grpc/server.rs similarity index 97% rename from src/api/grpc/server.rs rename to src/api/control/grpc/server.rs index d064b78c8..8e9bbf336 100644 --- a/src/api/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -5,11 +5,11 @@ use futures::future::Future; use grpcio::{Environment, RpcContext, Server, ServerBuilder, UnarySink}; use crate::{ - api::{ - control::{RoomId, RoomSpec}, + api::control::{ grpc::protos::control::{ ApplyRequest, CreateRequest, GetResponse, IdRequest, Response, }, + RoomId, RoomSpec, }, log::prelude::*, signalling::room_repo::RoomsRepository, @@ -18,7 +18,8 @@ use crate::{ use super::protos::control_grpc::{create_control_api, ControlApi}; use crate::{ - api::grpc::protos::control::Error, signalling::room_repo::StartRoom, + api::control::grpc::protos::control::Error, + signalling::room_repo::StartRoom, }; use futures::future::Either; use std::collections::HashMap; diff --git a/src/api/control/member.rs b/src/api/control/member.rs index 55b2b55cc..3e2723d46 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -7,10 +7,8 @@ use macro_attr::*; use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; use serde::Deserialize; -use crate::api::{ - control::endpoint::{ - WebRtcPlayEndpoint, WebRtcPublishEndpoint, WebRtcPublishId, - }, +use crate::api::control::{ + endpoint::{WebRtcPlayEndpoint, WebRtcPublishEndpoint, WebRtcPublishId}, grpc::protos::control::Member as MemberProto, }; diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index f1e9a3e22..1dc8ae8de 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -1,6 +1,7 @@ //! Implementation of Control API. pub mod endpoint; +pub mod grpc; pub mod member; pub mod pipeline; pub mod room; diff --git a/src/api/control/room.rs b/src/api/control/room.rs index 4e9cb6996..fdc836830 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -7,7 +7,7 @@ use macro_attr::*; use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; use serde::Deserialize; -use crate::api::grpc::protos::control::Room as RoomProto; +use crate::api::control::grpc::protos::control::Room as RoomProto; use super::{ member::MemberSpec, pipeline::Pipeline, Element, MemberId, diff --git a/src/api/mod.rs b/src/api/mod.rs index 35620ff67..1c66e73e5 100644 --- a/src/api/mod.rs +++ b/src/api/mod.rs @@ -2,4 +2,3 @@ pub mod client; pub mod control; -pub mod grpc; diff --git a/src/bin/client.rs b/src/bin/client.rs index d4974b40f..53fe3426f 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -1,5 +1,5 @@ use grpcio::{ChannelBuilder, EnvBuilder}; -use medea::api::grpc::protos::{ +use medea::api::control::grpc::protos::{ control::{ CreateRequest, IdRequest, Member, Member_Element, Room, Room_Element, WebRtcPlayEndpoint, WebRtcPublishEndpoint, WebRtcPublishEndpoint_P2P, diff --git a/src/main.rs b/src/main.rs index e986a4089..29182786b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,7 +8,7 @@ use medea::{ start_static_rooms, }; -use medea::{api::grpc, turn::new_turn_auth_service, App}; +use medea::{api::control::grpc, turn::new_turn_auth_service, App}; use std::sync::Arc; fn main() -> Result<(), Error> { From 488433d7d11477e4c5669733e25fcf1c74a531fd Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 8 Jul 2019 14:18:16 +0300 Subject: [PATCH 278/735] Return sid on create --- src/api/control/grpc/server.rs | 49 +++++++++++++++------------------- 1 file changed, 21 insertions(+), 28 deletions(-) diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index 8e9bbf336..b252f4b6d 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -37,33 +37,30 @@ impl ControlApi for ControlApiService { req: CreateRequest, sink: UnarySink, ) { - // TODO let room_id = RoomId(req.get_id().to_string()); - - // TODO let room = RoomSpec::try_from_protobuf(room_id.clone(), req.get_room()) .unwrap(); - // let sid: HashMap = msg - // .room - // .members() - // .iter() - // .map(|(id, member)| { - // let addr = &self.app.config.server.bind_ip; - // let port = self.app.config.server.bind_port; - // let base_uri = format!("{}:{}", addr, port); - // - // let uri = format!( - // "wss://{}/{}/{}/{}", - // base_uri, - // &room_id, - // id, - // member.credentials() - // ); - // - // (id.clone().to_string(), uri) - // }) - // .collect(); + let sid: HashMap = room + .members() + .unwrap() + .iter() + .map(|(id, member)| { + let addr = &self.app.config.server.bind_ip; + let port = self.app.config.server.bind_port; + let base_uri = format!("{}:{}", addr, port); + + let uri = format!( + "wss://{}/{}/{}/{}", + base_uri, + &room_id, + id, + member.credentials() + ); + + (id.clone().to_string(), uri) + }) + .collect(); ctx.spawn( self.room_repository @@ -72,7 +69,7 @@ impl ControlApi for ControlApiService { .and_then(move |r| { if r.is_ok() { let mut res = Response::new(); - res.set_sid(HashMap::new()); + res.set_sid(sid); Either::A(sink.success(res).map_err(|_| ())) } else { let mut res = Response::new(); @@ -86,10 +83,6 @@ impl ControlApi for ControlApiService { } }), ); - - // self.room_repository.add(room_id, room); - - // debug!("{:?}", self.room_repository); } fn apply( From 162e2256fcd6efae9b74cdc3c4fceeb48a4a9d71 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 8 Jul 2019 15:02:33 +0300 Subject: [PATCH 279/735] Add LocalUri and refactor SrcUri parsing --- src/api/control/endpoint.rs | 153 +++++++++-------------------------- src/api/control/local_uri.rs | 58 +++++++++++++ src/api/control/mod.rs | 1 + 3 files changed, 96 insertions(+), 116 deletions(-) create mode 100644 src/api/control/local_uri.rs diff --git a/src/api/control/endpoint.rs b/src/api/control/endpoint.rs index 586f84cde..41fe30482 100644 --- a/src/api/control/endpoint.rs +++ b/src/api/control/endpoint.rs @@ -6,7 +6,7 @@ use failure::Fail; use macro_attr::*; use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; use serde::{ - de::{self, Deserializer, Error, Unexpected, Visitor}, + de::{self, Deserializer, Error, Visitor}, Deserialize, }; @@ -18,6 +18,7 @@ use crate::api::control::grpc::protos::control::{ }; use super::{ + local_uri::{LocalUri, LocalUriParseError}, Element, MemberId, RoomId, TryFromElementError, TryFromProtobufError, }; @@ -167,7 +168,7 @@ impl TryFrom<&WebRtcPlayEndpointProto> for WebRtcPlayEndpoint { fn try_from(value: &WebRtcPlayEndpointProto) -> Result { if value.has_src() { Ok(Self { - src: parse_src_uri(value.get_src())?, + src: SrcUri::parse(value.get_src())?, }) } else { Err(TryFromProtobufError::SrcUriNotFound) @@ -189,68 +190,42 @@ pub struct SrcUri { // TODO #[derive(Debug, Fail)] pub enum SrcParseError { - #[fail(display = "Invalid value {}", _0)] - InvalidValue(String), - #[fail(display = "Custom error {}", _0)] - Custom(String), - #[fail(display = "Missing field {}", _0)] - MissingField(String), + #[fail(display = "Missing fields {:?} in '{}' local URI.", _1, _0)] + MissingField(String, Vec), + #[fail(display = "Local URI '{}' parse error: {:?}", _0, _1)] + LocalUriParseError(String, LocalUriParseError), } -fn parse_src_uri(value: &str) -> Result { - let protocol_name: String = value.chars().take(8).collect(); - if protocol_name != "local://" { - return Err(SrcParseError::InvalidValue(format!( - "{} in {}", - protocol_name, value - ))); - } +impl SrcUri { + pub fn parse(value: &str) -> Result { + let local_uri = LocalUri::parse(value).map_err(|e| { + SrcParseError::LocalUriParseError(value.to_string(), e) + })?; + + let mut missing_fields = Vec::new(); + if local_uri.room_id.is_none() { + missing_fields.push("room_id".to_string()); + } + if local_uri.member_id.is_none() { + missing_fields.push("member_id".to_string()); + } + if local_uri.endpoint_id.is_none() { + missing_fields.push("endpoint_id".to_string()); + } - let uri_body = value.chars().skip(8).collect::(); - let mut uri_body_splitted: Vec<&str> = uri_body.rsplit('/').collect(); - let uri_body_splitted_len = uri_body_splitted.len(); - if uri_body_splitted_len != 3 { - let error_msg = if uri_body_splitted_len == 0 { - "room_id, member_id, endpoint_id" - } else if uri_body_splitted_len == 1 { - "member_id, endpoint_id" - } else if uri_body_splitted_len == 2 { - "endpoint_id" + if !missing_fields.is_empty() { + return Err(SrcParseError::MissingField( + value.to_string(), + missing_fields, + )); } else { - return Err(SrcParseError::Custom(format!( - "Too many fields: {}. Expecting 3 fields, found {}.", - uri_body, uri_body_splitted_len - ))); - }; - return Err(SrcParseError::MissingField(error_msg.to_string())); - } - let room_id = uri_body_splitted.pop().unwrap().to_string(); - if room_id.is_empty() { - return Err(SrcParseError::Custom(format!( - "room_id in {} is empty!", - value - ))); - } - let member_id = uri_body_splitted.pop().unwrap().to_string(); - if member_id.is_empty() { - return Err(SrcParseError::Custom(format!( - "member_id in {} is empty!", - value - ))); - } - let endpoint_id = uri_body_splitted.pop().unwrap().to_string(); - if endpoint_id.is_empty() { - return Err(SrcParseError::Custom(format!( - "endpoint_id in {} is empty!", - value - ))); + Ok(Self { + room_id: local_uri.room_id.unwrap(), + member_id: local_uri.member_id.unwrap(), + endpoint_id: WebRtcPublishId(local_uri.endpoint_id.unwrap()), + }) + } } - - Ok(SrcUri { - room_id: RoomId(room_id), - member_id: MemberId(member_id), - endpoint_id: WebRtcPublishId(endpoint_id), - }) } /// Serde deserializer for [`SrcUri`]. @@ -275,64 +250,10 @@ impl<'de> Deserialize<'de> for SrcUri { where E: de::Error, { - let protocol_name: String = value.chars().take(8).collect(); - if protocol_name != "local://" { - return Err(Error::invalid_value( - Unexpected::Str(&format!( - "{} in {}", - protocol_name, value - )), - &self, - )); - } - - let uri_body = value.chars().skip(8).collect::(); - let mut uri_body_splitted: Vec<&str> = - uri_body.rsplit('/').collect(); - let uri_body_splitted_len = uri_body_splitted.len(); - if uri_body_splitted_len != 3 { - let error_msg = if uri_body_splitted_len == 0 { - "room_id, member_id, endpoint_id" - } else if uri_body_splitted_len == 1 { - "member_id, endpoint_id" - } else if uri_body_splitted_len == 2 { - "endpoint_id" - } else { - return Err(Error::custom(format!( - "Too many fields: {}. Expecting 3 fields, found \ - {}.", - uri_body, uri_body_splitted_len - ))); - }; - return Err(Error::missing_field(error_msg)); + match SrcUri::parse(value) { + Ok(src_uri) => Ok(src_uri), + Err(e) => Err(Error::custom(e)), } - let room_id = uri_body_splitted.pop().unwrap().to_string(); - if room_id.is_empty() { - return Err(Error::custom(format!( - "room_id in {} is empty!", - value - ))); - } - let member_id = uri_body_splitted.pop().unwrap().to_string(); - if member_id.is_empty() { - return Err(Error::custom(format!( - "member_id in {} is empty!", - value - ))); - } - let endpoint_id = uri_body_splitted.pop().unwrap().to_string(); - if endpoint_id.is_empty() { - return Err(Error::custom(format!( - "endpoint_id in {} is empty!", - value - ))); - } - - Ok(SrcUri { - room_id: RoomId(room_id), - member_id: MemberId(member_id), - endpoint_id: WebRtcPublishId(endpoint_id), - }) } } diff --git a/src/api/control/local_uri.rs b/src/api/control/local_uri.rs new file mode 100644 index 000000000..ab754c0df --- /dev/null +++ b/src/api/control/local_uri.rs @@ -0,0 +1,58 @@ +use failure::Fail; + +use super::{MemberId, RoomId}; + +#[derive(Debug, Fail)] +pub enum LocalUriParseError { + #[fail(display = "Provided URIs protocol is not 'local://'")] + NotLocal(String), + #[fail(display = "Too many paths in provided URI")] + TooManyFields(usize), +} + +pub struct LocalUri { + /// ID of [`Room`] + pub room_id: Option, + /// ID of `Member` + pub member_id: Option, + /// Control ID of [`Endpoint`] + pub endpoint_id: Option, +} + +impl LocalUri { + pub fn parse(value: &str) -> Result { + let protocol_name: String = value.chars().take(8).collect(); + if protocol_name != "local://" { + return Err(LocalUriParseError::NotLocal(protocol_name)); + } + + let uri_body = value.chars().skip(8).collect::(); + let mut uri_body_splitted: Vec<&str> = uri_body.rsplit('/').collect(); + let uri_body_splitted_len = uri_body_splitted.len(); + + if uri_body_splitted_len > 3 { + return Err(LocalUriParseError::TooManyFields( + uri_body_splitted_len, + )); + } + + let room_id = uri_body_splitted + .pop() + .filter(|p| !p.is_empty()) + .map(|p| RoomId(p.to_string())); + let member_id = uri_body_splitted + .pop() + .filter(|p| !p.is_empty()) + .map(|p| MemberId(p.to_string())); + let endpoint_id = uri_body_splitted + .pop() + .filter(|p| !p.is_empty()) + .map(|p| p.to_string()); + + Ok(Self { + room_id, + member_id, + endpoint_id, + }) + } +} diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index 1dc8ae8de..32bc9ffd2 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -2,6 +2,7 @@ pub mod endpoint; pub mod grpc; +pub mod local_uri; pub mod member; pub mod pipeline; pub mod room; From 6db5c6b1b6ba9fad563bf6788a91fce4f87d753d Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 8 Jul 2019 15:22:43 +0300 Subject: [PATCH 280/735] Add room removing, fix dead lock in room remove --- src/api/control/grpc/server.rs | 38 ++++++++++++++++++++-------------- src/api/control/local_uri.rs | 18 ++++++++++++++++ src/signalling/room_repo.rs | 6 +++++- 3 files changed, 45 insertions(+), 17 deletions(-) diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index b252f4b6d..8cc821519 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -18,8 +18,8 @@ use crate::{ use super::protos::control_grpc::{create_control_api, ControlApi}; use crate::{ - api::control::grpc::protos::control::Error, - signalling::room_repo::StartRoom, + api::control::{grpc::protos::control::Error, local_uri::LocalUri}, + signalling::room_repo::{DeleteRoom, StartRoom}, }; use futures::future::Either; use std::collections::HashMap; @@ -96,21 +96,27 @@ impl ControlApi for ControlApiService { fn delete( &mut self, - _ctx: RpcContext, - _req: IdRequest, - _sink: UnarySink, + ctx: RpcContext, + req: IdRequest, + sink: UnarySink, ) { - // for id in req.get_id() { - // let uri = parse_local_uri(id).unwrap(); // TODO - // if uri.is_room_id() { - // self.room_repository - // .do_send(DeleteRoom(uri.room_id.unwrap())) - // } - // } - // - // let mut resp = Response::new(); - // resp.set_sid(HashMap::new()); - // ctx.spawn(sink.success(resp).map_err(|_| ())); + for id in req.get_id() { + let uri = LocalUri::parse(id).unwrap(); // TODO + + if uri.is_room_uri() { + self.room_repository + .do_send(DeleteRoom(uri.room_id.unwrap())); + } else { + unimplemented!() + } + } + + let mut resp = Response::new(); + resp.set_sid(HashMap::new()); + ctx.spawn( + sink.success(resp) + .map_err(|e| error!("gRPC response failed. {:?}", e)), + ); } fn get( diff --git a/src/api/control/local_uri.rs b/src/api/control/local_uri.rs index ab754c0df..ac290d713 100644 --- a/src/api/control/local_uri.rs +++ b/src/api/control/local_uri.rs @@ -55,4 +55,22 @@ impl LocalUri { endpoint_id, }) } + + pub fn is_room_uri(&self) -> bool { + self.room_id.is_some() + && self.member_id.is_none() + && self.endpoint_id.is_none() + } + + pub fn is_member_uri(&self) -> bool { + self.room_id.is_some() + && self.member_id.is_some() + && self.endpoint_id.is_none() + } + + pub fn is_endpoint_uri(&self) -> bool { + self.room_id.is_some() + && self.member_id.is_some() + && self.endpoint_id.is_some() + } } diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs index cc560ebf2..c731cd6c3 100644 --- a/src/signalling/room_repo.rs +++ b/src/signalling/room_repo.rs @@ -93,9 +93,13 @@ impl Handler for RoomsRepository { msg: DeleteRoom, _ctx: &mut Self::Context, ) -> Self::Result { + let mut is_need_remove = false; if let Some(room) = self.rooms.lock().unwrap().get(&msg.0) { room.do_send(CloseRoom {}); - self.rooms.lock().unwrap().remove(&msg.0); + is_need_remove = true; + } + if is_need_remove { + self.remove(&msg.0); } } } From e769ade31d92f3ed54c001cefd283f324bfafab2 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 8 Jul 2019 17:02:38 +0300 Subject: [PATCH 281/735] Add Delete Member --- src/api/control/grpc/server.rs | 13 ++++++++++--- src/bin/client.rs | 10 +++++++++- src/signalling/participants.rs | 20 ++++++++++++++++++++ src/signalling/room.rs | 16 ++++++++++++++++ src/signalling/room_repo.rs | 24 ++++++++++++++++++++++-- 5 files changed, 77 insertions(+), 6 deletions(-) diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index 8cc821519..cde8ca113 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -9,7 +9,7 @@ use crate::{ grpc::protos::control::{ ApplyRequest, CreateRequest, GetResponse, IdRequest, Response, }, - RoomId, RoomSpec, + RoomSpec, }, log::prelude::*, signalling::room_repo::RoomsRepository, @@ -19,7 +19,7 @@ use crate::{ use super::protos::control_grpc::{create_control_api, ControlApi}; use crate::{ api::control::{grpc::protos::control::Error, local_uri::LocalUri}, - signalling::room_repo::{DeleteRoom, StartRoom}, + signalling::room_repo::{DeleteMemberFromRoom, DeleteRoom, StartRoom}, }; use futures::future::Either; use std::collections::HashMap; @@ -37,7 +37,9 @@ impl ControlApi for ControlApiService { req: CreateRequest, sink: UnarySink, ) { - let room_id = RoomId(req.get_id().to_string()); + let local_uri = LocalUri::parse(req.get_id()).unwrap(); + let room_id = local_uri.room_id.unwrap(); + let room = RoomSpec::try_from_protobuf(room_id.clone(), req.get_room()) .unwrap(); @@ -106,6 +108,11 @@ impl ControlApi for ControlApiService { if uri.is_room_uri() { self.room_repository .do_send(DeleteRoom(uri.room_id.unwrap())); + } else if uri.is_member_uri() { + self.room_repository.do_send(DeleteMemberFromRoom { + room_id: uri.room_id.unwrap(), + member_id: uri.member_id.unwrap(), + }); } else { unimplemented!() } diff --git a/src/bin/client.rs b/src/bin/client.rs index 53fe3426f..4a7ed2491 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -46,7 +46,7 @@ fn main() { room_pipeline.insert("responder".to_string(), responder_member_element); room.set_pipeline(room_pipeline); req.set_room(room); - req.set_id("grpc-test".to_string()); + req.set_id("local://grpc-test".to_string()); let reply = client.create(&req).expect("rpc"); if reply.has_error() { @@ -62,4 +62,12 @@ fn main() { let reply = client.delete(&delete_request).expect("delete"); println!("{:?}", reply); + + let mut delete_member_req = IdRequest::new(); + let mut members = RepeatedField::new(); + members.push("local://video-call-1/caller".to_string()); + delete_member_req.set_id(members); + + let reply = client.delete(&delete_member_req).expect("delete member"); + println!("{:?}", reply); } diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index f0e0749d9..9c511a4b6 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -314,4 +314,24 @@ impl ParticipantService { join_all(close_fut).map(|_| ()) } + + pub fn delete_member(&mut self, member_id: &MemberId, ctx: &mut Context) { + if let Some(drop) = self.drop_connection_tasks.remove(member_id) { + ctx.cancel_future(drop); + } + + if let Some(mut conn) = self.connections.remove(member_id) { + ctx.spawn(wrap_future(conn.close())); + } + + if let Some(member) = self.members.remove(member_id) { + if let Some(ice_user) = member.take_ice_user() { + let delete_ice_user_fut = self + .turn + .delete(vec![ice_user]) + .map_err(|err| error!("Error removing IceUser {:?}", err)); + ctx.spawn(wrap_future(delete_ice_user_fut)); + } + } + } } diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 1d06c7481..e86a5d882 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -631,3 +631,19 @@ impl Handler for Room { .connection_closed(ctx, msg.member_id, &msg.reason); } } + +#[derive(Debug, Message)] +#[rtype(result = "()")] +pub struct DeleteMember(pub MemberId); + +impl Handler for Room { + type Result = (); + + fn handle( + &mut self, + msg: DeleteMember, + ctx: &mut Self::Context, + ) -> Self::Result { + self.members.delete_member(&msg.0, ctx); + } +} diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs index c731cd6c3..9c4e93ca7 100644 --- a/src/signalling/room_repo.rs +++ b/src/signalling/room_repo.rs @@ -6,9 +6,9 @@ use actix::{Actor, Addr, Context, Handler, Message}; use hashbrown::HashMap; use crate::{ - api::control::{room::RoomSpec, RoomId}, + api::control::{room::RoomSpec, MemberId, RoomId}, signalling::{ - room::{CloseRoom, RoomError}, + room::{CloseRoom, DeleteMember, RoomError}, Room, }, App, @@ -103,3 +103,23 @@ impl Handler for RoomsRepository { } } } + +#[derive(Message)] +#[rtype(result = "()")] +pub struct DeleteMemberFromRoom { + pub member_id: MemberId, + pub room_id: RoomId, +} + +impl Handler for RoomsRepository { + type Result = (); + + fn handle( + &mut self, + msg: DeleteMemberFromRoom, + _ctx: &mut Self::Context, + ) -> Self::Result { + let room = self.get(&msg.room_id).unwrap(); // TODO + room.do_send(DeleteMember(msg.member_id)); + } +} From 9c066770732204e32f9737fbd797d0d324485529 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 8 Jul 2019 18:12:27 +0300 Subject: [PATCH 282/735] Add endpoint delete --- src/api/control/grpc/server.rs | 12 ++++++++--- src/bin/client.rs | 12 +++++++++++ src/signalling/elements/member.rs | 14 ++++++++++++ src/signalling/participants.rs | 6 +++++- src/signalling/peers.rs | 35 +++++++++++++++++++++++++++++- src/signalling/room.rs | 36 ++++++++++++++++++++++++++++++- src/signalling/room_repo.rs | 29 ++++++++++++++++++++++++- 7 files changed, 137 insertions(+), 7 deletions(-) diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index cde8ca113..2f180f980 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -19,7 +19,9 @@ use crate::{ use super::protos::control_grpc::{create_control_api, ControlApi}; use crate::{ api::control::{grpc::protos::control::Error, local_uri::LocalUri}, - signalling::room_repo::{DeleteMemberFromRoom, DeleteRoom, StartRoom}, + signalling::room_repo::{ + DeleteEndpointFromMember, DeleteMemberFromRoom, DeleteRoom, StartRoom, + }, }; use futures::future::Either; use std::collections::HashMap; @@ -113,8 +115,12 @@ impl ControlApi for ControlApiService { room_id: uri.room_id.unwrap(), member_id: uri.member_id.unwrap(), }); - } else { - unimplemented!() + } else if uri.is_endpoint_uri() { + self.room_repository.do_send(DeleteEndpointFromMember { + room_id: uri.room_id.unwrap(), + member_id: uri.member_id.unwrap(), + endpoint_id: uri.endpoint_id.unwrap(), + }); } } diff --git a/src/bin/client.rs b/src/bin/client.rs index 4a7ed2491..807c12050 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -14,6 +14,7 @@ fn main() { let ch = ChannelBuilder::new(env).connect("localhost:50051"); let client = ControlApiClient::new(ch); + // Create room let mut req = CreateRequest::new(); let mut room = Room::new(); let mut publisher = Member::new(); @@ -55,6 +56,7 @@ fn main() { println!("Receiver: {:?}", reply.get_sid()); } + // Delete room let mut delete_request = IdRequest::new(); let mut rooms = RepeatedField::new(); rooms.push("local://pub-sub-video-call".to_string()); @@ -63,6 +65,16 @@ fn main() { let reply = client.delete(&delete_request).expect("delete"); println!("{:?}", reply); + // Delete endpoint + let mut delete_endpoint_req = IdRequest::new(); + let mut endpoints = RepeatedField::new(); + endpoints.push("local://video-call-1/caller".to_string()); + delete_endpoint_req.set_id(endpoints); + + let reply = client.delete(&delete_endpoint_req).expect("delete member"); + println!("{:?}", reply); + + // Delete member let mut delete_member_req = IdRequest::new(); let mut members = RepeatedField::new(); members.push("local://video-call-1/caller".to_string()); diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index d7997eb7a..5279b19fb 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -271,6 +271,20 @@ impl Member { pub fn remove_src(&self, id: &WebRtcPublishId) { self.0.borrow_mut().srcs.remove(id); } + + pub fn take_sink( + &self, + id: &WebRtcPlayId, + ) -> Option> { + self.0.borrow_mut().sinks.remove(id) + } + + pub fn take_src( + &self, + id: &WebRtcPublishId, + ) -> Option> { + self.0.borrow_mut().srcs.remove(id) + } } /// Creates all empty [`Member`] from [`RoomSpec`] and then diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 9c511a4b6..afd336891 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -315,7 +315,11 @@ impl ParticipantService { join_all(close_fut).map(|_| ()) } - pub fn delete_member(&mut self, member_id: &MemberId, ctx: &mut Context) { + pub fn delete_member( + &mut self, + member_id: &MemberId, + ctx: &mut Context, + ) { if let Some(drop) = self.drop_connection_tasks.remove(member_id) { ctx.cancel_future(drop); } diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index d3b60a2a4..e48da3be3 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -6,7 +6,7 @@ use std::{ }; use actix::{AsyncContext as _, Context}; -use hashbrown::HashMap; +use hashbrown::{HashMap, HashSet}; use crate::{ api::control::MemberId, @@ -173,6 +173,39 @@ impl PeerRepository { } } + pub fn remove_peer( + &mut self, + member_id: MemberId, + peer_id: PeerId, + ctx: &mut Context, + ) { + if let Some(_) = self.peers.remove(&peer_id) { + ctx.notify(PeersRemoved { + member_id, + peers_id: vec![peer_id], + }) + } + } + + pub fn remove_peers( + &mut self, + member_id: MemberId, + peer_ids: HashSet, + ctx: &mut Context, + ) { + let mut removed_peer_ids = Vec::new(); + for peer_id in peer_ids { + if let Some(_) = self.peers.remove(&peer_id) { + removed_peer_ids.push(peer_id); + } + } + + ctx.notify(PeersRemoved { + member_id, + peers_id: removed_peer_ids, + }) + } + /// Close all related to disconnected [`Member`] [`Peer`]s and partner /// [`Peer`]s. /// diff --git a/src/signalling/room.rs b/src/signalling/room.rs index e86a5d882..a8073f231 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -27,7 +27,10 @@ use crate::{ }, signalling::{ elements::{ - endpoints::webrtc::{WebRtcPlayEndpoint, WebRtcPublishEndpoint}, + endpoints::webrtc::{ + WebRtcPlayEndpoint, WebRtcPlayId, WebRtcPublishEndpoint, + WebRtcPublishId, + }, Member, MembersLoadError, }, participants::ParticipantService, @@ -647,3 +650,34 @@ impl Handler for Room { self.members.delete_member(&msg.0, ctx); } } + +#[derive(Debug, Message)] +#[rtype(result = "()")] +pub struct DeleteEndpoint { + pub member_id: MemberId, + pub endpoint_id: String, +} + +impl Handler for Room { + type Result = (); + + fn handle( + &mut self, + msg: DeleteEndpoint, + ctx: &mut Self::Context, + ) -> Self::Result { + let member = self.members.get_member_by_id(&msg.member_id).unwrap(); + let play_id = WebRtcPlayId(msg.endpoint_id); + if let Some(endpoint) = member.take_sink(&play_id) { + if let Some(peer_id) = endpoint.peer_id() { + self.peers.remove_peer(msg.member_id.clone(), peer_id, ctx); + } + } + + let publish_id = WebRtcPublishId(play_id.0); + if let Some(endpoint) = member.take_src(&publish_id) { + let peer_ids = endpoint.peer_ids(); + self.peers.remove_peers(msg.member_id, peer_ids, ctx); + } + } +} diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs index 9c4e93ca7..9606c20be 100644 --- a/src/signalling/room_repo.rs +++ b/src/signalling/room_repo.rs @@ -8,7 +8,7 @@ use hashbrown::HashMap; use crate::{ api::control::{room::RoomSpec, MemberId, RoomId}, signalling::{ - room::{CloseRoom, DeleteMember, RoomError}, + room::{CloseRoom, DeleteEndpoint, DeleteMember, RoomError}, Room, }, App, @@ -123,3 +123,30 @@ impl Handler for RoomsRepository { room.do_send(DeleteMember(msg.member_id)); } } + +#[derive(Message)] +#[rtype(result = "()")] +pub struct DeleteEndpointFromMember { + pub room_id: RoomId, + pub member_id: MemberId, + pub endpoint_id: String, +} + +impl Handler for RoomsRepository { + type Result = (); + + fn handle( + &mut self, + msg: DeleteEndpointFromMember, + _ctx: &mut Self::Context, + ) -> Self::Result { + if let Some(room) = self.get(&msg.room_id) { + room.do_send(DeleteEndpoint { + endpoint_id: msg.endpoint_id, + member_id: msg.member_id, + }); + } else { + panic!() + } + } +} From f46e9e321efd39bd19a3ef278242d257e77c8c71 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 8 Jul 2019 18:27:32 +0300 Subject: [PATCH 283/735] Add error to room repo --- src/signalling/room_repo.rs | 43 +++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs index 9606c20be..3bec25bdd 100644 --- a/src/signalling/room_repo.rs +++ b/src/signalling/room_repo.rs @@ -3,6 +3,7 @@ use std::sync::{Arc, Mutex}; use actix::{Actor, Addr, Context, Handler, Message}; +use failure::Fail; use hashbrown::HashMap; use crate::{ @@ -14,6 +15,12 @@ use crate::{ App, }; +#[derive(Debug, Fail)] +pub enum RoomRepoError { + #[fail(display = "Room with id {} not found.", _0)] + RoomNotFound(RoomId), +} + /// Repository that stores [`Room`]s addresses. #[derive(Clone, Debug)] pub struct RoomsRepository { @@ -82,50 +89,56 @@ impl Handler for RoomsRepository { } #[derive(Message)] -#[rtype(result = "()")] +#[rtype(result = "Result<(), RoomRepoError>")] pub struct DeleteRoom(pub RoomId); impl Handler for RoomsRepository { - type Result = (); + type Result = Result<(), RoomRepoError>; fn handle( &mut self, msg: DeleteRoom, _ctx: &mut Self::Context, ) -> Self::Result { - let mut is_need_remove = false; if let Some(room) = self.rooms.lock().unwrap().get(&msg.0) { room.do_send(CloseRoom {}); - is_need_remove = true; - } - if is_need_remove { - self.remove(&msg.0); + } else { + return Err(RoomRepoError::RoomNotFound(msg.0)); } + + self.remove(&msg.0); + + Ok(()) } } #[derive(Message)] -#[rtype(result = "()")] +#[rtype(result = "Result<(), RoomRepoError>")] pub struct DeleteMemberFromRoom { pub member_id: MemberId, pub room_id: RoomId, } impl Handler for RoomsRepository { - type Result = (); + type Result = Result<(), RoomRepoError>; fn handle( &mut self, msg: DeleteMemberFromRoom, _ctx: &mut Self::Context, ) -> Self::Result { - let room = self.get(&msg.room_id).unwrap(); // TODO - room.do_send(DeleteMember(msg.member_id)); + if let Some(room) = self.get(&msg.room_id) { + room.do_send(DeleteMember(msg.member_id)); + } else { + return Err(RoomRepoError::RoomNotFound(msg.room_id)); + } + + Ok(()) } } #[derive(Message)] -#[rtype(result = "()")] +#[rtype(result = "Result<(), RoomRepoError>")] pub struct DeleteEndpointFromMember { pub room_id: RoomId, pub member_id: MemberId, @@ -133,7 +146,7 @@ pub struct DeleteEndpointFromMember { } impl Handler for RoomsRepository { - type Result = (); + type Result = Result<(), RoomRepoError>; fn handle( &mut self, @@ -146,7 +159,9 @@ impl Handler for RoomsRepository { member_id: msg.member_id, }); } else { - panic!() + return Err(RoomRepoError::RoomNotFound(msg.room_id)); } + + Ok(()) } } From c651e7e6b46d2e0da0ff7e79357ca9affdd4290a Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 8 Jul 2019 19:04:26 +0300 Subject: [PATCH 284/735] Fix tests --- src/api/client/server.rs | 12 +++--------- src/turn/service.rs | 3 ++- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/api/client/server.rs b/src/api/client/server.rs index 55ef85c52..8f2bd0873 100644 --- a/src/api/client/server.rs +++ b/src/api/client/server.rs @@ -124,17 +124,13 @@ mod test { }; use super::*; - use crate::api::control::{ - model::room::RoomSpec, serde::room::SerdeRoomSpecImpl, - }; use std::sync::Arc; /// Creates [`RoomsRepository`] for tests filled with a single [`Room`]. fn room(conf: Conf) -> RoomsRepository { - let room_spec = control::serde::load_from_yaml_file( - "tests/specs/pub_sub_video_call.yml", - ) - .unwrap(); + let room_spec = + control::load_from_yaml_file("tests/specs/pub_sub_video_call.yml") + .unwrap(); let app = Arc::new(crate::App { config: conf, @@ -144,8 +140,6 @@ mod test { let room_id = room_spec.id.clone(); let client_room = Room::start_in_arbiter(&Arbiter::new(), move |_| { - let room_spec = SerdeRoomSpecImpl::new(&room_spec).unwrap(); - let room_spec = Box::new(&room_spec as &RoomSpec); let client_room = Room::new( &room_spec, app.config.rpc.reconnect_timeout, diff --git a/src/turn/service.rs b/src/turn/service.rs index 39bd2ff22..f96fc1932 100644 --- a/src/turn/service.rs +++ b/src/turn/service.rs @@ -310,7 +310,8 @@ pub mod test { } #[allow(clippy::module_name_repetitions)] - pub fn new_turn_auth_service_mock() -> Box { + pub fn new_turn_auth_service_mock() -> Box + { Box::new(TurnAuthServiceMock {}) } From a96a23a7140a6207aec252d6cc9f2d8604854ec5 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 8 Jul 2019 19:10:05 +0300 Subject: [PATCH 285/735] Fmt fix --- src/api/client/server.rs | 3 +-- src/api/control/grpc/server.rs | 21 +++++++++------------ src/api/control/member.rs | 2 +- src/api/control/room.rs | 5 +++-- src/bin/client.rs | 3 ++- src/lib.rs | 7 +++---- src/main.rs | 9 +++++---- 7 files changed, 24 insertions(+), 26 deletions(-) diff --git a/src/api/client/server.rs b/src/api/client/server.rs index 8f2bd0873..5c362eeaf 100644 --- a/src/api/client/server.rs +++ b/src/api/client/server.rs @@ -110,7 +110,7 @@ pub fn run(rooms: RoomsRepository, config: Conf) { #[cfg(test)] mod test { - use std::{ops::Add, thread, time::Duration}; + use std::{ops::Add, sync::Arc, thread, time::Duration}; use actix::{Actor as _, Arbiter}; use actix_http::{ws::Message, HttpService}; @@ -124,7 +124,6 @@ mod test { }; use super::*; - use std::sync::Arc; /// Creates [`RoomsRepository`] for tests filled with a single [`Room`]. fn room(conf: Conf) -> RoomsRepository { diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index 2f180f980..79c3e4243 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -1,30 +1,27 @@ -use std::sync::Arc; +use std::{collections::HashMap, sync::Arc}; use actix::{Actor, Addr, Arbiter, Context}; -use futures::future::Future; +use futures::future::{Either, Future}; use grpcio::{Environment, RpcContext, Server, ServerBuilder, UnarySink}; use crate::{ api::control::{ grpc::protos::control::{ - ApplyRequest, CreateRequest, GetResponse, IdRequest, Response, + ApplyRequest, CreateRequest, Error, GetResponse, IdRequest, + Response, }, + local_uri::LocalUri, RoomSpec, }, log::prelude::*, - signalling::room_repo::RoomsRepository, + signalling::room_repo::{ + DeleteEndpointFromMember, DeleteMemberFromRoom, DeleteRoom, + RoomsRepository, StartRoom, + }, App, }; use super::protos::control_grpc::{create_control_api, ControlApi}; -use crate::{ - api::control::{grpc::protos::control::Error, local_uri::LocalUri}, - signalling::room_repo::{ - DeleteEndpointFromMember, DeleteMemberFromRoom, DeleteRoom, StartRoom, - }, -}; -use futures::future::Either; -use std::collections::HashMap; #[derive(Clone)] struct ControlApiService { diff --git a/src/api/control/member.rs b/src/api/control/member.rs index 3e2723d46..5253b573e 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -10,10 +10,10 @@ use serde::Deserialize; use crate::api::control::{ endpoint::{WebRtcPlayEndpoint, WebRtcPublishEndpoint, WebRtcPublishId}, grpc::protos::control::Member as MemberProto, + Endpoint, TryFromProtobufError, }; use super::{pipeline::Pipeline, Element, TryFromElementError}; -use crate::api::control::{Endpoint, TryFromProtobufError}; macro_attr! { /// ID of [`Room`]. diff --git a/src/api/control/room.rs b/src/api/control/room.rs index fdc836830..d5a28f736 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -7,13 +7,14 @@ use macro_attr::*; use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; use serde::Deserialize; -use crate::api::control::grpc::protos::control::Room as RoomProto; +use crate::api::control::{ + grpc::protos::control::Room as RoomProto, TryFromProtobufError, +}; use super::{ member::MemberSpec, pipeline::Pipeline, Element, MemberId, TryFromElementError, }; -use crate::api::control::TryFromProtobufError; macro_attr! { /// ID of [`Room`]. diff --git a/src/bin/client.rs b/src/bin/client.rs index 807c12050..904a3f2ce 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -1,3 +1,5 @@ +use std::{collections::HashMap, sync::Arc}; + use grpcio::{ChannelBuilder, EnvBuilder}; use medea::api::control::grpc::protos::{ control::{ @@ -7,7 +9,6 @@ use medea::api::control::grpc::protos::{ control_grpc::ControlApiClient, }; use protobuf::RepeatedField; -use std::{collections::HashMap, sync::Arc}; fn main() { let env = Arc::new(EnvBuilder::new().build()); diff --git a/src/lib.rs b/src/lib.rs index e6e745252..f0f6e9fc8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -9,6 +9,8 @@ pub mod media; pub mod signalling; pub mod turn; +use std::sync::Arc; + use actix::{Actor as _, Addr}; use failure::Fail; use hashbrown::HashMap; @@ -17,12 +19,9 @@ use crate::{ api::control::{load_static_specs_from_dir, RoomId}, conf::Conf, signalling::{room::RoomError, Room}, - turn::service, + turn::{service, TurnAuthService}, }; -use crate::turn::TurnAuthService; -use std::sync::Arc; - #[derive(Debug)] pub struct App { pub config: Conf, diff --git a/src/main.rs b/src/main.rs index 29182786b..5a4111bfa 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,16 +1,17 @@ +use std::sync::Arc; + use actix::{Actor as _, Arbiter, System}; use failure::Error; use medea::{ - api::client::server, + api::{client::server, control::grpc}, conf::Conf, log::{self, prelude::*}, signalling::room_repo::RoomsRepository, start_static_rooms, + turn::new_turn_auth_service, + App, }; -use medea::{api::control::grpc, turn::new_turn_auth_service, App}; -use std::sync::Arc; - fn main() -> Result<(), Error> { dotenv::dotenv().ok(); let logger = log::new_dual_logger(std::io::stdout(), std::io::stderr()); From dddcfb862e976f3bc2a9aa8e779cdd6bf33eb2fb Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 8 Jul 2019 19:19:07 +0300 Subject: [PATCH 286/735] Remove old endpoints IDs --- src/api/control/mod.rs | 2 +- src/signalling/elements/endpoints/webrtc/mod.rs | 4 ++-- .../elements/endpoints/webrtc/play_endpoint.rs | 15 +++------------ .../endpoints/webrtc/publish_endpoint.rs | 13 ++----------- src/signalling/elements/member.rs | 16 +++++++--------- src/signalling/room.rs | 10 +++++----- 6 files changed, 20 insertions(+), 40 deletions(-) diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index 32bc9ffd2..cd8eca382 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -18,7 +18,7 @@ use self::{ }; pub use self::{ - endpoint::Endpoint, + endpoint::{Endpoint, WebRtcPlayId, WebRtcPublishId}, member::{Id as MemberId, MemberSpec}, room::{Id as RoomId, RoomSpec}, }; diff --git a/src/signalling/elements/endpoints/webrtc/mod.rs b/src/signalling/elements/endpoints/webrtc/mod.rs index aacfc952b..162c5ba2d 100644 --- a/src/signalling/elements/endpoints/webrtc/mod.rs +++ b/src/signalling/elements/endpoints/webrtc/mod.rs @@ -4,6 +4,6 @@ pub mod play_endpoint; pub mod publish_endpoint; #[doc(inline)] -pub use play_endpoint::{WebRtcPlayEndpoint, WebRtcPlayId}; +pub use play_endpoint::WebRtcPlayEndpoint; #[doc(inline)] -pub use publish_endpoint::{WebRtcPublishEndpoint, WebRtcPublishId}; +pub use publish_endpoint::WebRtcPublishEndpoint; diff --git a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs index 8c984aa1b..2a7bb57bc 100644 --- a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs @@ -5,23 +5,14 @@ use std::{ rc::{Rc, Weak}, }; -use macro_attr::*; -use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; - use crate::{ - api::control::endpoint::SrcUri, media::PeerId, signalling::elements::Member, + api::control::endpoint::{SrcUri, WebRtcPlayId as Id}, + media::PeerId, + signalling::elements::Member, }; use super::publish_endpoint::WebRtcPublishEndpoint; -pub use Id as WebRtcPlayId; - -macro_attr! { - /// ID of endpoint. - #[derive(Clone, Debug, Eq, Hash, PartialEq, NewtypeFrom!, NewtypeDisplay!)] - pub struct Id(pub String); -} - #[derive(Debug, Clone)] struct WebRtcPlayEndpointInner { /// ID of this [`WebRtcPlayEndpoint`]. diff --git a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs index a39e3108d..899d8362a 100644 --- a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs @@ -6,24 +6,15 @@ use std::{ }; use hashbrown::HashSet; -use macro_attr::*; -use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; use crate::{ - api::control::endpoint::P2pMode, media::PeerId, + api::control::endpoint::{P2pMode, WebRtcPublishId as Id}, + media::PeerId, signalling::elements::Member, }; use super::play_endpoint::WebRtcPlayEndpoint; -pub use Id as WebRtcPublishId; - -macro_attr! { - /// ID of endpoint. - #[derive(Clone, Debug, Eq, Hash, PartialEq, NewtypeFrom!, NewtypeDisplay!)] - pub struct Id(pub String); -} - #[derive(Debug, Clone)] struct WebRtcPublishEndpointInner { /// ID of this [`WebRtcPublishEndpoint`]. diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index 5279b19fb..da4735ba7 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -7,14 +7,15 @@ use hashbrown::HashMap; use medea_client_api_proto::IceServer; use crate::{ - api::control::{MemberId, MemberSpec, RoomSpec, TryFromElementError}, + api::control::{ + MemberId, MemberSpec, RoomSpec, TryFromElementError, WebRtcPlayId, + WebRtcPublishId, + }, log::prelude::*, media::{IceUser, PeerId}, }; -use super::endpoints::webrtc::{ - WebRtcPlayEndpoint, WebRtcPlayId, WebRtcPublishEndpoint, WebRtcPublishId, -}; +use super::endpoints::webrtc::{WebRtcPlayEndpoint, WebRtcPublishEndpoint}; /// Errors which may occur while loading [`Member`]s from [`RoomSpec`]. #[derive(Debug, Fail)] @@ -141,9 +142,7 @@ impl Member { publisher.add_sink(Rc::downgrade(&new_play_endpoint)); } else { - let new_publish_id = WebRtcPublishId( - spec_play_endpoint.src.endpoint_id.to_string(), - ); + let new_publish_id = &spec_play_endpoint.src.endpoint_id; let new_publish = Rc::new(WebRtcPublishEndpoint::new( new_publish_id.clone(), publisher_endpoint.p2p.clone(), @@ -170,8 +169,7 @@ impl Member { // This is necessary to create [`WebRtcPublishEndpoint`], // to which none [`WebRtcPlayEndpoint`] refers. this_member_spec.publish_endpoints().into_iter().for_each( - |(name, e)| { - let endpoint_id = WebRtcPublishId(name.to_string()); // TODO + |(endpoint_id, e)| { if self.srcs().get(&endpoint_id).is_none() { self.insert_src(Rc::new(WebRtcPublishEndpoint::new( endpoint_id, diff --git a/src/signalling/room.rs b/src/signalling/room.rs index a8073f231..cd9eefe4e 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -18,7 +18,10 @@ use crate::{ AuthorizationError, Authorize, ClosedReason, CommandMessage, RpcConnectionClosed, RpcConnectionEstablished, }, - control::{room::RoomSpec, MemberId, RoomId, TryFromElementError}, + control::{ + room::RoomSpec, MemberId, RoomId, TryFromElementError, + WebRtcPlayId, WebRtcPublishId, + }, }, log::prelude::*, media::{ @@ -27,10 +30,7 @@ use crate::{ }, signalling::{ elements::{ - endpoints::webrtc::{ - WebRtcPlayEndpoint, WebRtcPlayId, WebRtcPublishEndpoint, - WebRtcPublishId, - }, + endpoints::webrtc::{WebRtcPlayEndpoint, WebRtcPublishEndpoint}, Member, MembersLoadError, }, participants::ParticipantService, From eb57d74d8693e826ebfc3518001c5a28a25f355f Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 8 Jul 2019 19:43:33 +0300 Subject: [PATCH 287/735] Separate publish and play endpoints in api::control module --- src/api/control/endpoints/mod.rs | 66 +++++++++ .../control/endpoints/webrtc_play_endpoint.rs | 138 ++++++++++++++++++ .../endpoints/webrtc_publish_endpoint.rs | 77 ++++++++++ src/api/control/member.rs | 5 +- src/api/control/mod.rs | 14 +- .../endpoints/webrtc/play_endpoint.rs | 4 +- .../endpoints/webrtc/publish_endpoint.rs | 4 +- 7 files changed, 301 insertions(+), 7 deletions(-) create mode 100644 src/api/control/endpoints/mod.rs create mode 100644 src/api/control/endpoints/webrtc_play_endpoint.rs create mode 100644 src/api/control/endpoints/webrtc_publish_endpoint.rs diff --git a/src/api/control/endpoints/mod.rs b/src/api/control/endpoints/mod.rs new file mode 100644 index 000000000..8d7ef33c3 --- /dev/null +++ b/src/api/control/endpoints/mod.rs @@ -0,0 +1,66 @@ +pub mod webrtc_play_endpoint; +pub mod webrtc_publish_endpoint; + +use std::convert::TryFrom; + +use crate::api::control::grpc::protos::control::Member_Element as MemberElementProto; + +use super::{Element, TryFromElementError, TryFromProtobufError}; + +use self::{ + webrtc_play_endpoint::WebRtcPlayEndpoint, + webrtc_publish_endpoint::WebRtcPublishEndpoint, +}; + +/// [`Endpoint`] represents a media element that one or more media data streams +/// flow through. +#[derive(Debug)] +pub enum Endpoint { + WebRtcPublish(WebRtcPublishEndpoint), + WebRtcPlay(WebRtcPlayEndpoint), +} + +impl Into for Endpoint { + fn into(self) -> Element { + match self { + Endpoint::WebRtcPublish(e) => { + Element::WebRtcPublishEndpoint { spec: e } + } + Endpoint::WebRtcPlay(e) => Element::WebRtcPlayEndpoint { spec: e }, + } + } +} + +impl TryFrom<&MemberElementProto> for Endpoint { + type Error = TryFromProtobufError; + + fn try_from(value: &MemberElementProto) -> Result { + if value.has_webrtc_play() { + let play = WebRtcPlayEndpoint::try_from(value.get_webrtc_play())?; + return Ok(Endpoint::WebRtcPlay(play)); + } else if value.has_webrtc_pub() { + let publish = + WebRtcPublishEndpoint::try_from(value.get_webrtc_pub())?; + return Ok(Endpoint::WebRtcPublish(publish)); + } else { + // TODO + unimplemented!() + } + } +} + +impl TryFrom<&Element> for Endpoint { + type Error = TryFromElementError; + + fn try_from(from: &Element) -> Result { + match from { + Element::WebRtcPlayEndpoint { spec } => { + Ok(Endpoint::WebRtcPlay(spec.clone())) + } + Element::WebRtcPublishEndpoint { spec } => { + Ok(Endpoint::WebRtcPublish(spec.clone())) + } + _ => Err(TryFromElementError::NotEndpoint), + } + } +} diff --git a/src/api/control/endpoints/webrtc_play_endpoint.rs b/src/api/control/endpoints/webrtc_play_endpoint.rs new file mode 100644 index 000000000..408744395 --- /dev/null +++ b/src/api/control/endpoints/webrtc_play_endpoint.rs @@ -0,0 +1,138 @@ +use std::{convert::TryFrom, fmt}; + +use failure::Fail; +use macro_attr::*; +use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; +use serde::{ + de::{self, Deserializer, Error, Visitor}, + Deserialize, +}; + +use crate::api::control::{ + endpoints::webrtc_publish_endpoint::WebRtcPublishId, + grpc::protos::control::WebRtcPlayEndpoint as WebRtcPlayEndpointProto, + local_uri::{LocalUri, LocalUriParseError}, + MemberId, RoomId, TryFromProtobufError, +}; + +macro_attr! { + /// ID of [`Room`]. + #[derive( + Clone, + Debug, + Deserialize, + Eq, + Hash, + PartialEq, + NewtypeFrom!, + NewtypeDisplay!, + )] + pub struct WebRtcPlayId(pub String); +} + +/// Media element which is able to play media data for client via WebRTC. +#[allow(clippy::module_name_repetitions)] +#[derive(Clone, Deserialize, Debug)] +pub struct WebRtcPlayEndpoint { + /// Source URI in format `local://{room_id}/{member_id}/{endpoint_id}`. + pub src: SrcUri, +} + +impl TryFrom<&WebRtcPlayEndpointProto> for WebRtcPlayEndpoint { + type Error = TryFromProtobufError; + + fn try_from(value: &WebRtcPlayEndpointProto) -> Result { + if value.has_src() { + Ok(Self { + src: SrcUri::parse(value.get_src())?, + }) + } else { + Err(TryFromProtobufError::SrcUriNotFound) + } + } +} + +/// Special uri with pattern `local://{room_id}/{member_id}/{endpoint_id}`. +#[derive(Clone, Debug)] +pub struct SrcUri { + /// ID of [`Room`] + pub room_id: RoomId, + /// ID of `Member` + pub member_id: MemberId, + /// Control ID of [`Endpoint`] + pub endpoint_id: WebRtcPublishId, +} + +// TODO +#[derive(Debug, Fail)] +pub enum SrcParseError { + #[fail(display = "Missing fields {:?} in '{}' local URI.", _1, _0)] + MissingField(String, Vec), + #[fail(display = "Local URI '{}' parse error: {:?}", _0, _1)] + LocalUriParseError(String, LocalUriParseError), +} + +impl SrcUri { + pub fn parse(value: &str) -> Result { + let local_uri = LocalUri::parse(value).map_err(|e| { + SrcParseError::LocalUriParseError(value.to_string(), e) + })?; + + let mut missing_fields = Vec::new(); + if local_uri.room_id.is_none() { + missing_fields.push("room_id".to_string()); + } + if local_uri.member_id.is_none() { + missing_fields.push("member_id".to_string()); + } + if local_uri.endpoint_id.is_none() { + missing_fields.push("endpoint_id".to_string()); + } + + if !missing_fields.is_empty() { + return Err(SrcParseError::MissingField( + value.to_string(), + missing_fields, + )); + } else { + Ok(Self { + room_id: local_uri.room_id.unwrap(), + member_id: local_uri.member_id.unwrap(), + endpoint_id: WebRtcPublishId(local_uri.endpoint_id.unwrap()), + }) + } + } +} + +/// Serde deserializer for [`SrcUri`]. +/// Deserialize URIs with pattern `local://{room_id}/{member_id}/{endpoint_id}`. +impl<'de> Deserialize<'de> for SrcUri { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct SrcUriVisitor; + + impl<'de> Visitor<'de> for SrcUriVisitor { + type Value = SrcUri; + + fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str( + "Uri in format local://room_id/member_id/endpoint_id", + ) + } + + fn visit_str(self, value: &str) -> Result + where + E: de::Error, + { + match SrcUri::parse(value) { + Ok(src_uri) => Ok(src_uri), + Err(e) => Err(Error::custom(e)), + } + } + } + + deserializer.deserialize_identifier(SrcUriVisitor) + } +} diff --git a/src/api/control/endpoints/webrtc_publish_endpoint.rs b/src/api/control/endpoints/webrtc_publish_endpoint.rs new file mode 100644 index 000000000..6814826a0 --- /dev/null +++ b/src/api/control/endpoints/webrtc_publish_endpoint.rs @@ -0,0 +1,77 @@ +use std::convert::TryFrom; + +use macro_attr::*; +use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; +use serde::Deserialize; + +use crate::api::control::{ + grpc::protos::control::{ + WebRtcPublishEndpoint as WebRtcPublishEndpointProto, + WebRtcPublishEndpoint_P2P as WebRtcPublishEndpointP2pProto, + }, + TryFromProtobufError, +}; + +macro_attr! { + /// ID of [`Room`]. + #[derive( + Clone, + Debug, + Deserialize, + Eq, + Hash, + PartialEq, + NewtypeFrom!, + NewtypeDisplay!, + )] + pub struct WebRtcPublishId(pub String); +} + +/// Peer-to-peer mode of [`WebRtcPublishEndpoint`]. +#[derive(Clone, Deserialize, Debug)] +pub enum P2pMode { + /// Always connect peer-to-peer. + Always, + Never, + IfPossible, +} + +// TODO: use From +impl TryFrom for P2pMode { + type Error = TryFromProtobufError; + + fn try_from( + value: WebRtcPublishEndpointP2pProto, + ) -> Result { + Ok(match value { + WebRtcPublishEndpointP2pProto::ALWAYS => P2pMode::Always, + WebRtcPublishEndpointP2pProto::IF_POSSIBLE => P2pMode::IfPossible, + WebRtcPublishEndpointP2pProto::NEVER => P2pMode::Never, + }) + } +} + +/// Media element which is able to publish media data for another client via +/// WebRTC. +#[allow(clippy::module_name_repetitions)] +#[derive(Clone, Deserialize, Debug)] +pub struct WebRtcPublishEndpoint { + /// Peer-to-peer mode. + pub p2p: P2pMode, +} + +impl TryFrom<&WebRtcPublishEndpointProto> for WebRtcPublishEndpoint { + type Error = TryFromProtobufError; + + fn try_from( + value: &WebRtcPublishEndpointProto, + ) -> Result { + if value.has_p2p() { + Ok(Self { + p2p: P2pMode::try_from(value.get_p2p())?, + }) + } else { + Err(TryFromProtobufError::P2pModeNotFound) + } + } +} diff --git a/src/api/control/member.rs b/src/api/control/member.rs index 5253b573e..a59f78171 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -8,7 +8,10 @@ use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; use serde::Deserialize; use crate::api::control::{ - endpoint::{WebRtcPlayEndpoint, WebRtcPublishEndpoint, WebRtcPublishId}, + endpoints::{ + webrtc_play_endpoint::WebRtcPlayEndpoint, + webrtc_publish_endpoint::{WebRtcPublishEndpoint, WebRtcPublishId}, + }, grpc::protos::control::Member as MemberProto, Endpoint, TryFromProtobufError, }; diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index cd8eca382..80e40402c 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -1,6 +1,7 @@ //! Implementation of Control API. -pub mod endpoint; +// pub mod endpoint; +pub mod endpoints; pub mod grpc; pub mod local_uri; pub mod member; @@ -13,16 +14,21 @@ use failure::{Error, Fail}; use serde::Deserialize; use self::{ - endpoint::{WebRtcPlayEndpoint, WebRtcPublishEndpoint}, + endpoints::{ + webrtc_play_endpoint::{SrcParseError, WebRtcPlayEndpoint}, + webrtc_publish_endpoint::WebRtcPublishEndpoint, + }, pipeline::Pipeline, }; pub use self::{ - endpoint::{Endpoint, WebRtcPlayId, WebRtcPublishId}, + endpoints::{ + webrtc_play_endpoint::WebRtcPlayId, + webrtc_publish_endpoint::WebRtcPublishId, Endpoint, + }, member::{Id as MemberId, MemberSpec}, room::{Id as RoomId, RoomSpec}, }; -use crate::api::control::endpoint::SrcParseError; #[derive(Debug, Fail)] pub enum TryFromProtobufError { diff --git a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs index 2a7bb57bc..40c531367 100644 --- a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs @@ -6,7 +6,9 @@ use std::{ }; use crate::{ - api::control::endpoint::{SrcUri, WebRtcPlayId as Id}, + api::control::endpoints::webrtc_play_endpoint::{ + SrcUri, WebRtcPlayId as Id, + }, media::PeerId, signalling::elements::Member, }; diff --git a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs index 899d8362a..c9a5059ea 100644 --- a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs @@ -8,7 +8,9 @@ use std::{ use hashbrown::HashSet; use crate::{ - api::control::endpoint::{P2pMode, WebRtcPublishId as Id}, + api::control::endpoints::webrtc_publish_endpoint::{ + P2pMode, WebRtcPublishId as Id, + }, media::PeerId, signalling::elements::Member, }; From 6e084f2f8e7ed95251f39cda2c2fdd1308af79cc Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 8 Jul 2019 19:53:17 +0300 Subject: [PATCH 288/735] Delete old endpoint module --- src/api/control/endpoint.rs | 319 ------------------------------------ 1 file changed, 319 deletions(-) delete mode 100644 src/api/control/endpoint.rs diff --git a/src/api/control/endpoint.rs b/src/api/control/endpoint.rs deleted file mode 100644 index 41fe30482..000000000 --- a/src/api/control/endpoint.rs +++ /dev/null @@ -1,319 +0,0 @@ -//! Control API specification Endpoint definitions. - -use std::{convert::TryFrom, fmt}; - -use failure::Fail; -use macro_attr::*; -use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; -use serde::{ - de::{self, Deserializer, Error, Visitor}, - Deserialize, -}; - -use crate::api::control::grpc::protos::control::{ - Member_Element as MemberElementProto, - WebRtcPlayEndpoint as WebRtcPlayEndpointProto, - WebRtcPublishEndpoint as WebRtcPublishEndpointProto, - WebRtcPublishEndpoint_P2P as WebRtcPublishEndpointP2pProto, -}; - -use super::{ - local_uri::{LocalUri, LocalUriParseError}, - Element, MemberId, RoomId, TryFromElementError, TryFromProtobufError, -}; - -macro_attr! { - /// ID of [`Room`]. - #[derive( - Clone, - Debug, - Deserialize, - Eq, - Hash, - PartialEq, - NewtypeFrom!, - NewtypeDisplay!, - )] - pub struct WebRtcPublishId(pub String); -} - -macro_attr! { - /// ID of [`Room`]. - #[derive( - Clone, - Debug, - Deserialize, - Eq, - Hash, - PartialEq, - NewtypeFrom!, - NewtypeDisplay!, - )] - pub struct WebRtcPlayId(pub String); -} - -/// Peer-to-peer mode of [`WebRtcPublishEndpoint`]. -#[derive(Clone, Deserialize, Debug)] -pub enum P2pMode { - /// Always connect peer-to-peer. - Always, - Never, - IfPossible, -} - -// TODO: use From -impl TryFrom for P2pMode { - type Error = TryFromProtobufError; - - fn try_from( - value: WebRtcPublishEndpointP2pProto, - ) -> Result { - Ok(match value { - WebRtcPublishEndpointP2pProto::ALWAYS => P2pMode::Always, - WebRtcPublishEndpointP2pProto::IF_POSSIBLE => P2pMode::IfPossible, - WebRtcPublishEndpointP2pProto::NEVER => P2pMode::Never, - }) - } -} - -/// [`Endpoint`] represents a media element that one or more media data streams -/// flow through. -#[derive(Debug)] -pub enum Endpoint { - WebRtcPublish(WebRtcPublishEndpoint), - WebRtcPlay(WebRtcPlayEndpoint), -} - -impl Into for Endpoint { - fn into(self) -> Element { - match self { - Endpoint::WebRtcPublish(e) => { - Element::WebRtcPublishEndpoint { spec: e } - } - Endpoint::WebRtcPlay(e) => Element::WebRtcPlayEndpoint { spec: e }, - } - } -} - -impl TryFrom<&MemberElementProto> for Endpoint { - type Error = TryFromProtobufError; - - fn try_from(value: &MemberElementProto) -> Result { - if value.has_webrtc_play() { - let play = WebRtcPlayEndpoint::try_from(value.get_webrtc_play())?; - return Ok(Endpoint::WebRtcPlay(play)); - } else if value.has_webrtc_pub() { - let publish = - WebRtcPublishEndpoint::try_from(value.get_webrtc_pub())?; - return Ok(Endpoint::WebRtcPublish(publish)); - } else { - // TODO - unimplemented!() - } - } -} - -impl TryFrom<&Element> for Endpoint { - type Error = TryFromElementError; - - fn try_from(from: &Element) -> Result { - match from { - Element::WebRtcPlayEndpoint { spec } => { - Ok(Endpoint::WebRtcPlay(spec.clone())) - } - Element::WebRtcPublishEndpoint { spec } => { - Ok(Endpoint::WebRtcPublish(spec.clone())) - } - _ => Err(TryFromElementError::NotEndpoint), - } - } -} - -/// Media element which is able to publish media data for another client via -/// WebRTC. -#[allow(clippy::module_name_repetitions)] -#[derive(Clone, Deserialize, Debug)] -pub struct WebRtcPublishEndpoint { - /// Peer-to-peer mode. - pub p2p: P2pMode, -} - -impl TryFrom<&WebRtcPublishEndpointProto> for WebRtcPublishEndpoint { - type Error = TryFromProtobufError; - - fn try_from( - value: &WebRtcPublishEndpointProto, - ) -> Result { - if value.has_p2p() { - Ok(Self { - p2p: P2pMode::try_from(value.get_p2p())?, - }) - } else { - Err(TryFromProtobufError::P2pModeNotFound) - } - } -} - -/// Media element which is able to play media data for client via WebRTC. -#[allow(clippy::module_name_repetitions)] -#[derive(Clone, Deserialize, Debug)] -pub struct WebRtcPlayEndpoint { - /// Source URI in format `local://{room_id}/{member_id}/{endpoint_id}`. - pub src: SrcUri, -} - -impl TryFrom<&WebRtcPlayEndpointProto> for WebRtcPlayEndpoint { - type Error = TryFromProtobufError; - - fn try_from(value: &WebRtcPlayEndpointProto) -> Result { - if value.has_src() { - Ok(Self { - src: SrcUri::parse(value.get_src())?, - }) - } else { - Err(TryFromProtobufError::SrcUriNotFound) - } - } -} - -/// Special uri with pattern `local://{room_id}/{member_id}/{endpoint_id}`. -#[derive(Clone, Debug)] -pub struct SrcUri { - /// ID of [`Room`] - pub room_id: RoomId, - /// ID of `Member` - pub member_id: MemberId, - /// Control ID of [`Endpoint`] - pub endpoint_id: WebRtcPublishId, -} - -// TODO -#[derive(Debug, Fail)] -pub enum SrcParseError { - #[fail(display = "Missing fields {:?} in '{}' local URI.", _1, _0)] - MissingField(String, Vec), - #[fail(display = "Local URI '{}' parse error: {:?}", _0, _1)] - LocalUriParseError(String, LocalUriParseError), -} - -impl SrcUri { - pub fn parse(value: &str) -> Result { - let local_uri = LocalUri::parse(value).map_err(|e| { - SrcParseError::LocalUriParseError(value.to_string(), e) - })?; - - let mut missing_fields = Vec::new(); - if local_uri.room_id.is_none() { - missing_fields.push("room_id".to_string()); - } - if local_uri.member_id.is_none() { - missing_fields.push("member_id".to_string()); - } - if local_uri.endpoint_id.is_none() { - missing_fields.push("endpoint_id".to_string()); - } - - if !missing_fields.is_empty() { - return Err(SrcParseError::MissingField( - value.to_string(), - missing_fields, - )); - } else { - Ok(Self { - room_id: local_uri.room_id.unwrap(), - member_id: local_uri.member_id.unwrap(), - endpoint_id: WebRtcPublishId(local_uri.endpoint_id.unwrap()), - }) - } - } -} - -/// Serde deserializer for [`SrcUri`]. -/// Deserialize URIs with pattern `local://{room_id}/{member_id}/{endpoint_id}`. -impl<'de> Deserialize<'de> for SrcUri { - fn deserialize(deserializer: D) -> Result - where - D: Deserializer<'de>, - { - struct SrcUriVisitor; - - impl<'de> Visitor<'de> for SrcUriVisitor { - type Value = SrcUri; - - fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str( - "Uri in format local://room_id/member_id/endpoint_id", - ) - } - - fn visit_str(self, value: &str) -> Result - where - E: de::Error, - { - match SrcUri::parse(value) { - Ok(src_uri) => Ok(src_uri), - Err(e) => Err(Error::custom(e)), - } - } - } - - deserializer.deserialize_identifier(SrcUriVisitor) - } -} - -#[cfg(test)] -mod src_uri_deserialization_tests { - use serde::Deserialize; - - use super::*; - - #[derive(Deserialize)] - struct SrcUriTest { - src: SrcUri, - } - - #[inline] - fn id>(s: &str) -> T { - T::from(s.to_string()) - } - - #[test] - fn deserialize() { - let valid_json_uri = - r#"{ "src": "local://room_id/member_id/endpoint_id" }"#; - let local_uri: SrcUriTest = - serde_json::from_str(valid_json_uri).unwrap(); - - assert_eq!(local_uri.src.member_id, id("member_id")); - assert_eq!(local_uri.src.room_id, id("room_id")); - assert_eq!(local_uri.src.endpoint_id, id("endpoint_id")); - } - - #[test] - fn return_error_when_uri_not_local() { - let invalid_json_uri = - r#"{ "src": "not_local://room_id/member_id/endpoint_id" }"#; - match serde_json::from_str::(invalid_json_uri) { - Ok(_) => assert!(false), - Err(_) => assert!(true), - } - } - - #[test] - fn return_error_when_uri_is_not_full() { - let invalid_json_uri = r#"{ "src": "local://room_id/member_id" }"#; - match serde_json::from_str::(invalid_json_uri) { - Ok(_) => assert!(false), - Err(_) => assert!(true), - } - } - - #[test] - fn return_error_when_uri_have_empty_part() { - let invalid_json_uri = r#"{ "src": "local://room_id//endpoint_id" }"#; - match serde_json::from_str::(invalid_json_uri) { - Ok(_) => assert!(false), - Err(_) => assert!(true), - } - } -} From 7950c013b0dc5ea29508eba64f1353e796cbf0a6 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 9 Jul 2019 12:28:02 +0300 Subject: [PATCH 289/735] Add simple error returning, minor refactor create room --- src/api/control/grpc/server.rs | 152 +++++++++++++++++++++++++-------- 1 file changed, 118 insertions(+), 34 deletions(-) diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index 79c3e4243..08a74c913 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -1,6 +1,7 @@ use std::{collections::HashMap, sync::Arc}; use actix::{Actor, Addr, Arbiter, Context}; +use failure::Fail; use futures::future::{Either, Future}; use grpcio::{Environment, RpcContext, Server, ServerBuilder, UnarySink}; @@ -10,41 +11,72 @@ use crate::{ ApplyRequest, CreateRequest, Error, GetResponse, IdRequest, Response, }, - local_uri::LocalUri, - RoomSpec, + local_uri::{LocalUri, LocalUriParseError}, + RoomSpec, TryFromElementError, TryFromProtobufError, }, log::prelude::*, - signalling::room_repo::{ - DeleteEndpointFromMember, DeleteMemberFromRoom, DeleteRoom, - RoomsRepository, StartRoom, + signalling::{ + room::RoomError, + room_repo::{ + DeleteEndpointFromMember, DeleteMemberFromRoom, DeleteRoom, + RoomsRepository, StartRoom, + }, }, App, }; use super::protos::control_grpc::{create_control_api, ControlApi}; +#[derive(Debug, Fail)] +enum ControlApiError { + #[fail(display = "{:?}", _0)] + LocalUri(LocalUriParseError), + #[fail(display = "{:?}", _0)] + TryFromProtobuf(TryFromProtobufError), + #[fail(display = "{:?}", _0)] + TryFromElement(TryFromElementError), +} + +impl From for ControlApiError { + fn from(from: LocalUriParseError) -> Self { + ControlApiError::LocalUri(from) + } +} + +impl From for ControlApiError { + fn from(from: TryFromProtobufError) -> Self { + ControlApiError::TryFromProtobuf(from) + } +} + +impl From for ControlApiError { + fn from(from: TryFromElementError) -> Self { + ControlApiError::TryFromElement(from) + } +} + #[derive(Clone)] struct ControlApiService { room_repository: Addr, app: Arc, } -impl ControlApi for ControlApiService { - fn create( +impl ControlApiService { + pub fn create_room( &mut self, - ctx: RpcContext, req: CreateRequest, - sink: UnarySink, - ) { - let local_uri = LocalUri::parse(req.get_id()).unwrap(); + ) -> Result< + impl Future, Error = ()>, + ControlApiError, + > { + let local_uri = LocalUri::parse(req.get_id())?; let room_id = local_uri.room_id.unwrap(); - let room = RoomSpec::try_from_protobuf(room_id.clone(), req.get_room()) - .unwrap(); + let room = + RoomSpec::try_from_protobuf(room_id.clone(), req.get_room())?; let sid: HashMap = room - .members() - .unwrap() + .members()? .iter() .map(|(id, member)| { let addr = &self.app.config.server.bind_ip; @@ -63,27 +95,79 @@ impl ControlApi for ControlApiService { }) .collect(); - ctx.spawn( - self.room_repository - .send(StartRoom(room_id, room)) - .map_err(|e| error!("Start room mailbox error. {:?}", e)) - .and_then(move |r| { - if r.is_ok() { - let mut res = Response::new(); - res.set_sid(sid); - Either::A(sink.success(res).map_err(|_| ())) - } else { - let mut res = Response::new(); - let mut error = Error::new(); - error.set_status(500); - error.set_code(500); - error.set_text(String::new()); + // TODO: errors from `SendRoom` not bubbled up. + Ok(self + .room_repository + .send(StartRoom(room_id, room)) + .map_err(|e| error!("Start room mailbox error. {:?}", e)) + .map(move |_| sid)) + } +} + +impl ControlApi for ControlApiService { + fn create( + &mut self, + ctx: RpcContext, + req: CreateRequest, + sink: UnarySink, + ) { + let local_uri = LocalUri::parse(req.get_id()).unwrap(); + + let create = { + if local_uri.is_room_uri() { + self.create_room(req) + } else { + unimplemented!() + } + }; + + match create { + Ok(fut) => ctx.spawn(fut.and_then(move |r| { + let mut response = Response::new(); + response.set_sid(r); + sink.success(response).map_err(|_| ()) + })), + Err(e) => { + let mut res = Response::new(); + let mut error = Error::new(); + + match e { + ControlApiError::TryFromProtobuf(e) => match e { + TryFromProtobufError::MemberElementNotFound + | TryFromProtobufError::MemberCredentialsNotFound + | TryFromProtobufError::P2pModeNotFound + | TryFromProtobufError::SrcUriNotFound + | TryFromProtobufError::RoomElementNotFound => { + error.set_status(404); + error.set_code(0); + error.set_text(e.to_string()); + error.set_element(String::new()); + } + TryFromProtobufError::SrcUriError(e) => { + error.set_status(400); + error.set_code(0); + error.set_text(e.to_string()); + error.set_element(String::new()); + } + }, + ControlApiError::TryFromElement(e) => { + error.set_status(400); + error.set_code(0); + error.set_text(e.to_string()); error.set_element(String::new()); - res.set_error(error); - Either::B(sink.success(res).map_err(|_| ())) } - }), - ); + ControlApiError::LocalUri(e) => { + error.set_status(400); + error.set_code(0); + error.set_text(e.to_string()); + error.set_element(String::new()); + } + } + + res.set_error(error); + ctx.spawn(sink.success(res).map_err(|_| ())); + } + } } fn apply( From 58313bfb2567b6f60ddbeadfd18c49cd8f12e154 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 9 Jul 2019 13:14:51 +0300 Subject: [PATCH 290/735] Add protobuf serialization --- .../control/endpoints/webrtc_play_endpoint.rs | 28 ++++++++++++------ .../endpoints/webrtc_publish_endpoint.rs | 10 +++++++ .../endpoints/webrtc/play_endpoint.rs | 19 ++++++++++-- .../endpoints/webrtc/publish_endpoint.rs | 24 +++++++++++++-- src/signalling/elements/member.rs | 29 +++++++++++++++++++ src/signalling/participants.rs | 4 +++ src/signalling/room.rs | 22 ++++++++++++++ 7 files changed, 123 insertions(+), 13 deletions(-) diff --git a/src/api/control/endpoints/webrtc_play_endpoint.rs b/src/api/control/endpoints/webrtc_play_endpoint.rs index 408744395..0d72ac38d 100644 --- a/src/api/control/endpoints/webrtc_play_endpoint.rs +++ b/src/api/control/endpoints/webrtc_play_endpoint.rs @@ -52,6 +52,15 @@ impl TryFrom<&WebRtcPlayEndpointProto> for WebRtcPlayEndpoint { } } +// TODO +#[derive(Debug, Fail)] +pub enum SrcParseError { + #[fail(display = "Missing fields {:?} in '{}' local URI.", _1, _0)] + MissingField(String, Vec), + #[fail(display = "Local URI '{}' parse error: {:?}", _0, _1)] + LocalUriParseError(String, LocalUriParseError), +} + /// Special uri with pattern `local://{room_id}/{member_id}/{endpoint_id}`. #[derive(Clone, Debug)] pub struct SrcUri { @@ -63,15 +72,6 @@ pub struct SrcUri { pub endpoint_id: WebRtcPublishId, } -// TODO -#[derive(Debug, Fail)] -pub enum SrcParseError { - #[fail(display = "Missing fields {:?} in '{}' local URI.", _1, _0)] - MissingField(String, Vec), - #[fail(display = "Local URI '{}' parse error: {:?}", _0, _1)] - LocalUriParseError(String, LocalUriParseError), -} - impl SrcUri { pub fn parse(value: &str) -> Result { let local_uri = LocalUri::parse(value).map_err(|e| { @@ -136,3 +136,13 @@ impl<'de> Deserialize<'de> for SrcUri { deserializer.deserialize_identifier(SrcUriVisitor) } } + +impl fmt::Display for SrcUri { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!( + f, + "local://{}/{}/{}", + self.room_id, self.member_id, self.endpoint_id + ) + } +} diff --git a/src/api/control/endpoints/webrtc_publish_endpoint.rs b/src/api/control/endpoints/webrtc_publish_endpoint.rs index 6814826a0..3241b9d50 100644 --- a/src/api/control/endpoints/webrtc_publish_endpoint.rs +++ b/src/api/control/endpoints/webrtc_publish_endpoint.rs @@ -51,6 +51,16 @@ impl TryFrom for P2pMode { } } +impl Into for P2pMode { + fn into(self) -> WebRtcPublishEndpointP2pProto { + match self { + P2pMode::Always => WebRtcPublishEndpointP2pProto::ALWAYS, + P2pMode::IfPossible => WebRtcPublishEndpointP2pProto::IF_POSSIBLE, + P2pMode::Never => WebRtcPublishEndpointP2pProto::NEVER, + } + } +} + /// Media element which is able to publish media data for another client via /// WebRTC. #[allow(clippy::module_name_repetitions)] diff --git a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs index 40c531367..c6c99b6be 100644 --- a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs @@ -6,8 +6,12 @@ use std::{ }; use crate::{ - api::control::endpoints::webrtc_play_endpoint::{ - SrcUri, WebRtcPlayId as Id, + api::control::{ + endpoints::webrtc_play_endpoint::{SrcUri, WebRtcPlayId as Id}, + grpc::protos::control::{ + Member_Element as ElementProto, + WebRtcPlayEndpoint as WebRtcPlayEndpointProto, + }, }, media::PeerId, signalling::elements::Member, @@ -157,3 +161,14 @@ impl WebRtcPlayEndpoint { self.0.borrow().id.clone() } } + +impl Into for Rc { + fn into(self) -> ElementProto { + let mut element = ElementProto::new(); + let mut play = WebRtcPlayEndpointProto::new(); + play.set_src(self.src_uri().to_string()); + element.set_webrtc_play(play); + + element + } +} diff --git a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs index c9a5059ea..7c641bbc9 100644 --- a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs @@ -8,8 +8,13 @@ use std::{ use hashbrown::HashSet; use crate::{ - api::control::endpoints::webrtc_publish_endpoint::{ - P2pMode, WebRtcPublishId as Id, + api::control::{ + endpoints::webrtc_publish_endpoint::{P2pMode, WebRtcPublishId as Id}, + grpc::protos::control::{ + Member_Element as ElementProto, + WebRtcPublishEndpoint as WebRtcPublishEndpointProto, + WebRtcPublishEndpoint_P2P as WebRtcPublishEndpointP2pProto, + }, }, media::PeerId, signalling::elements::Member, @@ -168,4 +173,19 @@ impl WebRtcPublishEndpoint { pub fn remove_empty_weaks_from_sinks(&self) { self.0.borrow_mut().sinks.retain(|e| e.upgrade().is_some()); } + + pub fn p2p(&self) -> P2pMode { + self.0.borrow().p2p.clone() + } +} + +impl Into for Rc { + fn into(self) -> ElementProto { + let mut element = ElementProto::new(); + let mut publish = WebRtcPublishEndpointProto::new(); + publish.set_p2p(self.p2p().into()); + element.set_webrtc_pub(publish); + + element + } } diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index da4735ba7..f1394cb56 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -1,6 +1,7 @@ //! [`Member`] is member of [`Room`] with [`RpcConnection`]. use std::{cell::RefCell, convert::TryFrom as _, rc::Rc}; +use std::collections::HashMap as StdHashMap; use failure::Fail; use hashbrown::HashMap; @@ -8,6 +9,9 @@ use medea_client_api_proto::IceServer; use crate::{ api::control::{ + grpc::protos::control::{ + Member as MemberProto, Room_Element as ElementProto, + }, MemberId, MemberSpec, RoomSpec, TryFromElementError, WebRtcPlayId, WebRtcPublishId, }, @@ -16,6 +20,7 @@ use crate::{ }; use super::endpoints::webrtc::{WebRtcPlayEndpoint, WebRtcPublishEndpoint}; +use crate::api::control::grpc::protos::control::Member_Element; /// Errors which may occur while loading [`Member`]s from [`RoomSpec`]. #[derive(Debug, Fail)] @@ -330,6 +335,30 @@ pub fn parse_members( Ok(members) } +impl Into for Rc { + fn into(self) -> ElementProto { + let mut element = ElementProto::new(); + let mut member = MemberProto::new(); + + let mut member_pipeline = StdHashMap::new(); + for (id, play) in self.sinks() { + member_pipeline + .insert(id.to_string(), play.into()); + } + for (id, publish) in self.srcs() { + member_pipeline + .insert(id.to_string(), publish.into()); + } + member.set_pipeline(member_pipeline); + + member.set_credentials(self.credentials()); + + element.set_member(member); + + element + } +} + #[cfg(test)] mod tests { use std::rc::Rc; diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index afd336891..1283b9b9b 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -116,6 +116,10 @@ impl ParticipantService { self.members.get(id).cloned() } + pub fn members(&self) -> HashMap> { + self.members.clone() + } + /// Lookup [`Member`] by provided id and credentials. Returns /// [`Err(AuthorizationError::MemberNotExists)`] if lookup by /// [`MemberId`] failed. Returns diff --git a/src/signalling/room.rs b/src/signalling/room.rs index cd9eefe4e..e0b041aa3 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -2,6 +2,7 @@ //! connection establishment between concrete [`Member`]s. use std::{rc::Rc, sync::Arc, time::Duration}; +use std::collections::HashMap as StdHashMap; use actix::{ fut::wrap_future, Actor, ActorFuture, AsyncContext, Context, Handler, @@ -22,6 +23,10 @@ use crate::{ room::RoomSpec, MemberId, RoomId, TryFromElementError, WebRtcPlayId, WebRtcPublishId, }, + control::grpc::protos::control::{ + Element as ElementProto, + Room as RoomProto, + } }, log::prelude::*, media::{ @@ -450,6 +455,23 @@ impl Actor for Room { type Context = Context; } +impl Into for Room { + fn into(self) -> ElementProto { + let mut element = ElementProto::new(); + let mut room = RoomProto::new(); + + let mut pipeline = StdHashMap::new(); + for (id, member) in self.members.members() { + pipeline.insert(id.to_string(), member.into()); + } + room.set_pipeline(pipeline); + + element.set_room(room); + + element + } +} + impl Handler for Room { type Result = Result<(), AuthorizationError>; From 4da21047122c86a02f1eea07a492089ae0ac28ac Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 9 Jul 2019 13:58:54 +0300 Subject: [PATCH 291/735] Add get room --- src/api/control/grpc/server.rs | 23 ++++++++++--- src/bin/client.rs | 9 +++++ src/signalling/elements/member.rs | 12 +++---- src/signalling/room.rs | 35 +++++++++++++++----- src/signalling/room_repo.rs | 55 ++++++++++++++++++++++++++++--- 5 files changed, 110 insertions(+), 24 deletions(-) diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index 08a74c913..4037e9cb0 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -19,7 +19,7 @@ use crate::{ room::RoomError, room_repo::{ DeleteEndpointFromMember, DeleteMemberFromRoom, DeleteRoom, - RoomsRepository, StartRoom, + GetRoom, RoomsRepository, StartRoom, }, }, App, @@ -215,11 +215,24 @@ impl ControlApi for ControlApiService { fn get( &mut self, - _ctx: RpcContext, - _req: IdRequest, - _sink: UnarySink, + ctx: RpcContext, + req: IdRequest, + sink: UnarySink, ) { - unimplemented!() + let local_uri = LocalUri::parse(&req.get_id()[0]).unwrap(); + + ctx.spawn( + self.room_repository + .send(GetRoom(local_uri.room_id.clone().unwrap())) + .map_err(|e| ()) + .and_then(|r| { + let result = r.unwrap(); + let mut response = GetResponse::new(); + response.set_elements(result); + + sink.success(response).map_err(|_| ()) + }), + ); } } diff --git a/src/bin/client.rs b/src/bin/client.rs index 904a3f2ce..38911fe72 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -83,4 +83,13 @@ fn main() { let reply = client.delete(&delete_member_req).expect("delete member"); println!("{:?}", reply); + + // Get room + let mut get_room_request = IdRequest::new(); + let mut room = RepeatedField::new(); + room.push("local://grpc-test".to_string()); + get_room_request.set_id(room); + + let reply = client.get(&get_room_request).expect("get room"); + println!("{:?}", reply); } diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index f1394cb56..fb97c7297 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -1,7 +1,9 @@ //! [`Member`] is member of [`Room`] with [`RpcConnection`]. -use std::{cell::RefCell, convert::TryFrom as _, rc::Rc}; -use std::collections::HashMap as StdHashMap; +use std::{ + cell::RefCell, collections::HashMap as StdHashMap, convert::TryFrom as _, + rc::Rc, +}; use failure::Fail; use hashbrown::HashMap; @@ -342,12 +344,10 @@ impl Into for Rc { let mut member_pipeline = StdHashMap::new(); for (id, play) in self.sinks() { - member_pipeline - .insert(id.to_string(), play.into()); + member_pipeline.insert(id.to_string(), play.into()); } for (id, publish) in self.srcs() { - member_pipeline - .insert(id.to_string(), publish.into()); + member_pipeline.insert(id.to_string(), publish.into()); } member.set_pipeline(member_pipeline); diff --git a/src/signalling/room.rs b/src/signalling/room.rs index e0b041aa3..b1299a64b 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -1,8 +1,9 @@ //! Room definitions and implementations. Room is responsible for media //! connection establishment between concrete [`Member`]s. -use std::{rc::Rc, sync::Arc, time::Duration}; -use std::collections::HashMap as StdHashMap; +use std::{ + collections::HashMap as StdHashMap, rc::Rc, sync::Arc, time::Duration, +}; use actix::{ fut::wrap_future, Actor, ActorFuture, AsyncContext, Context, Handler, @@ -20,13 +21,13 @@ use crate::{ RpcConnectionClosed, RpcConnectionEstablished, }, control::{ - room::RoomSpec, MemberId, RoomId, TryFromElementError, - WebRtcPlayId, WebRtcPublishId, + grpc::protos::control::{ + Element as ElementProto, Room as RoomProto, + }, + room::RoomSpec, + MemberId, RoomId, TryFromElementError, WebRtcPlayId, + WebRtcPublishId, }, - control::grpc::protos::control::{ - Element as ElementProto, - Room as RoomProto, - } }, log::prelude::*, media::{ @@ -455,7 +456,7 @@ impl Actor for Room { type Context = Context; } -impl Into for Room { +impl Into for &mut Room { fn into(self) -> ElementProto { let mut element = ElementProto::new(); let mut room = RoomProto::new(); @@ -472,6 +473,22 @@ impl Into for Room { } } +#[derive(Message)] +#[rtype(result = "Result")] +pub struct Serialize; + +impl Handler for Room { + type Result = Result; + + fn handle( + &mut self, + msg: Serialize, + ctx: &mut Self::Context, + ) -> Self::Result { + Ok(self.into()) + } +} + impl Handler for Room { type Result = Result<(), AuthorizationError>; diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs index 3bec25bdd..7a039a127 100644 --- a/src/signalling/room_repo.rs +++ b/src/signalling/room_repo.rs @@ -1,24 +1,37 @@ //! Repository that stores [`Room`]s addresses. -use std::sync::{Arc, Mutex}; +use std::{ + collections::HashMap as StdHashMap, + sync::{Arc, Mutex}, +}; -use actix::{Actor, Addr, Context, Handler, Message}; +use actix::{Actor, ActorFuture, Addr, Context, Handler, Message}; use failure::Fail; use hashbrown::HashMap; use crate::{ - api::control::{room::RoomSpec, MemberId, RoomId}, + api::control::{ + grpc::protos::control::Element as ElementProto, room::RoomSpec, + MemberId, RoomId, + }, signalling::{ - room::{CloseRoom, DeleteEndpoint, DeleteMember, RoomError}, + room::{CloseRoom, DeleteEndpoint, DeleteMember, RoomError, Serialize}, Room, }, App, }; +use actix::fut::wrap_future; +use futures::future::{Either, Future}; + +type ActFuture = + Box>; #[derive(Debug, Fail)] pub enum RoomRepoError { #[fail(display = "Room with id {} not found.", _0)] RoomNotFound(RoomId), + #[fail(display = "Unknow error.")] + Unknow, } /// Repository that stores [`Room`]s addresses. @@ -165,3 +178,37 @@ impl Handler for RoomsRepository { Ok(()) } } + +#[derive(Message)] +#[rtype(result = "Result, RoomRepoError>")] +pub struct GetRoom(pub RoomId); + +impl Handler for RoomsRepository { + type Result = ActFuture, RoomRepoError>; + + fn handle( + &mut self, + msg: GetRoom, + ctx: &mut Self::Context, + ) -> Self::Result { + let fut = { + if let Some(room) = self.rooms.lock().unwrap().get(&msg.0) { + Either::A( + room.send(Serialize) + .map_err(|_| RoomRepoError::Unknow) + .map(move |r| { + let mut ee = StdHashMap::new(); + ee.insert(msg.0.to_string(), r.unwrap()); // TODO + ee + }), + ) + } else { + Either::B(futures::future::err(RoomRepoError::RoomNotFound( + msg.0, + ))) + } + }; + + Box::new(wrap_future(fut)) + } +} From 869e9b842d427bda7bd8534917c969f605cf088d Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 9 Jul 2019 14:11:36 +0300 Subject: [PATCH 292/735] Get many rooms --- src/api/control/grpc/server.rs | 14 +++++++++++--- src/bin/client.rs | 1 + src/signalling/room_repo.rs | 30 ++++++++++++++---------------- 3 files changed, 26 insertions(+), 19 deletions(-) diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index 4037e9cb0..b5ee0eca4 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -219,16 +219,24 @@ impl ControlApi for ControlApiService { req: IdRequest, sink: UnarySink, ) { - let local_uri = LocalUri::parse(&req.get_id()[0]).unwrap(); + let mut room_ids = Vec::new(); + + for uri in req.get_id() { + let local_uri = LocalUri::parse(uri).unwrap(); + room_ids.push(local_uri.room_id.unwrap()); + } ctx.spawn( self.room_repository - .send(GetRoom(local_uri.room_id.clone().unwrap())) + .send(GetRoom(room_ids)) .map_err(|e| ()) .and_then(|r| { let result = r.unwrap(); + + let elements = result.into_iter().collect(); + let mut response = GetResponse::new(); - response.set_elements(result); + response.set_elements(elements); sink.success(response).map_err(|_| ()) }), diff --git a/src/bin/client.rs b/src/bin/client.rs index 38911fe72..e191c2fd3 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -88,6 +88,7 @@ fn main() { let mut get_room_request = IdRequest::new(); let mut room = RepeatedField::new(); room.push("local://grpc-test".to_string()); + room.push("local://video-call-1".to_string()); get_room_request.set_id(room); let reply = client.get(&get_room_request).expect("get room"); diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs index 7a039a127..84f482adb 100644 --- a/src/signalling/room_repo.rs +++ b/src/signalling/room_repo.rs @@ -180,35 +180,33 @@ impl Handler for RoomsRepository { } #[derive(Message)] -#[rtype(result = "Result, RoomRepoError>")] -pub struct GetRoom(pub RoomId); +#[rtype(result = "Result, RoomRepoError>")] +pub struct GetRoom(pub Vec); impl Handler for RoomsRepository { - type Result = ActFuture, RoomRepoError>; + type Result = ActFuture, RoomRepoError>; fn handle( &mut self, msg: GetRoom, ctx: &mut Self::Context, ) -> Self::Result { - let fut = { - if let Some(room) = self.rooms.lock().unwrap().get(&msg.0) { - Either::A( + let mut futs = Vec::new(); + + for room_id in msg.0 { + if let Some(room) = self.rooms.lock().unwrap().get(&room_id) { + futs.push( room.send(Serialize) .map_err(|_| RoomRepoError::Unknow) - .map(move |r| { - let mut ee = StdHashMap::new(); - ee.insert(msg.0.to_string(), r.unwrap()); // TODO - ee - }), + .map(move |r| (room_id.to_string(), r.unwrap())), ) } else { - Either::B(futures::future::err(RoomRepoError::RoomNotFound( - msg.0, - ))) + return Box::new(wrap_future(futures::future::err( + RoomRepoError::RoomNotFound(room_id), + ))); } - }; + } - Box::new(wrap_future(fut)) + Box::new(wrap_future(futures::future::join_all(futs))) } } From 5cafe794c78d58d2c059cb8d523c83cea850935d Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 9 Jul 2019 14:45:50 +0300 Subject: [PATCH 293/735] Return LocalUri in get Room --- src/api/control/local_uri.rs | 20 ++++++++++++++++ src/signalling/elements/member.rs | 38 +++++++++++++++++++++++++------ src/signalling/room.rs | 9 +++++++- src/signalling/room_repo.rs | 13 ++++++++--- 4 files changed, 69 insertions(+), 11 deletions(-) diff --git a/src/api/control/local_uri.rs b/src/api/control/local_uri.rs index ac290d713..1287e85fe 100644 --- a/src/api/control/local_uri.rs +++ b/src/api/control/local_uri.rs @@ -1,6 +1,9 @@ +use std::fmt; + use failure::Fail; use super::{MemberId, RoomId}; +use crate::api::control::endpoints::webrtc_play_endpoint::SrcUri; #[derive(Debug, Fail)] pub enum LocalUriParseError { @@ -74,3 +77,20 @@ impl LocalUri { && self.endpoint_id.is_some() } } + +impl fmt::Display for LocalUri { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "local://")?; + if let Some(room_id) = &self.room_id { + write!(f, "{}", room_id)?; + if let Some(member_id) = &self.member_id { + write!(f, "/{}", member_id)?; + if let Some(endpoint_id) = &self.endpoint_id { + write!(f, "/{}", endpoint_id)? + } + } + } + + Ok(()) + } +} diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index fb97c7297..fcd010e9f 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -14,15 +14,17 @@ use crate::{ grpc::protos::control::{ Member as MemberProto, Room_Element as ElementProto, }, - MemberId, MemberSpec, RoomSpec, TryFromElementError, WebRtcPlayId, - WebRtcPublishId, + MemberId, MemberSpec, RoomId, RoomSpec, TryFromElementError, + WebRtcPlayId, WebRtcPublishId, }, log::prelude::*, media::{IceUser, PeerId}, }; use super::endpoints::webrtc::{WebRtcPlayEndpoint, WebRtcPublishEndpoint}; -use crate::api::control::grpc::protos::control::Member_Element; +use crate::api::control::{ + grpc::protos::control::Member_Element, local_uri::LocalUri, +}; /// Errors which may occur while loading [`Member`]s from [`RoomSpec`]. #[derive(Debug, Fail)] @@ -53,6 +55,8 @@ pub struct Member(RefCell); #[allow(clippy::module_name_repetitions)] #[derive(Debug)] struct MemberInner { + room_id: RoomId, + id: MemberId, /// All [`WebRtcPublishEndpoint`]s of this [`Member`]. @@ -73,13 +77,14 @@ impl Member { /// /// To fill this [`Member`], you need to call the [`Member::load`] /// function. - fn new(id: MemberId, credentials: String) -> Self { + fn new(id: MemberId, credentials: String, room_id: RoomId) -> Self { Self(RefCell::new(MemberInner { id, srcs: HashMap::new(), sinks: HashMap::new(), credentials, ice_user: None, + room_id, })) } @@ -290,6 +295,10 @@ impl Member { ) -> Option> { self.0.borrow_mut().srcs.remove(id) } + + pub fn room_id(&self) -> RoomId { + self.0.borrow().room_id.clone() + } } /// Creates all empty [`Member`] from [`RoomSpec`] and then @@ -305,7 +314,11 @@ pub fn parse_members( for (id, member) in &members_spec { members.insert( id.clone(), - Rc::new(Member::new(id.clone(), member.credentials().to_string())), + Rc::new(Member::new( + id.clone(), + member.credentials().to_string(), + room_spec.id.clone(), + )), ); } @@ -344,10 +357,21 @@ impl Into for Rc { let mut member_pipeline = StdHashMap::new(); for (id, play) in self.sinks() { - member_pipeline.insert(id.to_string(), play.into()); + let local_uri = LocalUri { + room_id: Some(self.room_id()), + member_id: Some(self.id()), + endpoint_id: Some(id.to_string()), + }; + member_pipeline.insert(local_uri.to_string(), play.into()); } for (id, publish) in self.srcs() { - member_pipeline.insert(id.to_string(), publish.into()); + let local_uri = LocalUri { + room_id: Some(self.room_id()), + member_id: Some(self.id()), + endpoint_id: Some(id.to_string()), + }; + + member_pipeline.insert(local_uri.to_string(), publish.into()); } member.set_pipeline(member_pipeline); diff --git a/src/signalling/room.rs b/src/signalling/room.rs index b1299a64b..741e9cd2f 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -24,6 +24,7 @@ use crate::{ grpc::protos::control::{ Element as ElementProto, Room as RoomProto, }, + local_uri::LocalUri, room::RoomSpec, MemberId, RoomId, TryFromElementError, WebRtcPlayId, WebRtcPublishId, @@ -463,7 +464,13 @@ impl Into for &mut Room { let mut pipeline = StdHashMap::new(); for (id, member) in self.members.members() { - pipeline.insert(id.to_string(), member.into()); + let local_uri = LocalUri { + room_id: Some(self.get_id()), + member_id: Some(id), + endpoint_id: None, + }; + + pipeline.insert(local_uri.to_string(), member.into()); } room.set_pipeline(pipeline); diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs index 84f482adb..88d184b3f 100644 --- a/src/signalling/room_repo.rs +++ b/src/signalling/room_repo.rs @@ -11,8 +11,8 @@ use hashbrown::HashMap; use crate::{ api::control::{ - grpc::protos::control::Element as ElementProto, room::RoomSpec, - MemberId, RoomId, + grpc::protos::control::Element as ElementProto, local_uri::LocalUri, + room::RoomSpec, MemberId, RoomId, }, signalling::{ room::{CloseRoom, DeleteEndpoint, DeleteMember, RoomError, Serialize}, @@ -198,7 +198,14 @@ impl Handler for RoomsRepository { futs.push( room.send(Serialize) .map_err(|_| RoomRepoError::Unknow) - .map(move |r| (room_id.to_string(), r.unwrap())), + .map(move |r| { + let local_uri = LocalUri { + room_id: Some(room_id), + member_id: None, + endpoint_id: None, + }; + (local_uri.to_string(), r.unwrap()) + }), ) } else { return Box::new(wrap_future(futures::future::err( From bbbdde967ed44979c92ba0d628113e7392f650d8 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 9 Jul 2019 15:09:10 +0300 Subject: [PATCH 294/735] Add get member --- src/api/control/grpc/server.rs | 8 +++++-- src/bin/client.rs | 4 ++-- src/signalling/room.rs | 26 +++++++++++++++++++- src/signalling/room_repo.rs | 44 +++++++++++++++++++++++++++++++++- 4 files changed, 76 insertions(+), 6 deletions(-) diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index b5ee0eca4..c0931dcb5 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -26,6 +26,7 @@ use crate::{ }; use super::protos::control_grpc::{create_control_api, ControlApi}; +use crate::signalling::room_repo::GetMember; #[derive(Debug, Fail)] enum ControlApiError { @@ -223,12 +224,15 @@ impl ControlApi for ControlApiService { for uri in req.get_id() { let local_uri = LocalUri::parse(uri).unwrap(); - room_ids.push(local_uri.room_id.unwrap()); + room_ids.push(( + local_uri.room_id.unwrap(), + local_uri.member_id.unwrap(), + )); } ctx.spawn( self.room_repository - .send(GetRoom(room_ids)) + .send(GetMember(room_ids)) .map_err(|e| ()) .and_then(|r| { let result = r.unwrap(); diff --git a/src/bin/client.rs b/src/bin/client.rs index e191c2fd3..971a78102 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -87,8 +87,8 @@ fn main() { // Get room let mut get_room_request = IdRequest::new(); let mut room = RepeatedField::new(); - room.push("local://grpc-test".to_string()); - room.push("local://video-call-1".to_string()); + room.push("local://grpc-test/publisher".to_string()); + room.push("local://video-call-1/responder".to_string()); get_room_request.set_id(room); let reply = client.get(&get_room_request).expect("get room"); diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 741e9cd2f..056a951d1 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -22,7 +22,8 @@ use crate::{ }, control::{ grpc::protos::control::{ - Element as ElementProto, Room as RoomProto, + Element as ElementProto, Member_Element, Room as RoomProto, + Room_Element, }, local_uri::LocalUri, room::RoomSpec, @@ -496,6 +497,29 @@ impl Handler for Room { } } +#[derive(Message)] +#[rtype(result = "Result")] +pub struct SerializeMember(pub MemberId); + +impl Handler for Room { + type Result = Result; + + fn handle( + &mut self, + msg: SerializeMember, + ctx: &mut Self::Context, + ) -> Self::Result { + let member = self.members.get_member_by_id(&msg.0).unwrap(); // TODO + let mut member_element: Room_Element = member.into(); + let member = member_element.take_member(); + + let mut element = ElementProto::new(); + element.set_member(member); + + Ok(element) + } +} + impl Handler for Room { type Result = Result<(), AuthorizationError>; diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs index 88d184b3f..6528b5e6c 100644 --- a/src/signalling/room_repo.rs +++ b/src/signalling/room_repo.rs @@ -15,7 +15,10 @@ use crate::{ room::RoomSpec, MemberId, RoomId, }, signalling::{ - room::{CloseRoom, DeleteEndpoint, DeleteMember, RoomError, Serialize}, + room::{ + CloseRoom, DeleteEndpoint, DeleteMember, RoomError, Serialize, + SerializeMember, + }, Room, }, App, @@ -217,3 +220,42 @@ impl Handler for RoomsRepository { Box::new(wrap_future(futures::future::join_all(futs))) } } + +#[derive(Message)] +#[rtype(result = "Result, RoomRepoError>")] +pub struct GetMember(pub Vec<(RoomId, MemberId)>); + +impl Handler for RoomsRepository { + type Result = ActFuture, RoomRepoError>; + + fn handle( + &mut self, + msg: GetMember, + ctx: &mut Self::Context, + ) -> Self::Result { + let mut futs = Vec::new(); + + for (room_id, member_id) in msg.0 { + if let Some(room) = self.rooms.lock().unwrap().get(&room_id) { + futs.push( + room.send(SerializeMember(member_id.clone())) + .map_err(|_| RoomRepoError::Unknow) + .map(|r| { + let local_uri = LocalUri { + room_id: Some(room_id), + member_id: Some(member_id), + endpoint_id: None, + }; + (local_uri.to_string(), r.unwrap()) + }), + ) + } else { + return Box::new(wrap_future(futures::future::err( + RoomRepoError::RoomNotFound(room_id), + ))); + } + } + + Box::new(wrap_future(futures::future::join_all(futs))) + } +} From 9c1e8d193c14d27b5a529f0b937437ef21cdf1d6 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 9 Jul 2019 15:32:23 +0300 Subject: [PATCH 295/735] Get member and room at same moment --- src/api/control/grpc/server.rs | 50 ++++++++++++++++++++++------------ src/bin/client.rs | 2 +- 2 files changed, 34 insertions(+), 18 deletions(-) diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index c0931dcb5..3e52ad25c 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -2,7 +2,7 @@ use std::{collections::HashMap, sync::Arc}; use actix::{Actor, Addr, Arbiter, Context}; use failure::Fail; -use futures::future::{Either, Future}; +use futures::future::{Either, Future, IntoFuture}; use grpcio::{Environment, RpcContext, Server, ServerBuilder, UnarySink}; use crate::{ @@ -221,30 +221,46 @@ impl ControlApi for ControlApiService { sink: UnarySink, ) { let mut room_ids = Vec::new(); + let mut member_ids = Vec::new(); + let mut endpoint_ids = Vec::new(); for uri in req.get_id() { let local_uri = LocalUri::parse(uri).unwrap(); - room_ids.push(( - local_uri.room_id.unwrap(), - local_uri.member_id.unwrap(), - )); - } - ctx.spawn( - self.room_repository - .send(GetMember(room_ids)) - .map_err(|e| ()) - .and_then(|r| { - let result = r.unwrap(); + if local_uri.is_room_uri() { + room_ids.push(local_uri.room_id.unwrap()); + } else if local_uri.is_member_uri() { + member_ids.push(( + local_uri.room_id.unwrap(), + local_uri.member_id.unwrap(), + )); + } else if local_uri.is_endpoint_uri() { + endpoint_ids.push(( + local_uri.room_id.unwrap(), + local_uri.member_id.unwrap(), + local_uri.endpoint_id.unwrap(), + )); + } + } - let elements = result.into_iter().collect(); + let room_fut = self.room_repository.send(GetRoom(room_ids)); + let member_fut = self.room_repository.send(GetMember(member_ids)); - let mut response = GetResponse::new(); - response.set_elements(elements); + let mega_future = room_fut.join(member_fut).map_err(|_| ()).and_then( + |(room, member)| { + let elements = room + .unwrap() + .into_iter() + .chain(member.unwrap().into_iter()) + .collect(); + let mut response = GetResponse::new(); + response.set_elements(elements); - sink.success(response).map_err(|_| ()) - }), + sink.success(response).map_err(|_| ()) + }, ); + + ctx.spawn(mega_future); } } diff --git a/src/bin/client.rs b/src/bin/client.rs index 971a78102..710396272 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -87,7 +87,7 @@ fn main() { // Get room let mut get_room_request = IdRequest::new(); let mut room = RepeatedField::new(); - room.push("local://grpc-test/publisher".to_string()); + room.push("local://grpc-test".to_string()); room.push("local://video-call-1/responder".to_string()); get_room_request.set_id(room); From 217db6274a9001ff6b5e3386b627a146d07233ce Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 9 Jul 2019 15:53:43 +0300 Subject: [PATCH 296/735] Add Get endpoint --- src/api/control/grpc/server.rs | 13 ++++++---- src/bin/client.rs | 3 ++- src/signalling/room.rs | 36 ++++++++++++++++++++++++++++ src/signalling/room_repo.rs | 44 +++++++++++++++++++++++++++++++++- 4 files changed, 89 insertions(+), 7 deletions(-) diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index 3e52ad25c..b42e24796 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -26,7 +26,7 @@ use crate::{ }; use super::protos::control_grpc::{create_control_api, ControlApi}; -use crate::signalling::room_repo::GetMember; +use crate::signalling::room_repo::{GetEndpoint, GetMember}; #[derive(Debug, Fail)] enum ControlApiError { @@ -245,20 +245,23 @@ impl ControlApi for ControlApiService { let room_fut = self.room_repository.send(GetRoom(room_ids)); let member_fut = self.room_repository.send(GetMember(member_ids)); + let endpoint_fut = self.room_repository.send(GetEndpoint(endpoint_ids)); - let mega_future = room_fut.join(member_fut).map_err(|_| ()).and_then( - |(room, member)| { + let mega_future = room_fut + .join3(member_fut, endpoint_fut) + .map_err(|_| ()) + .and_then(|(room, member, endpoint)| { let elements = room .unwrap() .into_iter() .chain(member.unwrap().into_iter()) + .chain(endpoint.unwrap().into_iter()) .collect(); let mut response = GetResponse::new(); response.set_elements(elements); sink.success(response).map_err(|_| ()) - }, - ); + }); ctx.spawn(mega_future); } diff --git a/src/bin/client.rs b/src/bin/client.rs index 710396272..7f2b71a4b 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -69,7 +69,7 @@ fn main() { // Delete endpoint let mut delete_endpoint_req = IdRequest::new(); let mut endpoints = RepeatedField::new(); - endpoints.push("local://video-call-1/caller".to_string()); + endpoints.push("local://video-call-1/caller/publish".to_string()); delete_endpoint_req.set_id(endpoints); let reply = client.delete(&delete_endpoint_req).expect("delete member"); @@ -89,6 +89,7 @@ fn main() { let mut room = RepeatedField::new(); room.push("local://grpc-test".to_string()); room.push("local://video-call-1/responder".to_string()); + room.push("local://grpc-test/publisher/publish".to_string()); get_room_request.set_id(room); let reply = client.get(&get_room_request).expect("get room"); diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 056a951d1..26c5cec43 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -520,6 +520,42 @@ impl Handler for Room { } } +#[derive(Message)] +#[rtype(result = "Result")] +pub struct SerializeEndpoint(pub MemberId, pub String); + +impl Handler for Room { + type Result = Result; + + fn handle( + &mut self, + msg: SerializeEndpoint, + ctx: &mut Self::Context, + ) -> Self::Result { + let member = self.members.get_member_by_id(&msg.0).unwrap(); // TODO + let endpoint_id = WebRtcPublishId(msg.1); + let mut element = ElementProto::new(); + + if let Some(endpoint) = member.get_src_by_id(&endpoint_id) { + let mut member_element: Member_Element = endpoint.into(); + let endpoint = member_element.take_webrtc_pub(); + element.set_webrtc_pub(endpoint); + } else { + let endpoint_id = WebRtcPlayId(endpoint_id.0); + + if let Some(endpoint) = member.get_sink_by_id(&endpoint_id) { + let mut member_element: Member_Element = endpoint.into(); + let endpoint = member_element.take_webrtc_play(); + element.set_webrtc_play(endpoint); + } else { + panic!(); // TODO + } + } + + Ok(element) + } +} + impl Handler for Room { type Result = Result<(), AuthorizationError>; diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs index 6528b5e6c..f4ab9d555 100644 --- a/src/signalling/room_repo.rs +++ b/src/signalling/room_repo.rs @@ -17,7 +17,7 @@ use crate::{ signalling::{ room::{ CloseRoom, DeleteEndpoint, DeleteMember, RoomError, Serialize, - SerializeMember, + SerializeEndpoint, SerializeMember, }, Room, }, @@ -259,3 +259,45 @@ impl Handler for RoomsRepository { Box::new(wrap_future(futures::future::join_all(futs))) } } + +#[derive(Message)] +#[rtype(result = "Result, RoomRepoError>")] +pub struct GetEndpoint(pub Vec<(RoomId, MemberId, String)>); + +impl Handler for RoomsRepository { + type Result = ActFuture, RoomRepoError>; + + fn handle( + &mut self, + msg: GetEndpoint, + ctx: &mut Self::Context, + ) -> Self::Result { + let mut futs = Vec::new(); + + for (room_id, member_id, endpoint_id) in msg.0 { + if let Some(room) = self.rooms.lock().unwrap().get(&room_id) { + futs.push( + room.send(SerializeEndpoint( + member_id.clone(), + endpoint_id.clone(), + )) + .map_err(|_| RoomRepoError::Unknow) + .map(|r| { + let local_uri = LocalUri { + room_id: Some(room_id), + member_id: Some(member_id), + endpoint_id: Some(endpoint_id), + }; + (local_uri.to_string(), r.unwrap()) + }), + ); + } else { + return Box::new(wrap_future(futures::future::err( + RoomRepoError::RoomNotFound(room_id), + ))); + } + } + + Box::new(wrap_future(futures::future::join_all(futs))) + } +} From a1452631dceafaefa3bb639540f46fd4ba08a539 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 9 Jul 2019 17:36:43 +0300 Subject: [PATCH 297/735] Error handling for Get --- src/api/control/grpc/server.rs | 35 ++++++++++--- src/bin/client.rs | 2 +- src/signalling/room.rs | 28 +++++++---- src/signalling/room_repo.rs | 91 ++++++++++++++++++++++------------ 4 files changed, 109 insertions(+), 47 deletions(-) diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index b42e24796..2a28da677 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -251,16 +251,39 @@ impl ControlApi for ControlApiService { .join3(member_fut, endpoint_fut) .map_err(|_| ()) .and_then(|(room, member, endpoint)| { - let elements = room - .unwrap() + let mut elements = HashMap::new(); + + let elements_result = room .into_iter() - .chain(member.unwrap().into_iter()) - .chain(endpoint.unwrap().into_iter()) - .collect(); + .chain(member.into_iter()) + .chain(endpoint.into_iter()) + .flat_map(|e| e.into_iter()); + + for element in elements_result { + match element { + Ok((id, o)) => { + elements.insert(id, o); + } + Err(e) => { + let mut error = Error::new(); + error.set_status(500); + error.set_code(500); + error.set_text(String::new()); + error.set_element(String::new()); + let mut response = GetResponse::new(); + response.set_error(error); + + return Either::A( + sink.success(response).map_err(|_| ()), + ); + } + } + } + let mut response = GetResponse::new(); response.set_elements(elements); - sink.success(response).map_err(|_| ()) + Either::B(sink.success(response).map_err(|_| ())) }); ctx.spawn(mega_future); diff --git a/src/bin/client.rs b/src/bin/client.rs index 7f2b71a4b..b12e0932c 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -89,7 +89,7 @@ fn main() { let mut room = RepeatedField::new(); room.push("local://grpc-test".to_string()); room.push("local://video-call-1/responder".to_string()); - room.push("local://grpc-test/publisher/publish".to_string()); + room.push("local://grpc-test/publisher/publih".to_string()); get_room_request.set_id(room); let reply = client.get(&get_room_request).expect("get room"); diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 26c5cec43..899326091 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -58,6 +58,8 @@ pub enum RoomError { PeerNotFound(PeerId), #[fail(display = "Couldn't find Member with [id = {}]", _0)] MemberNotFound(MemberId), + #[fail(display = "Endpoint with ID '{}' not found.", _0)] + EndpointNotFound(String), #[fail(display = "Member [id = {}] does not have Turn credentials", _0)] NoTurnCredentials(MemberId), #[fail(display = "Couldn't find RpcConnection with Member [id = {}]", _0)] @@ -482,11 +484,11 @@ impl Into for &mut Room { } #[derive(Message)] -#[rtype(result = "Result")] +#[rtype(result = "Result")] pub struct Serialize; impl Handler for Room { - type Result = Result; + type Result = Result; fn handle( &mut self, @@ -498,18 +500,22 @@ impl Handler for Room { } #[derive(Message)] -#[rtype(result = "Result")] +#[rtype(result = "Result")] pub struct SerializeMember(pub MemberId); impl Handler for Room { - type Result = Result; + type Result = Result; fn handle( &mut self, msg: SerializeMember, ctx: &mut Self::Context, ) -> Self::Result { - let member = self.members.get_member_by_id(&msg.0).unwrap(); // TODO + let member = self + .members + .get_member_by_id(&msg.0) + .map_or(Err(RoomError::MemberNotFound(msg.0)), Ok)?; + let mut member_element: Room_Element = member.into(); let member = member_element.take_member(); @@ -521,18 +527,22 @@ impl Handler for Room { } #[derive(Message)] -#[rtype(result = "Result")] +#[rtype(result = "Result")] pub struct SerializeEndpoint(pub MemberId, pub String); impl Handler for Room { - type Result = Result; + type Result = Result; fn handle( &mut self, msg: SerializeEndpoint, ctx: &mut Self::Context, ) -> Self::Result { - let member = self.members.get_member_by_id(&msg.0).unwrap(); // TODO + let member = self + .members + .get_member_by_id(&msg.0) + .map_or(Err(RoomError::MemberNotFound(msg.0)), Ok)?; // TODO + let endpoint_id = WebRtcPublishId(msg.1); let mut element = ElementProto::new(); @@ -548,7 +558,7 @@ impl Handler for Room { let endpoint = member_element.take_webrtc_play(); element.set_webrtc_play(endpoint); } else { - panic!(); // TODO + return Err(RoomError::EndpointNotFound(endpoint_id.0)); } } diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs index f4ab9d555..ab1e69797 100644 --- a/src/signalling/room_repo.rs +++ b/src/signalling/room_repo.rs @@ -5,7 +5,9 @@ use std::{ sync::{Arc, Mutex}, }; -use actix::{Actor, ActorFuture, Addr, Context, Handler, Message}; +use actix::{ + Actor, ActorFuture, Addr, Context, Handler, MailboxError, Message, +}; use failure::Fail; use hashbrown::HashMap; @@ -33,10 +35,18 @@ type ActFuture = pub enum RoomRepoError { #[fail(display = "Room with id {} not found.", _0)] RoomNotFound(RoomId), + #[fail(display = "Mailbox error: {:?}", _0)] + MailboxError(MailboxError), #[fail(display = "Unknow error.")] Unknow, } +impl From for RoomRepoError { + fn from(e: MailboxError) -> Self { + RoomRepoError::MailboxError(e) + } +} + /// Repository that stores [`Room`]s addresses. #[derive(Clone, Debug)] pub struct RoomsRepository { @@ -183,11 +193,15 @@ impl Handler for RoomsRepository { } #[derive(Message)] -#[rtype(result = "Result, RoomRepoError>")] +#[rtype(result = "Result>, \ + RoomRepoError>")] pub struct GetRoom(pub Vec); impl Handler for RoomsRepository { - type Result = ActFuture, RoomRepoError>; + type Result = ActFuture< + Vec>, + RoomRepoError, + >; fn handle( &mut self, @@ -200,14 +214,16 @@ impl Handler for RoomsRepository { if let Some(room) = self.rooms.lock().unwrap().get(&room_id) { futs.push( room.send(Serialize) - .map_err(|_| RoomRepoError::Unknow) - .map(move |r| { - let local_uri = LocalUri { - room_id: Some(room_id), - member_id: None, - endpoint_id: None, - }; - (local_uri.to_string(), r.unwrap()) + .map_err(|e| RoomRepoError::from(e)) + .map(move |result| { + result.map(|r| { + let local_uri = LocalUri { + room_id: Some(room_id), + member_id: None, + endpoint_id: None, + }; + (local_uri.to_string(), r) + }) }), ) } else { @@ -222,11 +238,15 @@ impl Handler for RoomsRepository { } #[derive(Message)] -#[rtype(result = "Result, RoomRepoError>")] +#[rtype(result = "Result>, \ + RoomRepoError>")] pub struct GetMember(pub Vec<(RoomId, MemberId)>); impl Handler for RoomsRepository { - type Result = ActFuture, RoomRepoError>; + type Result = ActFuture< + Vec>, + RoomRepoError, + >; fn handle( &mut self, @@ -239,14 +259,17 @@ impl Handler for RoomsRepository { if let Some(room) = self.rooms.lock().unwrap().get(&room_id) { futs.push( room.send(SerializeMember(member_id.clone())) - .map_err(|_| RoomRepoError::Unknow) - .map(|r| { - let local_uri = LocalUri { - room_id: Some(room_id), - member_id: Some(member_id), - endpoint_id: None, - }; - (local_uri.to_string(), r.unwrap()) + .map_err(|e| RoomRepoError::from(e)) + .map(|result| { + result.map(|r| { + let local_uri = LocalUri { + room_id: Some(room_id), + member_id: Some(member_id), + endpoint_id: None, + }; + + (local_uri.to_string(), r) + }) }), ) } else { @@ -261,11 +284,15 @@ impl Handler for RoomsRepository { } #[derive(Message)] -#[rtype(result = "Result, RoomRepoError>")] +#[rtype(result = "Result>, \ + RoomRepoError>")] pub struct GetEndpoint(pub Vec<(RoomId, MemberId, String)>); impl Handler for RoomsRepository { - type Result = ActFuture, RoomRepoError>; + type Result = ActFuture< + Vec>, + RoomRepoError, + >; fn handle( &mut self, @@ -281,14 +308,16 @@ impl Handler for RoomsRepository { member_id.clone(), endpoint_id.clone(), )) - .map_err(|_| RoomRepoError::Unknow) - .map(|r| { - let local_uri = LocalUri { - room_id: Some(room_id), - member_id: Some(member_id), - endpoint_id: Some(endpoint_id), - }; - (local_uri.to_string(), r.unwrap()) + .map_err(|e| RoomRepoError::from(e)) + .map(|result| { + result.map(|r| { + let local_uri = LocalUri { + room_id: Some(room_id), + member_id: Some(member_id), + endpoint_id: Some(endpoint_id), + }; + (local_uri.to_string(), r) + }) }), ); } else { From 6b59fbcc50aabc245fba32860f364d3ef44f1576 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 9 Jul 2019 19:53:10 +0300 Subject: [PATCH 298/735] Make delete member and endpoint atomic --- src/api/control/grpc/server.rs | 98 +++++++++++++++++++++++++++------- src/bin/client.rs | 2 +- src/signalling/room.rs | 69 +++++++++++++++++++++++- src/signalling/room_repo.rs | 88 +++++++++++++++++++++++++++++- 4 files changed, 235 insertions(+), 22 deletions(-) diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index 2a28da677..a8004e48e 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -26,7 +26,13 @@ use crate::{ }; use super::protos::control_grpc::{create_control_api, ControlApi}; -use crate::signalling::room_repo::{GetEndpoint, GetMember}; +use crate::signalling::{ + room::DeleteEndpointCheck, + room_repo::{ + DeleteEndpointFromMemberCheck, DeleteMemberFromRoomCheck, GetEndpoint, + GetMember, + }, +}; #[derive(Debug, Fail)] enum ControlApiError { @@ -186,6 +192,10 @@ impl ControlApi for ControlApiService { req: IdRequest, sink: UnarySink, ) { + // let mut delete_room_futs = Vec::new(); + let mut delete_member_futs = Vec::new(); + let mut delete_endpoints_futs = Vec::new(); + for id in req.get_id() { let uri = LocalUri::parse(id).unwrap(); // TODO @@ -193,25 +203,77 @@ impl ControlApi for ControlApiService { self.room_repository .do_send(DeleteRoom(uri.room_id.unwrap())); } else if uri.is_member_uri() { - self.room_repository.do_send(DeleteMemberFromRoom { - room_id: uri.room_id.unwrap(), - member_id: uri.member_id.unwrap(), - }); + delete_member_futs.push(self.room_repository.send( + DeleteMemberFromRoomCheck { + room_id: uri.room_id.unwrap(), + member_id: uri.member_id.unwrap(), + }, + )); } else if uri.is_endpoint_uri() { - self.room_repository.do_send(DeleteEndpointFromMember { - room_id: uri.room_id.unwrap(), - member_id: uri.member_id.unwrap(), - endpoint_id: uri.endpoint_id.unwrap(), - }); + delete_endpoints_futs.push(self.room_repository.send( + DeleteEndpointFromMemberCheck { + room_id: uri.room_id.unwrap(), + member_id: uri.member_id.unwrap(), + endpoint_id: uri.endpoint_id.unwrap(), + }, + )); } } - let mut resp = Response::new(); - resp.set_sid(HashMap::new()); + let mega_delete_member_fut = + futures::future::join_all(delete_member_futs); + let mega_delete_endpoints_fut = + futures::future::join_all(delete_endpoints_futs); + + let room_repository_addr = self.room_repository.clone(); + ctx.spawn( - sink.success(resp) - .map_err(|e| error!("gRPC response failed. {:?}", e)), + mega_delete_endpoints_fut + .join(mega_delete_member_fut) + .map_err(|_| ()) + .and_then(move |(member, endpoint)| { + let mut members_msgs = Vec::new(); + let mut endpoints_msgs = Vec::new(); + for member_fut in member { + let member_msg = member_fut.unwrap().unwrap(); + members_msgs.push( + room_repository_addr + .send(member_msg) + .map_err(|_| ()), + ); + } + + for endpoint_fut in endpoint { + let endpoint_msg = endpoint_fut.unwrap().unwrap(); + endpoints_msgs.push( + room_repository_addr + .send(endpoint_msg) + .map_err(|_| ()), + ); + } + + let members_msgs = futures::future::join_all(members_msgs); + let endpoints_msgs = + futures::future::join_all(endpoints_msgs); + + members_msgs + .join(endpoints_msgs) + .map_err(|_| ()) + .map(|_| ()) + .and_then(|_| { + let mut response = Response::new(); + response.set_sid(HashMap::new()); + sink.success(response).map_err(|_| ()) + }) + }), ); + + // let mut resp = Response::new(); + // resp.set_sid(HashMap::new()); + // ctx.spawn( + // sink.success(resp) + // .map_err(|e| error!("gRPC response failed. {:?}", e)), + // ); } fn get( @@ -266,10 +328,10 @@ impl ControlApi for ControlApiService { } Err(e) => { let mut error = Error::new(); - error.set_status(500); - error.set_code(500); - error.set_text(String::new()); - error.set_element(String::new()); + error.set_status(400); + error.set_code(0); // TODO + error.set_text(e.to_string()); + error.set_element(String::new()); // TODO let mut response = GetResponse::new(); response.set_error(error); diff --git a/src/bin/client.rs b/src/bin/client.rs index b12e0932c..7f2b71a4b 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -89,7 +89,7 @@ fn main() { let mut room = RepeatedField::new(); room.push("local://grpc-test".to_string()); room.push("local://video-call-1/responder".to_string()); - room.push("local://grpc-test/publisher/publih".to_string()); + room.push("local://grpc-test/publisher/publish".to_string()); get_room_request.set_id(room); let reply = client.get(&get_room_request).expect("get room"); diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 899326091..7bcb63b59 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -751,7 +751,7 @@ impl Handler for Room { } } -#[derive(Debug, Message)] +#[derive(Debug, Message, Clone)] #[rtype(result = "()")] pub struct DeleteMember(pub MemberId); @@ -768,6 +768,26 @@ impl Handler for Room { } #[derive(Debug, Message)] +#[rtype(result = "Result<(), RoomError>")] +pub struct DeleteMemberCheck(pub MemberId); + +impl Handler for Room { + type Result = Result<(), RoomError>; + + fn handle( + &mut self, + msg: DeleteMemberCheck, + ctx: &mut Self::Context, + ) -> Self::Result { + if let None = self.members.get_member_by_id(&msg.0) { + panic!() + }; + + Ok(()) + } +} + +#[derive(Debug, Message, Clone)] #[rtype(result = "()")] pub struct DeleteEndpoint { pub member_id: MemberId, @@ -797,3 +817,50 @@ impl Handler for Room { } } } + +#[derive(Debug, Message)] +#[rtype(result = "Result<(), RoomError>")] +pub struct DeleteEndpointCheck { + pub member_id: MemberId, + pub endpoint_id: String, +} + +impl Handler for Room { + type Result = Result<(), RoomError>; + + fn handle( + &mut self, + msg: DeleteEndpointCheck, + ctx: &mut Self::Context, + ) -> Self::Result { + let member = match self.members.get_member_by_id(&msg.member_id) { + Some(m) => m, + None => panic!(), + }; + let play_id = WebRtcPlayId(msg.endpoint_id); + + if let Some(endpoint) = member.get_sink_by_id(&play_id) { + if let Some(peer_id) = endpoint.peer_id() { + if let Err(_) = self.peers.get_peer(peer_id) { + return Ok(()); + } + } else { + panic!() + } + } + + let publish_id = WebRtcPublishId(play_id.0); + if let Some(endpoint) = member.get_src_by_id(&publish_id) { + let peer_ids = endpoint.peer_ids(); + for peer_id in peer_ids { + if let Err(_) = self.peers.get_peer(peer_id) { + panic!() + } + } + } else { + panic!() + } + + Ok(()) + } +} diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs index ab1e69797..5f6b128c1 100644 --- a/src/signalling/room_repo.rs +++ b/src/signalling/room_repo.rs @@ -18,8 +18,9 @@ use crate::{ }, signalling::{ room::{ - CloseRoom, DeleteEndpoint, DeleteMember, RoomError, Serialize, - SerializeEndpoint, SerializeMember, + CloseRoom, DeleteEndpoint, DeleteEndpointCheck, DeleteMember, + DeleteMemberCheck, RoomError, Serialize, SerializeEndpoint, + SerializeMember, }, Room, }, @@ -163,6 +164,46 @@ impl Handler for RoomsRepository { } } +#[derive(Message)] +#[rtype( + result = "Result, RoomRepoError>" +)] +pub struct DeleteMemberFromRoomCheck { + pub member_id: MemberId, + pub room_id: RoomId, +} + +impl Handler for RoomsRepository { + type Result = + ActFuture, RoomRepoError>; + + fn handle( + &mut self, + msg: DeleteMemberFromRoomCheck, + ctx: &mut Self::Context, + ) -> Self::Result { + let fut = + if let Some(room) = self.rooms.lock().unwrap().get(&msg.room_id) { + Either::A( + room.send(DeleteMemberCheck(msg.member_id.clone())) + .map_err(|e| RoomRepoError::from(e)) + .map(|r| { + r.map(|_| DeleteMemberFromRoom { + room_id: msg.room_id, + member_id: msg.member_id, + }) + }), + ) + } else { + Either::B(futures::future::err(RoomRepoError::RoomNotFound( + msg.room_id, + ))) + }; + + Box::new(wrap_future(fut)) + } +} + #[derive(Message)] #[rtype(result = "Result<(), RoomRepoError>")] pub struct DeleteEndpointFromMember { @@ -192,6 +233,49 @@ impl Handler for RoomsRepository { } } +#[derive(Message)] +#[rtype(result = "Result, \ + RoomRepoError>")] +pub struct DeleteEndpointFromMemberCheck { + pub room_id: RoomId, + pub member_id: MemberId, + pub endpoint_id: String, +} + +impl Handler for RoomsRepository { + type Result = + ActFuture, RoomRepoError>; + + fn handle( + &mut self, + msg: DeleteEndpointFromMemberCheck, + ctx: &mut Self::Context, + ) -> Self::Result { + let fut = if let Some(room) = self.get(&msg.room_id) { + Either::A( + room.send(DeleteEndpointCheck { + member_id: msg.member_id.clone(), + endpoint_id: msg.endpoint_id.clone(), + }) + .map_err(|e| RoomRepoError::from(e)) + .map(|r| { + r.map(|_| DeleteEndpointFromMember { + room_id: msg.room_id, + member_id: msg.member_id, + endpoint_id: msg.endpoint_id, + }) + }), + ) + } else { + Either::B(futures::future::err(RoomRepoError::RoomNotFound( + msg.room_id, + ))) + }; + + Box::new(wrap_future(fut)) + } +} + #[derive(Message)] #[rtype(result = "Result>, \ RoomRepoError>")] From 4986be7ead75acd32f46a48cff2f631ee7d1d59c Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 9 Jul 2019 19:56:52 +0300 Subject: [PATCH 299/735] Make DeleteMember's and DeleteEndpoint's constructor private --- src/signalling/room_repo.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs index 5f6b128c1..b9f65c0da 100644 --- a/src/signalling/room_repo.rs +++ b/src/signalling/room_repo.rs @@ -142,8 +142,8 @@ impl Handler for RoomsRepository { #[derive(Message)] #[rtype(result = "Result<(), RoomRepoError>")] pub struct DeleteMemberFromRoom { - pub member_id: MemberId, - pub room_id: RoomId, + member_id: MemberId, + room_id: RoomId, } impl Handler for RoomsRepository { @@ -207,9 +207,9 @@ impl Handler for RoomsRepository { #[derive(Message)] #[rtype(result = "Result<(), RoomRepoError>")] pub struct DeleteEndpointFromMember { - pub room_id: RoomId, - pub member_id: MemberId, - pub endpoint_id: String, + room_id: RoomId, + member_id: MemberId, + endpoint_id: String, } impl Handler for RoomsRepository { From c22cb808f10592153978cae11af9b6dd0d6646b0 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 9 Jul 2019 20:02:31 +0300 Subject: [PATCH 300/735] Fix warns --- src/api/control/grpc/server.rs | 18 ++++------------ src/api/control/local_uri.rs | 1 - .../endpoints/webrtc/publish_endpoint.rs | 1 - src/signalling/elements/member.rs | 4 +--- src/signalling/room.rs | 12 +++++------ src/signalling/room_repo.rs | 21 ++++++++----------- 6 files changed, 20 insertions(+), 37 deletions(-) diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index a8004e48e..ecae8a6c5 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -2,7 +2,7 @@ use std::{collections::HashMap, sync::Arc}; use actix::{Actor, Addr, Arbiter, Context}; use failure::Fail; -use futures::future::{Either, Future, IntoFuture}; +use futures::future::{Either, Future}; use grpcio::{Environment, RpcContext, Server, ServerBuilder, UnarySink}; use crate::{ @@ -15,24 +15,14 @@ use crate::{ RoomSpec, TryFromElementError, TryFromProtobufError, }, log::prelude::*, - signalling::{ - room::RoomError, - room_repo::{ - DeleteEndpointFromMember, DeleteMemberFromRoom, DeleteRoom, - GetRoom, RoomsRepository, StartRoom, - }, + signalling::room_repo::{ + DeleteEndpointFromMemberCheck, DeleteMemberFromRoomCheck, DeleteRoom, + GetEndpoint, GetMember, GetRoom, RoomsRepository, StartRoom, }, App, }; use super::protos::control_grpc::{create_control_api, ControlApi}; -use crate::signalling::{ - room::DeleteEndpointCheck, - room_repo::{ - DeleteEndpointFromMemberCheck, DeleteMemberFromRoomCheck, GetEndpoint, - GetMember, - }, -}; #[derive(Debug, Fail)] enum ControlApiError { diff --git a/src/api/control/local_uri.rs b/src/api/control/local_uri.rs index 1287e85fe..edb618f93 100644 --- a/src/api/control/local_uri.rs +++ b/src/api/control/local_uri.rs @@ -3,7 +3,6 @@ use std::fmt; use failure::Fail; use super::{MemberId, RoomId}; -use crate::api::control::endpoints::webrtc_play_endpoint::SrcUri; #[derive(Debug, Fail)] pub enum LocalUriParseError { diff --git a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs index 7c641bbc9..91246dac5 100644 --- a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs @@ -13,7 +13,6 @@ use crate::{ grpc::protos::control::{ Member_Element as ElementProto, WebRtcPublishEndpoint as WebRtcPublishEndpointProto, - WebRtcPublishEndpoint_P2P as WebRtcPublishEndpointP2pProto, }, }, media::PeerId, diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index fcd010e9f..62eda252c 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -14,6 +14,7 @@ use crate::{ grpc::protos::control::{ Member as MemberProto, Room_Element as ElementProto, }, + local_uri::LocalUri, MemberId, MemberSpec, RoomId, RoomSpec, TryFromElementError, WebRtcPlayId, WebRtcPublishId, }, @@ -22,9 +23,6 @@ use crate::{ }; use super::endpoints::webrtc::{WebRtcPlayEndpoint, WebRtcPublishEndpoint}; -use crate::api::control::{ - grpc::protos::control::Member_Element, local_uri::LocalUri, -}; /// Errors which may occur while loading [`Member`]s from [`RoomSpec`]. #[derive(Debug, Fail)] diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 7bcb63b59..1a8a5bbc0 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -492,8 +492,8 @@ impl Handler for Room { fn handle( &mut self, - msg: Serialize, - ctx: &mut Self::Context, + _msg: Serialize, + _ctx: &mut Self::Context, ) -> Self::Result { Ok(self.into()) } @@ -509,7 +509,7 @@ impl Handler for Room { fn handle( &mut self, msg: SerializeMember, - ctx: &mut Self::Context, + _ctx: &mut Self::Context, ) -> Self::Result { let member = self .members @@ -536,7 +536,7 @@ impl Handler for Room { fn handle( &mut self, msg: SerializeEndpoint, - ctx: &mut Self::Context, + _ctx: &mut Self::Context, ) -> Self::Result { let member = self .members @@ -777,7 +777,7 @@ impl Handler for Room { fn handle( &mut self, msg: DeleteMemberCheck, - ctx: &mut Self::Context, + _ctx: &mut Self::Context, ) -> Self::Result { if let None = self.members.get_member_by_id(&msg.0) { panic!() @@ -831,7 +831,7 @@ impl Handler for Room { fn handle( &mut self, msg: DeleteEndpointCheck, - ctx: &mut Self::Context, + _ctx: &mut Self::Context, ) -> Self::Result { let member = match self.members.get_member_by_id(&msg.member_id) { Some(m) => m, diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs index b9f65c0da..73886b201 100644 --- a/src/signalling/room_repo.rs +++ b/src/signalling/room_repo.rs @@ -1,14 +1,13 @@ //! Repository that stores [`Room`]s addresses. -use std::{ - collections::HashMap as StdHashMap, - sync::{Arc, Mutex}, -}; +use std::sync::{Arc, Mutex}; use actix::{ - Actor, ActorFuture, Addr, Context, Handler, MailboxError, Message, + fut::wrap_future, Actor, ActorFuture, Addr, Context, Handler, MailboxError, + Message, }; use failure::Fail; +use futures::future::{Either, Future}; use hashbrown::HashMap; use crate::{ @@ -26,8 +25,6 @@ use crate::{ }, App, }; -use actix::fut::wrap_future; -use futures::future::{Either, Future}; type ActFuture = Box>; @@ -180,7 +177,7 @@ impl Handler for RoomsRepository { fn handle( &mut self, msg: DeleteMemberFromRoomCheck, - ctx: &mut Self::Context, + _ctx: &mut Self::Context, ) -> Self::Result { let fut = if let Some(room) = self.rooms.lock().unwrap().get(&msg.room_id) { @@ -249,7 +246,7 @@ impl Handler for RoomsRepository { fn handle( &mut self, msg: DeleteEndpointFromMemberCheck, - ctx: &mut Self::Context, + _ctx: &mut Self::Context, ) -> Self::Result { let fut = if let Some(room) = self.get(&msg.room_id) { Either::A( @@ -290,7 +287,7 @@ impl Handler for RoomsRepository { fn handle( &mut self, msg: GetRoom, - ctx: &mut Self::Context, + _ctx: &mut Self::Context, ) -> Self::Result { let mut futs = Vec::new(); @@ -335,7 +332,7 @@ impl Handler for RoomsRepository { fn handle( &mut self, msg: GetMember, - ctx: &mut Self::Context, + _ctx: &mut Self::Context, ) -> Self::Result { let mut futs = Vec::new(); @@ -381,7 +378,7 @@ impl Handler for RoomsRepository { fn handle( &mut self, msg: GetEndpoint, - ctx: &mut Self::Context, + _ctx: &mut Self::Context, ) -> Self::Result { let mut futs = Vec::new(); From ffe7774aac54055e9243a5c0b7a232580d0ca041 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 9 Jul 2019 20:14:15 +0300 Subject: [PATCH 301/735] Make room delete atomic --- src/api/control/grpc/server.rs | 30 ++++++++++++++++++++++-------- src/signalling/room_repo.rs | 22 +++++++++++++++++++++- 2 files changed, 43 insertions(+), 9 deletions(-) diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index ecae8a6c5..3288d4b8d 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -16,13 +16,14 @@ use crate::{ }, log::prelude::*, signalling::room_repo::{ - DeleteEndpointFromMemberCheck, DeleteMemberFromRoomCheck, DeleteRoom, - GetEndpoint, GetMember, GetRoom, RoomsRepository, StartRoom, + DeleteEndpointFromMemberCheck, DeleteMemberFromRoomCheck, GetEndpoint, + GetMember, GetRoom, RoomsRepository, StartRoom, }, App, }; use super::protos::control_grpc::{create_control_api, ControlApi}; +use crate::signalling::room_repo::DeleteRoomCheck; #[derive(Debug, Fail)] enum ControlApiError { @@ -182,7 +183,7 @@ impl ControlApi for ControlApiService { req: IdRequest, sink: UnarySink, ) { - // let mut delete_room_futs = Vec::new(); + let mut delete_room_futs = Vec::new(); let mut delete_member_futs = Vec::new(); let mut delete_endpoints_futs = Vec::new(); @@ -190,8 +191,10 @@ impl ControlApi for ControlApiService { let uri = LocalUri::parse(id).unwrap(); // TODO if uri.is_room_uri() { - self.room_repository - .do_send(DeleteRoom(uri.room_id.unwrap())); + delete_room_futs.push( + self.room_repository + .send(DeleteRoomCheck(uri.room_id.unwrap())), + ); } else if uri.is_member_uri() { delete_member_futs.push(self.room_repository.send( DeleteMemberFromRoomCheck { @@ -210,6 +213,7 @@ impl ControlApi for ControlApiService { } } + let mega_delete_room_fut = futures::future::join_all(delete_room_futs); let mega_delete_member_fut = futures::future::join_all(delete_member_futs); let mega_delete_endpoints_fut = @@ -219,11 +223,13 @@ impl ControlApi for ControlApiService { ctx.spawn( mega_delete_endpoints_fut - .join(mega_delete_member_fut) + .join3(mega_delete_member_fut, mega_delete_room_fut) .map_err(|_| ()) - .and_then(move |(member, endpoint)| { + .and_then(move |(member, endpoint, room)| { let mut members_msgs = Vec::new(); let mut endpoints_msgs = Vec::new(); + let mut room_msgs = Vec::new(); + for member_fut in member { let member_msg = member_fut.unwrap().unwrap(); members_msgs.push( @@ -242,12 +248,20 @@ impl ControlApi for ControlApiService { ); } + for room_fut in room { + let room_msg = room_fut.unwrap(); + room_msgs.push( + room_repository_addr.send(room_msg).map_err(|_| ()), + ); + } + let members_msgs = futures::future::join_all(members_msgs); let endpoints_msgs = futures::future::join_all(endpoints_msgs); + let room_msgs = futures::future::join_all(room_msgs); members_msgs - .join(endpoints_msgs) + .join3(endpoints_msgs, room_msgs) .map_err(|_| ()) .map(|_| ()) .and_then(|_| { diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs index 73886b201..ce3856742 100644 --- a/src/signalling/room_repo.rs +++ b/src/signalling/room_repo.rs @@ -114,7 +114,7 @@ impl Handler for RoomsRepository { #[derive(Message)] #[rtype(result = "Result<(), RoomRepoError>")] -pub struct DeleteRoom(pub RoomId); +pub struct DeleteRoom(RoomId); impl Handler for RoomsRepository { type Result = Result<(), RoomRepoError>; @@ -136,6 +136,26 @@ impl Handler for RoomsRepository { } } +#[derive(Message)] +#[rtype(result = "Result")] +pub struct DeleteRoomCheck(pub RoomId); + +impl Handler for RoomsRepository { + type Result = Result; + + fn handle( + &mut self, + msg: DeleteRoomCheck, + _ctx: &mut Self::Context, + ) -> Self::Result { + if let None = self.rooms.lock().unwrap().get(&msg.0) { + Err(RoomRepoError::RoomNotFound(msg.0)) + } else { + Ok(DeleteRoom(msg.0)) + } + } +} + #[derive(Message)] #[rtype(result = "Result<(), RoomRepoError>")] pub struct DeleteMemberFromRoom { From 00ab25ffbfa303eb52404e016ed2877551b82bf3 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 9 Jul 2019 20:24:49 +0300 Subject: [PATCH 302/735] Minor refactor gRPC client --- src/bin/client.rs | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/bin/client.rs b/src/bin/client.rs index 7f2b71a4b..de5ed0b05 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -15,7 +15,14 @@ fn main() { let ch = ChannelBuilder::new(env).connect("localhost:50051"); let client = ControlApiClient::new(ch); - // Create room + create_room(&client); + delete_room(&client); + delete_endpoint(&client); + delete_member(&client); + get_room(&client); +} + +fn create_room(client: &ControlApiClient) { let mut req = CreateRequest::new(); let mut room = Room::new(); let mut publisher = Member::new(); @@ -56,8 +63,9 @@ fn main() { } else { println!("Receiver: {:?}", reply.get_sid()); } +} - // Delete room +fn delete_room(client: &ControlApiClient) { let mut delete_request = IdRequest::new(); let mut rooms = RepeatedField::new(); rooms.push("local://pub-sub-video-call".to_string()); @@ -65,8 +73,9 @@ fn main() { let reply = client.delete(&delete_request).expect("delete"); println!("{:?}", reply); +} - // Delete endpoint +fn delete_endpoint(client: &ControlApiClient) { let mut delete_endpoint_req = IdRequest::new(); let mut endpoints = RepeatedField::new(); endpoints.push("local://video-call-1/caller/publish".to_string()); @@ -74,8 +83,9 @@ fn main() { let reply = client.delete(&delete_endpoint_req).expect("delete member"); println!("{:?}", reply); +} - // Delete member +fn delete_member(client: &ControlApiClient) { let mut delete_member_req = IdRequest::new(); let mut members = RepeatedField::new(); members.push("local://video-call-1/caller".to_string()); @@ -83,8 +93,9 @@ fn main() { let reply = client.delete(&delete_member_req).expect("delete member"); println!("{:?}", reply); +} - // Get room +fn get_room(client: &ControlApiClient) { let mut get_room_request = IdRequest::new(); let mut room = RepeatedField::new(); room.push("local://grpc-test".to_string()); From 5fe004855e3314846f7f2be81a7e7465a6ca97ea Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 10 Jul 2019 12:57:05 +0300 Subject: [PATCH 303/735] Add Create Member --- src/api/control/grpc/server.rs | 17 ++++++- src/api/control/member.rs | 8 +-- src/bin/client.rs | 30 +++++++++-- src/signalling/elements/member.rs | 6 ++- src/signalling/participants.rs | 84 ++++++++++++++++++++++++++++++- src/signalling/room.rs | 19 ++++++- src/signalling/room_repo.rs | 33 ++++++++++-- 7 files changed, 179 insertions(+), 18 deletions(-) diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index 3288d4b8d..87d45bc6c 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -1,4 +1,4 @@ -use std::{collections::HashMap, sync::Arc}; +use std::{collections::HashMap, convert::TryFrom, sync::Arc}; use actix::{Actor, Addr, Arbiter, Context}; use failure::Fail; @@ -23,7 +23,10 @@ use crate::{ }; use super::protos::control_grpc::{create_control_api, ControlApi}; -use crate::signalling::room_repo::DeleteRoomCheck; +use crate::{ + api::control::MemberSpec, + signalling::room_repo::{CreateMemberInRoom, DeleteRoomCheck}, +}; #[derive(Debug, Fail)] enum ControlApiError { @@ -114,6 +117,16 @@ impl ControlApi for ControlApiService { let create = { if local_uri.is_room_uri() { self.create_room(req) + } else if local_uri.is_member_uri() { + let member_spec = + MemberSpec::try_from(req.get_member()).unwrap(); + self.room_repository.do_send(CreateMemberInRoom { + room_id: local_uri.room_id.unwrap(), + member_id: local_uri.member_id.unwrap(), + spec: member_spec, + }); + + return; } else { unimplemented!() } diff --git a/src/api/control/member.rs b/src/api/control/member.rs index a59f78171..a7eb36340 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -13,7 +13,7 @@ use crate::api::control::{ webrtc_publish_endpoint::{WebRtcPublishEndpoint, WebRtcPublishId}, }, grpc::protos::control::Member as MemberProto, - Endpoint, TryFromProtobufError, + Endpoint, TryFromProtobufError, WebRtcPlayId, }; use super::{pipeline::Pipeline, Element, TryFromElementError}; @@ -55,11 +55,13 @@ impl Into for MemberSpec { impl MemberSpec { /// Returns all [`WebRtcPlayEndpoint`]s of this [`MemberSpec`]. - pub fn play_endpoints(&self) -> HashMap<&String, &WebRtcPlayEndpoint> { + pub fn play_endpoints(&self) -> HashMap { self.pipeline .iter() .filter_map(|(id, e)| match e { - Element::WebRtcPlayEndpoint { spec } => Some((id, spec)), + Element::WebRtcPlayEndpoint { spec } => { + Some((WebRtcPlayId(id.clone()), spec)) + } _ => None, }) .collect() diff --git a/src/bin/client.rs b/src/bin/client.rs index de5ed0b05..e97c93734 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -9,6 +9,7 @@ use medea::api::control::grpc::protos::{ control_grpc::ControlApiClient, }; use protobuf::RepeatedField; +use std::time::Duration; fn main() { let env = Arc::new(EnvBuilder::new().build()); @@ -16,9 +17,11 @@ fn main() { let client = ControlApiClient::new(ch); create_room(&client); - delete_room(&client); - delete_endpoint(&client); - delete_member(&client); + // delete_room(&client); + // delete_endpoint(&client); + // delete_member(&client); + create_member(&client); + // std::thread::sleep(Duration::from_secs(1)); get_room(&client); } @@ -65,6 +68,25 @@ fn create_room(client: &ControlApiClient) { } } +fn create_member(client: &ControlApiClient) { + let mut create_member_request = CreateRequest::new(); + let mut member = Member::new(); + let mut member_pipeline = HashMap::new(); + + let mut play_endpoint = WebRtcPlayEndpoint::new(); + play_endpoint.set_src("local://grpc-test/publisher/publish".to_string()); + let mut member_element = Member_Element::new(); + member_element.set_webrtc_play(play_endpoint); + member_pipeline.insert("play".to_string(), member_element); + + member.set_credentials("test".to_string()); + member.set_pipeline(member_pipeline); + create_member_request.set_id("local://grpc-test/player".to_string()); + create_member_request.set_member(member); + + let reply = client.create(&create_member_request); +} + fn delete_room(client: &ControlApiClient) { let mut delete_request = IdRequest::new(); let mut rooms = RepeatedField::new(); @@ -104,5 +126,5 @@ fn get_room(client: &ControlApiClient) { get_room_request.set_id(room); let reply = client.get(&get_room_request).expect("get room"); - println!("{:?}", reply); + println!("{:#?}", reply); } diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index 62eda252c..defda8535 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -75,7 +75,8 @@ impl Member { /// /// To fill this [`Member`], you need to call the [`Member::load`] /// function. - fn new(id: MemberId, credentials: String, room_id: RoomId) -> Self { + // TODO: private + pub fn new(id: MemberId, credentials: String, room_id: RoomId) -> Self { Self(RefCell::new(MemberInner { id, srcs: HashMap::new(), @@ -87,7 +88,8 @@ impl Member { } /// Load all srcs and sinks of this [`Member`]. - fn load( + // TODO: private + pub fn load( &self, room_spec: &RoomSpec, store: &HashMap>, diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 1283b9b9b..a85c0a440 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -27,12 +27,15 @@ use crate::{ AuthorizationError, ClosedReason, EventMessage, RpcConnection, RpcConnectionClosed, }, - control::{MemberId, RoomId, RoomSpec}, + control::{MemberId, MemberSpec, RoomId, RoomSpec, WebRtcPlayId}, }, log::prelude::*, media::IceUser, signalling::{ - elements::{parse_members, Member, MembersLoadError}, + elements::{ + endpoints::webrtc::{WebRtcPlayEndpoint, WebRtcPublishEndpoint}, + parse_members, Member, MembersLoadError, + }, room::{ActFuture, RoomError}, Room, }, @@ -342,4 +345,81 @@ impl ParticipantService { } } } + + pub fn create_member(&mut self, id: MemberId, spec: MemberSpec) { + let signalling_member = Rc::new(Member::new( + id.clone(), + spec.credentials().to_string(), + self.room_id.clone(), + )); + + for (id, publish) in spec.publish_endpoints() { + let signalling_publish = Rc::new(WebRtcPublishEndpoint::new( + id.clone(), + publish.p2p.clone(), + Vec::new(), + Rc::downgrade(&signalling_member), + )); + signalling_member.insert_src(signalling_publish); + } + + for (id, play) in spec.play_endpoints() { + let partner_member = + self.get_member_by_id(&play.src.member_id).unwrap(); + let src = + partner_member.get_src_by_id(&play.src.endpoint_id).unwrap(); + + let sink = Rc::new(WebRtcPlayEndpoint::new( + id.clone(), + play.src.clone(), + Rc::downgrade(&src), + Rc::downgrade(&signalling_member), + )); + + src.add_sink(Rc::downgrade(&sink)); + signalling_member.insert_sink(sink); + } + + self.members.insert(id, signalling_member); + + // for (id, member) in &members { + // let signalling_member = Rc::new(Member::new( + // id.clone(), + // member.credentials().to_string(), + // self.room_id.clone(), + // )); + // for (id, publish) in member.publish_endpoints() { + // let signalling_publish = + // Rc::new(WebRtcPublishEndpoint::new( + // id.clone(), publish.p2p.clone(), + // Vec::new(), + // Rc::downgrade(&signalling_member), + // )); + // signalling_member.insert_src(signalling_publish); + // } + // self.members.insert(id.clone(), signalling_member); + // } + // + // for (id, member) in members { + // let signalling_member = + // self.get_member_by_id(&id).unwrap(); for (id, + // play) in member.play_endpoints() { let + // partner_member = + // self.get_member_by_id(&play.src.member_id).unwrap(); + // let src = partner_member + // .get_src_by_id(&play.src.endpoint_id) + // .unwrap(); + // + // let sink = Rc::new(WebRtcPlayEndpoint::new( + // id.clone(), + // play.src.clone(), + // Rc::downgrade(&src), + // Rc::downgrade(&signalling_member), + // )); + // + // src.add_sink(Rc::downgrade(&sink)); + // signalling_member.insert_sink(sink); + // } + // } + } } diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 1a8a5bbc0..634069299 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -27,7 +27,7 @@ use crate::{ }, local_uri::LocalUri, room::RoomSpec, - MemberId, RoomId, TryFromElementError, WebRtcPlayId, + MemberId, MemberSpec, RoomId, TryFromElementError, WebRtcPlayId, WebRtcPublishId, }, }, @@ -864,3 +864,20 @@ impl Handler for Room { Ok(()) } } + +#[derive(Message, Debug)] +#[rtype(result = "Result<(), RoomError>")] +pub struct CreateMember(pub MemberId, pub MemberSpec); + +impl Handler for Room { + type Result = Result<(), RoomError>; + + fn handle( + &mut self, + msg: CreateMember, + ctx: &mut Self::Context, + ) -> Self::Result { + self.members.create_member(msg.0, msg.1); + Ok(()) + } +} diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs index ce3856742..275ce069e 100644 --- a/src/signalling/room_repo.rs +++ b/src/signalling/room_repo.rs @@ -13,13 +13,13 @@ use hashbrown::HashMap; use crate::{ api::control::{ grpc::protos::control::Element as ElementProto, local_uri::LocalUri, - room::RoomSpec, MemberId, RoomId, + room::RoomSpec, MemberId, MemberSpec, RoomId, }, signalling::{ room::{ - CloseRoom, DeleteEndpoint, DeleteEndpointCheck, DeleteMember, - DeleteMemberCheck, RoomError, Serialize, SerializeEndpoint, - SerializeMember, + CloseRoom, CreateMember, DeleteEndpoint, DeleteEndpointCheck, + DeleteMember, DeleteMemberCheck, RoomError, Serialize, + SerializeEndpoint, SerializeMember, }, Room, }, @@ -431,3 +431,28 @@ impl Handler for RoomsRepository { Box::new(wrap_future(futures::future::join_all(futs))) } } + +#[derive(Message)] +#[rtype(result = "Result<(), RoomRepoError>")] +pub struct CreateMemberInRoom { + pub room_id: RoomId, + pub member_id: MemberId, + pub spec: MemberSpec, +} + +impl Handler for RoomsRepository { + type Result = Result<(), RoomRepoError>; + + fn handle( + &mut self, + msg: CreateMemberInRoom, + ctx: &mut Self::Context, + ) -> Self::Result { + if let Some(room) = self.rooms.lock().unwrap().get(&msg.room_id) { + room.do_send(CreateMember(msg.member_id, msg.spec)); + } else { + unimplemented!() + } + Ok(()) + } +} From c46c53be2af2d35b189db1af78ab38691d29637b Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 10 Jul 2019 13:32:06 +0300 Subject: [PATCH 304/735] Add Create Endpoint --- src/api/control/endpoints/mod.rs | 22 ++++++- src/api/control/grpc/server.rs | 16 ++++- src/bin/client.rs | 12 ++++ src/signalling/elements/member.rs | 22 +++++++ src/signalling/participants.rs | 98 ++++++++++++++++++------------- src/signalling/room.rs | 41 ++++++++++++- src/signalling/room_repo.rs | 39 ++++++++++-- 7 files changed, 201 insertions(+), 49 deletions(-) diff --git a/src/api/control/endpoints/mod.rs b/src/api/control/endpoints/mod.rs index 8d7ef33c3..30eac8bcb 100644 --- a/src/api/control/endpoints/mod.rs +++ b/src/api/control/endpoints/mod.rs @@ -3,7 +3,9 @@ pub mod webrtc_publish_endpoint; use std::convert::TryFrom; -use crate::api::control::grpc::protos::control::Member_Element as MemberElementProto; +use crate::api::control::grpc::protos::control::{ + CreateRequest, Member_Element as MemberElementProto, +}; use super::{Element, TryFromElementError, TryFromProtobufError}; @@ -49,6 +51,24 @@ impl TryFrom<&MemberElementProto> for Endpoint { } } +impl TryFrom<&CreateRequest> for Endpoint { + type Error = TryFromProtobufError; + + fn try_from(value: &CreateRequest) -> Result { + if value.has_webrtc_play() { + let play = WebRtcPlayEndpoint::try_from(value.get_webrtc_play())?; + return Ok(Endpoint::WebRtcPlay(play)); + } else if value.has_webrtc_pub() { + let publish = + WebRtcPublishEndpoint::try_from(value.get_webrtc_pub())?; + return Ok(Endpoint::WebRtcPublish(publish)); + } else { + // TODO + unimplemented!() + } + } +} + impl TryFrom<&Element> for Endpoint { type Error = TryFromElementError; diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index 87d45bc6c..b8c629b49 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -24,8 +24,10 @@ use crate::{ use super::protos::control_grpc::{create_control_api, ControlApi}; use crate::{ - api::control::MemberSpec, - signalling::room_repo::{CreateMemberInRoom, DeleteRoomCheck}, + api::control::{Endpoint, MemberSpec}, + signalling::room_repo::{ + CreateEndpointInRoom, CreateMemberInRoom, DeleteRoomCheck, + }, }; #[derive(Debug, Fail)] @@ -126,6 +128,16 @@ impl ControlApi for ControlApiService { spec: member_spec, }); + return; + } else if local_uri.is_endpoint_uri() { + let endpoint = Endpoint::try_from(&req).unwrap(); + self.room_repository.do_send(CreateEndpointInRoom { + room_id: local_uri.room_id.unwrap(), + member_id: local_uri.member_id.unwrap(), + endpoint_id: local_uri.endpoint_id.unwrap(), + spec: endpoint, + }); + return; } else { unimplemented!() diff --git a/src/bin/client.rs b/src/bin/client.rs index e97c93734..9c1c470a2 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -22,6 +22,7 @@ fn main() { // delete_member(&client); create_member(&client); // std::thread::sleep(Duration::from_secs(1)); + create_endpoint(&client); get_room(&client); } @@ -87,6 +88,17 @@ fn create_member(client: &ControlApiClient) { let reply = client.create(&create_member_request); } +fn create_endpoint(client: &ControlApiClient) { + let mut create_endpoint_request = CreateRequest::new(); + let mut endpoint = WebRtcPublishEndpoint::new(); + endpoint.set_p2p(WebRtcPublishEndpoint_P2P::ALWAYS); + create_endpoint_request + .set_id("local://grpc-test/player/create-publish".to_string()); + create_endpoint_request.set_webrtc_pub(endpoint); + + client.create(&create_endpoint_request); +} + fn delete_room(client: &ControlApiClient) { let mut delete_request = IdRequest::new(); let mut rooms = RepeatedField::new(); diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index defda8535..3addb5b27 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -11,6 +11,10 @@ use medea_client_api_proto::IceServer; use crate::{ api::control::{ + endpoints::{ + webrtc_play_endpoint::WebRtcPlayEndpoint as WebRtcPlayEndpointSpec, + webrtc_publish_endpoint::WebRtcPublishEndpoint as WebRtcPublishEndpointSpec, + }, grpc::protos::control::{ Member as MemberProto, Room_Element as ElementProto, }, @@ -299,6 +303,24 @@ impl Member { pub fn room_id(&self) -> RoomId { self.0.borrow().room_id.clone() } + + pub fn create_sink( + member: Rc, + id: WebRtcPlayId, + spec: WebRtcPlayEndpointSpec, + ) { + let src = member.get_src_by_id(&spec.src.endpoint_id).unwrap(); + + let sink = Rc::new(WebRtcPlayEndpoint::new( + id, + spec.src, + Rc::downgrade(&src), + Rc::downgrade(&member), + )); + + src.add_sink(Rc::downgrade(&sink)); + member.insert_sink(sink); + } } /// Creates all empty [`Member`] from [`RoomSpec`] and then diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index a85c0a440..b355cb135 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -27,7 +27,14 @@ use crate::{ AuthorizationError, ClosedReason, EventMessage, RpcConnection, RpcConnectionClosed, }, - control::{MemberId, MemberSpec, RoomId, RoomSpec, WebRtcPlayId}, + control::{ + endpoints::{ + webrtc_play_endpoint::WebRtcPlayEndpoint as WebRtcPlayEndpointSpec, + webrtc_publish_endpoint::WebRtcPublishEndpoint as WebRtcPublishEndpointSpec, + }, + MemberId, MemberSpec, RoomId, RoomSpec, WebRtcPlayId, + WebRtcPublishId, + }, }, log::prelude::*, media::IceUser, @@ -381,45 +388,56 @@ impl ParticipantService { } self.members.insert(id, signalling_member); + } + + pub fn create_sink_endpoint( + &mut self, + member_id: MemberId, + endpoint_id: WebRtcPlayId, + spec: WebRtcPlayEndpointSpec, + ) { + debug!( + "Created sink endpoint with ID '{}' for member '{}' in room with \ + ID '{}'", + endpoint_id, member_id, self.room_id + ); + let member = self.get_member_by_id(&member_id).unwrap(); + + let partner_member = + self.get_member_by_id(&spec.src.member_id).unwrap(); + let src = partner_member.get_src_by_id(&spec.src.endpoint_id).unwrap(); + + let sink = Rc::new(WebRtcPlayEndpoint::new( + endpoint_id, + spec.src, + Rc::downgrade(&src), + Rc::downgrade(&member), + )); + + src.add_sink(Rc::downgrade(&sink)); + member.insert_sink(sink); + } + + pub fn create_src_endpoint( + &mut self, + member_id: MemberId, + endpoint_id: WebRtcPublishId, + spec: WebRtcPublishEndpointSpec, + ) { + debug!( + "Created src endpoint with ID '{}' for member '{}' in room with \ + ID '{}'", + endpoint_id, member_id, self.room_id + ); + let member = self.get_member_by_id(&member_id).unwrap(); + + let src = Rc::new(WebRtcPublishEndpoint::new( + endpoint_id, + spec.p2p, + Vec::new(), + Rc::downgrade(&member), + )); - // for (id, member) in &members { - // let signalling_member = Rc::new(Member::new( - // id.clone(), - // member.credentials().to_string(), - // self.room_id.clone(), - // )); - // for (id, publish) in member.publish_endpoints() { - // let signalling_publish = - // Rc::new(WebRtcPublishEndpoint::new( - // id.clone(), publish.p2p.clone(), - // Vec::new(), - // Rc::downgrade(&signalling_member), - // )); - // signalling_member.insert_src(signalling_publish); - // } - // self.members.insert(id.clone(), signalling_member); - // } - // - // for (id, member) in members { - // let signalling_member = - // self.get_member_by_id(&id).unwrap(); for (id, - // play) in member.play_endpoints() { let - // partner_member = - // self.get_member_by_id(&play.src.member_id).unwrap(); - // let src = partner_member - // .get_src_by_id(&play.src.endpoint_id) - // .unwrap(); - // - // let sink = Rc::new(WebRtcPlayEndpoint::new( - // id.clone(), - // play.src.clone(), - // Rc::downgrade(&src), - // Rc::downgrade(&signalling_member), - // )); - // - // src.add_sink(Rc::downgrade(&sink)); - // signalling_member.insert_sink(sink); - // } - // } + member.insert_src(src); } } diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 634069299..7f5207aea 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -27,8 +27,8 @@ use crate::{ }, local_uri::LocalUri, room::RoomSpec, - MemberId, MemberSpec, RoomId, TryFromElementError, WebRtcPlayId, - WebRtcPublishId, + Endpoint as EndpointSpec, MemberId, MemberSpec, RoomId, + TryFromElementError, WebRtcPlayId, WebRtcPublishId, }, }, log::prelude::*, @@ -881,3 +881,40 @@ impl Handler for Room { Ok(()) } } + +#[derive(Message, Debug)] +#[rtype(result = "Result<(), RoomError>")] +pub struct CreateEndpoint { + pub member_id: MemberId, + pub endpoint_id: String, + pub spec: EndpointSpec, +} + +impl Handler for Room { + type Result = Result<(), RoomError>; + + fn handle( + &mut self, + msg: CreateEndpoint, + ctx: &mut Self::Context, + ) -> Self::Result { + match msg.spec { + EndpointSpec::WebRtcPlay(e) => { + self.members.create_sink_endpoint( + msg.member_id, + WebRtcPlayId(msg.endpoint_id), + e, + ); + } + EndpointSpec::WebRtcPublish(e) => { + self.members.create_src_endpoint( + msg.member_id, + WebRtcPublishId(msg.endpoint_id), + e, + ); + } + } + + Ok(()) + } +} diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs index 275ce069e..a98316924 100644 --- a/src/signalling/room_repo.rs +++ b/src/signalling/room_repo.rs @@ -13,13 +13,13 @@ use hashbrown::HashMap; use crate::{ api::control::{ grpc::protos::control::Element as ElementProto, local_uri::LocalUri, - room::RoomSpec, MemberId, MemberSpec, RoomId, + room::RoomSpec, Endpoint as EndpointSpec, MemberId, MemberSpec, RoomId, }, signalling::{ room::{ - CloseRoom, CreateMember, DeleteEndpoint, DeleteEndpointCheck, - DeleteMember, DeleteMemberCheck, RoomError, Serialize, - SerializeEndpoint, SerializeMember, + CloseRoom, CreateEndpoint, CreateMember, DeleteEndpoint, + DeleteEndpointCheck, DeleteMember, DeleteMemberCheck, RoomError, + Serialize, SerializeEndpoint, SerializeMember, }, Room, }, @@ -456,3 +456,34 @@ impl Handler for RoomsRepository { Ok(()) } } + +#[derive(Message)] +#[rtype(result = "Result<(), RoomRepoError>")] +pub struct CreateEndpointInRoom { + pub room_id: RoomId, + pub member_id: MemberId, + pub endpoint_id: String, + pub spec: EndpointSpec, +} + +impl Handler for RoomsRepository { + type Result = Result<(), RoomRepoError>; + + fn handle( + &mut self, + msg: CreateEndpointInRoom, + ctx: &mut Self::Context, + ) -> Self::Result { + if let Some(room) = self.rooms.lock().unwrap().get(&msg.room_id) { + room.do_send(CreateEndpoint { + member_id: msg.member_id, + endpoint_id: msg.endpoint_id, + spec: msg.spec, + }); + } else { + unimplemented!() + } + + Ok(()) + } +} From 57398d58a3f39f869c4278869e0c0f2d348a75a0 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 10 Jul 2019 14:16:19 +0300 Subject: [PATCH 305/735] Bubbleup errors --- src/signalling/elements/member.rs | 30 +++++++++++++++ src/signalling/participants.rs | 62 ++++++++++++++++++++++++------- src/signalling/room.rs | 60 +++++++++++++++--------------- 3 files changed, 109 insertions(+), 43 deletions(-) diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index 3addb5b27..2df9b9df9 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -50,6 +50,12 @@ impl From for MembersLoadError { } } +#[derive(Debug, Fail)] +pub enum MemberError { + #[fail(display = "Endpoint with ID '{}' not found.", _0)] + EndpointNotFound(String), +} + /// [`Member`] is member of [`Room`] with [`RpcConnection`]. #[derive(Debug)] pub struct Member(RefCell); @@ -268,6 +274,18 @@ impl Member { self.0.borrow().srcs.get(id).cloned() } + pub fn get_src( + &self, + id: &WebRtcPublishId, + ) -> Result, MemberError> { + self.0 + .borrow() + .srcs + .get(id) + .cloned() + .map_or(Err(MemberError::EndpointNotFound(id.to_string())), Ok) + } + /// Lookup [`WebRtcPlayEndpoint`] sink endpoint by [`EndpointId`]. pub fn get_sink_by_id( &self, @@ -276,6 +294,18 @@ impl Member { self.0.borrow().sinks.get(id).cloned() } + pub fn get_sink( + &self, + id: &WebRtcPlayId, + ) -> Result, MemberError> { + self.0 + .borrow() + .sinks + .get(id) + .cloned() + .map_or(Err(MemberError::EndpointNotFound(id.to_string())), Ok) + } + /// Remove sink [`WebRtcPlayEndpoint`] from this [`Member`]. pub fn remove_sink(&self, id: &WebRtcPlayId) { self.0.borrow_mut().sinks.remove(id); diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index b355cb135..cee28a0a4 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -41,8 +41,10 @@ use crate::{ signalling::{ elements::{ endpoints::webrtc::{WebRtcPlayEndpoint, WebRtcPublishEndpoint}, + member::MemberError, parse_members, Member, MembersLoadError, }, + participants::ParticipantServiceErr::ParticipantNotFound, room::{ActFuture, RoomError}, Room, }, @@ -61,6 +63,8 @@ pub enum ParticipantServiceErr { MailBoxErr(MailboxError), #[fail(display = "Participant with Id [{}] was not found", _0)] ParticipantNotFound(MemberId), + #[fail(display = "Endpoint not found.")] + EndpointNotFound(String), } impl From for ParticipantServiceErr { @@ -75,6 +79,16 @@ impl From for ParticipantServiceErr { } } +impl From for ParticipantServiceErr { + fn from(err: MemberError) -> Self { + match err { + MemberError::EndpointNotFound(e) => { + ParticipantServiceErr::EndpointNotFound(e) + } + } + } +} + /// Participant is [`Member`] with [`RpcConnection`]. [`ParticipantService`] /// stores [`Member`]s and associated [`RpcConnection`]s, handles /// [`RpcConnection`] authorization, establishment, message sending. @@ -126,6 +140,16 @@ impl ParticipantService { self.members.get(id).cloned() } + pub fn get_member( + &self, + id: &MemberId, + ) -> Result, ParticipantServiceErr> { + self.members.get(id).cloned().map_or( + Err(ParticipantServiceErr::ParticipantNotFound(id.clone())), + Ok, + ) + } + pub fn members(&self) -> HashMap> { self.members.clone() } @@ -353,7 +377,11 @@ impl ParticipantService { } } - pub fn create_member(&mut self, id: MemberId, spec: MemberSpec) { + pub fn create_member( + &mut self, + id: MemberId, + spec: MemberSpec, + ) -> Result<(), ParticipantServiceErr> { let signalling_member = Rc::new(Member::new( id.clone(), spec.credentials().to_string(), @@ -371,10 +399,8 @@ impl ParticipantService { } for (id, play) in spec.play_endpoints() { - let partner_member = - self.get_member_by_id(&play.src.member_id).unwrap(); - let src = - partner_member.get_src_by_id(&play.src.endpoint_id).unwrap(); + let partner_member = self.get_member(&play.src.member_id)?; + let src = partner_member.get_src(&play.src.endpoint_id)?; let sink = Rc::new(WebRtcPlayEndpoint::new( id.clone(), @@ -383,11 +409,18 @@ impl ParticipantService { Rc::downgrade(&signalling_member), )); - src.add_sink(Rc::downgrade(&sink)); signalling_member.insert_sink(sink); } + // This is needed for atomicity. + for (id, sink) in signalling_member.sinks() { + let src = sink.src(); + src.add_sink(Rc::downgrade(&sink)); + } + self.members.insert(id, signalling_member); + + Ok(()) } pub fn create_sink_endpoint( @@ -395,17 +428,16 @@ impl ParticipantService { member_id: MemberId, endpoint_id: WebRtcPlayId, spec: WebRtcPlayEndpointSpec, - ) { + ) -> Result<(), ParticipantServiceErr> { debug!( "Created sink endpoint with ID '{}' for member '{}' in room with \ ID '{}'", endpoint_id, member_id, self.room_id ); - let member = self.get_member_by_id(&member_id).unwrap(); + let member = self.get_member(&member_id)?; - let partner_member = - self.get_member_by_id(&spec.src.member_id).unwrap(); - let src = partner_member.get_src_by_id(&spec.src.endpoint_id).unwrap(); + let partner_member = self.get_member(&spec.src.member_id)?; + let src = partner_member.get_src(&spec.src.endpoint_id)?; let sink = Rc::new(WebRtcPlayEndpoint::new( endpoint_id, @@ -416,6 +448,8 @@ impl ParticipantService { src.add_sink(Rc::downgrade(&sink)); member.insert_sink(sink); + + Ok(()) } pub fn create_src_endpoint( @@ -423,13 +457,13 @@ impl ParticipantService { member_id: MemberId, endpoint_id: WebRtcPublishId, spec: WebRtcPublishEndpointSpec, - ) { + ) -> Result<(), ParticipantServiceErr> { debug!( "Created src endpoint with ID '{}' for member '{}' in room with \ ID '{}'", endpoint_id, member_id, self.room_id ); - let member = self.get_member_by_id(&member_id).unwrap(); + let member = self.get_member(&member_id)?; let src = Rc::new(WebRtcPublishEndpoint::new( endpoint_id, @@ -439,5 +473,7 @@ impl ParticipantService { )); member.insert_src(src); + + Ok(()) } } diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 7f5207aea..448dbc0eb 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -39,9 +39,10 @@ use crate::{ signalling::{ elements::{ endpoints::webrtc::{WebRtcPlayEndpoint, WebRtcPublishEndpoint}, + member::MemberError, Member, MembersLoadError, }, - participants::ParticipantService, + participants::{ParticipantService, ParticipantServiceErr}, peers::PeerRepository, }, turn::TurnAuthService, @@ -72,6 +73,8 @@ pub enum RoomError { BadRoomSpec(String), #[fail(display = "Turn service error: {}", _0)] TurnServiceError(String), + #[fail(display = "{:?}", _0)] + ParticipantServiceErr(ParticipantServiceErr), } impl From for RoomError { @@ -98,6 +101,22 @@ impl From for RoomError { } } +impl From for RoomError { + fn from(err: ParticipantServiceErr) -> Self { + RoomError::ParticipantServiceErr(err) + } +} + +impl From for RoomError { + fn from(err: MemberError) -> Self { + match err { + MemberError::EndpointNotFound(id) => { + RoomError::EndpointNotFound(id) + } + } + } +} + /// Media server room with its [`Member`]s. #[derive(Debug)] pub struct Room { @@ -779,9 +798,7 @@ impl Handler for Room { msg: DeleteMemberCheck, _ctx: &mut Self::Context, ) -> Self::Result { - if let None = self.members.get_member_by_id(&msg.0) { - panic!() - }; + self.members.get_member(&msg.0)?; Ok(()) } @@ -802,7 +819,7 @@ impl Handler for Room { msg: DeleteEndpoint, ctx: &mut Self::Context, ) -> Self::Result { - let member = self.members.get_member_by_id(&msg.member_id).unwrap(); + let member = self.members.get_member(&msg.member_id).unwrap(); let play_id = WebRtcPlayId(msg.endpoint_id); if let Some(endpoint) = member.take_sink(&play_id) { if let Some(peer_id) = endpoint.peer_id() { @@ -833,33 +850,16 @@ impl Handler for Room { msg: DeleteEndpointCheck, _ctx: &mut Self::Context, ) -> Self::Result { - let member = match self.members.get_member_by_id(&msg.member_id) { - Some(m) => m, - None => panic!(), - }; + let member = self.members.get_member(&msg.member_id)?; + let play_id = WebRtcPlayId(msg.endpoint_id); - if let Some(endpoint) = member.get_sink_by_id(&play_id) { - if let Some(peer_id) = endpoint.peer_id() { - if let Err(_) = self.peers.get_peer(peer_id) { - return Ok(()); - } - } else { - panic!() - } + if let Some(_) = member.get_sink_by_id(&play_id) { + return Ok(()); } let publish_id = WebRtcPublishId(play_id.0); - if let Some(endpoint) = member.get_src_by_id(&publish_id) { - let peer_ids = endpoint.peer_ids(); - for peer_id in peer_ids { - if let Err(_) = self.peers.get_peer(peer_id) { - panic!() - } - } - } else { - panic!() - } + member.get_src(&publish_id)?; Ok(()) } @@ -877,7 +877,7 @@ impl Handler for Room { msg: CreateMember, ctx: &mut Self::Context, ) -> Self::Result { - self.members.create_member(msg.0, msg.1); + self.members.create_member(msg.0, msg.1)?; Ok(()) } } @@ -904,14 +904,14 @@ impl Handler for Room { msg.member_id, WebRtcPlayId(msg.endpoint_id), e, - ); + )?; } EndpointSpec::WebRtcPublish(e) => { self.members.create_src_endpoint( msg.member_id, WebRtcPublishId(msg.endpoint_id), e, - ); + )?; } } From 67f5193787754135a9e46716be83bf5f46cf567f Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 10 Jul 2019 15:13:08 +0300 Subject: [PATCH 306/735] Prepare for Create error handling --- src/api/control/grpc/server.rs | 265 ++++++++++++++++++++++----------- src/signalling/room_repo.rs | 53 ++++--- 2 files changed, 208 insertions(+), 110 deletions(-) diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index b8c629b49..e0d0c817d 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -1,6 +1,6 @@ use std::{collections::HashMap, convert::TryFrom, sync::Arc}; -use actix::{Actor, Addr, Arbiter, Context}; +use actix::{Actor, Addr, Arbiter, Context, MailboxError}; use failure::Fail; use futures::future::{Either, Future}; use grpcio::{Environment, RpcContext, Server, ServerBuilder, UnarySink}; @@ -25,8 +25,12 @@ use crate::{ use super::protos::control_grpc::{create_control_api, ControlApi}; use crate::{ api::control::{Endpoint, MemberSpec}, - signalling::room_repo::{ - CreateEndpointInRoom, CreateMemberInRoom, DeleteRoomCheck, + signalling::{ + room::RoomError, + room_repo::{ + CreateEndpointInRoom, CreateMemberInRoom, DeleteRoomCheck, + RoomRepoError, + }, }, }; @@ -38,6 +42,8 @@ enum ControlApiError { TryFromProtobuf(TryFromProtobufError), #[fail(display = "{:?}", _0)] TryFromElement(TryFromElementError), + #[fail(display = "{:?}", _0)] + MailboxError(MailboxError), } impl From for ControlApiError { @@ -58,6 +64,25 @@ impl From for ControlApiError { } } +impl From for ControlApiError { + fn from(from: MailboxError) -> Self { + ControlApiError::MailboxError(from) + } +} + +macro_rules! fut_try { + ($call:expr) => { + match $call { + Ok(o) => o, + Err(e) => { + return Either::B(futures::future::err(ControlApiError::from( + e, + ))) + } + } + }; +} + #[derive(Clone)] struct ControlApiService { room_repository: Addr, @@ -68,18 +93,23 @@ impl ControlApiService { pub fn create_room( &mut self, req: CreateRequest, - ) -> Result< - impl Future, Error = ()>, - ControlApiError, + ) -> impl Future< + Item = Result< + Result, RoomError>, + RoomRepoError, + >, + Error = ControlApiError, > { - let local_uri = LocalUri::parse(req.get_id())?; + let local_uri = fut_try!(LocalUri::parse(req.get_id())); + let room_id = local_uri.room_id.unwrap(); - let room = - RoomSpec::try_from_protobuf(room_id.clone(), req.get_room())?; + let room = fut_try!(RoomSpec::try_from_protobuf( + room_id.clone(), + req.get_room() + )); - let sid: HashMap = room - .members()? + let sid: HashMap = fut_try!(room.members()) .iter() .map(|(id, member)| { let addr = &self.app.config.server.bind_ip; @@ -99,11 +129,60 @@ impl ControlApiService { .collect(); // TODO: errors from `SendRoom` not bubbled up. - Ok(self - .room_repository - .send(StartRoom(room_id, room)) - .map_err(|e| error!("Start room mailbox error. {:?}", e)) - .map(move |_| sid)) + Either::A( + self.room_repository + .send(StartRoom(room_id, room)) + .map_err(|e| ControlApiError::from(e)) + .map(move |_| Ok(Ok(sid))), + ) + } + + pub fn create_member( + &mut self, + req: CreateRequest, + ) -> impl Future< + Item = Result< + Result, RoomError>, + RoomRepoError, + >, + Error = ControlApiError, + > { + let local_uri = LocalUri::parse(req.get_id()).unwrap(); + + let member_spec = MemberSpec::try_from(req.get_member()).unwrap(); + + self.room_repository + .send(CreateMemberInRoom { + room_id: local_uri.room_id.unwrap(), + member_id: local_uri.member_id.unwrap(), + spec: member_spec, + }) + .map_err(|e| ControlApiError::from(e)) + .map(|r| r.map(|r| r.map(|r| HashMap::new()))) + } + + pub fn create_endpoint( + &mut self, + req: CreateRequest, + ) -> impl Future< + Item = Result< + Result, RoomError>, + RoomRepoError, + >, + Error = ControlApiError, + > { + let local_uri = LocalUri::parse(req.get_id()).unwrap(); + + let endpoint = Endpoint::try_from(&req).unwrap(); + self.room_repository + .send(CreateEndpointInRoom { + room_id: local_uri.room_id.unwrap(), + member_id: local_uri.member_id.unwrap(), + endpoint_id: local_uri.endpoint_id.unwrap(), + spec: endpoint, + }) + .map_err(|e| ControlApiError::from(e)) + .map(|r| r.map(|r| r.map(|r| HashMap::new()))) } } @@ -116,81 +195,87 @@ impl ControlApi for ControlApiService { ) { let local_uri = LocalUri::parse(req.get_id()).unwrap(); - let create = { - if local_uri.is_room_uri() { - self.create_room(req) - } else if local_uri.is_member_uri() { - let member_spec = - MemberSpec::try_from(req.get_member()).unwrap(); - self.room_repository.do_send(CreateMemberInRoom { - room_id: local_uri.room_id.unwrap(), - member_id: local_uri.member_id.unwrap(), - spec: member_spec, - }); - - return; - } else if local_uri.is_endpoint_uri() { - let endpoint = Endpoint::try_from(&req).unwrap(); - self.room_repository.do_send(CreateEndpointInRoom { - room_id: local_uri.room_id.unwrap(), - member_id: local_uri.member_id.unwrap(), - endpoint_id: local_uri.endpoint_id.unwrap(), - spec: endpoint, - }); - - return; - } else { - unimplemented!() - } - }; - - match create { - Ok(fut) => ctx.spawn(fut.and_then(move |r| { - let mut response = Response::new(); - response.set_sid(r); - sink.success(response).map_err(|_| ()) - })), - Err(e) => { - let mut res = Response::new(); - let mut error = Error::new(); - - match e { - ControlApiError::TryFromProtobuf(e) => match e { - TryFromProtobufError::MemberElementNotFound - | TryFromProtobufError::MemberCredentialsNotFound - | TryFromProtobufError::P2pModeNotFound - | TryFromProtobufError::SrcUriNotFound - | TryFromProtobufError::RoomElementNotFound => { - error.set_status(404); - error.set_code(0); - error.set_text(e.to_string()); - error.set_element(String::new()); - } - TryFromProtobufError::SrcUriError(e) => { - error.set_status(400); - error.set_code(0); - error.set_text(e.to_string()); - error.set_element(String::new()); - } - }, - ControlApiError::TryFromElement(e) => { - error.set_status(400); - error.set_code(0); - error.set_text(e.to_string()); - error.set_element(String::new()); - } - ControlApiError::LocalUri(e) => { - error.set_status(400); - error.set_code(0); - error.set_text(e.to_string()); - error.set_element(String::new()); - } - } - - res.set_error(error); - ctx.spawn(sink.success(res).map_err(|_| ())); - } + if local_uri.is_room_uri() { + ctx.spawn(self.create_room(req).map_err(|_| ()).and_then( + move |r| { + let mut response = Response::new(); + response.set_sid(r.unwrap().unwrap()); + sink.success(response).map_err(|_| ()) + }, + )); + } else if local_uri.is_member_uri() { + ctx.spawn(self.create_member(req).map_err(|_| ()).and_then( + move |r| { + let mut response = Response::new(); + response.set_sid(r.unwrap().unwrap()); + sink.success(response).map_err(|_| ()) + }, + )); + } else if local_uri.is_endpoint_uri() { + ctx.spawn(self.create_endpoint(req).map_err(|_| ()).and_then( + move |r| { + let mut response = Response::new(); + response.set_sid(r.unwrap().unwrap()); + sink.success(response).map_err(|_| ()) + }, + )); + } else { + unimplemented!() } + + // ctx.spawn(create.and_then(move |r| { + // let mut response = Response::new(); + // response.set_sid(r.unwrap().unwrap()); + // sink.success(response).map_err(|_| ()) + // })); + + // match create { + // Ok(fut) => ctx.spawn(fut.and_then(move |r| { + // let mut response = Response::new(); + // response.set_sid(r); + // sink.success(response).map_err(|_| ()) + // })), + // Err(e) => { + // let mut res = Response::new(); + // let mut error = Error::new(); + // + // match e { + // ControlApiError::TryFromProtobuf(e) => match e { + // TryFromProtobufError::MemberElementNotFound + // | + // TryFromProtobufError::MemberCredentialsNotFound + // | TryFromProtobufError::P2pModeNotFound + // | TryFromProtobufError::SrcUriNotFound + // | TryFromProtobufError::RoomElementNotFound => { + // error.set_status(404); + // error.set_code(0); + // error.set_text(e.to_string()); + // error.set_element(String::new()); } + // TryFromProtobufError::SrcUriError(e) => { + // error.set_status(400); + // error.set_code(0); + // error.set_text(e.to_string()); + // error.set_element(String::new()); + // } + // }, + // ControlApiError::TryFromElement(e) => { + // error.set_status(400); + // error.set_code(0); + // error.set_text(e.to_string()); + // error.set_element(String::new()); + // } + // ControlApiError::LocalUri(e) => { + // error.set_status(400); + // error.set_code(0); + // error.set_text(e.to_string()); + // error.set_element(String::new()); + // } + // } + // + // res.set_error(error); + // ctx.spawn(sink.success(res).map_err(|_| ())); + // } + // } } fn apply( diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs index a98316924..1442d1a01 100644 --- a/src/signalling/room_repo.rs +++ b/src/signalling/room_repo.rs @@ -433,7 +433,7 @@ impl Handler for RoomsRepository { } #[derive(Message)] -#[rtype(result = "Result<(), RoomRepoError>")] +#[rtype(result = "Result, RoomRepoError>")] pub struct CreateMemberInRoom { pub room_id: RoomId, pub member_id: MemberId, @@ -441,24 +441,31 @@ pub struct CreateMemberInRoom { } impl Handler for RoomsRepository { - type Result = Result<(), RoomRepoError>; + type Result = ActFuture, RoomRepoError>; fn handle( &mut self, msg: CreateMemberInRoom, ctx: &mut Self::Context, ) -> Self::Result { - if let Some(room) = self.rooms.lock().unwrap().get(&msg.room_id) { - room.do_send(CreateMember(msg.member_id, msg.spec)); - } else { - unimplemented!() - } - Ok(()) + let fut = + if let Some(room) = self.rooms.lock().unwrap().get(&msg.room_id) { + Either::A( + room.send(CreateMember(msg.member_id, msg.spec)) + .map_err(|e| RoomRepoError::from(e)), + ) + } else { + Either::B(futures::future::err(RoomRepoError::RoomNotFound( + msg.room_id, + ))) + }; + + Box::new(wrap_future(fut)) } } #[derive(Message)] -#[rtype(result = "Result<(), RoomRepoError>")] +#[rtype(result = "Result, RoomRepoError>")] pub struct CreateEndpointInRoom { pub room_id: RoomId, pub member_id: MemberId, @@ -467,23 +474,29 @@ pub struct CreateEndpointInRoom { } impl Handler for RoomsRepository { - type Result = Result<(), RoomRepoError>; + type Result = ActFuture, RoomRepoError>; fn handle( &mut self, msg: CreateEndpointInRoom, ctx: &mut Self::Context, ) -> Self::Result { - if let Some(room) = self.rooms.lock().unwrap().get(&msg.room_id) { - room.do_send(CreateEndpoint { - member_id: msg.member_id, - endpoint_id: msg.endpoint_id, - spec: msg.spec, - }); - } else { - unimplemented!() - } + let fut = + if let Some(room) = self.rooms.lock().unwrap().get(&msg.room_id) { + Either::A( + room.send(CreateEndpoint { + member_id: msg.member_id, + endpoint_id: msg.endpoint_id, + spec: msg.spec, + }) + .map_err(|e| RoomRepoError::from(e)), + ) + } else { + Either::B(futures::future::err(RoomRepoError::RoomNotFound( + msg.room_id, + ))) + }; - Ok(()) + Box::new(wrap_future(fut)) } } From a2dfa78c5fca8b19e860e986bbb009e0781bd3ca Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 10 Jul 2019 16:46:13 +0300 Subject: [PATCH 307/735] Implement error handling for Create method --- src/api/control/grpc/server.rs | 158 ++++++++++++++++++--------------- src/bin/client.rs | 6 +- src/signalling/room_repo.rs | 1 + 3 files changed, 92 insertions(+), 73 deletions(-) diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index e0d0c817d..578b0df8d 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -26,6 +26,7 @@ use super::protos::control_grpc::{create_control_api, ControlApi}; use crate::{ api::control::{Endpoint, MemberSpec}, signalling::{ + participants::ParticipantServiceErr, room::RoomError, room_repo::{ CreateEndpointInRoom, CreateMemberInRoom, DeleteRoomCheck, @@ -158,7 +159,10 @@ impl ControlApiService { spec: member_spec, }) .map_err(|e| ControlApiError::from(e)) - .map(|r| r.map(|r| r.map(|r| HashMap::new()))) + .map(|r| { + println!("{:?}", r); + r.map(|r| r.map(|r| HashMap::new())) + }) } pub fn create_endpoint( @@ -186,6 +190,77 @@ impl ControlApiService { } } +fn create_response( + result: Result, RoomError>, RoomRepoError>, +) -> Response { + let mut error = Error::new(); + + match result { + Ok(r) => match r { + Ok(sid) => { + let mut response = Response::new(); + response.set_sid(sid); + return response; + } + Err(e) => match &e { + RoomError::EndpointNotFound(id) => { + error.set_element(id.to_string()); // TODO + error.set_code(0); // TODO + error.set_status(404); + error.set_text(e.to_string()); + } + RoomError::MemberNotFound(id) => { + error.set_element(id.to_string()); // TODO + error.set_code(0); // TODO + error.set_status(404); + error.set_text(e.to_string()); + } + RoomError::ParticipantServiceErr(e) => match e { + ParticipantServiceErr::EndpointNotFound(id) => { + error.set_element(id.to_string()); // TODO + error.set_code(0); // TODO + error.set_status(404); + error.set_text(e.to_string()); + } + _ => { + error.set_element(String::new()); + error.set_code(0); // TODO + error.set_status(500); + error.set_text(format!( + "Unknow ParticipantService error. {:?}", + e + )); + } + }, + _ => { + error.set_element(String::new()); + error.set_code(0); // TODO + error.set_status(500); + error.set_text(format!("Unknow RoomError error. {:?}", e)); + } + }, + }, + Err(e) => match &e { + RoomRepoError::RoomNotFound(id) => { + error.set_element(id.to_string()); + error.set_code(0); // TODO + error.set_status(404); + error.set_text(e.to_string()); + } + _ => { + error.set_element(String::new()); + error.set_code(0); // TODO + error.set_status(500); + error.set_text(format!("Unknow RoomRepo error. {:?}", e)); + } + }, + } + + let mut error_response = Response::new(); + error_response.set_error(error); + error_response +} + impl ControlApi for ControlApiService { fn create( &mut self, @@ -197,85 +272,26 @@ impl ControlApi for ControlApiService { if local_uri.is_room_uri() { ctx.spawn(self.create_room(req).map_err(|_| ()).and_then( - move |r| { - let mut response = Response::new(); - response.set_sid(r.unwrap().unwrap()); - sink.success(response).map_err(|_| ()) - }, + move |r| sink.success(create_response(r)).map_err(|_| ()), )); } else if local_uri.is_member_uri() { ctx.spawn(self.create_member(req).map_err(|_| ()).and_then( - move |r| { - let mut response = Response::new(); - response.set_sid(r.unwrap().unwrap()); - sink.success(response).map_err(|_| ()) - }, + move |r| sink.success(create_response(r)).map_err(|_| ()), )); } else if local_uri.is_endpoint_uri() { ctx.spawn(self.create_endpoint(req).map_err(|_| ()).and_then( - move |r| { - let mut response = Response::new(); - response.set_sid(r.unwrap().unwrap()); - sink.success(response).map_err(|_| ()) - }, + move |r| sink.success(create_response(r)).map_err(|_| ()), )); } else { - unimplemented!() + let mut error_response = Response::new(); + let mut error = Error::new(); + error.set_status(400); + error.set_code(0); + error.set_text(format!("Invalid ID '{}'.", req.get_id())); + error.set_element(local_uri.to_string()); + error_response.set_error(error); + ctx.spawn(sink.success(error_response).map_err(|_| ())); } - - // ctx.spawn(create.and_then(move |r| { - // let mut response = Response::new(); - // response.set_sid(r.unwrap().unwrap()); - // sink.success(response).map_err(|_| ()) - // })); - - // match create { - // Ok(fut) => ctx.spawn(fut.and_then(move |r| { - // let mut response = Response::new(); - // response.set_sid(r); - // sink.success(response).map_err(|_| ()) - // })), - // Err(e) => { - // let mut res = Response::new(); - // let mut error = Error::new(); - // - // match e { - // ControlApiError::TryFromProtobuf(e) => match e { - // TryFromProtobufError::MemberElementNotFound - // | - // TryFromProtobufError::MemberCredentialsNotFound - // | TryFromProtobufError::P2pModeNotFound - // | TryFromProtobufError::SrcUriNotFound - // | TryFromProtobufError::RoomElementNotFound => { - // error.set_status(404); - // error.set_code(0); - // error.set_text(e.to_string()); - // error.set_element(String::new()); } - // TryFromProtobufError::SrcUriError(e) => { - // error.set_status(400); - // error.set_code(0); - // error.set_text(e.to_string()); - // error.set_element(String::new()); - // } - // }, - // ControlApiError::TryFromElement(e) => { - // error.set_status(400); - // error.set_code(0); - // error.set_text(e.to_string()); - // error.set_element(String::new()); - // } - // ControlApiError::LocalUri(e) => { - // error.set_status(400); - // error.set_code(0); - // error.set_text(e.to_string()); - // error.set_element(String::new()); - // } - // } - // - // res.set_error(error); - // ctx.spawn(sink.success(res).map_err(|_| ())); - // } - // } } fn apply( diff --git a/src/bin/client.rs b/src/bin/client.rs index 9c1c470a2..45069ee7a 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -85,7 +85,8 @@ fn create_member(client: &ControlApiClient) { create_member_request.set_id("local://grpc-test/player".to_string()); create_member_request.set_member(member); - let reply = client.create(&create_member_request); + let reply = client.create(&create_member_request).unwrap(); + println!("{:?}", reply) } fn create_endpoint(client: &ControlApiClient) { @@ -96,7 +97,8 @@ fn create_endpoint(client: &ControlApiClient) { .set_id("local://grpc-test/player/create-publish".to_string()); create_endpoint_request.set_webrtc_pub(endpoint); - client.create(&create_endpoint_request); + let reply = client.create(&create_endpoint_request).unwrap(); + println!("{:?}", reply); } fn delete_room(client: &ControlApiClient) { diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs index 1442d1a01..dca7425fc 100644 --- a/src/signalling/room_repo.rs +++ b/src/signalling/room_repo.rs @@ -455,6 +455,7 @@ impl Handler for RoomsRepository { .map_err(|e| RoomRepoError::from(e)), ) } else { + println!("jhfkljdshfajdshf"); Either::B(futures::future::err(RoomRepoError::RoomNotFound( msg.room_id, ))) From 706554b2f3722a6b452488e076f9455551224c5d Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 10 Jul 2019 17:02:04 +0300 Subject: [PATCH 308/735] Improve error handling for Create --- src/api/control/grpc/server.rs | 130 ++++++++++++++++++++++----------- src/signalling/room_repo.rs | 1 - 2 files changed, 86 insertions(+), 45 deletions(-) diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index 578b0df8d..923eac3ef 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -94,6 +94,7 @@ impl ControlApiService { pub fn create_room( &mut self, req: CreateRequest, + local_uri: LocalUri, ) -> impl Future< Item = Result< Result, RoomError>, @@ -101,8 +102,6 @@ impl ControlApiService { >, Error = ControlApiError, > { - let local_uri = fut_try!(LocalUri::parse(req.get_id())); - let room_id = local_uri.room_id.unwrap(); let room = fut_try!(RoomSpec::try_from_protobuf( @@ -141,6 +140,7 @@ impl ControlApiService { pub fn create_member( &mut self, req: CreateRequest, + local_uri: LocalUri, ) -> impl Future< Item = Result< Result, RoomError>, @@ -148,26 +148,24 @@ impl ControlApiService { >, Error = ControlApiError, > { - let local_uri = LocalUri::parse(req.get_id()).unwrap(); + let member_spec = fut_try!(MemberSpec::try_from(req.get_member())); - let member_spec = MemberSpec::try_from(req.get_member()).unwrap(); - - self.room_repository - .send(CreateMemberInRoom { - room_id: local_uri.room_id.unwrap(), - member_id: local_uri.member_id.unwrap(), - spec: member_spec, - }) - .map_err(|e| ControlApiError::from(e)) - .map(|r| { - println!("{:?}", r); - r.map(|r| r.map(|r| HashMap::new())) - }) + Either::A( + self.room_repository + .send(CreateMemberInRoom { + room_id: local_uri.room_id.unwrap(), + member_id: local_uri.member_id.unwrap(), + spec: member_spec, + }) + .map_err(|e| ControlApiError::from(e)) + .map(|r| r.map(|r| r.map(|r| HashMap::new()))), + ) } pub fn create_endpoint( &mut self, req: CreateRequest, + local_uri: LocalUri, ) -> impl Future< Item = Result< Result, RoomError>, @@ -175,18 +173,18 @@ impl ControlApiService { >, Error = ControlApiError, > { - let local_uri = LocalUri::parse(req.get_id()).unwrap(); - - let endpoint = Endpoint::try_from(&req).unwrap(); - self.room_repository - .send(CreateEndpointInRoom { - room_id: local_uri.room_id.unwrap(), - member_id: local_uri.member_id.unwrap(), - endpoint_id: local_uri.endpoint_id.unwrap(), - spec: endpoint, - }) - .map_err(|e| ControlApiError::from(e)) - .map(|r| r.map(|r| r.map(|r| HashMap::new()))) + let endpoint = fut_try!(Endpoint::try_from(&req)); + Either::A( + self.room_repository + .send(CreateEndpointInRoom { + room_id: local_uri.room_id.unwrap(), + member_id: local_uri.member_id.unwrap(), + endpoint_id: local_uri.endpoint_id.unwrap(), + spec: endpoint, + }) + .map_err(|e| ControlApiError::from(e)) + .map(|r| r.map(|r| r.map(|r| HashMap::new()))), + ) } } @@ -271,17 +269,68 @@ impl ControlApi for ControlApiService { let local_uri = LocalUri::parse(req.get_id()).unwrap(); if local_uri.is_room_uri() { - ctx.spawn(self.create_room(req).map_err(|_| ()).and_then( - move |r| sink.success(create_response(r)).map_err(|_| ()), - )); + if req.has_room() { + ctx.spawn( + self.create_room(req, local_uri).map_err(|_| ()).and_then( + move |r| { + sink.success(create_response(r)).map_err(|_| ()) + }, + ), + ); + } else { + let mut error_response = Response::new(); + let mut error = Error::new(); + error.set_status(400); + error.set_code(0); + error.set_text( + "ID for room but element is not room.".to_string(), + ); + error.set_element(String::new()); + error_response.set_error(error); + ctx.spawn(sink.success(error_response).map_err(|_| ())); + } } else if local_uri.is_member_uri() { - ctx.spawn(self.create_member(req).map_err(|_| ()).and_then( - move |r| sink.success(create_response(r)).map_err(|_| ()), - )); + if req.has_member() { + ctx.spawn( + self.create_member(req, local_uri) + .map_err(|_| ()) + .and_then(move |r| { + sink.success(create_response(r)).map_err(|_| ()) + }), + ); + } else { + let mut error_response = Response::new(); + let mut error = Error::new(); + error.set_status(400); + error.set_code(0); + error.set_text( + "ID for member but element is not member.".to_string(), + ); + error.set_element(String::new()); + error_response.set_error(error); + ctx.spawn(sink.success(error_response).map_err(|_| ())); + } } else if local_uri.is_endpoint_uri() { - ctx.spawn(self.create_endpoint(req).map_err(|_| ()).and_then( - move |r| sink.success(create_response(r)).map_err(|_| ()), - )); + if req.has_webrtc_pub() || req.has_webrtc_play() { + ctx.spawn( + self.create_endpoint(req, local_uri) + .map_err(|_| ()) + .and_then(move |r| { + sink.success(create_response(r)).map_err(|_| ()) + }), + ); + } else { + let mut error_response = Response::new(); + let mut error = Error::new(); + error.set_status(400); + error.set_code(0); + error.set_text( + "ID for endpoint but element is not endpoint.".to_string(), + ); + error.set_element(String::new()); + error_response.set_error(error); + ctx.spawn(sink.success(error_response).map_err(|_| ())); + } } else { let mut error_response = Response::new(); let mut error = Error::new(); @@ -397,13 +446,6 @@ impl ControlApi for ControlApiService { }) }), ); - - // let mut resp = Response::new(); - // resp.set_sid(HashMap::new()); - // ctx.spawn( - // sink.success(resp) - // .map_err(|e| error!("gRPC response failed. {:?}", e)), - // ); } fn get( diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs index dca7425fc..1442d1a01 100644 --- a/src/signalling/room_repo.rs +++ b/src/signalling/room_repo.rs @@ -455,7 +455,6 @@ impl Handler for RoomsRepository { .map_err(|e| RoomRepoError::from(e)), ) } else { - println!("jhfkljdshfajdshf"); Either::B(futures::future::err(RoomRepoError::RoomNotFound( msg.room_id, ))) From 5af9efc86bc700a9acfc6ea8e53326d43facaf5c Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 10 Jul 2019 17:15:16 +0300 Subject: [PATCH 309/735] Return local uri in EndpointNotFound --- src/api/control/local_uri.rs | 13 ++++++++++++ src/signalling/elements/member.rs | 34 +++++++++++++++++++------------ src/signalling/participants.rs | 3 ++- src/signalling/room.rs | 13 +++++------- 4 files changed, 41 insertions(+), 22 deletions(-) diff --git a/src/api/control/local_uri.rs b/src/api/control/local_uri.rs index edb618f93..3c69c3ed5 100644 --- a/src/api/control/local_uri.rs +++ b/src/api/control/local_uri.rs @@ -12,6 +12,7 @@ pub enum LocalUriParseError { TooManyFields(usize), } +#[derive(Debug)] pub struct LocalUri { /// ID of [`Room`] pub room_id: Option, @@ -22,6 +23,18 @@ pub struct LocalUri { } impl LocalUri { + pub fn new( + room_id: Option, + member_id: Option, + endpoint_id: Option, + ) -> Self { + Self { + room_id, + member_id, + endpoint_id, + } + } + pub fn parse(value: &str) -> Result { let protocol_name: String = value.chars().take(8).collect(); if protocol_name != "local://" { diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index 2df9b9df9..df94b008e 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -53,7 +53,7 @@ impl From for MembersLoadError { #[derive(Debug, Fail)] pub enum MemberError { #[fail(display = "Endpoint with ID '{}' not found.", _0)] - EndpointNotFound(String), + EndpointNotFound(LocalUri), } /// [`Member`] is member of [`Room`] with [`RpcConnection`]. @@ -274,16 +274,22 @@ impl Member { self.0.borrow().srcs.get(id).cloned() } + fn get_local_uri(&self) -> LocalUri { + LocalUri::new(Some(self.room_id()), Some(self.id()), None) + } + pub fn get_src( &self, id: &WebRtcPublishId, ) -> Result, MemberError> { - self.0 - .borrow() - .srcs - .get(id) - .cloned() - .map_or(Err(MemberError::EndpointNotFound(id.to_string())), Ok) + self.0.borrow().srcs.get(id).cloned().map_or_else( + || { + let mut local_uri = self.get_local_uri(); + local_uri.endpoint_id = Some(id.to_string()); + Err(MemberError::EndpointNotFound(local_uri)) + }, + Ok, + ) } /// Lookup [`WebRtcPlayEndpoint`] sink endpoint by [`EndpointId`]. @@ -298,12 +304,14 @@ impl Member { &self, id: &WebRtcPlayId, ) -> Result, MemberError> { - self.0 - .borrow() - .sinks - .get(id) - .cloned() - .map_or(Err(MemberError::EndpointNotFound(id.to_string())), Ok) + self.0.borrow().sinks.get(id).cloned().map_or_else( + || { + let mut local_uri = self.get_local_uri(); + local_uri.endpoint_id = Some(id.to_string()); + Err(MemberError::EndpointNotFound(local_uri)) + }, + Ok, + ) } /// Remove sink [`WebRtcPlayEndpoint`] from this [`Member`]. diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index cee28a0a4..8e4ca4b2f 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -32,6 +32,7 @@ use crate::{ webrtc_play_endpoint::WebRtcPlayEndpoint as WebRtcPlayEndpointSpec, webrtc_publish_endpoint::WebRtcPublishEndpoint as WebRtcPublishEndpointSpec, }, + local_uri::LocalUri, MemberId, MemberSpec, RoomId, RoomSpec, WebRtcPlayId, WebRtcPublishId, }, @@ -64,7 +65,7 @@ pub enum ParticipantServiceErr { #[fail(display = "Participant with Id [{}] was not found", _0)] ParticipantNotFound(MemberId), #[fail(display = "Endpoint not found.")] - EndpointNotFound(String), + EndpointNotFound(LocalUri), } impl From for ParticipantServiceErr { diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 448dbc0eb..9124a3183 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -60,7 +60,7 @@ pub enum RoomError { #[fail(display = "Couldn't find Member with [id = {}]", _0)] MemberNotFound(MemberId), #[fail(display = "Endpoint with ID '{}' not found.", _0)] - EndpointNotFound(String), + EndpointNotFound(LocalUri), #[fail(display = "Member [id = {}] does not have Turn credentials", _0)] NoTurnCredentials(MemberId), #[fail(display = "Couldn't find RpcConnection with Member [id = {}]", _0)] @@ -572,13 +572,10 @@ impl Handler for Room { } else { let endpoint_id = WebRtcPlayId(endpoint_id.0); - if let Some(endpoint) = member.get_sink_by_id(&endpoint_id) { - let mut member_element: Member_Element = endpoint.into(); - let endpoint = member_element.take_webrtc_play(); - element.set_webrtc_play(endpoint); - } else { - return Err(RoomError::EndpointNotFound(endpoint_id.0)); - } + let endpoint = member.get_sink(&endpoint_id)?; + let mut member_element: Member_Element = endpoint.into(); + let endpoint = member_element.take_webrtc_play(); + element.set_webrtc_play(endpoint); } Ok(element) From 96daff178852e36503c425c944bf2cd33de5bb8b Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 10 Jul 2019 17:26:32 +0300 Subject: [PATCH 310/735] Return local uri in ParticipantNotFound --- src/api/control/grpc/server.rs | 12 ++++++------ src/signalling/participants.rs | 14 +++++++++++--- src/signalling/room.rs | 22 +++++++--------------- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index 923eac3ef..8c902d0bf 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -207,12 +207,6 @@ fn create_response( error.set_status(404); error.set_text(e.to_string()); } - RoomError::MemberNotFound(id) => { - error.set_element(id.to_string()); // TODO - error.set_code(0); // TODO - error.set_status(404); - error.set_text(e.to_string()); - } RoomError::ParticipantServiceErr(e) => match e { ParticipantServiceErr::EndpointNotFound(id) => { error.set_element(id.to_string()); // TODO @@ -220,6 +214,12 @@ fn create_response( error.set_status(404); error.set_text(e.to_string()); } + ParticipantServiceErr::ParticipantNotFound(id) => { + error.set_element(id.to_string()); // TODO + error.set_code(0); // TODO + error.set_status(404); + error.set_text(e.to_string()); + } _ => { error.set_element(String::new()); error.set_code(0); // TODO diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 8e4ca4b2f..22a38ad66 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -63,7 +63,7 @@ pub enum ParticipantServiceErr { )] MailBoxErr(MailboxError), #[fail(display = "Participant with Id [{}] was not found", _0)] - ParticipantNotFound(MemberId), + ParticipantNotFound(LocalUri), #[fail(display = "Endpoint not found.")] EndpointNotFound(LocalUri), } @@ -141,12 +141,18 @@ impl ParticipantService { self.members.get(id).cloned() } + fn get_local_uri(&self, member_id: MemberId) -> LocalUri { + LocalUri::new(Some(self.room_id.clone()), Some(member_id), None) + } + pub fn get_member( &self, id: &MemberId, ) -> Result, ParticipantServiceErr> { self.members.get(id).cloned().map_or( - Err(ParticipantServiceErr::ParticipantNotFound(id.clone())), + Err(ParticipantServiceErr::ParticipantNotFound( + self.get_local_uri(id.clone()), + )), Ok, ) } @@ -212,7 +218,9 @@ impl ParticipantService { let member = match self.get_member_by_id(&member_id) { None => { return Box::new(wrap_future(future::err( - ParticipantServiceErr::ParticipantNotFound(member_id), + ParticipantServiceErr::ParticipantNotFound( + self.get_local_uri(member_id), + ), ))); } Some(member) => member, diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 9124a3183..5bbff7642 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -57,8 +57,6 @@ pub type ActFuture = pub enum RoomError { #[fail(display = "Couldn't find Peer with [id = {}]", _0)] PeerNotFound(PeerId), - #[fail(display = "Couldn't find Member with [id = {}]", _0)] - MemberNotFound(MemberId), #[fail(display = "Endpoint with ID '{}' not found.", _0)] EndpointNotFound(LocalUri), #[fail(display = "Member [id = {}] does not have Turn credentials", _0)] @@ -188,10 +186,11 @@ impl Room { let member_id = sender.member_id(); let ice_servers = self .members - .get_member_by_id(&member_id) - .ok_or_else(|| RoomError::MemberNotFound(member_id.clone()))? + .get_member(&member_id)? .servers_list() - .ok_or_else(|| RoomError::NoTurnCredentials(member_id.clone()))?; + .ok_or_else(|| { + RoomError::NoTurnCredentials(member_id.clone()) + })?; let peer_created = Event::PeerCreated { peer_id: sender.id(), sdp_offer: None, @@ -236,8 +235,7 @@ impl Room { let to_member_id = to_peer.member_id(); let ice_servers = self .members - .get_member_by_id(&to_member_id) - .ok_or_else(|| RoomError::MemberNotFound(to_member_id.clone()))? + .get_member(&to_member_id)? .servers_list() .ok_or_else(|| { RoomError::NoTurnCredentials(to_member_id.clone()) @@ -530,10 +528,7 @@ impl Handler for Room { msg: SerializeMember, _ctx: &mut Self::Context, ) -> Self::Result { - let member = self - .members - .get_member_by_id(&msg.0) - .map_or(Err(RoomError::MemberNotFound(msg.0)), Ok)?; + let member = self.members.get_member(&msg.0)?; let mut member_element: Room_Element = member.into(); let member = member_element.take_member(); @@ -557,10 +552,7 @@ impl Handler for Room { msg: SerializeEndpoint, _ctx: &mut Self::Context, ) -> Self::Result { - let member = self - .members - .get_member_by_id(&msg.0) - .map_or(Err(RoomError::MemberNotFound(msg.0)), Ok)?; // TODO + let member = self.members.get_member(&msg.0)?; let endpoint_id = WebRtcPublishId(msg.1); let mut element = ElementProto::new(); From 92218104650a93143229d097fb09b9aa73883dd8 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 10 Jul 2019 17:33:43 +0300 Subject: [PATCH 311/735] Return local uri in RoomNotFound --- src/signalling/room_repo.rs | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs index 1442d1a01..34f5ec1f8 100644 --- a/src/signalling/room_repo.rs +++ b/src/signalling/room_repo.rs @@ -32,7 +32,7 @@ type ActFuture = #[derive(Debug, Fail)] pub enum RoomRepoError { #[fail(display = "Room with id {} not found.", _0)] - RoomNotFound(RoomId), + RoomNotFound(LocalUri), #[fail(display = "Mailbox error: {:?}", _0)] MailboxError(MailboxError), #[fail(display = "Unknow error.")] @@ -82,6 +82,10 @@ impl Actor for RoomsRepository { type Context = Context; } +fn get_local_uri(room_id: RoomId) -> LocalUri { + LocalUri::new(Some(room_id), None, None) +} + // TODO: return sids. #[derive(Message)] #[rtype(result = "Result<(), RoomError>")] @@ -127,7 +131,7 @@ impl Handler for RoomsRepository { if let Some(room) = self.rooms.lock().unwrap().get(&msg.0) { room.do_send(CloseRoom {}); } else { - return Err(RoomRepoError::RoomNotFound(msg.0)); + return Err(RoomRepoError::RoomNotFound(get_local_uri(msg.0))); } self.remove(&msg.0); @@ -149,7 +153,7 @@ impl Handler for RoomsRepository { _ctx: &mut Self::Context, ) -> Self::Result { if let None = self.rooms.lock().unwrap().get(&msg.0) { - Err(RoomRepoError::RoomNotFound(msg.0)) + Err(RoomRepoError::RoomNotFound(get_local_uri(msg.0))) } else { Ok(DeleteRoom(msg.0)) } @@ -174,7 +178,9 @@ impl Handler for RoomsRepository { if let Some(room) = self.get(&msg.room_id) { room.do_send(DeleteMember(msg.member_id)); } else { - return Err(RoomRepoError::RoomNotFound(msg.room_id)); + return Err(RoomRepoError::RoomNotFound(get_local_uri( + msg.room_id, + ))); } Ok(()) @@ -213,7 +219,7 @@ impl Handler for RoomsRepository { ) } else { Either::B(futures::future::err(RoomRepoError::RoomNotFound( - msg.room_id, + get_local_uri(msg.room_id), ))) }; @@ -243,7 +249,9 @@ impl Handler for RoomsRepository { member_id: msg.member_id, }); } else { - return Err(RoomRepoError::RoomNotFound(msg.room_id)); + return Err(RoomRepoError::RoomNotFound(get_local_uri( + msg.room_id, + ))); } Ok(()) @@ -285,7 +293,7 @@ impl Handler for RoomsRepository { ) } else { Either::B(futures::future::err(RoomRepoError::RoomNotFound( - msg.room_id, + get_local_uri(msg.room_id), ))) }; @@ -329,7 +337,7 @@ impl Handler for RoomsRepository { ) } else { return Box::new(wrap_future(futures::future::err( - RoomRepoError::RoomNotFound(room_id), + RoomRepoError::RoomNotFound(get_local_uri(room_id)), ))); } } @@ -375,7 +383,7 @@ impl Handler for RoomsRepository { ) } else { return Box::new(wrap_future(futures::future::err( - RoomRepoError::RoomNotFound(room_id), + RoomRepoError::RoomNotFound(get_local_uri(room_id)), ))); } } @@ -423,7 +431,7 @@ impl Handler for RoomsRepository { ); } else { return Box::new(wrap_future(futures::future::err( - RoomRepoError::RoomNotFound(room_id), + RoomRepoError::RoomNotFound(get_local_uri(room_id)), ))); } } @@ -456,7 +464,7 @@ impl Handler for RoomsRepository { ) } else { Either::B(futures::future::err(RoomRepoError::RoomNotFound( - msg.room_id, + get_local_uri(msg.room_id), ))) }; @@ -493,7 +501,7 @@ impl Handler for RoomsRepository { ) } else { Either::B(futures::future::err(RoomRepoError::RoomNotFound( - msg.room_id, + get_local_uri(msg.room_id), ))) }; From a96db3da0d084d940e4d0d411c41140703ef3d51 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 10 Jul 2019 18:19:08 +0300 Subject: [PATCH 312/735] Error handling for Get method --- src/api/control/grpc/server.rs | 82 ++++++++++++---------------------- src/signalling/room.rs | 50 +++++++++++++++++++-- src/signalling/room_repo.rs | 27 ++++++++++- 3 files changed, 100 insertions(+), 59 deletions(-) diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index 8c902d0bf..754a5db64 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -137,6 +137,7 @@ impl ControlApiService { ) } + // TODO: return sids pub fn create_member( &mut self, req: CreateRequest, @@ -200,43 +201,7 @@ fn create_response( response.set_sid(sid); return response; } - Err(e) => match &e { - RoomError::EndpointNotFound(id) => { - error.set_element(id.to_string()); // TODO - error.set_code(0); // TODO - error.set_status(404); - error.set_text(e.to_string()); - } - RoomError::ParticipantServiceErr(e) => match e { - ParticipantServiceErr::EndpointNotFound(id) => { - error.set_element(id.to_string()); // TODO - error.set_code(0); // TODO - error.set_status(404); - error.set_text(e.to_string()); - } - ParticipantServiceErr::ParticipantNotFound(id) => { - error.set_element(id.to_string()); // TODO - error.set_code(0); // TODO - error.set_status(404); - error.set_text(e.to_string()); - } - _ => { - error.set_element(String::new()); - error.set_code(0); // TODO - error.set_status(500); - error.set_text(format!( - "Unknow ParticipantService error. {:?}", - e - )); - } - }, - _ => { - error.set_element(String::new()); - error.set_code(0); // TODO - error.set_status(500); - error.set_text(format!("Unknow RoomError error. {:?}", e)); - } - }, + Err(e) => error = e.into(), }, Err(e) => match &e { RoomRepoError::RoomNotFound(id) => { @@ -483,33 +448,42 @@ impl ControlApi for ControlApiService { let mega_future = room_fut .join3(member_fut, endpoint_fut) - .map_err(|_| ()) + .map_err(|e| println!("{:?}", e)) .and_then(|(room, member, endpoint)| { let mut elements = HashMap::new(); + let mut elements_results = Vec::new(); + + let results = vec![room, member, endpoint]; + + let closure = |_| (); + + for result in results { + match result { + Ok(o) => { + elements_results.push(o); + } + Err(e) => { + let mut response = GetResponse::new(); + let error: Error = e.into(); + response.set_error(error); + return sink.success(response).map_err(closure); + } + } + } - let elements_result = room - .into_iter() - .chain(member.into_iter()) - .chain(endpoint.into_iter()) - .flat_map(|e| e.into_iter()); + let elements_results = + elements_results.into_iter().flat_map(|e| e.into_iter()); - for element in elements_result { + for element in elements_results { match element { Ok((id, o)) => { elements.insert(id, o); } Err(e) => { - let mut error = Error::new(); - error.set_status(400); - error.set_code(0); // TODO - error.set_text(e.to_string()); - error.set_element(String::new()); // TODO let mut response = GetResponse::new(); + let error: Error = e.into(); response.set_error(error); - - return Either::A( - sink.success(response).map_err(|_| ()), - ); + return sink.success(response).map_err(closure); } } } @@ -517,7 +491,7 @@ impl ControlApi for ControlApiService { let mut response = GetResponse::new(); response.set_elements(elements); - Either::B(sink.success(response).map_err(|_| ())) + sink.success(response).map_err(closure) }); ctx.spawn(mega_future); diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 5bbff7642..e1389df11 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -22,8 +22,8 @@ use crate::{ }, control::{ grpc::protos::control::{ - Element as ElementProto, Member_Element, Room as RoomProto, - Room_Element, + Element as ElementProto, Error as ErrorProto, Member_Element, + Room as RoomProto, Room_Element, }, local_uri::LocalUri, room::RoomSpec, @@ -71,7 +71,7 @@ pub enum RoomError { BadRoomSpec(String), #[fail(display = "Turn service error: {}", _0)] TurnServiceError(String), - #[fail(display = "{:?}", _0)] + #[fail(display = "{}", _0)] ParticipantServiceErr(ParticipantServiceErr), } @@ -115,6 +115,50 @@ impl From for RoomError { } } +impl Into for RoomError { + fn into(self) -> ErrorProto { + let mut error = ErrorProto::new(); + match &self { + RoomError::EndpointNotFound(id) => { + error.set_element(id.to_string()); // TODO + error.set_code(0); // TODO + error.set_status(404); + error.set_text(self.to_string()); + } + RoomError::ParticipantServiceErr(e) => match e { + ParticipantServiceErr::EndpointNotFound(id) => { + error.set_element(id.to_string()); // TODO + error.set_code(0); // TODO + error.set_status(404); + error.set_text(self.to_string()); + } + ParticipantServiceErr::ParticipantNotFound(id) => { + error.set_element(id.to_string()); // TODO + error.set_code(0); // TODO + error.set_status(404); + error.set_text(self.to_string()); + } + _ => { + error.set_element(String::new()); + error.set_code(0); // TODO + error.set_status(500); + error.set_text(format!( + "Unknow ParticipantService error. {:?}", + e + )); + } + }, + _ => { + error.set_element(String::new()); + error.set_code(0); // TODO + error.set_status(500); + error.set_text(format!("Unknow RoomError error. {:?}", self)); + } + } + error + } +} + /// Media server room with its [`Member`]s. #[derive(Debug)] pub struct Room { diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs index 34f5ec1f8..42d063b1a 100644 --- a/src/signalling/room_repo.rs +++ b/src/signalling/room_repo.rs @@ -12,8 +12,10 @@ use hashbrown::HashMap; use crate::{ api::control::{ - grpc::protos::control::Element as ElementProto, local_uri::LocalUri, - room::RoomSpec, Endpoint as EndpointSpec, MemberId, MemberSpec, RoomId, + grpc::protos::control::{Element as ElementProto, Error as ErrorProto}, + local_uri::LocalUri, + room::RoomSpec, + Endpoint as EndpointSpec, MemberId, MemberSpec, RoomId, }, signalling::{ room::{ @@ -39,6 +41,27 @@ pub enum RoomRepoError { Unknow, } +impl Into for RoomRepoError { + fn into(self) -> ErrorProto { + let mut error = ErrorProto::new(); + match &self { + RoomRepoError::RoomNotFound(id) => { + error.set_element(id.to_string()); + error.set_code(0); // TODO + error.set_status(404); + error.set_text(self.to_string()); + } + _ => { + error.set_element(String::new()); + error.set_code(0); // TODO + error.set_status(500); + error.set_text(format!("Unknow RoomRepo error. {:?}", self)); + } + } + error + } +} + impl From for RoomRepoError { fn from(e: MailboxError) -> Self { RoomRepoError::MailboxError(e) From 6db6ac551449b48760593e876409fc3c23dec28f Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 10 Jul 2019 18:22:20 +0300 Subject: [PATCH 313/735] Fix error in create_response --- src/api/control/grpc/server.rs | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index 754a5db64..c4ad8b9a1 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -203,20 +203,7 @@ fn create_response( } Err(e) => error = e.into(), }, - Err(e) => match &e { - RoomRepoError::RoomNotFound(id) => { - error.set_element(id.to_string()); - error.set_code(0); // TODO - error.set_status(404); - error.set_text(e.to_string()); - } - _ => { - error.set_element(String::new()); - error.set_code(0); // TODO - error.set_status(500); - error.set_text(format!("Unknow RoomRepo error. {:?}", e)); - } - }, + Err(e) => error = e.into(), } let mut error_response = Response::new(); From 919777348ac4a71bd6808c805e28e26e5106ab80 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 10 Jul 2019 18:37:57 +0300 Subject: [PATCH 314/735] Add validation for already exists Room in Create --- src/api/control/grpc/server.rs | 2 +- src/signalling/participants.rs | 4 ++-- src/signalling/room.rs | 2 +- src/signalling/room_repo.rs | 29 ++++++++++++++++++++++++++--- 4 files changed, 30 insertions(+), 7 deletions(-) diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index c4ad8b9a1..91b55e5c2 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -133,7 +133,7 @@ impl ControlApiService { self.room_repository .send(StartRoom(room_id, room)) .map_err(|e| ControlApiError::from(e)) - .map(move |_| Ok(Ok(sid))), + .map(move |r| r.map(|_| Ok(sid))), ) } diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 22a38ad66..38bf1dc6c 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -62,9 +62,9 @@ pub enum ParticipantServiceErr { _0 )] MailBoxErr(MailboxError), - #[fail(display = "Participant with Id [{}] was not found", _0)] + #[fail(display = "Participant [id = {}] not found", _0)] ParticipantNotFound(LocalUri), - #[fail(display = "Endpoint not found.")] + #[fail(display = "Endpoint [id = {}] not found.", _0)] EndpointNotFound(LocalUri), } diff --git a/src/signalling/room.rs b/src/signalling/room.rs index e1389df11..031f7fc9c 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -57,7 +57,7 @@ pub type ActFuture = pub enum RoomError { #[fail(display = "Couldn't find Peer with [id = {}]", _0)] PeerNotFound(PeerId), - #[fail(display = "Endpoint with ID '{}' not found.", _0)] + #[fail(display = "Endpoint [id = {}] not found.", _0)] EndpointNotFound(LocalUri), #[fail(display = "Member [id = {}] does not have Turn credentials", _0)] NoTurnCredentials(MemberId), diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs index 42d063b1a..2b8b49825 100644 --- a/src/signalling/room_repo.rs +++ b/src/signalling/room_repo.rs @@ -33,14 +33,24 @@ type ActFuture = #[derive(Debug, Fail)] pub enum RoomRepoError { - #[fail(display = "Room with id {} not found.", _0)] + #[fail(display = "Room [id = {}] not found.", _0)] RoomNotFound(LocalUri), #[fail(display = "Mailbox error: {:?}", _0)] MailboxError(MailboxError), + #[fail(display = "Room [id = {}] already exists.", _0)] + RoomAlreadyExists(LocalUri), + #[fail(display = "{}", _0)] + RoomError(RoomError), #[fail(display = "Unknow error.")] Unknow, } +impl From for RoomRepoError { + fn from(err: RoomError) -> Self { + RoomRepoError::RoomError(err) + } +} + impl Into for RoomRepoError { fn into(self) -> ErrorProto { let mut error = ErrorProto::new(); @@ -51,6 +61,12 @@ impl Into for RoomRepoError { error.set_status(404); error.set_text(self.to_string()); } + RoomRepoError::RoomAlreadyExists(id) => { + error.set_element(id.to_string()); + error.set_code(0); // TODO + error.set_status(400); // TODO: Maybe 409?? + error.set_text(self.to_string()); + } _ => { error.set_element(String::new()); error.set_code(0); // TODO @@ -111,11 +127,11 @@ fn get_local_uri(room_id: RoomId) -> LocalUri { // TODO: return sids. #[derive(Message)] -#[rtype(result = "Result<(), RoomError>")] +#[rtype(result = "Result<(), RoomRepoError>")] pub struct StartRoom(pub RoomId, pub RoomSpec); impl Handler for RoomsRepository { - type Result = Result<(), RoomError>; + type Result = Result<(), RoomRepoError>; fn handle( &mut self, @@ -123,6 +139,13 @@ impl Handler for RoomsRepository { _ctx: &mut Self::Context, ) -> Self::Result { let room_id = msg.0; + + if self.rooms.lock().unwrap().get(&room_id).is_some() { + return Err(RoomRepoError::RoomAlreadyExists(get_local_uri( + room_id, + ))); + } + let room = msg.1; let turn = Arc::clone(&self.app.turn_service); From 24123b3370961e635b0cd0bc280c5e121940365f Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 10 Jul 2019 18:51:46 +0300 Subject: [PATCH 315/735] Add validation for already exists Member in Create --- src/signalling/participants.rs | 44 ++++++++++++++++++++++++++++++++++ src/signalling/room.rs | 24 +------------------ 2 files changed, 45 insertions(+), 23 deletions(-) diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 38bf1dc6c..5575f5ddc 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -32,6 +32,7 @@ use crate::{ webrtc_play_endpoint::WebRtcPlayEndpoint as WebRtcPlayEndpointSpec, webrtc_publish_endpoint::WebRtcPublishEndpoint as WebRtcPublishEndpointSpec, }, + grpc::protos::control::Error as ErrorProto, local_uri::LocalUri, MemberId, MemberSpec, RoomId, RoomSpec, WebRtcPlayId, WebRtcPublishId, @@ -66,6 +67,8 @@ pub enum ParticipantServiceErr { ParticipantNotFound(LocalUri), #[fail(display = "Endpoint [id = {}] not found.", _0)] EndpointNotFound(LocalUri), + #[fail(display = "Participant [id = {}] already exists.", _0)] + ParticipantAlreadyExists(LocalUri), } impl From for ParticipantServiceErr { @@ -90,6 +93,42 @@ impl From for ParticipantServiceErr { } } +impl Into for &ParticipantServiceErr { + fn into(self) -> ErrorProto { + let mut error = ErrorProto::new(); + match &self { + ParticipantServiceErr::EndpointNotFound(id) => { + error.set_element(id.to_string()); // TODO + error.set_code(0); // TODO + error.set_status(404); + error.set_text(self.to_string()); + } + ParticipantServiceErr::ParticipantNotFound(id) => { + error.set_element(id.to_string()); // TODO + error.set_code(0); // TODO + error.set_status(404); + error.set_text(self.to_string()); + } + ParticipantServiceErr::ParticipantAlreadyExists(id) => { + error.set_element(id.to_string()); + error.set_code(0); // TODO + error.set_status(400); + error.set_text(self.to_string()); + } + _ => { + error.set_element(String::new()); + error.set_code(0); // TODO + error.set_status(500); + error.set_text(format!( + "Unknow ParticipantService error. {:?}", + self + )); + } + } + error + } +} + /// Participant is [`Member`] with [`RpcConnection`]. [`ParticipantService`] /// stores [`Member`]s and associated [`RpcConnection`]s, handles /// [`RpcConnection`] authorization, establishment, message sending. @@ -391,6 +430,11 @@ impl ParticipantService { id: MemberId, spec: MemberSpec, ) -> Result<(), ParticipantServiceErr> { + if self.members.get(&id).is_some() { + return Err(ParticipantServiceErr::ParticipantAlreadyExists( + self.get_local_uri(id), + )); + } let signalling_member = Rc::new(Member::new( id.clone(), spec.credentials().to_string(), diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 031f7fc9c..e697ce15c 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -125,29 +125,7 @@ impl Into for RoomError { error.set_status(404); error.set_text(self.to_string()); } - RoomError::ParticipantServiceErr(e) => match e { - ParticipantServiceErr::EndpointNotFound(id) => { - error.set_element(id.to_string()); // TODO - error.set_code(0); // TODO - error.set_status(404); - error.set_text(self.to_string()); - } - ParticipantServiceErr::ParticipantNotFound(id) => { - error.set_element(id.to_string()); // TODO - error.set_code(0); // TODO - error.set_status(404); - error.set_text(self.to_string()); - } - _ => { - error.set_element(String::new()); - error.set_code(0); // TODO - error.set_status(500); - error.set_text(format!( - "Unknow ParticipantService error. {:?}", - e - )); - } - }, + RoomError::ParticipantServiceErr(e) => error = e.into(), _ => { error.set_element(String::new()); error.set_code(0); // TODO From 97caba37437e9dd8c037560c9326a298ab1e5a24 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 10 Jul 2019 19:00:05 +0300 Subject: [PATCH 316/735] Add validation for already exists Endpoint in Create --- src/signalling/elements/member.rs | 16 ++++++++-------- src/signalling/participants.rs | 29 +++++++++++++++++++---------- 2 files changed, 27 insertions(+), 18 deletions(-) diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index df94b008e..2455060b8 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -274,8 +274,8 @@ impl Member { self.0.borrow().srcs.get(id).cloned() } - fn get_local_uri(&self) -> LocalUri { - LocalUri::new(Some(self.room_id()), Some(self.id()), None) + pub fn get_local_uri(&self, endpoint_id: String) -> LocalUri { + LocalUri::new(Some(self.room_id()), Some(self.id()), Some(endpoint_id)) } pub fn get_src( @@ -284,9 +284,9 @@ impl Member { ) -> Result, MemberError> { self.0.borrow().srcs.get(id).cloned().map_or_else( || { - let mut local_uri = self.get_local_uri(); - local_uri.endpoint_id = Some(id.to_string()); - Err(MemberError::EndpointNotFound(local_uri)) + Err(MemberError::EndpointNotFound( + self.get_local_uri(id.to_string()), + )) }, Ok, ) @@ -306,9 +306,9 @@ impl Member { ) -> Result, MemberError> { self.0.borrow().sinks.get(id).cloned().map_or_else( || { - let mut local_uri = self.get_local_uri(); - local_uri.endpoint_id = Some(id.to_string()); - Err(MemberError::EndpointNotFound(local_uri)) + Err(MemberError::EndpointNotFound( + self.get_local_uri(id.to_string()), + )) }, Ok, ) diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 5575f5ddc..9f93cc356 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -69,6 +69,8 @@ pub enum ParticipantServiceErr { EndpointNotFound(LocalUri), #[fail(display = "Participant [id = {}] already exists.", _0)] ParticipantAlreadyExists(LocalUri), + #[fail(display = "Endpoint [id = {}] already exists.", _0)] + EndpointAlreadyExists(LocalUri), } impl From for ParticipantServiceErr { @@ -115,6 +117,12 @@ impl Into for &ParticipantServiceErr { error.set_status(400); error.set_text(self.to_string()); } + ParticipantServiceErr::EndpointAlreadyExists(id) => { + error.set_element(id.to_string()); + error.set_code(0); // TODO + error.set_status(400); + error.set_text(self.to_string()); + } _ => { error.set_element(String::new()); error.set_code(0); // TODO @@ -482,12 +490,12 @@ impl ParticipantService { endpoint_id: WebRtcPlayId, spec: WebRtcPlayEndpointSpec, ) -> Result<(), ParticipantServiceErr> { - debug!( - "Created sink endpoint with ID '{}' for member '{}' in room with \ - ID '{}'", - endpoint_id, member_id, self.room_id - ); let member = self.get_member(&member_id)?; + if member.get_sink_by_id(&endpoint_id).is_some() { + return Err(ParticipantServiceErr::EndpointAlreadyExists( + member.get_local_uri(endpoint_id.to_string()), + )); + } let partner_member = self.get_member(&spec.src.member_id)?; let src = partner_member.get_src(&spec.src.endpoint_id)?; @@ -511,13 +519,14 @@ impl ParticipantService { endpoint_id: WebRtcPublishId, spec: WebRtcPublishEndpointSpec, ) -> Result<(), ParticipantServiceErr> { - debug!( - "Created src endpoint with ID '{}' for member '{}' in room with \ - ID '{}'", - endpoint_id, member_id, self.room_id - ); let member = self.get_member(&member_id)?; + if member.get_src_by_id(&endpoint_id).is_some() { + return Err(ParticipantServiceErr::EndpointAlreadyExists( + member.get_local_uri(endpoint_id.to_string()), + )); + } + let src = Rc::new(WebRtcPublishEndpoint::new( endpoint_id, spec.p2p, From 8da8c31d4f94268df97076d1ab8e484b9795f2e8 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 10 Jul 2019 19:07:53 +0300 Subject: [PATCH 317/735] Fix warns, minor refactor --- src/api/control/grpc/server.rs | 15 ++++++--------- src/bin/client.rs | 3 ++- src/signalling/elements/member.rs | 5 +---- src/signalling/participants.rs | 3 +-- src/signalling/room.rs | 4 ++-- src/signalling/room_repo.rs | 4 ++-- 6 files changed, 14 insertions(+), 20 deletions(-) diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index 91b55e5c2..0eb2c660b 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -26,7 +26,6 @@ use super::protos::control_grpc::{create_control_api, ControlApi}; use crate::{ api::control::{Endpoint, MemberSpec}, signalling::{ - participants::ParticipantServiceErr, room::RoomError, room_repo::{ CreateEndpointInRoom, CreateMemberInRoom, DeleteRoomCheck, @@ -159,7 +158,7 @@ impl ControlApiService { spec: member_spec, }) .map_err(|e| ControlApiError::from(e)) - .map(|r| r.map(|r| r.map(|r| HashMap::new()))), + .map(|r| r.map(|r| r.map(|_| HashMap::new()))), ) } @@ -184,7 +183,7 @@ impl ControlApiService { spec: endpoint, }) .map_err(|e| ControlApiError::from(e)) - .map(|r| r.map(|r| r.map(|r| HashMap::new()))), + .map(|r| r.map(|r| r.map(|_| HashMap::new()))), ) } } @@ -192,19 +191,17 @@ impl ControlApiService { fn create_response( result: Result, RoomError>, RoomRepoError>, ) -> Response { - let mut error = Error::new(); - - match result { + let error: Error = match result { Ok(r) => match r { Ok(sid) => { let mut response = Response::new(); response.set_sid(sid); return response; } - Err(e) => error = e.into(), + Err(e) => e.into(), }, - Err(e) => error = e.into(), - } + Err(e) => e.into(), + }; let mut error_response = Response::new(); error_response.set_error(error); diff --git a/src/bin/client.rs b/src/bin/client.rs index 45069ee7a..aa0a9f76b 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -1,3 +1,5 @@ +#![allow(dead_code)] + use std::{collections::HashMap, sync::Arc}; use grpcio::{ChannelBuilder, EnvBuilder}; @@ -9,7 +11,6 @@ use medea::api::control::grpc::protos::{ control_grpc::ControlApiClient, }; use protobuf::RepeatedField; -use std::time::Duration; fn main() { let env = Arc::new(EnvBuilder::new().build()); diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index 2455060b8..9c5423b63 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -11,10 +11,7 @@ use medea_client_api_proto::IceServer; use crate::{ api::control::{ - endpoints::{ - webrtc_play_endpoint::WebRtcPlayEndpoint as WebRtcPlayEndpointSpec, - webrtc_publish_endpoint::WebRtcPublishEndpoint as WebRtcPublishEndpointSpec, - }, + endpoints::webrtc_play_endpoint::WebRtcPlayEndpoint as WebRtcPlayEndpointSpec, grpc::protos::control::{ Member as MemberProto, Room_Element as ElementProto, }, diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 9f93cc356..9969d4c94 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -46,7 +46,6 @@ use crate::{ member::MemberError, parse_members, Member, MembersLoadError, }, - participants::ParticipantServiceErr::ParticipantNotFound, room::{ActFuture, RoomError}, Room, }, @@ -474,7 +473,7 @@ impl ParticipantService { } // This is needed for atomicity. - for (id, sink) in signalling_member.sinks() { + for (_, sink) in signalling_member.sinks() { let src = sink.src(); src.add_sink(Rc::downgrade(&sink)); } diff --git a/src/signalling/room.rs b/src/signalling/room.rs index e697ce15c..ae194ff63 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -886,7 +886,7 @@ impl Handler for Room { fn handle( &mut self, msg: CreateMember, - ctx: &mut Self::Context, + _ctx: &mut Self::Context, ) -> Self::Result { self.members.create_member(msg.0, msg.1)?; Ok(()) @@ -907,7 +907,7 @@ impl Handler for Room { fn handle( &mut self, msg: CreateEndpoint, - ctx: &mut Self::Context, + _ctx: &mut Self::Context, ) -> Self::Result { match msg.spec { EndpointSpec::WebRtcPlay(e) => { diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs index 2b8b49825..d0273ba8b 100644 --- a/src/signalling/room_repo.rs +++ b/src/signalling/room_repo.rs @@ -500,7 +500,7 @@ impl Handler for RoomsRepository { fn handle( &mut self, msg: CreateMemberInRoom, - ctx: &mut Self::Context, + _ctx: &mut Self::Context, ) -> Self::Result { let fut = if let Some(room) = self.rooms.lock().unwrap().get(&msg.room_id) { @@ -533,7 +533,7 @@ impl Handler for RoomsRepository { fn handle( &mut self, msg: CreateEndpointInRoom, - ctx: &mut Self::Context, + _ctx: &mut Self::Context, ) -> Self::Result { let fut = if let Some(room) = self.rooms.lock().unwrap().get(&msg.room_id) { From 72dad30fe08a0146d909b81e99d07c84a33028f6 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 10 Jul 2019 19:13:24 +0300 Subject: [PATCH 318/735] Refactor for fix rustfmt errors --- src/api/client/server.rs | 7 +++---- src/api/control/endpoints/mod.rs | 8 ++++---- src/signalling/elements/member.rs | 2 +- src/signalling/participants.rs | 4 ++-- src/turn/mod.rs | 2 +- src/turn/service.rs | 3 +-- 6 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/api/client/server.rs b/src/api/client/server.rs index 5c362eeaf..21462e789 100644 --- a/src/api/client/server.rs +++ b/src/api/client/server.rs @@ -119,8 +119,7 @@ mod test { use futures::{future::IntoFuture as _, sink::Sink as _, Stream as _}; use crate::{ - api::control, conf::Conf, signalling::Room, - turn::new_turn_auth_service_mock, + api::control, conf::Conf, signalling::Room, turn::get_turn_service_mock, }; use super::*; @@ -133,7 +132,7 @@ mod test { let app = Arc::new(crate::App { config: conf, - turn_service: Arc::new(new_turn_auth_service_mock()), + turn_service: Arc::new(get_turn_service_mock()), }); let app_cloned = Arc::clone(&app); @@ -142,7 +141,7 @@ mod test { let client_room = Room::new( &room_spec, app.config.rpc.reconnect_timeout, - Arc::new(new_turn_auth_service_mock()), + Arc::new(get_turn_service_mock()), ) .unwrap(); client_room diff --git a/src/api/control/endpoints/mod.rs b/src/api/control/endpoints/mod.rs index 30eac8bcb..532fa3f66 100644 --- a/src/api/control/endpoints/mod.rs +++ b/src/api/control/endpoints/mod.rs @@ -9,10 +9,10 @@ use crate::api::control::grpc::protos::control::{ use super::{Element, TryFromElementError, TryFromProtobufError}; -use self::{ - webrtc_play_endpoint::WebRtcPlayEndpoint, - webrtc_publish_endpoint::WebRtcPublishEndpoint, -}; +#[doc(inline)] +pub use webrtc_play_endpoint::WebRtcPlayEndpoint; +#[doc(inline)] +pub use webrtc_publish_endpoint::WebRtcPublishEndpoint; /// [`Endpoint`] represents a media element that one or more media data streams /// flow through. diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index 9c5423b63..028a2ab88 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -11,7 +11,7 @@ use medea_client_api_proto::IceServer; use crate::{ api::control::{ - endpoints::webrtc_play_endpoint::WebRtcPlayEndpoint as WebRtcPlayEndpointSpec, + endpoints::WebRtcPlayEndpoint as WebRtcPlayEndpointSpec, grpc::protos::control::{ Member as MemberProto, Room_Element as ElementProto, }, diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 9969d4c94..2317d724b 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -29,8 +29,8 @@ use crate::{ }, control::{ endpoints::{ - webrtc_play_endpoint::WebRtcPlayEndpoint as WebRtcPlayEndpointSpec, - webrtc_publish_endpoint::WebRtcPublishEndpoint as WebRtcPublishEndpointSpec, + WebRtcPlayEndpoint as WebRtcPlayEndpointSpec, + WebRtcPublishEndpoint as WebRtcPublishEndpointSpec, }, grpc::protos::control::Error as ErrorProto, local_uri::LocalUri, diff --git a/src/turn/mod.rs b/src/turn/mod.rs index aa4b70c18..47b6c7a85 100644 --- a/src/turn/mod.rs +++ b/src/turn/mod.rs @@ -6,4 +6,4 @@ pub use self::service::{ }; #[cfg(test)] -pub use self::service::test::new_turn_auth_service_mock; +pub use self::service::test::get_turn_service_mock; diff --git a/src/turn/service.rs b/src/turn/service.rs index f96fc1932..913e86e83 100644 --- a/src/turn/service.rs +++ b/src/turn/service.rs @@ -310,8 +310,7 @@ pub mod test { } #[allow(clippy::module_name_repetitions)] - pub fn new_turn_auth_service_mock() -> Box - { + pub fn get_turn_service_mock() -> Box { Box::new(TurnAuthServiceMock {}) } From d14c25062bd9b1ba1fd28dc8a0db74806d5edd6c Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 10 Jul 2019 19:34:42 +0300 Subject: [PATCH 319/735] Return sids in member create --- src/api/control/grpc/server.rs | 34 ++++++++++++++++++++++------------ src/conf/mod.rs | 7 +++++++ 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index 0eb2c660b..b0311161c 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -111,13 +111,11 @@ impl ControlApiService { let sid: HashMap = fut_try!(room.members()) .iter() .map(|(id, member)| { - let addr = &self.app.config.server.bind_ip; - let port = self.app.config.server.bind_port; - let base_uri = format!("{}:{}", addr, port); + let base_url = self.app.config.get_base_rpc_url(); let uri = format!( - "wss://{}/{}/{}/{}", - base_uri, + "{}/{}/{}/{}", + base_url, &room_id, id, member.credentials() @@ -127,7 +125,6 @@ impl ControlApiService { }) .collect(); - // TODO: errors from `SendRoom` not bubbled up. Either::A( self.room_repository .send(StartRoom(room_id, room)) @@ -136,7 +133,6 @@ impl ControlApiService { ) } - // TODO: return sids pub fn create_member( &mut self, req: CreateRequest, @@ -148,17 +144,31 @@ impl ControlApiService { >, Error = ControlApiError, > { - let member_spec = fut_try!(MemberSpec::try_from(req.get_member())); + let spec = fut_try!(MemberSpec::try_from(req.get_member())); + + let room_id = local_uri.room_id.unwrap(); + let member_id = local_uri.member_id.unwrap(); + + let base_url = self.app.config.get_base_rpc_url(); + let sid = format!( + "{}/{}/{}/{}", + base_url, + room_id, + member_id, + spec.credentials() + ); + let mut sids = HashMap::new(); + sids.insert(member_id.to_string(), sid); Either::A( self.room_repository .send(CreateMemberInRoom { - room_id: local_uri.room_id.unwrap(), - member_id: local_uri.member_id.unwrap(), - spec: member_spec, + room_id, + member_id, + spec, }) .map_err(|e| ControlApiError::from(e)) - .map(|r| r.map(|r| r.map(|_| HashMap::new()))), + .map(|r| r.map(|r| r.map(|_| sids))), ) } diff --git a/src/conf/mod.rs b/src/conf/mod.rs index cda2908fa..344ea63a0 100644 --- a/src/conf/mod.rs +++ b/src/conf/mod.rs @@ -57,6 +57,13 @@ impl Conf { Ok(cfg.try_into()?) } + + pub fn get_base_rpc_url(&self) -> String { + // TODO: maybe create host config value and use it? + let addr = &self.server.bind_ip; + let port = self.server.bind_port; + format!("wss://{}:{}", addr, port) + } } /// Returns the path to the configuration file, if it's set via CLI `args` From b6f7a38f1a22098e57168adf9ff36e48237b0e4e Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 10 Jul 2019 19:57:01 +0300 Subject: [PATCH 320/735] Validate ID --- src/api/control/grpc/server.rs | 54 ++++++++++++++++++++++++++++++---- 1 file changed, 49 insertions(+), 5 deletions(-) diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index b0311161c..9fed95d70 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -219,13 +219,31 @@ fn create_response( } impl ControlApi for ControlApiService { + // TODO: Fix bug with error in src uri of spec fn create( &mut self, ctx: RpcContext, req: CreateRequest, sink: UnarySink, ) { - let local_uri = LocalUri::parse(req.get_id()).unwrap(); + let local_uri = match LocalUri::parse(req.get_id()) { + Ok(o) => o, + Err(e) => { + let mut error_response = Response::new(); + let mut error = Error::new(); + error.set_status(400); + error.set_code(0); + error.set_text(format!( + "Invalid ID [id = {}]. {}", + req.get_id(), + e + )); + error.set_element(req.get_id().to_string()); + error_response.set_error(error); + ctx.spawn(sink.success(error_response).map_err(|_| ())); + return; + } + }; if local_uri.is_room_uri() { if req.has_room() { @@ -322,7 +340,20 @@ impl ControlApi for ControlApiService { let mut delete_endpoints_futs = Vec::new(); for id in req.get_id() { - let uri = LocalUri::parse(id).unwrap(); // TODO + let uri = match LocalUri::parse(id) { + Ok(o) => o, + Err(e) => { + let mut error_response = Response::new(); + let mut error = Error::new(); + error.set_status(400); + error.set_code(0); + error.set_text(format!("Invalid ID [id = {}]. {}", id, e)); + error.set_element(id.clone()); + error_response.set_error(error); + ctx.spawn(sink.success(error_response).map_err(|_| ())); + return; + } + }; if uri.is_room_uri() { delete_room_futs.push( @@ -417,8 +448,21 @@ impl ControlApi for ControlApiService { let mut member_ids = Vec::new(); let mut endpoint_ids = Vec::new(); - for uri in req.get_id() { - let local_uri = LocalUri::parse(uri).unwrap(); + for id in req.get_id() { + let local_uri = match LocalUri::parse(id) { + Ok(o) => o, + Err(e) => { + let mut error_response = GetResponse::new(); + let mut error = Error::new(); + error.set_status(400); + error.set_code(0); + error.set_text(format!("Invalid ID [id = {}]. {}", id, e)); + error.set_element(id.clone()); + error_response.set_error(error); + ctx.spawn(sink.success(error_response).map_err(|_| ())); + return; + } + }; if local_uri.is_room_uri() { room_ids.push(local_uri.room_id.unwrap()); @@ -520,7 +564,7 @@ pub fn run( let cq_count = app.config.grpc.completion_queue_count; let service = create_control_api(ControlApiService { - app: app, + app, room_repository: room_repo, }); let env = Arc::new(Environment::new(cq_count)); From 5f76e1f07753d21293b5d8b28f25e08184231617 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 10 Jul 2019 20:10:45 +0300 Subject: [PATCH 321/735] Minor fixes --- .../endpoints/webrtc_publish_endpoint.rs | 15 +++++-------- src/api/control/grpc/server.rs | 22 ++++++++----------- src/api/control/mod.rs | 1 - src/bin/client.rs | 6 +---- src/signalling/elements/member.rs | 3 +-- src/signalling/participants.rs | 4 ++-- src/signalling/room.rs | 2 +- src/signalling/room_repo.rs | 1 - 8 files changed, 19 insertions(+), 35 deletions(-) diff --git a/src/api/control/endpoints/webrtc_publish_endpoint.rs b/src/api/control/endpoints/webrtc_publish_endpoint.rs index 3241b9d50..e2184d9b4 100644 --- a/src/api/control/endpoints/webrtc_publish_endpoint.rs +++ b/src/api/control/endpoints/webrtc_publish_endpoint.rs @@ -36,18 +36,13 @@ pub enum P2pMode { IfPossible, } -// TODO: use From -impl TryFrom for P2pMode { - type Error = TryFromProtobufError; - - fn try_from( - value: WebRtcPublishEndpointP2pProto, - ) -> Result { - Ok(match value { +impl From for P2pMode { + fn from(value: WebRtcPublishEndpointP2pProto) -> Self { + match value { WebRtcPublishEndpointP2pProto::ALWAYS => P2pMode::Always, WebRtcPublishEndpointP2pProto::IF_POSSIBLE => P2pMode::IfPossible, WebRtcPublishEndpointP2pProto::NEVER => P2pMode::Never, - }) + } } } @@ -78,7 +73,7 @@ impl TryFrom<&WebRtcPublishEndpointProto> for WebRtcPublishEndpoint { ) -> Result { if value.has_p2p() { Ok(Self { - p2p: P2pMode::try_from(value.get_p2p())?, + p2p: P2pMode::from(value.get_p2p()), }) } else { Err(TryFromProtobufError::P2pModeNotFound) diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index 9fed95d70..01aecd674 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -12,28 +12,24 @@ use crate::{ Response, }, local_uri::{LocalUri, LocalUriParseError}, - RoomSpec, TryFromElementError, TryFromProtobufError, + Endpoint, MemberSpec, RoomSpec, TryFromElementError, + TryFromProtobufError, }, log::prelude::*, - signalling::room_repo::{ - DeleteEndpointFromMemberCheck, DeleteMemberFromRoomCheck, GetEndpoint, - GetMember, GetRoom, RoomsRepository, StartRoom, - }, - App, -}; - -use super::protos::control_grpc::{create_control_api, ControlApi}; -use crate::{ - api::control::{Endpoint, MemberSpec}, signalling::{ room::RoomError, room_repo::{ - CreateEndpointInRoom, CreateMemberInRoom, DeleteRoomCheck, - RoomRepoError, + CreateEndpointInRoom, CreateMemberInRoom, + DeleteEndpointFromMemberCheck, DeleteMemberFromRoomCheck, + DeleteRoomCheck, GetEndpoint, GetMember, GetRoom, RoomRepoError, + RoomsRepository, StartRoom, }, }, + App, }; +use super::protos::control_grpc::{create_control_api, ControlApi}; + #[derive(Debug, Fail)] enum ControlApiError { #[fail(display = "{:?}", _0)] diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index 80e40402c..94880778a 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -46,7 +46,6 @@ pub enum TryFromProtobufError { MemberCredentialsNotFound, } -// TODO: Maybe better way for do it??? impl From for TryFromProtobufError { fn from(from: SrcParseError) -> Self { TryFromProtobufError::SrcUriError(from) diff --git a/src/bin/client.rs b/src/bin/client.rs index aa0a9f76b..aad9faf88 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -63,11 +63,7 @@ fn create_room(client: &ControlApiClient) { req.set_id("local://grpc-test".to_string()); let reply = client.create(&req).expect("rpc"); - if reply.has_error() { - println!("Error: {:?}", reply.get_error()); - } else { - println!("Receiver: {:?}", reply.get_sid()); - } + println!("{:?}", reply); } fn create_member(client: &ControlApiClient) { diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index 028a2ab88..3de17766e 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -95,8 +95,7 @@ impl Member { } /// Load all srcs and sinks of this [`Member`]. - // TODO: private - pub fn load( + fn load( &self, room_spec: &RoomSpec, store: &HashMap>, diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 2317d724b..2c903eb0c 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -99,13 +99,13 @@ impl Into for &ParticipantServiceErr { let mut error = ErrorProto::new(); match &self { ParticipantServiceErr::EndpointNotFound(id) => { - error.set_element(id.to_string()); // TODO + error.set_element(id.to_string()); error.set_code(0); // TODO error.set_status(404); error.set_text(self.to_string()); } ParticipantServiceErr::ParticipantNotFound(id) => { - error.set_element(id.to_string()); // TODO + error.set_element(id.to_string()); error.set_code(0); // TODO error.set_status(404); error.set_text(self.to_string()); diff --git a/src/signalling/room.rs b/src/signalling/room.rs index ae194ff63..24041cd8b 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -120,7 +120,7 @@ impl Into for RoomError { let mut error = ErrorProto::new(); match &self { RoomError::EndpointNotFound(id) => { - error.set_element(id.to_string()); // TODO + error.set_element(id.to_string()); error.set_code(0); // TODO error.set_status(404); error.set_text(self.to_string()); diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs index d0273ba8b..0176878a3 100644 --- a/src/signalling/room_repo.rs +++ b/src/signalling/room_repo.rs @@ -125,7 +125,6 @@ fn get_local_uri(room_id: RoomId) -> LocalUri { LocalUri::new(Some(room_id), None, None) } -// TODO: return sids. #[derive(Message)] #[rtype(result = "Result<(), RoomRepoError>")] pub struct StartRoom(pub RoomId, pub RoomSpec); From 986a74217ffe42b03e201a79d9a2031c30839f49 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 11 Jul 2019 13:54:00 +0300 Subject: [PATCH 322/735] Properly return errors while loading spec --- src/api/control/grpc/server.rs | 4 +- src/signalling/elements/member.rs | 177 +++++++++++++++++++++++------- src/signalling/participants.rs | 8 +- src/signalling/room.rs | 34 ++---- src/signalling/room_repo.rs | 3 + 5 files changed, 158 insertions(+), 68 deletions(-) diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index 01aecd674..7ecfd6705 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -204,7 +204,7 @@ fn create_response( response.set_sid(sid); return response; } - Err(e) => e.into(), + Err(ref e) => e.into(), }, Err(e) => e.into(), }; @@ -513,7 +513,7 @@ impl ControlApi for ControlApiService { Ok((id, o)) => { elements.insert(id, o); } - Err(e) => { + Err(ref e) => { let mut response = GetResponse::new(); let error: Error = e.into(); response.set_error(error); diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index 3de17766e..d1cdbaa09 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -13,7 +13,8 @@ use crate::{ api::control::{ endpoints::WebRtcPlayEndpoint as WebRtcPlayEndpointSpec, grpc::protos::control::{ - Member as MemberProto, Room_Element as ElementProto, + Error as ErrorProto, Member as MemberProto, + Room_Element as ElementProto, }, local_uri::LocalUri, MemberId, MemberSpec, RoomId, RoomSpec, TryFromElementError, @@ -30,27 +31,86 @@ use super::endpoints::webrtc::{WebRtcPlayEndpoint, WebRtcPublishEndpoint}; pub enum MembersLoadError { /// Errors that can occur when we try transform some spec from [`Element`]. #[fail(display = "TryFromElementError: {}", _0)] - TryFromError(TryFromElementError), + TryFromError(TryFromElementError, LocalUri), /// [`Member`] not found. - #[fail(display = "Member with id '{}' not found.", _0)] - MemberNotFound(MemberId), + #[fail(display = "Member [id = {}] not found.", _0)] + MemberNotFound(LocalUri), + + #[fail( + display = "Play endpoint [id = {}] not found while loading spec,", + _0 + )] + PlayEndpointNotFound(LocalUri), + + #[fail( + display = "Publish endpoint [id = {}] not found while loading spec.", + _0 + )] + PublishEndpointNotFound(LocalUri), +} + +#[derive(Debug, Fail)] +pub enum MemberError { + #[fail(display = "Publish endpoint [id = {}] not found.", _0)] + PublishEndpointNotFound(LocalUri), - /// [`Endpoint`] not found. - #[fail(display = "Endpoint with id '{}' not found.", _0)] - EndpointNotFound(String), + #[fail(display = "Play endpoint [id = {}] not found.", _0)] + PlayEndpointNotFound(LocalUri), } -impl From for MembersLoadError { - fn from(err: TryFromElementError) -> Self { - MembersLoadError::TryFromError(err) +impl Into for &MembersLoadError { + fn into(self) -> ErrorProto { + let mut error = ErrorProto::new(); + match &self { + MembersLoadError::TryFromError(_, id) => { + error.set_element(id.to_string()); + error.set_code(0); // TODO + error.set_status(400); + error.set_text(self.to_string()); + } + MembersLoadError::MemberNotFound(id) => { + error.set_element(id.to_string()); + error.set_code(0); // TODO + error.set_status(400); + error.set_text(self.to_string()); + } + MembersLoadError::PublishEndpointNotFound(id) => { + error.set_element(id.to_string()); + error.set_code(0); // TODO + error.set_status(400); + error.set_text(self.to_string()); + } + MembersLoadError::PlayEndpointNotFound(id) => { + error.set_element(id.to_string()); + error.set_code(0); // TODO + error.set_status(400); + error.set_text(self.to_string()); + } + } + error } } -#[derive(Debug, Fail)] -pub enum MemberError { - #[fail(display = "Endpoint with ID '{}' not found.", _0)] - EndpointNotFound(LocalUri), +impl Into for &MemberError { + fn into(self) -> ErrorProto { + let mut error = ErrorProto::new(); + match &self { + MemberError::PlayEndpointNotFound(id) => { + error.set_element(id.to_string()); + error.set_code(0); // TODO + error.set_status(400); + error.set_text(self.to_string()); + } + MemberError::PublishEndpointNotFound(id) => { + error.set_element(id.to_string()); + error.set_code(0); // TODO + error.set_status(400); + error.set_text(self.to_string()); + } + } + error + } } /// [`Member`] is member of [`Room`] with [`RpcConnection`]. @@ -94,22 +154,49 @@ impl Member { })) } + fn get_member_from_room_spec( + &self, + room_spec: &RoomSpec, + member_id: &MemberId, + ) -> Result { + let element = room_spec.pipeline.get(&member_id.0).map_or( + Err(MembersLoadError::MemberNotFound(LocalUri::new( + Some(self.room_id()), + Some(member_id.clone()), + None, + ))), + Ok, + )?; + + MemberSpec::try_from(element).map_err(|e| { + MembersLoadError::TryFromError( + e, + LocalUri::new( + Some(self.room_id()), + Some(member_id.clone()), + None, + ), + ) + }) + } + /// Load all srcs and sinks of this [`Member`]. fn load( &self, room_spec: &RoomSpec, store: &HashMap>, ) -> Result<(), MembersLoadError> { - let this_member_spec = MemberSpec::try_from( - room_spec - .pipeline - .get(&self.id().0) - .map_or(Err(MembersLoadError::MemberNotFound(self.id())), Ok)?, - )?; + let self_id = self.id(); - let this_member = store - .get(&self.id()) - .map_or(Err(MembersLoadError::MemberNotFound(self.id())), Ok)?; + let this_member_spec = + self.get_member_from_room_spec(room_spec, &self_id)?; + + let this_member = store.get(&self.id()).map_or( + Err(MembersLoadError::MemberNotFound( + self.get_member_local_uri(), + )), + Ok, + )?; for (spec_play_name, spec_play_endpoint) in this_member_spec.play_endpoints() @@ -117,27 +204,26 @@ impl Member { let publisher_id = MemberId(spec_play_endpoint.src.member_id.to_string()); let publisher_member = store.get(&publisher_id).map_or( - Err(MembersLoadError::MemberNotFound(publisher_id)), + Err(MembersLoadError::MemberNotFound(LocalUri::new( + Some(self.room_id()), + Some(publisher_id), + None, + ))), Ok, )?; - let publisher_spec = MemberSpec::try_from( - room_spec - .pipeline - .get(&spec_play_endpoint.src.member_id.to_string()) - .map_or( - Err(MembersLoadError::MemberNotFound( - spec_play_endpoint.src.member_id.clone(), - )), - Ok, - )?, + let publisher_spec = self.get_member_from_room_spec( + room_spec, + &spec_play_endpoint.src.member_id, )?; let publisher_endpoint = *publisher_spec .publish_endpoints() .get(&spec_play_endpoint.src.endpoint_id) .map_or( - Err(MembersLoadError::EndpointNotFound( - spec_play_endpoint.src.endpoint_id.to_string(), + Err(MembersLoadError::PublishEndpointNotFound( + publisher_member.get_local_uri( + spec_play_endpoint.src.endpoint_id.to_string(), + ), )), Ok, )?; @@ -202,6 +288,10 @@ impl Member { Ok(()) } + fn get_member_local_uri(&self) -> LocalUri { + LocalUri::new(Some(self.room_id()), Some(self.id()), None) + } + /// Notify [`Member`] that some [`Peer`]s removed. /// /// All [`PeerId`]s related to this [`Member`] will be removed. @@ -280,7 +370,7 @@ impl Member { ) -> Result, MemberError> { self.0.borrow().srcs.get(id).cloned().map_or_else( || { - Err(MemberError::EndpointNotFound( + Err(MemberError::PublishEndpointNotFound( self.get_local_uri(id.to_string()), )) }, @@ -302,7 +392,7 @@ impl Member { ) -> Result, MemberError> { self.0.borrow().sinks.get(id).cloned().map_or_else( || { - Err(MemberError::EndpointNotFound( + Err(MemberError::PlayEndpointNotFound( self.get_local_uri(id.to_string()), )) }, @@ -364,7 +454,16 @@ impl Member { pub fn parse_members( room_spec: &RoomSpec, ) -> Result>, MembersLoadError> { - let members_spec = room_spec.members()?; + // TODO: maybe improve error? + let members_spec = match room_spec.members() { + Ok(o) => o, + Err(e) => { + return Err(MembersLoadError::TryFromError( + e, + LocalUri::new(Some(room_spec.id.clone()), None, None), + )) + } + }; let mut members = HashMap::new(); for (id, member) in &members_spec { diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 2c903eb0c..4f6c9e718 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -66,6 +66,8 @@ pub enum ParticipantServiceErr { ParticipantNotFound(LocalUri), #[fail(display = "Endpoint [id = {}] not found.", _0)] EndpointNotFound(LocalUri), + #[fail(display = "{}", _0)] + MemberError(MemberError), #[fail(display = "Participant [id = {}] already exists.", _0)] ParticipantAlreadyExists(LocalUri), #[fail(display = "Endpoint [id = {}] already exists.", _0)] @@ -86,11 +88,7 @@ impl From for ParticipantServiceErr { impl From for ParticipantServiceErr { fn from(err: MemberError) -> Self { - match err { - MemberError::EndpointNotFound(e) => { - ParticipantServiceErr::EndpointNotFound(e) - } - } + ParticipantServiceErr::MemberError(err) } } diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 24041cd8b..9161c5d5b 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -57,8 +57,8 @@ pub type ActFuture = pub enum RoomError { #[fail(display = "Couldn't find Peer with [id = {}]", _0)] PeerNotFound(PeerId), - #[fail(display = "Endpoint [id = {}] not found.", _0)] - EndpointNotFound(LocalUri), + #[fail(display = "{}", _0)] + MemberError(MemberError), #[fail(display = "Member [id = {}] does not have Turn credentials", _0)] NoTurnCredentials(MemberId), #[fail(display = "Couldn't find RpcConnection with Member [id = {}]", _0)] @@ -67,6 +67,10 @@ pub enum RoomError { UnableToSendEvent(MemberId), #[fail(display = "PeerError: {}", _0)] PeerStateError(PeerStateError), + #[fail(display = "{}", _0)] + MembersLoadError(MembersLoadError), + #[fail(display = "{}", _0)] + TryFromElementError(TryFromElementError), #[fail(display = "Generic room error: {}", _0)] BadRoomSpec(String), #[fail(display = "Turn service error: {}", _0)] @@ -83,19 +87,13 @@ impl From for RoomError { impl From for RoomError { fn from(err: TryFromElementError) -> Self { - RoomError::BadRoomSpec(format!( - "Element located in wrong place. {}", - err - )) + RoomError::TryFromElementError(err) } } impl From for RoomError { fn from(err: MembersLoadError) -> Self { - RoomError::BadRoomSpec(format!( - "Error while loading room spec. {}", - err - )) + RoomError::MembersLoadError(err) } } @@ -107,25 +105,17 @@ impl From for RoomError { impl From for RoomError { fn from(err: MemberError) -> Self { - match err { - MemberError::EndpointNotFound(id) => { - RoomError::EndpointNotFound(id) - } - } + RoomError::MemberError(err) } } -impl Into for RoomError { +impl Into for &RoomError { fn into(self) -> ErrorProto { let mut error = ErrorProto::new(); match &self { - RoomError::EndpointNotFound(id) => { - error.set_element(id.to_string()); - error.set_code(0); // TODO - error.set_status(404); - error.set_text(self.to_string()); - } + RoomError::MemberError(e) => error = e.into(), RoomError::ParticipantServiceErr(e) => error = e.into(), + RoomError::MembersLoadError(e) => error = e.into(), _ => { error.set_element(String::new()); error.set_code(0); // TODO diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs index 0176878a3..175eee06c 100644 --- a/src/signalling/room_repo.rs +++ b/src/signalling/room_repo.rs @@ -67,6 +67,9 @@ impl Into for RoomRepoError { error.set_status(400); // TODO: Maybe 409?? error.set_text(self.to_string()); } + RoomRepoError::RoomError(e) => { + error = e.into(); + } _ => { error.set_element(String::new()); error.set_code(0); // TODO From dbdb7cb0c8ae97ee80737c0b17f52091f1f5cb6d Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 11 Jul 2019 14:51:22 +0300 Subject: [PATCH 323/735] Improve Create error handling --- .../control/endpoints/webrtc_play_endpoint.rs | 22 +++++- src/api/control/grpc/server.rs | 73 ++++++++++++------- src/api/control/local_uri.rs | 38 ++++++++-- src/api/control/mod.rs | 21 ++++++ src/bin/client.rs | 12 ++- 5 files changed, 128 insertions(+), 38 deletions(-) diff --git a/src/api/control/endpoints/webrtc_play_endpoint.rs b/src/api/control/endpoints/webrtc_play_endpoint.rs index 0d72ac38d..7476701c3 100644 --- a/src/api/control/endpoints/webrtc_play_endpoint.rs +++ b/src/api/control/endpoints/webrtc_play_endpoint.rs @@ -10,7 +10,9 @@ use serde::{ use crate::api::control::{ endpoints::webrtc_publish_endpoint::WebRtcPublishId, - grpc::protos::control::WebRtcPlayEndpoint as WebRtcPlayEndpointProto, + grpc::protos::control::{ + Error as ErrorProto, WebRtcPlayEndpoint as WebRtcPlayEndpointProto, + }, local_uri::{LocalUri, LocalUriParseError}, MemberId, RoomId, TryFromProtobufError, }; @@ -61,6 +63,24 @@ pub enum SrcParseError { LocalUriParseError(String, LocalUriParseError), } +impl Into for &SrcParseError { + fn into(self) -> ErrorProto { + let mut error = ErrorProto::new(); + match &self { + SrcParseError::MissingField(text, _) => { + error.set_code(0); + error.set_status(400); + error.set_element(text.clone()); + error.set_text(self.to_string()); + } + SrcParseError::LocalUriParseError(_, e) => { + error = e.into(); + } + } + error + } +} + /// Special uri with pattern `local://{room_id}/{member_id}/{endpoint_id}`. #[derive(Clone, Debug)] pub struct SrcUri { diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index 7ecfd6705..35e1563b9 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -66,6 +66,29 @@ impl From for ControlApiError { } } +impl Into for ControlApiError { + fn into(self) -> Error { + let mut error = Error::new(); + match &self { + ControlApiError::LocalUri(e) => error = e.into(), + ControlApiError::TryFromProtobuf(e) => error = e.into(), + ControlApiError::MailboxError(e) => { + error.set_status(500); + error.set_code(0); + error.set_text(format!("Internal server error. {:?}", e)); + error.set_element(String::new()); + } + _ => { + error.set_status(500); + error.set_code(0); + error.set_text(format!("Internal server error. {:?}", self)); + error.set_element(String::new()); + } + } + error + } +} + macro_rules! fut_try { ($call:expr) => { match $call { @@ -195,16 +218,22 @@ impl ControlApiService { } fn create_response( - result: Result, RoomError>, RoomRepoError>, + result: Result< + Result, RoomError>, RoomRepoError>, + ControlApiError, + >, ) -> Response { let error: Error = match result { Ok(r) => match r { - Ok(sid) => { - let mut response = Response::new(); - response.set_sid(sid); - return response; - } - Err(ref e) => e.into(), + Ok(r) => match r { + Ok(sid) => { + let mut response = Response::new(); + response.set_sid(sid); + return response; + } + Err(ref e) => e.into(), + }, + Err(e) => e.into(), }, Err(e) => e.into(), }; @@ -243,13 +272,9 @@ impl ControlApi for ControlApiService { if local_uri.is_room_uri() { if req.has_room() { - ctx.spawn( - self.create_room(req, local_uri).map_err(|_| ()).and_then( - move |r| { - sink.success(create_response(r)).map_err(|_| ()) - }, - ), - ); + ctx.spawn(self.create_room(req, local_uri).then(move |r| { + sink.success(create_response(r)).map_err(|_| ()) + })); } else { let mut error_response = Response::new(); let mut error = Error::new(); @@ -264,13 +289,9 @@ impl ControlApi for ControlApiService { } } else if local_uri.is_member_uri() { if req.has_member() { - ctx.spawn( - self.create_member(req, local_uri) - .map_err(|_| ()) - .and_then(move |r| { - sink.success(create_response(r)).map_err(|_| ()) - }), - ); + ctx.spawn(self.create_member(req, local_uri).then(move |r| { + sink.success(create_response(r)).map_err(|_| ()) + })); } else { let mut error_response = Response::new(); let mut error = Error::new(); @@ -285,13 +306,9 @@ impl ControlApi for ControlApiService { } } else if local_uri.is_endpoint_uri() { if req.has_webrtc_pub() || req.has_webrtc_play() { - ctx.spawn( - self.create_endpoint(req, local_uri) - .map_err(|_| ()) - .and_then(move |r| { - sink.success(create_response(r)).map_err(|_| ()) - }), - ); + ctx.spawn(self.create_endpoint(req, local_uri).then( + move |r| sink.success(create_response(r)).map_err(|_| ()), + )); } else { let mut error_response = Response::new(); let mut error = Error::new(); diff --git a/src/api/control/local_uri.rs b/src/api/control/local_uri.rs index 3c69c3ed5..55eaee221 100644 --- a/src/api/control/local_uri.rs +++ b/src/api/control/local_uri.rs @@ -2,14 +2,38 @@ use std::fmt; use failure::Fail; +use crate::api::control::grpc::protos::control::Error as ErrorProto; + use super::{MemberId, RoomId}; #[derive(Debug, Fail)] pub enum LocalUriParseError { - #[fail(display = "Provided URIs protocol is not 'local://'")] - NotLocal(String), - #[fail(display = "Too many paths in provided URI")] - TooManyFields(usize), + #[fail(display = "Provided URIs protocol is not 'local://'.")] + NotLocal(String, String), + #[fail(display = "Too many ({}) paths in provided URI.", _0)] + TooManyFields(usize, String), +} + +impl Into for &LocalUriParseError { + fn into(self) -> ErrorProto { + let mut error = ErrorProto::new(); + match &self { + LocalUriParseError::NotLocal(_, text) => { + error.set_code(0); + error.set_status(400); + error.set_text(self.to_string()); + error.set_element(text.clone()) + } + LocalUriParseError::TooManyFields(_, text) => { + error.set_code(0); + error.set_status(400); + error.set_text(self.to_string()); + error.set_element(text.clone()) + } + } + + error + } } #[derive(Debug)] @@ -38,7 +62,10 @@ impl LocalUri { pub fn parse(value: &str) -> Result { let protocol_name: String = value.chars().take(8).collect(); if protocol_name != "local://" { - return Err(LocalUriParseError::NotLocal(protocol_name)); + return Err(LocalUriParseError::NotLocal( + protocol_name, + value.to_string(), + )); } let uri_body = value.chars().skip(8).collect::(); @@ -48,6 +75,7 @@ impl LocalUri { if uri_body_splitted_len > 3 { return Err(LocalUriParseError::TooManyFields( uri_body_splitted_len, + value.to_string(), )); } diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index 94880778a..76bc6c169 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -13,6 +13,8 @@ use std::{convert::TryFrom as _, fs::File, io::Read as _, path::Path}; use failure::{Error, Fail}; use serde::Deserialize; +use crate::api::control::grpc::protos::control::Error as ErrorProto; + use self::{ endpoints::{ webrtc_play_endpoint::{SrcParseError, WebRtcPlayEndpoint}, @@ -52,6 +54,25 @@ impl From for TryFromProtobufError { } } +impl Into for &TryFromProtobufError { + fn into(self) -> ErrorProto { + let mut error = ErrorProto::new(); + match self { + TryFromProtobufError::SrcUriError(e) => { + error = e.into(); + } + _ => { + // TODO + error.set_code(0); + error.set_status(400); + error.set_text(self.to_string()); + error.set_element(String::new()); + } + } + error + } +} + /// Errors that can occur when we try transform some spec from [`Element`]. /// This error used in all [`TryFrom`] of Control API. #[allow(clippy::pub_enum_variant_names)] diff --git a/src/bin/client.rs b/src/bin/client.rs index aad9faf88..55fb97346 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -62,7 +62,7 @@ fn create_room(client: &ControlApiClient) { req.set_room(room); req.set_id("local://grpc-test".to_string()); - let reply = client.create(&req).expect("rpc"); + let reply = client.create(&req).expect("create room"); println!("{:?}", reply); } @@ -82,7 +82,9 @@ fn create_member(client: &ControlApiClient) { create_member_request.set_id("local://grpc-test/player".to_string()); create_member_request.set_member(member); - let reply = client.create(&create_member_request).unwrap(); + let reply = client + .create(&create_member_request) + .expect("create member"); println!("{:?}", reply) } @@ -94,7 +96,9 @@ fn create_endpoint(client: &ControlApiClient) { .set_id("local://grpc-test/player/create-publish".to_string()); create_endpoint_request.set_webrtc_pub(endpoint); - let reply = client.create(&create_endpoint_request).unwrap(); + let reply = client + .create(&create_endpoint_request) + .expect("create endpoint"); println!("{:?}", reply); } @@ -104,7 +108,7 @@ fn delete_room(client: &ControlApiClient) { rooms.push("local://pub-sub-video-call".to_string()); delete_request.set_id(rooms); - let reply = client.delete(&delete_request).expect("delete"); + let reply = client.delete(&delete_request).expect("delete room"); println!("{:?}", reply); } From 32b3f97eed71e5f17418758411831d9785d8dd31 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 11 Jul 2019 15:07:57 +0300 Subject: [PATCH 324/735] Macro for parsing local uri --- src/api/control/grpc/server.rs | 69 +++++++++++----------------------- 1 file changed, 22 insertions(+), 47 deletions(-) diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index 35e1563b9..ec9926aeb 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -102,6 +102,25 @@ macro_rules! fut_try { }; } +macro_rules! parse_local_uri { + ($uri:expr, $ctx:expr, $sink:expr, $response:ty) => { + match LocalUri::parse($uri) { + Ok(o) => o, + Err(e) => { + let mut error_response = <$response>::new(); + let mut error = Error::new(); + error.set_status(400); + error.set_code(0); + error.set_text(format!("Invalid ID [id = {}]. {}", $uri, e)); + error.set_element($uri.to_string()); + error_response.set_error(error); + $ctx.spawn($sink.success(error_response).map_err(|_| ())); + return; + } + } + }; +} + #[derive(Clone)] struct ControlApiService { room_repository: Addr, @@ -244,31 +263,13 @@ fn create_response( } impl ControlApi for ControlApiService { - // TODO: Fix bug with error in src uri of spec fn create( &mut self, ctx: RpcContext, req: CreateRequest, sink: UnarySink, ) { - let local_uri = match LocalUri::parse(req.get_id()) { - Ok(o) => o, - Err(e) => { - let mut error_response = Response::new(); - let mut error = Error::new(); - error.set_status(400); - error.set_code(0); - error.set_text(format!( - "Invalid ID [id = {}]. {}", - req.get_id(), - e - )); - error.set_element(req.get_id().to_string()); - error_response.set_error(error); - ctx.spawn(sink.success(error_response).map_err(|_| ())); - return; - } - }; + let local_uri = parse_local_uri!(req.get_id(), ctx, sink, Response); if local_uri.is_room_uri() { if req.has_room() { @@ -353,20 +354,7 @@ impl ControlApi for ControlApiService { let mut delete_endpoints_futs = Vec::new(); for id in req.get_id() { - let uri = match LocalUri::parse(id) { - Ok(o) => o, - Err(e) => { - let mut error_response = Response::new(); - let mut error = Error::new(); - error.set_status(400); - error.set_code(0); - error.set_text(format!("Invalid ID [id = {}]. {}", id, e)); - error.set_element(id.clone()); - error_response.set_error(error); - ctx.spawn(sink.success(error_response).map_err(|_| ())); - return; - } - }; + let uri = parse_local_uri!(id, ctx, sink, Response); if uri.is_room_uri() { delete_room_futs.push( @@ -462,20 +450,7 @@ impl ControlApi for ControlApiService { let mut endpoint_ids = Vec::new(); for id in req.get_id() { - let local_uri = match LocalUri::parse(id) { - Ok(o) => o, - Err(e) => { - let mut error_response = GetResponse::new(); - let mut error = Error::new(); - error.set_status(400); - error.set_code(0); - error.set_text(format!("Invalid ID [id = {}]. {}", id, e)); - error.set_element(id.clone()); - error_response.set_error(error); - ctx.spawn(sink.success(error_response).map_err(|_| ())); - return; - } - }; + let local_uri = parse_local_uri!(id, ctx, sink, GetResponse); if local_uri.is_room_uri() { room_ids.push(local_uri.room_id.unwrap()); From cb0bce50fb2c4dc759f059b62efce5f20bead0d6 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 11 Jul 2019 15:50:41 +0300 Subject: [PATCH 325/735] Add docs, minor refactor --- .../control/endpoints/webrtc_play_endpoint.rs | 5 +++ src/api/control/grpc/mod.rs | 2 + src/api/control/grpc/protos/mod.rs | 4 ++ src/api/control/grpc/server.rs | 20 ++++++++++ src/api/control/local_uri.rs | 11 +++++ src/signalling/elements/member.rs | 17 ++++++++ src/signalling/participants.rs | 40 +++++++++++++++++-- src/signalling/peers.rs | 4 ++ src/signalling/room.rs | 24 ++++++----- src/signalling/room_repo.rs | 9 +++-- 10 files changed, 119 insertions(+), 17 deletions(-) diff --git a/src/api/control/endpoints/webrtc_play_endpoint.rs b/src/api/control/endpoints/webrtc_play_endpoint.rs index 7476701c3..2b6b75e29 100644 --- a/src/api/control/endpoints/webrtc_play_endpoint.rs +++ b/src/api/control/endpoints/webrtc_play_endpoint.rs @@ -82,6 +82,7 @@ impl Into for &SrcParseError { } /// Special uri with pattern `local://{room_id}/{member_id}/{endpoint_id}`. +/// This uri can pointing only to [`WebRtcPublishEndpoint`]. #[derive(Clone, Debug)] pub struct SrcUri { /// ID of [`Room`] @@ -93,6 +94,10 @@ pub struct SrcUri { } impl SrcUri { + /// Parse [`SrcUri`] from str. + /// + /// Returns [`SrcParseError::LocalUriParseError`] when some error happened + /// while parsing URI. pub fn parse(value: &str) -> Result { let local_uri = LocalUri::parse(value).map_err(|e| { SrcParseError::LocalUriParseError(value.to_string(), e) diff --git a/src/api/control/grpc/mod.rs b/src/api/control/grpc/mod.rs index 47c576ee3..1b990a386 100644 --- a/src/api/control/grpc/mod.rs +++ b/src/api/control/grpc/mod.rs @@ -1,2 +1,4 @@ +//! Implementation of gRPC server and generated gRPC protos. + pub mod protos; pub mod server; diff --git a/src/api/control/grpc/protos/mod.rs b/src/api/control/grpc/protos/mod.rs index 3053d7002..8b8903270 100644 --- a/src/api/control/grpc/protos/mod.rs +++ b/src/api/control/grpc/protos/mod.rs @@ -1,2 +1,6 @@ +//! gRPC generated specs. +//! Don't edit `*.rs` files in this module because it automatically generated by +//! `protoc` in `build.rs` file. + pub mod control; pub mod control_grpc; diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index ec9926aeb..367b9d427 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -32,12 +32,21 @@ use super::protos::control_grpc::{create_control_api, ControlApi}; #[derive(Debug, Fail)] enum ControlApiError { + /// Error when parsing ID of element. #[fail(display = "{:?}", _0)] LocalUri(LocalUriParseError), + + /// This error is rather abnormal, since what it catches must be caught at + /// the level of the gRPC. #[fail(display = "{:?}", _0)] TryFromProtobuf(TryFromProtobufError), + + /// This error is rather abnormal, since what it catches must be caught at + /// the level of the gRPC. #[fail(display = "{:?}", _0)] TryFromElement(TryFromElementError), + + /// Wrapped [`MailboxError`]. #[fail(display = "{:?}", _0)] MailboxError(MailboxError), } @@ -128,6 +137,7 @@ struct ControlApiService { } impl ControlApiService { + /// Implementation of `Create` method for `Room` element. pub fn create_room( &mut self, req: CreateRequest, @@ -171,6 +181,7 @@ impl ControlApiService { ) } + /// Implementation of `Create` method for `Member` element. pub fn create_member( &mut self, req: CreateRequest, @@ -210,6 +221,8 @@ impl ControlApiService { ) } + /// Implementation of `Create` method for `WebRtcPublishEndpoint` and + /// `WebRtcPlayEndpoint` elements. pub fn create_endpoint( &mut self, req: CreateRequest, @@ -236,6 +249,7 @@ impl ControlApiService { } } +/// Generate [`Response`] for `Create` method of all elements. fn create_response( result: Result< Result, RoomError>, RoomRepoError>, @@ -263,6 +277,7 @@ fn create_response( } impl ControlApi for ControlApiService { + /// Implementation for `Create` method of gRPC control API. fn create( &mut self, ctx: RpcContext, @@ -334,6 +349,7 @@ impl ControlApi for ControlApiService { } } + /// Implementation for `Apply` method of gRPC control API. fn apply( &mut self, _ctx: RpcContext, @@ -343,6 +359,7 @@ impl ControlApi for ControlApiService { unimplemented!() } + /// Implementation for `Delete` method of gRPC control API. fn delete( &mut self, ctx: RpcContext, @@ -439,6 +456,7 @@ impl ControlApi for ControlApiService { ); } + /// Implementation for `Get` method of gRPC control API. fn get( &mut self, ctx: RpcContext, @@ -524,6 +542,7 @@ impl ControlApi for ControlApiService { } } +/// Actor wrapper for `grcio` gRPC server. #[allow(clippy::module_name_repetitions)] pub struct GrpcServer { server: Server, @@ -543,6 +562,7 @@ impl Actor for GrpcServer { } } +/// Run gRPC server in actix actor. pub fn run( room_repo: Addr, app: Arc, diff --git a/src/api/control/local_uri.rs b/src/api/control/local_uri.rs index 55eaee221..bd11a2cb5 100644 --- a/src/api/control/local_uri.rs +++ b/src/api/control/local_uri.rs @@ -36,6 +36,9 @@ impl Into for &LocalUriParseError { } } +/// Uri in format "local://room_id/member_id/endpoint_id" +/// This kind of uri used for pointing to some element in spec (`Room`, +/// `Member`, `WebRtcPlayEndpoint`, `WebRtcPublishEndpoint`, etc). #[derive(Debug)] pub struct LocalUri { /// ID of [`Room`] @@ -47,6 +50,7 @@ pub struct LocalUri { } impl LocalUri { + /// Create new [`LocalUri`] with provided IDs. pub fn new( room_id: Option, member_id: Option, @@ -59,6 +63,10 @@ impl LocalUri { } } + /// Parse [`LocalUri`] from str. + /// + /// Returns [`LocalUriParse::NotLocal`] when uri is not "local://" + /// Returns [`LocalUriParse::TooManyFields`] when uri have too many paths. pub fn parse(value: &str) -> Result { let protocol_name: String = value.chars().take(8).collect(); if protocol_name != "local://" { @@ -99,18 +107,21 @@ impl LocalUri { }) } + /// Return true if this [`LocalUri`] pointing to `Room` element. pub fn is_room_uri(&self) -> bool { self.room_id.is_some() && self.member_id.is_none() && self.endpoint_id.is_none() } + /// Return true if this [`LocalUri`] pointing to `Member` element. pub fn is_member_uri(&self) -> bool { self.room_id.is_some() && self.member_id.is_some() && self.endpoint_id.is_none() } + /// Return true if this [`LocalUri`] pointing to `Endpoint` element. pub fn is_endpoint_uri(&self) -> bool { self.room_id.is_some() && self.member_id.is_some() diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index d1cdbaa09..7d0a84060 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -154,6 +154,11 @@ impl Member { })) } + /// Lookup [`MemberSpec`] by ID from [`MemberSpec`]. + /// + /// Returns [`MembersLoadError::MemberNotFound`] when member not found. + /// Returns [`MembersLoadError::TryFromError`] when found element which is + /// not [`MemberSpec`]. fn get_member_from_room_spec( &self, room_spec: &RoomSpec, @@ -288,6 +293,7 @@ impl Member { Ok(()) } + /// Return [`LocalUri`] for this [`Member`]. fn get_member_local_uri(&self) -> LocalUri { LocalUri::new(Some(self.room_id()), Some(self.id()), None) } @@ -386,6 +392,10 @@ impl Member { self.0.borrow().sinks.get(id).cloned() } + /// Lookup [`WebRtcPlayEndpoint`] sink endpoint by [`EndpointId`]. + /// + /// Returns [`MemberError::PlayEndpointNotFound`] when + /// [`WebRtcPlayEndpoint`] not found. pub fn get_sink( &self, id: &WebRtcPlayId, @@ -410,6 +420,7 @@ impl Member { self.0.borrow_mut().srcs.remove(id); } + /// Take sink from [`Member`]'s `sinks`. pub fn take_sink( &self, id: &WebRtcPlayId, @@ -417,6 +428,7 @@ impl Member { self.0.borrow_mut().sinks.remove(id) } + /// Take src from [`Member`]'s `srsc`. pub fn take_src( &self, id: &WebRtcPublishId, @@ -428,6 +440,11 @@ impl Member { self.0.borrow().room_id.clone() } + /// Create new [`WebRtcPlayEndpoint`] based on provided + /// [`WebRtcPlayEndpointSpec`]. + /// + /// This function will add created [`WebRtcPlayEndpoint`] to src's + /// [`WebRtcPublishEndpoint`] and to provided [`Member`]. pub fn create_sink( member: Rc, id: WebRtcPlayId, diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 4f6c9e718..a06b230d0 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -185,17 +185,25 @@ impl ParticipantService { self.members.get(id).cloned() } - fn get_local_uri(&self, member_id: MemberId) -> LocalUri { + /// Generate [`LocalUri`] which point to some [`Member`] in this `Room`. + /// + /// __Note__ this function don't check presence of [`Member`] in this + /// `Room`. + fn get_local_uri_to_member(&self, member_id: MemberId) -> LocalUri { LocalUri::new(Some(self.room_id.clone()), Some(member_id), None) } + /// Lookup [`Member`] by [`MemberId`]. + /// + /// Returns [`ParticipantServiceErr::ParticipantNotFound`] if member not + /// found. pub fn get_member( &self, id: &MemberId, ) -> Result, ParticipantServiceErr> { self.members.get(id).cloned().map_or( Err(ParticipantServiceErr::ParticipantNotFound( - self.get_local_uri(id.clone()), + self.get_local_uri_to_member(id.clone()), )), Ok, ) @@ -263,7 +271,7 @@ impl ParticipantService { None => { return Box::new(wrap_future(future::err( ParticipantServiceErr::ParticipantNotFound( - self.get_local_uri(member_id), + self.get_local_uri_to_member(member_id), ), ))); } @@ -406,6 +414,9 @@ impl ParticipantService { join_all(close_fut).map(|_| ()) } + /// Delete [`Member`] from [`ParticipantService`], remove this user from + /// [`TurnAuthService`], close RPC connection with him and remove drop + /// connection task. pub fn delete_member( &mut self, member_id: &MemberId, @@ -430,6 +441,13 @@ impl ParticipantService { } } + /// Create new [`Member`] in this [`ParticipantService`]. + /// + /// This function will check that new [`Member`]'s ID is not present in + /// [`ParticipantService`]. + /// + /// Returns [`ParticipantServiceErr::ParticipantAlreadyExists`] when + /// [`Member`]'s ID already presented in [`ParticipantService`]. pub fn create_member( &mut self, id: MemberId, @@ -437,7 +455,7 @@ impl ParticipantService { ) -> Result<(), ParticipantServiceErr> { if self.members.get(&id).is_some() { return Err(ParticipantServiceErr::ParticipantAlreadyExists( - self.get_local_uri(id), + self.get_local_uri_to_member(id), )); } let signalling_member = Rc::new(Member::new( @@ -481,6 +499,13 @@ impl ParticipantService { Ok(()) } + /// Create new [`WebRtcPlayEndpoint`] in specified [`Member`]. + /// + /// This function will check that new [`WebRtcPlayEndpoint`]'s ID is not + /// present in [`ParticipantService`]. + /// + /// Returns [`ParticipantServiceErr::EndpointAlreadyExists`] when + /// [`WebRtcPlayEndpoint`]'s ID already presented in [`Member`]. pub fn create_sink_endpoint( &mut self, member_id: MemberId, @@ -510,6 +535,13 @@ impl ParticipantService { Ok(()) } + /// Create new [`WebRtcPlayEndpoint`] in specified [`Member`]. + /// + /// This function will check that new [`WebRtcPublishEndpoint`]'s ID is not + /// present in [`ParticipantService`]. + /// + /// Returns [`ParticipantServiceErr::EndpointAlreadyExists`] when + /// [`WebRtcPublishEndpoint`]'s ID already presented in [`Member`]. pub fn create_src_endpoint( &mut self, member_id: MemberId, diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index e48da3be3..10a616a92 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -173,6 +173,8 @@ impl PeerRepository { } } + /// Delete [`PeerStateMachine`] from this [`PeerRepository`] and send + /// [`PeersRemoved`] to [`Member`]. pub fn remove_peer( &mut self, member_id: MemberId, @@ -187,6 +189,8 @@ impl PeerRepository { } } + /// Delete [`PeerStateMachine`]s from this [`PeerRepository`] and send + /// [`PeersRemoved`] to [`Member`]s. pub fn remove_peers( &mut self, member_id: MemberId, diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 9161c5d5b..c199d40cc 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -514,14 +514,15 @@ impl Into for &mut Room { #[derive(Message)] #[rtype(result = "Result")] -pub struct Serialize; +pub struct SerializeProtobufRoom; -impl Handler for Room { +impl Handler for Room { type Result = Result; + /// Serialize this [`Room`] to protobuf object. fn handle( &mut self, - _msg: Serialize, + _msg: SerializeProtobufRoom, _ctx: &mut Self::Context, ) -> Self::Result { Ok(self.into()) @@ -530,14 +531,15 @@ impl Handler for Room { #[derive(Message)] #[rtype(result = "Result")] -pub struct SerializeMember(pub MemberId); +pub struct SerializeProtobufMember(pub MemberId); -impl Handler for Room { +impl Handler for Room { type Result = Result; + /// Serialize [`Member`] to protobuf object. fn handle( &mut self, - msg: SerializeMember, + msg: SerializeProtobufMember, _ctx: &mut Self::Context, ) -> Self::Result { let member = self.members.get_member(&msg.0)?; @@ -554,14 +556,16 @@ impl Handler for Room { #[derive(Message)] #[rtype(result = "Result")] -pub struct SerializeEndpoint(pub MemberId, pub String); +pub struct SerializeProtobufEndpoint(pub MemberId, pub String); -impl Handler for Room { +impl Handler for Room { type Result = Result; + /// Serialize [`WebRtcPlayEndpoint`] or [`WebRtcPublishEndpoint`] to + /// protobuf object. fn handle( &mut self, - msg: SerializeEndpoint, + msg: SerializeProtobufEndpoint, _ctx: &mut Self::Context, ) -> Self::Result { let member = self.members.get_member(&msg.0)?; @@ -873,6 +877,7 @@ pub struct CreateMember(pub MemberId, pub MemberSpec); impl Handler for Room { type Result = Result<(), RoomError>; + /// Create new [`Member`] in this [`Room`]. fn handle( &mut self, msg: CreateMember, @@ -894,6 +899,7 @@ pub struct CreateEndpoint { impl Handler for Room { type Result = Result<(), RoomError>; + /// Create new `Endpoint` from [`EndpointSpec`]. fn handle( &mut self, msg: CreateEndpoint, diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs index 175eee06c..0ae634ba7 100644 --- a/src/signalling/room_repo.rs +++ b/src/signalling/room_repo.rs @@ -21,7 +21,8 @@ use crate::{ room::{ CloseRoom, CreateEndpoint, CreateMember, DeleteEndpoint, DeleteEndpointCheck, DeleteMember, DeleteMemberCheck, RoomError, - Serialize, SerializeEndpoint, SerializeMember, + SerializeProtobufEndpoint, SerializeProtobufMember, + SerializeProtobufRoom, }, Room, }, @@ -370,7 +371,7 @@ impl Handler for RoomsRepository { for room_id in msg.0 { if let Some(room) = self.rooms.lock().unwrap().get(&room_id) { futs.push( - room.send(Serialize) + room.send(SerializeProtobufRoom) .map_err(|e| RoomRepoError::from(e)) .map(move |result| { result.map(|r| { @@ -415,7 +416,7 @@ impl Handler for RoomsRepository { for (room_id, member_id) in msg.0 { if let Some(room) = self.rooms.lock().unwrap().get(&room_id) { futs.push( - room.send(SerializeMember(member_id.clone())) + room.send(SerializeProtobufMember(member_id.clone())) .map_err(|e| RoomRepoError::from(e)) .map(|result| { result.map(|r| { @@ -461,7 +462,7 @@ impl Handler for RoomsRepository { for (room_id, member_id, endpoint_id) in msg.0 { if let Some(room) = self.rooms.lock().unwrap().get(&room_id) { futs.push( - room.send(SerializeEndpoint( + room.send(SerializeProtobufEndpoint( member_id.clone(), endpoint_id.clone(), )) From 0c698b370bf9a3a99f2480421e9b6bbca54b096a Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 11 Jul 2019 17:31:35 +0300 Subject: [PATCH 326/735] Some docs and refactor --- config.toml | 2 +- src/api/control/endpoints/webrtc_publish_endpoint.rs | 2 ++ src/api/control/grpc/server.rs | 2 ++ src/api/control/local_uri.rs | 2 ++ src/api/control/member.rs | 1 + src/api/control/room.rs | 1 + src/conf/grpc.rs | 2 +- src/signalling/room.rs | 4 ++-- 8 files changed, 12 insertions(+), 4 deletions(-) diff --git a/config.toml b/config.toml index f05c4129c..6449ac3dd 100644 --- a/config.toml +++ b/config.toml @@ -93,7 +93,7 @@ static_specs_path = "dev/specs" # Port to bind gRPC server to. # # Default: -# bind_port = 50_051 +# bind_port = 50051 # Completion queue count of gRPC server. # diff --git a/src/api/control/endpoints/webrtc_publish_endpoint.rs b/src/api/control/endpoints/webrtc_publish_endpoint.rs index e2184d9b4..8c90e830e 100644 --- a/src/api/control/endpoints/webrtc_publish_endpoint.rs +++ b/src/api/control/endpoints/webrtc_publish_endpoint.rs @@ -1,3 +1,5 @@ +//! WebRtcPublish + use std::convert::TryFrom; use macro_attr::*; diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index 367b9d427..289fbf3a6 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -1,3 +1,5 @@ +//! Implementation of gRPC control API. + use std::{collections::HashMap, convert::TryFrom, sync::Arc}; use actix::{Actor, Addr, Arbiter, Context, MailboxError}; diff --git a/src/api/control/local_uri.rs b/src/api/control/local_uri.rs index bd11a2cb5..982676919 100644 --- a/src/api/control/local_uri.rs +++ b/src/api/control/local_uri.rs @@ -1,3 +1,5 @@ +//! URI for pointing to some medea element. + use std::fmt; use failure::Fail; diff --git a/src/api/control/member.rs b/src/api/control/member.rs index a7eb36340..bd875b8c1 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -90,6 +90,7 @@ impl MemberSpec { impl TryFrom<&MemberProto> for MemberSpec { type Error = TryFromProtobufError; + /// Serialize [`MemberSpec`] from protobuf object. fn try_from(value: &MemberProto) -> Result { let mut pipeline = StdHashMap::new(); for (id, member_element) in value.get_pipeline() { diff --git a/src/api/control/room.rs b/src/api/control/room.rs index d5a28f736..a0cf19e2f 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -41,6 +41,7 @@ pub struct RoomSpec { } impl RoomSpec { + /// Deserialize [`RoomSpec`] from protobuf object. pub fn try_from_protobuf( id: Id, proto: &RoomProto, diff --git a/src/conf/grpc.rs b/src/conf/grpc.rs index b745af41b..b11b00497 100644 --- a/src/conf/grpc.rs +++ b/src/conf/grpc.rs @@ -10,7 +10,7 @@ pub struct Grpc { #[default(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)))] pub bind_ip: IpAddr, - /// Port to bind gRPC server to. Defaults to `8080`. + /// Port to bind gRPC server to. Defaults to `50_051`. #[default(50_051)] pub bind_port: u16, diff --git a/src/signalling/room.rs b/src/signalling/room.rs index c199d40cc..3d0e2ba08 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -870,6 +870,7 @@ impl Handler for Room { } } +/// Create new [`Member`] in this [`Room`]. #[derive(Message, Debug)] #[rtype(result = "Result<(), RoomError>")] pub struct CreateMember(pub MemberId, pub MemberSpec); @@ -877,7 +878,6 @@ pub struct CreateMember(pub MemberId, pub MemberSpec); impl Handler for Room { type Result = Result<(), RoomError>; - /// Create new [`Member`] in this [`Room`]. fn handle( &mut self, msg: CreateMember, @@ -888,6 +888,7 @@ impl Handler for Room { } } +/// Create new `Endpoint` from [`EndpointSpec`]. #[derive(Message, Debug)] #[rtype(result = "Result<(), RoomError>")] pub struct CreateEndpoint { @@ -899,7 +900,6 @@ pub struct CreateEndpoint { impl Handler for Room { type Result = Result<(), RoomError>; - /// Create new `Endpoint` from [`EndpointSpec`]. fn handle( &mut self, msg: CreateEndpoint, From c3e80ddda6d46634bd9a1f38d7162c282dbbe6e6 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 11 Jul 2019 17:54:08 +0300 Subject: [PATCH 327/735] Remove delete checks --- src/api/control/grpc/server.rs | 70 +++++------------ src/bin/client.rs | 10 +-- src/signalling/room.rs | 71 ++++-------------- src/signalling/room_repo.rs | 132 +++------------------------------ 4 files changed, 46 insertions(+), 237 deletions(-) diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index 289fbf3a6..5d146cf50 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -21,16 +21,17 @@ use crate::{ signalling::{ room::RoomError, room_repo::{ - CreateEndpointInRoom, CreateMemberInRoom, - DeleteEndpointFromMemberCheck, DeleteMemberFromRoomCheck, - DeleteRoomCheck, GetEndpoint, GetMember, GetRoom, RoomRepoError, - RoomsRepository, StartRoom, + CreateEndpointInRoom, CreateMemberInRoom, GetEndpoint, GetMember, + GetRoom, RoomRepoError, RoomsRepository, StartRoom, }, }, App, }; use super::protos::control_grpc::{create_control_api, ControlApi}; +use crate::signalling::room_repo::{ + DeleteEndpointFromMember, DeleteMemberFromRoom, DeleteRoom, +}; #[derive(Debug, Fail)] enum ControlApiError { @@ -377,19 +378,18 @@ impl ControlApi for ControlApiService { if uri.is_room_uri() { delete_room_futs.push( - self.room_repository - .send(DeleteRoomCheck(uri.room_id.unwrap())), + self.room_repository.send(DeleteRoom(uri.room_id.unwrap())), ); } else if uri.is_member_uri() { delete_member_futs.push(self.room_repository.send( - DeleteMemberFromRoomCheck { + DeleteMemberFromRoom { room_id: uri.room_id.unwrap(), member_id: uri.member_id.unwrap(), }, )); } else if uri.is_endpoint_uri() { delete_endpoints_futs.push(self.room_repository.send( - DeleteEndpointFromMemberCheck { + DeleteEndpointFromMember { room_id: uri.room_id.unwrap(), member_id: uri.member_id.unwrap(), endpoint_id: uri.endpoint_id.unwrap(), @@ -404,56 +404,20 @@ impl ControlApi for ControlApiService { let mega_delete_endpoints_fut = futures::future::join_all(delete_endpoints_futs); - let room_repository_addr = self.room_repository.clone(); - ctx.spawn( mega_delete_endpoints_fut .join3(mega_delete_member_fut, mega_delete_room_fut) .map_err(|_| ()) .and_then(move |(member, endpoint, room)| { - let mut members_msgs = Vec::new(); - let mut endpoints_msgs = Vec::new(); - let mut room_msgs = Vec::new(); - - for member_fut in member { - let member_msg = member_fut.unwrap().unwrap(); - members_msgs.push( - room_repository_addr - .send(member_msg) - .map_err(|_| ()), - ); - } - - for endpoint_fut in endpoint { - let endpoint_msg = endpoint_fut.unwrap().unwrap(); - endpoints_msgs.push( - room_repository_addr - .send(endpoint_msg) - .map_err(|_| ()), - ); - } - - for room_fut in room { - let room_msg = room_fut.unwrap(); - room_msgs.push( - room_repository_addr.send(room_msg).map_err(|_| ()), - ); - } - - let members_msgs = futures::future::join_all(members_msgs); - let endpoints_msgs = - futures::future::join_all(endpoints_msgs); - let room_msgs = futures::future::join_all(room_msgs); - - members_msgs - .join3(endpoints_msgs, room_msgs) - .map_err(|_| ()) - .map(|_| ()) - .and_then(|_| { - let mut response = Response::new(); - response.set_sid(HashMap::new()); - sink.success(response).map_err(|_| ()) - }) + member + .into_iter() + .chain(endpoint.into_iter()) + .chain(room.into_iter()) + .for_each(|r| r.unwrap()); + // TODO + let mut response = Response::new(); + response.set_sid(HashMap::new()); + sink.success(response).map_err(|_| ()) }), ); } diff --git a/src/bin/client.rs b/src/bin/client.rs index 55fb97346..89d3b8856 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -18,12 +18,12 @@ fn main() { let client = ControlApiClient::new(ch); create_room(&client); - // delete_room(&client); - // delete_endpoint(&client); - // delete_member(&client); - create_member(&client); + delete_room(&client); + // delete_endpoint(&client); + // delete_member(&client); + // create_member(&client); // std::thread::sleep(Duration::from_secs(1)); - create_endpoint(&client); + // create_endpoint(&client); get_room(&client); } diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 3d0e2ba08..44c2d0cd0 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -791,24 +791,6 @@ impl Handler for Room { } } -#[derive(Debug, Message)] -#[rtype(result = "Result<(), RoomError>")] -pub struct DeleteMemberCheck(pub MemberId); - -impl Handler for Room { - type Result = Result<(), RoomError>; - - fn handle( - &mut self, - msg: DeleteMemberCheck, - _ctx: &mut Self::Context, - ) -> Self::Result { - self.members.get_member(&msg.0)?; - - Ok(()) - } -} - #[derive(Debug, Message, Clone)] #[rtype(result = "()")] pub struct DeleteEndpoint { @@ -824,49 +806,22 @@ impl Handler for Room { msg: DeleteEndpoint, ctx: &mut Self::Context, ) -> Self::Result { - let member = self.members.get_member(&msg.member_id).unwrap(); - let play_id = WebRtcPlayId(msg.endpoint_id); - if let Some(endpoint) = member.take_sink(&play_id) { - if let Some(peer_id) = endpoint.peer_id() { - self.peers.remove_peer(msg.member_id.clone(), peer_id, ctx); + if let Some(member) = self.members.get_member_by_id(&msg.member_id) { + let play_id = WebRtcPlayId(msg.endpoint_id); + if let Some(endpoint) = member.take_sink(&play_id) { + if let Some(peer_id) = endpoint.peer_id() { + self.peers.remove_peer(msg.member_id.clone(), peer_id, ctx); + } } - } - - let publish_id = WebRtcPublishId(play_id.0); - if let Some(endpoint) = member.take_src(&publish_id) { - let peer_ids = endpoint.peer_ids(); - self.peers.remove_peers(msg.member_id, peer_ids, ctx); - } - } -} - -#[derive(Debug, Message)] -#[rtype(result = "Result<(), RoomError>")] -pub struct DeleteEndpointCheck { - pub member_id: MemberId, - pub endpoint_id: String, -} - -impl Handler for Room { - type Result = Result<(), RoomError>; - - fn handle( - &mut self, - msg: DeleteEndpointCheck, - _ctx: &mut Self::Context, - ) -> Self::Result { - let member = self.members.get_member(&msg.member_id)?; - - let play_id = WebRtcPlayId(msg.endpoint_id); - if let Some(_) = member.get_sink_by_id(&play_id) { - return Ok(()); + let publish_id = WebRtcPublishId(play_id.0); + if let Some(endpoint) = member.take_src(&publish_id) { + let peer_ids = endpoint.peer_ids(); + self.peers.remove_peers(msg.member_id, peer_ids, ctx); + } + } else { + return; } - - let publish_id = WebRtcPublishId(play_id.0); - member.get_src(&publish_id)?; - - Ok(()) } } diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs index 0ae634ba7..a1909fc5e 100644 --- a/src/signalling/room_repo.rs +++ b/src/signalling/room_repo.rs @@ -20,9 +20,8 @@ use crate::{ signalling::{ room::{ CloseRoom, CreateEndpoint, CreateMember, DeleteEndpoint, - DeleteEndpointCheck, DeleteMember, DeleteMemberCheck, RoomError, - SerializeProtobufEndpoint, SerializeProtobufMember, - SerializeProtobufRoom, + DeleteMember, RoomError, SerializeProtobufEndpoint, + SerializeProtobufMember, SerializeProtobufRoom, }, Room, }, @@ -167,7 +166,7 @@ impl Handler for RoomsRepository { #[derive(Message)] #[rtype(result = "Result<(), RoomRepoError>")] -pub struct DeleteRoom(RoomId); +pub struct DeleteRoom(pub RoomId); impl Handler for RoomsRepository { type Result = Result<(), RoomRepoError>; @@ -177,43 +176,21 @@ impl Handler for RoomsRepository { msg: DeleteRoom, _ctx: &mut Self::Context, ) -> Self::Result { - if let Some(room) = self.rooms.lock().unwrap().get(&msg.0) { + let mut room_repo = self.rooms.lock().unwrap(); + if let Some(room) = room_repo.get(&msg.0) { room.do_send(CloseRoom {}); - } else { - return Err(RoomRepoError::RoomNotFound(get_local_uri(msg.0))); + room_repo.remove(&msg.0); } - self.remove(&msg.0); - Ok(()) } } -#[derive(Message)] -#[rtype(result = "Result")] -pub struct DeleteRoomCheck(pub RoomId); - -impl Handler for RoomsRepository { - type Result = Result; - - fn handle( - &mut self, - msg: DeleteRoomCheck, - _ctx: &mut Self::Context, - ) -> Self::Result { - if let None = self.rooms.lock().unwrap().get(&msg.0) { - Err(RoomRepoError::RoomNotFound(get_local_uri(msg.0))) - } else { - Ok(DeleteRoom(msg.0)) - } - } -} - #[derive(Message)] #[rtype(result = "Result<(), RoomRepoError>")] pub struct DeleteMemberFromRoom { - member_id: MemberId, - room_id: RoomId, + pub member_id: MemberId, + pub room_id: RoomId, } impl Handler for RoomsRepository { @@ -236,52 +213,12 @@ impl Handler for RoomsRepository { } } -#[derive(Message)] -#[rtype( - result = "Result, RoomRepoError>" -)] -pub struct DeleteMemberFromRoomCheck { - pub member_id: MemberId, - pub room_id: RoomId, -} - -impl Handler for RoomsRepository { - type Result = - ActFuture, RoomRepoError>; - - fn handle( - &mut self, - msg: DeleteMemberFromRoomCheck, - _ctx: &mut Self::Context, - ) -> Self::Result { - let fut = - if let Some(room) = self.rooms.lock().unwrap().get(&msg.room_id) { - Either::A( - room.send(DeleteMemberCheck(msg.member_id.clone())) - .map_err(|e| RoomRepoError::from(e)) - .map(|r| { - r.map(|_| DeleteMemberFromRoom { - room_id: msg.room_id, - member_id: msg.member_id, - }) - }), - ) - } else { - Either::B(futures::future::err(RoomRepoError::RoomNotFound( - get_local_uri(msg.room_id), - ))) - }; - - Box::new(wrap_future(fut)) - } -} - #[derive(Message)] #[rtype(result = "Result<(), RoomRepoError>")] pub struct DeleteEndpointFromMember { - room_id: RoomId, - member_id: MemberId, - endpoint_id: String, + pub room_id: RoomId, + pub member_id: MemberId, + pub endpoint_id: String, } impl Handler for RoomsRepository { @@ -297,59 +234,12 @@ impl Handler for RoomsRepository { endpoint_id: msg.endpoint_id, member_id: msg.member_id, }); - } else { - return Err(RoomRepoError::RoomNotFound(get_local_uri( - msg.room_id, - ))); } Ok(()) } } -#[derive(Message)] -#[rtype(result = "Result, \ - RoomRepoError>")] -pub struct DeleteEndpointFromMemberCheck { - pub room_id: RoomId, - pub member_id: MemberId, - pub endpoint_id: String, -} - -impl Handler for RoomsRepository { - type Result = - ActFuture, RoomRepoError>; - - fn handle( - &mut self, - msg: DeleteEndpointFromMemberCheck, - _ctx: &mut Self::Context, - ) -> Self::Result { - let fut = if let Some(room) = self.get(&msg.room_id) { - Either::A( - room.send(DeleteEndpointCheck { - member_id: msg.member_id.clone(), - endpoint_id: msg.endpoint_id.clone(), - }) - .map_err(|e| RoomRepoError::from(e)) - .map(|r| { - r.map(|_| DeleteEndpointFromMember { - room_id: msg.room_id, - member_id: msg.member_id, - endpoint_id: msg.endpoint_id, - }) - }), - ) - } else { - Either::B(futures::future::err(RoomRepoError::RoomNotFound( - get_local_uri(msg.room_id), - ))) - }; - - Box::new(wrap_future(fut)) - } -} - #[derive(Message)] #[rtype(result = "Result>, \ RoomRepoError>")] From aed15c9f11f3013f9df49bbc8cbd7bf3a80a466c Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 11 Jul 2019 19:38:27 +0300 Subject: [PATCH 328/735] Move error code into enum, rewrite logic for error returning --- .../control/endpoints/webrtc_play_endpoint.rs | 34 ++-- src/api/control/grpc/server.rs | 48 ++--- src/api/control/local_uri.rs | 29 +-- src/api/control/mod.rs | 19 +- src/api/error_codes.rs | 192 ++++++++++++++++++ src/api/mod.rs | 1 + src/signalling/elements/member.rs | 52 ++--- src/signalling/participants.rs | 39 +--- src/signalling/room.rs | 22 +- src/signalling/room_repo.rs | 46 ++--- 10 files changed, 304 insertions(+), 178 deletions(-) create mode 100644 src/api/error_codes.rs diff --git a/src/api/control/endpoints/webrtc_play_endpoint.rs b/src/api/control/endpoints/webrtc_play_endpoint.rs index 2b6b75e29..0d10fa69b 100644 --- a/src/api/control/endpoints/webrtc_play_endpoint.rs +++ b/src/api/control/endpoints/webrtc_play_endpoint.rs @@ -8,13 +8,16 @@ use serde::{ Deserialize, }; -use crate::api::control::{ - endpoints::webrtc_publish_endpoint::WebRtcPublishId, - grpc::protos::control::{ - Error as ErrorProto, WebRtcPlayEndpoint as WebRtcPlayEndpointProto, +use crate::api::{ + control::{ + endpoints::webrtc_publish_endpoint::WebRtcPublishId, + grpc::protos::control::{ + Error as ErrorProto, WebRtcPlayEndpoint as WebRtcPlayEndpointProto, + }, + local_uri::{LocalUri, LocalUriParseError}, + MemberId, RoomId, TryFromProtobufError, }, - local_uri::{LocalUri, LocalUriParseError}, - MemberId, RoomId, TryFromProtobufError, + error_codes::ErrorCode, }; macro_attr! { @@ -63,21 +66,14 @@ pub enum SrcParseError { LocalUriParseError(String, LocalUriParseError), } -impl Into for &SrcParseError { - fn into(self) -> ErrorProto { - let mut error = ErrorProto::new(); - match &self { - SrcParseError::MissingField(text, _) => { - error.set_code(0); - error.set_status(400); - error.set_element(text.clone()); - error.set_text(self.to_string()); - } - SrcParseError::LocalUriParseError(_, e) => { - error = e.into(); +impl Into for SrcParseError { + fn into(self) -> ErrorCode { + match self { + SrcParseError::MissingField(text, fields) => { + ErrorCode::MissingFieldsInSrcUri(text, fields) } + SrcParseError::LocalUriParseError(_, err) => err.into(), } - error } } diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index 5d146cf50..e67cfb22c 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -29,8 +29,11 @@ use crate::{ }; use super::protos::control_grpc::{create_control_api, ControlApi}; -use crate::signalling::room_repo::{ - DeleteEndpointFromMember, DeleteMemberFromRoom, DeleteRoom, +use crate::{ + api::error_codes::ErrorCode, + signalling::room_repo::{ + DeleteEndpointFromMember, DeleteMemberFromRoom, DeleteRoom, + }, }; #[derive(Debug, Fail)] @@ -78,26 +81,13 @@ impl From for ControlApiError { } } -impl Into for ControlApiError { - fn into(self) -> Error { - let mut error = Error::new(); - match &self { - ControlApiError::LocalUri(e) => error = e.into(), - ControlApiError::TryFromProtobuf(e) => error = e.into(), - ControlApiError::MailboxError(e) => { - error.set_status(500); - error.set_code(0); - error.set_text(format!("Internal server error. {:?}", e)); - error.set_element(String::new()); - } - _ => { - error.set_status(500); - error.set_code(0); - error.set_text(format!("Internal server error. {:?}", self)); - error.set_element(String::new()); - } +impl Into for ControlApiError { + fn into(self) -> ErrorCode { + match self { + ControlApiError::LocalUri(e) => e.into(), + ControlApiError::TryFromProtobuf(e) => e.into(), + _ => ErrorCode::UnknownError(self.to_string()), } - error } } @@ -259,7 +249,7 @@ fn create_response( ControlApiError, >, ) -> Response { - let error: Error = match result { + let error: ErrorCode = match result { Ok(r) => match r { Ok(r) => match r { Ok(sid) => { @@ -267,7 +257,7 @@ fn create_response( response.set_sid(sid); return response; } - Err(ref e) => e.into(), + Err(e) => e.into(), }, Err(e) => e.into(), }, @@ -275,7 +265,7 @@ fn create_response( }; let mut error_response = Response::new(); - error_response.set_error(error); + error_response.set_error(error.into()); error_response } @@ -474,8 +464,8 @@ impl ControlApi for ControlApiService { } Err(e) => { let mut response = GetResponse::new(); - let error: Error = e.into(); - response.set_error(error); + let error: ErrorCode = e.into(); + response.set_error(error.into()); return sink.success(response).map_err(closure); } } @@ -489,10 +479,10 @@ impl ControlApi for ControlApiService { Ok((id, o)) => { elements.insert(id, o); } - Err(ref e) => { + Err(e) => { let mut response = GetResponse::new(); - let error: Error = e.into(); - response.set_error(error); + let error: ErrorCode = e.into(); + response.set_error(error.into()); return sink.success(response).map_err(closure); } } diff --git a/src/api/control/local_uri.rs b/src/api/control/local_uri.rs index 982676919..4fe17c6bb 100644 --- a/src/api/control/local_uri.rs +++ b/src/api/control/local_uri.rs @@ -7,34 +7,26 @@ use failure::Fail; use crate::api::control::grpc::protos::control::Error as ErrorProto; use super::{MemberId, RoomId}; +use crate::api::error_codes::ErrorCode; #[derive(Debug, Fail)] pub enum LocalUriParseError { #[fail(display = "Provided URIs protocol is not 'local://'.")] - NotLocal(String, String), + NotLocal(String), #[fail(display = "Too many ({}) paths in provided URI.", _0)] TooManyFields(usize, String), } -impl Into for &LocalUriParseError { - fn into(self) -> ErrorProto { - let mut error = ErrorProto::new(); - match &self { - LocalUriParseError::NotLocal(_, text) => { - error.set_code(0); - error.set_status(400); - error.set_text(self.to_string()); - error.set_element(text.clone()) +impl Into for LocalUriParseError { + fn into(self) -> ErrorCode { + match self { + LocalUriParseError::NotLocal(text) => { + ErrorCode::ElementIdIsNotLocal(text) } LocalUriParseError::TooManyFields(_, text) => { - error.set_code(0); - error.set_status(400); - error.set_text(self.to_string()); - error.set_element(text.clone()) + ErrorCode::ElementIdIsTooLong(text) } } - - error } } @@ -72,10 +64,7 @@ impl LocalUri { pub fn parse(value: &str) -> Result { let protocol_name: String = value.chars().take(8).collect(); if protocol_name != "local://" { - return Err(LocalUriParseError::NotLocal( - protocol_name, - value.to_string(), - )); + return Err(LocalUriParseError::NotLocal(value.to_string())); } let uri_body = value.chars().skip(8).collect::(); diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index 76bc6c169..102f74c6b 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -31,6 +31,7 @@ pub use self::{ member::{Id as MemberId, MemberSpec}, room::{Id as RoomId, RoomSpec}, }; +use crate::api::error_codes::ErrorCode; #[derive(Debug, Fail)] pub enum TryFromProtobufError { @@ -54,22 +55,12 @@ impl From for TryFromProtobufError { } } -impl Into for &TryFromProtobufError { - fn into(self) -> ErrorProto { - let mut error = ErrorProto::new(); +impl Into for TryFromProtobufError { + fn into(self) -> ErrorCode { match self { - TryFromProtobufError::SrcUriError(e) => { - error = e.into(); - } - _ => { - // TODO - error.set_code(0); - error.set_status(400); - error.set_text(self.to_string()); - error.set_element(String::new()); - } + TryFromProtobufError::SrcUriError(e) => e.into(), + _ => ErrorCode::UnknownError(self.to_string()), } - error } } diff --git a/src/api/error_codes.rs b/src/api/error_codes.rs new file mode 100644 index 000000000..9002c7466 --- /dev/null +++ b/src/api/error_codes.rs @@ -0,0 +1,192 @@ +use crate::api::control::{ + grpc::protos::control::Error as ErrorProto, + local_uri::{LocalUri, LocalUriParseError}, +}; + +pub enum ErrorCode { + /// Unknown server error. + /// + /// Code: __1000__. + UnknownError(String), + + //////////////////////////////////// + // Not found (1001 - 1099 codes) // + ////////////////////////////////// + /// Publish endpoint not found. + /// + /// Code: __1001__. + PublishEndpointNotFound(LocalUri), + /// Play endpoint not found. + /// + /// Code: __1002__. + PlayEndpointNotFound(LocalUri), + /// Member not found. + /// + /// Code: __1003__. + MemberNotFound(LocalUri), + /// Room not found. + /// + /// Code: __1004__. + RoomNotFound(LocalUri), + EndpointNotFound(LocalUri), + + ////////////////////////////////////// + // Spec errors (1200 - 1299 codes) // + //////////////////////////////////// + /// Medea expects `Room` element in pipeline but received not him. + /// + /// Code: __1200__. + NotRoomInSpec(LocalUri), + /// Medea expects `Member` element in pipeline but received not him. + /// + /// Code: __1201__. + NotMemberInSpec(LocalUri), + /// Medea expects `Endpoint` element in pipeline but received not him. + /// + /// Code: __1202__. + NotEndpointInSpec(LocalUri), + /// Invalid source URI in play endpoint. + /// + /// Code: __1203__. + InvalidSrcUri(LocalUri), + + ///////////////////////////////// + // Parse errors (1300 - 1399) // + /////////////////////////////// + ElementIdIsNotLocal(String), + ElementIdIsTooLong(String), + MissingFieldsInSrcUri(String, Vec), + + ///////////////////////////// + // Conflict (1400 - 1499) // + /////////////////////////// + MemberAlreadyExists(LocalUri), + EndpointAlreadyExists(LocalUri), + RoomAlreadyExists(LocalUri), +} + +impl Into for ErrorCode { + fn into(self) -> ErrorProto { + let mut error = ErrorProto::new(); + error.set_status(0); + match self { + ErrorCode::UnknownError(msg) => { + error.set_text(format!( + "Unexpected error happened. Here is it '{}'.", + msg + )); + error.set_element(String::new()); + error.set_code(1000); + } + + //////////////////////////////////// + // Not found (1001 - 1099 codes) // + ////////////////////////////////// + ErrorCode::PublishEndpointNotFound(id) => { + error.set_text("Publish endpoint not found".to_string()); + error.set_element(id.to_string()); + error.set_code(1001) + } + ErrorCode::PlayEndpointNotFound(id) => { + error.set_text("Play endpoint not found.".to_string()); + error.set_element(id.to_string()); + error.set_code(1002); + } + ErrorCode::MemberNotFound(id) => { + error.set_text("Member not found.".to_string()); + error.set_element(id.to_string()); + error.set_code(1003); + } + ErrorCode::RoomNotFound(id) => { + error.set_text("Room not found.".to_string()); + error.set_element(id.to_string()); + error.set_code(1004); + } + ErrorCode::EndpointNotFound(id) => { + error.set_text("Endpoint not found.".to_string()); + error.set_element(id.to_string()); + error.set_code(1405); + } + + ////////////////////////////////////// + // Spec errors (1200 - 1299 codes) // + //////////////////////////////////// + ErrorCode::NotRoomInSpec(id) => { + error.set_text( + "Expecting Room element but it's not.".to_string(), + ); + error.set_element(id.to_string()); + error.set_code(1200); + } + ErrorCode::NotMemberInSpec(id) => { + error.set_text( + "Expecting Member element but it's not.".to_string(), + ); + error.set_element(id.to_string()); + error.set_code(1201); + } + ErrorCode::NotEndpointInSpec(id) => { + error.set_text( + "Expecting Member element but it's not.".to_string(), + ); + error.set_element(id.to_string()); + error.set_code(1202); + } + ErrorCode::InvalidSrcUri(id) => { + error.set_text( + "Invalid source ID in publish endpoint spec.".to_string(), + ); + error.set_element(id.to_string()); + error.set_code(1203); + } + + ///////////////////////////////// + // Parse errors (1300 - 1399) // + /////////////////////////////// + ErrorCode::ElementIdIsNotLocal(uri) => { + error.set_text( + "Element's ID's URI has not have 'local://' protocol." + .to_string(), + ); + error.set_element(uri); + error.set_code(1300); + } + ErrorCode::ElementIdIsTooLong(uri) => { + error.set_text( + "In provided element's ID too many slashes.".to_string(), + ); + error.set_element(uri); + error.set_code(1301); + } + ErrorCode::MissingFieldsInSrcUri(uri, fields) => { + error.set_text(format!( + "Missing {:?} fields in element ID.", + fields + )); + error.set_element(uri); + error.set_code(1302); + } + + ///////////////////////////// + // Conflict (1400 - 1499) // + /////////////////////////// + ErrorCode::MemberAlreadyExists(id) => { + error.set_text("Member already exists.".to_string()); + error.set_element(id.to_string()); + error.set_code(1400); + } + ErrorCode::EndpointAlreadyExists(id) => { + error.set_text("Endpoint already exists.".to_string()); + error.set_element(id.to_string()); + error.set_code(1401); + } + ErrorCode::RoomAlreadyExists(id) => { + error.set_text("Room already exists.".to_string()); + error.set_element(id.to_string()); + error.set_code(1402); + } + } + + error + } +} diff --git a/src/api/mod.rs b/src/api/mod.rs index 1c66e73e5..ac72696fa 100644 --- a/src/api/mod.rs +++ b/src/api/mod.rs @@ -2,3 +2,4 @@ pub mod client; pub mod control; +pub mod error_codes; diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index 7d0a84060..7b4752935 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -25,6 +25,7 @@ use crate::{ }; use super::endpoints::webrtc::{WebRtcPlayEndpoint, WebRtcPublishEndpoint}; +use crate::api::error_codes::ErrorCode; /// Errors which may occur while loading [`Member`]s from [`RoomSpec`]. #[derive(Debug, Fail)] @@ -59,36 +60,28 @@ pub enum MemberError { PlayEndpointNotFound(LocalUri), } -impl Into for &MembersLoadError { - fn into(self) -> ErrorProto { - let mut error = ErrorProto::new(); - match &self { - MembersLoadError::TryFromError(_, id) => { - error.set_element(id.to_string()); - error.set_code(0); // TODO - error.set_status(400); - error.set_text(self.to_string()); - } +impl Into for MembersLoadError { + fn into(self) -> ErrorCode { + match self { + MembersLoadError::TryFromError(e, id) => match e { + TryFromElementError::NotEndpoint => { + ErrorCode::NotEndpointInSpec(id) + } + TryFromElementError::NotMember => { + ErrorCode::NotMemberInSpec(id) + } + TryFromElementError::NotRoom => ErrorCode::NotRoomInSpec(id), + }, MembersLoadError::MemberNotFound(id) => { - error.set_element(id.to_string()); - error.set_code(0); // TODO - error.set_status(400); - error.set_text(self.to_string()); + ErrorCode::MemberNotFound(id) } MembersLoadError::PublishEndpointNotFound(id) => { - error.set_element(id.to_string()); - error.set_code(0); // TODO - error.set_status(400); - error.set_text(self.to_string()); + ErrorCode::PublishEndpointNotFound(id) } MembersLoadError::PlayEndpointNotFound(id) => { - error.set_element(id.to_string()); - error.set_code(0); // TODO - error.set_status(400); - error.set_text(self.to_string()); + ErrorCode::PlayEndpointNotFound(id) } } - error } } @@ -113,6 +106,19 @@ impl Into for &MemberError { } } +impl Into for MemberError { + fn into(self) -> ErrorCode { + match self { + MemberError::PlayEndpointNotFound(id) => { + ErrorCode::PlayEndpointNotFound(id) + } + MemberError::PublishEndpointNotFound(id) => { + ErrorCode::PublishEndpointNotFound(id) + } + } + } +} + /// [`Member`] is member of [`Room`] with [`RpcConnection`]. #[derive(Debug)] pub struct Member(RefCell); diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index a06b230d0..227d0bada 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -37,6 +37,7 @@ use crate::{ MemberId, MemberSpec, RoomId, RoomSpec, WebRtcPlayId, WebRtcPublishId, }, + error_codes::ErrorCode, }, log::prelude::*, media::IceUser, @@ -92,45 +93,23 @@ impl From for ParticipantServiceErr { } } -impl Into for &ParticipantServiceErr { - fn into(self) -> ErrorProto { - let mut error = ErrorProto::new(); - match &self { +impl Into for ParticipantServiceErr { + fn into(self) -> ErrorCode { + match self { ParticipantServiceErr::EndpointNotFound(id) => { - error.set_element(id.to_string()); - error.set_code(0); // TODO - error.set_status(404); - error.set_text(self.to_string()); + ErrorCode::EndpointNotFound(id) } ParticipantServiceErr::ParticipantNotFound(id) => { - error.set_element(id.to_string()); - error.set_code(0); // TODO - error.set_status(404); - error.set_text(self.to_string()); + ErrorCode::MemberNotFound(id) } ParticipantServiceErr::ParticipantAlreadyExists(id) => { - error.set_element(id.to_string()); - error.set_code(0); // TODO - error.set_status(400); - error.set_text(self.to_string()); + ErrorCode::MemberAlreadyExists(id) } ParticipantServiceErr::EndpointAlreadyExists(id) => { - error.set_element(id.to_string()); - error.set_code(0); // TODO - error.set_status(400); - error.set_text(self.to_string()); - } - _ => { - error.set_element(String::new()); - error.set_code(0); // TODO - error.set_status(500); - error.set_text(format!( - "Unknow ParticipantService error. {:?}", - self - )); + ErrorCode::EndpointAlreadyExists(id) } + _ => ErrorCode::UnknownError(self.to_string()), } - error } } diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 44c2d0cd0..ed3aeba9b 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -30,6 +30,7 @@ use crate::{ Endpoint as EndpointSpec, MemberId, MemberSpec, RoomId, TryFromElementError, WebRtcPlayId, WebRtcPublishId, }, + error_codes::ErrorCode, }, log::prelude::*, media::{ @@ -109,21 +110,14 @@ impl From for RoomError { } } -impl Into for &RoomError { - fn into(self) -> ErrorProto { - let mut error = ErrorProto::new(); - match &self { - RoomError::MemberError(e) => error = e.into(), - RoomError::ParticipantServiceErr(e) => error = e.into(), - RoomError::MembersLoadError(e) => error = e.into(), - _ => { - error.set_element(String::new()); - error.set_code(0); // TODO - error.set_status(500); - error.set_text(format!("Unknow RoomError error. {:?}", self)); - } +impl Into for RoomError { + fn into(self) -> ErrorCode { + match self { + RoomError::MemberError(e) => e.into(), + RoomError::MembersLoadError(e) => e.into(), + RoomError::ParticipantServiceErr(e) => e.into(), + _ => ErrorCode::UnknownError(self.to_string()), } - error } } diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs index a1909fc5e..76b62b901 100644 --- a/src/signalling/room_repo.rs +++ b/src/signalling/room_repo.rs @@ -11,11 +11,16 @@ use futures::future::{Either, Future}; use hashbrown::HashMap; use crate::{ - api::control::{ - grpc::protos::control::{Element as ElementProto, Error as ErrorProto}, - local_uri::LocalUri, - room::RoomSpec, - Endpoint as EndpointSpec, MemberId, MemberSpec, RoomId, + api::{ + control::{ + grpc::protos::control::{ + Element as ElementProto, Error as ErrorProto, + }, + local_uri::LocalUri, + room::RoomSpec, + Endpoint as EndpointSpec, MemberId, MemberSpec, RoomId, + }, + error_codes::ErrorCode, }, signalling::{ room::{ @@ -51,33 +56,16 @@ impl From for RoomRepoError { } } -impl Into for RoomRepoError { - fn into(self) -> ErrorProto { - let mut error = ErrorProto::new(); - match &self { - RoomRepoError::RoomNotFound(id) => { - error.set_element(id.to_string()); - error.set_code(0); // TODO - error.set_status(404); - error.set_text(self.to_string()); - } +impl Into for RoomRepoError { + fn into(self) -> ErrorCode { + match self { + RoomRepoError::RoomNotFound(id) => ErrorCode::RoomNotFound(id), RoomRepoError::RoomAlreadyExists(id) => { - error.set_element(id.to_string()); - error.set_code(0); // TODO - error.set_status(400); // TODO: Maybe 409?? - error.set_text(self.to_string()); - } - RoomRepoError::RoomError(e) => { - error = e.into(); - } - _ => { - error.set_element(String::new()); - error.set_code(0); // TODO - error.set_status(500); - error.set_text(format!("Unknow RoomRepo error. {:?}", self)); + ErrorCode::RoomAlreadyExists(id) } + RoomRepoError::RoomError(e) => e.into(), + _ => ErrorCode::UnknownError(self.to_string()), } - error } } From b100c56bb41fa327b7a26fcb12eb45d6c07ca5eb Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 11 Jul 2019 19:56:27 +0300 Subject: [PATCH 329/735] Improve errors in Create --- src/api/control/grpc/server.rs | 71 ++++++++++++++++------------------ src/api/error_codes.rs | 37 ++++++++++++++++++ 2 files changed, 70 insertions(+), 38 deletions(-) diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index e67cfb22c..5dd3d3066 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -269,6 +269,17 @@ fn create_response( error_response } +fn error_response( + sink: UnarySink, + error_code: ErrorCode, +) -> impl Future { + let mut response = Response::new(); + let error: Error = error_code.into(); + response.set_error(error); + + sink.success(response).map_err(|_| ()) +} + impl ControlApi for ControlApiService { /// Implementation for `Create` method of gRPC control API. fn create( @@ -285,16 +296,12 @@ impl ControlApi for ControlApiService { sink.success(create_response(r)).map_err(|_| ()) })); } else { - let mut error_response = Response::new(); - let mut error = Error::new(); - error.set_status(400); - error.set_code(0); - error.set_text( - "ID for room but element is not room.".to_string(), - ); - error.set_element(String::new()); - error_response.set_error(error); - ctx.spawn(sink.success(error_response).map_err(|_| ())); + ctx.spawn(error_response( + sink, + ErrorCode::ElementIdForRoomButElementIsNot( + req.get_id().to_string(), + ), + )); } } else if local_uri.is_member_uri() { if req.has_member() { @@ -302,16 +309,12 @@ impl ControlApi for ControlApiService { sink.success(create_response(r)).map_err(|_| ()) })); } else { - let mut error_response = Response::new(); - let mut error = Error::new(); - error.set_status(400); - error.set_code(0); - error.set_text( - "ID for member but element is not member.".to_string(), - ); - error.set_element(String::new()); - error_response.set_error(error); - ctx.spawn(sink.success(error_response).map_err(|_| ())); + ctx.spawn(error_response( + sink, + ErrorCode::ElementIdForMemberButElementIsNot( + req.get_id().to_string(), + ), + )); } } else if local_uri.is_endpoint_uri() { if req.has_webrtc_pub() || req.has_webrtc_play() { @@ -319,26 +322,18 @@ impl ControlApi for ControlApiService { move |r| sink.success(create_response(r)).map_err(|_| ()), )); } else { - let mut error_response = Response::new(); - let mut error = Error::new(); - error.set_status(400); - error.set_code(0); - error.set_text( - "ID for endpoint but element is not endpoint.".to_string(), - ); - error.set_element(String::new()); - error_response.set_error(error); - ctx.spawn(sink.success(error_response).map_err(|_| ())); + ctx.spawn(error_response( + sink, + ErrorCode::ElementIdForEndpointButElementIsNot( + req.get_id().to_string(), + ), + )); } } else { - let mut error_response = Response::new(); - let mut error = Error::new(); - error.set_status(400); - error.set_code(0); - error.set_text(format!("Invalid ID '{}'.", req.get_id())); - error.set_element(local_uri.to_string()); - error_response.set_error(error); - ctx.spawn(sink.success(error_response).map_err(|_| ())); + ctx.spawn(error_response( + sink, + ErrorCode::InvalidElementUri(req.get_id().to_string()), + )); } } diff --git a/src/api/error_codes.rs b/src/api/error_codes.rs index 9002c7466..64e2e18e9 100644 --- a/src/api/error_codes.rs +++ b/src/api/error_codes.rs @@ -49,6 +49,11 @@ pub enum ErrorCode { /// /// Code: __1203__. InvalidSrcUri(LocalUri), + // TODO: simplify names + ElementIdForRoomButElementIsNot(String), + ElementIdForMemberButElementIsNot(String), + ElementIdForEndpointButElementIsNot(String), + InvalidElementUri(String), ///////////////////////////////// // Parse errors (1300 - 1399) // @@ -139,6 +144,38 @@ impl Into for ErrorCode { error.set_element(id.to_string()); error.set_code(1203); } + ErrorCode::ElementIdForRoomButElementIsNot(id) => { + error.set_text( + "You provided ID for Room but element's spec is not for \ + Room." + .to_string(), + ); + error.set_element(id); + error.set_code(1204); + } + ErrorCode::ElementIdForMemberButElementIsNot(id) => { + error.set_text( + "You provided ID for Member but element's spec is not for \ + Member." + .to_string(), + ); + error.set_element(id); + error.set_code(1205); + } + ErrorCode::ElementIdForEndpointButElementIsNot(id) => { + error.set_text( + "You provided ID for Endpoint but element's spec is not \ + for Endpoint." + .to_string(), + ); + error.set_element(id); + error.set_code(1206); + } + ErrorCode::InvalidElementUri(id) => { + error.set_text("Invalid element's URI".to_string()); + error.set_element(id); + error.set_code(1207); + } ///////////////////////////////// // Parse errors (1300 - 1399) // From 9f2ce84d13d5de00a4f10dacb2254c6d9eb77093 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 11 Jul 2019 20:09:46 +0300 Subject: [PATCH 330/735] Add docs for errors, fix numeration --- src/api/error_codes.rs | 94 +++++++++++++++++++++++++++++++----------- 1 file changed, 69 insertions(+), 25 deletions(-) diff --git a/src/api/error_codes.rs b/src/api/error_codes.rs index 64e2e18e9..edb86257c 100644 --- a/src/api/error_codes.rs +++ b/src/api/error_codes.rs @@ -1,8 +1,18 @@ +//! All errors which medea can return to control API user. +//! +//! # Error codes ranges +//! * __1000...1000__ Unknow server error +//! * __1001...1099__ Not found errors +//! * __1100...1199__ Spec errors +//! * __1200...1299__ Parse errors +//! * __1300...1399__ Conflicts + use crate::api::control::{ grpc::protos::control::Error as ErrorProto, local_uri::{LocalUri, LocalUriParseError}, }; +/// Medea control API errors. pub enum ErrorCode { /// Unknown server error. /// @@ -28,45 +38,79 @@ pub enum ErrorCode { /// /// Code: __1004__. RoomNotFound(LocalUri), + /// Endpoint not found. + /// + /// Code: __1005__. EndpointNotFound(LocalUri), ////////////////////////////////////// - // Spec errors (1200 - 1299 codes) // + // Spec errors (1100 - 1199 codes) // //////////////////////////////////// /// Medea expects `Room` element in pipeline but received not him. /// - /// Code: __1200__. + /// Code: __1100__. NotRoomInSpec(LocalUri), /// Medea expects `Member` element in pipeline but received not him. /// - /// Code: __1201__. + /// Code: __1101__. NotMemberInSpec(LocalUri), /// Medea expects `Endpoint` element in pipeline but received not him. /// - /// Code: __1202__. + /// Code: __1102__. NotEndpointInSpec(LocalUri), /// Invalid source URI in play endpoint. /// - /// Code: __1203__. + /// Code: __1103__. InvalidSrcUri(LocalUri), - // TODO: simplify names + /// Provided element ID to Room element but element spec is not for Room. + /// + /// Code: __1104__. ElementIdForRoomButElementIsNot(String), + /// Provided element ID to Member element but element spec is not for + /// Member. + /// + /// Code: __1105__. ElementIdForMemberButElementIsNot(String), + /// Provided element ID to Endpoint element but element spec is not for + /// Endpoint. + /// + /// Code: __1106__. ElementIdForEndpointButElementIsNot(String), + /// Invalid ID for element. + /// + /// Code: __1107__ InvalidElementUri(String), ///////////////////////////////// - // Parse errors (1300 - 1399) // + // Parse errors (1200 - 1299) // /////////////////////////////// + /// Element's ID don't have "local://" prefix. + /// + /// Code: __1200__. ElementIdIsNotLocal(String), + /// Element's ID have too many paths (slashes). + /// + /// Code: __1201__. ElementIdIsTooLong(String), + /// Source URI in publish endpoint missing some fields. + /// + /// Code: __1202__. MissingFieldsInSrcUri(String, Vec), ///////////////////////////// - // Conflict (1400 - 1499) // + // Conflict (1300 - 1399) // /////////////////////////// + /// Member already exists. + /// + /// Code: __1300__. MemberAlreadyExists(LocalUri), + /// Endpoint already exists. + /// + /// Code: __1301__. EndpointAlreadyExists(LocalUri), + /// Room already exists. + /// + /// Code: __1302__. RoomAlreadyExists(LocalUri), } @@ -114,35 +158,35 @@ impl Into for ErrorCode { } ////////////////////////////////////// - // Spec errors (1200 - 1299 codes) // + // Spec errors (1100 - 1199 codes) // //////////////////////////////////// ErrorCode::NotRoomInSpec(id) => { error.set_text( "Expecting Room element but it's not.".to_string(), ); error.set_element(id.to_string()); - error.set_code(1200); + error.set_code(1100); } ErrorCode::NotMemberInSpec(id) => { error.set_text( "Expecting Member element but it's not.".to_string(), ); error.set_element(id.to_string()); - error.set_code(1201); + error.set_code(1101); } ErrorCode::NotEndpointInSpec(id) => { error.set_text( "Expecting Member element but it's not.".to_string(), ); error.set_element(id.to_string()); - error.set_code(1202); + error.set_code(1102); } ErrorCode::InvalidSrcUri(id) => { error.set_text( "Invalid source ID in publish endpoint spec.".to_string(), ); error.set_element(id.to_string()); - error.set_code(1203); + error.set_code(1103); } ErrorCode::ElementIdForRoomButElementIsNot(id) => { error.set_text( @@ -151,7 +195,7 @@ impl Into for ErrorCode { .to_string(), ); error.set_element(id); - error.set_code(1204); + error.set_code(1104); } ErrorCode::ElementIdForMemberButElementIsNot(id) => { error.set_text( @@ -160,7 +204,7 @@ impl Into for ErrorCode { .to_string(), ); error.set_element(id); - error.set_code(1205); + error.set_code(1105); } ErrorCode::ElementIdForEndpointButElementIsNot(id) => { error.set_text( @@ -169,16 +213,16 @@ impl Into for ErrorCode { .to_string(), ); error.set_element(id); - error.set_code(1206); + error.set_code(1106); } ErrorCode::InvalidElementUri(id) => { error.set_text("Invalid element's URI".to_string()); error.set_element(id); - error.set_code(1207); + error.set_code(1107); } ///////////////////////////////// - // Parse errors (1300 - 1399) // + // Parse errors (1200 - 1299) // /////////////////////////////// ErrorCode::ElementIdIsNotLocal(uri) => { error.set_text( @@ -186,14 +230,14 @@ impl Into for ErrorCode { .to_string(), ); error.set_element(uri); - error.set_code(1300); + error.set_code(1200); } ErrorCode::ElementIdIsTooLong(uri) => { error.set_text( "In provided element's ID too many slashes.".to_string(), ); error.set_element(uri); - error.set_code(1301); + error.set_code(1201); } ErrorCode::MissingFieldsInSrcUri(uri, fields) => { error.set_text(format!( @@ -201,26 +245,26 @@ impl Into for ErrorCode { fields )); error.set_element(uri); - error.set_code(1302); + error.set_code(1202); } ///////////////////////////// - // Conflict (1400 - 1499) // + // Conflict (1300 - 1399) // /////////////////////////// ErrorCode::MemberAlreadyExists(id) => { error.set_text("Member already exists.".to_string()); error.set_element(id.to_string()); - error.set_code(1400); + error.set_code(1300); } ErrorCode::EndpointAlreadyExists(id) => { error.set_text("Endpoint already exists.".to_string()); error.set_element(id.to_string()); - error.set_code(1401); + error.set_code(1301); } ErrorCode::RoomAlreadyExists(id) => { error.set_text("Room already exists.".to_string()); error.set_element(id.to_string()); - error.set_code(1402); + error.set_code(1302); } } From 8d229bd7708667e2c330e6f20b11701e0dc2cac7 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 11 Jul 2019 20:23:37 +0300 Subject: [PATCH 331/735] Fix warns and formatting --- .../control/endpoints/webrtc_play_endpoint.rs | 4 +-- src/api/control/grpc/server.rs | 28 +++++++++---------- src/api/control/local_uri.rs | 3 +- src/api/control/mod.rs | 3 +- src/api/error_codes.rs | 3 +- src/signalling/participants.rs | 1 - src/signalling/room.rs | 4 +-- src/signalling/room_repo.rs | 9 ++---- 8 files changed, 22 insertions(+), 33 deletions(-) diff --git a/src/api/control/endpoints/webrtc_play_endpoint.rs b/src/api/control/endpoints/webrtc_play_endpoint.rs index 0d10fa69b..e911d3844 100644 --- a/src/api/control/endpoints/webrtc_play_endpoint.rs +++ b/src/api/control/endpoints/webrtc_play_endpoint.rs @@ -11,9 +11,7 @@ use serde::{ use crate::api::{ control::{ endpoints::webrtc_publish_endpoint::WebRtcPublishId, - grpc::protos::control::{ - Error as ErrorProto, WebRtcPlayEndpoint as WebRtcPlayEndpointProto, - }, + grpc::protos::control::WebRtcPlayEndpoint as WebRtcPlayEndpointProto, local_uri::{LocalUri, LocalUriParseError}, MemberId, RoomId, TryFromProtobufError, }, diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index 5dd3d3066..38eb21ea5 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -8,33 +8,31 @@ use futures::future::{Either, Future}; use grpcio::{Environment, RpcContext, Server, ServerBuilder, UnarySink}; use crate::{ - api::control::{ - grpc::protos::control::{ - ApplyRequest, CreateRequest, Error, GetResponse, IdRequest, - Response, + api::{ + control::{ + grpc::protos::control::{ + ApplyRequest, CreateRequest, Error, GetResponse, IdRequest, + Response, + }, + local_uri::{LocalUri, LocalUriParseError}, + Endpoint, MemberSpec, RoomSpec, TryFromElementError, + TryFromProtobufError, }, - local_uri::{LocalUri, LocalUriParseError}, - Endpoint, MemberSpec, RoomSpec, TryFromElementError, - TryFromProtobufError, + error_codes::ErrorCode, }, log::prelude::*, signalling::{ room::RoomError, room_repo::{ - CreateEndpointInRoom, CreateMemberInRoom, GetEndpoint, GetMember, - GetRoom, RoomRepoError, RoomsRepository, StartRoom, + CreateEndpointInRoom, CreateMemberInRoom, DeleteEndpointFromMember, + DeleteMemberFromRoom, DeleteRoom, GetEndpoint, GetMember, GetRoom, + RoomRepoError, RoomsRepository, StartRoom, }, }, App, }; use super::protos::control_grpc::{create_control_api, ControlApi}; -use crate::{ - api::error_codes::ErrorCode, - signalling::room_repo::{ - DeleteEndpointFromMember, DeleteMemberFromRoom, DeleteRoom, - }, -}; #[derive(Debug, Fail)] enum ControlApiError { diff --git a/src/api/control/local_uri.rs b/src/api/control/local_uri.rs index 4fe17c6bb..418a54f0b 100644 --- a/src/api/control/local_uri.rs +++ b/src/api/control/local_uri.rs @@ -4,10 +4,9 @@ use std::fmt; use failure::Fail; -use crate::api::control::grpc::protos::control::Error as ErrorProto; +use crate::api::error_codes::ErrorCode; use super::{MemberId, RoomId}; -use crate::api::error_codes::ErrorCode; #[derive(Debug, Fail)] pub enum LocalUriParseError { diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index 102f74c6b..ba615bef9 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -13,7 +13,7 @@ use std::{convert::TryFrom as _, fs::File, io::Read as _, path::Path}; use failure::{Error, Fail}; use serde::Deserialize; -use crate::api::control::grpc::protos::control::Error as ErrorProto; +use crate::api::error_codes::ErrorCode; use self::{ endpoints::{ @@ -31,7 +31,6 @@ pub use self::{ member::{Id as MemberId, MemberSpec}, room::{Id as RoomId, RoomSpec}, }; -use crate::api::error_codes::ErrorCode; #[derive(Debug, Fail)] pub enum TryFromProtobufError { diff --git a/src/api/error_codes.rs b/src/api/error_codes.rs index edb86257c..e98aeb341 100644 --- a/src/api/error_codes.rs +++ b/src/api/error_codes.rs @@ -8,8 +8,7 @@ //! * __1300...1399__ Conflicts use crate::api::control::{ - grpc::protos::control::Error as ErrorProto, - local_uri::{LocalUri, LocalUriParseError}, + grpc::protos::control::Error as ErrorProto, local_uri::LocalUri, }; /// Medea control API errors. diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 227d0bada..f1a8709b7 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -32,7 +32,6 @@ use crate::{ WebRtcPlayEndpoint as WebRtcPlayEndpointSpec, WebRtcPublishEndpoint as WebRtcPublishEndpointSpec, }, - grpc::protos::control::Error as ErrorProto, local_uri::LocalUri, MemberId, MemberSpec, RoomId, RoomSpec, WebRtcPlayId, WebRtcPublishId, diff --git a/src/signalling/room.rs b/src/signalling/room.rs index ed3aeba9b..9940194df 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -22,8 +22,8 @@ use crate::{ }, control::{ grpc::protos::control::{ - Element as ElementProto, Error as ErrorProto, Member_Element, - Room as RoomProto, Room_Element, + Element as ElementProto, Member_Element, Room as RoomProto, + Room_Element, }, local_uri::LocalUri, room::RoomSpec, diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs index 76b62b901..6f437aaa9 100644 --- a/src/signalling/room_repo.rs +++ b/src/signalling/room_repo.rs @@ -13,12 +13,9 @@ use hashbrown::HashMap; use crate::{ api::{ control::{ - grpc::protos::control::{ - Element as ElementProto, Error as ErrorProto, - }, - local_uri::LocalUri, - room::RoomSpec, - Endpoint as EndpointSpec, MemberId, MemberSpec, RoomId, + grpc::protos::control::Element as ElementProto, + local_uri::LocalUri, room::RoomSpec, Endpoint as EndpointSpec, + MemberId, MemberSpec, RoomId, }, error_codes::ErrorCode, }, From 35af30ab25a423d3feffa1f5a2085b96ba5da13a Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 11 Jul 2019 20:33:07 +0300 Subject: [PATCH 332/735] Fix parse_local_uri macro --- src/api/control/grpc/server.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index 38eb21ea5..23330c9f8 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -108,11 +108,8 @@ macro_rules! parse_local_uri { Ok(o) => o, Err(e) => { let mut error_response = <$response>::new(); - let mut error = Error::new(); - error.set_status(400); - error.set_code(0); - error.set_text(format!("Invalid ID [id = {}]. {}", $uri, e)); - error.set_element($uri.to_string()); + let error: ErrorCode = e.into(); + let error: Error = error.into(); error_response.set_error(error); $ctx.spawn($sink.success(error_response).map_err(|_| ())); return; From 0cabfab4ba829f55c035470681d7f5b3bb0beaf7 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 12 Jul 2019 12:25:07 +0300 Subject: [PATCH 333/735] Handle mailbox errors --- src/api/control/grpc/server.rs | 163 ++++++++++++++++++++++----------- 1 file changed, 109 insertions(+), 54 deletions(-) diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index 23330c9f8..7c9be1994 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -272,7 +272,9 @@ fn error_response( let error: Error = error_code.into(); response.set_error(error); - sink.success(response).map_err(|_| ()) + sink.success(response).map_err(|e| { + warn!("Error while sending Error response by gRPC. {:?}", e) + }) } impl ControlApi for ControlApiService { @@ -301,7 +303,12 @@ impl ControlApi for ControlApiService { } else if local_uri.is_member_uri() { if req.has_member() { ctx.spawn(self.create_member(req, local_uri).then(move |r| { - sink.success(create_response(r)).map_err(|_| ()) + sink.success(create_response(r)).map_err(|e| { + warn!( + "Error while sending Create response by gRPC. {:?}", + e + ) + }) })); } else { ctx.spawn(error_response( @@ -314,7 +321,15 @@ impl ControlApi for ControlApiService { } else if local_uri.is_endpoint_uri() { if req.has_webrtc_pub() || req.has_webrtc_play() { ctx.spawn(self.create_endpoint(req, local_uri).then( - move |r| sink.success(create_response(r)).map_err(|_| ()), + move |r| { + sink.success(create_response(r)).map_err(|e| { + warn!( + "Error while sending Create response by gRPC. \ + {:?}", + e + ) + }) + }, )); } else { ctx.spawn(error_response( @@ -387,17 +402,41 @@ impl ControlApi for ControlApiService { ctx.spawn( mega_delete_endpoints_fut .join3(mega_delete_member_fut, mega_delete_room_fut) - .map_err(|_| ()) - .and_then(move |(member, endpoint, room)| { - member - .into_iter() - .chain(endpoint.into_iter()) - .chain(room.into_iter()) - .for_each(|r| r.unwrap()); - // TODO - let mut response = Response::new(); - response.set_sid(HashMap::new()); - sink.success(response).map_err(|_| ()) + .map_err(|e| { + warn!("Control API Delete method mailbox error. {:?}", e) + }) + .then(move |result| { + let map_err_closure = |e| { + warn!( + "Error while sending Delete response by gRPC. {:?}", + e + ) + }; + match result { + Ok((member, endpoint, room)) => { + member + .into_iter() + .chain(endpoint.into_iter()) + .chain(room.into_iter()) + .for_each(|r| r.unwrap()); + // TODO + let mut response = Response::new(); + response.set_sid(HashMap::new()); + sink.success(response).map_err(map_err_closure) + } + Err(e) => { + warn!( + "Control API Delete method mailbox error. {:?}", + e + ); + let mut response = Response::new(); + let error: Error = + ErrorCode::UnknownError(format!("{:?}", e)) + .into(); + response.set_error(error); + sink.success(response).map_err(map_err_closure) + } + } }), ); } @@ -436,52 +475,68 @@ impl ControlApi for ControlApiService { let member_fut = self.room_repository.send(GetMember(member_ids)); let endpoint_fut = self.room_repository.send(GetEndpoint(endpoint_ids)); - let mega_future = room_fut - .join3(member_fut, endpoint_fut) - .map_err(|e| println!("{:?}", e)) - .and_then(|(room, member, endpoint)| { - let mut elements = HashMap::new(); - let mut elements_results = Vec::new(); - - let results = vec![room, member, endpoint]; - - let closure = |_| (); - - for result in results { - match result { - Ok(o) => { - elements_results.push(o); + let mega_future = + room_fut.join3(member_fut, endpoint_fut).then(|result| { + let grpc_err_closure = + |e| warn!("Error while sending Get response. {:?}", e); + + match result { + Ok((room, member, endpoint)) => { + let mut elements = HashMap::new(); + let mut elements_results = Vec::new(); + + let results = vec![room, member, endpoint]; + + for result in results { + match result { + Ok(o) => { + elements_results.push(o); + } + Err(e) => { + let mut response = GetResponse::new(); + let error: ErrorCode = e.into(); + response.set_error(error.into()); + return sink + .success(response) + .map_err(grpc_err_closure); + } + } } - Err(e) => { - let mut response = GetResponse::new(); - let error: ErrorCode = e.into(); - response.set_error(error.into()); - return sink.success(response).map_err(closure); + + let elements_results = elements_results + .into_iter() + .flat_map(|e| e.into_iter()); + + for element in elements_results { + match element { + Ok((id, o)) => { + elements.insert(id, o); + } + Err(e) => { + let mut response = GetResponse::new(); + let error: ErrorCode = e.into(); + response.set_error(error.into()); + return sink + .success(response) + .map_err(grpc_err_closure); + } + } } - } - } - let elements_results = - elements_results.into_iter().flat_map(|e| e.into_iter()); + let mut response = GetResponse::new(); + response.set_elements(elements); - for element in elements_results { - match element { - Ok((id, o)) => { - elements.insert(id, o); - } - Err(e) => { - let mut response = GetResponse::new(); - let error: ErrorCode = e.into(); - response.set_error(error.into()); - return sink.success(response).map_err(closure); - } + sink.success(response).map_err(grpc_err_closure) + } + Err(e) => { + warn!("Control API Get method mailbox error. {:?}", e); + let mut response = GetResponse::new(); + let error: Error = + ErrorCode::UnknownError(format!("{:?}", e)).into(); + response.set_error(error); + sink.success(response).map_err(grpc_err_closure) } } - - let mut response = GetResponse::new(); - response.set_elements(elements); - - sink.success(response).map_err(closure) }); ctx.spawn(mega_future); From 33e19d59ec737a426f081874b964a62ee8314651 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 12 Jul 2019 12:46:13 +0300 Subject: [PATCH 334/735] Fix error handling in Get method --- src/api/control/grpc/server.rs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index 7c9be1994..e1f9b0519 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -402,9 +402,6 @@ impl ControlApi for ControlApiService { ctx.spawn( mega_delete_endpoints_fut .join3(mega_delete_member_fut, mega_delete_room_fut) - .map_err(|e| { - warn!("Control API Delete method mailbox error. {:?}", e) - }) .then(move |result| { let map_err_closure = |e| { warn!( @@ -414,12 +411,21 @@ impl ControlApi for ControlApiService { }; match result { Ok((member, endpoint, room)) => { - member + let results = member .into_iter() .chain(endpoint.into_iter()) - .chain(room.into_iter()) - .for_each(|r| r.unwrap()); - // TODO + .chain(room.into_iter()); + for result in results { + if let Err(e) = result { + let mut response = Response::new(); + let error: ErrorCode = e.into(); + response.set_error(error.into()); + return sink + .success(response) + .map_err(map_err_closure); + } + } + let mut response = Response::new(); response.set_sid(HashMap::new()); sink.success(response).map_err(map_err_closure) From 7b543495a7f893181bf465c245687e22ed5b2aea Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 12 Jul 2019 13:38:31 +0300 Subject: [PATCH 335/735] Fix peers deleting and Delete Member --- src/signalling/participants.rs | 3 +- src/signalling/peers.rs | 50 ++++++++++++++++++++-------------- src/signalling/room.rs | 28 +++++++++++++------ 3 files changed, 50 insertions(+), 31 deletions(-) diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index f1a8709b7..1740bef59 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -46,7 +46,7 @@ use crate::{ member::MemberError, parse_members, Member, MembersLoadError, }, - room::{ActFuture, RoomError}, + room::{ActFuture, DeleteEndpoint, RoomError}, Room, }, turn::{TurnAuthService, TurnServiceErr, UnreachablePolicy}, @@ -409,6 +409,7 @@ impl ParticipantService { } if let Some(member) = self.members.remove(member_id) { + for (id, sink) in member.sinks() {} if let Some(ice_user) = member.take_ice_user() { let delete_ice_user_fut = self .turn diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index 10a616a92..99bb8ea77 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -173,41 +173,49 @@ impl PeerRepository { } } - /// Delete [`PeerStateMachine`] from this [`PeerRepository`] and send - /// [`PeersRemoved`] to [`Member`]. - pub fn remove_peer( + /// Delete [`PeerStateMachine`]s from this [`PeerRepository`] and send + /// [`PeersRemoved`] to [`Member`]s. + pub fn remove_peers( &mut self, member_id: MemberId, - peer_id: PeerId, + peer_ids: HashSet, ctx: &mut Context, ) { - if let Some(_) = self.peers.remove(&peer_id) { + let mut removed_peers = HashMap::new(); + for peer_id in peer_ids { + if let Some(peer) = self.peers.remove(&peer_id) { + let partner_peer_id = peer.partner_peer_id(); + let partner_member_id = peer.partner_member_id(); + if let Some(peer) = self.peers.remove(&partner_peer_id) { + removed_peers + .entry(partner_member_id) + .or_insert(Vec::new()) + .push(partner_peer_id); + } + removed_peers + .entry(member_id.clone()) + .or_insert(Vec::new()) + .push(peer_id); + } + } + + for (member_id, removed_peers_ids) in removed_peers { ctx.notify(PeersRemoved { member_id, - peers_id: vec![peer_id], + peers_id: removed_peers_ids, }) } } - /// Delete [`PeerStateMachine`]s from this [`PeerRepository`] and send - /// [`PeersRemoved`] to [`Member`]s. - pub fn remove_peers( + pub fn remove_peer( &mut self, member_id: MemberId, - peer_ids: HashSet, + peer_id: PeerId, ctx: &mut Context, ) { - let mut removed_peer_ids = Vec::new(); - for peer_id in peer_ids { - if let Some(_) = self.peers.remove(&peer_id) { - removed_peer_ids.push(peer_id); - } - } - - ctx.notify(PeersRemoved { - member_id, - peers_id: removed_peer_ids, - }) + let mut peers_id = HashSet::new(); + peers_id.insert(peer_id); + self.remove_peers(member_id, peers_id, ctx); } /// Close all related to disconnected [`Member`] [`Peer`]s and partner diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 9940194df..0ff119593 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -11,7 +11,7 @@ use actix::{ }; use failure::Fail; use futures::future; -use hashbrown::HashMap; +use hashbrown::{HashMap, HashSet}; use medea_client_api_proto::{Command, Event, IceCandidate}; use crate::{ @@ -626,14 +626,6 @@ impl Handler for Room { ); if let Some(member) = self.members.get_member_by_id(&msg.member_id) { member.peers_removed(&msg.peers_id); - } else { - error!( - "Participant with id {} for which received \ - Event::PeersRemoved not found. Closing room.", - msg.member_id - ); - ctx.notify(CloseRoom {}); - return Box::new(wrap_future(future::err(()))); } Box::new( @@ -781,6 +773,24 @@ impl Handler for Room { msg: DeleteMember, ctx: &mut Self::Context, ) -> Self::Result { + debug!("Delete Member [id = {}] in room [id = {}].", msg.0, self.id); + if let Some(member) = self.members.get_member_by_id(&msg.0) { + let mut peers = HashSet::new(); + for (id, sink) in member.sinks() { + if let Some(peer_id) = sink.peer_id() { + peers.insert(peer_id); + } + } + + for (id, src) in member.srcs() { + for peer_id in src.peer_ids() { + peers.insert(peer_id); + } + } + + self.peers.remove_peers(member.id(), peers, ctx); + } + self.members.delete_member(&msg.0, ctx); } } From a8f389ae397ce9b4feafd0977e8540c0ed906be8 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 12 Jul 2019 13:40:45 +0300 Subject: [PATCH 336/735] Fix warns --- src/signalling/participants.rs | 3 +-- src/signalling/peers.rs | 2 +- src/signalling/room.rs | 6 +++--- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 1740bef59..f1a8709b7 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -46,7 +46,7 @@ use crate::{ member::MemberError, parse_members, Member, MembersLoadError, }, - room::{ActFuture, DeleteEndpoint, RoomError}, + room::{ActFuture, RoomError}, Room, }, turn::{TurnAuthService, TurnServiceErr, UnreachablePolicy}, @@ -409,7 +409,6 @@ impl ParticipantService { } if let Some(member) = self.members.remove(member_id) { - for (id, sink) in member.sinks() {} if let Some(ice_user) = member.take_ice_user() { let delete_ice_user_fut = self .turn diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index 99bb8ea77..297283982 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -186,7 +186,7 @@ impl PeerRepository { if let Some(peer) = self.peers.remove(&peer_id) { let partner_peer_id = peer.partner_peer_id(); let partner_member_id = peer.partner_member_id(); - if let Some(peer) = self.peers.remove(&partner_peer_id) { + if let Some(_) = self.peers.remove(&partner_peer_id) { removed_peers .entry(partner_member_id) .or_insert(Vec::new()) diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 0ff119593..e8275a87b 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -618,7 +618,7 @@ impl Handler for Room { fn handle( &mut self, msg: PeersRemoved, - ctx: &mut Self::Context, + _ctx: &mut Self::Context, ) -> Self::Result { info!( "Peers {:?} removed for member '{}'.", @@ -776,13 +776,13 @@ impl Handler for Room { debug!("Delete Member [id = {}] in room [id = {}].", msg.0, self.id); if let Some(member) = self.members.get_member_by_id(&msg.0) { let mut peers = HashSet::new(); - for (id, sink) in member.sinks() { + for (_, sink) in member.sinks() { if let Some(peer_id) = sink.peer_id() { peers.insert(peer_id); } } - for (id, src) in member.srcs() { + for (_, src) in member.srcs() { for peer_id in src.peer_ids() { peers.insert(peer_id); } From f06366efe3b7263ac4bf7b5b4e1032e9e709a735 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 12 Jul 2019 14:02:08 +0300 Subject: [PATCH 337/735] Minor refactor --- src/signalling/elements/member.rs | 26 ++++++++++++++------------ src/signalling/participants.rs | 4 ++-- src/signalling/room_repo.rs | 20 ++++++++++---------- 3 files changed, 26 insertions(+), 24 deletions(-) diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index 7b4752935..0b528defe 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -203,9 +203,7 @@ impl Member { self.get_member_from_room_spec(room_spec, &self_id)?; let this_member = store.get(&self.id()).map_or( - Err(MembersLoadError::MemberNotFound( - self.get_member_local_uri(), - )), + Err(MembersLoadError::MemberNotFound(self.get_local_uri())), Ok, )?; @@ -232,7 +230,7 @@ impl Member { .get(&spec_play_endpoint.src.endpoint_id) .map_or( Err(MembersLoadError::PublishEndpointNotFound( - publisher_member.get_local_uri( + publisher_member.get_local_uri_to_endpoint( spec_play_endpoint.src.endpoint_id.to_string(), ), )), @@ -299,11 +297,19 @@ impl Member { Ok(()) } - /// Return [`LocalUri`] for this [`Member`]. - fn get_member_local_uri(&self) -> LocalUri { + /// Return [`LocalUri`] to this [`Member`]. + fn get_local_uri(&self) -> LocalUri { LocalUri::new(Some(self.room_id()), Some(self.id()), None) } + /// Return [`LocalUri`] to some endpoint from this [`Member`]. + /// + /// __Note__ this function don't check presence of `Endpoint` in this + /// [`Member`]. + pub fn get_local_uri_to_endpoint(&self, endpoint_id: String) -> LocalUri { + LocalUri::new(Some(self.room_id()), Some(self.id()), Some(endpoint_id)) + } + /// Notify [`Member`] that some [`Peer`]s removed. /// /// All [`PeerId`]s related to this [`Member`] will be removed. @@ -372,10 +378,6 @@ impl Member { self.0.borrow().srcs.get(id).cloned() } - pub fn get_local_uri(&self, endpoint_id: String) -> LocalUri { - LocalUri::new(Some(self.room_id()), Some(self.id()), Some(endpoint_id)) - } - pub fn get_src( &self, id: &WebRtcPublishId, @@ -383,7 +385,7 @@ impl Member { self.0.borrow().srcs.get(id).cloned().map_or_else( || { Err(MemberError::PublishEndpointNotFound( - self.get_local_uri(id.to_string()), + self.get_local_uri_to_endpoint(id.to_string()), )) }, Ok, @@ -409,7 +411,7 @@ impl Member { self.0.borrow().sinks.get(id).cloned().map_or_else( || { Err(MemberError::PlayEndpointNotFound( - self.get_local_uri(id.to_string()), + self.get_local_uri_to_endpoint(id.to_string()), )) }, Ok, diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index f1a8709b7..af9abeeb3 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -493,7 +493,7 @@ impl ParticipantService { let member = self.get_member(&member_id)?; if member.get_sink_by_id(&endpoint_id).is_some() { return Err(ParticipantServiceErr::EndpointAlreadyExists( - member.get_local_uri(endpoint_id.to_string()), + member.get_local_uri_to_endpoint(endpoint_id.to_string()), )); } @@ -530,7 +530,7 @@ impl ParticipantService { if member.get_src_by_id(&endpoint_id).is_some() { return Err(ParticipantServiceErr::EndpointAlreadyExists( - member.get_local_uri(endpoint_id.to_string()), + member.get_local_uri_to_endpoint(endpoint_id.to_string()), )); } diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs index 6f437aaa9..25bca51dc 100644 --- a/src/signalling/room_repo.rs +++ b/src/signalling/room_repo.rs @@ -109,7 +109,7 @@ impl Actor for RoomsRepository { type Context = Context; } -fn get_local_uri(room_id: RoomId) -> LocalUri { +fn get_local_uri_to_room(room_id: RoomId) -> LocalUri { LocalUri::new(Some(room_id), None, None) } @@ -128,9 +128,9 @@ impl Handler for RoomsRepository { let room_id = msg.0; if self.rooms.lock().unwrap().get(&room_id).is_some() { - return Err(RoomRepoError::RoomAlreadyExists(get_local_uri( - room_id, - ))); + return Err(RoomRepoError::RoomAlreadyExists( + get_local_uri_to_room(room_id), + )); } let room = msg.1; @@ -189,7 +189,7 @@ impl Handler for RoomsRepository { if let Some(room) = self.get(&msg.room_id) { room.do_send(DeleteMember(msg.member_id)); } else { - return Err(RoomRepoError::RoomNotFound(get_local_uri( + return Err(RoomRepoError::RoomNotFound(get_local_uri_to_room( msg.room_id, ))); } @@ -261,7 +261,7 @@ impl Handler for RoomsRepository { ) } else { return Box::new(wrap_future(futures::future::err( - RoomRepoError::RoomNotFound(get_local_uri(room_id)), + RoomRepoError::RoomNotFound(get_local_uri_to_room(room_id)), ))); } } @@ -307,7 +307,7 @@ impl Handler for RoomsRepository { ) } else { return Box::new(wrap_future(futures::future::err( - RoomRepoError::RoomNotFound(get_local_uri(room_id)), + RoomRepoError::RoomNotFound(get_local_uri_to_room(room_id)), ))); } } @@ -355,7 +355,7 @@ impl Handler for RoomsRepository { ); } else { return Box::new(wrap_future(futures::future::err( - RoomRepoError::RoomNotFound(get_local_uri(room_id)), + RoomRepoError::RoomNotFound(get_local_uri_to_room(room_id)), ))); } } @@ -388,7 +388,7 @@ impl Handler for RoomsRepository { ) } else { Either::B(futures::future::err(RoomRepoError::RoomNotFound( - get_local_uri(msg.room_id), + get_local_uri_to_room(msg.room_id), ))) }; @@ -425,7 +425,7 @@ impl Handler for RoomsRepository { ) } else { Either::B(futures::future::err(RoomRepoError::RoomNotFound( - get_local_uri(msg.room_id), + get_local_uri_to_room(msg.room_id), ))) }; From 00c3736e41f561484543e39177feb73077883636 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 12 Jul 2019 14:07:23 +0300 Subject: [PATCH 338/735] Fix endpoints collision --- src/bin/client.rs | 8 ++++---- src/signalling/participants.rs | 12 ++++++++++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/bin/client.rs b/src/bin/client.rs index 89d3b8856..32a724c7b 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -18,12 +18,12 @@ fn main() { let client = ControlApiClient::new(ch); create_room(&client); - delete_room(&client); - // delete_endpoint(&client); + // delete_room(&client); + // delete_endpoint(&client); // delete_member(&client); // create_member(&client); // std::thread::sleep(Duration::from_secs(1)); - // create_endpoint(&client); + create_endpoint(&client); get_room(&client); } @@ -93,7 +93,7 @@ fn create_endpoint(client: &ControlApiClient) { let mut endpoint = WebRtcPublishEndpoint::new(); endpoint.set_p2p(WebRtcPublishEndpoint_P2P::ALWAYS); create_endpoint_request - .set_id("local://grpc-test/player/create-publish".to_string()); + .set_id("local://grpc-test/responder/play".to_string()); create_endpoint_request.set_webrtc_pub(endpoint); let reply = client diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index af9abeeb3..398d09ac4 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -491,7 +491,11 @@ impl ParticipantService { spec: WebRtcPlayEndpointSpec, ) -> Result<(), ParticipantServiceErr> { let member = self.get_member(&member_id)?; - if member.get_sink_by_id(&endpoint_id).is_some() { + if member.get_sink_by_id(&endpoint_id).is_some() + || member + .get_src_by_id(&WebRtcPublishId(endpoint_id.0.clone())) + .is_some() + { return Err(ParticipantServiceErr::EndpointAlreadyExists( member.get_local_uri_to_endpoint(endpoint_id.to_string()), )); @@ -528,7 +532,11 @@ impl ParticipantService { ) -> Result<(), ParticipantServiceErr> { let member = self.get_member(&member_id)?; - if member.get_src_by_id(&endpoint_id).is_some() { + if member.get_src_by_id(&endpoint_id).is_some() + || member + .get_sink_by_id(&WebRtcPlayId(endpoint_id.0.clone())) + .is_some() + { return Err(ParticipantServiceErr::EndpointAlreadyExists( member.get_local_uri_to_endpoint(endpoint_id.to_string()), )); From 29cce2b2b336961a8424a322b823baf00277a151 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 12 Jul 2019 14:33:11 +0300 Subject: [PATCH 339/735] Add some docs --- src/api/control/endpoints/mod.rs | 2 ++ src/api/control/endpoints/webrtc_play_endpoint.rs | 2 +- src/api/control/endpoints/webrtc_publish_endpoint.rs | 2 +- src/api/control/local_uri.rs | 3 +++ src/api/control/member.rs | 2 +- src/api/control/mod.rs | 1 + src/conf/grpc.rs | 3 +++ src/conf/mod.rs | 1 + src/conf/rpc.rs | 1 + src/lib.rs | 1 + src/signalling/elements/member.rs | 9 +++++++-- src/signalling/participants.rs | 1 + src/signalling/peers.rs | 6 ++++++ src/signalling/room.rs | 5 +++++ src/signalling/room_repo.rs | 12 ++++++++++++ 15 files changed, 46 insertions(+), 5 deletions(-) diff --git a/src/api/control/endpoints/mod.rs b/src/api/control/endpoints/mod.rs index 532fa3f66..3dca30107 100644 --- a/src/api/control/endpoints/mod.rs +++ b/src/api/control/endpoints/mod.rs @@ -1,3 +1,5 @@ +//! Endpoint elements of medea spec. + pub mod webrtc_play_endpoint; pub mod webrtc_publish_endpoint; diff --git a/src/api/control/endpoints/webrtc_play_endpoint.rs b/src/api/control/endpoints/webrtc_play_endpoint.rs index e911d3844..9ffaf03d6 100644 --- a/src/api/control/endpoints/webrtc_play_endpoint.rs +++ b/src/api/control/endpoints/webrtc_play_endpoint.rs @@ -19,7 +19,7 @@ use crate::api::{ }; macro_attr! { - /// ID of [`Room`]. + /// ID of [`WebRtcPlayEndpoint`]. #[derive( Clone, Debug, diff --git a/src/api/control/endpoints/webrtc_publish_endpoint.rs b/src/api/control/endpoints/webrtc_publish_endpoint.rs index 8c90e830e..930001dda 100644 --- a/src/api/control/endpoints/webrtc_publish_endpoint.rs +++ b/src/api/control/endpoints/webrtc_publish_endpoint.rs @@ -15,7 +15,7 @@ use crate::api::control::{ }; macro_attr! { - /// ID of [`Room`]. + /// ID of [`WebRtcPublishEndpoint`]. #[derive( Clone, Debug, diff --git a/src/api/control/local_uri.rs b/src/api/control/local_uri.rs index 418a54f0b..02204ef93 100644 --- a/src/api/control/local_uri.rs +++ b/src/api/control/local_uri.rs @@ -10,8 +10,11 @@ use super::{MemberId, RoomId}; #[derive(Debug, Fail)] pub enum LocalUriParseError { + /// Protocol of provided URI is not "local://". #[fail(display = "Provided URIs protocol is not 'local://'.")] NotLocal(String), + + /// Too many paths in provided URI. #[fail(display = "Too many ({}) paths in provided URI.", _0)] TooManyFields(usize, String), } diff --git a/src/api/control/member.rs b/src/api/control/member.rs index bd875b8c1..c5bc5a335 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -19,7 +19,7 @@ use crate::api::control::{ use super::{pipeline::Pipeline, Element, TryFromElementError}; macro_attr! { - /// ID of [`Room`]. + /// ID of [`Member`]. #[derive( Clone, Debug, diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index ba615bef9..8c5dfec69 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -23,6 +23,7 @@ use self::{ pipeline::Pipeline, }; +#[doc(inline)] pub use self::{ endpoints::{ webrtc_play_endpoint::WebRtcPlayId, diff --git a/src/conf/grpc.rs b/src/conf/grpc.rs index b11b00497..5cce340be 100644 --- a/src/conf/grpc.rs +++ b/src/conf/grpc.rs @@ -1,8 +1,11 @@ +//! gRPC server settings. + use std::net::{IpAddr, Ipv4Addr}; use serde::{Deserialize, Serialize}; use smart_default::SmartDefault; +/// gRPC server settings. #[derive(Clone, Debug, Deserialize, Serialize, SmartDefault)] #[serde(default)] pub struct Grpc { diff --git a/src/conf/mod.rs b/src/conf/mod.rs index 344ea63a0..60e7aae4c 100644 --- a/src/conf/mod.rs +++ b/src/conf/mod.rs @@ -36,6 +36,7 @@ pub struct Conf { /// TURN server settings. pub turn: Turn, + /// gRPC server settings. pub grpc: Grpc, } diff --git a/src/conf/rpc.rs b/src/conf/rpc.rs index 0408de3ef..2c1aba7db 100644 --- a/src/conf/rpc.rs +++ b/src/conf/rpc.rs @@ -1,4 +1,5 @@ //! RPC connection settings. + use serde::{Deserialize, Serialize}; use smart_default::SmartDefault; diff --git a/src/lib.rs b/src/lib.rs index f0f6e9fc8..28184a006 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -22,6 +22,7 @@ use crate::{ turn::{service, TurnAuthService}, }; +/// Global app context. #[derive(Debug)] pub struct App { pub config: Conf, diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index 0b528defe..e234d6825 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -38,12 +38,14 @@ pub enum MembersLoadError { #[fail(display = "Member [id = {}] not found.", _0)] MemberNotFound(LocalUri), + /// [`WebRtcPlayEndpoint`] not found. #[fail( display = "Play endpoint [id = {}] not found while loading spec,", _0 )] PlayEndpointNotFound(LocalUri), + /// [`WebRtcPublishEndpoint`] not found. #[fail( display = "Publish endpoint [id = {}] not found while loading spec.", _0 @@ -370,7 +372,7 @@ impl Member { self.0.borrow_mut().srcs.insert(endpoint.id(), endpoint); } - /// Lookup [`WebRtcPublishEndpoint`] source endpoint by [`EndpointId`]. + /// Lookup [`WebRtcPublishEndpoint`] source endpoint by [`WebRtcPublishId`]. pub fn get_src_by_id( &self, id: &WebRtcPublishId, @@ -378,6 +380,10 @@ impl Member { self.0.borrow().srcs.get(id).cloned() } + /// Lookup [`WebRtcPublishEndpoint`] source endpoint by [`WebRtcPublishId`]. + /// + /// Returns [`MeberError::PublishEndpointNotFound`] when + /// [`WebRtcPublishEndpoint`] not found. pub fn get_src( &self, id: &WebRtcPublishId, @@ -479,7 +485,6 @@ impl Member { pub fn parse_members( room_spec: &RoomSpec, ) -> Result>, MembersLoadError> { - // TODO: maybe improve error? let members_spec = match room_spec.members() { Ok(o) => o, Err(e) => { diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 398d09ac4..8d86c7d55 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -187,6 +187,7 @@ impl ParticipantService { ) } + /// Returns all [`Member`] from this [`ParticipantService`]. pub fn members(&self) -> HashMap> { self.members.clone() } diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index 297283982..2ef224149 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -175,6 +175,8 @@ impl PeerRepository { /// Delete [`PeerStateMachine`]s from this [`PeerRepository`] and send /// [`PeersRemoved`] to [`Member`]s. + /// + /// __Note:__ this also delete partner peers. pub fn remove_peers( &mut self, member_id: MemberId, @@ -207,6 +209,10 @@ impl PeerRepository { } } + /// Delete [`PeerStateMachine`] from this [`PeerRepository`] and send + /// [`PeersRemoved`] to [`Member`]s. + /// + /// __Note:__ this also delete partner peer. pub fn remove_peer( &mut self, member_id: MemberId, diff --git a/src/signalling/room.rs b/src/signalling/room.rs index e8275a87b..337b34265 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -506,6 +506,7 @@ impl Into for &mut Room { } } +/// Serialize this [`Room`] to protobuf object. #[derive(Message)] #[rtype(result = "Result")] pub struct SerializeProtobufRoom; @@ -523,6 +524,7 @@ impl Handler for Room { } } +/// Serialize [`Member`] from this [`Room`] to protobuf object. #[derive(Message)] #[rtype(result = "Result")] pub struct SerializeProtobufMember(pub MemberId); @@ -548,6 +550,7 @@ impl Handler for Room { } } +/// Serialize endpoint from this [`Room`] to protobuf object. #[derive(Message)] #[rtype(result = "Result")] pub struct SerializeProtobufEndpoint(pub MemberId, pub String); @@ -761,6 +764,7 @@ impl Handler for Room { } } +/// Signal for delete [`Member`] from this [`Room`] #[derive(Debug, Message, Clone)] #[rtype(result = "()")] pub struct DeleteMember(pub MemberId); @@ -795,6 +799,7 @@ impl Handler for Room { } } +/// Signal for delete endpoint from this [`Room`] #[derive(Debug, Message, Clone)] #[rtype(result = "()")] pub struct DeleteEndpoint { diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs index 25bca51dc..989a7f877 100644 --- a/src/signalling/room_repo.rs +++ b/src/signalling/room_repo.rs @@ -109,6 +109,10 @@ impl Actor for RoomsRepository { type Context = Context; } +/// Returns [`LocalUri`] pointing to [`Room`]. +/// +/// __Note__ this function don't check presence of [`Room`] in this +/// [`RoomsRepository`]. fn get_local_uri_to_room(room_id: RoomId) -> LocalUri { LocalUri::new(Some(room_id), None, None) } @@ -149,6 +153,7 @@ impl Handler for RoomsRepository { } } +/// Signal for delete [`Room`]. #[derive(Message)] #[rtype(result = "Result<(), RoomRepoError>")] pub struct DeleteRoom(pub RoomId); @@ -171,6 +176,7 @@ impl Handler for RoomsRepository { } } +/// Signal for delete [`Member`] from [`Room`]. #[derive(Message)] #[rtype(result = "Result<(), RoomRepoError>")] pub struct DeleteMemberFromRoom { @@ -198,6 +204,7 @@ impl Handler for RoomsRepository { } } +/// Signal for delete [`Endpoint`] from [`Member`]. #[derive(Message)] #[rtype(result = "Result<(), RoomRepoError>")] pub struct DeleteEndpointFromMember { @@ -225,6 +232,7 @@ impl Handler for RoomsRepository { } } +/// Signal for get serialized to protobuf object [`Room`]. #[derive(Message)] #[rtype(result = "Result>, \ RoomRepoError>")] @@ -270,6 +278,7 @@ impl Handler for RoomsRepository { } } +/// Signal for get serialized to protobuf object [`Member`]. #[derive(Message)] #[rtype(result = "Result>, \ RoomRepoError>")] @@ -316,6 +325,7 @@ impl Handler for RoomsRepository { } } +/// Signal for get serialized to protobuf object `Endpoint`. #[derive(Message)] #[rtype(result = "Result>, \ RoomRepoError>")] @@ -364,6 +374,7 @@ impl Handler for RoomsRepository { } } +/// Signal for create new [`Member`] in [`Room`] #[derive(Message)] #[rtype(result = "Result, RoomRepoError>")] pub struct CreateMemberInRoom { @@ -396,6 +407,7 @@ impl Handler for RoomsRepository { } } +/// Signal for create new [`Endpoint`] in [`Room`] #[derive(Message)] #[rtype(result = "Result, RoomRepoError>")] pub struct CreateEndpointInRoom { From 738e1c801d568919880f8d934753d4985a937cdf Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 12 Jul 2019 15:02:07 +0300 Subject: [PATCH 340/735] Fix lints --- .clippy.toml | 2 +- src/api/control/endpoints/mod.rs | 8 +++--- .../control/endpoints/webrtc_play_endpoint.rs | 12 ++++----- .../endpoints/webrtc_publish_endpoint.rs | 2 +- src/api/control/grpc/server.rs | 24 ++++++++--------- src/api/control/local_uri.rs | 4 ++- src/signalling/elements/member.rs | 27 +++---------------- src/signalling/participants.rs | 6 ++--- src/signalling/peers.rs | 12 ++++----- src/signalling/room.rs | 13 ++++----- src/signalling/room_repo.rs | 18 ++++++------- 11 files changed, 54 insertions(+), 74 deletions(-) diff --git a/.clippy.toml b/.clippy.toml index 1fcc3149f..153470a8c 100644 --- a/.clippy.toml +++ b/.clippy.toml @@ -10,5 +10,5 @@ doc-valid-idents = [ "iOS", "macOS", "TeX", "LaTeX", "BibTeX", "BibLaTeX", "MinGW", "WebSocket", "RTCIceServer", "RTCConfiguration", - "WebRTC", + "WebRTC", "gRPC", ] diff --git a/src/api/control/endpoints/mod.rs b/src/api/control/endpoints/mod.rs index 3dca30107..b0d54deba 100644 --- a/src/api/control/endpoints/mod.rs +++ b/src/api/control/endpoints/mod.rs @@ -41,11 +41,11 @@ impl TryFrom<&MemberElementProto> for Endpoint { fn try_from(value: &MemberElementProto) -> Result { if value.has_webrtc_play() { let play = WebRtcPlayEndpoint::try_from(value.get_webrtc_play())?; - return Ok(Endpoint::WebRtcPlay(play)); + Ok(Endpoint::WebRtcPlay(play)) } else if value.has_webrtc_pub() { let publish = WebRtcPublishEndpoint::try_from(value.get_webrtc_pub())?; - return Ok(Endpoint::WebRtcPublish(publish)); + Ok(Endpoint::WebRtcPublish(publish)) } else { // TODO unimplemented!() @@ -59,11 +59,11 @@ impl TryFrom<&CreateRequest> for Endpoint { fn try_from(value: &CreateRequest) -> Result { if value.has_webrtc_play() { let play = WebRtcPlayEndpoint::try_from(value.get_webrtc_play())?; - return Ok(Endpoint::WebRtcPlay(play)); + Ok(Endpoint::WebRtcPlay(play)) } else if value.has_webrtc_pub() { let publish = WebRtcPublishEndpoint::try_from(value.get_webrtc_pub())?; - return Ok(Endpoint::WebRtcPublish(publish)); + Ok(Endpoint::WebRtcPublish(publish)) } else { // TODO unimplemented!() diff --git a/src/api/control/endpoints/webrtc_play_endpoint.rs b/src/api/control/endpoints/webrtc_play_endpoint.rs index 9ffaf03d6..3c433d78d 100644 --- a/src/api/control/endpoints/webrtc_play_endpoint.rs +++ b/src/api/control/endpoints/webrtc_play_endpoint.rs @@ -108,17 +108,17 @@ impl SrcUri { missing_fields.push("endpoint_id".to_string()); } - if !missing_fields.is_empty() { - return Err(SrcParseError::MissingField( - value.to_string(), - missing_fields, - )); - } else { + if missing_fields.is_empty() { Ok(Self { room_id: local_uri.room_id.unwrap(), member_id: local_uri.member_id.unwrap(), endpoint_id: WebRtcPublishId(local_uri.endpoint_id.unwrap()), }) + } else { + Err(SrcParseError::MissingField( + value.to_string(), + missing_fields, + )) } } } diff --git a/src/api/control/endpoints/webrtc_publish_endpoint.rs b/src/api/control/endpoints/webrtc_publish_endpoint.rs index 930001dda..27b24133f 100644 --- a/src/api/control/endpoints/webrtc_publish_endpoint.rs +++ b/src/api/control/endpoints/webrtc_publish_endpoint.rs @@ -1,4 +1,4 @@ -//! WebRtcPublish +//! `WebRtcPublishEndpoint` implementation. use std::convert::TryFrom; diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index e1f9b0519..13b3cd98b 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -128,7 +128,7 @@ impl ControlApiService { /// Implementation of `Create` method for `Room` element. pub fn create_room( &mut self, - req: CreateRequest, + req: &CreateRequest, local_uri: LocalUri, ) -> impl Future< Item = Result< @@ -164,7 +164,7 @@ impl ControlApiService { Either::A( self.room_repository .send(StartRoom(room_id, room)) - .map_err(|e| ControlApiError::from(e)) + .map_err(ControlApiError::from) .map(move |r| r.map(|_| Ok(sid))), ) } @@ -172,7 +172,7 @@ impl ControlApiService { /// Implementation of `Create` method for `Member` element. pub fn create_member( &mut self, - req: CreateRequest, + req: &CreateRequest, local_uri: LocalUri, ) -> impl Future< Item = Result< @@ -204,7 +204,7 @@ impl ControlApiService { member_id, spec, }) - .map_err(|e| ControlApiError::from(e)) + .map_err(ControlApiError::from) .map(|r| r.map(|r| r.map(|_| sids))), ) } @@ -213,7 +213,7 @@ impl ControlApiService { /// `WebRtcPlayEndpoint` elements. pub fn create_endpoint( &mut self, - req: CreateRequest, + req: &CreateRequest, local_uri: LocalUri, ) -> impl Future< Item = Result< @@ -222,7 +222,7 @@ impl ControlApiService { >, Error = ControlApiError, > { - let endpoint = fut_try!(Endpoint::try_from(&req)); + let endpoint = fut_try!(Endpoint::try_from(req)); Either::A( self.room_repository .send(CreateEndpointInRoom { @@ -231,7 +231,7 @@ impl ControlApiService { endpoint_id: local_uri.endpoint_id.unwrap(), spec: endpoint, }) - .map_err(|e| ControlApiError::from(e)) + .map_err(ControlApiError::from) .map(|r| r.map(|r| r.map(|_| HashMap::new()))), ) } @@ -289,7 +289,7 @@ impl ControlApi for ControlApiService { if local_uri.is_room_uri() { if req.has_room() { - ctx.spawn(self.create_room(req, local_uri).then(move |r| { + ctx.spawn(self.create_room(&req, local_uri).then(move |r| { sink.success(create_response(r)).map_err(|_| ()) })); } else { @@ -302,7 +302,7 @@ impl ControlApi for ControlApiService { } } else if local_uri.is_member_uri() { if req.has_member() { - ctx.spawn(self.create_member(req, local_uri).then(move |r| { + ctx.spawn(self.create_member(&req, local_uri).then(move |r| { sink.success(create_response(r)).map_err(|e| { warn!( "Error while sending Create response by gRPC. {:?}", @@ -320,7 +320,7 @@ impl ControlApi for ControlApiService { } } else if local_uri.is_endpoint_uri() { if req.has_webrtc_pub() || req.has_webrtc_play() { - ctx.spawn(self.create_endpoint(req, local_uri).then( + ctx.spawn(self.create_endpoint(&req, local_uri).then( move |r| { sink.success(create_response(r)).map_err(|e| { warn!( @@ -511,7 +511,7 @@ impl ControlApi for ControlApiService { let elements_results = elements_results .into_iter() - .flat_map(|e| e.into_iter()); + .flat_map(std::iter::IntoIterator::into_iter); for element in elements_results { match element { @@ -574,7 +574,7 @@ pub fn run( room_repo: Addr, app: Arc, ) -> Addr { - let bind_ip = app.config.grpc.bind_ip.clone().to_string(); + let bind_ip = app.config.grpc.bind_ip.to_string(); let bind_port = app.config.grpc.bind_port; let cq_count = app.config.grpc.completion_queue_count; diff --git a/src/api/control/local_uri.rs b/src/api/control/local_uri.rs index 02204ef93..aeefbe7b7 100644 --- a/src/api/control/local_uri.rs +++ b/src/api/control/local_uri.rs @@ -8,6 +8,7 @@ use crate::api::error_codes::ErrorCode; use super::{MemberId, RoomId}; +#[allow(clippy::module_name_repetitions)] #[derive(Debug, Fail)] pub enum LocalUriParseError { /// Protocol of provided URI is not "local://". @@ -32,6 +33,7 @@ impl Into for LocalUriParseError { } } +#[allow(clippy::doc_markdown)] /// Uri in format "local://room_id/member_id/endpoint_id" /// This kind of uri used for pointing to some element in spec (`Room`, /// `Member`, `WebRtcPlayEndpoint`, `WebRtcPublishEndpoint`, etc). @@ -91,7 +93,7 @@ impl LocalUri { let endpoint_id = uri_body_splitted .pop() .filter(|p| !p.is_empty()) - .map(|p| p.to_string()); + .map(std::string::ToString::to_string); Ok(Self { room_id, diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index e234d6825..83d84106a 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -13,8 +13,7 @@ use crate::{ api::control::{ endpoints::WebRtcPlayEndpoint as WebRtcPlayEndpointSpec, grpc::protos::control::{ - Error as ErrorProto, Member as MemberProto, - Room_Element as ElementProto, + Member as MemberProto, Room_Element as ElementProto, }, local_uri::LocalUri, MemberId, MemberSpec, RoomId, RoomSpec, TryFromElementError, @@ -53,6 +52,7 @@ pub enum MembersLoadError { PublishEndpointNotFound(LocalUri), } +#[allow(clippy::module_name_repetitions)] #[derive(Debug, Fail)] pub enum MemberError { #[fail(display = "Publish endpoint [id = {}] not found.", _0)] @@ -87,27 +87,6 @@ impl Into for MembersLoadError { } } -impl Into for &MemberError { - fn into(self) -> ErrorProto { - let mut error = ErrorProto::new(); - match &self { - MemberError::PlayEndpointNotFound(id) => { - error.set_element(id.to_string()); - error.set_code(0); // TODO - error.set_status(400); - error.set_text(self.to_string()); - } - MemberError::PublishEndpointNotFound(id) => { - error.set_element(id.to_string()); - error.set_code(0); // TODO - error.set_status(400); - error.set_text(self.to_string()); - } - } - error - } -} - impl Into for MemberError { fn into(self) -> ErrorCode { match self { @@ -460,7 +439,7 @@ impl Member { /// This function will add created [`WebRtcPlayEndpoint`] to src's /// [`WebRtcPublishEndpoint`] and to provided [`Member`]. pub fn create_sink( - member: Rc, + member: &Rc, id: WebRtcPlayId, spec: WebRtcPlayEndpointSpec, ) { diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 8d86c7d55..8c4236b35 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -430,7 +430,7 @@ impl ParticipantService { pub fn create_member( &mut self, id: MemberId, - spec: MemberSpec, + spec: &MemberSpec, ) -> Result<(), ParticipantServiceErr> { if self.members.get(&id).is_some() { return Err(ParticipantServiceErr::ParticipantAlreadyExists( @@ -487,7 +487,7 @@ impl ParticipantService { /// [`WebRtcPlayEndpoint`]'s ID already presented in [`Member`]. pub fn create_sink_endpoint( &mut self, - member_id: MemberId, + member_id: &MemberId, endpoint_id: WebRtcPlayId, spec: WebRtcPlayEndpointSpec, ) -> Result<(), ParticipantServiceErr> { @@ -527,7 +527,7 @@ impl ParticipantService { /// [`WebRtcPublishEndpoint`]'s ID already presented in [`Member`]. pub fn create_src_endpoint( &mut self, - member_id: MemberId, + member_id: &MemberId, endpoint_id: WebRtcPublishId, spec: WebRtcPublishEndpointSpec, ) -> Result<(), ParticipantServiceErr> { diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index 2ef224149..f87088592 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -179,7 +179,7 @@ impl PeerRepository { /// __Note:__ this also delete partner peers. pub fn remove_peers( &mut self, - member_id: MemberId, + member_id: &MemberId, peer_ids: HashSet, ctx: &mut Context, ) { @@ -188,7 +188,7 @@ impl PeerRepository { if let Some(peer) = self.peers.remove(&peer_id) { let partner_peer_id = peer.partner_peer_id(); let partner_member_id = peer.partner_member_id(); - if let Some(_) = self.peers.remove(&partner_peer_id) { + if self.peers.remove(&partner_peer_id).is_some() { removed_peers .entry(partner_member_id) .or_insert(Vec::new()) @@ -215,13 +215,13 @@ impl PeerRepository { /// __Note:__ this also delete partner peer. pub fn remove_peer( &mut self, - member_id: MemberId, + member_id: &MemberId, peer_id: PeerId, ctx: &mut Context, ) { - let mut peers_id = HashSet::new(); - peers_id.insert(peer_id); - self.remove_peers(member_id, peers_id, ctx); + let mut peers_id_to_delete = HashSet::new(); + peers_id_to_delete.insert(peer_id); + self.remove_peers(&member_id, peers_id_to_delete, ctx); } /// Close all related to disconnected [`Member`] [`Peer`]s and partner diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 337b34265..4b426d87a 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -507,6 +507,7 @@ impl Into for &mut Room { } /// Serialize this [`Room`] to protobuf object. +#[allow(clippy::module_name_repetitions)] #[derive(Message)] #[rtype(result = "Result")] pub struct SerializeProtobufRoom; @@ -792,7 +793,7 @@ impl Handler for Room { } } - self.peers.remove_peers(member.id(), peers, ctx); + self.peers.remove_peers(&member.id(), peers, ctx); } self.members.delete_member(&msg.0, ctx); @@ -819,14 +820,14 @@ impl Handler for Room { let play_id = WebRtcPlayId(msg.endpoint_id); if let Some(endpoint) = member.take_sink(&play_id) { if let Some(peer_id) = endpoint.peer_id() { - self.peers.remove_peer(msg.member_id.clone(), peer_id, ctx); + self.peers.remove_peer(&msg.member_id, peer_id, ctx); } } let publish_id = WebRtcPublishId(play_id.0); if let Some(endpoint) = member.take_src(&publish_id) { let peer_ids = endpoint.peer_ids(); - self.peers.remove_peers(msg.member_id, peer_ids, ctx); + self.peers.remove_peers(&msg.member_id, peer_ids, ctx); } } else { return; @@ -847,7 +848,7 @@ impl Handler for Room { msg: CreateMember, _ctx: &mut Self::Context, ) -> Self::Result { - self.members.create_member(msg.0, msg.1)?; + self.members.create_member(msg.0, &msg.1)?; Ok(()) } } @@ -872,14 +873,14 @@ impl Handler for Room { match msg.spec { EndpointSpec::WebRtcPlay(e) => { self.members.create_sink_endpoint( - msg.member_id, + &msg.member_id, WebRtcPlayId(msg.endpoint_id), e, )?; } EndpointSpec::WebRtcPublish(e) => { self.members.create_src_endpoint( - msg.member_id, + &msg.member_id, WebRtcPublishId(msg.endpoint_id), e, )?; diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs index 989a7f877..05d09ed61 100644 --- a/src/signalling/room_repo.rs +++ b/src/signalling/room_repo.rs @@ -33,6 +33,7 @@ use crate::{ type ActFuture = Box>; +#[allow(clippy::module_name_repetitions)] #[derive(Debug, Fail)] pub enum RoomRepoError { #[fail(display = "Room [id = {}] not found.", _0)] @@ -141,11 +142,8 @@ impl Handler for RoomsRepository { let turn = Arc::clone(&self.app.turn_service); - let room = Room::new( - &room, - self.app.config.rpc.reconnect_timeout.clone(), - turn, - )?; + let room = + Room::new(&room, self.app.config.rpc.reconnect_timeout, turn)?; let room_addr = room.start(); self.rooms.lock().unwrap().insert(room_id, room_addr); @@ -255,7 +253,7 @@ impl Handler for RoomsRepository { if let Some(room) = self.rooms.lock().unwrap().get(&room_id) { futs.push( room.send(SerializeProtobufRoom) - .map_err(|e| RoomRepoError::from(e)) + .map_err(RoomRepoError::from) .map(move |result| { result.map(|r| { let local_uri = LocalUri { @@ -301,7 +299,7 @@ impl Handler for RoomsRepository { if let Some(room) = self.rooms.lock().unwrap().get(&room_id) { futs.push( room.send(SerializeProtobufMember(member_id.clone())) - .map_err(|e| RoomRepoError::from(e)) + .map_err(RoomRepoError::from) .map(|result| { result.map(|r| { let local_uri = LocalUri { @@ -351,7 +349,7 @@ impl Handler for RoomsRepository { member_id.clone(), endpoint_id.clone(), )) - .map_err(|e| RoomRepoError::from(e)) + .map_err(RoomRepoError::from) .map(|result| { result.map(|r| { let local_uri = LocalUri { @@ -395,7 +393,7 @@ impl Handler for RoomsRepository { if let Some(room) = self.rooms.lock().unwrap().get(&msg.room_id) { Either::A( room.send(CreateMember(msg.member_id, msg.spec)) - .map_err(|e| RoomRepoError::from(e)), + .map_err(RoomRepoError::from), ) } else { Either::B(futures::future::err(RoomRepoError::RoomNotFound( @@ -433,7 +431,7 @@ impl Handler for RoomsRepository { endpoint_id: msg.endpoint_id, spec: msg.spec, }) - .map_err(|e| RoomRepoError::from(e)), + .map_err(RoomRepoError::from), ) } else { Either::B(futures::future::err(RoomRepoError::RoomNotFound( From 56d8753454a4d68de0d2bcc04a7b01ec8477f3a4 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 12 Jul 2019 15:13:49 +0300 Subject: [PATCH 341/735] Use type alias for results of Get and Create --- src/api/control/grpc/server.rs | 35 ++++++++-------------------------- src/signalling/room_repo.rs | 27 +++++++++----------------- 2 files changed, 17 insertions(+), 45 deletions(-) diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index 13b3cd98b..73c627fd0 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -118,6 +118,10 @@ macro_rules! parse_local_uri { }; } +/// Type alias for result of Create request. +type CreateResult = + Result, RoomError>, RoomRepoError>; + #[derive(Clone)] struct ControlApiService { room_repository: Addr, @@ -130,13 +134,7 @@ impl ControlApiService { &mut self, req: &CreateRequest, local_uri: LocalUri, - ) -> impl Future< - Item = Result< - Result, RoomError>, - RoomRepoError, - >, - Error = ControlApiError, - > { + ) -> impl Future { let room_id = local_uri.room_id.unwrap(); let room = fut_try!(RoomSpec::try_from_protobuf( @@ -174,13 +172,7 @@ impl ControlApiService { &mut self, req: &CreateRequest, local_uri: LocalUri, - ) -> impl Future< - Item = Result< - Result, RoomError>, - RoomRepoError, - >, - Error = ControlApiError, - > { + ) -> impl Future { let spec = fut_try!(MemberSpec::try_from(req.get_member())); let room_id = local_uri.room_id.unwrap(); @@ -215,13 +207,7 @@ impl ControlApiService { &mut self, req: &CreateRequest, local_uri: LocalUri, - ) -> impl Future< - Item = Result< - Result, RoomError>, - RoomRepoError, - >, - Error = ControlApiError, - > { + ) -> impl Future { let endpoint = fut_try!(Endpoint::try_from(req)); Either::A( self.room_repository @@ -238,12 +224,7 @@ impl ControlApiService { } /// Generate [`Response`] for `Create` method of all elements. -fn create_response( - result: Result< - Result, RoomError>, RoomRepoError>, - ControlApiError, - >, -) -> Response { +fn create_response(result: Result) -> Response { let error: ErrorCode = match result { Ok(r) => match r { Ok(r) => match r { diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs index 05d09ed61..8c528d032 100644 --- a/src/signalling/room_repo.rs +++ b/src/signalling/room_repo.rs @@ -230,17 +230,16 @@ impl Handler for RoomsRepository { } } +/// Type alias for result of Get request. +type GetResults = Vec>; + /// Signal for get serialized to protobuf object [`Room`]. #[derive(Message)] -#[rtype(result = "Result>, \ - RoomRepoError>")] +#[rtype(result = "Result")] pub struct GetRoom(pub Vec); impl Handler for RoomsRepository { - type Result = ActFuture< - Vec>, - RoomRepoError, - >; + type Result = ActFuture; fn handle( &mut self, @@ -278,15 +277,11 @@ impl Handler for RoomsRepository { /// Signal for get serialized to protobuf object [`Member`]. #[derive(Message)] -#[rtype(result = "Result>, \ - RoomRepoError>")] +#[rtype(result = "Result")] pub struct GetMember(pub Vec<(RoomId, MemberId)>); impl Handler for RoomsRepository { - type Result = ActFuture< - Vec>, - RoomRepoError, - >; + type Result = ActFuture; fn handle( &mut self, @@ -325,15 +320,11 @@ impl Handler for RoomsRepository { /// Signal for get serialized to protobuf object `Endpoint`. #[derive(Message)] -#[rtype(result = "Result>, \ - RoomRepoError>")] +#[rtype(result = "Result")] pub struct GetEndpoint(pub Vec<(RoomId, MemberId, String)>); impl Handler for RoomsRepository { - type Result = ActFuture< - Vec>, - RoomRepoError, - >; + type Result = ActFuture; fn handle( &mut self, From ac02b95da9b79f241d5d5608f01d36f771874ec5 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 12 Jul 2019 15:39:15 +0300 Subject: [PATCH 342/735] Minor refactor of WebRtcPublishEndpoint::new() --- .../elements/endpoints/webrtc/publish_endpoint.rs | 9 ++------- src/signalling/elements/member.rs | 2 -- src/signalling/participants.rs | 2 -- 3 files changed, 2 insertions(+), 11 deletions(-) diff --git a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs index 91246dac5..5bba1c3d4 100644 --- a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs @@ -100,16 +100,11 @@ pub struct WebRtcPublishEndpoint(RefCell); impl WebRtcPublishEndpoint { /// Create new [`WebRtcPublishEndpoint`]. - pub fn new( - id: Id, - p2p: P2pMode, - sinks: Vec>, - owner: Weak, - ) -> Self { + pub fn new(id: Id, p2p: P2pMode, owner: Weak) -> Self { Self(RefCell::new(WebRtcPublishEndpointInner { id, p2p, - sinks, + sinks: Vec::new(), owner, peer_ids: HashSet::new(), })) diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index 83d84106a..fb6b441e4 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -240,7 +240,6 @@ impl Member { let new_publish = Rc::new(WebRtcPublishEndpoint::new( new_publish_id.clone(), publisher_endpoint.p2p.clone(), - Vec::new(), Rc::downgrade(&publisher_member), )); @@ -268,7 +267,6 @@ impl Member { self.insert_src(Rc::new(WebRtcPublishEndpoint::new( endpoint_id, e.p2p.clone(), - Vec::new(), Rc::downgrade(&this_member), ))); } diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 8c4236b35..f382f17c5 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -447,7 +447,6 @@ impl ParticipantService { let signalling_publish = Rc::new(WebRtcPublishEndpoint::new( id.clone(), publish.p2p.clone(), - Vec::new(), Rc::downgrade(&signalling_member), )); signalling_member.insert_src(signalling_publish); @@ -546,7 +545,6 @@ impl ParticipantService { let src = Rc::new(WebRtcPublishEndpoint::new( endpoint_id, spec.p2p, - Vec::new(), Rc::downgrade(&member), )); From cd11115023c13a83e4c9294fa0f81e9e89e4366b Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 12 Jul 2019 16:32:06 +0300 Subject: [PATCH 343/735] Upd TODOs --- src/api/control/endpoints/mod.rs | 4 ++-- src/api/control/endpoints/webrtc_play_endpoint.rs | 1 - src/api/error_codes.rs | 3 ++- src/signalling/elements/member.rs | 1 - 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/api/control/endpoints/mod.rs b/src/api/control/endpoints/mod.rs index b0d54deba..53623d23d 100644 --- a/src/api/control/endpoints/mod.rs +++ b/src/api/control/endpoints/mod.rs @@ -47,7 +47,7 @@ impl TryFrom<&MemberElementProto> for Endpoint { WebRtcPublishEndpoint::try_from(value.get_webrtc_pub())?; Ok(Endpoint::WebRtcPublish(publish)) } else { - // TODO + // TODO implement another endpoints when they will be implemented unimplemented!() } } @@ -65,7 +65,7 @@ impl TryFrom<&CreateRequest> for Endpoint { WebRtcPublishEndpoint::try_from(value.get_webrtc_pub())?; Ok(Endpoint::WebRtcPublish(publish)) } else { - // TODO + // TODO implement another endpoints when they will be implemented unimplemented!() } } diff --git a/src/api/control/endpoints/webrtc_play_endpoint.rs b/src/api/control/endpoints/webrtc_play_endpoint.rs index 3c433d78d..c3a882557 100644 --- a/src/api/control/endpoints/webrtc_play_endpoint.rs +++ b/src/api/control/endpoints/webrtc_play_endpoint.rs @@ -55,7 +55,6 @@ impl TryFrom<&WebRtcPlayEndpointProto> for WebRtcPlayEndpoint { } } -// TODO #[derive(Debug, Fail)] pub enum SrcParseError { #[fail(display = "Missing fields {:?} in '{}' local URI.", _1, _0)] diff --git a/src/api/error_codes.rs b/src/api/error_codes.rs index e98aeb341..b847d3778 100644 --- a/src/api/error_codes.rs +++ b/src/api/error_codes.rs @@ -12,6 +12,7 @@ use crate::api::control::{ }; /// Medea control API errors. +// TODO: write macro for generating error codes. pub enum ErrorCode { /// Unknown server error. /// @@ -153,7 +154,7 @@ impl Into for ErrorCode { ErrorCode::EndpointNotFound(id) => { error.set_text("Endpoint not found.".to_string()); error.set_element(id.to_string()); - error.set_code(1405); + error.set_code(1005); } ////////////////////////////////////// diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index fb6b441e4..be02cace6 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -129,7 +129,6 @@ impl Member { /// /// To fill this [`Member`], you need to call the [`Member::load`] /// function. - // TODO: private pub fn new(id: MemberId, credentials: String, room_id: RoomId) -> Self { Self(RefCell::new(MemberInner { id, From aa05f761329c4b2def8c273c08e86612e53a60af Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 12 Jul 2019 16:43:19 +0300 Subject: [PATCH 344/735] Some fixes for test gRPC client --- src/bin/client.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/bin/client.rs b/src/bin/client.rs index 32a724c7b..a9545a084 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -18,11 +18,10 @@ fn main() { let client = ControlApiClient::new(ch); create_room(&client); - // delete_room(&client); - // delete_endpoint(&client); - // delete_member(&client); - // create_member(&client); - // std::thread::sleep(Duration::from_secs(1)); + delete_room(&client); + delete_endpoint(&client); + delete_member(&client); + create_member(&client); create_endpoint(&client); get_room(&client); } @@ -93,7 +92,7 @@ fn create_endpoint(client: &ControlApiClient) { let mut endpoint = WebRtcPublishEndpoint::new(); endpoint.set_p2p(WebRtcPublishEndpoint_P2P::ALWAYS); create_endpoint_request - .set_id("local://grpc-test/responder/play".to_string()); + .set_id("local://grpc-test/responder/publish".to_string()); create_endpoint_request.set_webrtc_pub(endpoint); let reply = client From fc43f02895057321eaf673d8f789f0719732c7bb Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 12 Jul 2019 17:14:16 +0300 Subject: [PATCH 345/735] Add some docs --- .../control/endpoints/webrtc_play_endpoint.rs | 2 ++ src/api/control/grpc/server.rs | 20 ++++++++++--------- src/api/control/mod.rs | 18 ++++++++++++++++- 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/src/api/control/endpoints/webrtc_play_endpoint.rs b/src/api/control/endpoints/webrtc_play_endpoint.rs index c3a882557..772d86775 100644 --- a/src/api/control/endpoints/webrtc_play_endpoint.rs +++ b/src/api/control/endpoints/webrtc_play_endpoint.rs @@ -1,3 +1,5 @@ +//! `WebRtcPlayEndpoint` implementation. + use std::{convert::TryFrom, fmt}; use failure::Fail; diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index 73c627fd0..a5568faa9 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -224,7 +224,9 @@ impl ControlApiService { } /// Generate [`Response`] for `Create` method of all elements. -fn create_response(result: Result) -> Response { +fn get_response_for_create( + result: Result, +) -> Response { let error: ErrorCode = match result { Ok(r) => match r { Ok(r) => match r { @@ -245,7 +247,7 @@ fn create_response(result: Result) -> Response { error_response } -fn error_response( +fn get_error_response_future( sink: UnarySink, error_code: ErrorCode, ) -> impl Future { @@ -271,10 +273,10 @@ impl ControlApi for ControlApiService { if local_uri.is_room_uri() { if req.has_room() { ctx.spawn(self.create_room(&req, local_uri).then(move |r| { - sink.success(create_response(r)).map_err(|_| ()) + sink.success(get_response_for_create(r)).map_err(|_| ()) })); } else { - ctx.spawn(error_response( + ctx.spawn(get_error_response_future( sink, ErrorCode::ElementIdForRoomButElementIsNot( req.get_id().to_string(), @@ -284,7 +286,7 @@ impl ControlApi for ControlApiService { } else if local_uri.is_member_uri() { if req.has_member() { ctx.spawn(self.create_member(&req, local_uri).then(move |r| { - sink.success(create_response(r)).map_err(|e| { + sink.success(get_response_for_create(r)).map_err(|e| { warn!( "Error while sending Create response by gRPC. {:?}", e @@ -292,7 +294,7 @@ impl ControlApi for ControlApiService { }) })); } else { - ctx.spawn(error_response( + ctx.spawn(get_error_response_future( sink, ErrorCode::ElementIdForMemberButElementIsNot( req.get_id().to_string(), @@ -303,7 +305,7 @@ impl ControlApi for ControlApiService { if req.has_webrtc_pub() || req.has_webrtc_play() { ctx.spawn(self.create_endpoint(&req, local_uri).then( move |r| { - sink.success(create_response(r)).map_err(|e| { + sink.success(get_response_for_create(r)).map_err(|e| { warn!( "Error while sending Create response by gRPC. \ {:?}", @@ -313,7 +315,7 @@ impl ControlApi for ControlApiService { }, )); } else { - ctx.spawn(error_response( + ctx.spawn(get_error_response_future( sink, ErrorCode::ElementIdForEndpointButElementIsNot( req.get_id().to_string(), @@ -321,7 +323,7 @@ impl ControlApi for ControlApiService { )); } } else { - ctx.spawn(error_response( + ctx.spawn(get_error_response_future( sink, ErrorCode::InvalidElementUri(req.get_id().to_string()), )); diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index 8c5dfec69..584937098 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -1,6 +1,5 @@ //! Implementation of Control API. -// pub mod endpoint; pub mod endpoints; pub mod grpc; pub mod local_uri; @@ -33,18 +32,30 @@ pub use self::{ room::{Id as RoomId, RoomSpec}, }; +/// Errors which may occur while deserialize protobuf spec. #[derive(Debug, Fail)] pub enum TryFromProtobufError { + /// Error while parsing src uri of [`WebRtcPlayEndpoint`]. #[fail(display = "Src uri parse error: {:?}", _0)] SrcUriError(SrcParseError), + + /// Src URI not provided for [`WebRtcPlayEndpoint`]. #[fail(display = "Src uri for publish endpoint not provided.")] SrcUriNotFound, + + /// Room element not provided. #[fail(display = "Room element not provided.")] RoomElementNotFound, + + /// Member element not provided. #[fail(display = "Member element not provided.")] MemberElementNotFound, + + /// [`P2pMode`] not found. #[fail(display = "P2p mode for play endpoint not provided.")] P2pModeNotFound, + + /// Member credentials not found. #[fail(display = "Credentials for member not provided.")] MemberCredentialsNotFound, } @@ -69,10 +80,15 @@ impl Into for TryFromProtobufError { #[allow(clippy::pub_enum_variant_names)] #[derive(Debug, Fail)] pub enum TryFromElementError { + /// Element is not Endpoint. #[fail(display = "Element is not Endpoint")] NotEndpoint, + + /// Element is not Room. #[fail(display = "Element is not Room")] NotRoom, + + /// Element is not Member. #[fail(display = "Element is not Member")] NotMember, } From e261df2d4ee1a99e8cdc0263e53703d99efd6a9c Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 12 Jul 2019 17:50:34 +0300 Subject: [PATCH 346/735] Add some macro, refactor gRPC server, add docs --- src/api/control/grpc/server.rs | 203 +++++++++++++++++++-------------- 1 file changed, 115 insertions(+), 88 deletions(-) diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index a5568faa9..1eceaa527 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -4,7 +4,7 @@ use std::{collections::HashMap, convert::TryFrom, sync::Arc}; use actix::{Actor, Addr, Arbiter, Context, MailboxError}; use failure::Fail; -use futures::future::{Either, Future}; +use futures::future::{self, Either, Future}; use grpcio::{Environment, RpcContext, Server, ServerBuilder, UnarySink}; use crate::{ @@ -89,6 +89,10 @@ impl Into for ControlApiError { } } +/// Try to unwrap some [`Result`] and if it `Err` then return err future with +/// [`ControlApiError`]. +/// +/// __Note:__ this macro returns [`Either::B`]. macro_rules! fut_try { ($call:expr) => { match $call { @@ -102,22 +106,42 @@ macro_rules! fut_try { }; } +/// Macro for parse [`LocalUri`] and send error to client if some error occurs. +/// +/// See `send_error_response` doc for details about arguments for this macro. macro_rules! parse_local_uri { ($uri:expr, $ctx:expr, $sink:expr, $response:ty) => { match LocalUri::parse($uri) { Ok(o) => o, Err(e) => { - let mut error_response = <$response>::new(); let error: ErrorCode = e.into(); - let error: Error = error.into(); - error_response.set_error(error); - $ctx.spawn($sink.success(error_response).map_err(|_| ())); - return; + send_error_response!($ctx, $sink, error, $response); } } }; } +/// Macro for send [`Error`] to client and `return` from current function. +/// +/// `$error_code` - some object which can tranform into [`Error`] by `Into` +/// trait. +/// +/// `$response` - is type of response ([`GetResponse`], [`Response`] +/// etc). +macro_rules! send_error_response { + ($ctx:tt, $sink:tt, $error_code:expr, $response:ty) => { + let mut response = <$response>::new(); + let error: Error = $error_code.into(); + response.set_error(error); + + $ctx.spawn($sink.success(response).map_err(|e| { + warn!("Error while sending Error response by gRPC. {:?}", e) + })); + + return; + }; +} + /// Type alias for result of Create request. type CreateResult = Result, RoomError>, RoomRepoError>; @@ -247,19 +271,6 @@ fn get_response_for_create( error_response } -fn get_error_response_future( - sink: UnarySink, - error_code: ErrorCode, -) -> impl Future { - let mut response = Response::new(); - let error: Error = error_code.into(); - response.set_error(error); - - sink.success(response).map_err(|e| { - warn!("Error while sending Error response by gRPC. {:?}", e) - }) -} - impl ControlApi for ControlApiService { /// Implementation for `Create` method of gRPC control API. fn create( @@ -276,12 +287,14 @@ impl ControlApi for ControlApiService { sink.success(get_response_for_create(r)).map_err(|_| ()) })); } else { - ctx.spawn(get_error_response_future( + send_error_response!( + ctx, sink, ErrorCode::ElementIdForRoomButElementIsNot( req.get_id().to_string(), ), - )); + Response + ); } } else if local_uri.is_member_uri() { if req.has_member() { @@ -294,12 +307,14 @@ impl ControlApi for ControlApiService { }) })); } else { - ctx.spawn(get_error_response_future( + send_error_response!( + ctx, sink, ErrorCode::ElementIdForMemberButElementIsNot( req.get_id().to_string(), ), - )); + Response + ); } } else if local_uri.is_endpoint_uri() { if req.has_webrtc_pub() || req.has_webrtc_play() { @@ -315,18 +330,22 @@ impl ControlApi for ControlApiService { }, )); } else { - ctx.spawn(get_error_response_future( + send_error_response!( + ctx, sink, ErrorCode::ElementIdForEndpointButElementIsNot( req.get_id().to_string(), ), - )); + Response + ); } } else { - ctx.spawn(get_error_response_future( + send_error_response!( + ctx, sink, ErrorCode::InvalidElementUri(req.get_id().to_string()), - )); + Response + ); } } @@ -373,18 +392,22 @@ impl ControlApi for ControlApiService { endpoint_id: uri.endpoint_id.unwrap(), }, )); + } else { + send_error_response!( + ctx, + sink, + ErrorCode::InvalidElementUri(id.to_string()), + Response + ); } } - let mega_delete_room_fut = futures::future::join_all(delete_room_futs); - let mega_delete_member_fut = - futures::future::join_all(delete_member_futs); - let mega_delete_endpoints_fut = - futures::future::join_all(delete_endpoints_futs); - ctx.spawn( - mega_delete_endpoints_fut - .join3(mega_delete_member_fut, mega_delete_room_fut) + future::join_all(delete_room_futs) + .join3( + future::join_all(delete_member_futs), + future::join_all(delete_endpoints_futs), + ) .then(move |result| { let map_err_closure = |e| { warn!( @@ -457,6 +480,13 @@ impl ControlApi for ControlApiService { local_uri.member_id.unwrap(), local_uri.endpoint_id.unwrap(), )); + } else { + send_error_response!( + ctx, + sink, + ErrorCode::InvalidElementUri(id.to_string()), + GetResponse + ); } } @@ -464,71 +494,68 @@ impl ControlApi for ControlApiService { let member_fut = self.room_repository.send(GetMember(member_ids)); let endpoint_fut = self.room_repository.send(GetEndpoint(endpoint_ids)); - let mega_future = - room_fut.join3(member_fut, endpoint_fut).then(|result| { - let grpc_err_closure = - |e| warn!("Error while sending Get response. {:?}", e); + ctx.spawn(room_fut.join3(member_fut, endpoint_fut).then(|result| { + let grpc_err_closure = + |e| warn!("Error while sending Get response. {:?}", e); - match result { - Ok((room, member, endpoint)) => { - let mut elements = HashMap::new(); - let mut elements_results = Vec::new(); + match result { + Ok((room, member, endpoint)) => { + let mut elements = HashMap::new(); + let mut elements_results = Vec::new(); - let results = vec![room, member, endpoint]; + let results = vec![room, member, endpoint]; - for result in results { - match result { - Ok(o) => { - elements_results.push(o); - } - Err(e) => { - let mut response = GetResponse::new(); - let error: ErrorCode = e.into(); - response.set_error(error.into()); - return sink - .success(response) - .map_err(grpc_err_closure); - } + for result in results { + match result { + Ok(o) => { + elements_results.push(o); + } + Err(e) => { + let mut response = GetResponse::new(); + let error: ErrorCode = e.into(); + response.set_error(error.into()); + return sink + .success(response) + .map_err(grpc_err_closure); } } + } - let elements_results = elements_results - .into_iter() - .flat_map(std::iter::IntoIterator::into_iter); + let elements_results = elements_results + .into_iter() + .flat_map(std::iter::IntoIterator::into_iter); - for element in elements_results { - match element { - Ok((id, o)) => { - elements.insert(id, o); - } - Err(e) => { - let mut response = GetResponse::new(); - let error: ErrorCode = e.into(); - response.set_error(error.into()); - return sink - .success(response) - .map_err(grpc_err_closure); - } + for element in elements_results { + match element { + Ok((id, o)) => { + elements.insert(id, o); + } + Err(e) => { + let mut response = GetResponse::new(); + let error: ErrorCode = e.into(); + response.set_error(error.into()); + return sink + .success(response) + .map_err(grpc_err_closure); } } + } - let mut response = GetResponse::new(); - response.set_elements(elements); + let mut response = GetResponse::new(); + response.set_elements(elements); - sink.success(response).map_err(grpc_err_closure) - } - Err(e) => { - warn!("Control API Get method mailbox error. {:?}", e); - let mut response = GetResponse::new(); - let error: Error = - ErrorCode::UnknownError(format!("{:?}", e)).into(); - response.set_error(error); - sink.success(response).map_err(grpc_err_closure) - } + sink.success(response).map_err(grpc_err_closure) } - }); - - ctx.spawn(mega_future); + Err(e) => { + warn!("Control API Get method mailbox error. {:?}", e); + let mut response = GetResponse::new(); + let error: Error = + ErrorCode::UnknownError(format!("{:?}", e)).into(); + response.set_error(error); + sink.success(response).map_err(grpc_err_closure) + } + } + })); } } From 34cbdaf181f2f83557b640c14e5f63ec305f3dfd Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 12 Jul 2019 19:07:59 +0300 Subject: [PATCH 347/735] Fix clippy error on generated code --- src/api/control/grpc/protos/mod.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/api/control/grpc/protos/mod.rs b/src/api/control/grpc/protos/mod.rs index 8b8903270..3dae24491 100644 --- a/src/api/control/grpc/protos/mod.rs +++ b/src/api/control/grpc/protos/mod.rs @@ -2,5 +2,9 @@ //! Don't edit `*.rs` files in this module because it automatically generated by //! `protoc` in `build.rs` file. +#![allow(clippy::pedantic)] +#![allow(clippy::cargo)] +#![allow(clippy::nursery)] + pub mod control; pub mod control_grpc; From 78390a17cb8f6786d3d04f3cc98b6cd95750cdaa Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 12 Jul 2019 19:28:47 +0300 Subject: [PATCH 348/735] Gitignore generated protos --- .gitignore | 4 + src/api/control/grpc/protos/control.rs | 6395 ------------------- src/api/control/grpc/protos/control_grpc.rs | 155 - 3 files changed, 4 insertions(+), 6550 deletions(-) delete mode 100644 src/api/control/grpc/protos/control.rs delete mode 100644 src/api/control/grpc/protos/control_grpc.rs diff --git a/.gitignore b/.gitignore index d971d4214..ddd4d7b05 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,7 @@ /target/ **/*.rs.bk + +/src/api/control/grpc/protos +!/src/api/control/grpc/protos/mod.rs +!/src/api/control/grpc/protos/control.proto diff --git a/src/api/control/grpc/protos/control.rs b/src/api/control/grpc/protos/control.rs deleted file mode 100644 index e154cccfa..000000000 --- a/src/api/control/grpc/protos/control.rs +++ /dev/null @@ -1,6395 +0,0 @@ -// This file is generated by rust-protobuf 2.7.0. Do not edit -// @generated - -// https://github.com/Manishearth/rust-clippy/issues/702 -#![allow(unknown_lints)] -#![allow(clippy::all)] - -#![cfg_attr(rustfmt, rustfmt_skip)] - -#![allow(box_pointers)] -#![allow(dead_code)] -#![allow(missing_docs)] -#![allow(non_camel_case_types)] -#![allow(non_snake_case)] -#![allow(non_upper_case_globals)] -#![allow(trivial_casts)] -#![allow(unsafe_code)] -#![allow(unused_imports)] -#![allow(unused_results)] -//! Generated file from `control.proto` - -use protobuf::Message as Message_imported_for_functions; -use protobuf::ProtobufEnum as ProtobufEnum_imported_for_functions; - -/// Generated files are compatible only with the same version -/// of protobuf runtime. -const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_7_0; - -#[derive(PartialEq,Clone,Default)] -pub struct CreateRequest { - // message fields - id: ::protobuf::SingularField<::std::string::String>, - // message oneof groups - pub el: ::std::option::Option, - // special fields - pub unknown_fields: ::protobuf::UnknownFields, - pub cached_size: ::protobuf::CachedSize, -} - -impl<'a> ::std::default::Default for &'a CreateRequest { - fn default() -> &'a CreateRequest { - ::default_instance() - } -} - -#[derive(Clone,PartialEq,Debug)] -pub enum CreateRequest_oneof_el { - hub(Hub), - file_recorder(FileRecorder), - member(Member), - relay(Relay), - room(Room), - webrtc_play(WebRtcPlayEndpoint), - webrtc_pub(WebRtcPublishEndpoint), -} - -impl CreateRequest { - pub fn new() -> CreateRequest { - ::std::default::Default::default() - } - - // required string id = 1; - - - pub fn get_id(&self) -> &str { - match self.id.as_ref() { - Some(v) => &v, - None => "", - } - } - pub fn clear_id(&mut self) { - self.id.clear(); - } - - pub fn has_id(&self) -> bool { - self.id.is_some() - } - - // Param is passed by value, moved - pub fn set_id(&mut self, v: ::std::string::String) { - self.id = ::protobuf::SingularField::some(v); - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_id(&mut self) -> &mut ::std::string::String { - if self.id.is_none() { - self.id.set_default(); - } - self.id.as_mut().unwrap() - } - - // Take field - pub fn take_id(&mut self) -> ::std::string::String { - self.id.take().unwrap_or_else(|| ::std::string::String::new()) - } - - // optional .medea.Hub hub = 2; - - - pub fn get_hub(&self) -> &Hub { - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::hub(ref v)) => v, - _ => Hub::default_instance(), - } - } - pub fn clear_hub(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_hub(&self) -> bool { - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::hub(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_hub(&mut self, v: Hub) { - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::hub(v)) - } - - // Mutable pointer to the field. - pub fn mut_hub(&mut self) -> &mut Hub { - if let ::std::option::Option::Some(CreateRequest_oneof_el::hub(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::hub(Hub::new())); - } - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::hub(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_hub(&mut self) -> Hub { - if self.has_hub() { - match self.el.take() { - ::std::option::Option::Some(CreateRequest_oneof_el::hub(v)) => v, - _ => panic!(), - } - } else { - Hub::new() - } - } - - // optional .medea.FileRecorder file_recorder = 3; - - - pub fn get_file_recorder(&self) -> &FileRecorder { - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::file_recorder(ref v)) => v, - _ => FileRecorder::default_instance(), - } - } - pub fn clear_file_recorder(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_file_recorder(&self) -> bool { - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::file_recorder(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_file_recorder(&mut self, v: FileRecorder) { - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::file_recorder(v)) - } - - // Mutable pointer to the field. - pub fn mut_file_recorder(&mut self) -> &mut FileRecorder { - if let ::std::option::Option::Some(CreateRequest_oneof_el::file_recorder(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::file_recorder(FileRecorder::new())); - } - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::file_recorder(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_file_recorder(&mut self) -> FileRecorder { - if self.has_file_recorder() { - match self.el.take() { - ::std::option::Option::Some(CreateRequest_oneof_el::file_recorder(v)) => v, - _ => panic!(), - } - } else { - FileRecorder::new() - } - } - - // optional .medea.Member member = 4; - - - pub fn get_member(&self) -> &Member { - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::member(ref v)) => v, - _ => Member::default_instance(), - } - } - pub fn clear_member(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_member(&self) -> bool { - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::member(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_member(&mut self, v: Member) { - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::member(v)) - } - - // Mutable pointer to the field. - pub fn mut_member(&mut self) -> &mut Member { - if let ::std::option::Option::Some(CreateRequest_oneof_el::member(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::member(Member::new())); - } - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::member(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_member(&mut self) -> Member { - if self.has_member() { - match self.el.take() { - ::std::option::Option::Some(CreateRequest_oneof_el::member(v)) => v, - _ => panic!(), - } - } else { - Member::new() - } - } - - // optional .medea.Relay relay = 5; - - - pub fn get_relay(&self) -> &Relay { - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::relay(ref v)) => v, - _ => Relay::default_instance(), - } - } - pub fn clear_relay(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_relay(&self) -> bool { - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::relay(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_relay(&mut self, v: Relay) { - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::relay(v)) - } - - // Mutable pointer to the field. - pub fn mut_relay(&mut self) -> &mut Relay { - if let ::std::option::Option::Some(CreateRequest_oneof_el::relay(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::relay(Relay::new())); - } - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::relay(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_relay(&mut self) -> Relay { - if self.has_relay() { - match self.el.take() { - ::std::option::Option::Some(CreateRequest_oneof_el::relay(v)) => v, - _ => panic!(), - } - } else { - Relay::new() - } - } - - // optional .medea.Room room = 6; - - - pub fn get_room(&self) -> &Room { - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::room(ref v)) => v, - _ => Room::default_instance(), - } - } - pub fn clear_room(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_room(&self) -> bool { - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::room(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_room(&mut self, v: Room) { - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::room(v)) - } - - // Mutable pointer to the field. - pub fn mut_room(&mut self) -> &mut Room { - if let ::std::option::Option::Some(CreateRequest_oneof_el::room(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::room(Room::new())); - } - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::room(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_room(&mut self) -> Room { - if self.has_room() { - match self.el.take() { - ::std::option::Option::Some(CreateRequest_oneof_el::room(v)) => v, - _ => panic!(), - } - } else { - Room::new() - } - } - - // optional .medea.WebRtcPlayEndpoint webrtc_play = 7; - - - pub fn get_webrtc_play(&self) -> &WebRtcPlayEndpoint { - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_play(ref v)) => v, - _ => WebRtcPlayEndpoint::default_instance(), - } - } - pub fn clear_webrtc_play(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_webrtc_play(&self) -> bool { - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_play(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_webrtc_play(&mut self, v: WebRtcPlayEndpoint) { - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_play(v)) - } - - // Mutable pointer to the field. - pub fn mut_webrtc_play(&mut self) -> &mut WebRtcPlayEndpoint { - if let ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_play(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_play(WebRtcPlayEndpoint::new())); - } - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_play(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_webrtc_play(&mut self) -> WebRtcPlayEndpoint { - if self.has_webrtc_play() { - match self.el.take() { - ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_play(v)) => v, - _ => panic!(), - } - } else { - WebRtcPlayEndpoint::new() - } - } - - // optional .medea.WebRtcPublishEndpoint webrtc_pub = 8; - - - pub fn get_webrtc_pub(&self) -> &WebRtcPublishEndpoint { - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_pub(ref v)) => v, - _ => WebRtcPublishEndpoint::default_instance(), - } - } - pub fn clear_webrtc_pub(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_webrtc_pub(&self) -> bool { - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_pub(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_webrtc_pub(&mut self, v: WebRtcPublishEndpoint) { - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_pub(v)) - } - - // Mutable pointer to the field. - pub fn mut_webrtc_pub(&mut self) -> &mut WebRtcPublishEndpoint { - if let ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_pub(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_pub(WebRtcPublishEndpoint::new())); - } - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_pub(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_webrtc_pub(&mut self) -> WebRtcPublishEndpoint { - if self.has_webrtc_pub() { - match self.el.take() { - ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_pub(v)) => v, - _ => panic!(), - } - } else { - WebRtcPublishEndpoint::new() - } - } -} - -impl ::protobuf::Message for CreateRequest { - fn is_initialized(&self) -> bool { - if self.id.is_none() { - return false; - } - if let Some(CreateRequest_oneof_el::hub(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(CreateRequest_oneof_el::file_recorder(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(CreateRequest_oneof_el::member(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(CreateRequest_oneof_el::relay(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(CreateRequest_oneof_el::room(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(CreateRequest_oneof_el::webrtc_play(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(CreateRequest_oneof_el::webrtc_pub(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - 1 => { - ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.id)?; - }, - 2 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::hub(is.read_message()?)); - }, - 3 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::file_recorder(is.read_message()?)); - }, - 4 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::member(is.read_message()?)); - }, - 5 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::relay(is.read_message()?)); - }, - 6 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::room(is.read_message()?)); - }, - 7 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_play(is.read_message()?)); - }, - 8 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_pub(is.read_message()?)); - }, - _ => { - ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - if let Some(ref v) = self.id.as_ref() { - my_size += ::protobuf::rt::string_size(1, &v); - } - if let ::std::option::Option::Some(ref v) = self.el { - match v { - &CreateRequest_oneof_el::hub(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &CreateRequest_oneof_el::file_recorder(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &CreateRequest_oneof_el::member(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &CreateRequest_oneof_el::relay(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &CreateRequest_oneof_el::room(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &CreateRequest_oneof_el::webrtc_play(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &CreateRequest_oneof_el::webrtc_pub(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - }; - } - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { - if let Some(ref v) = self.id.as_ref() { - os.write_string(1, &v)?; - } - if let ::std::option::Option::Some(ref v) = self.el { - match v { - &CreateRequest_oneof_el::hub(ref v) => { - os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &CreateRequest_oneof_el::file_recorder(ref v) => { - os.write_tag(3, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &CreateRequest_oneof_el::member(ref v) => { - os.write_tag(4, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &CreateRequest_oneof_el::relay(ref v) => { - os.write_tag(5, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &CreateRequest_oneof_el::room(ref v) => { - os.write_tag(6, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &CreateRequest_oneof_el::webrtc_play(ref v) => { - os.write_tag(7, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &CreateRequest_oneof_el::webrtc_pub(ref v) => { - os.write_tag(8, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - }; - } - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any - } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any - } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - Self::descriptor_static() - } - - fn new() -> CreateRequest { - CreateRequest::new() - } - - fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "id", - |m: &CreateRequest| { &m.id }, - |m: &mut CreateRequest| { &mut m.id }, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Hub>( - "hub", - CreateRequest::has_hub, - CreateRequest::get_hub, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, FileRecorder>( - "file_recorder", - CreateRequest::has_file_recorder, - CreateRequest::get_file_recorder, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Member>( - "member", - CreateRequest::has_member, - CreateRequest::get_member, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Relay>( - "relay", - CreateRequest::has_relay, - CreateRequest::get_relay, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Room>( - "room", - CreateRequest::has_room, - CreateRequest::get_room, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPlayEndpoint>( - "webrtc_play", - CreateRequest::has_webrtc_play, - CreateRequest::get_webrtc_play, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPublishEndpoint>( - "webrtc_pub", - CreateRequest::has_webrtc_pub, - CreateRequest::get_webrtc_pub, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "CreateRequest", - fields, - file_descriptor_proto() - ) - }) - } - } - - fn default_instance() -> &'static CreateRequest { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const CreateRequest, - }; - unsafe { - instance.get(CreateRequest::new) - } - } -} - -impl ::protobuf::Clear for CreateRequest { - fn clear(&mut self) { - self.id.clear(); - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for CreateRequest { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for CreateRequest { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) - } -} - -#[derive(PartialEq,Clone,Default)] -pub struct ApplyRequest { - // message fields - id: ::protobuf::SingularField<::std::string::String>, - policy: ::std::option::Option, - // message oneof groups - pub el: ::std::option::Option, - // special fields - pub unknown_fields: ::protobuf::UnknownFields, - pub cached_size: ::protobuf::CachedSize, -} - -impl<'a> ::std::default::Default for &'a ApplyRequest { - fn default() -> &'a ApplyRequest { - ::default_instance() - } -} - -#[derive(Clone,PartialEq,Debug)] -pub enum ApplyRequest_oneof_el { - hub(Hub), - file_recorder(FileRecorder), - member(Member), - relay(Relay), - room(Room), - webrtc_play(WebRtcPlayEndpoint), - webrtc_pub(WebRtcPublishEndpoint), -} - -impl ApplyRequest { - pub fn new() -> ApplyRequest { - ::std::default::Default::default() - } - - // required string id = 1; - - - pub fn get_id(&self) -> &str { - match self.id.as_ref() { - Some(v) => &v, - None => "", - } - } - pub fn clear_id(&mut self) { - self.id.clear(); - } - - pub fn has_id(&self) -> bool { - self.id.is_some() - } - - // Param is passed by value, moved - pub fn set_id(&mut self, v: ::std::string::String) { - self.id = ::protobuf::SingularField::some(v); - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_id(&mut self) -> &mut ::std::string::String { - if self.id.is_none() { - self.id.set_default(); - } - self.id.as_mut().unwrap() - } - - // Take field - pub fn take_id(&mut self) -> ::std::string::String { - self.id.take().unwrap_or_else(|| ::std::string::String::new()) - } - - // optional .medea.Hub hub = 2; - - - pub fn get_hub(&self) -> &Hub { - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::hub(ref v)) => v, - _ => Hub::default_instance(), - } - } - pub fn clear_hub(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_hub(&self) -> bool { - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::hub(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_hub(&mut self, v: Hub) { - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::hub(v)) - } - - // Mutable pointer to the field. - pub fn mut_hub(&mut self) -> &mut Hub { - if let ::std::option::Option::Some(ApplyRequest_oneof_el::hub(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::hub(Hub::new())); - } - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::hub(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_hub(&mut self) -> Hub { - if self.has_hub() { - match self.el.take() { - ::std::option::Option::Some(ApplyRequest_oneof_el::hub(v)) => v, - _ => panic!(), - } - } else { - Hub::new() - } - } - - // optional .medea.FileRecorder file_recorder = 3; - - - pub fn get_file_recorder(&self) -> &FileRecorder { - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::file_recorder(ref v)) => v, - _ => FileRecorder::default_instance(), - } - } - pub fn clear_file_recorder(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_file_recorder(&self) -> bool { - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::file_recorder(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_file_recorder(&mut self, v: FileRecorder) { - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::file_recorder(v)) - } - - // Mutable pointer to the field. - pub fn mut_file_recorder(&mut self) -> &mut FileRecorder { - if let ::std::option::Option::Some(ApplyRequest_oneof_el::file_recorder(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::file_recorder(FileRecorder::new())); - } - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::file_recorder(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_file_recorder(&mut self) -> FileRecorder { - if self.has_file_recorder() { - match self.el.take() { - ::std::option::Option::Some(ApplyRequest_oneof_el::file_recorder(v)) => v, - _ => panic!(), - } - } else { - FileRecorder::new() - } - } - - // optional .medea.Member member = 4; - - - pub fn get_member(&self) -> &Member { - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::member(ref v)) => v, - _ => Member::default_instance(), - } - } - pub fn clear_member(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_member(&self) -> bool { - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::member(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_member(&mut self, v: Member) { - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::member(v)) - } - - // Mutable pointer to the field. - pub fn mut_member(&mut self) -> &mut Member { - if let ::std::option::Option::Some(ApplyRequest_oneof_el::member(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::member(Member::new())); - } - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::member(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_member(&mut self) -> Member { - if self.has_member() { - match self.el.take() { - ::std::option::Option::Some(ApplyRequest_oneof_el::member(v)) => v, - _ => panic!(), - } - } else { - Member::new() - } - } - - // optional .medea.Relay relay = 5; - - - pub fn get_relay(&self) -> &Relay { - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::relay(ref v)) => v, - _ => Relay::default_instance(), - } - } - pub fn clear_relay(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_relay(&self) -> bool { - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::relay(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_relay(&mut self, v: Relay) { - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::relay(v)) - } - - // Mutable pointer to the field. - pub fn mut_relay(&mut self) -> &mut Relay { - if let ::std::option::Option::Some(ApplyRequest_oneof_el::relay(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::relay(Relay::new())); - } - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::relay(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_relay(&mut self) -> Relay { - if self.has_relay() { - match self.el.take() { - ::std::option::Option::Some(ApplyRequest_oneof_el::relay(v)) => v, - _ => panic!(), - } - } else { - Relay::new() - } - } - - // optional .medea.Room room = 6; - - - pub fn get_room(&self) -> &Room { - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::room(ref v)) => v, - _ => Room::default_instance(), - } - } - pub fn clear_room(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_room(&self) -> bool { - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::room(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_room(&mut self, v: Room) { - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::room(v)) - } - - // Mutable pointer to the field. - pub fn mut_room(&mut self) -> &mut Room { - if let ::std::option::Option::Some(ApplyRequest_oneof_el::room(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::room(Room::new())); - } - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::room(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_room(&mut self) -> Room { - if self.has_room() { - match self.el.take() { - ::std::option::Option::Some(ApplyRequest_oneof_el::room(v)) => v, - _ => panic!(), - } - } else { - Room::new() - } - } - - // optional .medea.WebRtcPlayEndpoint webrtc_play = 7; - - - pub fn get_webrtc_play(&self) -> &WebRtcPlayEndpoint { - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(ref v)) => v, - _ => WebRtcPlayEndpoint::default_instance(), - } - } - pub fn clear_webrtc_play(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_webrtc_play(&self) -> bool { - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_webrtc_play(&mut self, v: WebRtcPlayEndpoint) { - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(v)) - } - - // Mutable pointer to the field. - pub fn mut_webrtc_play(&mut self) -> &mut WebRtcPlayEndpoint { - if let ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(WebRtcPlayEndpoint::new())); - } - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_webrtc_play(&mut self) -> WebRtcPlayEndpoint { - if self.has_webrtc_play() { - match self.el.take() { - ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(v)) => v, - _ => panic!(), - } - } else { - WebRtcPlayEndpoint::new() - } - } - - // optional .medea.WebRtcPublishEndpoint webrtc_pub = 8; - - - pub fn get_webrtc_pub(&self) -> &WebRtcPublishEndpoint { - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(ref v)) => v, - _ => WebRtcPublishEndpoint::default_instance(), - } - } - pub fn clear_webrtc_pub(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_webrtc_pub(&self) -> bool { - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_webrtc_pub(&mut self, v: WebRtcPublishEndpoint) { - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(v)) - } - - // Mutable pointer to the field. - pub fn mut_webrtc_pub(&mut self) -> &mut WebRtcPublishEndpoint { - if let ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(WebRtcPublishEndpoint::new())); - } - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_webrtc_pub(&mut self) -> WebRtcPublishEndpoint { - if self.has_webrtc_pub() { - match self.el.take() { - ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(v)) => v, - _ => panic!(), - } - } else { - WebRtcPublishEndpoint::new() - } - } - - // optional .medea.ApplyRequest.Policy policy = 9; - - - pub fn get_policy(&self) -> ApplyRequest_Policy { - self.policy.unwrap_or(ApplyRequest_Policy::APPLY) - } - pub fn clear_policy(&mut self) { - self.policy = ::std::option::Option::None; - } - - pub fn has_policy(&self) -> bool { - self.policy.is_some() - } - - // Param is passed by value, moved - pub fn set_policy(&mut self, v: ApplyRequest_Policy) { - self.policy = ::std::option::Option::Some(v); - } -} - -impl ::protobuf::Message for ApplyRequest { - fn is_initialized(&self) -> bool { - if self.id.is_none() { - return false; - } - if let Some(ApplyRequest_oneof_el::hub(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(ApplyRequest_oneof_el::file_recorder(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(ApplyRequest_oneof_el::member(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(ApplyRequest_oneof_el::relay(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(ApplyRequest_oneof_el::room(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(ApplyRequest_oneof_el::webrtc_play(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(ApplyRequest_oneof_el::webrtc_pub(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - 1 => { - ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.id)?; - }, - 2 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::hub(is.read_message()?)); - }, - 3 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::file_recorder(is.read_message()?)); - }, - 4 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::member(is.read_message()?)); - }, - 5 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::relay(is.read_message()?)); - }, - 6 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::room(is.read_message()?)); - }, - 7 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(is.read_message()?)); - }, - 8 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(is.read_message()?)); - }, - 9 => { - ::protobuf::rt::read_proto2_enum_with_unknown_fields_into(wire_type, is, &mut self.policy, 9, &mut self.unknown_fields)? - }, - _ => { - ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - if let Some(ref v) = self.id.as_ref() { - my_size += ::protobuf::rt::string_size(1, &v); - } - if let Some(v) = self.policy { - my_size += ::protobuf::rt::enum_size(9, v); - } - if let ::std::option::Option::Some(ref v) = self.el { - match v { - &ApplyRequest_oneof_el::hub(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &ApplyRequest_oneof_el::file_recorder(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &ApplyRequest_oneof_el::member(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &ApplyRequest_oneof_el::relay(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &ApplyRequest_oneof_el::room(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &ApplyRequest_oneof_el::webrtc_play(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &ApplyRequest_oneof_el::webrtc_pub(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - }; - } - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { - if let Some(ref v) = self.id.as_ref() { - os.write_string(1, &v)?; - } - if let Some(v) = self.policy { - os.write_enum(9, v.value())?; - } - if let ::std::option::Option::Some(ref v) = self.el { - match v { - &ApplyRequest_oneof_el::hub(ref v) => { - os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &ApplyRequest_oneof_el::file_recorder(ref v) => { - os.write_tag(3, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &ApplyRequest_oneof_el::member(ref v) => { - os.write_tag(4, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &ApplyRequest_oneof_el::relay(ref v) => { - os.write_tag(5, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &ApplyRequest_oneof_el::room(ref v) => { - os.write_tag(6, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &ApplyRequest_oneof_el::webrtc_play(ref v) => { - os.write_tag(7, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &ApplyRequest_oneof_el::webrtc_pub(ref v) => { - os.write_tag(8, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - }; - } - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any - } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any - } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - Self::descriptor_static() - } - - fn new() -> ApplyRequest { - ApplyRequest::new() - } - - fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "id", - |m: &ApplyRequest| { &m.id }, - |m: &mut ApplyRequest| { &mut m.id }, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Hub>( - "hub", - ApplyRequest::has_hub, - ApplyRequest::get_hub, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, FileRecorder>( - "file_recorder", - ApplyRequest::has_file_recorder, - ApplyRequest::get_file_recorder, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Member>( - "member", - ApplyRequest::has_member, - ApplyRequest::get_member, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Relay>( - "relay", - ApplyRequest::has_relay, - ApplyRequest::get_relay, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Room>( - "room", - ApplyRequest::has_room, - ApplyRequest::get_room, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPlayEndpoint>( - "webrtc_play", - ApplyRequest::has_webrtc_play, - ApplyRequest::get_webrtc_play, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPublishEndpoint>( - "webrtc_pub", - ApplyRequest::has_webrtc_pub, - ApplyRequest::get_webrtc_pub, - )); - fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeEnum>( - "policy", - |m: &ApplyRequest| { &m.policy }, - |m: &mut ApplyRequest| { &mut m.policy }, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "ApplyRequest", - fields, - file_descriptor_proto() - ) - }) - } - } - - fn default_instance() -> &'static ApplyRequest { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ApplyRequest, - }; - unsafe { - instance.get(ApplyRequest::new) - } - } -} - -impl ::protobuf::Clear for ApplyRequest { - fn clear(&mut self) { - self.id.clear(); - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.policy = ::std::option::Option::None; - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for ApplyRequest { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for ApplyRequest { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) - } -} - -#[derive(Clone,PartialEq,Eq,Debug,Hash)] -pub enum ApplyRequest_Policy { - APPLY = 1, - APPEND = 2, -} - -impl ::protobuf::ProtobufEnum for ApplyRequest_Policy { - fn value(&self) -> i32 { - *self as i32 - } - - fn from_i32(value: i32) -> ::std::option::Option { - match value { - 1 => ::std::option::Option::Some(ApplyRequest_Policy::APPLY), - 2 => ::std::option::Option::Some(ApplyRequest_Policy::APPEND), - _ => ::std::option::Option::None - } - } - - fn values() -> &'static [Self] { - static values: &'static [ApplyRequest_Policy] = &[ - ApplyRequest_Policy::APPLY, - ApplyRequest_Policy::APPEND, - ]; - values - } - - fn enum_descriptor_static() -> &'static ::protobuf::reflect::EnumDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::EnumDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::EnumDescriptor, - }; - unsafe { - descriptor.get(|| { - ::protobuf::reflect::EnumDescriptor::new("ApplyRequest_Policy", file_descriptor_proto()) - }) - } - } -} - -impl ::std::marker::Copy for ApplyRequest_Policy { -} - -// Note, `Default` is implemented although default value is not 0 -impl ::std::default::Default for ApplyRequest_Policy { - fn default() -> Self { - ApplyRequest_Policy::APPLY - } -} - -impl ::protobuf::reflect::ProtobufValue for ApplyRequest_Policy { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Enum(self.descriptor()) - } -} - -#[derive(PartialEq,Clone,Default)] -pub struct IdRequest { - // message fields - id: ::protobuf::RepeatedField<::std::string::String>, - // special fields - pub unknown_fields: ::protobuf::UnknownFields, - pub cached_size: ::protobuf::CachedSize, -} - -impl<'a> ::std::default::Default for &'a IdRequest { - fn default() -> &'a IdRequest { - ::default_instance() - } -} - -impl IdRequest { - pub fn new() -> IdRequest { - ::std::default::Default::default() - } - - // repeated string id = 1; - - - pub fn get_id(&self) -> &[::std::string::String] { - &self.id - } - pub fn clear_id(&mut self) { - self.id.clear(); - } - - // Param is passed by value, moved - pub fn set_id(&mut self, v: ::protobuf::RepeatedField<::std::string::String>) { - self.id = v; - } - - // Mutable pointer to the field. - pub fn mut_id(&mut self) -> &mut ::protobuf::RepeatedField<::std::string::String> { - &mut self.id - } - - // Take field - pub fn take_id(&mut self) -> ::protobuf::RepeatedField<::std::string::String> { - ::std::mem::replace(&mut self.id, ::protobuf::RepeatedField::new()) - } -} - -impl ::protobuf::Message for IdRequest { - fn is_initialized(&self) -> bool { - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - 1 => { - ::protobuf::rt::read_repeated_string_into(wire_type, is, &mut self.id)?; - }, - _ => { - ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - for value in &self.id { - my_size += ::protobuf::rt::string_size(1, &value); - }; - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { - for v in &self.id { - os.write_string(1, &v)?; - }; - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any - } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any - } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - Self::descriptor_static() - } - - fn new() -> IdRequest { - IdRequest::new() - } - - fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "id", - |m: &IdRequest| { &m.id }, - |m: &mut IdRequest| { &mut m.id }, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "IdRequest", - fields, - file_descriptor_proto() - ) - }) - } - } - - fn default_instance() -> &'static IdRequest { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const IdRequest, - }; - unsafe { - instance.get(IdRequest::new) - } - } -} - -impl ::protobuf::Clear for IdRequest { - fn clear(&mut self) { - self.id.clear(); - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for IdRequest { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for IdRequest { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) - } -} - -#[derive(PartialEq,Clone,Default)] -pub struct Response { - // message fields - pub sid: ::std::collections::HashMap<::std::string::String, ::std::string::String>, - error: ::protobuf::SingularPtrField, - // special fields - pub unknown_fields: ::protobuf::UnknownFields, - pub cached_size: ::protobuf::CachedSize, -} - -impl<'a> ::std::default::Default for &'a Response { - fn default() -> &'a Response { - ::default_instance() - } -} - -impl Response { - pub fn new() -> Response { - ::std::default::Default::default() - } - - // repeated .medea.Response.SidEntry sid = 1; - - - pub fn get_sid(&self) -> &::std::collections::HashMap<::std::string::String, ::std::string::String> { - &self.sid - } - pub fn clear_sid(&mut self) { - self.sid.clear(); - } - - // Param is passed by value, moved - pub fn set_sid(&mut self, v: ::std::collections::HashMap<::std::string::String, ::std::string::String>) { - self.sid = v; - } - - // Mutable pointer to the field. - pub fn mut_sid(&mut self) -> &mut ::std::collections::HashMap<::std::string::String, ::std::string::String> { - &mut self.sid - } - - // Take field - pub fn take_sid(&mut self) -> ::std::collections::HashMap<::std::string::String, ::std::string::String> { - ::std::mem::replace(&mut self.sid, ::std::collections::HashMap::new()) - } - - // optional .medea.Error error = 2; - - - pub fn get_error(&self) -> &Error { - self.error.as_ref().unwrap_or_else(|| Error::default_instance()) - } - pub fn clear_error(&mut self) { - self.error.clear(); - } - - pub fn has_error(&self) -> bool { - self.error.is_some() - } - - // Param is passed by value, moved - pub fn set_error(&mut self, v: Error) { - self.error = ::protobuf::SingularPtrField::some(v); - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_error(&mut self) -> &mut Error { - if self.error.is_none() { - self.error.set_default(); - } - self.error.as_mut().unwrap() - } - - // Take field - pub fn take_error(&mut self) -> Error { - self.error.take().unwrap_or_else(|| Error::new()) - } -} - -impl ::protobuf::Message for Response { - fn is_initialized(&self) -> bool { - for v in &self.error { - if !v.is_initialized() { - return false; - } - }; - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - 1 => { - ::protobuf::rt::read_map_into::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeString>(wire_type, is, &mut self.sid)?; - }, - 2 => { - ::protobuf::rt::read_singular_message_into(wire_type, is, &mut self.error)?; - }, - _ => { - ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - my_size += ::protobuf::rt::compute_map_size::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeString>(1, &self.sid); - if let Some(ref v) = self.error.as_ref() { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - } - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { - ::protobuf::rt::write_map_with_cached_sizes::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeString>(1, &self.sid, os)?; - if let Some(ref v) = self.error.as_ref() { - os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - } - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any - } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any - } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - Self::descriptor_static() - } - - fn new() -> Response { - Response::new() - } - - fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_map_accessor::<_, ::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeString>( - "sid", - |m: &Response| { &m.sid }, - |m: &mut Response| { &mut m.sid }, - )); - fields.push(::protobuf::reflect::accessor::make_singular_ptr_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( - "error", - |m: &Response| { &m.error }, - |m: &mut Response| { &mut m.error }, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "Response", - fields, - file_descriptor_proto() - ) - }) - } - } - - fn default_instance() -> &'static Response { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const Response, - }; - unsafe { - instance.get(Response::new) - } - } -} - -impl ::protobuf::Clear for Response { - fn clear(&mut self) { - self.sid.clear(); - self.error.clear(); - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for Response { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for Response { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) - } -} - -#[derive(PartialEq,Clone,Default)] -pub struct GetResponse { - // message fields - pub elements: ::std::collections::HashMap<::std::string::String, Element>, - error: ::protobuf::SingularPtrField, - // special fields - pub unknown_fields: ::protobuf::UnknownFields, - pub cached_size: ::protobuf::CachedSize, -} - -impl<'a> ::std::default::Default for &'a GetResponse { - fn default() -> &'a GetResponse { - ::default_instance() - } -} - -impl GetResponse { - pub fn new() -> GetResponse { - ::std::default::Default::default() - } - - // repeated .medea.GetResponse.ElementsEntry elements = 1; - - - pub fn get_elements(&self) -> &::std::collections::HashMap<::std::string::String, Element> { - &self.elements - } - pub fn clear_elements(&mut self) { - self.elements.clear(); - } - - // Param is passed by value, moved - pub fn set_elements(&mut self, v: ::std::collections::HashMap<::std::string::String, Element>) { - self.elements = v; - } - - // Mutable pointer to the field. - pub fn mut_elements(&mut self) -> &mut ::std::collections::HashMap<::std::string::String, Element> { - &mut self.elements - } - - // Take field - pub fn take_elements(&mut self) -> ::std::collections::HashMap<::std::string::String, Element> { - ::std::mem::replace(&mut self.elements, ::std::collections::HashMap::new()) - } - - // optional .medea.Error error = 2; - - - pub fn get_error(&self) -> &Error { - self.error.as_ref().unwrap_or_else(|| Error::default_instance()) - } - pub fn clear_error(&mut self) { - self.error.clear(); - } - - pub fn has_error(&self) -> bool { - self.error.is_some() - } - - // Param is passed by value, moved - pub fn set_error(&mut self, v: Error) { - self.error = ::protobuf::SingularPtrField::some(v); - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_error(&mut self) -> &mut Error { - if self.error.is_none() { - self.error.set_default(); - } - self.error.as_mut().unwrap() - } - - // Take field - pub fn take_error(&mut self) -> Error { - self.error.take().unwrap_or_else(|| Error::new()) - } -} - -impl ::protobuf::Message for GetResponse { - fn is_initialized(&self) -> bool { - for v in &self.error { - if !v.is_initialized() { - return false; - } - }; - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - 1 => { - ::protobuf::rt::read_map_into::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(wire_type, is, &mut self.elements)?; - }, - 2 => { - ::protobuf::rt::read_singular_message_into(wire_type, is, &mut self.error)?; - }, - _ => { - ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - my_size += ::protobuf::rt::compute_map_size::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(1, &self.elements); - if let Some(ref v) = self.error.as_ref() { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - } - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { - ::protobuf::rt::write_map_with_cached_sizes::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(1, &self.elements, os)?; - if let Some(ref v) = self.error.as_ref() { - os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - } - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any - } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any - } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - Self::descriptor_static() - } - - fn new() -> GetResponse { - GetResponse::new() - } - - fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_map_accessor::<_, ::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>( - "elements", - |m: &GetResponse| { &m.elements }, - |m: &mut GetResponse| { &mut m.elements }, - )); - fields.push(::protobuf::reflect::accessor::make_singular_ptr_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( - "error", - |m: &GetResponse| { &m.error }, - |m: &mut GetResponse| { &mut m.error }, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "GetResponse", - fields, - file_descriptor_proto() - ) - }) - } - } - - fn default_instance() -> &'static GetResponse { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const GetResponse, - }; - unsafe { - instance.get(GetResponse::new) - } - } -} - -impl ::protobuf::Clear for GetResponse { - fn clear(&mut self) { - self.elements.clear(); - self.error.clear(); - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for GetResponse { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for GetResponse { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) - } -} - -#[derive(PartialEq,Clone,Default)] -pub struct Error { - // message fields - status: ::std::option::Option, - code: ::std::option::Option, - text: ::protobuf::SingularField<::std::string::String>, - doc: ::protobuf::SingularField<::std::string::String>, - element: ::protobuf::SingularField<::std::string::String>, - details: ::protobuf::SingularPtrField<::protobuf::well_known_types::Any>, - backtrace: ::protobuf::RepeatedField<::std::string::String>, - // special fields - pub unknown_fields: ::protobuf::UnknownFields, - pub cached_size: ::protobuf::CachedSize, -} - -impl<'a> ::std::default::Default for &'a Error { - fn default() -> &'a Error { - ::default_instance() - } -} - -impl Error { - pub fn new() -> Error { - ::std::default::Default::default() - } - - // required uint32 status = 1; - - - pub fn get_status(&self) -> u32 { - self.status.unwrap_or(0) - } - pub fn clear_status(&mut self) { - self.status = ::std::option::Option::None; - } - - pub fn has_status(&self) -> bool { - self.status.is_some() - } - - // Param is passed by value, moved - pub fn set_status(&mut self, v: u32) { - self.status = ::std::option::Option::Some(v); - } - - // required uint32 code = 2; - - - pub fn get_code(&self) -> u32 { - self.code.unwrap_or(0) - } - pub fn clear_code(&mut self) { - self.code = ::std::option::Option::None; - } - - pub fn has_code(&self) -> bool { - self.code.is_some() - } - - // Param is passed by value, moved - pub fn set_code(&mut self, v: u32) { - self.code = ::std::option::Option::Some(v); - } - - // required string text = 3; - - - pub fn get_text(&self) -> &str { - match self.text.as_ref() { - Some(v) => &v, - None => "", - } - } - pub fn clear_text(&mut self) { - self.text.clear(); - } - - pub fn has_text(&self) -> bool { - self.text.is_some() - } - - // Param is passed by value, moved - pub fn set_text(&mut self, v: ::std::string::String) { - self.text = ::protobuf::SingularField::some(v); - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_text(&mut self) -> &mut ::std::string::String { - if self.text.is_none() { - self.text.set_default(); - } - self.text.as_mut().unwrap() - } - - // Take field - pub fn take_text(&mut self) -> ::std::string::String { - self.text.take().unwrap_or_else(|| ::std::string::String::new()) - } - - // optional string doc = 4; - - - pub fn get_doc(&self) -> &str { - match self.doc.as_ref() { - Some(v) => &v, - None => "", - } - } - pub fn clear_doc(&mut self) { - self.doc.clear(); - } - - pub fn has_doc(&self) -> bool { - self.doc.is_some() - } - - // Param is passed by value, moved - pub fn set_doc(&mut self, v: ::std::string::String) { - self.doc = ::protobuf::SingularField::some(v); - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_doc(&mut self) -> &mut ::std::string::String { - if self.doc.is_none() { - self.doc.set_default(); - } - self.doc.as_mut().unwrap() - } - - // Take field - pub fn take_doc(&mut self) -> ::std::string::String { - self.doc.take().unwrap_or_else(|| ::std::string::String::new()) - } - - // required string element = 5; - - - pub fn get_element(&self) -> &str { - match self.element.as_ref() { - Some(v) => &v, - None => "", - } - } - pub fn clear_element(&mut self) { - self.element.clear(); - } - - pub fn has_element(&self) -> bool { - self.element.is_some() - } - - // Param is passed by value, moved - pub fn set_element(&mut self, v: ::std::string::String) { - self.element = ::protobuf::SingularField::some(v); - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_element(&mut self) -> &mut ::std::string::String { - if self.element.is_none() { - self.element.set_default(); - } - self.element.as_mut().unwrap() - } - - // Take field - pub fn take_element(&mut self) -> ::std::string::String { - self.element.take().unwrap_or_else(|| ::std::string::String::new()) - } - - // optional .google.protobuf.Any details = 6; - - - pub fn get_details(&self) -> &::protobuf::well_known_types::Any { - self.details.as_ref().unwrap_or_else(|| ::protobuf::well_known_types::Any::default_instance()) - } - pub fn clear_details(&mut self) { - self.details.clear(); - } - - pub fn has_details(&self) -> bool { - self.details.is_some() - } - - // Param is passed by value, moved - pub fn set_details(&mut self, v: ::protobuf::well_known_types::Any) { - self.details = ::protobuf::SingularPtrField::some(v); - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_details(&mut self) -> &mut ::protobuf::well_known_types::Any { - if self.details.is_none() { - self.details.set_default(); - } - self.details.as_mut().unwrap() - } - - // Take field - pub fn take_details(&mut self) -> ::protobuf::well_known_types::Any { - self.details.take().unwrap_or_else(|| ::protobuf::well_known_types::Any::new()) - } - - // repeated string backtrace = 7; - - - pub fn get_backtrace(&self) -> &[::std::string::String] { - &self.backtrace - } - pub fn clear_backtrace(&mut self) { - self.backtrace.clear(); - } - - // Param is passed by value, moved - pub fn set_backtrace(&mut self, v: ::protobuf::RepeatedField<::std::string::String>) { - self.backtrace = v; - } - - // Mutable pointer to the field. - pub fn mut_backtrace(&mut self) -> &mut ::protobuf::RepeatedField<::std::string::String> { - &mut self.backtrace - } - - // Take field - pub fn take_backtrace(&mut self) -> ::protobuf::RepeatedField<::std::string::String> { - ::std::mem::replace(&mut self.backtrace, ::protobuf::RepeatedField::new()) - } -} - -impl ::protobuf::Message for Error { - fn is_initialized(&self) -> bool { - if self.status.is_none() { - return false; - } - if self.code.is_none() { - return false; - } - if self.text.is_none() { - return false; - } - if self.element.is_none() { - return false; - } - for v in &self.details { - if !v.is_initialized() { - return false; - } - }; - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - 1 => { - if wire_type != ::protobuf::wire_format::WireTypeVarint { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - let tmp = is.read_uint32()?; - self.status = ::std::option::Option::Some(tmp); - }, - 2 => { - if wire_type != ::protobuf::wire_format::WireTypeVarint { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - let tmp = is.read_uint32()?; - self.code = ::std::option::Option::Some(tmp); - }, - 3 => { - ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.text)?; - }, - 4 => { - ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.doc)?; - }, - 5 => { - ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.element)?; - }, - 6 => { - ::protobuf::rt::read_singular_message_into(wire_type, is, &mut self.details)?; - }, - 7 => { - ::protobuf::rt::read_repeated_string_into(wire_type, is, &mut self.backtrace)?; - }, - _ => { - ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - if let Some(v) = self.status { - my_size += ::protobuf::rt::value_size(1, v, ::protobuf::wire_format::WireTypeVarint); - } - if let Some(v) = self.code { - my_size += ::protobuf::rt::value_size(2, v, ::protobuf::wire_format::WireTypeVarint); - } - if let Some(ref v) = self.text.as_ref() { - my_size += ::protobuf::rt::string_size(3, &v); - } - if let Some(ref v) = self.doc.as_ref() { - my_size += ::protobuf::rt::string_size(4, &v); - } - if let Some(ref v) = self.element.as_ref() { - my_size += ::protobuf::rt::string_size(5, &v); - } - if let Some(ref v) = self.details.as_ref() { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - } - for value in &self.backtrace { - my_size += ::protobuf::rt::string_size(7, &value); - }; - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { - if let Some(v) = self.status { - os.write_uint32(1, v)?; - } - if let Some(v) = self.code { - os.write_uint32(2, v)?; - } - if let Some(ref v) = self.text.as_ref() { - os.write_string(3, &v)?; - } - if let Some(ref v) = self.doc.as_ref() { - os.write_string(4, &v)?; - } - if let Some(ref v) = self.element.as_ref() { - os.write_string(5, &v)?; - } - if let Some(ref v) = self.details.as_ref() { - os.write_tag(6, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - } - for v in &self.backtrace { - os.write_string(7, &v)?; - }; - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any - } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any - } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - Self::descriptor_static() - } - - fn new() -> Error { - Error::new() - } - - fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeUint32>( - "status", - |m: &Error| { &m.status }, - |m: &mut Error| { &mut m.status }, - )); - fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeUint32>( - "code", - |m: &Error| { &m.code }, - |m: &mut Error| { &mut m.code }, - )); - fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "text", - |m: &Error| { &m.text }, - |m: &mut Error| { &mut m.text }, - )); - fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "doc", - |m: &Error| { &m.doc }, - |m: &mut Error| { &mut m.doc }, - )); - fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "element", - |m: &Error| { &m.element }, - |m: &mut Error| { &mut m.element }, - )); - fields.push(::protobuf::reflect::accessor::make_singular_ptr_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage<::protobuf::well_known_types::Any>>( - "details", - |m: &Error| { &m.details }, - |m: &mut Error| { &mut m.details }, - )); - fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "backtrace", - |m: &Error| { &m.backtrace }, - |m: &mut Error| { &mut m.backtrace }, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "Error", - fields, - file_descriptor_proto() - ) - }) - } - } - - fn default_instance() -> &'static Error { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const Error, - }; - unsafe { - instance.get(Error::new) - } - } -} - -impl ::protobuf::Clear for Error { - fn clear(&mut self) { - self.status = ::std::option::Option::None; - self.code = ::std::option::Option::None; - self.text.clear(); - self.doc.clear(); - self.element.clear(); - self.details.clear(); - self.backtrace.clear(); - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for Error { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for Error { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) - } -} - -#[derive(PartialEq,Clone,Default)] -pub struct Element { - // message oneof groups - pub el: ::std::option::Option, - // special fields - pub unknown_fields: ::protobuf::UnknownFields, - pub cached_size: ::protobuf::CachedSize, -} - -impl<'a> ::std::default::Default for &'a Element { - fn default() -> &'a Element { - ::default_instance() - } -} - -#[derive(Clone,PartialEq,Debug)] -pub enum Element_oneof_el { - hub(Hub), - file_recorder(FileRecorder), - member(Member), - relay(Relay), - room(Room), - webrtc_play(WebRtcPlayEndpoint), - webrtc_pub(WebRtcPublishEndpoint), -} - -impl Element { - pub fn new() -> Element { - ::std::default::Default::default() - } - - // optional .medea.Hub hub = 2; - - - pub fn get_hub(&self) -> &Hub { - match self.el { - ::std::option::Option::Some(Element_oneof_el::hub(ref v)) => v, - _ => Hub::default_instance(), - } - } - pub fn clear_hub(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_hub(&self) -> bool { - match self.el { - ::std::option::Option::Some(Element_oneof_el::hub(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_hub(&mut self, v: Hub) { - self.el = ::std::option::Option::Some(Element_oneof_el::hub(v)) - } - - // Mutable pointer to the field. - pub fn mut_hub(&mut self) -> &mut Hub { - if let ::std::option::Option::Some(Element_oneof_el::hub(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(Element_oneof_el::hub(Hub::new())); - } - match self.el { - ::std::option::Option::Some(Element_oneof_el::hub(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_hub(&mut self) -> Hub { - if self.has_hub() { - match self.el.take() { - ::std::option::Option::Some(Element_oneof_el::hub(v)) => v, - _ => panic!(), - } - } else { - Hub::new() - } - } - - // optional .medea.FileRecorder file_recorder = 3; - - - pub fn get_file_recorder(&self) -> &FileRecorder { - match self.el { - ::std::option::Option::Some(Element_oneof_el::file_recorder(ref v)) => v, - _ => FileRecorder::default_instance(), - } - } - pub fn clear_file_recorder(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_file_recorder(&self) -> bool { - match self.el { - ::std::option::Option::Some(Element_oneof_el::file_recorder(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_file_recorder(&mut self, v: FileRecorder) { - self.el = ::std::option::Option::Some(Element_oneof_el::file_recorder(v)) - } - - // Mutable pointer to the field. - pub fn mut_file_recorder(&mut self) -> &mut FileRecorder { - if let ::std::option::Option::Some(Element_oneof_el::file_recorder(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(Element_oneof_el::file_recorder(FileRecorder::new())); - } - match self.el { - ::std::option::Option::Some(Element_oneof_el::file_recorder(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_file_recorder(&mut self) -> FileRecorder { - if self.has_file_recorder() { - match self.el.take() { - ::std::option::Option::Some(Element_oneof_el::file_recorder(v)) => v, - _ => panic!(), - } - } else { - FileRecorder::new() - } - } - - // optional .medea.Member member = 4; - - - pub fn get_member(&self) -> &Member { - match self.el { - ::std::option::Option::Some(Element_oneof_el::member(ref v)) => v, - _ => Member::default_instance(), - } - } - pub fn clear_member(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_member(&self) -> bool { - match self.el { - ::std::option::Option::Some(Element_oneof_el::member(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_member(&mut self, v: Member) { - self.el = ::std::option::Option::Some(Element_oneof_el::member(v)) - } - - // Mutable pointer to the field. - pub fn mut_member(&mut self) -> &mut Member { - if let ::std::option::Option::Some(Element_oneof_el::member(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(Element_oneof_el::member(Member::new())); - } - match self.el { - ::std::option::Option::Some(Element_oneof_el::member(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_member(&mut self) -> Member { - if self.has_member() { - match self.el.take() { - ::std::option::Option::Some(Element_oneof_el::member(v)) => v, - _ => panic!(), - } - } else { - Member::new() - } - } - - // optional .medea.Relay relay = 5; - - - pub fn get_relay(&self) -> &Relay { - match self.el { - ::std::option::Option::Some(Element_oneof_el::relay(ref v)) => v, - _ => Relay::default_instance(), - } - } - pub fn clear_relay(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_relay(&self) -> bool { - match self.el { - ::std::option::Option::Some(Element_oneof_el::relay(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_relay(&mut self, v: Relay) { - self.el = ::std::option::Option::Some(Element_oneof_el::relay(v)) - } - - // Mutable pointer to the field. - pub fn mut_relay(&mut self) -> &mut Relay { - if let ::std::option::Option::Some(Element_oneof_el::relay(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(Element_oneof_el::relay(Relay::new())); - } - match self.el { - ::std::option::Option::Some(Element_oneof_el::relay(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_relay(&mut self) -> Relay { - if self.has_relay() { - match self.el.take() { - ::std::option::Option::Some(Element_oneof_el::relay(v)) => v, - _ => panic!(), - } - } else { - Relay::new() - } - } - - // optional .medea.Room room = 6; - - - pub fn get_room(&self) -> &Room { - match self.el { - ::std::option::Option::Some(Element_oneof_el::room(ref v)) => v, - _ => Room::default_instance(), - } - } - pub fn clear_room(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_room(&self) -> bool { - match self.el { - ::std::option::Option::Some(Element_oneof_el::room(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_room(&mut self, v: Room) { - self.el = ::std::option::Option::Some(Element_oneof_el::room(v)) - } - - // Mutable pointer to the field. - pub fn mut_room(&mut self) -> &mut Room { - if let ::std::option::Option::Some(Element_oneof_el::room(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(Element_oneof_el::room(Room::new())); - } - match self.el { - ::std::option::Option::Some(Element_oneof_el::room(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_room(&mut self) -> Room { - if self.has_room() { - match self.el.take() { - ::std::option::Option::Some(Element_oneof_el::room(v)) => v, - _ => panic!(), - } - } else { - Room::new() - } - } - - // optional .medea.WebRtcPlayEndpoint webrtc_play = 7; - - - pub fn get_webrtc_play(&self) -> &WebRtcPlayEndpoint { - match self.el { - ::std::option::Option::Some(Element_oneof_el::webrtc_play(ref v)) => v, - _ => WebRtcPlayEndpoint::default_instance(), - } - } - pub fn clear_webrtc_play(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_webrtc_play(&self) -> bool { - match self.el { - ::std::option::Option::Some(Element_oneof_el::webrtc_play(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_webrtc_play(&mut self, v: WebRtcPlayEndpoint) { - self.el = ::std::option::Option::Some(Element_oneof_el::webrtc_play(v)) - } - - // Mutable pointer to the field. - pub fn mut_webrtc_play(&mut self) -> &mut WebRtcPlayEndpoint { - if let ::std::option::Option::Some(Element_oneof_el::webrtc_play(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(Element_oneof_el::webrtc_play(WebRtcPlayEndpoint::new())); - } - match self.el { - ::std::option::Option::Some(Element_oneof_el::webrtc_play(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_webrtc_play(&mut self) -> WebRtcPlayEndpoint { - if self.has_webrtc_play() { - match self.el.take() { - ::std::option::Option::Some(Element_oneof_el::webrtc_play(v)) => v, - _ => panic!(), - } - } else { - WebRtcPlayEndpoint::new() - } - } - - // optional .medea.WebRtcPublishEndpoint webrtc_pub = 8; - - - pub fn get_webrtc_pub(&self) -> &WebRtcPublishEndpoint { - match self.el { - ::std::option::Option::Some(Element_oneof_el::webrtc_pub(ref v)) => v, - _ => WebRtcPublishEndpoint::default_instance(), - } - } - pub fn clear_webrtc_pub(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_webrtc_pub(&self) -> bool { - match self.el { - ::std::option::Option::Some(Element_oneof_el::webrtc_pub(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_webrtc_pub(&mut self, v: WebRtcPublishEndpoint) { - self.el = ::std::option::Option::Some(Element_oneof_el::webrtc_pub(v)) - } - - // Mutable pointer to the field. - pub fn mut_webrtc_pub(&mut self) -> &mut WebRtcPublishEndpoint { - if let ::std::option::Option::Some(Element_oneof_el::webrtc_pub(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(Element_oneof_el::webrtc_pub(WebRtcPublishEndpoint::new())); - } - match self.el { - ::std::option::Option::Some(Element_oneof_el::webrtc_pub(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_webrtc_pub(&mut self) -> WebRtcPublishEndpoint { - if self.has_webrtc_pub() { - match self.el.take() { - ::std::option::Option::Some(Element_oneof_el::webrtc_pub(v)) => v, - _ => panic!(), - } - } else { - WebRtcPublishEndpoint::new() - } - } -} - -impl ::protobuf::Message for Element { - fn is_initialized(&self) -> bool { - if let Some(Element_oneof_el::hub(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(Element_oneof_el::file_recorder(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(Element_oneof_el::member(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(Element_oneof_el::relay(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(Element_oneof_el::room(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(Element_oneof_el::webrtc_play(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(Element_oneof_el::webrtc_pub(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - 2 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(Element_oneof_el::hub(is.read_message()?)); - }, - 3 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(Element_oneof_el::file_recorder(is.read_message()?)); - }, - 4 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(Element_oneof_el::member(is.read_message()?)); - }, - 5 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(Element_oneof_el::relay(is.read_message()?)); - }, - 6 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(Element_oneof_el::room(is.read_message()?)); - }, - 7 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(Element_oneof_el::webrtc_play(is.read_message()?)); - }, - 8 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(Element_oneof_el::webrtc_pub(is.read_message()?)); - }, - _ => { - ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - if let ::std::option::Option::Some(ref v) = self.el { - match v { - &Element_oneof_el::hub(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &Element_oneof_el::file_recorder(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &Element_oneof_el::member(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &Element_oneof_el::relay(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &Element_oneof_el::room(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &Element_oneof_el::webrtc_play(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &Element_oneof_el::webrtc_pub(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - }; - } - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { - if let ::std::option::Option::Some(ref v) = self.el { - match v { - &Element_oneof_el::hub(ref v) => { - os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &Element_oneof_el::file_recorder(ref v) => { - os.write_tag(3, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &Element_oneof_el::member(ref v) => { - os.write_tag(4, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &Element_oneof_el::relay(ref v) => { - os.write_tag(5, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &Element_oneof_el::room(ref v) => { - os.write_tag(6, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &Element_oneof_el::webrtc_play(ref v) => { - os.write_tag(7, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &Element_oneof_el::webrtc_pub(ref v) => { - os.write_tag(8, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - }; - } - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any - } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any - } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - Self::descriptor_static() - } - - fn new() -> Element { - Element::new() - } - - fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Hub>( - "hub", - Element::has_hub, - Element::get_hub, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, FileRecorder>( - "file_recorder", - Element::has_file_recorder, - Element::get_file_recorder, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Member>( - "member", - Element::has_member, - Element::get_member, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Relay>( - "relay", - Element::has_relay, - Element::get_relay, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Room>( - "room", - Element::has_room, - Element::get_room, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPlayEndpoint>( - "webrtc_play", - Element::has_webrtc_play, - Element::get_webrtc_play, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPublishEndpoint>( - "webrtc_pub", - Element::has_webrtc_pub, - Element::get_webrtc_pub, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "Element", - fields, - file_descriptor_proto() - ) - }) - } - } - - fn default_instance() -> &'static Element { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const Element, - }; - unsafe { - instance.get(Element::new) - } - } -} - -impl ::protobuf::Clear for Element { - fn clear(&mut self) { - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for Element { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for Element { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) - } -} - -#[derive(PartialEq,Clone,Default)] -pub struct Room { - // message fields - pub pipeline: ::std::collections::HashMap<::std::string::String, Room_Element>, - // special fields - pub unknown_fields: ::protobuf::UnknownFields, - pub cached_size: ::protobuf::CachedSize, -} - -impl<'a> ::std::default::Default for &'a Room { - fn default() -> &'a Room { - ::default_instance() - } -} - -impl Room { - pub fn new() -> Room { - ::std::default::Default::default() - } - - // repeated .medea.Room.PipelineEntry pipeline = 1; - - - pub fn get_pipeline(&self) -> &::std::collections::HashMap<::std::string::String, Room_Element> { - &self.pipeline - } - pub fn clear_pipeline(&mut self) { - self.pipeline.clear(); - } - - // Param is passed by value, moved - pub fn set_pipeline(&mut self, v: ::std::collections::HashMap<::std::string::String, Room_Element>) { - self.pipeline = v; - } - - // Mutable pointer to the field. - pub fn mut_pipeline(&mut self) -> &mut ::std::collections::HashMap<::std::string::String, Room_Element> { - &mut self.pipeline - } - - // Take field - pub fn take_pipeline(&mut self) -> ::std::collections::HashMap<::std::string::String, Room_Element> { - ::std::mem::replace(&mut self.pipeline, ::std::collections::HashMap::new()) - } -} - -impl ::protobuf::Message for Room { - fn is_initialized(&self) -> bool { - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - 1 => { - ::protobuf::rt::read_map_into::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(wire_type, is, &mut self.pipeline)?; - }, - _ => { - ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - my_size += ::protobuf::rt::compute_map_size::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(1, &self.pipeline); - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { - ::protobuf::rt::write_map_with_cached_sizes::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(1, &self.pipeline, os)?; - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any - } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any - } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - Self::descriptor_static() - } - - fn new() -> Room { - Room::new() - } - - fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_map_accessor::<_, ::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>( - "pipeline", - |m: &Room| { &m.pipeline }, - |m: &mut Room| { &mut m.pipeline }, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "Room", - fields, - file_descriptor_proto() - ) - }) - } - } - - fn default_instance() -> &'static Room { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const Room, - }; - unsafe { - instance.get(Room::new) - } - } -} - -impl ::protobuf::Clear for Room { - fn clear(&mut self) { - self.pipeline.clear(); - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for Room { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for Room { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) - } -} - -#[derive(PartialEq,Clone,Default)] -pub struct Room_Element { - // message oneof groups - pub el: ::std::option::Option, - // special fields - pub unknown_fields: ::protobuf::UnknownFields, - pub cached_size: ::protobuf::CachedSize, -} - -impl<'a> ::std::default::Default for &'a Room_Element { - fn default() -> &'a Room_Element { - ::default_instance() - } -} - -#[derive(Clone,PartialEq,Debug)] -pub enum Room_Element_oneof_el { - hub(Hub), - file_recorder(FileRecorder), - member(Member), - relay(Relay), - webrtc_play(WebRtcPlayEndpoint), - webrtc_pub(WebRtcPublishEndpoint), -} - -impl Room_Element { - pub fn new() -> Room_Element { - ::std::default::Default::default() - } - - // optional .medea.Hub hub = 1; - - - pub fn get_hub(&self) -> &Hub { - match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::hub(ref v)) => v, - _ => Hub::default_instance(), - } - } - pub fn clear_hub(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_hub(&self) -> bool { - match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::hub(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_hub(&mut self, v: Hub) { - self.el = ::std::option::Option::Some(Room_Element_oneof_el::hub(v)) - } - - // Mutable pointer to the field. - pub fn mut_hub(&mut self) -> &mut Hub { - if let ::std::option::Option::Some(Room_Element_oneof_el::hub(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(Room_Element_oneof_el::hub(Hub::new())); - } - match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::hub(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_hub(&mut self) -> Hub { - if self.has_hub() { - match self.el.take() { - ::std::option::Option::Some(Room_Element_oneof_el::hub(v)) => v, - _ => panic!(), - } - } else { - Hub::new() - } - } - - // optional .medea.FileRecorder file_recorder = 2; - - - pub fn get_file_recorder(&self) -> &FileRecorder { - match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::file_recorder(ref v)) => v, - _ => FileRecorder::default_instance(), - } - } - pub fn clear_file_recorder(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_file_recorder(&self) -> bool { - match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::file_recorder(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_file_recorder(&mut self, v: FileRecorder) { - self.el = ::std::option::Option::Some(Room_Element_oneof_el::file_recorder(v)) - } - - // Mutable pointer to the field. - pub fn mut_file_recorder(&mut self) -> &mut FileRecorder { - if let ::std::option::Option::Some(Room_Element_oneof_el::file_recorder(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(Room_Element_oneof_el::file_recorder(FileRecorder::new())); - } - match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::file_recorder(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_file_recorder(&mut self) -> FileRecorder { - if self.has_file_recorder() { - match self.el.take() { - ::std::option::Option::Some(Room_Element_oneof_el::file_recorder(v)) => v, - _ => panic!(), - } - } else { - FileRecorder::new() - } - } - - // optional .medea.Member member = 3; - - - pub fn get_member(&self) -> &Member { - match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::member(ref v)) => v, - _ => Member::default_instance(), - } - } - pub fn clear_member(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_member(&self) -> bool { - match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::member(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_member(&mut self, v: Member) { - self.el = ::std::option::Option::Some(Room_Element_oneof_el::member(v)) - } - - // Mutable pointer to the field. - pub fn mut_member(&mut self) -> &mut Member { - if let ::std::option::Option::Some(Room_Element_oneof_el::member(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(Room_Element_oneof_el::member(Member::new())); - } - match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::member(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_member(&mut self) -> Member { - if self.has_member() { - match self.el.take() { - ::std::option::Option::Some(Room_Element_oneof_el::member(v)) => v, - _ => panic!(), - } - } else { - Member::new() - } - } - - // optional .medea.Relay relay = 4; - - - pub fn get_relay(&self) -> &Relay { - match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::relay(ref v)) => v, - _ => Relay::default_instance(), - } - } - pub fn clear_relay(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_relay(&self) -> bool { - match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::relay(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_relay(&mut self, v: Relay) { - self.el = ::std::option::Option::Some(Room_Element_oneof_el::relay(v)) - } - - // Mutable pointer to the field. - pub fn mut_relay(&mut self) -> &mut Relay { - if let ::std::option::Option::Some(Room_Element_oneof_el::relay(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(Room_Element_oneof_el::relay(Relay::new())); - } - match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::relay(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_relay(&mut self) -> Relay { - if self.has_relay() { - match self.el.take() { - ::std::option::Option::Some(Room_Element_oneof_el::relay(v)) => v, - _ => panic!(), - } - } else { - Relay::new() - } - } - - // optional .medea.WebRtcPlayEndpoint webrtc_play = 5; - - - pub fn get_webrtc_play(&self) -> &WebRtcPlayEndpoint { - match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(ref v)) => v, - _ => WebRtcPlayEndpoint::default_instance(), - } - } - pub fn clear_webrtc_play(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_webrtc_play(&self) -> bool { - match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_webrtc_play(&mut self, v: WebRtcPlayEndpoint) { - self.el = ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(v)) - } - - // Mutable pointer to the field. - pub fn mut_webrtc_play(&mut self) -> &mut WebRtcPlayEndpoint { - if let ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(WebRtcPlayEndpoint::new())); - } - match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_webrtc_play(&mut self) -> WebRtcPlayEndpoint { - if self.has_webrtc_play() { - match self.el.take() { - ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(v)) => v, - _ => panic!(), - } - } else { - WebRtcPlayEndpoint::new() - } - } - - // optional .medea.WebRtcPublishEndpoint webrtc_pub = 6; - - - pub fn get_webrtc_pub(&self) -> &WebRtcPublishEndpoint { - match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(ref v)) => v, - _ => WebRtcPublishEndpoint::default_instance(), - } - } - pub fn clear_webrtc_pub(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_webrtc_pub(&self) -> bool { - match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_webrtc_pub(&mut self, v: WebRtcPublishEndpoint) { - self.el = ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(v)) - } - - // Mutable pointer to the field. - pub fn mut_webrtc_pub(&mut self) -> &mut WebRtcPublishEndpoint { - if let ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(WebRtcPublishEndpoint::new())); - } - match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_webrtc_pub(&mut self) -> WebRtcPublishEndpoint { - if self.has_webrtc_pub() { - match self.el.take() { - ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(v)) => v, - _ => panic!(), - } - } else { - WebRtcPublishEndpoint::new() - } - } -} - -impl ::protobuf::Message for Room_Element { - fn is_initialized(&self) -> bool { - if let Some(Room_Element_oneof_el::hub(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(Room_Element_oneof_el::file_recorder(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(Room_Element_oneof_el::member(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(Room_Element_oneof_el::relay(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(Room_Element_oneof_el::webrtc_play(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(Room_Element_oneof_el::webrtc_pub(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - 1 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(Room_Element_oneof_el::hub(is.read_message()?)); - }, - 2 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(Room_Element_oneof_el::file_recorder(is.read_message()?)); - }, - 3 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(Room_Element_oneof_el::member(is.read_message()?)); - }, - 4 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(Room_Element_oneof_el::relay(is.read_message()?)); - }, - 5 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(is.read_message()?)); - }, - 6 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(is.read_message()?)); - }, - _ => { - ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - if let ::std::option::Option::Some(ref v) = self.el { - match v { - &Room_Element_oneof_el::hub(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &Room_Element_oneof_el::file_recorder(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &Room_Element_oneof_el::member(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &Room_Element_oneof_el::relay(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &Room_Element_oneof_el::webrtc_play(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &Room_Element_oneof_el::webrtc_pub(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - }; - } - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { - if let ::std::option::Option::Some(ref v) = self.el { - match v { - &Room_Element_oneof_el::hub(ref v) => { - os.write_tag(1, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &Room_Element_oneof_el::file_recorder(ref v) => { - os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &Room_Element_oneof_el::member(ref v) => { - os.write_tag(3, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &Room_Element_oneof_el::relay(ref v) => { - os.write_tag(4, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &Room_Element_oneof_el::webrtc_play(ref v) => { - os.write_tag(5, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &Room_Element_oneof_el::webrtc_pub(ref v) => { - os.write_tag(6, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - }; - } - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any - } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any - } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - Self::descriptor_static() - } - - fn new() -> Room_Element { - Room_Element::new() - } - - fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Hub>( - "hub", - Room_Element::has_hub, - Room_Element::get_hub, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, FileRecorder>( - "file_recorder", - Room_Element::has_file_recorder, - Room_Element::get_file_recorder, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Member>( - "member", - Room_Element::has_member, - Room_Element::get_member, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Relay>( - "relay", - Room_Element::has_relay, - Room_Element::get_relay, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPlayEndpoint>( - "webrtc_play", - Room_Element::has_webrtc_play, - Room_Element::get_webrtc_play, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPublishEndpoint>( - "webrtc_pub", - Room_Element::has_webrtc_pub, - Room_Element::get_webrtc_pub, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "Room_Element", - fields, - file_descriptor_proto() - ) - }) - } - } - - fn default_instance() -> &'static Room_Element { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const Room_Element, - }; - unsafe { - instance.get(Room_Element::new) - } - } -} - -impl ::protobuf::Clear for Room_Element { - fn clear(&mut self) { - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for Room_Element { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for Room_Element { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) - } -} - -#[derive(PartialEq,Clone,Default)] -pub struct Member { - // message fields - on_join: ::protobuf::SingularField<::std::string::String>, - on_leave: ::protobuf::SingularField<::std::string::String>, - credentials: ::protobuf::SingularField<::std::string::String>, - pub pipeline: ::std::collections::HashMap<::std::string::String, Member_Element>, - // special fields - pub unknown_fields: ::protobuf::UnknownFields, - pub cached_size: ::protobuf::CachedSize, -} - -impl<'a> ::std::default::Default for &'a Member { - fn default() -> &'a Member { - ::default_instance() - } -} - -impl Member { - pub fn new() -> Member { - ::std::default::Default::default() - } - - // optional string on_join = 1; - - - pub fn get_on_join(&self) -> &str { - match self.on_join.as_ref() { - Some(v) => &v, - None => "", - } - } - pub fn clear_on_join(&mut self) { - self.on_join.clear(); - } - - pub fn has_on_join(&self) -> bool { - self.on_join.is_some() - } - - // Param is passed by value, moved - pub fn set_on_join(&mut self, v: ::std::string::String) { - self.on_join = ::protobuf::SingularField::some(v); - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_on_join(&mut self) -> &mut ::std::string::String { - if self.on_join.is_none() { - self.on_join.set_default(); - } - self.on_join.as_mut().unwrap() - } - - // Take field - pub fn take_on_join(&mut self) -> ::std::string::String { - self.on_join.take().unwrap_or_else(|| ::std::string::String::new()) - } - - // optional string on_leave = 2; - - - pub fn get_on_leave(&self) -> &str { - match self.on_leave.as_ref() { - Some(v) => &v, - None => "", - } - } - pub fn clear_on_leave(&mut self) { - self.on_leave.clear(); - } - - pub fn has_on_leave(&self) -> bool { - self.on_leave.is_some() - } - - // Param is passed by value, moved - pub fn set_on_leave(&mut self, v: ::std::string::String) { - self.on_leave = ::protobuf::SingularField::some(v); - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_on_leave(&mut self) -> &mut ::std::string::String { - if self.on_leave.is_none() { - self.on_leave.set_default(); - } - self.on_leave.as_mut().unwrap() - } - - // Take field - pub fn take_on_leave(&mut self) -> ::std::string::String { - self.on_leave.take().unwrap_or_else(|| ::std::string::String::new()) - } - - // required string credentials = 3; - - - pub fn get_credentials(&self) -> &str { - match self.credentials.as_ref() { - Some(v) => &v, - None => "", - } - } - pub fn clear_credentials(&mut self) { - self.credentials.clear(); - } - - pub fn has_credentials(&self) -> bool { - self.credentials.is_some() - } - - // Param is passed by value, moved - pub fn set_credentials(&mut self, v: ::std::string::String) { - self.credentials = ::protobuf::SingularField::some(v); - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_credentials(&mut self) -> &mut ::std::string::String { - if self.credentials.is_none() { - self.credentials.set_default(); - } - self.credentials.as_mut().unwrap() - } - - // Take field - pub fn take_credentials(&mut self) -> ::std::string::String { - self.credentials.take().unwrap_or_else(|| ::std::string::String::new()) - } - - // repeated .medea.Member.PipelineEntry pipeline = 4; - - - pub fn get_pipeline(&self) -> &::std::collections::HashMap<::std::string::String, Member_Element> { - &self.pipeline - } - pub fn clear_pipeline(&mut self) { - self.pipeline.clear(); - } - - // Param is passed by value, moved - pub fn set_pipeline(&mut self, v: ::std::collections::HashMap<::std::string::String, Member_Element>) { - self.pipeline = v; - } - - // Mutable pointer to the field. - pub fn mut_pipeline(&mut self) -> &mut ::std::collections::HashMap<::std::string::String, Member_Element> { - &mut self.pipeline - } - - // Take field - pub fn take_pipeline(&mut self) -> ::std::collections::HashMap<::std::string::String, Member_Element> { - ::std::mem::replace(&mut self.pipeline, ::std::collections::HashMap::new()) - } -} - -impl ::protobuf::Message for Member { - fn is_initialized(&self) -> bool { - if self.credentials.is_none() { - return false; - } - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - 1 => { - ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.on_join)?; - }, - 2 => { - ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.on_leave)?; - }, - 3 => { - ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.credentials)?; - }, - 4 => { - ::protobuf::rt::read_map_into::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(wire_type, is, &mut self.pipeline)?; - }, - _ => { - ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - if let Some(ref v) = self.on_join.as_ref() { - my_size += ::protobuf::rt::string_size(1, &v); - } - if let Some(ref v) = self.on_leave.as_ref() { - my_size += ::protobuf::rt::string_size(2, &v); - } - if let Some(ref v) = self.credentials.as_ref() { - my_size += ::protobuf::rt::string_size(3, &v); - } - my_size += ::protobuf::rt::compute_map_size::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(4, &self.pipeline); - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { - if let Some(ref v) = self.on_join.as_ref() { - os.write_string(1, &v)?; - } - if let Some(ref v) = self.on_leave.as_ref() { - os.write_string(2, &v)?; - } - if let Some(ref v) = self.credentials.as_ref() { - os.write_string(3, &v)?; - } - ::protobuf::rt::write_map_with_cached_sizes::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(4, &self.pipeline, os)?; - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any - } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any - } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - Self::descriptor_static() - } - - fn new() -> Member { - Member::new() - } - - fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "on_join", - |m: &Member| { &m.on_join }, - |m: &mut Member| { &mut m.on_join }, - )); - fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "on_leave", - |m: &Member| { &m.on_leave }, - |m: &mut Member| { &mut m.on_leave }, - )); - fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "credentials", - |m: &Member| { &m.credentials }, - |m: &mut Member| { &mut m.credentials }, - )); - fields.push(::protobuf::reflect::accessor::make_map_accessor::<_, ::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>( - "pipeline", - |m: &Member| { &m.pipeline }, - |m: &mut Member| { &mut m.pipeline }, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "Member", - fields, - file_descriptor_proto() - ) - }) - } - } - - fn default_instance() -> &'static Member { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const Member, - }; - unsafe { - instance.get(Member::new) - } - } -} - -impl ::protobuf::Clear for Member { - fn clear(&mut self) { - self.on_join.clear(); - self.on_leave.clear(); - self.credentials.clear(); - self.pipeline.clear(); - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for Member { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for Member { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) - } -} - -#[derive(PartialEq,Clone,Default)] -pub struct Member_Element { - // message oneof groups - pub el: ::std::option::Option, - // special fields - pub unknown_fields: ::protobuf::UnknownFields, - pub cached_size: ::protobuf::CachedSize, -} - -impl<'a> ::std::default::Default for &'a Member_Element { - fn default() -> &'a Member_Element { - ::default_instance() - } -} - -#[derive(Clone,PartialEq,Debug)] -pub enum Member_Element_oneof_el { - hub(Hub), - file_recorder(FileRecorder), - relay(Relay), - webrtc_play(WebRtcPlayEndpoint), - webrtc_pub(WebRtcPublishEndpoint), -} - -impl Member_Element { - pub fn new() -> Member_Element { - ::std::default::Default::default() - } - - // optional .medea.Hub hub = 1; - - - pub fn get_hub(&self) -> &Hub { - match self.el { - ::std::option::Option::Some(Member_Element_oneof_el::hub(ref v)) => v, - _ => Hub::default_instance(), - } - } - pub fn clear_hub(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_hub(&self) -> bool { - match self.el { - ::std::option::Option::Some(Member_Element_oneof_el::hub(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_hub(&mut self, v: Hub) { - self.el = ::std::option::Option::Some(Member_Element_oneof_el::hub(v)) - } - - // Mutable pointer to the field. - pub fn mut_hub(&mut self) -> &mut Hub { - if let ::std::option::Option::Some(Member_Element_oneof_el::hub(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(Member_Element_oneof_el::hub(Hub::new())); - } - match self.el { - ::std::option::Option::Some(Member_Element_oneof_el::hub(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_hub(&mut self) -> Hub { - if self.has_hub() { - match self.el.take() { - ::std::option::Option::Some(Member_Element_oneof_el::hub(v)) => v, - _ => panic!(), - } - } else { - Hub::new() - } - } - - // optional .medea.FileRecorder file_recorder = 2; - - - pub fn get_file_recorder(&self) -> &FileRecorder { - match self.el { - ::std::option::Option::Some(Member_Element_oneof_el::file_recorder(ref v)) => v, - _ => FileRecorder::default_instance(), - } - } - pub fn clear_file_recorder(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_file_recorder(&self) -> bool { - match self.el { - ::std::option::Option::Some(Member_Element_oneof_el::file_recorder(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_file_recorder(&mut self, v: FileRecorder) { - self.el = ::std::option::Option::Some(Member_Element_oneof_el::file_recorder(v)) - } - - // Mutable pointer to the field. - pub fn mut_file_recorder(&mut self) -> &mut FileRecorder { - if let ::std::option::Option::Some(Member_Element_oneof_el::file_recorder(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(Member_Element_oneof_el::file_recorder(FileRecorder::new())); - } - match self.el { - ::std::option::Option::Some(Member_Element_oneof_el::file_recorder(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_file_recorder(&mut self) -> FileRecorder { - if self.has_file_recorder() { - match self.el.take() { - ::std::option::Option::Some(Member_Element_oneof_el::file_recorder(v)) => v, - _ => panic!(), - } - } else { - FileRecorder::new() - } - } - - // optional .medea.Relay relay = 3; - - - pub fn get_relay(&self) -> &Relay { - match self.el { - ::std::option::Option::Some(Member_Element_oneof_el::relay(ref v)) => v, - _ => Relay::default_instance(), - } - } - pub fn clear_relay(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_relay(&self) -> bool { - match self.el { - ::std::option::Option::Some(Member_Element_oneof_el::relay(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_relay(&mut self, v: Relay) { - self.el = ::std::option::Option::Some(Member_Element_oneof_el::relay(v)) - } - - // Mutable pointer to the field. - pub fn mut_relay(&mut self) -> &mut Relay { - if let ::std::option::Option::Some(Member_Element_oneof_el::relay(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(Member_Element_oneof_el::relay(Relay::new())); - } - match self.el { - ::std::option::Option::Some(Member_Element_oneof_el::relay(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_relay(&mut self) -> Relay { - if self.has_relay() { - match self.el.take() { - ::std::option::Option::Some(Member_Element_oneof_el::relay(v)) => v, - _ => panic!(), - } - } else { - Relay::new() - } - } - - // optional .medea.WebRtcPlayEndpoint webrtc_play = 4; - - - pub fn get_webrtc_play(&self) -> &WebRtcPlayEndpoint { - match self.el { - ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(ref v)) => v, - _ => WebRtcPlayEndpoint::default_instance(), - } - } - pub fn clear_webrtc_play(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_webrtc_play(&self) -> bool { - match self.el { - ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_webrtc_play(&mut self, v: WebRtcPlayEndpoint) { - self.el = ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(v)) - } - - // Mutable pointer to the field. - pub fn mut_webrtc_play(&mut self) -> &mut WebRtcPlayEndpoint { - if let ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(WebRtcPlayEndpoint::new())); - } - match self.el { - ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_webrtc_play(&mut self) -> WebRtcPlayEndpoint { - if self.has_webrtc_play() { - match self.el.take() { - ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(v)) => v, - _ => panic!(), - } - } else { - WebRtcPlayEndpoint::new() - } - } - - // optional .medea.WebRtcPublishEndpoint webrtc_pub = 5; - - - pub fn get_webrtc_pub(&self) -> &WebRtcPublishEndpoint { - match self.el { - ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(ref v)) => v, - _ => WebRtcPublishEndpoint::default_instance(), - } - } - pub fn clear_webrtc_pub(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_webrtc_pub(&self) -> bool { - match self.el { - ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_webrtc_pub(&mut self, v: WebRtcPublishEndpoint) { - self.el = ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(v)) - } - - // Mutable pointer to the field. - pub fn mut_webrtc_pub(&mut self) -> &mut WebRtcPublishEndpoint { - if let ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(WebRtcPublishEndpoint::new())); - } - match self.el { - ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_webrtc_pub(&mut self) -> WebRtcPublishEndpoint { - if self.has_webrtc_pub() { - match self.el.take() { - ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(v)) => v, - _ => panic!(), - } - } else { - WebRtcPublishEndpoint::new() - } - } -} - -impl ::protobuf::Message for Member_Element { - fn is_initialized(&self) -> bool { - if let Some(Member_Element_oneof_el::hub(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(Member_Element_oneof_el::file_recorder(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(Member_Element_oneof_el::relay(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(Member_Element_oneof_el::webrtc_play(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(Member_Element_oneof_el::webrtc_pub(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - 1 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(Member_Element_oneof_el::hub(is.read_message()?)); - }, - 2 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(Member_Element_oneof_el::file_recorder(is.read_message()?)); - }, - 3 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(Member_Element_oneof_el::relay(is.read_message()?)); - }, - 4 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(is.read_message()?)); - }, - 5 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(is.read_message()?)); - }, - _ => { - ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - if let ::std::option::Option::Some(ref v) = self.el { - match v { - &Member_Element_oneof_el::hub(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &Member_Element_oneof_el::file_recorder(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &Member_Element_oneof_el::relay(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &Member_Element_oneof_el::webrtc_play(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &Member_Element_oneof_el::webrtc_pub(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - }; - } - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { - if let ::std::option::Option::Some(ref v) = self.el { - match v { - &Member_Element_oneof_el::hub(ref v) => { - os.write_tag(1, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &Member_Element_oneof_el::file_recorder(ref v) => { - os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &Member_Element_oneof_el::relay(ref v) => { - os.write_tag(3, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &Member_Element_oneof_el::webrtc_play(ref v) => { - os.write_tag(4, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &Member_Element_oneof_el::webrtc_pub(ref v) => { - os.write_tag(5, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - }; - } - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any - } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any - } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - Self::descriptor_static() - } - - fn new() -> Member_Element { - Member_Element::new() - } - - fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Hub>( - "hub", - Member_Element::has_hub, - Member_Element::get_hub, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, FileRecorder>( - "file_recorder", - Member_Element::has_file_recorder, - Member_Element::get_file_recorder, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Relay>( - "relay", - Member_Element::has_relay, - Member_Element::get_relay, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPlayEndpoint>( - "webrtc_play", - Member_Element::has_webrtc_play, - Member_Element::get_webrtc_play, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPublishEndpoint>( - "webrtc_pub", - Member_Element::has_webrtc_pub, - Member_Element::get_webrtc_pub, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "Member_Element", - fields, - file_descriptor_proto() - ) - }) - } - } - - fn default_instance() -> &'static Member_Element { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const Member_Element, - }; - unsafe { - instance.get(Member_Element::new) - } - } -} - -impl ::protobuf::Clear for Member_Element { - fn clear(&mut self) { - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for Member_Element { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for Member_Element { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) - } -} - -#[derive(PartialEq,Clone,Default)] -pub struct WebRtcPublishEndpoint { - // message fields - p2p: ::std::option::Option, - dst: ::protobuf::SingularField<::std::string::String>, - on_start: ::protobuf::SingularField<::std::string::String>, - on_stop: ::protobuf::SingularField<::std::string::String>, - // special fields - pub unknown_fields: ::protobuf::UnknownFields, - pub cached_size: ::protobuf::CachedSize, -} - -impl<'a> ::std::default::Default for &'a WebRtcPublishEndpoint { - fn default() -> &'a WebRtcPublishEndpoint { - ::default_instance() - } -} - -impl WebRtcPublishEndpoint { - pub fn new() -> WebRtcPublishEndpoint { - ::std::default::Default::default() - } - - // optional .medea.WebRtcPublishEndpoint.P2P p2p = 1; - - - pub fn get_p2p(&self) -> WebRtcPublishEndpoint_P2P { - self.p2p.unwrap_or(WebRtcPublishEndpoint_P2P::NEVER) - } - pub fn clear_p2p(&mut self) { - self.p2p = ::std::option::Option::None; - } - - pub fn has_p2p(&self) -> bool { - self.p2p.is_some() - } - - // Param is passed by value, moved - pub fn set_p2p(&mut self, v: WebRtcPublishEndpoint_P2P) { - self.p2p = ::std::option::Option::Some(v); - } - - // optional string dst = 2; - - - pub fn get_dst(&self) -> &str { - match self.dst.as_ref() { - Some(v) => &v, - None => "", - } - } - pub fn clear_dst(&mut self) { - self.dst.clear(); - } - - pub fn has_dst(&self) -> bool { - self.dst.is_some() - } - - // Param is passed by value, moved - pub fn set_dst(&mut self, v: ::std::string::String) { - self.dst = ::protobuf::SingularField::some(v); - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_dst(&mut self) -> &mut ::std::string::String { - if self.dst.is_none() { - self.dst.set_default(); - } - self.dst.as_mut().unwrap() - } - - // Take field - pub fn take_dst(&mut self) -> ::std::string::String { - self.dst.take().unwrap_or_else(|| ::std::string::String::new()) - } - - // optional string on_start = 3; - - - pub fn get_on_start(&self) -> &str { - match self.on_start.as_ref() { - Some(v) => &v, - None => "", - } - } - pub fn clear_on_start(&mut self) { - self.on_start.clear(); - } - - pub fn has_on_start(&self) -> bool { - self.on_start.is_some() - } - - // Param is passed by value, moved - pub fn set_on_start(&mut self, v: ::std::string::String) { - self.on_start = ::protobuf::SingularField::some(v); - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_on_start(&mut self) -> &mut ::std::string::String { - if self.on_start.is_none() { - self.on_start.set_default(); - } - self.on_start.as_mut().unwrap() - } - - // Take field - pub fn take_on_start(&mut self) -> ::std::string::String { - self.on_start.take().unwrap_or_else(|| ::std::string::String::new()) - } - - // optional string on_stop = 4; - - - pub fn get_on_stop(&self) -> &str { - match self.on_stop.as_ref() { - Some(v) => &v, - None => "", - } - } - pub fn clear_on_stop(&mut self) { - self.on_stop.clear(); - } - - pub fn has_on_stop(&self) -> bool { - self.on_stop.is_some() - } - - // Param is passed by value, moved - pub fn set_on_stop(&mut self, v: ::std::string::String) { - self.on_stop = ::protobuf::SingularField::some(v); - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_on_stop(&mut self) -> &mut ::std::string::String { - if self.on_stop.is_none() { - self.on_stop.set_default(); - } - self.on_stop.as_mut().unwrap() - } - - // Take field - pub fn take_on_stop(&mut self) -> ::std::string::String { - self.on_stop.take().unwrap_or_else(|| ::std::string::String::new()) - } -} - -impl ::protobuf::Message for WebRtcPublishEndpoint { - fn is_initialized(&self) -> bool { - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - 1 => { - ::protobuf::rt::read_proto2_enum_with_unknown_fields_into(wire_type, is, &mut self.p2p, 1, &mut self.unknown_fields)? - }, - 2 => { - ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.dst)?; - }, - 3 => { - ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.on_start)?; - }, - 4 => { - ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.on_stop)?; - }, - _ => { - ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - if let Some(v) = self.p2p { - my_size += ::protobuf::rt::enum_size(1, v); - } - if let Some(ref v) = self.dst.as_ref() { - my_size += ::protobuf::rt::string_size(2, &v); - } - if let Some(ref v) = self.on_start.as_ref() { - my_size += ::protobuf::rt::string_size(3, &v); - } - if let Some(ref v) = self.on_stop.as_ref() { - my_size += ::protobuf::rt::string_size(4, &v); - } - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { - if let Some(v) = self.p2p { - os.write_enum(1, v.value())?; - } - if let Some(ref v) = self.dst.as_ref() { - os.write_string(2, &v)?; - } - if let Some(ref v) = self.on_start.as_ref() { - os.write_string(3, &v)?; - } - if let Some(ref v) = self.on_stop.as_ref() { - os.write_string(4, &v)?; - } - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any - } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any - } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - Self::descriptor_static() - } - - fn new() -> WebRtcPublishEndpoint { - WebRtcPublishEndpoint::new() - } - - fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeEnum>( - "p2p", - |m: &WebRtcPublishEndpoint| { &m.p2p }, - |m: &mut WebRtcPublishEndpoint| { &mut m.p2p }, - )); - fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "dst", - |m: &WebRtcPublishEndpoint| { &m.dst }, - |m: &mut WebRtcPublishEndpoint| { &mut m.dst }, - )); - fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "on_start", - |m: &WebRtcPublishEndpoint| { &m.on_start }, - |m: &mut WebRtcPublishEndpoint| { &mut m.on_start }, - )); - fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "on_stop", - |m: &WebRtcPublishEndpoint| { &m.on_stop }, - |m: &mut WebRtcPublishEndpoint| { &mut m.on_stop }, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "WebRtcPublishEndpoint", - fields, - file_descriptor_proto() - ) - }) - } - } - - fn default_instance() -> &'static WebRtcPublishEndpoint { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const WebRtcPublishEndpoint, - }; - unsafe { - instance.get(WebRtcPublishEndpoint::new) - } - } -} - -impl ::protobuf::Clear for WebRtcPublishEndpoint { - fn clear(&mut self) { - self.p2p = ::std::option::Option::None; - self.dst.clear(); - self.on_start.clear(); - self.on_stop.clear(); - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for WebRtcPublishEndpoint { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for WebRtcPublishEndpoint { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) - } -} - -#[derive(Clone,PartialEq,Eq,Debug,Hash)] -pub enum WebRtcPublishEndpoint_P2P { - NEVER = 0, - IF_POSSIBLE = 1, - ALWAYS = 2, -} - -impl ::protobuf::ProtobufEnum for WebRtcPublishEndpoint_P2P { - fn value(&self) -> i32 { - *self as i32 - } - - fn from_i32(value: i32) -> ::std::option::Option { - match value { - 0 => ::std::option::Option::Some(WebRtcPublishEndpoint_P2P::NEVER), - 1 => ::std::option::Option::Some(WebRtcPublishEndpoint_P2P::IF_POSSIBLE), - 2 => ::std::option::Option::Some(WebRtcPublishEndpoint_P2P::ALWAYS), - _ => ::std::option::Option::None - } - } - - fn values() -> &'static [Self] { - static values: &'static [WebRtcPublishEndpoint_P2P] = &[ - WebRtcPublishEndpoint_P2P::NEVER, - WebRtcPublishEndpoint_P2P::IF_POSSIBLE, - WebRtcPublishEndpoint_P2P::ALWAYS, - ]; - values - } - - fn enum_descriptor_static() -> &'static ::protobuf::reflect::EnumDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::EnumDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::EnumDescriptor, - }; - unsafe { - descriptor.get(|| { - ::protobuf::reflect::EnumDescriptor::new("WebRtcPublishEndpoint_P2P", file_descriptor_proto()) - }) - } - } -} - -impl ::std::marker::Copy for WebRtcPublishEndpoint_P2P { -} - -impl ::std::default::Default for WebRtcPublishEndpoint_P2P { - fn default() -> Self { - WebRtcPublishEndpoint_P2P::NEVER - } -} - -impl ::protobuf::reflect::ProtobufValue for WebRtcPublishEndpoint_P2P { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Enum(self.descriptor()) - } -} - -#[derive(PartialEq,Clone,Default)] -pub struct WebRtcPlayEndpoint { - // message fields - src: ::protobuf::SingularField<::std::string::String>, - on_start: ::protobuf::SingularField<::std::string::String>, - on_stop: ::protobuf::SingularField<::std::string::String>, - // special fields - pub unknown_fields: ::protobuf::UnknownFields, - pub cached_size: ::protobuf::CachedSize, -} - -impl<'a> ::std::default::Default for &'a WebRtcPlayEndpoint { - fn default() -> &'a WebRtcPlayEndpoint { - ::default_instance() - } -} - -impl WebRtcPlayEndpoint { - pub fn new() -> WebRtcPlayEndpoint { - ::std::default::Default::default() - } - - // required string src = 1; - - - pub fn get_src(&self) -> &str { - match self.src.as_ref() { - Some(v) => &v, - None => "", - } - } - pub fn clear_src(&mut self) { - self.src.clear(); - } - - pub fn has_src(&self) -> bool { - self.src.is_some() - } - - // Param is passed by value, moved - pub fn set_src(&mut self, v: ::std::string::String) { - self.src = ::protobuf::SingularField::some(v); - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_src(&mut self) -> &mut ::std::string::String { - if self.src.is_none() { - self.src.set_default(); - } - self.src.as_mut().unwrap() - } - - // Take field - pub fn take_src(&mut self) -> ::std::string::String { - self.src.take().unwrap_or_else(|| ::std::string::String::new()) - } - - // optional string on_start = 2; - - - pub fn get_on_start(&self) -> &str { - match self.on_start.as_ref() { - Some(v) => &v, - None => "", - } - } - pub fn clear_on_start(&mut self) { - self.on_start.clear(); - } - - pub fn has_on_start(&self) -> bool { - self.on_start.is_some() - } - - // Param is passed by value, moved - pub fn set_on_start(&mut self, v: ::std::string::String) { - self.on_start = ::protobuf::SingularField::some(v); - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_on_start(&mut self) -> &mut ::std::string::String { - if self.on_start.is_none() { - self.on_start.set_default(); - } - self.on_start.as_mut().unwrap() - } - - // Take field - pub fn take_on_start(&mut self) -> ::std::string::String { - self.on_start.take().unwrap_or_else(|| ::std::string::String::new()) - } - - // optional string on_stop = 3; - - - pub fn get_on_stop(&self) -> &str { - match self.on_stop.as_ref() { - Some(v) => &v, - None => "", - } - } - pub fn clear_on_stop(&mut self) { - self.on_stop.clear(); - } - - pub fn has_on_stop(&self) -> bool { - self.on_stop.is_some() - } - - // Param is passed by value, moved - pub fn set_on_stop(&mut self, v: ::std::string::String) { - self.on_stop = ::protobuf::SingularField::some(v); - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_on_stop(&mut self) -> &mut ::std::string::String { - if self.on_stop.is_none() { - self.on_stop.set_default(); - } - self.on_stop.as_mut().unwrap() - } - - // Take field - pub fn take_on_stop(&mut self) -> ::std::string::String { - self.on_stop.take().unwrap_or_else(|| ::std::string::String::new()) - } -} - -impl ::protobuf::Message for WebRtcPlayEndpoint { - fn is_initialized(&self) -> bool { - if self.src.is_none() { - return false; - } - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - 1 => { - ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.src)?; - }, - 2 => { - ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.on_start)?; - }, - 3 => { - ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.on_stop)?; - }, - _ => { - ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - if let Some(ref v) = self.src.as_ref() { - my_size += ::protobuf::rt::string_size(1, &v); - } - if let Some(ref v) = self.on_start.as_ref() { - my_size += ::protobuf::rt::string_size(2, &v); - } - if let Some(ref v) = self.on_stop.as_ref() { - my_size += ::protobuf::rt::string_size(3, &v); - } - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { - if let Some(ref v) = self.src.as_ref() { - os.write_string(1, &v)?; - } - if let Some(ref v) = self.on_start.as_ref() { - os.write_string(2, &v)?; - } - if let Some(ref v) = self.on_stop.as_ref() { - os.write_string(3, &v)?; - } - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any - } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any - } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - Self::descriptor_static() - } - - fn new() -> WebRtcPlayEndpoint { - WebRtcPlayEndpoint::new() - } - - fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "src", - |m: &WebRtcPlayEndpoint| { &m.src }, - |m: &mut WebRtcPlayEndpoint| { &mut m.src }, - )); - fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "on_start", - |m: &WebRtcPlayEndpoint| { &m.on_start }, - |m: &mut WebRtcPlayEndpoint| { &mut m.on_start }, - )); - fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "on_stop", - |m: &WebRtcPlayEndpoint| { &m.on_stop }, - |m: &mut WebRtcPlayEndpoint| { &mut m.on_stop }, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "WebRtcPlayEndpoint", - fields, - file_descriptor_proto() - ) - }) - } - } - - fn default_instance() -> &'static WebRtcPlayEndpoint { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const WebRtcPlayEndpoint, - }; - unsafe { - instance.get(WebRtcPlayEndpoint::new) - } - } -} - -impl ::protobuf::Clear for WebRtcPlayEndpoint { - fn clear(&mut self) { - self.src.clear(); - self.on_start.clear(); - self.on_stop.clear(); - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for WebRtcPlayEndpoint { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for WebRtcPlayEndpoint { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) - } -} - -#[derive(PartialEq,Clone,Default)] -pub struct Hub { - // special fields - pub unknown_fields: ::protobuf::UnknownFields, - pub cached_size: ::protobuf::CachedSize, -} - -impl<'a> ::std::default::Default for &'a Hub { - fn default() -> &'a Hub { - ::default_instance() - } -} - -impl Hub { - pub fn new() -> Hub { - ::std::default::Default::default() - } -} - -impl ::protobuf::Message for Hub { - fn is_initialized(&self) -> bool { - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - _ => { - ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any - } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any - } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - Self::descriptor_static() - } - - fn new() -> Hub { - Hub::new() - } - - fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let fields = ::std::vec::Vec::new(); - ::protobuf::reflect::MessageDescriptor::new::( - "Hub", - fields, - file_descriptor_proto() - ) - }) - } - } - - fn default_instance() -> &'static Hub { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const Hub, - }; - unsafe { - instance.get(Hub::new) - } - } -} - -impl ::protobuf::Clear for Hub { - fn clear(&mut self) { - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for Hub { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for Hub { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) - } -} - -#[derive(PartialEq,Clone,Default)] -pub struct FileRecorder { - // message fields - src: ::protobuf::SingularField<::std::string::String>, - dst: ::protobuf::SingularField<::std::string::String>, - on_start: ::protobuf::SingularField<::std::string::String>, - on_stop: ::protobuf::SingularField<::std::string::String>, - // special fields - pub unknown_fields: ::protobuf::UnknownFields, - pub cached_size: ::protobuf::CachedSize, -} - -impl<'a> ::std::default::Default for &'a FileRecorder { - fn default() -> &'a FileRecorder { - ::default_instance() - } -} - -impl FileRecorder { - pub fn new() -> FileRecorder { - ::std::default::Default::default() - } - - // required string src = 1; - - - pub fn get_src(&self) -> &str { - match self.src.as_ref() { - Some(v) => &v, - None => "", - } - } - pub fn clear_src(&mut self) { - self.src.clear(); - } - - pub fn has_src(&self) -> bool { - self.src.is_some() - } - - // Param is passed by value, moved - pub fn set_src(&mut self, v: ::std::string::String) { - self.src = ::protobuf::SingularField::some(v); - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_src(&mut self) -> &mut ::std::string::String { - if self.src.is_none() { - self.src.set_default(); - } - self.src.as_mut().unwrap() - } - - // Take field - pub fn take_src(&mut self) -> ::std::string::String { - self.src.take().unwrap_or_else(|| ::std::string::String::new()) - } - - // required string dst = 2; - - - pub fn get_dst(&self) -> &str { - match self.dst.as_ref() { - Some(v) => &v, - None => "", - } - } - pub fn clear_dst(&mut self) { - self.dst.clear(); - } - - pub fn has_dst(&self) -> bool { - self.dst.is_some() - } - - // Param is passed by value, moved - pub fn set_dst(&mut self, v: ::std::string::String) { - self.dst = ::protobuf::SingularField::some(v); - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_dst(&mut self) -> &mut ::std::string::String { - if self.dst.is_none() { - self.dst.set_default(); - } - self.dst.as_mut().unwrap() - } - - // Take field - pub fn take_dst(&mut self) -> ::std::string::String { - self.dst.take().unwrap_or_else(|| ::std::string::String::new()) - } - - // optional string on_start = 3; - - - pub fn get_on_start(&self) -> &str { - match self.on_start.as_ref() { - Some(v) => &v, - None => "", - } - } - pub fn clear_on_start(&mut self) { - self.on_start.clear(); - } - - pub fn has_on_start(&self) -> bool { - self.on_start.is_some() - } - - // Param is passed by value, moved - pub fn set_on_start(&mut self, v: ::std::string::String) { - self.on_start = ::protobuf::SingularField::some(v); - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_on_start(&mut self) -> &mut ::std::string::String { - if self.on_start.is_none() { - self.on_start.set_default(); - } - self.on_start.as_mut().unwrap() - } - - // Take field - pub fn take_on_start(&mut self) -> ::std::string::String { - self.on_start.take().unwrap_or_else(|| ::std::string::String::new()) - } - - // optional string on_stop = 4; - - - pub fn get_on_stop(&self) -> &str { - match self.on_stop.as_ref() { - Some(v) => &v, - None => "", - } - } - pub fn clear_on_stop(&mut self) { - self.on_stop.clear(); - } - - pub fn has_on_stop(&self) -> bool { - self.on_stop.is_some() - } - - // Param is passed by value, moved - pub fn set_on_stop(&mut self, v: ::std::string::String) { - self.on_stop = ::protobuf::SingularField::some(v); - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_on_stop(&mut self) -> &mut ::std::string::String { - if self.on_stop.is_none() { - self.on_stop.set_default(); - } - self.on_stop.as_mut().unwrap() - } - - // Take field - pub fn take_on_stop(&mut self) -> ::std::string::String { - self.on_stop.take().unwrap_or_else(|| ::std::string::String::new()) - } -} - -impl ::protobuf::Message for FileRecorder { - fn is_initialized(&self) -> bool { - if self.src.is_none() { - return false; - } - if self.dst.is_none() { - return false; - } - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - 1 => { - ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.src)?; - }, - 2 => { - ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.dst)?; - }, - 3 => { - ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.on_start)?; - }, - 4 => { - ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.on_stop)?; - }, - _ => { - ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - if let Some(ref v) = self.src.as_ref() { - my_size += ::protobuf::rt::string_size(1, &v); - } - if let Some(ref v) = self.dst.as_ref() { - my_size += ::protobuf::rt::string_size(2, &v); - } - if let Some(ref v) = self.on_start.as_ref() { - my_size += ::protobuf::rt::string_size(3, &v); - } - if let Some(ref v) = self.on_stop.as_ref() { - my_size += ::protobuf::rt::string_size(4, &v); - } - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { - if let Some(ref v) = self.src.as_ref() { - os.write_string(1, &v)?; - } - if let Some(ref v) = self.dst.as_ref() { - os.write_string(2, &v)?; - } - if let Some(ref v) = self.on_start.as_ref() { - os.write_string(3, &v)?; - } - if let Some(ref v) = self.on_stop.as_ref() { - os.write_string(4, &v)?; - } - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any - } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any - } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - Self::descriptor_static() - } - - fn new() -> FileRecorder { - FileRecorder::new() - } - - fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "src", - |m: &FileRecorder| { &m.src }, - |m: &mut FileRecorder| { &mut m.src }, - )); - fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "dst", - |m: &FileRecorder| { &m.dst }, - |m: &mut FileRecorder| { &mut m.dst }, - )); - fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "on_start", - |m: &FileRecorder| { &m.on_start }, - |m: &mut FileRecorder| { &mut m.on_start }, - )); - fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "on_stop", - |m: &FileRecorder| { &m.on_stop }, - |m: &mut FileRecorder| { &mut m.on_stop }, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "FileRecorder", - fields, - file_descriptor_proto() - ) - }) - } - } - - fn default_instance() -> &'static FileRecorder { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const FileRecorder, - }; - unsafe { - instance.get(FileRecorder::new) - } - } -} - -impl ::protobuf::Clear for FileRecorder { - fn clear(&mut self) { - self.src.clear(); - self.dst.clear(); - self.on_start.clear(); - self.on_stop.clear(); - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for FileRecorder { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for FileRecorder { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) - } -} - -#[derive(PartialEq,Clone,Default)] -pub struct Relay { - // message fields - src: ::protobuf::SingularField<::std::string::String>, - dst: ::protobuf::SingularField<::std::string::String>, - // special fields - pub unknown_fields: ::protobuf::UnknownFields, - pub cached_size: ::protobuf::CachedSize, -} - -impl<'a> ::std::default::Default for &'a Relay { - fn default() -> &'a Relay { - ::default_instance() - } -} - -impl Relay { - pub fn new() -> Relay { - ::std::default::Default::default() - } - - // required string src = 1; - - - pub fn get_src(&self) -> &str { - match self.src.as_ref() { - Some(v) => &v, - None => "", - } - } - pub fn clear_src(&mut self) { - self.src.clear(); - } - - pub fn has_src(&self) -> bool { - self.src.is_some() - } - - // Param is passed by value, moved - pub fn set_src(&mut self, v: ::std::string::String) { - self.src = ::protobuf::SingularField::some(v); - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_src(&mut self) -> &mut ::std::string::String { - if self.src.is_none() { - self.src.set_default(); - } - self.src.as_mut().unwrap() - } - - // Take field - pub fn take_src(&mut self) -> ::std::string::String { - self.src.take().unwrap_or_else(|| ::std::string::String::new()) - } - - // optional string dst = 2; - - - pub fn get_dst(&self) -> &str { - match self.dst.as_ref() { - Some(v) => &v, - None => "", - } - } - pub fn clear_dst(&mut self) { - self.dst.clear(); - } - - pub fn has_dst(&self) -> bool { - self.dst.is_some() - } - - // Param is passed by value, moved - pub fn set_dst(&mut self, v: ::std::string::String) { - self.dst = ::protobuf::SingularField::some(v); - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_dst(&mut self) -> &mut ::std::string::String { - if self.dst.is_none() { - self.dst.set_default(); - } - self.dst.as_mut().unwrap() - } - - // Take field - pub fn take_dst(&mut self) -> ::std::string::String { - self.dst.take().unwrap_or_else(|| ::std::string::String::new()) - } -} - -impl ::protobuf::Message for Relay { - fn is_initialized(&self) -> bool { - if self.src.is_none() { - return false; - } - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - 1 => { - ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.src)?; - }, - 2 => { - ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.dst)?; - }, - _ => { - ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - if let Some(ref v) = self.src.as_ref() { - my_size += ::protobuf::rt::string_size(1, &v); - } - if let Some(ref v) = self.dst.as_ref() { - my_size += ::protobuf::rt::string_size(2, &v); - } - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { - if let Some(ref v) = self.src.as_ref() { - os.write_string(1, &v)?; - } - if let Some(ref v) = self.dst.as_ref() { - os.write_string(2, &v)?; - } - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any - } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any - } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - Self::descriptor_static() - } - - fn new() -> Relay { - Relay::new() - } - - fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "src", - |m: &Relay| { &m.src }, - |m: &mut Relay| { &mut m.src }, - )); - fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "dst", - |m: &Relay| { &m.dst }, - |m: &mut Relay| { &mut m.dst }, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "Relay", - fields, - file_descriptor_proto() - ) - }) - } - } - - fn default_instance() -> &'static Relay { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const Relay, - }; - unsafe { - instance.get(Relay::new) - } - } -} - -impl ::protobuf::Clear for Relay { - fn clear(&mut self) { - self.src.clear(); - self.dst.clear(); - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for Relay { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for Relay { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) - } -} - -static file_descriptor_proto_data: &'static [u8] = b"\ - \n\rcontrol.proto\x12\x05medea\x1a\x19google/protobuf/any.proto\"\xf0\ - \x02\n\rCreateRequest\x12\x0e\n\x02id\x18\x01\x20\x02(\tR\x02id\x12\x1e\ - \n\x03hub\x18\x02\x20\x01(\x0b2\n.medea.HubH\0R\x03hub\x12:\n\rfile_reco\ - rder\x18\x03\x20\x01(\x0b2\x13.medea.FileRecorderH\0R\x0cfileRecorder\ - \x12'\n\x06member\x18\x04\x20\x01(\x0b2\r.medea.MemberH\0R\x06member\x12\ - $\n\x05relay\x18\x05\x20\x01(\x0b2\x0c.medea.RelayH\0R\x05relay\x12!\n\ - \x04room\x18\x06\x20\x01(\x0b2\x0b.medea.RoomH\0R\x04room\x12<\n\x0bwebr\ - tc_play\x18\x07\x20\x01(\x0b2\x19.medea.WebRtcPlayEndpointH\0R\nwebrtcPl\ - ay\x12=\n\nwebrtc_pub\x18\x08\x20\x01(\x0b2\x1c.medea.WebRtcPublishEndpo\ - intH\0R\twebrtcPubB\x04\n\x02el\"\xcb\x03\n\x0cApplyRequest\x12\x0e\n\ - \x02id\x18\x01\x20\x02(\tR\x02id\x12\x1e\n\x03hub\x18\x02\x20\x01(\x0b2\ - \n.medea.HubH\0R\x03hub\x12:\n\rfile_recorder\x18\x03\x20\x01(\x0b2\x13.\ - medea.FileRecorderH\0R\x0cfileRecorder\x12'\n\x06member\x18\x04\x20\x01(\ - \x0b2\r.medea.MemberH\0R\x06member\x12$\n\x05relay\x18\x05\x20\x01(\x0b2\ - \x0c.medea.RelayH\0R\x05relay\x12!\n\x04room\x18\x06\x20\x01(\x0b2\x0b.m\ - edea.RoomH\0R\x04room\x12<\n\x0bwebrtc_play\x18\x07\x20\x01(\x0b2\x19.me\ - dea.WebRtcPlayEndpointH\0R\nwebrtcPlay\x12=\n\nwebrtc_pub\x18\x08\x20\ - \x01(\x0b2\x1c.medea.WebRtcPublishEndpointH\0R\twebrtcPub\x129\n\x06poli\ - cy\x18\t\x20\x01(\x0e2\x1a.medea.ApplyRequest.Policy:\x05APPLYR\x06polic\ - y\"\x1f\n\x06Policy\x12\t\n\x05APPLY\x10\x01\x12\n\n\x06APPEND\x10\x02B\ - \x04\n\x02el\"\x1b\n\tIdRequest\x12\x0e\n\x02id\x18\x01\x20\x03(\tR\x02i\ - d\"\x92\x01\n\x08Response\x12*\n\x03sid\x18\x01\x20\x03(\x0b2\x18.medea.\ - Response.SidEntryR\x03sid\x12\"\n\x05error\x18\x02\x20\x01(\x0b2\x0c.med\ - ea.ErrorR\x05error\x1a6\n\x08SidEntry\x12\x10\n\x03key\x18\x01\x20\x01(\ - \tR\x03key\x12\x14\n\x05value\x18\x02\x20\x01(\tR\x05value:\x028\x01\"\ - \xbc\x01\n\x0bGetResponse\x12<\n\x08elements\x18\x01\x20\x03(\x0b2\x20.m\ - edea.GetResponse.ElementsEntryR\x08elements\x12\"\n\x05error\x18\x02\x20\ - \x01(\x0b2\x0c.medea.ErrorR\x05error\x1aK\n\rElementsEntry\x12\x10\n\x03\ - key\x18\x01\x20\x01(\tR\x03key\x12$\n\x05value\x18\x02\x20\x01(\x0b2\x0e\ - .medea.ElementR\x05value:\x028\x01\"\xc1\x01\n\x05Error\x12\x16\n\x06sta\ - tus\x18\x01\x20\x02(\rR\x06status\x12\x12\n\x04code\x18\x02\x20\x02(\rR\ - \x04code\x12\x12\n\x04text\x18\x03\x20\x02(\tR\x04text\x12\x10\n\x03doc\ - \x18\x04\x20\x01(\tR\x03doc\x12\x18\n\x07element\x18\x05\x20\x02(\tR\x07\ - element\x12.\n\x07details\x18\x06\x20\x01(\x0b2\x14.google.protobuf.AnyR\ - \x07details\x12\x1c\n\tbacktrace\x18\x07\x20\x03(\tR\tbacktrace\"\xda\ - \x02\n\x07Element\x12\x1e\n\x03hub\x18\x02\x20\x01(\x0b2\n.medea.HubH\0R\ - \x03hub\x12:\n\rfile_recorder\x18\x03\x20\x01(\x0b2\x13.medea.FileRecord\ - erH\0R\x0cfileRecorder\x12'\n\x06member\x18\x04\x20\x01(\x0b2\r.medea.Me\ - mberH\0R\x06member\x12$\n\x05relay\x18\x05\x20\x01(\x0b2\x0c.medea.Relay\ - H\0R\x05relay\x12!\n\x04room\x18\x06\x20\x01(\x0b2\x0b.medea.RoomH\0R\ - \x04room\x12<\n\x0bwebrtc_play\x18\x07\x20\x01(\x0b2\x19.medea.WebRtcPla\ - yEndpointH\0R\nwebrtcPlay\x12=\n\nwebrtc_pub\x18\x08\x20\x01(\x0b2\x1c.m\ - edea.WebRtcPublishEndpointH\0R\twebrtcPubB\x04\n\x02el\"\xc9\x03\n\x04Ro\ - om\x125\n\x08pipeline\x18\x01\x20\x03(\x0b2\x19.medea.Room.PipelineEntry\ - R\x08pipeline\x1aP\n\rPipelineEntry\x12\x10\n\x03key\x18\x01\x20\x01(\tR\ - \x03key\x12)\n\x05value\x18\x02\x20\x01(\x0b2\x13.medea.Room.ElementR\ - \x05value:\x028\x01\x1a\xb7\x02\n\x07Element\x12\x1e\n\x03hub\x18\x01\ - \x20\x01(\x0b2\n.medea.HubH\0R\x03hub\x12:\n\rfile_recorder\x18\x02\x20\ - \x01(\x0b2\x13.medea.FileRecorderH\0R\x0cfileRecorder\x12'\n\x06member\ - \x18\x03\x20\x01(\x0b2\r.medea.MemberH\0R\x06member\x12$\n\x05relay\x18\ - \x04\x20\x01(\x0b2\x0c.medea.RelayH\0R\x05relay\x12<\n\x0bwebrtc_play\ - \x18\x05\x20\x01(\x0b2\x19.medea.WebRtcPlayEndpointH\0R\nwebrtcPlay\x12=\ - \n\nwebrtc_pub\x18\x06\x20\x01(\x0b2\x1c.medea.WebRtcPublishEndpointH\0R\ - \twebrtcPubB\x04\n\x02el\"\xfc\x03\n\x06Member\x12\x17\n\x07on_join\x18\ - \x01\x20\x01(\tR\x06onJoin\x12\x19\n\x08on_leave\x18\x02\x20\x01(\tR\x07\ - onLeave\x12\x20\n\x0bcredentials\x18\x03\x20\x02(\tR\x0bcredentials\x127\ - \n\x08pipeline\x18\x04\x20\x03(\x0b2\x1b.medea.Member.PipelineEntryR\x08\ - pipeline\x1aR\n\rPipelineEntry\x12\x10\n\x03key\x18\x01\x20\x01(\tR\x03k\ - ey\x12+\n\x05value\x18\x02\x20\x01(\x0b2\x15.medea.Member.ElementR\x05va\ - lue:\x028\x01\x1a\x8e\x02\n\x07Element\x12\x1e\n\x03hub\x18\x01\x20\x01(\ - \x0b2\n.medea.HubH\0R\x03hub\x12:\n\rfile_recorder\x18\x02\x20\x01(\x0b2\ - \x13.medea.FileRecorderH\0R\x0cfileRecorder\x12$\n\x05relay\x18\x03\x20\ - \x01(\x0b2\x0c.medea.RelayH\0R\x05relay\x12<\n\x0bwebrtc_play\x18\x04\ - \x20\x01(\x0b2\x19.medea.WebRtcPlayEndpointH\0R\nwebrtcPlay\x12=\n\nwebr\ - tc_pub\x18\x05\x20\x01(\x0b2\x1c.medea.WebRtcPublishEndpointH\0R\twebrtc\ - PubB\x04\n\x02el\"\xc7\x01\n\x15WebRtcPublishEndpoint\x129\n\x03p2p\x18\ - \x01\x20\x01(\x0e2\x20.medea.WebRtcPublishEndpoint.P2P:\x05NEVERR\x03p2p\ - \x12\x10\n\x03dst\x18\x02\x20\x01(\tR\x03dst\x12\x19\n\x08on_start\x18\ - \x03\x20\x01(\tR\x07onStart\x12\x17\n\x07on_stop\x18\x04\x20\x01(\tR\x06\ - onStop\"-\n\x03P2P\x12\t\n\x05NEVER\x10\0\x12\x0f\n\x0bIF_POSSIBLE\x10\ - \x01\x12\n\n\x06ALWAYS\x10\x02\"Z\n\x12WebRtcPlayEndpoint\x12\x10\n\x03s\ - rc\x18\x01\x20\x02(\tR\x03src\x12\x19\n\x08on_start\x18\x02\x20\x01(\tR\ - \x07onStart\x12\x17\n\x07on_stop\x18\x03\x20\x01(\tR\x06onStop\"\x05\n\ - \x03Hub\"f\n\x0cFileRecorder\x12\x10\n\x03src\x18\x01\x20\x02(\tR\x03src\ - \x12\x10\n\x03dst\x18\x02\x20\x02(\tR\x03dst\x12\x19\n\x08on_start\x18\ - \x03\x20\x01(\tR\x07onStart\x12\x17\n\x07on_stop\x18\x04\x20\x01(\tR\x06\ - onStop\"+\n\x05Relay\x12\x10\n\x03src\x18\x01\x20\x02(\tR\x03src\x12\x10\ - \n\x03dst\x18\x02\x20\x01(\tR\x03dst2\xc6\x01\n\nControlApi\x12/\n\x06Cr\ - eate\x12\x14.medea.CreateRequest\x1a\x0f.medea.Response\x12-\n\x05Apply\ - \x12\x13.medea.ApplyRequest\x1a\x0f.medea.Response\x12+\n\x06Delete\x12\ - \x10.medea.IdRequest\x1a\x0f.medea.Response\x12+\n\x03Get\x12\x10.medea.\ - IdRequest\x1a\x12.medea.GetResponse\ -"; - -static mut file_descriptor_proto_lazy: ::protobuf::lazy::Lazy<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::descriptor::FileDescriptorProto, -}; - -fn parse_descriptor_proto() -> ::protobuf::descriptor::FileDescriptorProto { - ::protobuf::parse_from_bytes(file_descriptor_proto_data).unwrap() -} - -pub fn file_descriptor_proto() -> &'static ::protobuf::descriptor::FileDescriptorProto { - unsafe { - file_descriptor_proto_lazy.get(|| { - parse_descriptor_proto() - }) - } -} diff --git a/src/api/control/grpc/protos/control_grpc.rs b/src/api/control/grpc/protos/control_grpc.rs deleted file mode 100644 index 200c56a85..000000000 --- a/src/api/control/grpc/protos/control_grpc.rs +++ /dev/null @@ -1,155 +0,0 @@ -// This file is generated. Do not edit -// @generated - -// https://github.com/Manishearth/rust-clippy/issues/702 -#![allow(unknown_lints)] -#![allow(clippy::all)] - -#![cfg_attr(rustfmt, rustfmt_skip)] - -#![allow(box_pointers)] -#![allow(dead_code)] -#![allow(missing_docs)] -#![allow(non_camel_case_types)] -#![allow(non_snake_case)] -#![allow(non_upper_case_globals)] -#![allow(trivial_casts)] -#![allow(unsafe_code)] -#![allow(unused_imports)] -#![allow(unused_results)] - -const METHOD_CONTROL_API_CREATE: ::grpcio::Method = ::grpcio::Method { - ty: ::grpcio::MethodType::Unary, - name: "/medea.ControlApi/Create", - req_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, - resp_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, -}; - -const METHOD_CONTROL_API_APPLY: ::grpcio::Method = ::grpcio::Method { - ty: ::grpcio::MethodType::Unary, - name: "/medea.ControlApi/Apply", - req_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, - resp_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, -}; - -const METHOD_CONTROL_API_DELETE: ::grpcio::Method = ::grpcio::Method { - ty: ::grpcio::MethodType::Unary, - name: "/medea.ControlApi/Delete", - req_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, - resp_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, -}; - -const METHOD_CONTROL_API_GET: ::grpcio::Method = ::grpcio::Method { - ty: ::grpcio::MethodType::Unary, - name: "/medea.ControlApi/Get", - req_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, - resp_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, -}; - -#[derive(Clone)] -pub struct ControlApiClient { - client: ::grpcio::Client, -} - -impl ControlApiClient { - pub fn new(channel: ::grpcio::Channel) -> Self { - ControlApiClient { - client: ::grpcio::Client::new(channel), - } - } - - pub fn create_opt(&self, req: &super::control::CreateRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result { - self.client.unary_call(&METHOD_CONTROL_API_CREATE, req, opt) - } - - pub fn create(&self, req: &super::control::CreateRequest) -> ::grpcio::Result { - self.create_opt(req, ::grpcio::CallOption::default()) - } - - pub fn create_async_opt(&self, req: &super::control::CreateRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { - self.client.unary_call_async(&METHOD_CONTROL_API_CREATE, req, opt) - } - - pub fn create_async(&self, req: &super::control::CreateRequest) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { - self.create_async_opt(req, ::grpcio::CallOption::default()) - } - - pub fn apply_opt(&self, req: &super::control::ApplyRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result { - self.client.unary_call(&METHOD_CONTROL_API_APPLY, req, opt) - } - - pub fn apply(&self, req: &super::control::ApplyRequest) -> ::grpcio::Result { - self.apply_opt(req, ::grpcio::CallOption::default()) - } - - pub fn apply_async_opt(&self, req: &super::control::ApplyRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { - self.client.unary_call_async(&METHOD_CONTROL_API_APPLY, req, opt) - } - - pub fn apply_async(&self, req: &super::control::ApplyRequest) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { - self.apply_async_opt(req, ::grpcio::CallOption::default()) - } - - pub fn delete_opt(&self, req: &super::control::IdRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result { - self.client.unary_call(&METHOD_CONTROL_API_DELETE, req, opt) - } - - pub fn delete(&self, req: &super::control::IdRequest) -> ::grpcio::Result { - self.delete_opt(req, ::grpcio::CallOption::default()) - } - - pub fn delete_async_opt(&self, req: &super::control::IdRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { - self.client.unary_call_async(&METHOD_CONTROL_API_DELETE, req, opt) - } - - pub fn delete_async(&self, req: &super::control::IdRequest) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { - self.delete_async_opt(req, ::grpcio::CallOption::default()) - } - - pub fn get_opt(&self, req: &super::control::IdRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result { - self.client.unary_call(&METHOD_CONTROL_API_GET, req, opt) - } - - pub fn get(&self, req: &super::control::IdRequest) -> ::grpcio::Result { - self.get_opt(req, ::grpcio::CallOption::default()) - } - - pub fn get_async_opt(&self, req: &super::control::IdRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { - self.client.unary_call_async(&METHOD_CONTROL_API_GET, req, opt) - } - - pub fn get_async(&self, req: &super::control::IdRequest) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { - self.get_async_opt(req, ::grpcio::CallOption::default()) - } - pub fn spawn(&self, f: F) where F: ::futures::Future + Send + 'static { - self.client.spawn(f) - } -} - -pub trait ControlApi { - fn create(&mut self, ctx: ::grpcio::RpcContext, req: super::control::CreateRequest, sink: ::grpcio::UnarySink); - fn apply(&mut self, ctx: ::grpcio::RpcContext, req: super::control::ApplyRequest, sink: ::grpcio::UnarySink); - fn delete(&mut self, ctx: ::grpcio::RpcContext, req: super::control::IdRequest, sink: ::grpcio::UnarySink); - fn get(&mut self, ctx: ::grpcio::RpcContext, req: super::control::IdRequest, sink: ::grpcio::UnarySink); -} - -pub fn create_control_api(s: S) -> ::grpcio::Service { - let mut builder = ::grpcio::ServiceBuilder::new(); - let mut instance = s.clone(); - builder = builder.add_unary_handler(&METHOD_CONTROL_API_CREATE, move |ctx, req, resp| { - instance.create(ctx, req, resp) - }); - let mut instance = s.clone(); - builder = builder.add_unary_handler(&METHOD_CONTROL_API_APPLY, move |ctx, req, resp| { - instance.apply(ctx, req, resp) - }); - let mut instance = s.clone(); - builder = builder.add_unary_handler(&METHOD_CONTROL_API_DELETE, move |ctx, req, resp| { - instance.delete(ctx, req, resp) - }); - let mut instance = s.clone(); - builder = builder.add_unary_handler(&METHOD_CONTROL_API_GET, move |ctx, req, resp| { - instance.get(ctx, req, resp) - }); - builder.build() -} From f32fab5a8935616430d058eb03c3c012c83726c2 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 12 Jul 2019 19:42:00 +0300 Subject: [PATCH 349/735] Migrate to proto3 --- .../control/endpoints/webrtc_play_endpoint.rs | 11 ++-- .../endpoints/webrtc_publish_endpoint.rs | 11 ++-- src/api/control/grpc/protos/control.proto | 60 +++++++++---------- src/api/control/member.rs | 7 ++- 4 files changed, 42 insertions(+), 47 deletions(-) diff --git a/src/api/control/endpoints/webrtc_play_endpoint.rs b/src/api/control/endpoints/webrtc_play_endpoint.rs index 772d86775..45e92ee5e 100644 --- a/src/api/control/endpoints/webrtc_play_endpoint.rs +++ b/src/api/control/endpoints/webrtc_play_endpoint.rs @@ -47,13 +47,10 @@ impl TryFrom<&WebRtcPlayEndpointProto> for WebRtcPlayEndpoint { type Error = TryFromProtobufError; fn try_from(value: &WebRtcPlayEndpointProto) -> Result { - if value.has_src() { - Ok(Self { - src: SrcUri::parse(value.get_src())?, - }) - } else { - Err(TryFromProtobufError::SrcUriNotFound) - } + // TODO: think about absent src uri. + Ok(Self { + src: SrcUri::parse(value.get_src())?, + }) } } diff --git a/src/api/control/endpoints/webrtc_publish_endpoint.rs b/src/api/control/endpoints/webrtc_publish_endpoint.rs index 27b24133f..04cfb9334 100644 --- a/src/api/control/endpoints/webrtc_publish_endpoint.rs +++ b/src/api/control/endpoints/webrtc_publish_endpoint.rs @@ -67,18 +67,15 @@ pub struct WebRtcPublishEndpoint { pub p2p: P2pMode, } +// TODO: make it From impl TryFrom<&WebRtcPublishEndpointProto> for WebRtcPublishEndpoint { type Error = TryFromProtobufError; fn try_from( value: &WebRtcPublishEndpointProto, ) -> Result { - if value.has_p2p() { - Ok(Self { - p2p: P2pMode::from(value.get_p2p()), - }) - } else { - Err(TryFromProtobufError::P2pModeNotFound) - } + Ok(Self { + p2p: P2pMode::from(value.get_p2p()), + }) } } diff --git a/src/api/control/grpc/protos/control.proto b/src/api/control/grpc/protos/control.proto index 55d26d2d4..d6e6a065c 100644 --- a/src/api/control/grpc/protos/control.proto +++ b/src/api/control/grpc/protos/control.proto @@ -1,4 +1,4 @@ -syntax = "proto2"; +syntax = "proto3"; import "google/protobuf/any.proto"; @@ -11,7 +11,7 @@ service ControlApi { rpc Get (IdRequest) returns (GetResponse); } message CreateRequest { - required string id = 1; + string id = 1; oneof el { Hub hub = 2; FileRecorder file_recorder = 3; @@ -23,7 +23,7 @@ message CreateRequest { } } message ApplyRequest { - required string id = 1; + string id = 1; oneof el { Hub hub = 2; FileRecorder file_recorder = 3; @@ -33,11 +33,11 @@ message ApplyRequest { WebRtcPlayEndpoint webrtc_play = 7; WebRtcPublishEndpoint webrtc_pub = 8; } - optional Policy policy = 9 [default = APPLY]; + Policy policy = 9; enum Policy { - APPLY = 1; - APPEND = 2; + APPLY = 0; + APPEND = 1; } } message IdRequest { @@ -45,19 +45,19 @@ message IdRequest { } message Response { map sid = 1; - optional Error error = 2; + Error error = 2; } message GetResponse { map elements = 1; - optional Error error = 2; + Error error = 2; } message Error { - required uint32 status = 1; - required uint32 code = 2; - required string text = 3; - optional string doc = 4; - required string element = 5; - optional google.protobuf.Any details = 6; + uint32 status = 1; + uint32 code = 2; + string text = 3; + string doc = 4; + string element = 5; + google.protobuf.Any details = 6; repeated string backtrace = 7; } @@ -89,9 +89,9 @@ message Room { } message Member { - optional string on_join = 1; - optional string on_leave = 2; - required string credentials = 3; + string on_join = 1; + string on_leave = 2; + string credentials = 3; map pipeline = 4; message Element { @@ -106,10 +106,10 @@ message Member { } message WebRtcPublishEndpoint { - optional P2P p2p = 1 [default = NEVER]; - optional string dst = 2; - optional string on_start = 3; - optional string on_stop = 4; + P2P p2p = 1; + string dst = 2; + string on_start = 3; + string on_stop = 4; enum P2P { NEVER = 0; @@ -119,21 +119,21 @@ message WebRtcPublishEndpoint { } message WebRtcPlayEndpoint { - required string src = 1; - optional string on_start = 2; - optional string on_stop = 3; + string src = 1; + string on_start = 2; + string on_stop = 3; } message Hub {} message FileRecorder { - required string src = 1; - required string dst = 2; - optional string on_start = 3; - optional string on_stop = 4; + string src = 1; + string dst = 2; + string on_start = 3; + string on_stop = 4; } message Relay { - required string src = 1; - optional string dst = 2; + string src = 1; + string dst = 2; } diff --git a/src/api/control/member.rs b/src/api/control/member.rs index c5bc5a335..dc3e6bde6 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -99,9 +99,10 @@ impl TryFrom<&MemberProto> for MemberSpec { } let pipeline = Pipeline::new(pipeline); - if !value.has_credentials() { - return Err(TryFromProtobufError::MemberCredentialsNotFound); - } + // TODO: think about absent credentials. + // if !value.has_credentials() { + // return Err(TryFromProtobufError::MemberCredentialsNotFound); + // } Ok(Self { pipeline, From 858f485dc23aaab571e1c0920901612933f49317 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 12 Jul 2019 19:48:19 +0300 Subject: [PATCH 350/735] Rewrite protobuf to WebRtcPublishEndpoint to From trait --- src/api/control/endpoints/mod.rs | 6 ++--- .../endpoints/webrtc_publish_endpoint.rs | 24 ++++++------------- 2 files changed, 9 insertions(+), 21 deletions(-) diff --git a/src/api/control/endpoints/mod.rs b/src/api/control/endpoints/mod.rs index 53623d23d..768029ee9 100644 --- a/src/api/control/endpoints/mod.rs +++ b/src/api/control/endpoints/mod.rs @@ -43,8 +43,7 @@ impl TryFrom<&MemberElementProto> for Endpoint { let play = WebRtcPlayEndpoint::try_from(value.get_webrtc_play())?; Ok(Endpoint::WebRtcPlay(play)) } else if value.has_webrtc_pub() { - let publish = - WebRtcPublishEndpoint::try_from(value.get_webrtc_pub())?; + let publish = WebRtcPublishEndpoint::from(value.get_webrtc_pub()); Ok(Endpoint::WebRtcPublish(publish)) } else { // TODO implement another endpoints when they will be implemented @@ -61,8 +60,7 @@ impl TryFrom<&CreateRequest> for Endpoint { let play = WebRtcPlayEndpoint::try_from(value.get_webrtc_play())?; Ok(Endpoint::WebRtcPlay(play)) } else if value.has_webrtc_pub() { - let publish = - WebRtcPublishEndpoint::try_from(value.get_webrtc_pub())?; + let publish = WebRtcPublishEndpoint::from(value.get_webrtc_pub()); Ok(Endpoint::WebRtcPublish(publish)) } else { // TODO implement another endpoints when they will be implemented diff --git a/src/api/control/endpoints/webrtc_publish_endpoint.rs b/src/api/control/endpoints/webrtc_publish_endpoint.rs index 04cfb9334..a4357add2 100644 --- a/src/api/control/endpoints/webrtc_publish_endpoint.rs +++ b/src/api/control/endpoints/webrtc_publish_endpoint.rs @@ -1,17 +1,12 @@ //! `WebRtcPublishEndpoint` implementation. -use std::convert::TryFrom; - use macro_attr::*; use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; use serde::Deserialize; -use crate::api::control::{ - grpc::protos::control::{ - WebRtcPublishEndpoint as WebRtcPublishEndpointProto, - WebRtcPublishEndpoint_P2P as WebRtcPublishEndpointP2pProto, - }, - TryFromProtobufError, +use crate::api::control::grpc::protos::control::{ + WebRtcPublishEndpoint as WebRtcPublishEndpointProto, + WebRtcPublishEndpoint_P2P as WebRtcPublishEndpointP2pProto, }; macro_attr! { @@ -67,15 +62,10 @@ pub struct WebRtcPublishEndpoint { pub p2p: P2pMode, } -// TODO: make it From -impl TryFrom<&WebRtcPublishEndpointProto> for WebRtcPublishEndpoint { - type Error = TryFromProtobufError; - - fn try_from( - value: &WebRtcPublishEndpointProto, - ) -> Result { - Ok(Self { +impl From<&WebRtcPublishEndpointProto> for WebRtcPublishEndpoint { + fn from(value: &WebRtcPublishEndpointProto) -> Self { + Self { p2p: P2pMode::from(value.get_p2p()), - }) + } } } From ca8091c413c3b3a6acd67d56cc8deead9fab12a4 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 12 Jul 2019 19:55:06 +0300 Subject: [PATCH 351/735] Remove status field from protobuf error message --- src/api/control/grpc/protos/control.proto | 1 - src/api/error_codes.rs | 1 - 2 files changed, 2 deletions(-) diff --git a/src/api/control/grpc/protos/control.proto b/src/api/control/grpc/protos/control.proto index d6e6a065c..6a3de8a9d 100644 --- a/src/api/control/grpc/protos/control.proto +++ b/src/api/control/grpc/protos/control.proto @@ -52,7 +52,6 @@ message GetResponse { Error error = 2; } message Error { - uint32 status = 1; uint32 code = 2; string text = 3; string doc = 4; diff --git a/src/api/error_codes.rs b/src/api/error_codes.rs index b847d3778..3779b51a5 100644 --- a/src/api/error_codes.rs +++ b/src/api/error_codes.rs @@ -117,7 +117,6 @@ pub enum ErrorCode { impl Into for ErrorCode { fn into(self) -> ErrorProto { let mut error = ErrorProto::new(); - error.set_status(0); match self { ErrorCode::UnknownError(msg) => { error.set_text(format!( From e33249479eb8eae8a2ea6ab6866e8c57bc20ad01 Mon Sep 17 00:00:00 2001 From: alexlapa Date: Fri, 12 Jul 2019 20:19:37 +0300 Subject: [PATCH 352/735] refactor --- .../endpoints/webrtc/play_endpoint.rs | 9 - src/signalling/participants.rs | 2 +- src/signalling/room.rs | 37 +- tests/e2e/signalling.rs | 407 ------------------ tests/e2e/signalling/mod.rs | 169 ++++++++ tests/e2e/signalling/pub_sub_signallng.rs | 105 +++++ tests/e2e/signalling/three_pubs.rs | 139 ++++++ 7 files changed, 430 insertions(+), 438 deletions(-) delete mode 100644 tests/e2e/signalling.rs create mode 100644 tests/e2e/signalling/mod.rs create mode 100644 tests/e2e/signalling/pub_sub_signallng.rs create mode 100644 tests/e2e/signalling/three_pubs.rs diff --git a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs index 8c984aa1b..b9c5c5b90 100644 --- a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs @@ -65,10 +65,6 @@ impl WebRtcPlayEndpointInner { Weak::upgrade(&self.src).unwrap() } - fn is_connected(&self) -> bool { - self.peer_id.is_some() - } - fn set_peer_id(&mut self, peer_id: PeerId) { self.peer_id = Some(peer_id) } @@ -137,11 +133,6 @@ impl WebRtcPlayEndpoint { self.0.borrow().src() } - /// Check that peer connection established for this [`WebRtcPlayEndpoint`]. - pub fn is_connected(&self) -> bool { - self.0.borrow().is_connected() - } - /// Save [`PeerId`] of this [`WebRtcPlayEndpoint`]. pub fn set_peer_id(&self, peer_id: PeerId) { self.0.borrow_mut().set_peer_id(peer_id); diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 4509d8a42..91657acfa 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -228,9 +228,9 @@ impl ParticipantService { // no way to handle absence of RpcConnection. pub fn connection_closed( &mut self, - ctx: &mut Context, member_id: MemberId, reason: &ClosedReason, + ctx: &mut Context, ) { let closed_at = Instant::now(); match reason { diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 5a74fa775..a44457d5c 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -369,14 +369,15 @@ impl Room { let mut created_peers: Vec<(PeerId, PeerId)> = Vec::new(); // Create all connected publish endpoints. - for (_, publish) in member.srcs() { - for receiver in publish.sinks() { + for (_, publisher) in member.srcs() { + for receiver in publisher.sinks() { let receiver_owner = receiver.owner(); - if self.members.member_has_connection(&receiver_owner.id()) - && !receiver.is_connected() + if receiver.peer_id().is_none() + && self.members.member_has_connection(&receiver_owner.id()) { - if let Some(p) = self.connect_endpoints(&publish, &receiver) + if let Some(p) = + self.connect_endpoints(&publisher, &receiver) { created_peers.push(p) } @@ -385,17 +386,13 @@ impl Room { } // Create all connected play's receivers peers. - for (_, play) in member.sinks() { - let plays_publisher = play.src(); - let plays_publisher_owner = plays_publisher.owner(); - - if self - .members - .member_has_connection(&plays_publisher_owner.id()) - && !play.is_connected() + for (_, receiver) in member.sinks() { + let publisher = receiver.src(); + + if receiver.peer_id().is_none() + && self.members.member_has_connection(&publisher.owner().id()) { - if let Some(p) = self.connect_endpoints(&plays_publisher, &play) - { + if let Some(p) = self.connect_endpoints(&publisher, &receiver) { created_peers.push(p); } } @@ -573,17 +570,15 @@ impl Handler for Room { msg: RpcConnectionEstablished, ctx: &mut Self::Context, ) -> Self::Result { - info!("RpcConnectionEstablished for member {}", msg.member_id); - - let member_id = msg.member_id; + info!("RpcConnectionEstablished for member {}", &msg.member_id); let fut = self .members - .connection_established(ctx, member_id.clone(), msg.connection) + .connection_established(ctx, msg.member_id, msg.connection) .map_err(|err, _, _| { error!("RpcConnectionEstablished error {:?}", err) }) - .map(move |member, room, ctx| { + .map(|member, room, ctx| { room.init_member_connections(&member, ctx); }); Box::new(fut) @@ -628,6 +623,6 @@ impl Handler for Room { } self.members - .connection_closed(ctx, msg.member_id, &msg.reason); + .connection_closed(msg.member_id, &msg.reason, ctx); } } diff --git a/tests/e2e/signalling.rs b/tests/e2e/signalling.rs deleted file mode 100644 index 2430c0364..000000000 --- a/tests/e2e/signalling.rs +++ /dev/null @@ -1,407 +0,0 @@ -//! Signalling API e2e tests. - -use std::{cell::Cell, rc::Rc, time::Duration}; - -use actix::{ - Actor, Arbiter, AsyncContext, Context, Handler, Message, StreamHandler, - System, -}; -use actix_codec::Framed; -use actix_http::ws::{Codec, Message as WsMessage}; -use awc::{ - error::WsProtocolError, - ws::{CloseCode, CloseReason, Frame}, - BoxedSocket, -}; -use futures::{future::Future, sink::Sink, stream::SplitSink, Stream}; -use medea::media::PeerId; -use medea_client_api_proto::{Command, Direction, Event, IceCandidate}; -use serde_json::error::Error as SerdeError; - -/// Medea client for testing purposes. -struct TestMember { - /// Writer to WebSocket. - writer: SplitSink>, - - /// All [`Event`]s which this [`TestMember`] received. - /// This field used for give some debug info when test just stuck forever - /// (most often, such a test will end on a timer of five seconds - /// and display all events of this [`TestMember`]). - events: Vec, - - /// Function which will be called at every received by this [`TestMember`] - /// [`Event`]. - test_fn: Box)>, -} - -impl TestMember { - /// Signaling heartbeat for server. - /// Most likely, this ping will never be sent, - /// because it has been established that it is sent once per 3 seconds, - /// and there are simply no tests that last so much. - fn heartbeat(&self, ctx: &mut Context) { - ctx.run_later(Duration::from_secs(3), |act, ctx| { - act.writer - .start_send(WsMessage::Text(r#"{"ping": 1}"#.to_string())) - .unwrap(); - act.writer.poll_complete().unwrap(); - act.heartbeat(ctx); - }); - } - - /// Send command to the server. - fn send_command(&mut self, msg: Command) { - // self.writer.text(&serde_json::to_string(&msg).unwrap()); - let json = serde_json::to_string(&msg).unwrap(); - self.writer.start_send(WsMessage::Text(json)).unwrap(); - self.writer.poll_complete().unwrap(); - } - - /// Start test member in new [`Arbiter`] by given URI. - /// `test_fn` - is function which will be called at every [`Event`] - /// received from server. - pub fn start( - uri: &str, - test_fn: Box)>, - ) { - Arbiter::spawn( - awc::Client::new() - .ws(uri) - .connect() - .map_err(|e| panic!("Error: {}", e)) - .map(|(_, framed)| { - let (sink, stream) = framed.split(); - TestMember::create(|ctx| { - TestMember::add_stream(stream, ctx); - TestMember { - writer: sink, - events: Vec::new(), - test_fn, - } - }); - }), - ) - } -} - -impl Actor for TestMember { - type Context = Context; - - /// Start heartbeat and set a timer that will panic when 5 seconds expire. - /// The timer is needed because some tests may just stuck - /// and listen socket forever. - fn started(&mut self, ctx: &mut Self::Context) { - self.heartbeat(ctx); - ctx.run_later(Duration::from_secs(5), |act, _ctx| { - panic!( - "This test lasts more than 5 seconds. Most likely, this is \ - not normal. Here is all events of member: {:?}", - act.events - ); - }); - } -} - -struct CloseSocket; - -impl Message for CloseSocket { - type Result = (); -} - -impl Handler for TestMember { - type Result = (); - - fn handle(&mut self, _: CloseSocket, _: &mut Self::Context) { - self.writer - .start_send(WsMessage::Close(Some(CloseReason { - code: CloseCode::Normal, - description: None, - }))) - .unwrap(); - self.writer.poll_complete().unwrap(); - } -} - -impl StreamHandler for TestMember { - /// Basic signalling implementation. - /// A `TestMember::test_fn` [`FnMut`] function will be called for each - /// [`Event`] received from test server. - fn handle(&mut self, msg: Frame, ctx: &mut Context) { - match msg { - Frame::Text(txt) => { - let txt = String::from_utf8(txt.unwrap().to_vec()).unwrap(); - let event: Result = - serde_json::from_str(&txt); - if let Ok(event) = event { - self.events.push(event.clone()); - // Test function call - (self.test_fn)(&event, ctx); - match event { - Event::PeerCreated { - peer_id, sdp_offer, .. - } => { - match sdp_offer { - Some(_) => { - self.send_command(Command::MakeSdpAnswer { - peer_id, - sdp_answer: "responder_answer" - .to_string(), - }); - } - None => { - self.send_command(Command::MakeSdpOffer { - peer_id, - sdp_offer: "caller_offer".to_string(), - }); - } - } - self.send_command(Command::SetIceCandidate { - peer_id, - candidate: IceCandidate { - candidate: "ice_candidate".to_string(), - sdp_m_line_index: None, - sdp_mid: None, - }, - }); - } - _ => (), - } - } - } - _ => (), - } - } -} - -#[test] -fn pub_sub_video_call() { - System::run(|| { - let base_url = "ws://localhost:8081/ws/pub-sub-video-call"; - - // Note that events is separated by members. - // Every member will have different instance of this. - let mut events = Vec::new(); - let test_fn = move |event: &Event, _: &mut Context| { - events.push(event.clone()); - - // Start checking result of test. - if let Event::IceCandidateDiscovered { .. } = event { - let peers_count = events - .iter() - .filter(|e| match e { - Event::PeerCreated { .. } => true, - _ => false, - }) - .count(); - assert_eq!(peers_count, 1); - - let mut is_caller = false; - if let Event::PeerCreated { - peer_id, - sdp_offer, - tracks, - ice_servers, - } = &events[0] - { - assert_eq!(ice_servers.len(), 2); - assert_eq!( - ice_servers[0].urls[0], - "stun:127.0.0.1:3478".to_string() - ); - assert_eq!( - ice_servers[1].urls[0], - "turn:127.0.0.1:3478".to_string() - ); - assert_eq!( - ice_servers[1].urls[1], - "turn:127.0.0.1:3478?transport=tcp".to_string() - ); - - if let Some(_) = sdp_offer { - is_caller = false; - } else { - is_caller = true; - } - assert_eq!(tracks.len(), 2); - for track in tracks { - match &track.direction { - Direction::Send { receivers } => { - assert!(is_caller); - assert!(!receivers.contains(&peer_id)); - } - Direction::Recv { sender } => { - assert!(!is_caller); - assert_ne!(sender, peer_id); - } - } - } - } else { - assert!(false) - } - - if is_caller { - if let Event::SdpAnswerMade { .. } = &events[1] { - } else { - assert!(false); - } - - if let Event::IceCandidateDiscovered { .. } = &events[2] { - } else { - assert!(false); - } - } else { - if let Event::IceCandidateDiscovered { .. } = &events[1] { - } else { - assert!(false); - } - } - - if is_caller { - System::current().stop(); - } - } - }; - - TestMember::start( - &format!("{}/caller/test", base_url), - Box::new(test_fn.clone()), - ); - TestMember::start( - &format!("{}/responder/test", base_url), - Box::new(test_fn), - ); - }) - .unwrap(); -} - -#[test] -fn three_members_p2p_video_call() { - System::run(|| { - let base_url = "ws://localhost:8081/ws/three-members-conference"; - - // Note that events, peer_created_count, ice_candidates - // is separated by members. - // Every member will have different instance of this. - let mut events = Vec::new(); - let mut peer_created_count = 0; - let mut ice_candidates = 0; - - // This is shared state of members. - let members_tested = Rc::new(Cell::new(0)); - let members_peers_removed = Rc::new(Cell::new(0)); - - let test_fn = move |event: &Event, ctx: &mut Context| { - events.push(event.clone()); - match event { - Event::PeerCreated { ice_servers, .. } => { - assert_eq!(ice_servers.len(), 2); - assert_eq!( - ice_servers[0].urls[0], - "stun:127.0.0.1:3478".to_string() - ); - assert_eq!( - ice_servers[1].urls[0], - "turn:127.0.0.1:3478".to_string() - ); - assert_eq!( - ice_servers[1].urls[1], - "turn:127.0.0.1:3478?transport=tcp".to_string() - ); - - peer_created_count += 1; - } - Event::IceCandidateDiscovered { .. } => { - ice_candidates += 1; - if ice_candidates == 2 { - // Start checking result of test. - - assert_eq!(peer_created_count, 2); - - events.iter().for_each(|e| match e { - Event::PeerCreated { - peer_id, tracks, .. - } => { - assert_eq!(tracks.len(), 4); - let recv_count = tracks - .iter() - .filter_map(|t| match &t.direction { - Direction::Recv { sender } => { - Some(sender) - } - _ => None, - }) - .map(|sender| { - assert_ne!(sender, peer_id); - }) - .count(); - assert_eq!(recv_count, 2); - - let send_count = tracks - .iter() - .filter_map(|t| match &t.direction { - Direction::Send { receivers } => { - Some(receivers) - } - _ => None, - }) - .map(|receivers| { - assert!(!receivers.contains(peer_id)); - assert_eq!(receivers.len(), 1); - }) - .count(); - assert_eq!(send_count, 2); - } - _ => (), - }); - - // Check peers removing. - // After closing socket, server should send - // Event::PeersRemoved to all remaining - // members. - // Close should happen when last TestMember pass - // tests. - if members_tested.get() == 2 { - ctx.notify(CloseSocket); - } - members_tested.set(members_tested.get() + 1); - } - } - Event::PeersRemoved { .. } => { - // This event should get two remaining members after closing - // last tested member. - let peers_removed: Vec<&Vec> = events - .iter() - .filter_map(|e| match e { - Event::PeersRemoved { peer_ids } => Some(peer_ids), - _ => None, - }) - .collect(); - assert_eq!(peers_removed.len(), 1); - assert_eq!(peers_removed[0].len(), 2); - assert_ne!(peers_removed[0][0], peers_removed[0][1]); - - members_peers_removed.set(members_peers_removed.get() + 1); - // Stop when all members receive Event::PeerRemoved - if members_peers_removed.get() == 2 { - System::current().stop(); - } - } - _ => (), - } - }; - - TestMember::start( - &format!("{}/member-1/test", base_url), - Box::new(test_fn.clone()), - ); - TestMember::start( - &format!("{}/member-2/test", base_url), - Box::new(test_fn.clone()), - ); - TestMember::start( - &format!("{}/member-3/test", base_url), - Box::new(test_fn), - ); - }) - .unwrap(); -} diff --git a/tests/e2e/signalling/mod.rs b/tests/e2e/signalling/mod.rs new file mode 100644 index 000000000..9663eceb4 --- /dev/null +++ b/tests/e2e/signalling/mod.rs @@ -0,0 +1,169 @@ +//! Signalling API e2e tests. + +mod pub_sub_signallng; +mod three_pubs; + +use std::time::Duration; + +use actix::{ + Actor, Arbiter, AsyncContext, Context, Handler, Message, StreamHandler, +}; +use actix_codec::Framed; +use actix_http::ws::{Codec, Message as WsMessage}; +use awc::{ + error::WsProtocolError, + ws::{CloseCode, CloseReason, Frame}, + BoxedSocket, +}; +use futures::{future::Future, sink::Sink, stream::SplitSink, Stream}; +use medea_client_api_proto::{Command, Event, IceCandidate}; +use serde_json::error::Error as SerdeError; + +/// Medea client for testing purposes. +pub struct TestMember { + /// Writer to WebSocket. + writer: SplitSink>, + + /// All [`Event`]s which this [`TestMember`] received. + /// This field used for give some debug info when test just stuck forever + /// (most often, such a test will end on a timer of five seconds + /// and display all events of this [`TestMember`]). + events: Vec, + + /// Function which will be called at every received by this [`TestMember`] + /// [`Event`]. + test_fn: Box)>, +} + +impl TestMember { + /// Signaling heartbeat for server. + /// Most likely, this ping will never be sent, + /// because it has been established that it is sent once per 3 seconds, + /// and there are simply no tests that last so much. + fn heartbeat(&self, ctx: &mut Context) { + ctx.run_later(Duration::from_secs(3), |act, ctx| { + act.writer + .start_send(WsMessage::Text(r#"{"ping": 1}"#.to_string())) + .unwrap(); + act.writer.poll_complete().unwrap(); + act.heartbeat(ctx); + }); + } + + /// Send command to the server. + fn send_command(&mut self, msg: Command) { + // self.writer.text(&serde_json::to_string(&msg).unwrap()); + let json = serde_json::to_string(&msg).unwrap(); + self.writer.start_send(WsMessage::Text(json)).unwrap(); + self.writer.poll_complete().unwrap(); + } + + /// Start test member in new [`Arbiter`] by given URI. + /// `test_fn` - is function which will be called at every [`Event`] + /// received from server. + pub fn start( + uri: &str, + test_fn: Box)>, + ) { + Arbiter::spawn( + awc::Client::new() + .ws(uri) + .connect() + .map_err(|e| panic!("Error: {}", e)) + .map(|(_, framed)| { + let (sink, stream) = framed.split(); + TestMember::create(|ctx| { + TestMember::add_stream(stream, ctx); + TestMember { + writer: sink, + events: Vec::new(), + test_fn, + } + }); + }), + ) + } +} + +impl Actor for TestMember { + type Context = Context; + + /// Start heartbeat and set a timer that will panic when 5 seconds expire. + /// The timer is needed because some tests may just stuck + /// and listen socket forever. + fn started(&mut self, ctx: &mut Self::Context) { + self.heartbeat(ctx); + ctx.run_later(Duration::from_secs(5), |act, _ctx| { + panic!( + "This test lasts more than 5 seconds. Most likely, this is \ + not normal. Here is all events of member: {:?}", + act.events + ); + }); + } +} + +pub struct CloseSocket; + +impl Message for CloseSocket { + type Result = (); +} + +impl Handler for TestMember { + type Result = (); + + fn handle(&mut self, _: CloseSocket, _: &mut Self::Context) { + self.writer + .start_send(WsMessage::Close(Some(CloseReason { + code: CloseCode::Normal, + description: None, + }))) + .unwrap(); + self.writer.poll_complete().unwrap(); + } +} + +impl StreamHandler for TestMember { + /// Basic signalling implementation. + /// A `TestMember::test_fn` [`FnMut`] function will be called for each + /// [`Event`] received from test server. + fn handle(&mut self, msg: Frame, ctx: &mut Context) { + if let Frame::Text(txt) = msg { + let txt = String::from_utf8(txt.unwrap().to_vec()).unwrap(); + let event: Result = serde_json::from_str(&txt); + if let Ok(event) = event { + self.events.push(event.clone()); + // Test function call + (self.test_fn)(&event, ctx); + + if let Event::PeerCreated { + peer_id, sdp_offer, .. + } = event + { + match sdp_offer { + Some(_) => { + self.send_command(Command::MakeSdpAnswer { + peer_id, + sdp_answer: "responder_answer".to_string(), + }); + } + None => { + self.send_command(Command::MakeSdpOffer { + peer_id, + sdp_offer: "caller_offer".to_string(), + }); + } + } + self.send_command(Command::SetIceCandidate { + peer_id, + candidate: IceCandidate { + candidate: "ice_candidate".to_string(), + sdp_m_line_index: None, + sdp_mid: None, + }, + }); + } + } + } + } +} diff --git a/tests/e2e/signalling/pub_sub_signallng.rs b/tests/e2e/signalling/pub_sub_signallng.rs new file mode 100644 index 000000000..1bc70b728 --- /dev/null +++ b/tests/e2e/signalling/pub_sub_signallng.rs @@ -0,0 +1,105 @@ +use actix::{Context, System}; +use medea_client_api_proto::{Direction, Event}; + +use crate::signalling::TestMember; + +#[test] +fn pub_sub_video_call() { + System::run(|| { + let base_url = "ws://localhost:8081/ws/pub-sub-video-call"; + + // Note that events is separated by members. + // Every member will have different instance of this. + let mut events = Vec::new(); + let test_fn = move |event: &Event, _: &mut Context| { + events.push(event.clone()); + + // Start checking result of test. + if let Event::IceCandidateDiscovered { .. } = event { + let peers_count = events + .iter() + .filter(|e| match e { + Event::PeerCreated { .. } => true, + _ => false, + }) + .count(); + assert_eq!(peers_count, 1); + + let is_caller; + if let Event::PeerCreated { + peer_id, + sdp_offer, + tracks, + ice_servers, + } = &events[0] + { + assert_eq!(ice_servers.len(), 2); + assert_eq!( + ice_servers[0].urls[0], + "stun:127.0.0.1:3478".to_string() + ); + assert_eq!( + ice_servers[1].urls[0], + "turn:127.0.0.1:3478".to_string() + ); + assert_eq!( + ice_servers[1].urls[1], + "turn:127.0.0.1:3478?transport=tcp".to_string() + ); + + if sdp_offer.is_some() { + is_caller = false; + } else { + is_caller = true; + } + assert_eq!(tracks.len(), 2); + for track in tracks { + match &track.direction { + Direction::Send { receivers } => { + assert!(is_caller); + assert!(!receivers.contains(&peer_id)); + } + Direction::Recv { sender } => { + assert!(!is_caller); + assert_ne!(sender, peer_id); + } + } + } + } else { + unreachable!() + } + + if is_caller { + if let Event::SdpAnswerMade { .. } = &events[1] { + } else { + unreachable!(); + } + + if let Event::IceCandidateDiscovered { .. } = &events[2] { + } else { + unreachable!(); + } + } else if let Event::IceCandidateDiscovered { .. } = &events[1] + { + + } else { + unreachable!(); + } + + if is_caller { + System::current().stop(); + } + } + }; + + TestMember::start( + &format!("{}/caller/test", base_url), + Box::new(test_fn.clone()), + ); + TestMember::start( + &format!("{}/responder/test", base_url), + Box::new(test_fn), + ); + }) + .unwrap(); +} diff --git a/tests/e2e/signalling/three_pubs.rs b/tests/e2e/signalling/three_pubs.rs new file mode 100644 index 000000000..c97177444 --- /dev/null +++ b/tests/e2e/signalling/three_pubs.rs @@ -0,0 +1,139 @@ +use std::{cell::Cell, rc::Rc}; + +use actix::{AsyncContext as _, Context, System}; +use medea::media::PeerId; +use medea_client_api_proto::{Direction, Event}; + +use crate::signalling::{CloseSocket, TestMember}; + +#[test] +fn three_members_p2p_video_call() { + System::run(|| { + let base_url = "ws://localhost:8081/ws/three-members-conference"; + + // Note that events, peer_created_count, ice_candidates + // is separated by members. + // Every member will have different instance of this. + let mut events = Vec::new(); + let mut peer_created_count = 0; + let mut ice_candidates = 0; + + // This is shared state of members. + let members_tested = Rc::new(Cell::new(0)); + let members_peers_removed = Rc::new(Cell::new(0)); + + let test_fn = move |event: &Event, ctx: &mut Context| { + events.push(event.clone()); + match event { + Event::PeerCreated { ice_servers, .. } => { + assert_eq!(ice_servers.len(), 2); + assert_eq!( + ice_servers[0].urls[0], + "stun:127.0.0.1:3478".to_string() + ); + assert_eq!( + ice_servers[1].urls[0], + "turn:127.0.0.1:3478".to_string() + ); + assert_eq!( + ice_servers[1].urls[1], + "turn:127.0.0.1:3478?transport=tcp".to_string() + ); + + peer_created_count += 1; + } + Event::IceCandidateDiscovered { .. } => { + ice_candidates += 1; + if ice_candidates == 2 { + // Start checking result of test. + + assert_eq!(peer_created_count, 2); + + events.iter().for_each(|e| { + if let Event::PeerCreated { + peer_id, tracks, .. + } = e + { + assert_eq!(tracks.len(), 4); + let recv_count = tracks + .iter() + .filter_map(|t| match &t.direction { + Direction::Recv { sender } => { + Some(sender) + } + _ => None, + }) + .map(|sender| { + assert_ne!(sender, peer_id); + }) + .count(); + assert_eq!(recv_count, 2); + + let send_count = tracks + .iter() + .filter_map(|t| match &t.direction { + Direction::Send { receivers } => { + Some(receivers) + } + _ => None, + }) + .map(|receivers| { + assert!(!receivers.contains(peer_id)); + assert_eq!(receivers.len(), 1); + }) + .count(); + assert_eq!(send_count, 2); + } + }); + + // Check peers removing. + // After closing socket, server should send + // Event::PeersRemoved to all remaining + // members. + // Close should happen when last TestMember pass + // tests. + if members_tested.get() == 2 { + ctx.notify(CloseSocket); + } + members_tested.set(members_tested.get() + 1); + } + } + Event::PeersRemoved { .. } => { + // This event should get two remaining members after closing + // last tested member. + let peers_removed: Vec<&Vec> = events + .iter() + .filter_map(|e| match e { + Event::PeersRemoved { peer_ids } => Some(peer_ids), + _ => None, + }) + .collect(); + assert_eq!(peers_removed.len(), 1); + assert_eq!(peers_removed[0].len(), 2); + assert_ne!(peers_removed[0][0], peers_removed[0][1]); + + members_peers_removed.set(members_peers_removed.get() + 1); + // Stop when all members receive Event::PeerRemoved + if members_peers_removed.get() == 2 { + System::current().stop(); + } + } + _ => (), + } + }; + + TestMember::start( + &format!("{}/member-1/test", base_url), + Box::new(test_fn.clone()), + ); + TestMember::start( + &format!("{}/member-2/test", base_url), + Box::new(test_fn.clone()), + ); + TestMember::start( + &format!("{}/member-3/test", base_url), + Box::new(test_fn), + ); + }) + .unwrap(); +} From 235d75fbe4f95a027f7480117808a750bd6a8548 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 12 Jul 2019 20:24:42 +0300 Subject: [PATCH 353/735] New implementation for Delete Room --- src/signalling/room.rs | 32 ++++++++++++++++++++++++++++++++ src/signalling/room_repo.rs | 25 ++++++++++++++++--------- 2 files changed, 48 insertions(+), 9 deletions(-) diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 4b426d87a..67a129b14 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -765,6 +765,38 @@ impl Handler for Room { } } +// TODO: maybe better naming +#[derive(Message, Debug)] +#[rtype(result = "()")] +pub struct Delete; + +impl Handler for Room { + type Result = (); + + fn handle(&mut self, _: Delete, ctx: &mut Self::Context) -> Self::Result { + for (id, member) in self.members.members() { + if self.members.member_has_connection(&id) { + let peer_ids_to_remove: HashSet = member + .sinks() + .into_iter() + .filter_map(|(_, sink)| sink.peer_id()) + .chain( + member + .srcs() + .into_iter() + .flat_map(|(_, src)| src.peer_ids().into_iter()), + ) + .collect(); + + let member_id = id.clone(); + + self.peers.remove_peers(&member_id, peer_ids_to_remove, ctx); + self.members.delete_member(&member_id, ctx); + } + } + } +} + /// Signal for delete [`Member`] from this [`Room`] #[derive(Debug, Message, Clone)] #[rtype(result = "()")] diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs index 8c528d032..46307bccb 100644 --- a/src/signalling/room_repo.rs +++ b/src/signalling/room_repo.rs @@ -3,8 +3,8 @@ use std::sync::{Arc, Mutex}; use actix::{ - fut::wrap_future, Actor, ActorFuture, Addr, Context, Handler, MailboxError, - Message, + fut::wrap_future, Actor, ActorFuture, Addr, AsyncContext, Context, Handler, + MailboxError, Message, }; use failure::Fail; use futures::future::{Either, Future}; @@ -21,9 +21,9 @@ use crate::{ }, signalling::{ room::{ - CloseRoom, CreateEndpoint, CreateMember, DeleteEndpoint, - DeleteMember, RoomError, SerializeProtobufEndpoint, - SerializeProtobufMember, SerializeProtobufRoom, + CreateEndpoint, CreateMember, Delete, DeleteEndpoint, DeleteMember, + RoomError, SerializeProtobufEndpoint, SerializeProtobufMember, + SerializeProtobufRoom, }, Room, }, @@ -162,12 +162,19 @@ impl Handler for RoomsRepository { fn handle( &mut self, msg: DeleteRoom, - _ctx: &mut Self::Context, + ctx: &mut Self::Context, ) -> Self::Result { - let mut room_repo = self.rooms.lock().unwrap(); + let room_repo = self.rooms.lock().unwrap(); if let Some(room) = room_repo.get(&msg.0) { - room.do_send(CloseRoom {}); - room_repo.remove(&msg.0); + let rooms = Arc::clone(&self.rooms); + // TODO: handle errors + ctx.spawn(wrap_future( + room.send(Delete) + .map(move |_| { + rooms.lock().unwrap().remove(&msg.0); + }) + .map_err(|_| ()), + )); } Ok(()) From 4da92d650d43db1ecdc90fcbcdafbe45712772c3 Mon Sep 17 00:00:00 2001 From: alexlapa Date: Fri, 12 Jul 2019 20:26:38 +0300 Subject: [PATCH 354/735] refactor makefile --- Makefile | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 9b90e4b83..88f9918c7 100644 --- a/Makefile +++ b/Makefile @@ -158,8 +158,7 @@ medea-env = RUST_BACKTRACE=1 \ MEDEA_SERVER.STATIC_SPECS_PATH=tests/specs test.e2e: -ifeq ($(coturn),no) -else +ifneq ($(coturn),no) @make up.coturn endif ifeq ($(dockerized),no) @@ -172,8 +171,7 @@ ifeq ($(dockerized),no) - cargo test --test e2e @make down.medea -ifeq ($(coturn),no) -else +ifneq ($(coturn),no) @make down.coturn endif else From 7d30b34f476d10d8257374565c0f9b81f1d6db71 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 15 Jul 2019 12:20:26 +0300 Subject: [PATCH 355/735] Add check for absent src/local uri --- src/api/control/local_uri.rs | 8 ++++++++ src/api/error_codes.rs | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/src/api/control/local_uri.rs b/src/api/control/local_uri.rs index aeefbe7b7..3b6b99b9b 100644 --- a/src/api/control/local_uri.rs +++ b/src/api/control/local_uri.rs @@ -18,6 +18,10 @@ pub enum LocalUriParseError { /// Too many paths in provided URI. #[fail(display = "Too many ({}) paths in provided URI.", _0)] TooManyFields(usize, String), + + /// Provided empty `&str`. + #[fail(display = "You provided empty local uri.")] + Empty, } impl Into for LocalUriParseError { @@ -29,6 +33,7 @@ impl Into for LocalUriParseError { LocalUriParseError::TooManyFields(_, text) => { ErrorCode::ElementIdIsTooLong(text) } + LocalUriParseError::Empty => ErrorCode::EmptyElementId, } } } @@ -66,6 +71,9 @@ impl LocalUri { /// Returns [`LocalUriParse::NotLocal`] when uri is not "local://" /// Returns [`LocalUriParse::TooManyFields`] when uri have too many paths. pub fn parse(value: &str) -> Result { + if value.is_empty() { + return Err(LocalUriParseError::Empty); + } let protocol_name: String = value.chars().take(8).collect(); if protocol_name != "local://" { return Err(LocalUriParseError::NotLocal(value.to_string())); diff --git a/src/api/error_codes.rs b/src/api/error_codes.rs index 3779b51a5..600e28443 100644 --- a/src/api/error_codes.rs +++ b/src/api/error_codes.rs @@ -96,6 +96,10 @@ pub enum ErrorCode { /// /// Code: __1202__. MissingFieldsInSrcUri(String, Vec), + /// Empty element ID. + /// + /// Code: __1203__. + EmptyElementId, ///////////////////////////// // Conflict (1300 - 1399) // @@ -246,6 +250,11 @@ impl Into for ErrorCode { error.set_element(uri); error.set_code(1202); } + ErrorCode::EmptyElementId => { + error.set_text("Provided empty element ID.".to_string()); + error.set_element(String::new()); + error.set_code(1203); + } ///////////////////////////// // Conflict (1300 - 1399) // From 173c098695ae5137ce995f92ce68f5145024f715 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 15 Jul 2019 12:29:04 +0300 Subject: [PATCH 356/735] Better naming and close room mailbox handling --- src/api/control/endpoints/webrtc_play_endpoint.rs | 1 - src/signalling/room.rs | 9 +++++---- src/signalling/room_repo.rs | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/api/control/endpoints/webrtc_play_endpoint.rs b/src/api/control/endpoints/webrtc_play_endpoint.rs index 45e92ee5e..c37c5c6cc 100644 --- a/src/api/control/endpoints/webrtc_play_endpoint.rs +++ b/src/api/control/endpoints/webrtc_play_endpoint.rs @@ -47,7 +47,6 @@ impl TryFrom<&WebRtcPlayEndpointProto> for WebRtcPlayEndpoint { type Error = TryFromProtobufError; fn try_from(value: &WebRtcPlayEndpointProto) -> Result { - // TODO: think about absent src uri. Ok(Self { src: SrcUri::parse(value.get_src())?, }) diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 67a129b14..5157a461b 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -765,15 +765,14 @@ impl Handler for Room { } } -// TODO: maybe better naming #[derive(Message, Debug)] #[rtype(result = "()")] -pub struct Delete; +pub struct Close; -impl Handler for Room { +impl Handler for Room { type Result = (); - fn handle(&mut self, _: Delete, ctx: &mut Self::Context) -> Self::Result { + fn handle(&mut self, _: Close, ctx: &mut Self::Context) -> Self::Result { for (id, member) in self.members.members() { if self.members.member_has_connection(&id) { let peer_ids_to_remove: HashSet = member @@ -794,6 +793,8 @@ impl Handler for Room { self.members.delete_member(&member_id, ctx); } } + let drop_fut = self.members.drop_connections(ctx); + ctx.wait(wrap_future(drop_fut)); } } diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs index 46307bccb..89dacce7d 100644 --- a/src/signalling/room_repo.rs +++ b/src/signalling/room_repo.rs @@ -19,9 +19,10 @@ use crate::{ }, error_codes::ErrorCode, }, + log::prelude::*, signalling::{ room::{ - CreateEndpoint, CreateMember, Delete, DeleteEndpoint, DeleteMember, + Close, CreateEndpoint, CreateMember, DeleteEndpoint, DeleteMember, RoomError, SerializeProtobufEndpoint, SerializeProtobufMember, SerializeProtobufRoom, }, @@ -167,13 +168,12 @@ impl Handler for RoomsRepository { let room_repo = self.rooms.lock().unwrap(); if let Some(room) = room_repo.get(&msg.0) { let rooms = Arc::clone(&self.rooms); - // TODO: handle errors ctx.spawn(wrap_future( - room.send(Delete) + room.send(Close) .map(move |_| { rooms.lock().unwrap().remove(&msg.0); }) - .map_err(|_| ()), + .map_err(|e| warn!("Close room mailbox error {:?}.", e)), )); } From ad7fe88579caf03a39fa2474cf7e76729ed8f519 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 15 Jul 2019 14:32:12 +0300 Subject: [PATCH 357/735] Add error backtrace for control API --- .../control/endpoints/webrtc_play_endpoint.rs | 19 ++- src/api/control/grpc/server.rs | 20 ++- src/api/control/local_uri.rs | 19 ++- src/api/control/member.rs | 6 +- src/api/control/mod.rs | 14 +- src/api/error_codes.rs | 130 ++++++++++++------ src/media/peer.rs | 12 +- src/signalling/elements/member.rs | 51 +++++-- src/signalling/participants.rs | 33 ++++- src/signalling/room.rs | 34 ++++- src/signalling/room_repo.rs | 31 ++++- src/turn/repo.rs | 15 +- src/turn/service.rs | 23 +++- 13 files changed, 325 insertions(+), 82 deletions(-) diff --git a/src/api/control/endpoints/webrtc_play_endpoint.rs b/src/api/control/endpoints/webrtc_play_endpoint.rs index c37c5c6cc..b5801a7cd 100644 --- a/src/api/control/endpoints/webrtc_play_endpoint.rs +++ b/src/api/control/endpoints/webrtc_play_endpoint.rs @@ -17,7 +17,7 @@ use crate::api::{ local_uri::{LocalUri, LocalUriParseError}, MemberId, RoomId, TryFromProtobufError, }, - error_codes::ErrorCode, + error_codes::{Backtrace, ErrorCode}, }; macro_attr! { @@ -63,15 +63,30 @@ pub enum SrcParseError { impl Into for SrcParseError { fn into(self) -> ErrorCode { + let backtrace: Backtrace = (&self).into(); match self { SrcParseError::MissingField(text, fields) => { - ErrorCode::MissingFieldsInSrcUri(text, fields) + ErrorCode::MissingFieldsInSrcUri(text, fields, backtrace) } SrcParseError::LocalUriParseError(_, err) => err.into(), } } } +impl Into for &SrcParseError { + fn into(self) -> Backtrace { + let mut backtrace = Backtrace::new(); + backtrace.push(self); + match self { + SrcParseError::MissingField(..) => {} + SrcParseError::LocalUriParseError(_, e) => { + backtrace.merge(e.into()); + } + } + backtrace + } +} + /// Special uri with pattern `local://{room_id}/{member_id}/{endpoint_id}`. /// This uri can pointing only to [`WebRtcPublishEndpoint`]. #[derive(Clone, Debug)] diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index 1eceaa527..76bc4e622 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -18,7 +18,7 @@ use crate::{ Endpoint, MemberSpec, RoomSpec, TryFromElementError, TryFromProtobufError, }, - error_codes::ErrorCode, + error_codes::{Backtrace, ErrorCode}, }, log::prelude::*, signalling::{ @@ -292,6 +292,7 @@ impl ControlApi for ControlApiService { sink, ErrorCode::ElementIdForRoomButElementIsNot( req.get_id().to_string(), + Backtrace::new() ), Response ); @@ -312,6 +313,7 @@ impl ControlApi for ControlApiService { sink, ErrorCode::ElementIdForMemberButElementIsNot( req.get_id().to_string(), + Backtrace::new() ), Response ); @@ -335,6 +337,7 @@ impl ControlApi for ControlApiService { sink, ErrorCode::ElementIdForEndpointButElementIsNot( req.get_id().to_string(), + Backtrace::new() ), Response ); @@ -343,7 +346,10 @@ impl ControlApi for ControlApiService { send_error_response!( ctx, sink, - ErrorCode::InvalidElementUri(req.get_id().to_string()), + ErrorCode::InvalidElementUri( + req.get_id().to_string(), + Backtrace::new() + ), Response ); } @@ -396,7 +402,10 @@ impl ControlApi for ControlApiService { send_error_response!( ctx, sink, - ErrorCode::InvalidElementUri(id.to_string()), + ErrorCode::InvalidElementUri( + id.to_string(), + Backtrace::new() + ), Response ); } @@ -484,7 +493,10 @@ impl ControlApi for ControlApiService { send_error_response!( ctx, sink, - ErrorCode::InvalidElementUri(id.to_string()), + ErrorCode::InvalidElementUri( + id.to_string(), + Backtrace::new() + ), GetResponse ); } diff --git a/src/api/control/local_uri.rs b/src/api/control/local_uri.rs index 3b6b99b9b..e7785eaa4 100644 --- a/src/api/control/local_uri.rs +++ b/src/api/control/local_uri.rs @@ -4,7 +4,7 @@ use std::fmt; use failure::Fail; -use crate::api::error_codes::ErrorCode; +use crate::api::error_codes::{Backtrace, ErrorCode}; use super::{MemberId, RoomId}; @@ -26,23 +26,32 @@ pub enum LocalUriParseError { impl Into for LocalUriParseError { fn into(self) -> ErrorCode { + let backtrace: Backtrace = (&self).into(); match self { LocalUriParseError::NotLocal(text) => { - ErrorCode::ElementIdIsNotLocal(text) + ErrorCode::ElementIdIsNotLocal(text, backtrace) } LocalUriParseError::TooManyFields(_, text) => { - ErrorCode::ElementIdIsTooLong(text) + ErrorCode::ElementIdIsTooLong(text, backtrace) } - LocalUriParseError::Empty => ErrorCode::EmptyElementId, + LocalUriParseError::Empty => ErrorCode::EmptyElementId(backtrace), } } } +impl Into for &LocalUriParseError { + fn into(self) -> Backtrace { + let mut backtrace = Backtrace::new(); + backtrace.push(self); + backtrace + } +} + #[allow(clippy::doc_markdown)] /// Uri in format "local://room_id/member_id/endpoint_id" /// This kind of uri used for pointing to some element in spec (`Room`, /// `Member`, `WebRtcPlayEndpoint`, `WebRtcPublishEndpoint`, etc). -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct LocalUri { /// ID of [`Room`] pub room_id: Option, diff --git a/src/api/control/member.rs b/src/api/control/member.rs index dc3e6bde6..5f31bc67c 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -99,11 +99,7 @@ impl TryFrom<&MemberProto> for MemberSpec { } let pipeline = Pipeline::new(pipeline); - // TODO: think about absent credentials. - // if !value.has_credentials() { - // return Err(TryFromProtobufError::MemberCredentialsNotFound); - // } - + // Credentials here maybe absent. Ok(Self { pipeline, credentials: value.get_credentials().to_string(), diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index 584937098..b80d593d4 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -12,7 +12,7 @@ use std::{convert::TryFrom as _, fs::File, io::Read as _, path::Path}; use failure::{Error, Fail}; use serde::Deserialize; -use crate::api::error_codes::ErrorCode; +use crate::api::error_codes::{Backtrace, ErrorCode}; use self::{ endpoints::{ @@ -78,7 +78,7 @@ impl Into for TryFromProtobufError { /// Errors that can occur when we try transform some spec from [`Element`]. /// This error used in all [`TryFrom`] of Control API. #[allow(clippy::pub_enum_variant_names)] -#[derive(Debug, Fail)] +#[derive(Debug, Fail, Clone)] pub enum TryFromElementError { /// Element is not Endpoint. #[fail(display = "Element is not Endpoint")] @@ -93,6 +93,16 @@ pub enum TryFromElementError { NotMember, } +impl Into for &TryFromElementError { + fn into(self) -> Backtrace { + let mut backtrace = Backtrace::new(); + match self { + _ => backtrace.push(self), + } + backtrace + } +} + /// Entity for parsing Control API request. #[derive(Clone, Deserialize, Debug)] #[serde(tag = "kind")] diff --git a/src/api/error_codes.rs b/src/api/error_codes.rs index 600e28443..cce71a5fa 100644 --- a/src/api/error_codes.rs +++ b/src/api/error_codes.rs @@ -7,10 +7,38 @@ //! * __1200...1299__ Parse errors //! * __1300...1399__ Conflicts +use protobuf::RepeatedField; + use crate::api::control::{ grpc::protos::control::Error as ErrorProto, local_uri::LocalUri, }; +#[derive(Debug)] +pub struct Backtrace(pub Vec); + +impl Backtrace { + pub fn new() -> Self { + Self(Vec::new()) + } + + pub fn push(&mut self, error: &T) { + self.0.push(format!("{:?}", error)); + } + + pub fn merge(&mut self, mut another_backtrace: Backtrace) { + self.0.append(&mut another_backtrace.0); + } +} + +impl Into> for Backtrace { + fn into(self) -> RepeatedField { + let mut repeated_field = RepeatedField::new(); + self.0.into_iter().for_each(|e| repeated_field.push(e)); + + repeated_field + } +} + /// Medea control API errors. // TODO: write macro for generating error codes. pub enum ErrorCode { @@ -25,23 +53,23 @@ pub enum ErrorCode { /// Publish endpoint not found. /// /// Code: __1001__. - PublishEndpointNotFound(LocalUri), + PublishEndpointNotFound(LocalUri, Backtrace), /// Play endpoint not found. /// /// Code: __1002__. - PlayEndpointNotFound(LocalUri), + PlayEndpointNotFound(LocalUri, Backtrace), /// Member not found. /// /// Code: __1003__. - MemberNotFound(LocalUri), + MemberNotFound(LocalUri, Backtrace), /// Room not found. /// /// Code: __1004__. - RoomNotFound(LocalUri), + RoomNotFound(LocalUri, Backtrace), /// Endpoint not found. /// /// Code: __1005__. - EndpointNotFound(LocalUri), + EndpointNotFound(LocalUri, Backtrace), ////////////////////////////////////// // Spec errors (1100 - 1199 codes) // @@ -49,37 +77,37 @@ pub enum ErrorCode { /// Medea expects `Room` element in pipeline but received not him. /// /// Code: __1100__. - NotRoomInSpec(LocalUri), + NotRoomInSpec(LocalUri, Backtrace), /// Medea expects `Member` element in pipeline but received not him. /// /// Code: __1101__. - NotMemberInSpec(LocalUri), + NotMemberInSpec(LocalUri, Backtrace), /// Medea expects `Endpoint` element in pipeline but received not him. /// /// Code: __1102__. - NotEndpointInSpec(LocalUri), + NotEndpointInSpec(LocalUri, Backtrace), /// Invalid source URI in play endpoint. /// /// Code: __1103__. - InvalidSrcUri(LocalUri), + InvalidSrcUri(LocalUri, Backtrace), /// Provided element ID to Room element but element spec is not for Room. /// /// Code: __1104__. - ElementIdForRoomButElementIsNot(String), + ElementIdForRoomButElementIsNot(String, Backtrace), /// Provided element ID to Member element but element spec is not for /// Member. /// /// Code: __1105__. - ElementIdForMemberButElementIsNot(String), + ElementIdForMemberButElementIsNot(String, Backtrace), /// Provided element ID to Endpoint element but element spec is not for /// Endpoint. /// /// Code: __1106__. - ElementIdForEndpointButElementIsNot(String), + ElementIdForEndpointButElementIsNot(String, Backtrace), /// Invalid ID for element. /// /// Code: __1107__ - InvalidElementUri(String), + InvalidElementUri(String, Backtrace), ///////////////////////////////// // Parse errors (1200 - 1299) // @@ -87,19 +115,19 @@ pub enum ErrorCode { /// Element's ID don't have "local://" prefix. /// /// Code: __1200__. - ElementIdIsNotLocal(String), + ElementIdIsNotLocal(String, Backtrace), /// Element's ID have too many paths (slashes). /// /// Code: __1201__. - ElementIdIsTooLong(String), + ElementIdIsTooLong(String, Backtrace), /// Source URI in publish endpoint missing some fields. /// /// Code: __1202__. - MissingFieldsInSrcUri(String, Vec), + MissingFieldsInSrcUri(String, Vec, Backtrace), /// Empty element ID. /// /// Code: __1203__. - EmptyElementId, + EmptyElementId(Backtrace), ///////////////////////////// // Conflict (1300 - 1399) // @@ -107,15 +135,15 @@ pub enum ErrorCode { /// Member already exists. /// /// Code: __1300__. - MemberAlreadyExists(LocalUri), + MemberAlreadyExists(LocalUri, Backtrace), /// Endpoint already exists. /// /// Code: __1301__. - EndpointAlreadyExists(LocalUri), + EndpointAlreadyExists(LocalUri, Backtrace), /// Room already exists. /// /// Code: __1302__. - RoomAlreadyExists(LocalUri), + RoomAlreadyExists(LocalUri, Backtrace), } impl Into for ErrorCode { @@ -134,64 +162,73 @@ impl Into for ErrorCode { //////////////////////////////////// // Not found (1001 - 1099 codes) // ////////////////////////////////// - ErrorCode::PublishEndpointNotFound(id) => { + ErrorCode::PublishEndpointNotFound(id, backtrace) => { error.set_text("Publish endpoint not found".to_string()); error.set_element(id.to_string()); - error.set_code(1001) + error.set_code(1001); + error.set_backtrace(backtrace.into()) } - ErrorCode::PlayEndpointNotFound(id) => { + ErrorCode::PlayEndpointNotFound(id, backtrace) => { error.set_text("Play endpoint not found.".to_string()); error.set_element(id.to_string()); error.set_code(1002); + error.set_backtrace(backtrace.into()) } - ErrorCode::MemberNotFound(id) => { + ErrorCode::MemberNotFound(id, backtrace) => { error.set_text("Member not found.".to_string()); error.set_element(id.to_string()); error.set_code(1003); + error.set_backtrace(backtrace.into()) } - ErrorCode::RoomNotFound(id) => { + ErrorCode::RoomNotFound(id, backtrace) => { error.set_text("Room not found.".to_string()); error.set_element(id.to_string()); error.set_code(1004); + error.set_backtrace(backtrace.into()) } - ErrorCode::EndpointNotFound(id) => { + ErrorCode::EndpointNotFound(id, backtrace) => { error.set_text("Endpoint not found.".to_string()); error.set_element(id.to_string()); error.set_code(1005); + error.set_backtrace(backtrace.into()) } ////////////////////////////////////// // Spec errors (1100 - 1199 codes) // //////////////////////////////////// - ErrorCode::NotRoomInSpec(id) => { + ErrorCode::NotRoomInSpec(id, backtrace) => { error.set_text( "Expecting Room element but it's not.".to_string(), ); error.set_element(id.to_string()); error.set_code(1100); + error.set_backtrace(backtrace.into()); } - ErrorCode::NotMemberInSpec(id) => { + ErrorCode::NotMemberInSpec(id, backtrace) => { error.set_text( "Expecting Member element but it's not.".to_string(), ); error.set_element(id.to_string()); error.set_code(1101); + error.set_backtrace(backtrace.into()); } - ErrorCode::NotEndpointInSpec(id) => { + ErrorCode::NotEndpointInSpec(id, backtrace) => { error.set_text( "Expecting Member element but it's not.".to_string(), ); error.set_element(id.to_string()); error.set_code(1102); + error.set_backtrace(backtrace.into()); } - ErrorCode::InvalidSrcUri(id) => { + ErrorCode::InvalidSrcUri(id, backtrace) => { error.set_text( "Invalid source ID in publish endpoint spec.".to_string(), ); error.set_element(id.to_string()); error.set_code(1103); + error.set_backtrace(backtrace.into()); } - ErrorCode::ElementIdForRoomButElementIsNot(id) => { + ErrorCode::ElementIdForRoomButElementIsNot(id, backtrace) => { error.set_text( "You provided ID for Room but element's spec is not for \ Room." @@ -199,8 +236,9 @@ impl Into for ErrorCode { ); error.set_element(id); error.set_code(1104); + error.set_backtrace(backtrace.into()); } - ErrorCode::ElementIdForMemberButElementIsNot(id) => { + ErrorCode::ElementIdForMemberButElementIsNot(id, backtrace) => { error.set_text( "You provided ID for Member but element's spec is not for \ Member." @@ -208,8 +246,9 @@ impl Into for ErrorCode { ); error.set_element(id); error.set_code(1105); + error.set_backtrace(backtrace.into()); } - ErrorCode::ElementIdForEndpointButElementIsNot(id) => { + ErrorCode::ElementIdForEndpointButElementIsNot(id, backtrace) => { error.set_text( "You provided ID for Endpoint but element's spec is not \ for Endpoint." @@ -217,62 +256,71 @@ impl Into for ErrorCode { ); error.set_element(id); error.set_code(1106); + error.set_backtrace(backtrace.into()); } - ErrorCode::InvalidElementUri(id) => { + ErrorCode::InvalidElementUri(id, backtrace) => { error.set_text("Invalid element's URI".to_string()); error.set_element(id); error.set_code(1107); + error.set_backtrace(backtrace.into()); } ///////////////////////////////// // Parse errors (1200 - 1299) // /////////////////////////////// - ErrorCode::ElementIdIsNotLocal(uri) => { + ErrorCode::ElementIdIsNotLocal(uri, backtrace) => { error.set_text( "Element's ID's URI has not have 'local://' protocol." .to_string(), ); error.set_element(uri); error.set_code(1200); + error.set_backtrace(backtrace.into()); } - ErrorCode::ElementIdIsTooLong(uri) => { + ErrorCode::ElementIdIsTooLong(uri, backtrace) => { error.set_text( "In provided element's ID too many slashes.".to_string(), ); error.set_element(uri); error.set_code(1201); + error.set_backtrace(backtrace.into()); } - ErrorCode::MissingFieldsInSrcUri(uri, fields) => { + ErrorCode::MissingFieldsInSrcUri(uri, fields, backtrace) => { error.set_text(format!( "Missing {:?} fields in element ID.", fields )); error.set_element(uri); error.set_code(1202); + error.set_backtrace(backtrace.into()); } - ErrorCode::EmptyElementId => { + ErrorCode::EmptyElementId(backtrace) => { error.set_text("Provided empty element ID.".to_string()); error.set_element(String::new()); error.set_code(1203); + error.set_backtrace(backtrace.into()); } ///////////////////////////// // Conflict (1300 - 1399) // /////////////////////////// - ErrorCode::MemberAlreadyExists(id) => { + ErrorCode::MemberAlreadyExists(id, backtrace) => { error.set_text("Member already exists.".to_string()); error.set_element(id.to_string()); error.set_code(1300); + error.set_backtrace(backtrace.into()); } - ErrorCode::EndpointAlreadyExists(id) => { + ErrorCode::EndpointAlreadyExists(id, backtrace) => { error.set_text("Endpoint already exists.".to_string()); error.set_element(id.to_string()); error.set_code(1301); + error.set_backtrace(backtrace.into()); } - ErrorCode::RoomAlreadyExists(id) => { + ErrorCode::RoomAlreadyExists(id, backtrace) => { error.set_text("Room already exists.".to_string()); error.set_element(id.to_string()); error.set_code(1302); + error.set_backtrace(backtrace.into()); } } diff --git a/src/media/peer.rs b/src/media/peer.rs index e3c331d2e..7c7720bb3 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -14,7 +14,7 @@ use medea_client_api_proto::{ use medea_macro::enum_delegate; use crate::{ - api::control::MemberId, + api::{control::MemberId, error_codes::Backtrace}, media::{MediaTrack, TrackId}, signalling::peers::Counter, }; @@ -60,6 +60,16 @@ impl PeerStateError { } } +impl Into for &PeerStateError { + fn into(self) -> Backtrace { + let mut backtrace = Backtrace::new(); + match self { + PeerStateError::WrongState(..) => backtrace.push(self), + } + backtrace + } +} + /// Implementation of ['Peer'] state machine. #[allow(clippy::module_name_repetitions)] #[enum_delegate(pub fn id(&self) -> Id)] diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index be02cace6..4f77aa52e 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -24,7 +24,7 @@ use crate::{ }; use super::endpoints::webrtc::{WebRtcPlayEndpoint, WebRtcPublishEndpoint}; -use crate::api::error_codes::ErrorCode; +use crate::api::error_codes::{Backtrace, ErrorCode}; /// Errors which may occur while loading [`Member`]s from [`RoomSpec`]. #[derive(Debug, Fail)] @@ -64,37 +64,70 @@ pub enum MemberError { impl Into for MembersLoadError { fn into(self) -> ErrorCode { + let backtrace: Backtrace = (&self).into(); match self { MembersLoadError::TryFromError(e, id) => match e { TryFromElementError::NotEndpoint => { - ErrorCode::NotEndpointInSpec(id) + ErrorCode::NotEndpointInSpec(id, backtrace) } TryFromElementError::NotMember => { - ErrorCode::NotMemberInSpec(id) + ErrorCode::NotMemberInSpec(id, backtrace) + } + TryFromElementError::NotRoom => { + ErrorCode::NotRoomInSpec(id, backtrace) } - TryFromElementError::NotRoom => ErrorCode::NotRoomInSpec(id), }, MembersLoadError::MemberNotFound(id) => { - ErrorCode::MemberNotFound(id) + ErrorCode::MemberNotFound(id, backtrace) } MembersLoadError::PublishEndpointNotFound(id) => { - ErrorCode::PublishEndpointNotFound(id) + ErrorCode::PublishEndpointNotFound(id, backtrace) } MembersLoadError::PlayEndpointNotFound(id) => { - ErrorCode::PlayEndpointNotFound(id) + ErrorCode::PlayEndpointNotFound(id, backtrace) + } + } + } +} +// TODO: fmt +impl Into for &MembersLoadError { + fn into(self) -> Backtrace { + let mut backtrace = Backtrace::new(); + backtrace.push(self); + match self { + MembersLoadError::TryFromError(e, _) => { + backtrace.merge(e.into()); + } + _ => {} + } + backtrace + } +} + +impl Into for &MemberError { + fn into(self) -> Backtrace { + let mut backtrace = Backtrace::new(); + match self { + MemberError::PlayEndpointNotFound(_) => { + backtrace.push(self); + } + MemberError::PublishEndpointNotFound(_) => { + backtrace.push(self); } } + backtrace } } impl Into for MemberError { fn into(self) -> ErrorCode { + let backtrace: Backtrace = (&self).into(); match self { MemberError::PlayEndpointNotFound(id) => { - ErrorCode::PlayEndpointNotFound(id) + ErrorCode::PlayEndpointNotFound(id, backtrace) } MemberError::PublishEndpointNotFound(id) => { - ErrorCode::PublishEndpointNotFound(id) + ErrorCode::PublishEndpointNotFound(id, backtrace) } } } diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index f382f17c5..c5a7cc827 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -36,7 +36,7 @@ use crate::{ MemberId, MemberSpec, RoomId, RoomSpec, WebRtcPlayId, WebRtcPublishId, }, - error_codes::ErrorCode, + error_codes::{Backtrace, ErrorCode}, }, log::prelude::*, media::IceUser, @@ -92,20 +92,41 @@ impl From for ParticipantServiceErr { } } +impl Into for &ParticipantServiceErr { + fn into(self) -> Backtrace { + let mut backtrace = Backtrace::new(); + backtrace.push(self); + match self { + ParticipantServiceErr::MemberError(e) => { + backtrace.merge(e.into()); + } + ParticipantServiceErr::TurnServiceErr(e) => { + backtrace.merge(e.into()); + } + ParticipantServiceErr::MailBoxErr(e) => { + backtrace.push(e); + } + _ => {} + } + backtrace + } +} + impl Into for ParticipantServiceErr { fn into(self) -> ErrorCode { - match self { + let backtrace: Backtrace = (&self).into(); + match &self { ParticipantServiceErr::EndpointNotFound(id) => { - ErrorCode::EndpointNotFound(id) + ErrorCode::EndpointNotFound(id.clone(), backtrace) } ParticipantServiceErr::ParticipantNotFound(id) => { - ErrorCode::MemberNotFound(id) + ErrorCode::MemberNotFound(id.clone(), backtrace) } ParticipantServiceErr::ParticipantAlreadyExists(id) => { - ErrorCode::MemberAlreadyExists(id) + ErrorCode::MemberAlreadyExists(id.clone(), backtrace) } ParticipantServiceErr::EndpointAlreadyExists(id) => { - ErrorCode::EndpointAlreadyExists(id) + ErrorCode::EndpointAlreadyExists(id.clone(), backtrace) } _ => ErrorCode::UnknownError(self.to_string()), } diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 5157a461b..cb727f716 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -30,7 +30,7 @@ use crate::{ Endpoint as EndpointSpec, MemberId, MemberSpec, RoomId, TryFromElementError, WebRtcPlayId, WebRtcPublishId, }, - error_codes::ErrorCode, + error_codes::{Backtrace, ErrorCode}, }, log::prelude::*, media::{ @@ -121,6 +121,38 @@ impl Into for RoomError { } } +impl Into for &RoomError { + fn into(self) -> Backtrace { + let mut backtrace = Backtrace::new(); + match self { + RoomError::MemberError(e) => { + backtrace.push(self); + backtrace.merge(e.into()); + } + RoomError::MembersLoadError(e) => { + backtrace.push(self); + backtrace.merge(e.into()); + } + RoomError::ParticipantServiceErr(e) => { + backtrace.push(self); + backtrace.merge(e.into()); + } + RoomError::PeerStateError(e) => { + backtrace.push(self); + backtrace.merge(e.into()); + } + RoomError::TryFromElementError(e) => { + backtrace.push(self); + backtrace.merge(e.into()) + } + _ => { + backtrace.push(self); + } + } + backtrace + } +} + /// Media server room with its [`Member`]s. #[derive(Debug)] pub struct Room { diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs index 89dacce7d..d65c18b75 100644 --- a/src/signalling/room_repo.rs +++ b/src/signalling/room_repo.rs @@ -17,7 +17,7 @@ use crate::{ local_uri::LocalUri, room::RoomSpec, Endpoint as EndpointSpec, MemberId, MemberSpec, RoomId, }, - error_codes::ErrorCode, + error_codes::{Backtrace, ErrorCode}, }, log::prelude::*, signalling::{ @@ -57,10 +57,13 @@ impl From for RoomRepoError { impl Into for RoomRepoError { fn into(self) -> ErrorCode { + let backtrace = (&self).into(); match self { - RoomRepoError::RoomNotFound(id) => ErrorCode::RoomNotFound(id), - RoomRepoError::RoomAlreadyExists(id) => { - ErrorCode::RoomAlreadyExists(id) + RoomRepoError::RoomNotFound(ref id) => { + ErrorCode::RoomNotFound(id.clone(), backtrace) + } + RoomRepoError::RoomAlreadyExists(ref id) => { + ErrorCode::RoomAlreadyExists(id.clone(), backtrace) } RoomRepoError::RoomError(e) => e.into(), _ => ErrorCode::UnknownError(self.to_string()), @@ -68,6 +71,26 @@ impl Into for RoomRepoError { } } +impl Into for &RoomRepoError { + fn into(self) -> Backtrace { + let mut backtrace = Backtrace::new(); + match self { + RoomRepoError::RoomNotFound(_) => backtrace.push(self), + RoomRepoError::RoomAlreadyExists(_) => backtrace.push(self), + RoomRepoError::RoomError(e) => { + backtrace.push(self); + backtrace.merge(e.into()); + } + RoomRepoError::MailboxError(e) => { + backtrace.push(self); + backtrace.push(e); + } + RoomRepoError::Unknow => {} + } + backtrace + } +} + impl From for RoomRepoError { fn from(e: MailboxError) -> Self { RoomRepoError::MailboxError(e) diff --git a/src/turn/repo.rs b/src/turn/repo.rs index 1b7044fe8..6013d23b1 100644 --- a/src/turn/repo.rs +++ b/src/turn/repo.rs @@ -10,7 +10,7 @@ use futures::future::Future; use redis::{ConnectionInfo, RedisError}; use tokio::prelude::*; -use crate::{log::prelude::*, media::IceUser}; +use crate::{api::error_codes::Backtrace, log::prelude::*, media::IceUser}; #[derive(Fail, Debug)] pub enum TurnDatabaseErr { @@ -24,6 +24,19 @@ impl From for TurnDatabaseErr { } } +impl Into for &TurnDatabaseErr { + fn into(self) -> Backtrace { + let mut backtrace = Backtrace::new(); + backtrace.push(self); + match self { + TurnDatabaseErr::RedisError(e) => { + backtrace.push(e); + } + } + backtrace + } +} + // Abstraction over remote Redis database used to store Turn server // credentials. #[allow(clippy::module_name_repetitions)] diff --git a/src/turn/service.rs b/src/turn/service.rs index 913e86e83..6354190ba 100644 --- a/src/turn/service.rs +++ b/src/turn/service.rs @@ -12,7 +12,10 @@ use rand::{distributions::Alphanumeric, Rng}; use redis::ConnectionInfo; use crate::{ - api::control::{MemberId, RoomId}, + api::{ + control::{MemberId, RoomId}, + error_codes::Backtrace, + }, conf::Conf, media::IceUser, turn::repo::{TurnDatabase, TurnDatabaseErr}, @@ -122,6 +125,24 @@ impl From for TurnServiceErr { } } +impl Into for &TurnServiceErr { + fn into(self) -> Backtrace { + let mut backtrace = Backtrace::new(); + backtrace.push(&self); + match self { + TurnServiceErr::TurnAuthRepoErr(e) => { + backtrace.merge(e.into()); + } + TurnServiceErr::MailboxErr(e) => { + backtrace.push(e); + } + TurnServiceErr::TimedOut => {} + } + + backtrace + } +} + /// Defines [`TurnAuthService`] behaviour if remote database is unreachable #[derive(Debug)] pub enum UnreachablePolicy { From 74fb97a48a6cd59eb750c70551d657d250790e15 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 15 Jul 2019 15:21:32 +0300 Subject: [PATCH 358/735] Some docs and TODOs --- src/api/error_codes.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/api/error_codes.rs b/src/api/error_codes.rs index cce71a5fa..94757825b 100644 --- a/src/api/error_codes.rs +++ b/src/api/error_codes.rs @@ -7,24 +7,29 @@ //! * __1200...1299__ Parse errors //! * __1300...1399__ Conflicts +use lazy_static::lazy_static; use protobuf::RepeatedField; use crate::api::control::{ grpc::protos::control::Error as ErrorProto, local_uri::LocalUri, }; +/// Backtrace of nested errors for debugging purposes. #[derive(Debug)] pub struct Backtrace(pub Vec); impl Backtrace { + /// Create new empty [`Backtrace`]. pub fn new() -> Self { Self(Vec::new()) } + /// Add error to [`Backtrace`]. pub fn push(&mut self, error: &T) { self.0.push(format!("{:?}", error)); } + /// Merge this [`Backtrace`] with another [`Backtrace`]. pub fn merge(&mut self, mut another_backtrace: Backtrace) { self.0.append(&mut another_backtrace.0); } @@ -148,6 +153,7 @@ pub enum ErrorCode { impl Into for ErrorCode { fn into(self) -> ErrorProto { + // TODO: configure backtrace let mut error = ErrorProto::new(); match self { ErrorCode::UnknownError(msg) => { From d0574afc04a8c6c5c29b69aaf2338b38cb09a7a7 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 15 Jul 2019 15:43:44 +0300 Subject: [PATCH 359/735] Add host config --- config.toml | 5 +++++ src/api/error_codes.rs | 1 - src/conf/mod.rs | 5 +---- src/conf/server.rs | 4 ++++ 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/config.toml b/config.toml index 6449ac3dd..75510d9e0 100644 --- a/config.toml +++ b/config.toml @@ -1,4 +1,9 @@ [server] +# Server host +# +# Default: +# host = "localhost:8080" + # IP address to bind HTTP server to. # # Default: diff --git a/src/api/error_codes.rs b/src/api/error_codes.rs index 94757825b..b31450dab 100644 --- a/src/api/error_codes.rs +++ b/src/api/error_codes.rs @@ -7,7 +7,6 @@ //! * __1200...1299__ Parse errors //! * __1300...1399__ Conflicts -use lazy_static::lazy_static; use protobuf::RepeatedField; use crate::api::control::{ diff --git a/src/conf/mod.rs b/src/conf/mod.rs index 60e7aae4c..1600f9c2a 100644 --- a/src/conf/mod.rs +++ b/src/conf/mod.rs @@ -60,10 +60,7 @@ impl Conf { } pub fn get_base_rpc_url(&self) -> String { - // TODO: maybe create host config value and use it? - let addr = &self.server.bind_ip; - let port = self.server.bind_port; - format!("wss://{}:{}", addr, port) + format!("wss://{}", self.server.host) } } diff --git a/src/conf/server.rs b/src/conf/server.rs index e7e53a99e..3e1167221 100644 --- a/src/conf/server.rs +++ b/src/conf/server.rs @@ -9,6 +9,10 @@ use smart_default::SmartDefault; #[derive(Clone, Debug, Deserialize, Serialize, SmartDefault)] #[serde(default)] pub struct Server { + /// Server host. + #[default("localhost:8080".to_string())] + pub host: String, + /// IP address to bind HTTP server to. Defaults to `0.0.0.0`. #[default(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)))] pub bind_ip: IpAddr, From 1681ebaf37e8e149c6b898655ddb9009a4c4e78b Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 15 Jul 2019 18:41:31 +0300 Subject: [PATCH 360/735] Fix panic, e2e-demo --- dev/specs/pub_pub_video_call.yml | 34 ++++++++++ jason/e2e-demo/js/index.js | 4 +- src/lib.rs | 78 ++++++++++++++--------- src/main.rs | 27 ++++---- src/signalling/participants.rs | 13 ++-- src/signalling/room.rs | 3 +- tests/e2e/signalling/mod.rs | 38 +++++++---- tests/e2e/signalling/pub_sub_signallng.rs | 6 +- tests/e2e/signalling/three_pubs.rs | 5 +- 9 files changed, 142 insertions(+), 66 deletions(-) create mode 100644 dev/specs/pub_pub_video_call.yml diff --git a/dev/specs/pub_pub_video_call.yml b/dev/specs/pub_pub_video_call.yml new file mode 100644 index 000000000..560cf0ecb --- /dev/null +++ b/dev/specs/pub_pub_video_call.yml @@ -0,0 +1,34 @@ +kind: Room +id: pub-pub-video-call +spec: + pipeline: + # Here we're defining a member who initiates video call. + caller: + kind: Member + credentials: test + spec: + pipeline: + # Media element which is able to receive media data from client via WebRTC. + publish: + kind: WebRtcPublishEndpoint + spec: + # Actually, it receives not media data, but ICE candidates only. + p2p: Always + # Media element which is able to play media data for client via WebRTC. + play: + kind: WebRtcPlayEndpoint + spec: + src: "local://pub-pub-video-call/responder/publish" + responder: + kind: Member + credentials: test + spec: + pipeline: + publish: + kind: WebRtcPublishEndpoint + spec: + p2p: Always + play: + kind: WebRtcPlayEndpoint + spec: + src: "local://pub-pub-video-call/caller/publish" diff --git a/jason/e2e-demo/js/index.js b/jason/e2e-demo/js/index.js index c604a2787..d245aba5d 100644 --- a/jason/e2e-demo/js/index.js +++ b/jason/e2e-demo/js/index.js @@ -4,8 +4,8 @@ async function f() { let caller = new rust.Jason(); let responder = new rust.Jason(); - let caller_room = await caller.join_room("ws://localhost:8080/ws/1/1/caller_credentials"); - let responder_room = await responder.join_room("ws://localhost:8080/ws/1/2/responder_credentials"); + let caller_room = await caller.join_room("ws://localhost:8080/ws/pub-pub-video-call/caller/test"); + let responder_room = await responder.join_room("ws://localhost:8080/ws/pub-pub-video-call/responder/test"); caller_room.on_new_connection(function (connection) { console.log("caller got new connection with member " + connection.member_id()); diff --git a/src/lib.rs b/src/lib.rs index 1236b190f..fd9362a47 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -17,9 +17,11 @@ use crate::{ api::control::{load_static_specs_from_dir, RoomId}, conf::Conf, signalling::{room::RoomError, Room}, - turn::service, + turn::{service, TurnServiceErr}, }; use bb8::Pool; +use futures::future::Either; +use std::sync::{Arc, Mutex}; /// Errors which can happen while server starting. #[derive(Debug, Fail)] @@ -60,38 +62,54 @@ impl From for ServerStartError { /// Returns [`ServerStartError::BadRoomSpec`] /// if some error happened while creating room from spec. pub fn start_static_rooms( - config: &Conf, -) -> Result>, ServerStartError> { - if let Some(static_specs_path) = &config.server.static_specs_path { - let room_specs = match load_static_specs_from_dir(static_specs_path) { - Ok(r) => r, - Err(e) => return Err(ServerStartError::LoadSpec(e)), - }; - let mut rooms = HashMap::new(); - let arbiter = Arbiter::new(); + conf: &Conf, +) -> impl Future< + Item = Result>, ServerStartError>, + Error = TurnServiceErr, +> { + let config = conf.clone(); + if let Some(static_specs_path) = config.server.static_specs_path.clone() { + Either::A( + service::new_turn_auth_service(&config.turn) + .map(|t| Arc::new(Mutex::new(t))) + .map(move |turn_auth_service| { + let room_specs = + match load_static_specs_from_dir(static_specs_path) { + Ok(r) => r, + Err(e) => { + return Err(ServerStartError::LoadSpec(e)) + } + }; + let mut rooms = HashMap::new(); + let arbiter = Arbiter::new(); - for spec in room_specs { - if rooms.contains_key(spec.id()) { - return Err(ServerStartError::DuplicateRoomId( - spec.id().clone(), - )); - } + for spec in room_specs { + if rooms.contains_key(spec.id()) { + return Err(ServerStartError::DuplicateRoomId( + spec.id().clone(), + )); + } - let turn_auth_service = service::new_turn_auth_service(&config.turn) - .wait() - .expect("Unable to start turn service"); + let room_id = spec.id().clone(); + let rpc_reconnect_timeout = + config.rpc.reconnect_timeout; + let turn_cloned = Arc::clone(&turn_auth_service); + let room = + Room::start_in_arbiter(&arbiter, move |_| { + Room::new( + &spec, + rpc_reconnect_timeout, + turn_cloned, + ) + .unwrap() + }); + rooms.insert(room_id, room); + } - let room_id = spec.id().clone(); - let rpc_reconnect_timeout = config.rpc.reconnect_timeout; - let room = Room::start_in_arbiter(&arbiter, move |_| { - Room::new(&spec, rpc_reconnect_timeout, turn_auth_service) - .unwrap() - }); - rooms.insert(room_id, room); - } - - Ok(rooms) + Ok(rooms) + }), + ) } else { - Ok(HashMap::new()) + Either::B(futures::future::ok(Ok(HashMap::new()))) } } diff --git a/src/main.rs b/src/main.rs index de26a57d2..87633521f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,6 @@ use actix::System; use failure::Error; +use futures::future::Future; use medea::{ api::client::server, conf::Conf, @@ -14,20 +15,24 @@ fn main() -> Result<(), Error> { let _scope_guard = slog_scope::set_global_logger(logger); slog_stdlog::init()?; - let sys = System::new("medea"); - let config = Conf::parse()?; info!("{:?}", config); - let rooms = start_static_rooms(&config)?; - info!( - "Loaded rooms: {:?}", - rooms.iter().map(|(id, _)| &id.0).collect::>() - ); - let room_repo = RoomsRepository::new(rooms); - server::run(room_repo, config); - - let _ = sys.run(); + actix::run(|| { + start_static_rooms(&config) + .map_err(|e| error!("Turn: {:?}", e)) + .and_then(|res| { + let rooms = res.unwrap(); + info!( + "Loaded rooms: {:?}", + rooms.iter().map(|(id, _)| &id.0).collect::>() + ); + let room_repo = RoomsRepository::new(rooms); + server::run(room_repo, config) + .map_err(|e| error!("Server {:?}", e)) + }) + }) + .unwrap(); Ok(()) } diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 95507d538..59cc68abb 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -37,6 +37,7 @@ use crate::{ }, turn::{TurnAuthService, TurnServiceErr, UnreachablePolicy}, }; +use std::sync::{Arc, Mutex}; #[derive(Fail, Debug)] #[allow(clippy::module_name_repetitions)] @@ -76,7 +77,7 @@ pub struct ParticipantService { members: HashMap>, /// Service for managing authorization on Turn server. - turn: Box, + turn: Arc>>, /// Established [`RpcConnection`]s of [`Members`]s in this [`Room`]. // TODO: Replace Box> with enum, @@ -98,7 +99,7 @@ impl ParticipantService { pub fn new( room_spec: &RoomSpec, reconnect_timeout: Duration, - turn: Box, + turn: Arc>>, ) -> Result { Ok(Self { room_id: room_spec.id().clone(), @@ -191,7 +192,7 @@ impl ParticipantService { Box::new(wrap_future(connection.close().then(move |_| Ok(member)))) } else { Box::new( - wrap_future(self.turn.create( + wrap_future(self.turn.lock().unwrap().create( member_id.clone(), self.room_id.clone(), UnreachablePolicy::ReturnErr, @@ -270,7 +271,9 @@ impl ParticipantService { ) -> Box> { match self.get_member_by_id(&member_id) { Some(member) => match member.take_ice_user() { - Some(ice_user) => self.turn.delete(vec![ice_user]), + Some(ice_user) => { + self.turn.lock().unwrap().delete(vec![ice_user]) + } None => Box::new(future::ok(())), }, None => Box::new(future::ok(())), @@ -306,6 +309,8 @@ impl ParticipantService { } }); self.turn + .lock() + .unwrap() .delete(room_users) .map_err(|err| error!("Error removing IceUsers {:?}", err)) }); diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 8593ab300..9f696a9f9 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -35,6 +35,7 @@ use crate::{ }, turn::TurnAuthService, }; +use std::sync::{Arc, Mutex}; /// Ergonomic type alias for using [`ActorFuture`] for [`Room`]. pub type ActFuture = @@ -107,7 +108,7 @@ impl Room { pub fn new( room_spec: &RoomSpec, reconnect_timeout: Duration, - turn: Box, + turn: Arc>>, ) -> Result { Ok(Self { id: room_spec.id().clone(), diff --git a/tests/e2e/signalling/mod.rs b/tests/e2e/signalling/mod.rs index 9663eceb4..c68454bb4 100644 --- a/tests/e2e/signalling/mod.rs +++ b/tests/e2e/signalling/mod.rs @@ -16,8 +16,9 @@ use awc::{ BoxedSocket, }; use futures::{future::Future, sink::Sink, stream::SplitSink, Stream}; -use medea_client_api_proto::{Command, Event, IceCandidate}; +use medea_client_api_proto::{Command, Direction, Event, IceCandidate}; use serde_json::error::Error as SerdeError; +use std::collections::HashMap; /// Medea client for testing purposes. pub struct TestMember { @@ -137,23 +138,32 @@ impl StreamHandler for TestMember { (self.test_fn)(&event, ctx); if let Event::PeerCreated { - peer_id, sdp_offer, .. + peer_id, + sdp_offer, + tracks, + .. } = event { match sdp_offer { - Some(_) => { - self.send_command(Command::MakeSdpAnswer { - peer_id, - sdp_answer: "responder_answer".to_string(), - }); - } - None => { - self.send_command(Command::MakeSdpOffer { - peer_id, - sdp_offer: "caller_offer".to_string(), - }); - } + Some(_) => self.send_command(Command::MakeSdpAnswer { + peer_id, + sdp_answer: "responder_answer".into(), + }), + None => self.send_command(Command::MakeSdpOffer { + peer_id, + sdp_offer: "caller_offer".into(), + mids: tracks + .into_iter() + .filter_map(|t| match t.direction { + Direction::Send { .. } => Some(t.id), + Direction::Recv { .. } => None, + }) + .enumerate() + .map(|(mid, id)| (id, mid.to_string())) + .collect(), + }), } + self.send_command(Command::SetIceCandidate { peer_id, candidate: IceCandidate { diff --git a/tests/e2e/signalling/pub_sub_signallng.rs b/tests/e2e/signalling/pub_sub_signallng.rs index 1bc70b728..c1ad56142 100644 --- a/tests/e2e/signalling/pub_sub_signallng.rs +++ b/tests/e2e/signalling/pub_sub_signallng.rs @@ -55,11 +55,13 @@ fn pub_sub_video_call() { assert_eq!(tracks.len(), 2); for track in tracks { match &track.direction { - Direction::Send { receivers } => { + // TODO + Direction::Send { receivers, mid } => { assert!(is_caller); assert!(!receivers.contains(&peer_id)); } - Direction::Recv { sender } => { + // TODO + Direction::Recv { sender, mid } => { assert!(!is_caller); assert_ne!(sender, peer_id); } diff --git a/tests/e2e/signalling/three_pubs.rs b/tests/e2e/signalling/three_pubs.rs index c97177444..9c838194a 100644 --- a/tests/e2e/signalling/three_pubs.rs +++ b/tests/e2e/signalling/three_pubs.rs @@ -58,7 +58,8 @@ fn three_members_p2p_video_call() { let recv_count = tracks .iter() .filter_map(|t| match &t.direction { - Direction::Recv { sender } => { + // TODO + Direction::Recv { sender, mid } => { Some(sender) } _ => None, @@ -72,7 +73,7 @@ fn three_members_p2p_video_call() { let send_count = tracks .iter() .filter_map(|t| match &t.direction { - Direction::Send { receivers } => { + Direction::Send { receivers, mid } => { Some(receivers) } _ => None, From 220cba024606d64ea82727b2d30245b2f59ac697 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 15 Jul 2019 19:44:09 +0300 Subject: [PATCH 361/735] Fix e2e test --- src/api/control/grpc/protos/control.rs | 6109 +++++++++++++++++++ src/api/control/grpc/protos/control_grpc.rs | 155 + tests/e2e/signalling/mod.rs | 5 +- 3 files changed, 6265 insertions(+), 4 deletions(-) create mode 100644 src/api/control/grpc/protos/control.rs create mode 100644 src/api/control/grpc/protos/control_grpc.rs diff --git a/src/api/control/grpc/protos/control.rs b/src/api/control/grpc/protos/control.rs new file mode 100644 index 000000000..eb945dbde --- /dev/null +++ b/src/api/control/grpc/protos/control.rs @@ -0,0 +1,6109 @@ +// This file is generated by rust-protobuf 2.7.0. Do not edit +// @generated + +// https://github.com/Manishearth/rust-clippy/issues/702 +#![allow(unknown_lints)] +#![allow(clippy::all)] + +#![cfg_attr(rustfmt, rustfmt_skip)] + +#![allow(box_pointers)] +#![allow(dead_code)] +#![allow(missing_docs)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] +#![allow(non_upper_case_globals)] +#![allow(trivial_casts)] +#![allow(unsafe_code)] +#![allow(unused_imports)] +#![allow(unused_results)] +//! Generated file from `control.proto` + +use protobuf::Message as Message_imported_for_functions; +use protobuf::ProtobufEnum as ProtobufEnum_imported_for_functions; + +/// Generated files are compatible only with the same version +/// of protobuf runtime. +const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_7_0; + +#[derive(PartialEq,Clone,Default)] +pub struct CreateRequest { + // message fields + pub id: ::std::string::String, + // message oneof groups + pub el: ::std::option::Option, + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a CreateRequest { + fn default() -> &'a CreateRequest { + ::default_instance() + } +} + +#[derive(Clone,PartialEq,Debug)] +pub enum CreateRequest_oneof_el { + hub(Hub), + file_recorder(FileRecorder), + member(Member), + relay(Relay), + room(Room), + webrtc_play(WebRtcPlayEndpoint), + webrtc_pub(WebRtcPublishEndpoint), +} + +impl CreateRequest { + pub fn new() -> CreateRequest { + ::std::default::Default::default() + } + + // string id = 1; + + + pub fn get_id(&self) -> &str { + &self.id + } + pub fn clear_id(&mut self) { + self.id.clear(); + } + + // Param is passed by value, moved + pub fn set_id(&mut self, v: ::std::string::String) { + self.id = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_id(&mut self) -> &mut ::std::string::String { + &mut self.id + } + + // Take field + pub fn take_id(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.id, ::std::string::String::new()) + } + + // .medea.Hub hub = 2; + + + pub fn get_hub(&self) -> &Hub { + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::hub(ref v)) => v, + _ => Hub::default_instance(), + } + } + pub fn clear_hub(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_hub(&self) -> bool { + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::hub(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_hub(&mut self, v: Hub) { + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::hub(v)) + } + + // Mutable pointer to the field. + pub fn mut_hub(&mut self) -> &mut Hub { + if let ::std::option::Option::Some(CreateRequest_oneof_el::hub(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::hub(Hub::new())); + } + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::hub(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_hub(&mut self) -> Hub { + if self.has_hub() { + match self.el.take() { + ::std::option::Option::Some(CreateRequest_oneof_el::hub(v)) => v, + _ => panic!(), + } + } else { + Hub::new() + } + } + + // .medea.FileRecorder file_recorder = 3; + + + pub fn get_file_recorder(&self) -> &FileRecorder { + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::file_recorder(ref v)) => v, + _ => FileRecorder::default_instance(), + } + } + pub fn clear_file_recorder(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_file_recorder(&self) -> bool { + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::file_recorder(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_file_recorder(&mut self, v: FileRecorder) { + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::file_recorder(v)) + } + + // Mutable pointer to the field. + pub fn mut_file_recorder(&mut self) -> &mut FileRecorder { + if let ::std::option::Option::Some(CreateRequest_oneof_el::file_recorder(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::file_recorder(FileRecorder::new())); + } + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::file_recorder(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_file_recorder(&mut self) -> FileRecorder { + if self.has_file_recorder() { + match self.el.take() { + ::std::option::Option::Some(CreateRequest_oneof_el::file_recorder(v)) => v, + _ => panic!(), + } + } else { + FileRecorder::new() + } + } + + // .medea.Member member = 4; + + + pub fn get_member(&self) -> &Member { + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::member(ref v)) => v, + _ => Member::default_instance(), + } + } + pub fn clear_member(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_member(&self) -> bool { + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::member(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_member(&mut self, v: Member) { + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::member(v)) + } + + // Mutable pointer to the field. + pub fn mut_member(&mut self) -> &mut Member { + if let ::std::option::Option::Some(CreateRequest_oneof_el::member(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::member(Member::new())); + } + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::member(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_member(&mut self) -> Member { + if self.has_member() { + match self.el.take() { + ::std::option::Option::Some(CreateRequest_oneof_el::member(v)) => v, + _ => panic!(), + } + } else { + Member::new() + } + } + + // .medea.Relay relay = 5; + + + pub fn get_relay(&self) -> &Relay { + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::relay(ref v)) => v, + _ => Relay::default_instance(), + } + } + pub fn clear_relay(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_relay(&self) -> bool { + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::relay(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_relay(&mut self, v: Relay) { + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::relay(v)) + } + + // Mutable pointer to the field. + pub fn mut_relay(&mut self) -> &mut Relay { + if let ::std::option::Option::Some(CreateRequest_oneof_el::relay(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::relay(Relay::new())); + } + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::relay(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_relay(&mut self) -> Relay { + if self.has_relay() { + match self.el.take() { + ::std::option::Option::Some(CreateRequest_oneof_el::relay(v)) => v, + _ => panic!(), + } + } else { + Relay::new() + } + } + + // .medea.Room room = 6; + + + pub fn get_room(&self) -> &Room { + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::room(ref v)) => v, + _ => Room::default_instance(), + } + } + pub fn clear_room(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_room(&self) -> bool { + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::room(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_room(&mut self, v: Room) { + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::room(v)) + } + + // Mutable pointer to the field. + pub fn mut_room(&mut self) -> &mut Room { + if let ::std::option::Option::Some(CreateRequest_oneof_el::room(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::room(Room::new())); + } + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::room(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_room(&mut self) -> Room { + if self.has_room() { + match self.el.take() { + ::std::option::Option::Some(CreateRequest_oneof_el::room(v)) => v, + _ => panic!(), + } + } else { + Room::new() + } + } + + // .medea.WebRtcPlayEndpoint webrtc_play = 7; + + + pub fn get_webrtc_play(&self) -> &WebRtcPlayEndpoint { + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_play(ref v)) => v, + _ => WebRtcPlayEndpoint::default_instance(), + } + } + pub fn clear_webrtc_play(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_webrtc_play(&self) -> bool { + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_play(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_webrtc_play(&mut self, v: WebRtcPlayEndpoint) { + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_play(v)) + } + + // Mutable pointer to the field. + pub fn mut_webrtc_play(&mut self) -> &mut WebRtcPlayEndpoint { + if let ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_play(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_play(WebRtcPlayEndpoint::new())); + } + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_play(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_webrtc_play(&mut self) -> WebRtcPlayEndpoint { + if self.has_webrtc_play() { + match self.el.take() { + ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_play(v)) => v, + _ => panic!(), + } + } else { + WebRtcPlayEndpoint::new() + } + } + + // .medea.WebRtcPublishEndpoint webrtc_pub = 8; + + + pub fn get_webrtc_pub(&self) -> &WebRtcPublishEndpoint { + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_pub(ref v)) => v, + _ => WebRtcPublishEndpoint::default_instance(), + } + } + pub fn clear_webrtc_pub(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_webrtc_pub(&self) -> bool { + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_pub(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_webrtc_pub(&mut self, v: WebRtcPublishEndpoint) { + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_pub(v)) + } + + // Mutable pointer to the field. + pub fn mut_webrtc_pub(&mut self) -> &mut WebRtcPublishEndpoint { + if let ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_pub(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_pub(WebRtcPublishEndpoint::new())); + } + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_pub(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_webrtc_pub(&mut self) -> WebRtcPublishEndpoint { + if self.has_webrtc_pub() { + match self.el.take() { + ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_pub(v)) => v, + _ => panic!(), + } + } else { + WebRtcPublishEndpoint::new() + } + } +} + +impl ::protobuf::Message for CreateRequest { + fn is_initialized(&self) -> bool { + if let Some(CreateRequest_oneof_el::hub(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(CreateRequest_oneof_el::file_recorder(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(CreateRequest_oneof_el::member(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(CreateRequest_oneof_el::relay(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(CreateRequest_oneof_el::room(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(CreateRequest_oneof_el::webrtc_play(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(CreateRequest_oneof_el::webrtc_pub(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.id)?; + }, + 2 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::hub(is.read_message()?)); + }, + 3 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::file_recorder(is.read_message()?)); + }, + 4 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::member(is.read_message()?)); + }, + 5 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::relay(is.read_message()?)); + }, + 6 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::room(is.read_message()?)); + }, + 7 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_play(is.read_message()?)); + }, + 8 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_pub(is.read_message()?)); + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if !self.id.is_empty() { + my_size += ::protobuf::rt::string_size(1, &self.id); + } + if let ::std::option::Option::Some(ref v) = self.el { + match v { + &CreateRequest_oneof_el::hub(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &CreateRequest_oneof_el::file_recorder(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &CreateRequest_oneof_el::member(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &CreateRequest_oneof_el::relay(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &CreateRequest_oneof_el::room(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &CreateRequest_oneof_el::webrtc_play(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &CreateRequest_oneof_el::webrtc_pub(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + }; + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + if !self.id.is_empty() { + os.write_string(1, &self.id)?; + } + if let ::std::option::Option::Some(ref v) = self.el { + match v { + &CreateRequest_oneof_el::hub(ref v) => { + os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &CreateRequest_oneof_el::file_recorder(ref v) => { + os.write_tag(3, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &CreateRequest_oneof_el::member(ref v) => { + os.write_tag(4, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &CreateRequest_oneof_el::relay(ref v) => { + os.write_tag(5, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &CreateRequest_oneof_el::room(ref v) => { + os.write_tag(6, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &CreateRequest_oneof_el::webrtc_play(ref v) => { + os.write_tag(7, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &CreateRequest_oneof_el::webrtc_pub(ref v) => { + os.write_tag(8, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + }; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> CreateRequest { + CreateRequest::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "id", + |m: &CreateRequest| { &m.id }, + |m: &mut CreateRequest| { &mut m.id }, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Hub>( + "hub", + CreateRequest::has_hub, + CreateRequest::get_hub, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, FileRecorder>( + "file_recorder", + CreateRequest::has_file_recorder, + CreateRequest::get_file_recorder, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Member>( + "member", + CreateRequest::has_member, + CreateRequest::get_member, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Relay>( + "relay", + CreateRequest::has_relay, + CreateRequest::get_relay, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Room>( + "room", + CreateRequest::has_room, + CreateRequest::get_room, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPlayEndpoint>( + "webrtc_play", + CreateRequest::has_webrtc_play, + CreateRequest::get_webrtc_play, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPublishEndpoint>( + "webrtc_pub", + CreateRequest::has_webrtc_pub, + CreateRequest::get_webrtc_pub, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "CreateRequest", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static CreateRequest { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const CreateRequest, + }; + unsafe { + instance.get(CreateRequest::new) + } + } +} + +impl ::protobuf::Clear for CreateRequest { + fn clear(&mut self) { + self.id.clear(); + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for CreateRequest { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for CreateRequest { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct ApplyRequest { + // message fields + pub id: ::std::string::String, + pub policy: ApplyRequest_Policy, + // message oneof groups + pub el: ::std::option::Option, + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a ApplyRequest { + fn default() -> &'a ApplyRequest { + ::default_instance() + } +} + +#[derive(Clone,PartialEq,Debug)] +pub enum ApplyRequest_oneof_el { + hub(Hub), + file_recorder(FileRecorder), + member(Member), + relay(Relay), + room(Room), + webrtc_play(WebRtcPlayEndpoint), + webrtc_pub(WebRtcPublishEndpoint), +} + +impl ApplyRequest { + pub fn new() -> ApplyRequest { + ::std::default::Default::default() + } + + // string id = 1; + + + pub fn get_id(&self) -> &str { + &self.id + } + pub fn clear_id(&mut self) { + self.id.clear(); + } + + // Param is passed by value, moved + pub fn set_id(&mut self, v: ::std::string::String) { + self.id = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_id(&mut self) -> &mut ::std::string::String { + &mut self.id + } + + // Take field + pub fn take_id(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.id, ::std::string::String::new()) + } + + // .medea.Hub hub = 2; + + + pub fn get_hub(&self) -> &Hub { + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::hub(ref v)) => v, + _ => Hub::default_instance(), + } + } + pub fn clear_hub(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_hub(&self) -> bool { + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::hub(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_hub(&mut self, v: Hub) { + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::hub(v)) + } + + // Mutable pointer to the field. + pub fn mut_hub(&mut self) -> &mut Hub { + if let ::std::option::Option::Some(ApplyRequest_oneof_el::hub(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::hub(Hub::new())); + } + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::hub(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_hub(&mut self) -> Hub { + if self.has_hub() { + match self.el.take() { + ::std::option::Option::Some(ApplyRequest_oneof_el::hub(v)) => v, + _ => panic!(), + } + } else { + Hub::new() + } + } + + // .medea.FileRecorder file_recorder = 3; + + + pub fn get_file_recorder(&self) -> &FileRecorder { + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::file_recorder(ref v)) => v, + _ => FileRecorder::default_instance(), + } + } + pub fn clear_file_recorder(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_file_recorder(&self) -> bool { + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::file_recorder(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_file_recorder(&mut self, v: FileRecorder) { + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::file_recorder(v)) + } + + // Mutable pointer to the field. + pub fn mut_file_recorder(&mut self) -> &mut FileRecorder { + if let ::std::option::Option::Some(ApplyRequest_oneof_el::file_recorder(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::file_recorder(FileRecorder::new())); + } + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::file_recorder(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_file_recorder(&mut self) -> FileRecorder { + if self.has_file_recorder() { + match self.el.take() { + ::std::option::Option::Some(ApplyRequest_oneof_el::file_recorder(v)) => v, + _ => panic!(), + } + } else { + FileRecorder::new() + } + } + + // .medea.Member member = 4; + + + pub fn get_member(&self) -> &Member { + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::member(ref v)) => v, + _ => Member::default_instance(), + } + } + pub fn clear_member(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_member(&self) -> bool { + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::member(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_member(&mut self, v: Member) { + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::member(v)) + } + + // Mutable pointer to the field. + pub fn mut_member(&mut self) -> &mut Member { + if let ::std::option::Option::Some(ApplyRequest_oneof_el::member(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::member(Member::new())); + } + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::member(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_member(&mut self) -> Member { + if self.has_member() { + match self.el.take() { + ::std::option::Option::Some(ApplyRequest_oneof_el::member(v)) => v, + _ => panic!(), + } + } else { + Member::new() + } + } + + // .medea.Relay relay = 5; + + + pub fn get_relay(&self) -> &Relay { + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::relay(ref v)) => v, + _ => Relay::default_instance(), + } + } + pub fn clear_relay(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_relay(&self) -> bool { + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::relay(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_relay(&mut self, v: Relay) { + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::relay(v)) + } + + // Mutable pointer to the field. + pub fn mut_relay(&mut self) -> &mut Relay { + if let ::std::option::Option::Some(ApplyRequest_oneof_el::relay(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::relay(Relay::new())); + } + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::relay(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_relay(&mut self) -> Relay { + if self.has_relay() { + match self.el.take() { + ::std::option::Option::Some(ApplyRequest_oneof_el::relay(v)) => v, + _ => panic!(), + } + } else { + Relay::new() + } + } + + // .medea.Room room = 6; + + + pub fn get_room(&self) -> &Room { + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::room(ref v)) => v, + _ => Room::default_instance(), + } + } + pub fn clear_room(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_room(&self) -> bool { + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::room(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_room(&mut self, v: Room) { + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::room(v)) + } + + // Mutable pointer to the field. + pub fn mut_room(&mut self) -> &mut Room { + if let ::std::option::Option::Some(ApplyRequest_oneof_el::room(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::room(Room::new())); + } + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::room(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_room(&mut self) -> Room { + if self.has_room() { + match self.el.take() { + ::std::option::Option::Some(ApplyRequest_oneof_el::room(v)) => v, + _ => panic!(), + } + } else { + Room::new() + } + } + + // .medea.WebRtcPlayEndpoint webrtc_play = 7; + + + pub fn get_webrtc_play(&self) -> &WebRtcPlayEndpoint { + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(ref v)) => v, + _ => WebRtcPlayEndpoint::default_instance(), + } + } + pub fn clear_webrtc_play(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_webrtc_play(&self) -> bool { + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_webrtc_play(&mut self, v: WebRtcPlayEndpoint) { + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(v)) + } + + // Mutable pointer to the field. + pub fn mut_webrtc_play(&mut self) -> &mut WebRtcPlayEndpoint { + if let ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(WebRtcPlayEndpoint::new())); + } + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_webrtc_play(&mut self) -> WebRtcPlayEndpoint { + if self.has_webrtc_play() { + match self.el.take() { + ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(v)) => v, + _ => panic!(), + } + } else { + WebRtcPlayEndpoint::new() + } + } + + // .medea.WebRtcPublishEndpoint webrtc_pub = 8; + + + pub fn get_webrtc_pub(&self) -> &WebRtcPublishEndpoint { + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(ref v)) => v, + _ => WebRtcPublishEndpoint::default_instance(), + } + } + pub fn clear_webrtc_pub(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_webrtc_pub(&self) -> bool { + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_webrtc_pub(&mut self, v: WebRtcPublishEndpoint) { + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(v)) + } + + // Mutable pointer to the field. + pub fn mut_webrtc_pub(&mut self) -> &mut WebRtcPublishEndpoint { + if let ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(WebRtcPublishEndpoint::new())); + } + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_webrtc_pub(&mut self) -> WebRtcPublishEndpoint { + if self.has_webrtc_pub() { + match self.el.take() { + ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(v)) => v, + _ => panic!(), + } + } else { + WebRtcPublishEndpoint::new() + } + } + + // .medea.ApplyRequest.Policy policy = 9; + + + pub fn get_policy(&self) -> ApplyRequest_Policy { + self.policy + } + pub fn clear_policy(&mut self) { + self.policy = ApplyRequest_Policy::APPLY; + } + + // Param is passed by value, moved + pub fn set_policy(&mut self, v: ApplyRequest_Policy) { + self.policy = v; + } +} + +impl ::protobuf::Message for ApplyRequest { + fn is_initialized(&self) -> bool { + if let Some(ApplyRequest_oneof_el::hub(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(ApplyRequest_oneof_el::file_recorder(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(ApplyRequest_oneof_el::member(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(ApplyRequest_oneof_el::relay(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(ApplyRequest_oneof_el::room(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(ApplyRequest_oneof_el::webrtc_play(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(ApplyRequest_oneof_el::webrtc_pub(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.id)?; + }, + 2 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::hub(is.read_message()?)); + }, + 3 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::file_recorder(is.read_message()?)); + }, + 4 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::member(is.read_message()?)); + }, + 5 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::relay(is.read_message()?)); + }, + 6 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::room(is.read_message()?)); + }, + 7 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(is.read_message()?)); + }, + 8 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(is.read_message()?)); + }, + 9 => { + ::protobuf::rt::read_proto3_enum_with_unknown_fields_into(wire_type, is, &mut self.policy, 9, &mut self.unknown_fields)? + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if !self.id.is_empty() { + my_size += ::protobuf::rt::string_size(1, &self.id); + } + if self.policy != ApplyRequest_Policy::APPLY { + my_size += ::protobuf::rt::enum_size(9, self.policy); + } + if let ::std::option::Option::Some(ref v) = self.el { + match v { + &ApplyRequest_oneof_el::hub(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &ApplyRequest_oneof_el::file_recorder(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &ApplyRequest_oneof_el::member(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &ApplyRequest_oneof_el::relay(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &ApplyRequest_oneof_el::room(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &ApplyRequest_oneof_el::webrtc_play(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &ApplyRequest_oneof_el::webrtc_pub(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + }; + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + if !self.id.is_empty() { + os.write_string(1, &self.id)?; + } + if self.policy != ApplyRequest_Policy::APPLY { + os.write_enum(9, self.policy.value())?; + } + if let ::std::option::Option::Some(ref v) = self.el { + match v { + &ApplyRequest_oneof_el::hub(ref v) => { + os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &ApplyRequest_oneof_el::file_recorder(ref v) => { + os.write_tag(3, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &ApplyRequest_oneof_el::member(ref v) => { + os.write_tag(4, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &ApplyRequest_oneof_el::relay(ref v) => { + os.write_tag(5, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &ApplyRequest_oneof_el::room(ref v) => { + os.write_tag(6, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &ApplyRequest_oneof_el::webrtc_play(ref v) => { + os.write_tag(7, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &ApplyRequest_oneof_el::webrtc_pub(ref v) => { + os.write_tag(8, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + }; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> ApplyRequest { + ApplyRequest::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "id", + |m: &ApplyRequest| { &m.id }, + |m: &mut ApplyRequest| { &mut m.id }, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Hub>( + "hub", + ApplyRequest::has_hub, + ApplyRequest::get_hub, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, FileRecorder>( + "file_recorder", + ApplyRequest::has_file_recorder, + ApplyRequest::get_file_recorder, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Member>( + "member", + ApplyRequest::has_member, + ApplyRequest::get_member, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Relay>( + "relay", + ApplyRequest::has_relay, + ApplyRequest::get_relay, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Room>( + "room", + ApplyRequest::has_room, + ApplyRequest::get_room, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPlayEndpoint>( + "webrtc_play", + ApplyRequest::has_webrtc_play, + ApplyRequest::get_webrtc_play, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPublishEndpoint>( + "webrtc_pub", + ApplyRequest::has_webrtc_pub, + ApplyRequest::get_webrtc_pub, + )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeEnum>( + "policy", + |m: &ApplyRequest| { &m.policy }, + |m: &mut ApplyRequest| { &mut m.policy }, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "ApplyRequest", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static ApplyRequest { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ApplyRequest, + }; + unsafe { + instance.get(ApplyRequest::new) + } + } +} + +impl ::protobuf::Clear for ApplyRequest { + fn clear(&mut self) { + self.id.clear(); + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.policy = ApplyRequest_Policy::APPLY; + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for ApplyRequest { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for ApplyRequest { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(Clone,PartialEq,Eq,Debug,Hash)] +pub enum ApplyRequest_Policy { + APPLY = 0, + APPEND = 1, +} + +impl ::protobuf::ProtobufEnum for ApplyRequest_Policy { + fn value(&self) -> i32 { + *self as i32 + } + + fn from_i32(value: i32) -> ::std::option::Option { + match value { + 0 => ::std::option::Option::Some(ApplyRequest_Policy::APPLY), + 1 => ::std::option::Option::Some(ApplyRequest_Policy::APPEND), + _ => ::std::option::Option::None + } + } + + fn values() -> &'static [Self] { + static values: &'static [ApplyRequest_Policy] = &[ + ApplyRequest_Policy::APPLY, + ApplyRequest_Policy::APPEND, + ]; + values + } + + fn enum_descriptor_static() -> &'static ::protobuf::reflect::EnumDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::EnumDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::EnumDescriptor, + }; + unsafe { + descriptor.get(|| { + ::protobuf::reflect::EnumDescriptor::new("ApplyRequest_Policy", file_descriptor_proto()) + }) + } + } +} + +impl ::std::marker::Copy for ApplyRequest_Policy { +} + +impl ::std::default::Default for ApplyRequest_Policy { + fn default() -> Self { + ApplyRequest_Policy::APPLY + } +} + +impl ::protobuf::reflect::ProtobufValue for ApplyRequest_Policy { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Enum(self.descriptor()) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct IdRequest { + // message fields + pub id: ::protobuf::RepeatedField<::std::string::String>, + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a IdRequest { + fn default() -> &'a IdRequest { + ::default_instance() + } +} + +impl IdRequest { + pub fn new() -> IdRequest { + ::std::default::Default::default() + } + + // repeated string id = 1; + + + pub fn get_id(&self) -> &[::std::string::String] { + &self.id + } + pub fn clear_id(&mut self) { + self.id.clear(); + } + + // Param is passed by value, moved + pub fn set_id(&mut self, v: ::protobuf::RepeatedField<::std::string::String>) { + self.id = v; + } + + // Mutable pointer to the field. + pub fn mut_id(&mut self) -> &mut ::protobuf::RepeatedField<::std::string::String> { + &mut self.id + } + + // Take field + pub fn take_id(&mut self) -> ::protobuf::RepeatedField<::std::string::String> { + ::std::mem::replace(&mut self.id, ::protobuf::RepeatedField::new()) + } +} + +impl ::protobuf::Message for IdRequest { + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_repeated_string_into(wire_type, is, &mut self.id)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + for value in &self.id { + my_size += ::protobuf::rt::string_size(1, &value); + }; + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + for v in &self.id { + os.write_string(1, &v)?; + }; + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> IdRequest { + IdRequest::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "id", + |m: &IdRequest| { &m.id }, + |m: &mut IdRequest| { &mut m.id }, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "IdRequest", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static IdRequest { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const IdRequest, + }; + unsafe { + instance.get(IdRequest::new) + } + } +} + +impl ::protobuf::Clear for IdRequest { + fn clear(&mut self) { + self.id.clear(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for IdRequest { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for IdRequest { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct Response { + // message fields + pub sid: ::std::collections::HashMap<::std::string::String, ::std::string::String>, + pub error: ::protobuf::SingularPtrField, + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a Response { + fn default() -> &'a Response { + ::default_instance() + } +} + +impl Response { + pub fn new() -> Response { + ::std::default::Default::default() + } + + // repeated .medea.Response.SidEntry sid = 1; + + + pub fn get_sid(&self) -> &::std::collections::HashMap<::std::string::String, ::std::string::String> { + &self.sid + } + pub fn clear_sid(&mut self) { + self.sid.clear(); + } + + // Param is passed by value, moved + pub fn set_sid(&mut self, v: ::std::collections::HashMap<::std::string::String, ::std::string::String>) { + self.sid = v; + } + + // Mutable pointer to the field. + pub fn mut_sid(&mut self) -> &mut ::std::collections::HashMap<::std::string::String, ::std::string::String> { + &mut self.sid + } + + // Take field + pub fn take_sid(&mut self) -> ::std::collections::HashMap<::std::string::String, ::std::string::String> { + ::std::mem::replace(&mut self.sid, ::std::collections::HashMap::new()) + } + + // .medea.Error error = 2; + + + pub fn get_error(&self) -> &Error { + self.error.as_ref().unwrap_or_else(|| Error::default_instance()) + } + pub fn clear_error(&mut self) { + self.error.clear(); + } + + pub fn has_error(&self) -> bool { + self.error.is_some() + } + + // Param is passed by value, moved + pub fn set_error(&mut self, v: Error) { + self.error = ::protobuf::SingularPtrField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_error(&mut self) -> &mut Error { + if self.error.is_none() { + self.error.set_default(); + } + self.error.as_mut().unwrap() + } + + // Take field + pub fn take_error(&mut self) -> Error { + self.error.take().unwrap_or_else(|| Error::new()) + } +} + +impl ::protobuf::Message for Response { + fn is_initialized(&self) -> bool { + for v in &self.error { + if !v.is_initialized() { + return false; + } + }; + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_map_into::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeString>(wire_type, is, &mut self.sid)?; + }, + 2 => { + ::protobuf::rt::read_singular_message_into(wire_type, is, &mut self.error)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + my_size += ::protobuf::rt::compute_map_size::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeString>(1, &self.sid); + if let Some(ref v) = self.error.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + ::protobuf::rt::write_map_with_cached_sizes::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeString>(1, &self.sid, os)?; + if let Some(ref v) = self.error.as_ref() { + os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> Response { + Response::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_map_accessor::<_, ::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeString>( + "sid", + |m: &Response| { &m.sid }, + |m: &mut Response| { &mut m.sid }, + )); + fields.push(::protobuf::reflect::accessor::make_singular_ptr_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( + "error", + |m: &Response| { &m.error }, + |m: &mut Response| { &mut m.error }, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "Response", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static Response { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const Response, + }; + unsafe { + instance.get(Response::new) + } + } +} + +impl ::protobuf::Clear for Response { + fn clear(&mut self) { + self.sid.clear(); + self.error.clear(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for Response { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for Response { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct GetResponse { + // message fields + pub elements: ::std::collections::HashMap<::std::string::String, Element>, + pub error: ::protobuf::SingularPtrField, + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a GetResponse { + fn default() -> &'a GetResponse { + ::default_instance() + } +} + +impl GetResponse { + pub fn new() -> GetResponse { + ::std::default::Default::default() + } + + // repeated .medea.GetResponse.ElementsEntry elements = 1; + + + pub fn get_elements(&self) -> &::std::collections::HashMap<::std::string::String, Element> { + &self.elements + } + pub fn clear_elements(&mut self) { + self.elements.clear(); + } + + // Param is passed by value, moved + pub fn set_elements(&mut self, v: ::std::collections::HashMap<::std::string::String, Element>) { + self.elements = v; + } + + // Mutable pointer to the field. + pub fn mut_elements(&mut self) -> &mut ::std::collections::HashMap<::std::string::String, Element> { + &mut self.elements + } + + // Take field + pub fn take_elements(&mut self) -> ::std::collections::HashMap<::std::string::String, Element> { + ::std::mem::replace(&mut self.elements, ::std::collections::HashMap::new()) + } + + // .medea.Error error = 2; + + + pub fn get_error(&self) -> &Error { + self.error.as_ref().unwrap_or_else(|| Error::default_instance()) + } + pub fn clear_error(&mut self) { + self.error.clear(); + } + + pub fn has_error(&self) -> bool { + self.error.is_some() + } + + // Param is passed by value, moved + pub fn set_error(&mut self, v: Error) { + self.error = ::protobuf::SingularPtrField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_error(&mut self) -> &mut Error { + if self.error.is_none() { + self.error.set_default(); + } + self.error.as_mut().unwrap() + } + + // Take field + pub fn take_error(&mut self) -> Error { + self.error.take().unwrap_or_else(|| Error::new()) + } +} + +impl ::protobuf::Message for GetResponse { + fn is_initialized(&self) -> bool { + for v in &self.error { + if !v.is_initialized() { + return false; + } + }; + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_map_into::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(wire_type, is, &mut self.elements)?; + }, + 2 => { + ::protobuf::rt::read_singular_message_into(wire_type, is, &mut self.error)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + my_size += ::protobuf::rt::compute_map_size::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(1, &self.elements); + if let Some(ref v) = self.error.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + ::protobuf::rt::write_map_with_cached_sizes::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(1, &self.elements, os)?; + if let Some(ref v) = self.error.as_ref() { + os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> GetResponse { + GetResponse::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_map_accessor::<_, ::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>( + "elements", + |m: &GetResponse| { &m.elements }, + |m: &mut GetResponse| { &mut m.elements }, + )); + fields.push(::protobuf::reflect::accessor::make_singular_ptr_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( + "error", + |m: &GetResponse| { &m.error }, + |m: &mut GetResponse| { &mut m.error }, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "GetResponse", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static GetResponse { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const GetResponse, + }; + unsafe { + instance.get(GetResponse::new) + } + } +} + +impl ::protobuf::Clear for GetResponse { + fn clear(&mut self) { + self.elements.clear(); + self.error.clear(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for GetResponse { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for GetResponse { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct Error { + // message fields + pub code: u32, + pub text: ::std::string::String, + pub doc: ::std::string::String, + pub element: ::std::string::String, + pub details: ::protobuf::SingularPtrField<::protobuf::well_known_types::Any>, + pub backtrace: ::protobuf::RepeatedField<::std::string::String>, + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a Error { + fn default() -> &'a Error { + ::default_instance() + } +} + +impl Error { + pub fn new() -> Error { + ::std::default::Default::default() + } + + // uint32 code = 2; + + + pub fn get_code(&self) -> u32 { + self.code + } + pub fn clear_code(&mut self) { + self.code = 0; + } + + // Param is passed by value, moved + pub fn set_code(&mut self, v: u32) { + self.code = v; + } + + // string text = 3; + + + pub fn get_text(&self) -> &str { + &self.text + } + pub fn clear_text(&mut self) { + self.text.clear(); + } + + // Param is passed by value, moved + pub fn set_text(&mut self, v: ::std::string::String) { + self.text = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_text(&mut self) -> &mut ::std::string::String { + &mut self.text + } + + // Take field + pub fn take_text(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.text, ::std::string::String::new()) + } + + // string doc = 4; + + + pub fn get_doc(&self) -> &str { + &self.doc + } + pub fn clear_doc(&mut self) { + self.doc.clear(); + } + + // Param is passed by value, moved + pub fn set_doc(&mut self, v: ::std::string::String) { + self.doc = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_doc(&mut self) -> &mut ::std::string::String { + &mut self.doc + } + + // Take field + pub fn take_doc(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.doc, ::std::string::String::new()) + } + + // string element = 5; + + + pub fn get_element(&self) -> &str { + &self.element + } + pub fn clear_element(&mut self) { + self.element.clear(); + } + + // Param is passed by value, moved + pub fn set_element(&mut self, v: ::std::string::String) { + self.element = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_element(&mut self) -> &mut ::std::string::String { + &mut self.element + } + + // Take field + pub fn take_element(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.element, ::std::string::String::new()) + } + + // .google.protobuf.Any details = 6; + + + pub fn get_details(&self) -> &::protobuf::well_known_types::Any { + self.details.as_ref().unwrap_or_else(|| ::protobuf::well_known_types::Any::default_instance()) + } + pub fn clear_details(&mut self) { + self.details.clear(); + } + + pub fn has_details(&self) -> bool { + self.details.is_some() + } + + // Param is passed by value, moved + pub fn set_details(&mut self, v: ::protobuf::well_known_types::Any) { + self.details = ::protobuf::SingularPtrField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_details(&mut self) -> &mut ::protobuf::well_known_types::Any { + if self.details.is_none() { + self.details.set_default(); + } + self.details.as_mut().unwrap() + } + + // Take field + pub fn take_details(&mut self) -> ::protobuf::well_known_types::Any { + self.details.take().unwrap_or_else(|| ::protobuf::well_known_types::Any::new()) + } + + // repeated string backtrace = 7; + + + pub fn get_backtrace(&self) -> &[::std::string::String] { + &self.backtrace + } + pub fn clear_backtrace(&mut self) { + self.backtrace.clear(); + } + + // Param is passed by value, moved + pub fn set_backtrace(&mut self, v: ::protobuf::RepeatedField<::std::string::String>) { + self.backtrace = v; + } + + // Mutable pointer to the field. + pub fn mut_backtrace(&mut self) -> &mut ::protobuf::RepeatedField<::std::string::String> { + &mut self.backtrace + } + + // Take field + pub fn take_backtrace(&mut self) -> ::protobuf::RepeatedField<::std::string::String> { + ::std::mem::replace(&mut self.backtrace, ::protobuf::RepeatedField::new()) + } +} + +impl ::protobuf::Message for Error { + fn is_initialized(&self) -> bool { + for v in &self.details { + if !v.is_initialized() { + return false; + } + }; + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 2 => { + if wire_type != ::protobuf::wire_format::WireTypeVarint { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + let tmp = is.read_uint32()?; + self.code = tmp; + }, + 3 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.text)?; + }, + 4 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.doc)?; + }, + 5 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.element)?; + }, + 6 => { + ::protobuf::rt::read_singular_message_into(wire_type, is, &mut self.details)?; + }, + 7 => { + ::protobuf::rt::read_repeated_string_into(wire_type, is, &mut self.backtrace)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if self.code != 0 { + my_size += ::protobuf::rt::value_size(2, self.code, ::protobuf::wire_format::WireTypeVarint); + } + if !self.text.is_empty() { + my_size += ::protobuf::rt::string_size(3, &self.text); + } + if !self.doc.is_empty() { + my_size += ::protobuf::rt::string_size(4, &self.doc); + } + if !self.element.is_empty() { + my_size += ::protobuf::rt::string_size(5, &self.element); + } + if let Some(ref v) = self.details.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + } + for value in &self.backtrace { + my_size += ::protobuf::rt::string_size(7, &value); + }; + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + if self.code != 0 { + os.write_uint32(2, self.code)?; + } + if !self.text.is_empty() { + os.write_string(3, &self.text)?; + } + if !self.doc.is_empty() { + os.write_string(4, &self.doc)?; + } + if !self.element.is_empty() { + os.write_string(5, &self.element)?; + } + if let Some(ref v) = self.details.as_ref() { + os.write_tag(6, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + } + for v in &self.backtrace { + os.write_string(7, &v)?; + }; + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> Error { + Error::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeUint32>( + "code", + |m: &Error| { &m.code }, + |m: &mut Error| { &mut m.code }, + )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "text", + |m: &Error| { &m.text }, + |m: &mut Error| { &mut m.text }, + )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "doc", + |m: &Error| { &m.doc }, + |m: &mut Error| { &mut m.doc }, + )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "element", + |m: &Error| { &m.element }, + |m: &mut Error| { &mut m.element }, + )); + fields.push(::protobuf::reflect::accessor::make_singular_ptr_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage<::protobuf::well_known_types::Any>>( + "details", + |m: &Error| { &m.details }, + |m: &mut Error| { &mut m.details }, + )); + fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "backtrace", + |m: &Error| { &m.backtrace }, + |m: &mut Error| { &mut m.backtrace }, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "Error", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static Error { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const Error, + }; + unsafe { + instance.get(Error::new) + } + } +} + +impl ::protobuf::Clear for Error { + fn clear(&mut self) { + self.code = 0; + self.text.clear(); + self.doc.clear(); + self.element.clear(); + self.details.clear(); + self.backtrace.clear(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for Error { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for Error { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct Element { + // message oneof groups + pub el: ::std::option::Option, + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a Element { + fn default() -> &'a Element { + ::default_instance() + } +} + +#[derive(Clone,PartialEq,Debug)] +pub enum Element_oneof_el { + hub(Hub), + file_recorder(FileRecorder), + member(Member), + relay(Relay), + room(Room), + webrtc_play(WebRtcPlayEndpoint), + webrtc_pub(WebRtcPublishEndpoint), +} + +impl Element { + pub fn new() -> Element { + ::std::default::Default::default() + } + + // .medea.Hub hub = 2; + + + pub fn get_hub(&self) -> &Hub { + match self.el { + ::std::option::Option::Some(Element_oneof_el::hub(ref v)) => v, + _ => Hub::default_instance(), + } + } + pub fn clear_hub(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_hub(&self) -> bool { + match self.el { + ::std::option::Option::Some(Element_oneof_el::hub(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_hub(&mut self, v: Hub) { + self.el = ::std::option::Option::Some(Element_oneof_el::hub(v)) + } + + // Mutable pointer to the field. + pub fn mut_hub(&mut self) -> &mut Hub { + if let ::std::option::Option::Some(Element_oneof_el::hub(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Element_oneof_el::hub(Hub::new())); + } + match self.el { + ::std::option::Option::Some(Element_oneof_el::hub(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_hub(&mut self) -> Hub { + if self.has_hub() { + match self.el.take() { + ::std::option::Option::Some(Element_oneof_el::hub(v)) => v, + _ => panic!(), + } + } else { + Hub::new() + } + } + + // .medea.FileRecorder file_recorder = 3; + + + pub fn get_file_recorder(&self) -> &FileRecorder { + match self.el { + ::std::option::Option::Some(Element_oneof_el::file_recorder(ref v)) => v, + _ => FileRecorder::default_instance(), + } + } + pub fn clear_file_recorder(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_file_recorder(&self) -> bool { + match self.el { + ::std::option::Option::Some(Element_oneof_el::file_recorder(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_file_recorder(&mut self, v: FileRecorder) { + self.el = ::std::option::Option::Some(Element_oneof_el::file_recorder(v)) + } + + // Mutable pointer to the field. + pub fn mut_file_recorder(&mut self) -> &mut FileRecorder { + if let ::std::option::Option::Some(Element_oneof_el::file_recorder(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Element_oneof_el::file_recorder(FileRecorder::new())); + } + match self.el { + ::std::option::Option::Some(Element_oneof_el::file_recorder(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_file_recorder(&mut self) -> FileRecorder { + if self.has_file_recorder() { + match self.el.take() { + ::std::option::Option::Some(Element_oneof_el::file_recorder(v)) => v, + _ => panic!(), + } + } else { + FileRecorder::new() + } + } + + // .medea.Member member = 4; + + + pub fn get_member(&self) -> &Member { + match self.el { + ::std::option::Option::Some(Element_oneof_el::member(ref v)) => v, + _ => Member::default_instance(), + } + } + pub fn clear_member(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_member(&self) -> bool { + match self.el { + ::std::option::Option::Some(Element_oneof_el::member(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_member(&mut self, v: Member) { + self.el = ::std::option::Option::Some(Element_oneof_el::member(v)) + } + + // Mutable pointer to the field. + pub fn mut_member(&mut self) -> &mut Member { + if let ::std::option::Option::Some(Element_oneof_el::member(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Element_oneof_el::member(Member::new())); + } + match self.el { + ::std::option::Option::Some(Element_oneof_el::member(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_member(&mut self) -> Member { + if self.has_member() { + match self.el.take() { + ::std::option::Option::Some(Element_oneof_el::member(v)) => v, + _ => panic!(), + } + } else { + Member::new() + } + } + + // .medea.Relay relay = 5; + + + pub fn get_relay(&self) -> &Relay { + match self.el { + ::std::option::Option::Some(Element_oneof_el::relay(ref v)) => v, + _ => Relay::default_instance(), + } + } + pub fn clear_relay(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_relay(&self) -> bool { + match self.el { + ::std::option::Option::Some(Element_oneof_el::relay(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_relay(&mut self, v: Relay) { + self.el = ::std::option::Option::Some(Element_oneof_el::relay(v)) + } + + // Mutable pointer to the field. + pub fn mut_relay(&mut self) -> &mut Relay { + if let ::std::option::Option::Some(Element_oneof_el::relay(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Element_oneof_el::relay(Relay::new())); + } + match self.el { + ::std::option::Option::Some(Element_oneof_el::relay(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_relay(&mut self) -> Relay { + if self.has_relay() { + match self.el.take() { + ::std::option::Option::Some(Element_oneof_el::relay(v)) => v, + _ => panic!(), + } + } else { + Relay::new() + } + } + + // .medea.Room room = 6; + + + pub fn get_room(&self) -> &Room { + match self.el { + ::std::option::Option::Some(Element_oneof_el::room(ref v)) => v, + _ => Room::default_instance(), + } + } + pub fn clear_room(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_room(&self) -> bool { + match self.el { + ::std::option::Option::Some(Element_oneof_el::room(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_room(&mut self, v: Room) { + self.el = ::std::option::Option::Some(Element_oneof_el::room(v)) + } + + // Mutable pointer to the field. + pub fn mut_room(&mut self) -> &mut Room { + if let ::std::option::Option::Some(Element_oneof_el::room(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Element_oneof_el::room(Room::new())); + } + match self.el { + ::std::option::Option::Some(Element_oneof_el::room(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_room(&mut self) -> Room { + if self.has_room() { + match self.el.take() { + ::std::option::Option::Some(Element_oneof_el::room(v)) => v, + _ => panic!(), + } + } else { + Room::new() + } + } + + // .medea.WebRtcPlayEndpoint webrtc_play = 7; + + + pub fn get_webrtc_play(&self) -> &WebRtcPlayEndpoint { + match self.el { + ::std::option::Option::Some(Element_oneof_el::webrtc_play(ref v)) => v, + _ => WebRtcPlayEndpoint::default_instance(), + } + } + pub fn clear_webrtc_play(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_webrtc_play(&self) -> bool { + match self.el { + ::std::option::Option::Some(Element_oneof_el::webrtc_play(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_webrtc_play(&mut self, v: WebRtcPlayEndpoint) { + self.el = ::std::option::Option::Some(Element_oneof_el::webrtc_play(v)) + } + + // Mutable pointer to the field. + pub fn mut_webrtc_play(&mut self) -> &mut WebRtcPlayEndpoint { + if let ::std::option::Option::Some(Element_oneof_el::webrtc_play(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Element_oneof_el::webrtc_play(WebRtcPlayEndpoint::new())); + } + match self.el { + ::std::option::Option::Some(Element_oneof_el::webrtc_play(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_webrtc_play(&mut self) -> WebRtcPlayEndpoint { + if self.has_webrtc_play() { + match self.el.take() { + ::std::option::Option::Some(Element_oneof_el::webrtc_play(v)) => v, + _ => panic!(), + } + } else { + WebRtcPlayEndpoint::new() + } + } + + // .medea.WebRtcPublishEndpoint webrtc_pub = 8; + + + pub fn get_webrtc_pub(&self) -> &WebRtcPublishEndpoint { + match self.el { + ::std::option::Option::Some(Element_oneof_el::webrtc_pub(ref v)) => v, + _ => WebRtcPublishEndpoint::default_instance(), + } + } + pub fn clear_webrtc_pub(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_webrtc_pub(&self) -> bool { + match self.el { + ::std::option::Option::Some(Element_oneof_el::webrtc_pub(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_webrtc_pub(&mut self, v: WebRtcPublishEndpoint) { + self.el = ::std::option::Option::Some(Element_oneof_el::webrtc_pub(v)) + } + + // Mutable pointer to the field. + pub fn mut_webrtc_pub(&mut self) -> &mut WebRtcPublishEndpoint { + if let ::std::option::Option::Some(Element_oneof_el::webrtc_pub(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Element_oneof_el::webrtc_pub(WebRtcPublishEndpoint::new())); + } + match self.el { + ::std::option::Option::Some(Element_oneof_el::webrtc_pub(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_webrtc_pub(&mut self) -> WebRtcPublishEndpoint { + if self.has_webrtc_pub() { + match self.el.take() { + ::std::option::Option::Some(Element_oneof_el::webrtc_pub(v)) => v, + _ => panic!(), + } + } else { + WebRtcPublishEndpoint::new() + } + } +} + +impl ::protobuf::Message for Element { + fn is_initialized(&self) -> bool { + if let Some(Element_oneof_el::hub(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(Element_oneof_el::file_recorder(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(Element_oneof_el::member(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(Element_oneof_el::relay(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(Element_oneof_el::room(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(Element_oneof_el::webrtc_play(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(Element_oneof_el::webrtc_pub(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 2 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Element_oneof_el::hub(is.read_message()?)); + }, + 3 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Element_oneof_el::file_recorder(is.read_message()?)); + }, + 4 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Element_oneof_el::member(is.read_message()?)); + }, + 5 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Element_oneof_el::relay(is.read_message()?)); + }, + 6 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Element_oneof_el::room(is.read_message()?)); + }, + 7 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Element_oneof_el::webrtc_play(is.read_message()?)); + }, + 8 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Element_oneof_el::webrtc_pub(is.read_message()?)); + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if let ::std::option::Option::Some(ref v) = self.el { + match v { + &Element_oneof_el::hub(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &Element_oneof_el::file_recorder(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &Element_oneof_el::member(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &Element_oneof_el::relay(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &Element_oneof_el::room(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &Element_oneof_el::webrtc_play(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &Element_oneof_el::webrtc_pub(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + }; + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + if let ::std::option::Option::Some(ref v) = self.el { + match v { + &Element_oneof_el::hub(ref v) => { + os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &Element_oneof_el::file_recorder(ref v) => { + os.write_tag(3, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &Element_oneof_el::member(ref v) => { + os.write_tag(4, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &Element_oneof_el::relay(ref v) => { + os.write_tag(5, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &Element_oneof_el::room(ref v) => { + os.write_tag(6, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &Element_oneof_el::webrtc_play(ref v) => { + os.write_tag(7, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &Element_oneof_el::webrtc_pub(ref v) => { + os.write_tag(8, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + }; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> Element { + Element::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Hub>( + "hub", + Element::has_hub, + Element::get_hub, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, FileRecorder>( + "file_recorder", + Element::has_file_recorder, + Element::get_file_recorder, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Member>( + "member", + Element::has_member, + Element::get_member, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Relay>( + "relay", + Element::has_relay, + Element::get_relay, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Room>( + "room", + Element::has_room, + Element::get_room, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPlayEndpoint>( + "webrtc_play", + Element::has_webrtc_play, + Element::get_webrtc_play, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPublishEndpoint>( + "webrtc_pub", + Element::has_webrtc_pub, + Element::get_webrtc_pub, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "Element", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static Element { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const Element, + }; + unsafe { + instance.get(Element::new) + } + } +} + +impl ::protobuf::Clear for Element { + fn clear(&mut self) { + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for Element { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for Element { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct Room { + // message fields + pub pipeline: ::std::collections::HashMap<::std::string::String, Room_Element>, + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a Room { + fn default() -> &'a Room { + ::default_instance() + } +} + +impl Room { + pub fn new() -> Room { + ::std::default::Default::default() + } + + // repeated .medea.Room.PipelineEntry pipeline = 1; + + + pub fn get_pipeline(&self) -> &::std::collections::HashMap<::std::string::String, Room_Element> { + &self.pipeline + } + pub fn clear_pipeline(&mut self) { + self.pipeline.clear(); + } + + // Param is passed by value, moved + pub fn set_pipeline(&mut self, v: ::std::collections::HashMap<::std::string::String, Room_Element>) { + self.pipeline = v; + } + + // Mutable pointer to the field. + pub fn mut_pipeline(&mut self) -> &mut ::std::collections::HashMap<::std::string::String, Room_Element> { + &mut self.pipeline + } + + // Take field + pub fn take_pipeline(&mut self) -> ::std::collections::HashMap<::std::string::String, Room_Element> { + ::std::mem::replace(&mut self.pipeline, ::std::collections::HashMap::new()) + } +} + +impl ::protobuf::Message for Room { + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_map_into::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(wire_type, is, &mut self.pipeline)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + my_size += ::protobuf::rt::compute_map_size::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(1, &self.pipeline); + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + ::protobuf::rt::write_map_with_cached_sizes::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(1, &self.pipeline, os)?; + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> Room { + Room::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_map_accessor::<_, ::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>( + "pipeline", + |m: &Room| { &m.pipeline }, + |m: &mut Room| { &mut m.pipeline }, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "Room", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static Room { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const Room, + }; + unsafe { + instance.get(Room::new) + } + } +} + +impl ::protobuf::Clear for Room { + fn clear(&mut self) { + self.pipeline.clear(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for Room { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for Room { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct Room_Element { + // message oneof groups + pub el: ::std::option::Option, + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a Room_Element { + fn default() -> &'a Room_Element { + ::default_instance() + } +} + +#[derive(Clone,PartialEq,Debug)] +pub enum Room_Element_oneof_el { + hub(Hub), + file_recorder(FileRecorder), + member(Member), + relay(Relay), + webrtc_play(WebRtcPlayEndpoint), + webrtc_pub(WebRtcPublishEndpoint), +} + +impl Room_Element { + pub fn new() -> Room_Element { + ::std::default::Default::default() + } + + // .medea.Hub hub = 1; + + + pub fn get_hub(&self) -> &Hub { + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::hub(ref v)) => v, + _ => Hub::default_instance(), + } + } + pub fn clear_hub(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_hub(&self) -> bool { + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::hub(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_hub(&mut self, v: Hub) { + self.el = ::std::option::Option::Some(Room_Element_oneof_el::hub(v)) + } + + // Mutable pointer to the field. + pub fn mut_hub(&mut self) -> &mut Hub { + if let ::std::option::Option::Some(Room_Element_oneof_el::hub(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Room_Element_oneof_el::hub(Hub::new())); + } + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::hub(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_hub(&mut self) -> Hub { + if self.has_hub() { + match self.el.take() { + ::std::option::Option::Some(Room_Element_oneof_el::hub(v)) => v, + _ => panic!(), + } + } else { + Hub::new() + } + } + + // .medea.FileRecorder file_recorder = 2; + + + pub fn get_file_recorder(&self) -> &FileRecorder { + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::file_recorder(ref v)) => v, + _ => FileRecorder::default_instance(), + } + } + pub fn clear_file_recorder(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_file_recorder(&self) -> bool { + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::file_recorder(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_file_recorder(&mut self, v: FileRecorder) { + self.el = ::std::option::Option::Some(Room_Element_oneof_el::file_recorder(v)) + } + + // Mutable pointer to the field. + pub fn mut_file_recorder(&mut self) -> &mut FileRecorder { + if let ::std::option::Option::Some(Room_Element_oneof_el::file_recorder(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Room_Element_oneof_el::file_recorder(FileRecorder::new())); + } + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::file_recorder(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_file_recorder(&mut self) -> FileRecorder { + if self.has_file_recorder() { + match self.el.take() { + ::std::option::Option::Some(Room_Element_oneof_el::file_recorder(v)) => v, + _ => panic!(), + } + } else { + FileRecorder::new() + } + } + + // .medea.Member member = 3; + + + pub fn get_member(&self) -> &Member { + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::member(ref v)) => v, + _ => Member::default_instance(), + } + } + pub fn clear_member(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_member(&self) -> bool { + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::member(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_member(&mut self, v: Member) { + self.el = ::std::option::Option::Some(Room_Element_oneof_el::member(v)) + } + + // Mutable pointer to the field. + pub fn mut_member(&mut self) -> &mut Member { + if let ::std::option::Option::Some(Room_Element_oneof_el::member(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Room_Element_oneof_el::member(Member::new())); + } + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::member(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_member(&mut self) -> Member { + if self.has_member() { + match self.el.take() { + ::std::option::Option::Some(Room_Element_oneof_el::member(v)) => v, + _ => panic!(), + } + } else { + Member::new() + } + } + + // .medea.Relay relay = 4; + + + pub fn get_relay(&self) -> &Relay { + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::relay(ref v)) => v, + _ => Relay::default_instance(), + } + } + pub fn clear_relay(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_relay(&self) -> bool { + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::relay(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_relay(&mut self, v: Relay) { + self.el = ::std::option::Option::Some(Room_Element_oneof_el::relay(v)) + } + + // Mutable pointer to the field. + pub fn mut_relay(&mut self) -> &mut Relay { + if let ::std::option::Option::Some(Room_Element_oneof_el::relay(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Room_Element_oneof_el::relay(Relay::new())); + } + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::relay(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_relay(&mut self) -> Relay { + if self.has_relay() { + match self.el.take() { + ::std::option::Option::Some(Room_Element_oneof_el::relay(v)) => v, + _ => panic!(), + } + } else { + Relay::new() + } + } + + // .medea.WebRtcPlayEndpoint webrtc_play = 5; + + + pub fn get_webrtc_play(&self) -> &WebRtcPlayEndpoint { + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(ref v)) => v, + _ => WebRtcPlayEndpoint::default_instance(), + } + } + pub fn clear_webrtc_play(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_webrtc_play(&self) -> bool { + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_webrtc_play(&mut self, v: WebRtcPlayEndpoint) { + self.el = ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(v)) + } + + // Mutable pointer to the field. + pub fn mut_webrtc_play(&mut self) -> &mut WebRtcPlayEndpoint { + if let ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(WebRtcPlayEndpoint::new())); + } + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_webrtc_play(&mut self) -> WebRtcPlayEndpoint { + if self.has_webrtc_play() { + match self.el.take() { + ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(v)) => v, + _ => panic!(), + } + } else { + WebRtcPlayEndpoint::new() + } + } + + // .medea.WebRtcPublishEndpoint webrtc_pub = 6; + + + pub fn get_webrtc_pub(&self) -> &WebRtcPublishEndpoint { + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(ref v)) => v, + _ => WebRtcPublishEndpoint::default_instance(), + } + } + pub fn clear_webrtc_pub(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_webrtc_pub(&self) -> bool { + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_webrtc_pub(&mut self, v: WebRtcPublishEndpoint) { + self.el = ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(v)) + } + + // Mutable pointer to the field. + pub fn mut_webrtc_pub(&mut self) -> &mut WebRtcPublishEndpoint { + if let ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(WebRtcPublishEndpoint::new())); + } + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_webrtc_pub(&mut self) -> WebRtcPublishEndpoint { + if self.has_webrtc_pub() { + match self.el.take() { + ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(v)) => v, + _ => panic!(), + } + } else { + WebRtcPublishEndpoint::new() + } + } +} + +impl ::protobuf::Message for Room_Element { + fn is_initialized(&self) -> bool { + if let Some(Room_Element_oneof_el::hub(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(Room_Element_oneof_el::file_recorder(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(Room_Element_oneof_el::member(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(Room_Element_oneof_el::relay(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(Room_Element_oneof_el::webrtc_play(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(Room_Element_oneof_el::webrtc_pub(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Room_Element_oneof_el::hub(is.read_message()?)); + }, + 2 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Room_Element_oneof_el::file_recorder(is.read_message()?)); + }, + 3 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Room_Element_oneof_el::member(is.read_message()?)); + }, + 4 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Room_Element_oneof_el::relay(is.read_message()?)); + }, + 5 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(is.read_message()?)); + }, + 6 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(is.read_message()?)); + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if let ::std::option::Option::Some(ref v) = self.el { + match v { + &Room_Element_oneof_el::hub(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &Room_Element_oneof_el::file_recorder(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &Room_Element_oneof_el::member(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &Room_Element_oneof_el::relay(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &Room_Element_oneof_el::webrtc_play(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &Room_Element_oneof_el::webrtc_pub(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + }; + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + if let ::std::option::Option::Some(ref v) = self.el { + match v { + &Room_Element_oneof_el::hub(ref v) => { + os.write_tag(1, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &Room_Element_oneof_el::file_recorder(ref v) => { + os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &Room_Element_oneof_el::member(ref v) => { + os.write_tag(3, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &Room_Element_oneof_el::relay(ref v) => { + os.write_tag(4, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &Room_Element_oneof_el::webrtc_play(ref v) => { + os.write_tag(5, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &Room_Element_oneof_el::webrtc_pub(ref v) => { + os.write_tag(6, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + }; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> Room_Element { + Room_Element::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Hub>( + "hub", + Room_Element::has_hub, + Room_Element::get_hub, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, FileRecorder>( + "file_recorder", + Room_Element::has_file_recorder, + Room_Element::get_file_recorder, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Member>( + "member", + Room_Element::has_member, + Room_Element::get_member, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Relay>( + "relay", + Room_Element::has_relay, + Room_Element::get_relay, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPlayEndpoint>( + "webrtc_play", + Room_Element::has_webrtc_play, + Room_Element::get_webrtc_play, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPublishEndpoint>( + "webrtc_pub", + Room_Element::has_webrtc_pub, + Room_Element::get_webrtc_pub, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "Room_Element", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static Room_Element { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const Room_Element, + }; + unsafe { + instance.get(Room_Element::new) + } + } +} + +impl ::protobuf::Clear for Room_Element { + fn clear(&mut self) { + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for Room_Element { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for Room_Element { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct Member { + // message fields + pub on_join: ::std::string::String, + pub on_leave: ::std::string::String, + pub credentials: ::std::string::String, + pub pipeline: ::std::collections::HashMap<::std::string::String, Member_Element>, + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a Member { + fn default() -> &'a Member { + ::default_instance() + } +} + +impl Member { + pub fn new() -> Member { + ::std::default::Default::default() + } + + // string on_join = 1; + + + pub fn get_on_join(&self) -> &str { + &self.on_join + } + pub fn clear_on_join(&mut self) { + self.on_join.clear(); + } + + // Param is passed by value, moved + pub fn set_on_join(&mut self, v: ::std::string::String) { + self.on_join = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_on_join(&mut self) -> &mut ::std::string::String { + &mut self.on_join + } + + // Take field + pub fn take_on_join(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.on_join, ::std::string::String::new()) + } + + // string on_leave = 2; + + + pub fn get_on_leave(&self) -> &str { + &self.on_leave + } + pub fn clear_on_leave(&mut self) { + self.on_leave.clear(); + } + + // Param is passed by value, moved + pub fn set_on_leave(&mut self, v: ::std::string::String) { + self.on_leave = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_on_leave(&mut self) -> &mut ::std::string::String { + &mut self.on_leave + } + + // Take field + pub fn take_on_leave(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.on_leave, ::std::string::String::new()) + } + + // string credentials = 3; + + + pub fn get_credentials(&self) -> &str { + &self.credentials + } + pub fn clear_credentials(&mut self) { + self.credentials.clear(); + } + + // Param is passed by value, moved + pub fn set_credentials(&mut self, v: ::std::string::String) { + self.credentials = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_credentials(&mut self) -> &mut ::std::string::String { + &mut self.credentials + } + + // Take field + pub fn take_credentials(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.credentials, ::std::string::String::new()) + } + + // repeated .medea.Member.PipelineEntry pipeline = 4; + + + pub fn get_pipeline(&self) -> &::std::collections::HashMap<::std::string::String, Member_Element> { + &self.pipeline + } + pub fn clear_pipeline(&mut self) { + self.pipeline.clear(); + } + + // Param is passed by value, moved + pub fn set_pipeline(&mut self, v: ::std::collections::HashMap<::std::string::String, Member_Element>) { + self.pipeline = v; + } + + // Mutable pointer to the field. + pub fn mut_pipeline(&mut self) -> &mut ::std::collections::HashMap<::std::string::String, Member_Element> { + &mut self.pipeline + } + + // Take field + pub fn take_pipeline(&mut self) -> ::std::collections::HashMap<::std::string::String, Member_Element> { + ::std::mem::replace(&mut self.pipeline, ::std::collections::HashMap::new()) + } +} + +impl ::protobuf::Message for Member { + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.on_join)?; + }, + 2 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.on_leave)?; + }, + 3 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.credentials)?; + }, + 4 => { + ::protobuf::rt::read_map_into::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(wire_type, is, &mut self.pipeline)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if !self.on_join.is_empty() { + my_size += ::protobuf::rt::string_size(1, &self.on_join); + } + if !self.on_leave.is_empty() { + my_size += ::protobuf::rt::string_size(2, &self.on_leave); + } + if !self.credentials.is_empty() { + my_size += ::protobuf::rt::string_size(3, &self.credentials); + } + my_size += ::protobuf::rt::compute_map_size::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(4, &self.pipeline); + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + if !self.on_join.is_empty() { + os.write_string(1, &self.on_join)?; + } + if !self.on_leave.is_empty() { + os.write_string(2, &self.on_leave)?; + } + if !self.credentials.is_empty() { + os.write_string(3, &self.credentials)?; + } + ::protobuf::rt::write_map_with_cached_sizes::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(4, &self.pipeline, os)?; + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> Member { + Member::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "on_join", + |m: &Member| { &m.on_join }, + |m: &mut Member| { &mut m.on_join }, + )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "on_leave", + |m: &Member| { &m.on_leave }, + |m: &mut Member| { &mut m.on_leave }, + )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "credentials", + |m: &Member| { &m.credentials }, + |m: &mut Member| { &mut m.credentials }, + )); + fields.push(::protobuf::reflect::accessor::make_map_accessor::<_, ::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>( + "pipeline", + |m: &Member| { &m.pipeline }, + |m: &mut Member| { &mut m.pipeline }, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "Member", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static Member { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const Member, + }; + unsafe { + instance.get(Member::new) + } + } +} + +impl ::protobuf::Clear for Member { + fn clear(&mut self) { + self.on_join.clear(); + self.on_leave.clear(); + self.credentials.clear(); + self.pipeline.clear(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for Member { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for Member { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct Member_Element { + // message oneof groups + pub el: ::std::option::Option, + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a Member_Element { + fn default() -> &'a Member_Element { + ::default_instance() + } +} + +#[derive(Clone,PartialEq,Debug)] +pub enum Member_Element_oneof_el { + hub(Hub), + file_recorder(FileRecorder), + relay(Relay), + webrtc_play(WebRtcPlayEndpoint), + webrtc_pub(WebRtcPublishEndpoint), +} + +impl Member_Element { + pub fn new() -> Member_Element { + ::std::default::Default::default() + } + + // .medea.Hub hub = 1; + + + pub fn get_hub(&self) -> &Hub { + match self.el { + ::std::option::Option::Some(Member_Element_oneof_el::hub(ref v)) => v, + _ => Hub::default_instance(), + } + } + pub fn clear_hub(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_hub(&self) -> bool { + match self.el { + ::std::option::Option::Some(Member_Element_oneof_el::hub(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_hub(&mut self, v: Hub) { + self.el = ::std::option::Option::Some(Member_Element_oneof_el::hub(v)) + } + + // Mutable pointer to the field. + pub fn mut_hub(&mut self) -> &mut Hub { + if let ::std::option::Option::Some(Member_Element_oneof_el::hub(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Member_Element_oneof_el::hub(Hub::new())); + } + match self.el { + ::std::option::Option::Some(Member_Element_oneof_el::hub(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_hub(&mut self) -> Hub { + if self.has_hub() { + match self.el.take() { + ::std::option::Option::Some(Member_Element_oneof_el::hub(v)) => v, + _ => panic!(), + } + } else { + Hub::new() + } + } + + // .medea.FileRecorder file_recorder = 2; + + + pub fn get_file_recorder(&self) -> &FileRecorder { + match self.el { + ::std::option::Option::Some(Member_Element_oneof_el::file_recorder(ref v)) => v, + _ => FileRecorder::default_instance(), + } + } + pub fn clear_file_recorder(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_file_recorder(&self) -> bool { + match self.el { + ::std::option::Option::Some(Member_Element_oneof_el::file_recorder(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_file_recorder(&mut self, v: FileRecorder) { + self.el = ::std::option::Option::Some(Member_Element_oneof_el::file_recorder(v)) + } + + // Mutable pointer to the field. + pub fn mut_file_recorder(&mut self) -> &mut FileRecorder { + if let ::std::option::Option::Some(Member_Element_oneof_el::file_recorder(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Member_Element_oneof_el::file_recorder(FileRecorder::new())); + } + match self.el { + ::std::option::Option::Some(Member_Element_oneof_el::file_recorder(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_file_recorder(&mut self) -> FileRecorder { + if self.has_file_recorder() { + match self.el.take() { + ::std::option::Option::Some(Member_Element_oneof_el::file_recorder(v)) => v, + _ => panic!(), + } + } else { + FileRecorder::new() + } + } + + // .medea.Relay relay = 3; + + + pub fn get_relay(&self) -> &Relay { + match self.el { + ::std::option::Option::Some(Member_Element_oneof_el::relay(ref v)) => v, + _ => Relay::default_instance(), + } + } + pub fn clear_relay(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_relay(&self) -> bool { + match self.el { + ::std::option::Option::Some(Member_Element_oneof_el::relay(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_relay(&mut self, v: Relay) { + self.el = ::std::option::Option::Some(Member_Element_oneof_el::relay(v)) + } + + // Mutable pointer to the field. + pub fn mut_relay(&mut self) -> &mut Relay { + if let ::std::option::Option::Some(Member_Element_oneof_el::relay(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Member_Element_oneof_el::relay(Relay::new())); + } + match self.el { + ::std::option::Option::Some(Member_Element_oneof_el::relay(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_relay(&mut self) -> Relay { + if self.has_relay() { + match self.el.take() { + ::std::option::Option::Some(Member_Element_oneof_el::relay(v)) => v, + _ => panic!(), + } + } else { + Relay::new() + } + } + + // .medea.WebRtcPlayEndpoint webrtc_play = 4; + + + pub fn get_webrtc_play(&self) -> &WebRtcPlayEndpoint { + match self.el { + ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(ref v)) => v, + _ => WebRtcPlayEndpoint::default_instance(), + } + } + pub fn clear_webrtc_play(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_webrtc_play(&self) -> bool { + match self.el { + ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_webrtc_play(&mut self, v: WebRtcPlayEndpoint) { + self.el = ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(v)) + } + + // Mutable pointer to the field. + pub fn mut_webrtc_play(&mut self) -> &mut WebRtcPlayEndpoint { + if let ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(WebRtcPlayEndpoint::new())); + } + match self.el { + ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_webrtc_play(&mut self) -> WebRtcPlayEndpoint { + if self.has_webrtc_play() { + match self.el.take() { + ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(v)) => v, + _ => panic!(), + } + } else { + WebRtcPlayEndpoint::new() + } + } + + // .medea.WebRtcPublishEndpoint webrtc_pub = 5; + + + pub fn get_webrtc_pub(&self) -> &WebRtcPublishEndpoint { + match self.el { + ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(ref v)) => v, + _ => WebRtcPublishEndpoint::default_instance(), + } + } + pub fn clear_webrtc_pub(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_webrtc_pub(&self) -> bool { + match self.el { + ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_webrtc_pub(&mut self, v: WebRtcPublishEndpoint) { + self.el = ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(v)) + } + + // Mutable pointer to the field. + pub fn mut_webrtc_pub(&mut self) -> &mut WebRtcPublishEndpoint { + if let ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(WebRtcPublishEndpoint::new())); + } + match self.el { + ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_webrtc_pub(&mut self) -> WebRtcPublishEndpoint { + if self.has_webrtc_pub() { + match self.el.take() { + ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(v)) => v, + _ => panic!(), + } + } else { + WebRtcPublishEndpoint::new() + } + } +} + +impl ::protobuf::Message for Member_Element { + fn is_initialized(&self) -> bool { + if let Some(Member_Element_oneof_el::hub(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(Member_Element_oneof_el::file_recorder(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(Member_Element_oneof_el::relay(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(Member_Element_oneof_el::webrtc_play(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(Member_Element_oneof_el::webrtc_pub(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Member_Element_oneof_el::hub(is.read_message()?)); + }, + 2 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Member_Element_oneof_el::file_recorder(is.read_message()?)); + }, + 3 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Member_Element_oneof_el::relay(is.read_message()?)); + }, + 4 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(is.read_message()?)); + }, + 5 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(is.read_message()?)); + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if let ::std::option::Option::Some(ref v) = self.el { + match v { + &Member_Element_oneof_el::hub(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &Member_Element_oneof_el::file_recorder(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &Member_Element_oneof_el::relay(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &Member_Element_oneof_el::webrtc_play(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &Member_Element_oneof_el::webrtc_pub(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + }; + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + if let ::std::option::Option::Some(ref v) = self.el { + match v { + &Member_Element_oneof_el::hub(ref v) => { + os.write_tag(1, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &Member_Element_oneof_el::file_recorder(ref v) => { + os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &Member_Element_oneof_el::relay(ref v) => { + os.write_tag(3, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &Member_Element_oneof_el::webrtc_play(ref v) => { + os.write_tag(4, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &Member_Element_oneof_el::webrtc_pub(ref v) => { + os.write_tag(5, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + }; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> Member_Element { + Member_Element::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Hub>( + "hub", + Member_Element::has_hub, + Member_Element::get_hub, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, FileRecorder>( + "file_recorder", + Member_Element::has_file_recorder, + Member_Element::get_file_recorder, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Relay>( + "relay", + Member_Element::has_relay, + Member_Element::get_relay, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPlayEndpoint>( + "webrtc_play", + Member_Element::has_webrtc_play, + Member_Element::get_webrtc_play, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPublishEndpoint>( + "webrtc_pub", + Member_Element::has_webrtc_pub, + Member_Element::get_webrtc_pub, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "Member_Element", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static Member_Element { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const Member_Element, + }; + unsafe { + instance.get(Member_Element::new) + } + } +} + +impl ::protobuf::Clear for Member_Element { + fn clear(&mut self) { + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for Member_Element { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for Member_Element { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct WebRtcPublishEndpoint { + // message fields + pub p2p: WebRtcPublishEndpoint_P2P, + pub dst: ::std::string::String, + pub on_start: ::std::string::String, + pub on_stop: ::std::string::String, + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a WebRtcPublishEndpoint { + fn default() -> &'a WebRtcPublishEndpoint { + ::default_instance() + } +} + +impl WebRtcPublishEndpoint { + pub fn new() -> WebRtcPublishEndpoint { + ::std::default::Default::default() + } + + // .medea.WebRtcPublishEndpoint.P2P p2p = 1; + + + pub fn get_p2p(&self) -> WebRtcPublishEndpoint_P2P { + self.p2p + } + pub fn clear_p2p(&mut self) { + self.p2p = WebRtcPublishEndpoint_P2P::NEVER; + } + + // Param is passed by value, moved + pub fn set_p2p(&mut self, v: WebRtcPublishEndpoint_P2P) { + self.p2p = v; + } + + // string dst = 2; + + + pub fn get_dst(&self) -> &str { + &self.dst + } + pub fn clear_dst(&mut self) { + self.dst.clear(); + } + + // Param is passed by value, moved + pub fn set_dst(&mut self, v: ::std::string::String) { + self.dst = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_dst(&mut self) -> &mut ::std::string::String { + &mut self.dst + } + + // Take field + pub fn take_dst(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.dst, ::std::string::String::new()) + } + + // string on_start = 3; + + + pub fn get_on_start(&self) -> &str { + &self.on_start + } + pub fn clear_on_start(&mut self) { + self.on_start.clear(); + } + + // Param is passed by value, moved + pub fn set_on_start(&mut self, v: ::std::string::String) { + self.on_start = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_on_start(&mut self) -> &mut ::std::string::String { + &mut self.on_start + } + + // Take field + pub fn take_on_start(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.on_start, ::std::string::String::new()) + } + + // string on_stop = 4; + + + pub fn get_on_stop(&self) -> &str { + &self.on_stop + } + pub fn clear_on_stop(&mut self) { + self.on_stop.clear(); + } + + // Param is passed by value, moved + pub fn set_on_stop(&mut self, v: ::std::string::String) { + self.on_stop = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_on_stop(&mut self) -> &mut ::std::string::String { + &mut self.on_stop + } + + // Take field + pub fn take_on_stop(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.on_stop, ::std::string::String::new()) + } +} + +impl ::protobuf::Message for WebRtcPublishEndpoint { + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_proto3_enum_with_unknown_fields_into(wire_type, is, &mut self.p2p, 1, &mut self.unknown_fields)? + }, + 2 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.dst)?; + }, + 3 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.on_start)?; + }, + 4 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.on_stop)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if self.p2p != WebRtcPublishEndpoint_P2P::NEVER { + my_size += ::protobuf::rt::enum_size(1, self.p2p); + } + if !self.dst.is_empty() { + my_size += ::protobuf::rt::string_size(2, &self.dst); + } + if !self.on_start.is_empty() { + my_size += ::protobuf::rt::string_size(3, &self.on_start); + } + if !self.on_stop.is_empty() { + my_size += ::protobuf::rt::string_size(4, &self.on_stop); + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + if self.p2p != WebRtcPublishEndpoint_P2P::NEVER { + os.write_enum(1, self.p2p.value())?; + } + if !self.dst.is_empty() { + os.write_string(2, &self.dst)?; + } + if !self.on_start.is_empty() { + os.write_string(3, &self.on_start)?; + } + if !self.on_stop.is_empty() { + os.write_string(4, &self.on_stop)?; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> WebRtcPublishEndpoint { + WebRtcPublishEndpoint::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeEnum>( + "p2p", + |m: &WebRtcPublishEndpoint| { &m.p2p }, + |m: &mut WebRtcPublishEndpoint| { &mut m.p2p }, + )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "dst", + |m: &WebRtcPublishEndpoint| { &m.dst }, + |m: &mut WebRtcPublishEndpoint| { &mut m.dst }, + )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "on_start", + |m: &WebRtcPublishEndpoint| { &m.on_start }, + |m: &mut WebRtcPublishEndpoint| { &mut m.on_start }, + )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "on_stop", + |m: &WebRtcPublishEndpoint| { &m.on_stop }, + |m: &mut WebRtcPublishEndpoint| { &mut m.on_stop }, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "WebRtcPublishEndpoint", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static WebRtcPublishEndpoint { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const WebRtcPublishEndpoint, + }; + unsafe { + instance.get(WebRtcPublishEndpoint::new) + } + } +} + +impl ::protobuf::Clear for WebRtcPublishEndpoint { + fn clear(&mut self) { + self.p2p = WebRtcPublishEndpoint_P2P::NEVER; + self.dst.clear(); + self.on_start.clear(); + self.on_stop.clear(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for WebRtcPublishEndpoint { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for WebRtcPublishEndpoint { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(Clone,PartialEq,Eq,Debug,Hash)] +pub enum WebRtcPublishEndpoint_P2P { + NEVER = 0, + IF_POSSIBLE = 1, + ALWAYS = 2, +} + +impl ::protobuf::ProtobufEnum for WebRtcPublishEndpoint_P2P { + fn value(&self) -> i32 { + *self as i32 + } + + fn from_i32(value: i32) -> ::std::option::Option { + match value { + 0 => ::std::option::Option::Some(WebRtcPublishEndpoint_P2P::NEVER), + 1 => ::std::option::Option::Some(WebRtcPublishEndpoint_P2P::IF_POSSIBLE), + 2 => ::std::option::Option::Some(WebRtcPublishEndpoint_P2P::ALWAYS), + _ => ::std::option::Option::None + } + } + + fn values() -> &'static [Self] { + static values: &'static [WebRtcPublishEndpoint_P2P] = &[ + WebRtcPublishEndpoint_P2P::NEVER, + WebRtcPublishEndpoint_P2P::IF_POSSIBLE, + WebRtcPublishEndpoint_P2P::ALWAYS, + ]; + values + } + + fn enum_descriptor_static() -> &'static ::protobuf::reflect::EnumDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::EnumDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::EnumDescriptor, + }; + unsafe { + descriptor.get(|| { + ::protobuf::reflect::EnumDescriptor::new("WebRtcPublishEndpoint_P2P", file_descriptor_proto()) + }) + } + } +} + +impl ::std::marker::Copy for WebRtcPublishEndpoint_P2P { +} + +impl ::std::default::Default for WebRtcPublishEndpoint_P2P { + fn default() -> Self { + WebRtcPublishEndpoint_P2P::NEVER + } +} + +impl ::protobuf::reflect::ProtobufValue for WebRtcPublishEndpoint_P2P { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Enum(self.descriptor()) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct WebRtcPlayEndpoint { + // message fields + pub src: ::std::string::String, + pub on_start: ::std::string::String, + pub on_stop: ::std::string::String, + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a WebRtcPlayEndpoint { + fn default() -> &'a WebRtcPlayEndpoint { + ::default_instance() + } +} + +impl WebRtcPlayEndpoint { + pub fn new() -> WebRtcPlayEndpoint { + ::std::default::Default::default() + } + + // string src = 1; + + + pub fn get_src(&self) -> &str { + &self.src + } + pub fn clear_src(&mut self) { + self.src.clear(); + } + + // Param is passed by value, moved + pub fn set_src(&mut self, v: ::std::string::String) { + self.src = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_src(&mut self) -> &mut ::std::string::String { + &mut self.src + } + + // Take field + pub fn take_src(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.src, ::std::string::String::new()) + } + + // string on_start = 2; + + + pub fn get_on_start(&self) -> &str { + &self.on_start + } + pub fn clear_on_start(&mut self) { + self.on_start.clear(); + } + + // Param is passed by value, moved + pub fn set_on_start(&mut self, v: ::std::string::String) { + self.on_start = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_on_start(&mut self) -> &mut ::std::string::String { + &mut self.on_start + } + + // Take field + pub fn take_on_start(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.on_start, ::std::string::String::new()) + } + + // string on_stop = 3; + + + pub fn get_on_stop(&self) -> &str { + &self.on_stop + } + pub fn clear_on_stop(&mut self) { + self.on_stop.clear(); + } + + // Param is passed by value, moved + pub fn set_on_stop(&mut self, v: ::std::string::String) { + self.on_stop = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_on_stop(&mut self) -> &mut ::std::string::String { + &mut self.on_stop + } + + // Take field + pub fn take_on_stop(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.on_stop, ::std::string::String::new()) + } +} + +impl ::protobuf::Message for WebRtcPlayEndpoint { + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.src)?; + }, + 2 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.on_start)?; + }, + 3 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.on_stop)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if !self.src.is_empty() { + my_size += ::protobuf::rt::string_size(1, &self.src); + } + if !self.on_start.is_empty() { + my_size += ::protobuf::rt::string_size(2, &self.on_start); + } + if !self.on_stop.is_empty() { + my_size += ::protobuf::rt::string_size(3, &self.on_stop); + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + if !self.src.is_empty() { + os.write_string(1, &self.src)?; + } + if !self.on_start.is_empty() { + os.write_string(2, &self.on_start)?; + } + if !self.on_stop.is_empty() { + os.write_string(3, &self.on_stop)?; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> WebRtcPlayEndpoint { + WebRtcPlayEndpoint::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "src", + |m: &WebRtcPlayEndpoint| { &m.src }, + |m: &mut WebRtcPlayEndpoint| { &mut m.src }, + )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "on_start", + |m: &WebRtcPlayEndpoint| { &m.on_start }, + |m: &mut WebRtcPlayEndpoint| { &mut m.on_start }, + )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "on_stop", + |m: &WebRtcPlayEndpoint| { &m.on_stop }, + |m: &mut WebRtcPlayEndpoint| { &mut m.on_stop }, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "WebRtcPlayEndpoint", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static WebRtcPlayEndpoint { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const WebRtcPlayEndpoint, + }; + unsafe { + instance.get(WebRtcPlayEndpoint::new) + } + } +} + +impl ::protobuf::Clear for WebRtcPlayEndpoint { + fn clear(&mut self) { + self.src.clear(); + self.on_start.clear(); + self.on_stop.clear(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for WebRtcPlayEndpoint { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for WebRtcPlayEndpoint { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct Hub { + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a Hub { + fn default() -> &'a Hub { + ::default_instance() + } +} + +impl Hub { + pub fn new() -> Hub { + ::std::default::Default::default() + } +} + +impl ::protobuf::Message for Hub { + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> Hub { + Hub::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let fields = ::std::vec::Vec::new(); + ::protobuf::reflect::MessageDescriptor::new::( + "Hub", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static Hub { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const Hub, + }; + unsafe { + instance.get(Hub::new) + } + } +} + +impl ::protobuf::Clear for Hub { + fn clear(&mut self) { + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for Hub { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for Hub { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct FileRecorder { + // message fields + pub src: ::std::string::String, + pub dst: ::std::string::String, + pub on_start: ::std::string::String, + pub on_stop: ::std::string::String, + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a FileRecorder { + fn default() -> &'a FileRecorder { + ::default_instance() + } +} + +impl FileRecorder { + pub fn new() -> FileRecorder { + ::std::default::Default::default() + } + + // string src = 1; + + + pub fn get_src(&self) -> &str { + &self.src + } + pub fn clear_src(&mut self) { + self.src.clear(); + } + + // Param is passed by value, moved + pub fn set_src(&mut self, v: ::std::string::String) { + self.src = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_src(&mut self) -> &mut ::std::string::String { + &mut self.src + } + + // Take field + pub fn take_src(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.src, ::std::string::String::new()) + } + + // string dst = 2; + + + pub fn get_dst(&self) -> &str { + &self.dst + } + pub fn clear_dst(&mut self) { + self.dst.clear(); + } + + // Param is passed by value, moved + pub fn set_dst(&mut self, v: ::std::string::String) { + self.dst = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_dst(&mut self) -> &mut ::std::string::String { + &mut self.dst + } + + // Take field + pub fn take_dst(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.dst, ::std::string::String::new()) + } + + // string on_start = 3; + + + pub fn get_on_start(&self) -> &str { + &self.on_start + } + pub fn clear_on_start(&mut self) { + self.on_start.clear(); + } + + // Param is passed by value, moved + pub fn set_on_start(&mut self, v: ::std::string::String) { + self.on_start = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_on_start(&mut self) -> &mut ::std::string::String { + &mut self.on_start + } + + // Take field + pub fn take_on_start(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.on_start, ::std::string::String::new()) + } + + // string on_stop = 4; + + + pub fn get_on_stop(&self) -> &str { + &self.on_stop + } + pub fn clear_on_stop(&mut self) { + self.on_stop.clear(); + } + + // Param is passed by value, moved + pub fn set_on_stop(&mut self, v: ::std::string::String) { + self.on_stop = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_on_stop(&mut self) -> &mut ::std::string::String { + &mut self.on_stop + } + + // Take field + pub fn take_on_stop(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.on_stop, ::std::string::String::new()) + } +} + +impl ::protobuf::Message for FileRecorder { + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.src)?; + }, + 2 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.dst)?; + }, + 3 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.on_start)?; + }, + 4 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.on_stop)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if !self.src.is_empty() { + my_size += ::protobuf::rt::string_size(1, &self.src); + } + if !self.dst.is_empty() { + my_size += ::protobuf::rt::string_size(2, &self.dst); + } + if !self.on_start.is_empty() { + my_size += ::protobuf::rt::string_size(3, &self.on_start); + } + if !self.on_stop.is_empty() { + my_size += ::protobuf::rt::string_size(4, &self.on_stop); + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + if !self.src.is_empty() { + os.write_string(1, &self.src)?; + } + if !self.dst.is_empty() { + os.write_string(2, &self.dst)?; + } + if !self.on_start.is_empty() { + os.write_string(3, &self.on_start)?; + } + if !self.on_stop.is_empty() { + os.write_string(4, &self.on_stop)?; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> FileRecorder { + FileRecorder::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "src", + |m: &FileRecorder| { &m.src }, + |m: &mut FileRecorder| { &mut m.src }, + )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "dst", + |m: &FileRecorder| { &m.dst }, + |m: &mut FileRecorder| { &mut m.dst }, + )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "on_start", + |m: &FileRecorder| { &m.on_start }, + |m: &mut FileRecorder| { &mut m.on_start }, + )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "on_stop", + |m: &FileRecorder| { &m.on_stop }, + |m: &mut FileRecorder| { &mut m.on_stop }, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "FileRecorder", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static FileRecorder { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const FileRecorder, + }; + unsafe { + instance.get(FileRecorder::new) + } + } +} + +impl ::protobuf::Clear for FileRecorder { + fn clear(&mut self) { + self.src.clear(); + self.dst.clear(); + self.on_start.clear(); + self.on_stop.clear(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for FileRecorder { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for FileRecorder { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct Relay { + // message fields + pub src: ::std::string::String, + pub dst: ::std::string::String, + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a Relay { + fn default() -> &'a Relay { + ::default_instance() + } +} + +impl Relay { + pub fn new() -> Relay { + ::std::default::Default::default() + } + + // string src = 1; + + + pub fn get_src(&self) -> &str { + &self.src + } + pub fn clear_src(&mut self) { + self.src.clear(); + } + + // Param is passed by value, moved + pub fn set_src(&mut self, v: ::std::string::String) { + self.src = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_src(&mut self) -> &mut ::std::string::String { + &mut self.src + } + + // Take field + pub fn take_src(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.src, ::std::string::String::new()) + } + + // string dst = 2; + + + pub fn get_dst(&self) -> &str { + &self.dst + } + pub fn clear_dst(&mut self) { + self.dst.clear(); + } + + // Param is passed by value, moved + pub fn set_dst(&mut self, v: ::std::string::String) { + self.dst = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_dst(&mut self) -> &mut ::std::string::String { + &mut self.dst + } + + // Take field + pub fn take_dst(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.dst, ::std::string::String::new()) + } +} + +impl ::protobuf::Message for Relay { + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.src)?; + }, + 2 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.dst)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if !self.src.is_empty() { + my_size += ::protobuf::rt::string_size(1, &self.src); + } + if !self.dst.is_empty() { + my_size += ::protobuf::rt::string_size(2, &self.dst); + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + if !self.src.is_empty() { + os.write_string(1, &self.src)?; + } + if !self.dst.is_empty() { + os.write_string(2, &self.dst)?; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> Relay { + Relay::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "src", + |m: &Relay| { &m.src }, + |m: &mut Relay| { &mut m.src }, + )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "dst", + |m: &Relay| { &m.dst }, + |m: &mut Relay| { &mut m.dst }, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "Relay", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static Relay { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const Relay, + }; + unsafe { + instance.get(Relay::new) + } + } +} + +impl ::protobuf::Clear for Relay { + fn clear(&mut self) { + self.src.clear(); + self.dst.clear(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for Relay { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for Relay { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +static file_descriptor_proto_data: &'static [u8] = b"\ + \n\rcontrol.proto\x12\x05medea\x1a\x19google/protobuf/any.proto\"\xf0\ + \x02\n\rCreateRequest\x12\x0e\n\x02id\x18\x01\x20\x01(\tR\x02id\x12\x1e\ + \n\x03hub\x18\x02\x20\x01(\x0b2\n.medea.HubH\0R\x03hub\x12:\n\rfile_reco\ + rder\x18\x03\x20\x01(\x0b2\x13.medea.FileRecorderH\0R\x0cfileRecorder\ + \x12'\n\x06member\x18\x04\x20\x01(\x0b2\r.medea.MemberH\0R\x06member\x12\ + $\n\x05relay\x18\x05\x20\x01(\x0b2\x0c.medea.RelayH\0R\x05relay\x12!\n\ + \x04room\x18\x06\x20\x01(\x0b2\x0b.medea.RoomH\0R\x04room\x12<\n\x0bwebr\ + tc_play\x18\x07\x20\x01(\x0b2\x19.medea.WebRtcPlayEndpointH\0R\nwebrtcPl\ + ay\x12=\n\nwebrtc_pub\x18\x08\x20\x01(\x0b2\x1c.medea.WebRtcPublishEndpo\ + intH\0R\twebrtcPubB\x04\n\x02el\"\xc4\x03\n\x0cApplyRequest\x12\x0e\n\ + \x02id\x18\x01\x20\x01(\tR\x02id\x12\x1e\n\x03hub\x18\x02\x20\x01(\x0b2\ + \n.medea.HubH\0R\x03hub\x12:\n\rfile_recorder\x18\x03\x20\x01(\x0b2\x13.\ + medea.FileRecorderH\0R\x0cfileRecorder\x12'\n\x06member\x18\x04\x20\x01(\ + \x0b2\r.medea.MemberH\0R\x06member\x12$\n\x05relay\x18\x05\x20\x01(\x0b2\ + \x0c.medea.RelayH\0R\x05relay\x12!\n\x04room\x18\x06\x20\x01(\x0b2\x0b.m\ + edea.RoomH\0R\x04room\x12<\n\x0bwebrtc_play\x18\x07\x20\x01(\x0b2\x19.me\ + dea.WebRtcPlayEndpointH\0R\nwebrtcPlay\x12=\n\nwebrtc_pub\x18\x08\x20\ + \x01(\x0b2\x1c.medea.WebRtcPublishEndpointH\0R\twebrtcPub\x122\n\x06poli\ + cy\x18\t\x20\x01(\x0e2\x1a.medea.ApplyRequest.PolicyR\x06policy\"\x1f\n\ + \x06Policy\x12\t\n\x05APPLY\x10\0\x12\n\n\x06APPEND\x10\x01B\x04\n\x02el\ + \"\x1b\n\tIdRequest\x12\x0e\n\x02id\x18\x01\x20\x03(\tR\x02id\"\x92\x01\ + \n\x08Response\x12*\n\x03sid\x18\x01\x20\x03(\x0b2\x18.medea.Response.Si\ + dEntryR\x03sid\x12\"\n\x05error\x18\x02\x20\x01(\x0b2\x0c.medea.ErrorR\ + \x05error\x1a6\n\x08SidEntry\x12\x10\n\x03key\x18\x01\x20\x01(\tR\x03key\ + \x12\x14\n\x05value\x18\x02\x20\x01(\tR\x05value:\x028\x01\"\xbc\x01\n\ + \x0bGetResponse\x12<\n\x08elements\x18\x01\x20\x03(\x0b2\x20.medea.GetRe\ + sponse.ElementsEntryR\x08elements\x12\"\n\x05error\x18\x02\x20\x01(\x0b2\ + \x0c.medea.ErrorR\x05error\x1aK\n\rElementsEntry\x12\x10\n\x03key\x18\ + \x01\x20\x01(\tR\x03key\x12$\n\x05value\x18\x02\x20\x01(\x0b2\x0e.medea.\ + ElementR\x05value:\x028\x01\"\xa9\x01\n\x05Error\x12\x12\n\x04code\x18\ + \x02\x20\x01(\rR\x04code\x12\x12\n\x04text\x18\x03\x20\x01(\tR\x04text\ + \x12\x10\n\x03doc\x18\x04\x20\x01(\tR\x03doc\x12\x18\n\x07element\x18\ + \x05\x20\x01(\tR\x07element\x12.\n\x07details\x18\x06\x20\x01(\x0b2\x14.\ + google.protobuf.AnyR\x07details\x12\x1c\n\tbacktrace\x18\x07\x20\x03(\tR\ + \tbacktrace\"\xda\x02\n\x07Element\x12\x1e\n\x03hub\x18\x02\x20\x01(\x0b\ + 2\n.medea.HubH\0R\x03hub\x12:\n\rfile_recorder\x18\x03\x20\x01(\x0b2\x13\ + .medea.FileRecorderH\0R\x0cfileRecorder\x12'\n\x06member\x18\x04\x20\x01\ + (\x0b2\r.medea.MemberH\0R\x06member\x12$\n\x05relay\x18\x05\x20\x01(\x0b\ + 2\x0c.medea.RelayH\0R\x05relay\x12!\n\x04room\x18\x06\x20\x01(\x0b2\x0b.\ + medea.RoomH\0R\x04room\x12<\n\x0bwebrtc_play\x18\x07\x20\x01(\x0b2\x19.m\ + edea.WebRtcPlayEndpointH\0R\nwebrtcPlay\x12=\n\nwebrtc_pub\x18\x08\x20\ + \x01(\x0b2\x1c.medea.WebRtcPublishEndpointH\0R\twebrtcPubB\x04\n\x02el\"\ + \xc9\x03\n\x04Room\x125\n\x08pipeline\x18\x01\x20\x03(\x0b2\x19.medea.Ro\ + om.PipelineEntryR\x08pipeline\x1aP\n\rPipelineEntry\x12\x10\n\x03key\x18\ + \x01\x20\x01(\tR\x03key\x12)\n\x05value\x18\x02\x20\x01(\x0b2\x13.medea.\ + Room.ElementR\x05value:\x028\x01\x1a\xb7\x02\n\x07Element\x12\x1e\n\x03h\ + ub\x18\x01\x20\x01(\x0b2\n.medea.HubH\0R\x03hub\x12:\n\rfile_recorder\ + \x18\x02\x20\x01(\x0b2\x13.medea.FileRecorderH\0R\x0cfileRecorder\x12'\n\ + \x06member\x18\x03\x20\x01(\x0b2\r.medea.MemberH\0R\x06member\x12$\n\x05\ + relay\x18\x04\x20\x01(\x0b2\x0c.medea.RelayH\0R\x05relay\x12<\n\x0bwebrt\ + c_play\x18\x05\x20\x01(\x0b2\x19.medea.WebRtcPlayEndpointH\0R\nwebrtcPla\ + y\x12=\n\nwebrtc_pub\x18\x06\x20\x01(\x0b2\x1c.medea.WebRtcPublishEndpoi\ + ntH\0R\twebrtcPubB\x04\n\x02el\"\xfc\x03\n\x06Member\x12\x17\n\x07on_joi\ + n\x18\x01\x20\x01(\tR\x06onJoin\x12\x19\n\x08on_leave\x18\x02\x20\x01(\t\ + R\x07onLeave\x12\x20\n\x0bcredentials\x18\x03\x20\x01(\tR\x0bcredentials\ + \x127\n\x08pipeline\x18\x04\x20\x03(\x0b2\x1b.medea.Member.PipelineEntry\ + R\x08pipeline\x1aR\n\rPipelineEntry\x12\x10\n\x03key\x18\x01\x20\x01(\tR\ + \x03key\x12+\n\x05value\x18\x02\x20\x01(\x0b2\x15.medea.Member.ElementR\ + \x05value:\x028\x01\x1a\x8e\x02\n\x07Element\x12\x1e\n\x03hub\x18\x01\ + \x20\x01(\x0b2\n.medea.HubH\0R\x03hub\x12:\n\rfile_recorder\x18\x02\x20\ + \x01(\x0b2\x13.medea.FileRecorderH\0R\x0cfileRecorder\x12$\n\x05relay\ + \x18\x03\x20\x01(\x0b2\x0c.medea.RelayH\0R\x05relay\x12<\n\x0bwebrtc_pla\ + y\x18\x04\x20\x01(\x0b2\x19.medea.WebRtcPlayEndpointH\0R\nwebrtcPlay\x12\ + =\n\nwebrtc_pub\x18\x05\x20\x01(\x0b2\x1c.medea.WebRtcPublishEndpointH\0\ + R\twebrtcPubB\x04\n\x02el\"\xc0\x01\n\x15WebRtcPublishEndpoint\x122\n\ + \x03p2p\x18\x01\x20\x01(\x0e2\x20.medea.WebRtcPublishEndpoint.P2PR\x03p2\ + p\x12\x10\n\x03dst\x18\x02\x20\x01(\tR\x03dst\x12\x19\n\x08on_start\x18\ + \x03\x20\x01(\tR\x07onStart\x12\x17\n\x07on_stop\x18\x04\x20\x01(\tR\x06\ + onStop\"-\n\x03P2P\x12\t\n\x05NEVER\x10\0\x12\x0f\n\x0bIF_POSSIBLE\x10\ + \x01\x12\n\n\x06ALWAYS\x10\x02\"Z\n\x12WebRtcPlayEndpoint\x12\x10\n\x03s\ + rc\x18\x01\x20\x01(\tR\x03src\x12\x19\n\x08on_start\x18\x02\x20\x01(\tR\ + \x07onStart\x12\x17\n\x07on_stop\x18\x03\x20\x01(\tR\x06onStop\"\x05\n\ + \x03Hub\"f\n\x0cFileRecorder\x12\x10\n\x03src\x18\x01\x20\x01(\tR\x03src\ + \x12\x10\n\x03dst\x18\x02\x20\x01(\tR\x03dst\x12\x19\n\x08on_start\x18\ + \x03\x20\x01(\tR\x07onStart\x12\x17\n\x07on_stop\x18\x04\x20\x01(\tR\x06\ + onStop\"+\n\x05Relay\x12\x10\n\x03src\x18\x01\x20\x01(\tR\x03src\x12\x10\ + \n\x03dst\x18\x02\x20\x01(\tR\x03dst2\xc6\x01\n\nControlApi\x12/\n\x06Cr\ + eate\x12\x14.medea.CreateRequest\x1a\x0f.medea.Response\x12-\n\x05Apply\ + \x12\x13.medea.ApplyRequest\x1a\x0f.medea.Response\x12+\n\x06Delete\x12\ + \x10.medea.IdRequest\x1a\x0f.medea.Response\x12+\n\x03Get\x12\x10.medea.\ + IdRequest\x1a\x12.medea.GetResponseb\x06proto3\ +"; + +static mut file_descriptor_proto_lazy: ::protobuf::lazy::Lazy<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::descriptor::FileDescriptorProto, +}; + +fn parse_descriptor_proto() -> ::protobuf::descriptor::FileDescriptorProto { + ::protobuf::parse_from_bytes(file_descriptor_proto_data).unwrap() +} + +pub fn file_descriptor_proto() -> &'static ::protobuf::descriptor::FileDescriptorProto { + unsafe { + file_descriptor_proto_lazy.get(|| { + parse_descriptor_proto() + }) + } +} diff --git a/src/api/control/grpc/protos/control_grpc.rs b/src/api/control/grpc/protos/control_grpc.rs new file mode 100644 index 000000000..200c56a85 --- /dev/null +++ b/src/api/control/grpc/protos/control_grpc.rs @@ -0,0 +1,155 @@ +// This file is generated. Do not edit +// @generated + +// https://github.com/Manishearth/rust-clippy/issues/702 +#![allow(unknown_lints)] +#![allow(clippy::all)] + +#![cfg_attr(rustfmt, rustfmt_skip)] + +#![allow(box_pointers)] +#![allow(dead_code)] +#![allow(missing_docs)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] +#![allow(non_upper_case_globals)] +#![allow(trivial_casts)] +#![allow(unsafe_code)] +#![allow(unused_imports)] +#![allow(unused_results)] + +const METHOD_CONTROL_API_CREATE: ::grpcio::Method = ::grpcio::Method { + ty: ::grpcio::MethodType::Unary, + name: "/medea.ControlApi/Create", + req_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, + resp_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, +}; + +const METHOD_CONTROL_API_APPLY: ::grpcio::Method = ::grpcio::Method { + ty: ::grpcio::MethodType::Unary, + name: "/medea.ControlApi/Apply", + req_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, + resp_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, +}; + +const METHOD_CONTROL_API_DELETE: ::grpcio::Method = ::grpcio::Method { + ty: ::grpcio::MethodType::Unary, + name: "/medea.ControlApi/Delete", + req_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, + resp_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, +}; + +const METHOD_CONTROL_API_GET: ::grpcio::Method = ::grpcio::Method { + ty: ::grpcio::MethodType::Unary, + name: "/medea.ControlApi/Get", + req_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, + resp_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, +}; + +#[derive(Clone)] +pub struct ControlApiClient { + client: ::grpcio::Client, +} + +impl ControlApiClient { + pub fn new(channel: ::grpcio::Channel) -> Self { + ControlApiClient { + client: ::grpcio::Client::new(channel), + } + } + + pub fn create_opt(&self, req: &super::control::CreateRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result { + self.client.unary_call(&METHOD_CONTROL_API_CREATE, req, opt) + } + + pub fn create(&self, req: &super::control::CreateRequest) -> ::grpcio::Result { + self.create_opt(req, ::grpcio::CallOption::default()) + } + + pub fn create_async_opt(&self, req: &super::control::CreateRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { + self.client.unary_call_async(&METHOD_CONTROL_API_CREATE, req, opt) + } + + pub fn create_async(&self, req: &super::control::CreateRequest) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { + self.create_async_opt(req, ::grpcio::CallOption::default()) + } + + pub fn apply_opt(&self, req: &super::control::ApplyRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result { + self.client.unary_call(&METHOD_CONTROL_API_APPLY, req, opt) + } + + pub fn apply(&self, req: &super::control::ApplyRequest) -> ::grpcio::Result { + self.apply_opt(req, ::grpcio::CallOption::default()) + } + + pub fn apply_async_opt(&self, req: &super::control::ApplyRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { + self.client.unary_call_async(&METHOD_CONTROL_API_APPLY, req, opt) + } + + pub fn apply_async(&self, req: &super::control::ApplyRequest) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { + self.apply_async_opt(req, ::grpcio::CallOption::default()) + } + + pub fn delete_opt(&self, req: &super::control::IdRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result { + self.client.unary_call(&METHOD_CONTROL_API_DELETE, req, opt) + } + + pub fn delete(&self, req: &super::control::IdRequest) -> ::grpcio::Result { + self.delete_opt(req, ::grpcio::CallOption::default()) + } + + pub fn delete_async_opt(&self, req: &super::control::IdRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { + self.client.unary_call_async(&METHOD_CONTROL_API_DELETE, req, opt) + } + + pub fn delete_async(&self, req: &super::control::IdRequest) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { + self.delete_async_opt(req, ::grpcio::CallOption::default()) + } + + pub fn get_opt(&self, req: &super::control::IdRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result { + self.client.unary_call(&METHOD_CONTROL_API_GET, req, opt) + } + + pub fn get(&self, req: &super::control::IdRequest) -> ::grpcio::Result { + self.get_opt(req, ::grpcio::CallOption::default()) + } + + pub fn get_async_opt(&self, req: &super::control::IdRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { + self.client.unary_call_async(&METHOD_CONTROL_API_GET, req, opt) + } + + pub fn get_async(&self, req: &super::control::IdRequest) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { + self.get_async_opt(req, ::grpcio::CallOption::default()) + } + pub fn spawn(&self, f: F) where F: ::futures::Future + Send + 'static { + self.client.spawn(f) + } +} + +pub trait ControlApi { + fn create(&mut self, ctx: ::grpcio::RpcContext, req: super::control::CreateRequest, sink: ::grpcio::UnarySink); + fn apply(&mut self, ctx: ::grpcio::RpcContext, req: super::control::ApplyRequest, sink: ::grpcio::UnarySink); + fn delete(&mut self, ctx: ::grpcio::RpcContext, req: super::control::IdRequest, sink: ::grpcio::UnarySink); + fn get(&mut self, ctx: ::grpcio::RpcContext, req: super::control::IdRequest, sink: ::grpcio::UnarySink); +} + +pub fn create_control_api(s: S) -> ::grpcio::Service { + let mut builder = ::grpcio::ServiceBuilder::new(); + let mut instance = s.clone(); + builder = builder.add_unary_handler(&METHOD_CONTROL_API_CREATE, move |ctx, req, resp| { + instance.create(ctx, req, resp) + }); + let mut instance = s.clone(); + builder = builder.add_unary_handler(&METHOD_CONTROL_API_APPLY, move |ctx, req, resp| { + instance.apply(ctx, req, resp) + }); + let mut instance = s.clone(); + builder = builder.add_unary_handler(&METHOD_CONTROL_API_DELETE, move |ctx, req, resp| { + instance.delete(ctx, req, resp) + }); + let mut instance = s.clone(); + builder = builder.add_unary_handler(&METHOD_CONTROL_API_GET, move |ctx, req, resp| { + instance.get(ctx, req, resp) + }); + builder.build() +} diff --git a/tests/e2e/signalling/mod.rs b/tests/e2e/signalling/mod.rs index c68454bb4..7cb639801 100644 --- a/tests/e2e/signalling/mod.rs +++ b/tests/e2e/signalling/mod.rs @@ -154,10 +154,7 @@ impl StreamHandler for TestMember { sdp_offer: "caller_offer".into(), mids: tracks .into_iter() - .filter_map(|t| match t.direction { - Direction::Send { .. } => Some(t.id), - Direction::Recv { .. } => None, - }) + .map(|t| t.id) .enumerate() .map(|(mid, id)| (id, mid.to_string())) .collect(), From caa9cbf04312cff7cc12cc4ed94ff7f0456f5143 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 15 Jul 2019 19:49:20 +0300 Subject: [PATCH 362/735] Fix warns --- src/lib.rs | 1 - src/main.rs | 1 - src/turn/service.rs | 2 +- 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index fd9362a47..8f8c74ddd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -19,7 +19,6 @@ use crate::{ signalling::{room::RoomError, Room}, turn::{service, TurnServiceErr}, }; -use bb8::Pool; use futures::future::Either; use std::sync::{Arc, Mutex}; diff --git a/src/main.rs b/src/main.rs index 87633521f..6bccf9817 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,3 @@ -use actix::System; use failure::Error; use futures::future::Future; use medea::{ diff --git a/src/turn/service.rs b/src/turn/service.rs index 3e65776df..7551e6872 100644 --- a/src/turn/service.rs +++ b/src/turn/service.rs @@ -13,7 +13,7 @@ use redis::ConnectionInfo; use crate::{ api::control::{MemberId, RoomId}, - conf::{self, Conf}, + conf, media::IceUser, turn::repo::{TurnDatabase, TurnDatabaseErr}, }; From ade1ec58104111bc7474422338e326ce0afd2892 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 15 Jul 2019 19:58:40 +0300 Subject: [PATCH 363/735] Fix unit tests, delete outdated tests --- proto/client-api/src/lib.rs | 1 - src/api/client/rpc_connection.rs | 147 ------------------------ src/media/mod.rs | 2 +- src/media/peer.rs | 74 ------------ src/signalling/room.rs | 186 ------------------------------- src/turn/service.rs | 7 +- 6 files changed, 6 insertions(+), 411 deletions(-) diff --git a/proto/client-api/src/lib.rs b/proto/client-api/src/lib.rs index 20fc3ab8a..a207b1e1a 100644 --- a/proto/client-api/src/lib.rs +++ b/proto/client-api/src/lib.rs @@ -124,7 +124,6 @@ pub struct IceServer { /// Direction of [`Track`]. #[cfg_attr(feature = "medea", derive(Serialize, Debug, Clone, PartialEq))] #[cfg_attr(feature = "jason", derive(Deserialize))] -#[cfg_attr(test, derive(Debug, PartialEq))] // TODO: Use different struct without mids in TracksApplied event. pub enum Direction { Send { diff --git a/src/api/client/rpc_connection.rs b/src/api/client/rpc_connection.rs index c552eddeb..807eb9ba7 100644 --- a/src/api/client/rpc_connection.rs +++ b/src/api/client/rpc_connection.rs @@ -86,150 +86,3 @@ pub enum ClosedReason { /// [`RpcConnection`] was lost, but may be reestablished. Lost, } - -#[cfg(test)] -pub mod test { - use std::sync::{ - atomic::{AtomicUsize, Ordering}, - Arc, Mutex, - }; - - use actix::{ - Actor, ActorContext, Addr, AsyncContext, Context, Handler, Message, - System, - }; - use futures::future::Future; - use medea_client_api_proto::{Command, Direction, Event, IceCandidate}; - - use crate::{ - api::{ - client::rpc_connection::{ - ClosedReason, CommandMessage, EventMessage, RpcConnection, - RpcConnectionClosed, RpcConnectionEstablished, - }, - control::MemberId, - }, - signalling::Room, - }; - - /// [`RpcConnection`] impl convenient for testing. - #[derive(Debug, Clone)] - pub struct TestConnection { - pub member_id: MemberId, - pub room: Addr, - pub events: Arc>>, - pub stopped: Arc, - } - - impl Actor for TestConnection { - type Context = Context; - - fn started(&mut self, ctx: &mut Self::Context) { - self.room - .try_send(RpcConnectionEstablished { - member_id: self.member_id.clone(), - connection: Box::new(ctx.address()), - }) - .unwrap(); - } - - fn stopped(&mut self, _ctx: &mut Self::Context) { - self.stopped.fetch_add(1, Ordering::Relaxed); - if self.stopped.load(Ordering::Relaxed) > 1 { - System::current().stop() - } - } - } - - #[derive(Message)] - struct Close; - - impl Handler for TestConnection { - type Result = (); - - fn handle(&mut self, _: Close, ctx: &mut Self::Context) { - ctx.stop() - } - } - - impl Handler for TestConnection { - type Result = (); - - fn handle(&mut self, msg: EventMessage, _ctx: &mut Self::Context) { - let mut events = self.events.lock().unwrap(); - let event = msg.into(); - events.push(serde_json::to_string(&event).unwrap()); - match event { - Event::PeerCreated { - peer_id, - sdp_offer, - tracks, - ice_servers: _, - } => { - match sdp_offer { - Some(_) => self.room.do_send(CommandMessage::from( - Command::MakeSdpAnswer { - peer_id, - sdp_answer: "responder_answer".into(), - }, - )), - None => self.room.do_send(CommandMessage::from( - Command::MakeSdpOffer { - peer_id, - sdp_offer: "caller_offer".into(), - mids: tracks - .into_iter() - .filter_map(|t| match t.direction { - Direction::Send { .. } => Some(t.id), - Direction::Recv { .. } => None, - }) - .enumerate() - .map(|(mid, id)| (id, mid.to_string())) - .collect(), - }, - )), - } - self.room.do_send(CommandMessage::from( - Command::SetIceCandidate { - peer_id, - candidate: IceCandidate { - candidate: "ice_candidate".to_owned(), - sdp_m_line_index: None, - sdp_mid: None, - }, - }, - )) - } - Event::IceCandidateDiscovered { - peer_id: _, - candidate: _, - } => { - self.room.do_send(RpcConnectionClosed { - member_id: self.member_id.clone(), - reason: ClosedReason::Closed, - }); - } - Event::PeersRemoved { peer_ids: _ } => {} - Event::SdpAnswerMade { - peer_id: _, - sdp_answer: _, - } => {} - } - } - } - - impl RpcConnection for Addr { - fn close(&mut self) -> Box> { - let fut = self.send(Close {}).map_err(|_| ()); - Box::new(fut) - } - - fn send_event( - &self, - msg: EventMessage, - ) -> Box> { - let fut = self.send(msg).map_err(|_| ()); - Box::new(fut) - } - } -} diff --git a/src/media/mod.rs b/src/media/mod.rs index e2f3f9f8a..c66c9ea1c 100644 --- a/src/media/mod.rs +++ b/src/media/mod.rs @@ -6,7 +6,7 @@ pub mod track; pub use self::{ ice_user::IceUser, peer::{ - create_peers, Id as PeerId, New, Peer, PeerError, PeerStateMachine, + Id as PeerId, New, Peer, PeerError, PeerStateMachine, WaitLocalHaveRemote, WaitLocalSdp, WaitRemoteSdp, }, track::{Id as TrackId, MediaTrack}, diff --git a/src/media/peer.rs b/src/media/peer.rs index 9710e17df..acb453938 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -384,77 +384,3 @@ impl Peer { Ok(mids) } } - -/// Creates 1<=>1 [`Room`]. -#[cfg(not(test))] -pub fn create_peers( - caller: MemberId, - responder: MemberId, -) -> HashMap { - let caller_peer_id = 1; - let responder_peer_id = 2; - // TODO: Maybe member_id?? - let mut caller_peer = Peer::new( - caller_peer_id, - caller.clone(), - responder_peer_id, - responder.clone(), - ); - let mut responder_peer = Peer::new( - responder_peer_id, - responder.clone(), - caller_peer_id, - caller.clone(), - ); - - let track_audio = - Rc::new(MediaTrack::new(1, MediaType::Audio(AudioSettings {}))); - let track_video = - Rc::new(MediaTrack::new(2, MediaType::Video(VideoSettings {}))); - caller_peer.add_sender(track_audio.clone()); - caller_peer.add_sender(track_video.clone()); - responder_peer.add_receiver(track_audio); - responder_peer.add_receiver(track_video); - - let track_audio = - Rc::new(MediaTrack::new(3, MediaType::Audio(AudioSettings {}))); - let track_video = - Rc::new(MediaTrack::new(4, MediaType::Video(VideoSettings {}))); - responder_peer.add_sender(track_audio.clone()); - responder_peer.add_sender(track_video.clone()); - caller_peer.add_receiver(track_audio); - caller_peer.add_receiver(track_video); - - hashmap!( - caller => PeerStateMachine::New(caller_peer), - responder => PeerStateMachine::New(responder_peer), - ) -} - -/// Creates 1=>1 [`Room`]. -#[cfg(test)] -pub fn create_peers( - caller: MemberId, - responder: MemberId, -) -> HashMap { - let caller_peer_id = 1; - let responder_peer_id = 2; - let mut caller_peer = - Peer::new(caller_peer_id, caller, responder_peer_id, responder_peer_id); - let mut responder_peer = - Peer::new(responder_peer_id, responder, caller_peer_id, caller_peer_id); - - let track_audio = - Rc::new(MediaTrack::new(1, MediaType::Audio(AudioSettings {}))); - let track_video = - Rc::new(MediaTrack::new(2, MediaType::Video(VideoSettings {}))); - caller_peer.add_sender(track_audio.clone()); - caller_peer.add_sender(track_video.clone()); - responder_peer.add_receiver(track_audio); - responder_peer.add_receiver(track_video); - - hashmap!( - caller_peer_id => PeerStateMachine::New(caller_peer), - responder_peer_id => PeerStateMachine::New(responder_peer), - ) -} diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 9f696a9f9..6e18cc598 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -637,189 +637,3 @@ impl Handler for Room { .connection_closed(msg.member_id, &msg.reason, ctx); } } - -#[cfg(test)] -mod test { - use std::sync::{atomic::AtomicUsize, Arc, Mutex}; - - use actix::{Addr, System}; - - use medea_client_api_proto::{ - AudioSettings, Direction, IceServer, MediaType, Track, VideoSettings, - }; - - use crate::{ - api::client::rpc_connection::test::TestConnection, media::create_peers, - turn::new_turn_auth_service_mock, - }; - - use super::*; - - fn start_room() -> Addr { - let members = hashmap! { - 1 => Member{ - id: 1, - credentials: "caller_credentials".to_owned(), - ice_user: None - }, - 2 => Member{ - id: 2, - credentials: "responder_credentials".to_owned(), - ice_user: None - }, - }; - Room::new( - 1, - members, - create_peers(1, 2), - Duration::from_secs(10), - new_turn_auth_service_mock(), - ) - .start() - } - - #[test] - fn start_signaling() { - let stopped = Arc::new(AtomicUsize::new(0)); - let caller_events = Arc::new(Mutex::new(vec![])); - let caller_events_clone = Arc::clone(&caller_events); - let responder_events = Arc::new(Mutex::new(vec![])); - let responder_events_clone = Arc::clone(&responder_events); - - System::run(move || { - let room = start_room(); - let room_clone = room.clone(); - let stopped_clone = stopped.clone(); - - TestConnection { - events: caller_events_clone, - member_id: 1, - room: room_clone, - stopped: stopped_clone, - } - .start(); - - TestConnection { - events: responder_events_clone, - member_id: 2, - room, - stopped, - } - .start(); - }) - .unwrap(); - - let caller_events = caller_events.lock().unwrap(); - let responder_events = responder_events.lock().unwrap(); - assert_eq!( - caller_events.to_vec(), - vec![ - serde_json::to_string(&Event::PeerCreated { - peer_id: 1, - sdp_offer: None, - tracks: vec![ - Track { - id: 1, - direction: Direction::Send { - receivers: vec![2], - mid: None - }, - media_type: MediaType::Audio(AudioSettings {}), - }, - Track { - id: 2, - direction: Direction::Send { - receivers: vec![2], - mid: None - }, - media_type: MediaType::Video(VideoSettings {}), - }, - ], - ice_servers: vec![ - IceServer { - urls: vec!["stun:5.5.5.5:1234".to_string()], - username: None, - credential: None, - }, - IceServer { - urls: vec![ - "turn:5.5.5.5:1234".to_string(), - "turn:5.5.5.5:1234?transport=tcp".to_string() - ], - username: Some("username".to_string()), - credential: Some("password".to_string()), - }, - ], - }) - .unwrap(), - serde_json::to_string(&Event::SdpAnswerMade { - peer_id: 1, - sdp_answer: "responder_answer".into(), - }) - .unwrap(), - serde_json::to_string(&Event::IceCandidateDiscovered { - peer_id: 1, - candidate: IceCandidate { - candidate: "ice_candidate".to_owned(), - sdp_m_line_index: None, - sdp_mid: None - }, - }) - .unwrap(), - ] - ); - - assert_eq!( - responder_events.to_vec(), - vec![ - serde_json::to_string(&Event::PeerCreated { - peer_id: 2, - sdp_offer: Some("caller_offer".into()), - tracks: vec![ - Track { - id: 1, - direction: Direction::Recv { - sender: 1, - mid: Some(String::from("0")) - }, - media_type: MediaType::Audio(AudioSettings {}), - }, - Track { - id: 2, - direction: Direction::Recv { - sender: 1, - mid: Some(String::from("1")) - }, - media_type: MediaType::Video(VideoSettings {}), - }, - ], - ice_servers: vec![ - IceServer { - urls: vec!["stun:5.5.5.5:1234".to_string()], - username: None, - credential: None, - }, - IceServer { - urls: vec![ - "turn:5.5.5.5:1234".to_string(), - "turn:5.5.5.5:1234?transport=tcp".to_string() - ], - username: Some("username".to_string()), - credential: Some("password".to_string()), - }, - ], - }) - .unwrap(), - serde_json::to_string(&Event::IceCandidateDiscovered { - peer_id: 2, - candidate: IceCandidate { - candidate: "ice_candidate".to_owned(), - sdp_m_line_index: None, - sdp_mid: None - }, - }) - .unwrap(), - ] - ); - } -} diff --git a/src/turn/service.rs b/src/turn/service.rs index 7551e6872..7eebaba19 100644 --- a/src/turn/service.rs +++ b/src/turn/service.rs @@ -280,6 +280,8 @@ impl Handler for Service { #[cfg(test)] pub mod test { + use std::sync::{Arc, Mutex}; + use futures::future; use crate::media::IceUser; @@ -312,8 +314,9 @@ pub mod test { } #[allow(clippy::module_name_repetitions)] - pub fn new_turn_auth_service_mock() -> Box { - Box::new(TurnAuthServiceMock {}) + pub fn new_turn_auth_service_mock() -> Arc>> + { + Arc::new(Mutex::new(Box::new(TurnAuthServiceMock {}))) } } From d7ce2977163cc3290f5735c14cf55daaab26e251 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 15 Jul 2019 20:03:22 +0300 Subject: [PATCH 364/735] Fix warns in e2e test --- tests/e2e/signalling/mod.rs | 3 +-- tests/e2e/signalling/pub_sub_signallng.rs | 4 ++-- tests/e2e/signalling/three_pubs.rs | 8 ++++---- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/tests/e2e/signalling/mod.rs b/tests/e2e/signalling/mod.rs index 7cb639801..2e4355e24 100644 --- a/tests/e2e/signalling/mod.rs +++ b/tests/e2e/signalling/mod.rs @@ -16,9 +16,8 @@ use awc::{ BoxedSocket, }; use futures::{future::Future, sink::Sink, stream::SplitSink, Stream}; -use medea_client_api_proto::{Command, Direction, Event, IceCandidate}; +use medea_client_api_proto::{Command, Event, IceCandidate}; use serde_json::error::Error as SerdeError; -use std::collections::HashMap; /// Medea client for testing purposes. pub struct TestMember { diff --git a/tests/e2e/signalling/pub_sub_signallng.rs b/tests/e2e/signalling/pub_sub_signallng.rs index c1ad56142..0a76af3d0 100644 --- a/tests/e2e/signalling/pub_sub_signallng.rs +++ b/tests/e2e/signalling/pub_sub_signallng.rs @@ -56,12 +56,12 @@ fn pub_sub_video_call() { for track in tracks { match &track.direction { // TODO - Direction::Send { receivers, mid } => { + Direction::Send { receivers, .. } => { assert!(is_caller); assert!(!receivers.contains(&peer_id)); } // TODO - Direction::Recv { sender, mid } => { + Direction::Recv { sender, .. } => { assert!(!is_caller); assert_ne!(sender, peer_id); } diff --git a/tests/e2e/signalling/three_pubs.rs b/tests/e2e/signalling/three_pubs.rs index 9c838194a..a1287e601 100644 --- a/tests/e2e/signalling/three_pubs.rs +++ b/tests/e2e/signalling/three_pubs.rs @@ -59,7 +59,7 @@ fn three_members_p2p_video_call() { .iter() .filter_map(|t| match &t.direction { // TODO - Direction::Recv { sender, mid } => { + Direction::Recv { sender, .. } => { Some(sender) } _ => None, @@ -73,9 +73,9 @@ fn three_members_p2p_video_call() { let send_count = tracks .iter() .filter_map(|t| match &t.direction { - Direction::Send { receivers, mid } => { - Some(receivers) - } + Direction::Send { + receivers, .. + } => Some(receivers), _ => None, }) .map(|receivers| { From 4a7f910fd18c240db7c9de75453097005772764c Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 15 Jul 2019 20:17:14 +0300 Subject: [PATCH 365/735] Load awc from crates.io --- Cargo.lock | 114 +++++++++++++++++++++++++++++++++++++++-------------- Cargo.toml | 5 +-- 2 files changed, 85 insertions(+), 34 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index aff799be1..fb8c28982 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -123,7 +123,7 @@ dependencies = [ "actix-server 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "actix-service 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "actix-utils 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "awc 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "awc 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -250,7 +250,7 @@ dependencies = [ "actix-threadpool 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "actix-utils 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "actix-web-codegen 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "awc 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "awc 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", "encoding 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", @@ -365,29 +365,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "awc" -version = "0.2.1" -source = "git+https://github.com/actix/actix-web#c0c71f82c00fdac964bcf588c2ea49c4c18d5de7" -dependencies = [ - "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-http 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-service 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", - "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "mime 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", - "percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_urlencoded 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "awc" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -395,12 +373,12 @@ dependencies = [ "actix-service 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "mime 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", "percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", "serde_urlencoded 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -513,6 +491,15 @@ dependencies = [ "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "c2-chacha" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ppv-lite86 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "cc" version = "1.0.37" @@ -879,6 +866,15 @@ name = "gcc" version = "0.3.55" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "getrandom" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "h2" version = "0.1.24" @@ -1057,6 +1053,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "lazy_static" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "spin 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "libc" @@ -1138,7 +1137,7 @@ dependencies = [ "actix-http-test 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "actix-web 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "actix-web-actors 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "awc 0.2.1 (git+https://github.com/actix/actix-web)", + "awc 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "bb8 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "bb8-redis 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1417,6 +1416,11 @@ name = "percent-encoding" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "ppv-lite86" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "proc-macro2" version = "0.4.30" @@ -1477,6 +1481,18 @@ dependencies = [ "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "rand" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "getrandom 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_chacha 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "rand_chacha" version = "0.1.1" @@ -1486,6 +1502,16 @@ dependencies = [ "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "rand_chacha" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "c2-chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "rand_core" version = "0.3.1" @@ -1499,6 +1525,14 @@ name = "rand_core" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "rand_core" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "getrandom 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "rand_hc" version = "0.1.0" @@ -1507,6 +1541,14 @@ dependencies = [ "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "rand_isaac" version = "0.1.1" @@ -1968,6 +2010,11 @@ name = "sourcefile" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "spin" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "stable_deref_trait" version = "1.1.1" @@ -2642,8 +2689,7 @@ dependencies = [ "checksum ascii 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a5fc969a8ce2c9c0c4b0429bb8431544f6658283c8326ba5ff8c762b75369335" "checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" "checksum autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "0e49efa51329a5fd37e7c79db4621af617cd4e3e5bc224939808d076077077bf" -"checksum awc 0.2.1 (git+https://github.com/actix/actix-web)" = "" -"checksum awc 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c5133e9ca1d7f0560fb271f20286be3e896dac5736040a62a7ef1d62003160b6" +"checksum awc 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4c4763e6aa29a801d761dc3464f081d439ea5249ba90c3c3bdfc8dd3f739d233" "checksum backtrace 0.3.31 (registry+https://github.com/rust-lang/crates.io-index)" = "e0f77aa27f55a4beb477ff6bc4d9bf72f90eb422b19c1d8e5a644b8aeb674d66" "checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6" "checksum base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" @@ -2657,6 +2703,7 @@ dependencies = [ "checksum bumpalo 2.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "84dca3afd8e01b9526818b7963e5b4916063b3cdf9f10cf6b73ef0bd0ec37aa5" "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" "checksum bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" +"checksum c2-chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7d64d04786e0f528460fc884753cf8dddcc466be308f6026f8e355c41a0e4101" "checksum cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)" = "39f75544d7bbaf57560d2168f28fd649ff9c76153874db88bdbdfd839b1a7e7d" "checksum cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b486ce3ccf7ffd79fdeb678eac06a9e6c09fc88d33836340becb8fffe87c5e33" "checksum chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "77d81f58b7301084de3b958691458a53c3f7e0b1d702f77e550b6a88e3a88abe" @@ -2700,6 +2747,7 @@ dependencies = [ "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" "checksum futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)" = "a2037ec1c6c1c4f79557762eab1f7eae1f64f6cb418ace90fae88f0942b60139" "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" +"checksum getrandom 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "e65cce4e5084b14874c4e7097f38cab54f47ee554f9194673456ea379dcc4c55" "checksum h2 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)" = "69b2a5a3092cbebbc951fe55408402e696ee2ed09019137d1800fc2c411265d2" "checksum hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3bae29b6653b3412c2e71e9d486db9f9df5d701941d86683005efb9f2d28e3da" "checksum hashbrown 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "29fba9abe4742d586dfd0c06ae4f7e73a1c2d86b856933509b269d82cdf06e18" @@ -2756,16 +2804,21 @@ dependencies = [ "checksum parking_lot_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "94c8c7923936b28d546dfd14d4472eaf34c99b14e1c973a32b3e6d4eb04298c9" "checksum parking_lot_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cb88cb1cb3790baa6776844f968fea3be44956cf184fa1be5a03341f5491278c" "checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" +"checksum ppv-lite86 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e3cbf9f658cdb5000fcf6f362b8ea2ba154b9f146a61c7a20d647034c6b6561b" "checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" "checksum quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)" = "faf4799c5d274f3868a4aae320a0a182cbd2baee377b378f080e16a23e9d80db" "checksum rand 0.3.23 (registry+https://github.com/rust-lang/crates.io-index)" = "64ac302d8f83c0c1974bf758f6b041c6c8ada916fbb44a609158ca8b064cc76c" "checksum rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" "checksum rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" +"checksum rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d47eab0e83d9693d40f825f86948aa16eff6750ead4bdffc4ab95b8b3a7f052c" "checksum rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" +"checksum rand_chacha 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e193067942ef6f485a349a113329140d0ab9e2168ce92274499bb0e9a4190d9d" "checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" "checksum rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0e7a549d590831370895ab7ba4ea0c1b6b011d106b5ff2da6eee112615e6dc0" +"checksum rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "615e683324e75af5d43d8f7a39ffe3ee4a9dc42c5c701167a71dc59c3a493aca" "checksum rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" +"checksum rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" "checksum rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" "checksum rand_jitter 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" "checksum rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" @@ -2821,6 +2874,7 @@ dependencies = [ "checksum smart-default 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5a9dbd5f03d04e80355cbbe3ce5cf1f65c421eac575402e3d4d6e95d5a44edaa" "checksum socket2 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "4e626972d3593207547f14bf5fc9efa4d0e7283deb73fef1dff313dae9ab8878" "checksum sourcefile 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4bf77cb82ba8453b42b6ae1d692e4cdc92f9a47beaf89a847c8be83f4e328ad3" +"checksum spin 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44363f6f51401c34e7be73db0db371c04705d35efbe9f7d6082e03a921a32c55" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" "checksum string 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0bbfb8937e38e34c3444ff00afb28b0811d9554f15c5ad64d12b0308d1d1995" "checksum syn 0.15.38 (registry+https://github.com/rust-lang/crates.io-index)" = "37ea458a750f59ab679b47fef9b6722c586c5742f4cfe18a120bbc807e5e01fd" diff --git a/Cargo.toml b/Cargo.toml index d07f5f272..45e96bd3d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,10 +23,7 @@ lto = "thin" actix = "0.8" actix-web = "1.0" actix-web-actors = "1.0" -# TODO: use version from crates.io when commit -# https://github.com/actix/actix-web/commit/ff724e239db50210a9913de6e214be214f41befa#diff-c39fd968c2b6beb9a6960dd533618bcbR41 -# will be released in crates.io. -awc = { git = "https://github.com/actix/actix-web" } +awc = "0.2" bb8 = "0.3" bb8-redis = "0.3" chrono = "0.4" From 5162298ca35551f18ad24d517c46eccc36e23ea2 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 15 Jul 2019 20:17:44 +0300 Subject: [PATCH 366/735] Remove gRPC protos --- src/api/control/grpc/protos/control.rs | 6109 ------------------- src/api/control/grpc/protos/control_grpc.rs | 155 - 2 files changed, 6264 deletions(-) delete mode 100644 src/api/control/grpc/protos/control.rs delete mode 100644 src/api/control/grpc/protos/control_grpc.rs diff --git a/src/api/control/grpc/protos/control.rs b/src/api/control/grpc/protos/control.rs deleted file mode 100644 index eb945dbde..000000000 --- a/src/api/control/grpc/protos/control.rs +++ /dev/null @@ -1,6109 +0,0 @@ -// This file is generated by rust-protobuf 2.7.0. Do not edit -// @generated - -// https://github.com/Manishearth/rust-clippy/issues/702 -#![allow(unknown_lints)] -#![allow(clippy::all)] - -#![cfg_attr(rustfmt, rustfmt_skip)] - -#![allow(box_pointers)] -#![allow(dead_code)] -#![allow(missing_docs)] -#![allow(non_camel_case_types)] -#![allow(non_snake_case)] -#![allow(non_upper_case_globals)] -#![allow(trivial_casts)] -#![allow(unsafe_code)] -#![allow(unused_imports)] -#![allow(unused_results)] -//! Generated file from `control.proto` - -use protobuf::Message as Message_imported_for_functions; -use protobuf::ProtobufEnum as ProtobufEnum_imported_for_functions; - -/// Generated files are compatible only with the same version -/// of protobuf runtime. -const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_7_0; - -#[derive(PartialEq,Clone,Default)] -pub struct CreateRequest { - // message fields - pub id: ::std::string::String, - // message oneof groups - pub el: ::std::option::Option, - // special fields - pub unknown_fields: ::protobuf::UnknownFields, - pub cached_size: ::protobuf::CachedSize, -} - -impl<'a> ::std::default::Default for &'a CreateRequest { - fn default() -> &'a CreateRequest { - ::default_instance() - } -} - -#[derive(Clone,PartialEq,Debug)] -pub enum CreateRequest_oneof_el { - hub(Hub), - file_recorder(FileRecorder), - member(Member), - relay(Relay), - room(Room), - webrtc_play(WebRtcPlayEndpoint), - webrtc_pub(WebRtcPublishEndpoint), -} - -impl CreateRequest { - pub fn new() -> CreateRequest { - ::std::default::Default::default() - } - - // string id = 1; - - - pub fn get_id(&self) -> &str { - &self.id - } - pub fn clear_id(&mut self) { - self.id.clear(); - } - - // Param is passed by value, moved - pub fn set_id(&mut self, v: ::std::string::String) { - self.id = v; - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_id(&mut self) -> &mut ::std::string::String { - &mut self.id - } - - // Take field - pub fn take_id(&mut self) -> ::std::string::String { - ::std::mem::replace(&mut self.id, ::std::string::String::new()) - } - - // .medea.Hub hub = 2; - - - pub fn get_hub(&self) -> &Hub { - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::hub(ref v)) => v, - _ => Hub::default_instance(), - } - } - pub fn clear_hub(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_hub(&self) -> bool { - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::hub(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_hub(&mut self, v: Hub) { - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::hub(v)) - } - - // Mutable pointer to the field. - pub fn mut_hub(&mut self) -> &mut Hub { - if let ::std::option::Option::Some(CreateRequest_oneof_el::hub(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::hub(Hub::new())); - } - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::hub(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_hub(&mut self) -> Hub { - if self.has_hub() { - match self.el.take() { - ::std::option::Option::Some(CreateRequest_oneof_el::hub(v)) => v, - _ => panic!(), - } - } else { - Hub::new() - } - } - - // .medea.FileRecorder file_recorder = 3; - - - pub fn get_file_recorder(&self) -> &FileRecorder { - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::file_recorder(ref v)) => v, - _ => FileRecorder::default_instance(), - } - } - pub fn clear_file_recorder(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_file_recorder(&self) -> bool { - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::file_recorder(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_file_recorder(&mut self, v: FileRecorder) { - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::file_recorder(v)) - } - - // Mutable pointer to the field. - pub fn mut_file_recorder(&mut self) -> &mut FileRecorder { - if let ::std::option::Option::Some(CreateRequest_oneof_el::file_recorder(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::file_recorder(FileRecorder::new())); - } - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::file_recorder(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_file_recorder(&mut self) -> FileRecorder { - if self.has_file_recorder() { - match self.el.take() { - ::std::option::Option::Some(CreateRequest_oneof_el::file_recorder(v)) => v, - _ => panic!(), - } - } else { - FileRecorder::new() - } - } - - // .medea.Member member = 4; - - - pub fn get_member(&self) -> &Member { - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::member(ref v)) => v, - _ => Member::default_instance(), - } - } - pub fn clear_member(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_member(&self) -> bool { - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::member(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_member(&mut self, v: Member) { - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::member(v)) - } - - // Mutable pointer to the field. - pub fn mut_member(&mut self) -> &mut Member { - if let ::std::option::Option::Some(CreateRequest_oneof_el::member(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::member(Member::new())); - } - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::member(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_member(&mut self) -> Member { - if self.has_member() { - match self.el.take() { - ::std::option::Option::Some(CreateRequest_oneof_el::member(v)) => v, - _ => panic!(), - } - } else { - Member::new() - } - } - - // .medea.Relay relay = 5; - - - pub fn get_relay(&self) -> &Relay { - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::relay(ref v)) => v, - _ => Relay::default_instance(), - } - } - pub fn clear_relay(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_relay(&self) -> bool { - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::relay(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_relay(&mut self, v: Relay) { - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::relay(v)) - } - - // Mutable pointer to the field. - pub fn mut_relay(&mut self) -> &mut Relay { - if let ::std::option::Option::Some(CreateRequest_oneof_el::relay(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::relay(Relay::new())); - } - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::relay(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_relay(&mut self) -> Relay { - if self.has_relay() { - match self.el.take() { - ::std::option::Option::Some(CreateRequest_oneof_el::relay(v)) => v, - _ => panic!(), - } - } else { - Relay::new() - } - } - - // .medea.Room room = 6; - - - pub fn get_room(&self) -> &Room { - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::room(ref v)) => v, - _ => Room::default_instance(), - } - } - pub fn clear_room(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_room(&self) -> bool { - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::room(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_room(&mut self, v: Room) { - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::room(v)) - } - - // Mutable pointer to the field. - pub fn mut_room(&mut self) -> &mut Room { - if let ::std::option::Option::Some(CreateRequest_oneof_el::room(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::room(Room::new())); - } - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::room(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_room(&mut self) -> Room { - if self.has_room() { - match self.el.take() { - ::std::option::Option::Some(CreateRequest_oneof_el::room(v)) => v, - _ => panic!(), - } - } else { - Room::new() - } - } - - // .medea.WebRtcPlayEndpoint webrtc_play = 7; - - - pub fn get_webrtc_play(&self) -> &WebRtcPlayEndpoint { - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_play(ref v)) => v, - _ => WebRtcPlayEndpoint::default_instance(), - } - } - pub fn clear_webrtc_play(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_webrtc_play(&self) -> bool { - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_play(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_webrtc_play(&mut self, v: WebRtcPlayEndpoint) { - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_play(v)) - } - - // Mutable pointer to the field. - pub fn mut_webrtc_play(&mut self) -> &mut WebRtcPlayEndpoint { - if let ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_play(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_play(WebRtcPlayEndpoint::new())); - } - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_play(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_webrtc_play(&mut self) -> WebRtcPlayEndpoint { - if self.has_webrtc_play() { - match self.el.take() { - ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_play(v)) => v, - _ => panic!(), - } - } else { - WebRtcPlayEndpoint::new() - } - } - - // .medea.WebRtcPublishEndpoint webrtc_pub = 8; - - - pub fn get_webrtc_pub(&self) -> &WebRtcPublishEndpoint { - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_pub(ref v)) => v, - _ => WebRtcPublishEndpoint::default_instance(), - } - } - pub fn clear_webrtc_pub(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_webrtc_pub(&self) -> bool { - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_pub(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_webrtc_pub(&mut self, v: WebRtcPublishEndpoint) { - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_pub(v)) - } - - // Mutable pointer to the field. - pub fn mut_webrtc_pub(&mut self) -> &mut WebRtcPublishEndpoint { - if let ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_pub(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_pub(WebRtcPublishEndpoint::new())); - } - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_pub(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_webrtc_pub(&mut self) -> WebRtcPublishEndpoint { - if self.has_webrtc_pub() { - match self.el.take() { - ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_pub(v)) => v, - _ => panic!(), - } - } else { - WebRtcPublishEndpoint::new() - } - } -} - -impl ::protobuf::Message for CreateRequest { - fn is_initialized(&self) -> bool { - if let Some(CreateRequest_oneof_el::hub(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(CreateRequest_oneof_el::file_recorder(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(CreateRequest_oneof_el::member(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(CreateRequest_oneof_el::relay(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(CreateRequest_oneof_el::room(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(CreateRequest_oneof_el::webrtc_play(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(CreateRequest_oneof_el::webrtc_pub(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - 1 => { - ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.id)?; - }, - 2 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::hub(is.read_message()?)); - }, - 3 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::file_recorder(is.read_message()?)); - }, - 4 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::member(is.read_message()?)); - }, - 5 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::relay(is.read_message()?)); - }, - 6 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::room(is.read_message()?)); - }, - 7 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_play(is.read_message()?)); - }, - 8 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_pub(is.read_message()?)); - }, - _ => { - ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - if !self.id.is_empty() { - my_size += ::protobuf::rt::string_size(1, &self.id); - } - if let ::std::option::Option::Some(ref v) = self.el { - match v { - &CreateRequest_oneof_el::hub(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &CreateRequest_oneof_el::file_recorder(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &CreateRequest_oneof_el::member(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &CreateRequest_oneof_el::relay(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &CreateRequest_oneof_el::room(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &CreateRequest_oneof_el::webrtc_play(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &CreateRequest_oneof_el::webrtc_pub(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - }; - } - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { - if !self.id.is_empty() { - os.write_string(1, &self.id)?; - } - if let ::std::option::Option::Some(ref v) = self.el { - match v { - &CreateRequest_oneof_el::hub(ref v) => { - os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &CreateRequest_oneof_el::file_recorder(ref v) => { - os.write_tag(3, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &CreateRequest_oneof_el::member(ref v) => { - os.write_tag(4, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &CreateRequest_oneof_el::relay(ref v) => { - os.write_tag(5, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &CreateRequest_oneof_el::room(ref v) => { - os.write_tag(6, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &CreateRequest_oneof_el::webrtc_play(ref v) => { - os.write_tag(7, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &CreateRequest_oneof_el::webrtc_pub(ref v) => { - os.write_tag(8, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - }; - } - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any - } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any - } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - Self::descriptor_static() - } - - fn new() -> CreateRequest { - CreateRequest::new() - } - - fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "id", - |m: &CreateRequest| { &m.id }, - |m: &mut CreateRequest| { &mut m.id }, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Hub>( - "hub", - CreateRequest::has_hub, - CreateRequest::get_hub, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, FileRecorder>( - "file_recorder", - CreateRequest::has_file_recorder, - CreateRequest::get_file_recorder, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Member>( - "member", - CreateRequest::has_member, - CreateRequest::get_member, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Relay>( - "relay", - CreateRequest::has_relay, - CreateRequest::get_relay, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Room>( - "room", - CreateRequest::has_room, - CreateRequest::get_room, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPlayEndpoint>( - "webrtc_play", - CreateRequest::has_webrtc_play, - CreateRequest::get_webrtc_play, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPublishEndpoint>( - "webrtc_pub", - CreateRequest::has_webrtc_pub, - CreateRequest::get_webrtc_pub, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "CreateRequest", - fields, - file_descriptor_proto() - ) - }) - } - } - - fn default_instance() -> &'static CreateRequest { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const CreateRequest, - }; - unsafe { - instance.get(CreateRequest::new) - } - } -} - -impl ::protobuf::Clear for CreateRequest { - fn clear(&mut self) { - self.id.clear(); - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for CreateRequest { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for CreateRequest { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) - } -} - -#[derive(PartialEq,Clone,Default)] -pub struct ApplyRequest { - // message fields - pub id: ::std::string::String, - pub policy: ApplyRequest_Policy, - // message oneof groups - pub el: ::std::option::Option, - // special fields - pub unknown_fields: ::protobuf::UnknownFields, - pub cached_size: ::protobuf::CachedSize, -} - -impl<'a> ::std::default::Default for &'a ApplyRequest { - fn default() -> &'a ApplyRequest { - ::default_instance() - } -} - -#[derive(Clone,PartialEq,Debug)] -pub enum ApplyRequest_oneof_el { - hub(Hub), - file_recorder(FileRecorder), - member(Member), - relay(Relay), - room(Room), - webrtc_play(WebRtcPlayEndpoint), - webrtc_pub(WebRtcPublishEndpoint), -} - -impl ApplyRequest { - pub fn new() -> ApplyRequest { - ::std::default::Default::default() - } - - // string id = 1; - - - pub fn get_id(&self) -> &str { - &self.id - } - pub fn clear_id(&mut self) { - self.id.clear(); - } - - // Param is passed by value, moved - pub fn set_id(&mut self, v: ::std::string::String) { - self.id = v; - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_id(&mut self) -> &mut ::std::string::String { - &mut self.id - } - - // Take field - pub fn take_id(&mut self) -> ::std::string::String { - ::std::mem::replace(&mut self.id, ::std::string::String::new()) - } - - // .medea.Hub hub = 2; - - - pub fn get_hub(&self) -> &Hub { - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::hub(ref v)) => v, - _ => Hub::default_instance(), - } - } - pub fn clear_hub(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_hub(&self) -> bool { - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::hub(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_hub(&mut self, v: Hub) { - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::hub(v)) - } - - // Mutable pointer to the field. - pub fn mut_hub(&mut self) -> &mut Hub { - if let ::std::option::Option::Some(ApplyRequest_oneof_el::hub(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::hub(Hub::new())); - } - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::hub(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_hub(&mut self) -> Hub { - if self.has_hub() { - match self.el.take() { - ::std::option::Option::Some(ApplyRequest_oneof_el::hub(v)) => v, - _ => panic!(), - } - } else { - Hub::new() - } - } - - // .medea.FileRecorder file_recorder = 3; - - - pub fn get_file_recorder(&self) -> &FileRecorder { - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::file_recorder(ref v)) => v, - _ => FileRecorder::default_instance(), - } - } - pub fn clear_file_recorder(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_file_recorder(&self) -> bool { - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::file_recorder(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_file_recorder(&mut self, v: FileRecorder) { - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::file_recorder(v)) - } - - // Mutable pointer to the field. - pub fn mut_file_recorder(&mut self) -> &mut FileRecorder { - if let ::std::option::Option::Some(ApplyRequest_oneof_el::file_recorder(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::file_recorder(FileRecorder::new())); - } - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::file_recorder(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_file_recorder(&mut self) -> FileRecorder { - if self.has_file_recorder() { - match self.el.take() { - ::std::option::Option::Some(ApplyRequest_oneof_el::file_recorder(v)) => v, - _ => panic!(), - } - } else { - FileRecorder::new() - } - } - - // .medea.Member member = 4; - - - pub fn get_member(&self) -> &Member { - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::member(ref v)) => v, - _ => Member::default_instance(), - } - } - pub fn clear_member(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_member(&self) -> bool { - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::member(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_member(&mut self, v: Member) { - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::member(v)) - } - - // Mutable pointer to the field. - pub fn mut_member(&mut self) -> &mut Member { - if let ::std::option::Option::Some(ApplyRequest_oneof_el::member(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::member(Member::new())); - } - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::member(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_member(&mut self) -> Member { - if self.has_member() { - match self.el.take() { - ::std::option::Option::Some(ApplyRequest_oneof_el::member(v)) => v, - _ => panic!(), - } - } else { - Member::new() - } - } - - // .medea.Relay relay = 5; - - - pub fn get_relay(&self) -> &Relay { - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::relay(ref v)) => v, - _ => Relay::default_instance(), - } - } - pub fn clear_relay(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_relay(&self) -> bool { - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::relay(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_relay(&mut self, v: Relay) { - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::relay(v)) - } - - // Mutable pointer to the field. - pub fn mut_relay(&mut self) -> &mut Relay { - if let ::std::option::Option::Some(ApplyRequest_oneof_el::relay(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::relay(Relay::new())); - } - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::relay(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_relay(&mut self) -> Relay { - if self.has_relay() { - match self.el.take() { - ::std::option::Option::Some(ApplyRequest_oneof_el::relay(v)) => v, - _ => panic!(), - } - } else { - Relay::new() - } - } - - // .medea.Room room = 6; - - - pub fn get_room(&self) -> &Room { - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::room(ref v)) => v, - _ => Room::default_instance(), - } - } - pub fn clear_room(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_room(&self) -> bool { - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::room(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_room(&mut self, v: Room) { - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::room(v)) - } - - // Mutable pointer to the field. - pub fn mut_room(&mut self) -> &mut Room { - if let ::std::option::Option::Some(ApplyRequest_oneof_el::room(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::room(Room::new())); - } - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::room(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_room(&mut self) -> Room { - if self.has_room() { - match self.el.take() { - ::std::option::Option::Some(ApplyRequest_oneof_el::room(v)) => v, - _ => panic!(), - } - } else { - Room::new() - } - } - - // .medea.WebRtcPlayEndpoint webrtc_play = 7; - - - pub fn get_webrtc_play(&self) -> &WebRtcPlayEndpoint { - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(ref v)) => v, - _ => WebRtcPlayEndpoint::default_instance(), - } - } - pub fn clear_webrtc_play(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_webrtc_play(&self) -> bool { - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_webrtc_play(&mut self, v: WebRtcPlayEndpoint) { - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(v)) - } - - // Mutable pointer to the field. - pub fn mut_webrtc_play(&mut self) -> &mut WebRtcPlayEndpoint { - if let ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(WebRtcPlayEndpoint::new())); - } - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_webrtc_play(&mut self) -> WebRtcPlayEndpoint { - if self.has_webrtc_play() { - match self.el.take() { - ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(v)) => v, - _ => panic!(), - } - } else { - WebRtcPlayEndpoint::new() - } - } - - // .medea.WebRtcPublishEndpoint webrtc_pub = 8; - - - pub fn get_webrtc_pub(&self) -> &WebRtcPublishEndpoint { - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(ref v)) => v, - _ => WebRtcPublishEndpoint::default_instance(), - } - } - pub fn clear_webrtc_pub(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_webrtc_pub(&self) -> bool { - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_webrtc_pub(&mut self, v: WebRtcPublishEndpoint) { - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(v)) - } - - // Mutable pointer to the field. - pub fn mut_webrtc_pub(&mut self) -> &mut WebRtcPublishEndpoint { - if let ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(WebRtcPublishEndpoint::new())); - } - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_webrtc_pub(&mut self) -> WebRtcPublishEndpoint { - if self.has_webrtc_pub() { - match self.el.take() { - ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(v)) => v, - _ => panic!(), - } - } else { - WebRtcPublishEndpoint::new() - } - } - - // .medea.ApplyRequest.Policy policy = 9; - - - pub fn get_policy(&self) -> ApplyRequest_Policy { - self.policy - } - pub fn clear_policy(&mut self) { - self.policy = ApplyRequest_Policy::APPLY; - } - - // Param is passed by value, moved - pub fn set_policy(&mut self, v: ApplyRequest_Policy) { - self.policy = v; - } -} - -impl ::protobuf::Message for ApplyRequest { - fn is_initialized(&self) -> bool { - if let Some(ApplyRequest_oneof_el::hub(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(ApplyRequest_oneof_el::file_recorder(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(ApplyRequest_oneof_el::member(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(ApplyRequest_oneof_el::relay(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(ApplyRequest_oneof_el::room(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(ApplyRequest_oneof_el::webrtc_play(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(ApplyRequest_oneof_el::webrtc_pub(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - 1 => { - ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.id)?; - }, - 2 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::hub(is.read_message()?)); - }, - 3 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::file_recorder(is.read_message()?)); - }, - 4 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::member(is.read_message()?)); - }, - 5 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::relay(is.read_message()?)); - }, - 6 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::room(is.read_message()?)); - }, - 7 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(is.read_message()?)); - }, - 8 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(is.read_message()?)); - }, - 9 => { - ::protobuf::rt::read_proto3_enum_with_unknown_fields_into(wire_type, is, &mut self.policy, 9, &mut self.unknown_fields)? - }, - _ => { - ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - if !self.id.is_empty() { - my_size += ::protobuf::rt::string_size(1, &self.id); - } - if self.policy != ApplyRequest_Policy::APPLY { - my_size += ::protobuf::rt::enum_size(9, self.policy); - } - if let ::std::option::Option::Some(ref v) = self.el { - match v { - &ApplyRequest_oneof_el::hub(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &ApplyRequest_oneof_el::file_recorder(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &ApplyRequest_oneof_el::member(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &ApplyRequest_oneof_el::relay(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &ApplyRequest_oneof_el::room(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &ApplyRequest_oneof_el::webrtc_play(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &ApplyRequest_oneof_el::webrtc_pub(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - }; - } - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { - if !self.id.is_empty() { - os.write_string(1, &self.id)?; - } - if self.policy != ApplyRequest_Policy::APPLY { - os.write_enum(9, self.policy.value())?; - } - if let ::std::option::Option::Some(ref v) = self.el { - match v { - &ApplyRequest_oneof_el::hub(ref v) => { - os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &ApplyRequest_oneof_el::file_recorder(ref v) => { - os.write_tag(3, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &ApplyRequest_oneof_el::member(ref v) => { - os.write_tag(4, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &ApplyRequest_oneof_el::relay(ref v) => { - os.write_tag(5, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &ApplyRequest_oneof_el::room(ref v) => { - os.write_tag(6, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &ApplyRequest_oneof_el::webrtc_play(ref v) => { - os.write_tag(7, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &ApplyRequest_oneof_el::webrtc_pub(ref v) => { - os.write_tag(8, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - }; - } - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any - } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any - } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - Self::descriptor_static() - } - - fn new() -> ApplyRequest { - ApplyRequest::new() - } - - fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "id", - |m: &ApplyRequest| { &m.id }, - |m: &mut ApplyRequest| { &mut m.id }, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Hub>( - "hub", - ApplyRequest::has_hub, - ApplyRequest::get_hub, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, FileRecorder>( - "file_recorder", - ApplyRequest::has_file_recorder, - ApplyRequest::get_file_recorder, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Member>( - "member", - ApplyRequest::has_member, - ApplyRequest::get_member, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Relay>( - "relay", - ApplyRequest::has_relay, - ApplyRequest::get_relay, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Room>( - "room", - ApplyRequest::has_room, - ApplyRequest::get_room, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPlayEndpoint>( - "webrtc_play", - ApplyRequest::has_webrtc_play, - ApplyRequest::get_webrtc_play, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPublishEndpoint>( - "webrtc_pub", - ApplyRequest::has_webrtc_pub, - ApplyRequest::get_webrtc_pub, - )); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeEnum>( - "policy", - |m: &ApplyRequest| { &m.policy }, - |m: &mut ApplyRequest| { &mut m.policy }, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "ApplyRequest", - fields, - file_descriptor_proto() - ) - }) - } - } - - fn default_instance() -> &'static ApplyRequest { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ApplyRequest, - }; - unsafe { - instance.get(ApplyRequest::new) - } - } -} - -impl ::protobuf::Clear for ApplyRequest { - fn clear(&mut self) { - self.id.clear(); - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.policy = ApplyRequest_Policy::APPLY; - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for ApplyRequest { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for ApplyRequest { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) - } -} - -#[derive(Clone,PartialEq,Eq,Debug,Hash)] -pub enum ApplyRequest_Policy { - APPLY = 0, - APPEND = 1, -} - -impl ::protobuf::ProtobufEnum for ApplyRequest_Policy { - fn value(&self) -> i32 { - *self as i32 - } - - fn from_i32(value: i32) -> ::std::option::Option { - match value { - 0 => ::std::option::Option::Some(ApplyRequest_Policy::APPLY), - 1 => ::std::option::Option::Some(ApplyRequest_Policy::APPEND), - _ => ::std::option::Option::None - } - } - - fn values() -> &'static [Self] { - static values: &'static [ApplyRequest_Policy] = &[ - ApplyRequest_Policy::APPLY, - ApplyRequest_Policy::APPEND, - ]; - values - } - - fn enum_descriptor_static() -> &'static ::protobuf::reflect::EnumDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::EnumDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::EnumDescriptor, - }; - unsafe { - descriptor.get(|| { - ::protobuf::reflect::EnumDescriptor::new("ApplyRequest_Policy", file_descriptor_proto()) - }) - } - } -} - -impl ::std::marker::Copy for ApplyRequest_Policy { -} - -impl ::std::default::Default for ApplyRequest_Policy { - fn default() -> Self { - ApplyRequest_Policy::APPLY - } -} - -impl ::protobuf::reflect::ProtobufValue for ApplyRequest_Policy { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Enum(self.descriptor()) - } -} - -#[derive(PartialEq,Clone,Default)] -pub struct IdRequest { - // message fields - pub id: ::protobuf::RepeatedField<::std::string::String>, - // special fields - pub unknown_fields: ::protobuf::UnknownFields, - pub cached_size: ::protobuf::CachedSize, -} - -impl<'a> ::std::default::Default for &'a IdRequest { - fn default() -> &'a IdRequest { - ::default_instance() - } -} - -impl IdRequest { - pub fn new() -> IdRequest { - ::std::default::Default::default() - } - - // repeated string id = 1; - - - pub fn get_id(&self) -> &[::std::string::String] { - &self.id - } - pub fn clear_id(&mut self) { - self.id.clear(); - } - - // Param is passed by value, moved - pub fn set_id(&mut self, v: ::protobuf::RepeatedField<::std::string::String>) { - self.id = v; - } - - // Mutable pointer to the field. - pub fn mut_id(&mut self) -> &mut ::protobuf::RepeatedField<::std::string::String> { - &mut self.id - } - - // Take field - pub fn take_id(&mut self) -> ::protobuf::RepeatedField<::std::string::String> { - ::std::mem::replace(&mut self.id, ::protobuf::RepeatedField::new()) - } -} - -impl ::protobuf::Message for IdRequest { - fn is_initialized(&self) -> bool { - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - 1 => { - ::protobuf::rt::read_repeated_string_into(wire_type, is, &mut self.id)?; - }, - _ => { - ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - for value in &self.id { - my_size += ::protobuf::rt::string_size(1, &value); - }; - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { - for v in &self.id { - os.write_string(1, &v)?; - }; - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any - } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any - } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - Self::descriptor_static() - } - - fn new() -> IdRequest { - IdRequest::new() - } - - fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "id", - |m: &IdRequest| { &m.id }, - |m: &mut IdRequest| { &mut m.id }, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "IdRequest", - fields, - file_descriptor_proto() - ) - }) - } - } - - fn default_instance() -> &'static IdRequest { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const IdRequest, - }; - unsafe { - instance.get(IdRequest::new) - } - } -} - -impl ::protobuf::Clear for IdRequest { - fn clear(&mut self) { - self.id.clear(); - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for IdRequest { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for IdRequest { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) - } -} - -#[derive(PartialEq,Clone,Default)] -pub struct Response { - // message fields - pub sid: ::std::collections::HashMap<::std::string::String, ::std::string::String>, - pub error: ::protobuf::SingularPtrField, - // special fields - pub unknown_fields: ::protobuf::UnknownFields, - pub cached_size: ::protobuf::CachedSize, -} - -impl<'a> ::std::default::Default for &'a Response { - fn default() -> &'a Response { - ::default_instance() - } -} - -impl Response { - pub fn new() -> Response { - ::std::default::Default::default() - } - - // repeated .medea.Response.SidEntry sid = 1; - - - pub fn get_sid(&self) -> &::std::collections::HashMap<::std::string::String, ::std::string::String> { - &self.sid - } - pub fn clear_sid(&mut self) { - self.sid.clear(); - } - - // Param is passed by value, moved - pub fn set_sid(&mut self, v: ::std::collections::HashMap<::std::string::String, ::std::string::String>) { - self.sid = v; - } - - // Mutable pointer to the field. - pub fn mut_sid(&mut self) -> &mut ::std::collections::HashMap<::std::string::String, ::std::string::String> { - &mut self.sid - } - - // Take field - pub fn take_sid(&mut self) -> ::std::collections::HashMap<::std::string::String, ::std::string::String> { - ::std::mem::replace(&mut self.sid, ::std::collections::HashMap::new()) - } - - // .medea.Error error = 2; - - - pub fn get_error(&self) -> &Error { - self.error.as_ref().unwrap_or_else(|| Error::default_instance()) - } - pub fn clear_error(&mut self) { - self.error.clear(); - } - - pub fn has_error(&self) -> bool { - self.error.is_some() - } - - // Param is passed by value, moved - pub fn set_error(&mut self, v: Error) { - self.error = ::protobuf::SingularPtrField::some(v); - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_error(&mut self) -> &mut Error { - if self.error.is_none() { - self.error.set_default(); - } - self.error.as_mut().unwrap() - } - - // Take field - pub fn take_error(&mut self) -> Error { - self.error.take().unwrap_or_else(|| Error::new()) - } -} - -impl ::protobuf::Message for Response { - fn is_initialized(&self) -> bool { - for v in &self.error { - if !v.is_initialized() { - return false; - } - }; - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - 1 => { - ::protobuf::rt::read_map_into::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeString>(wire_type, is, &mut self.sid)?; - }, - 2 => { - ::protobuf::rt::read_singular_message_into(wire_type, is, &mut self.error)?; - }, - _ => { - ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - my_size += ::protobuf::rt::compute_map_size::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeString>(1, &self.sid); - if let Some(ref v) = self.error.as_ref() { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - } - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { - ::protobuf::rt::write_map_with_cached_sizes::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeString>(1, &self.sid, os)?; - if let Some(ref v) = self.error.as_ref() { - os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - } - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any - } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any - } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - Self::descriptor_static() - } - - fn new() -> Response { - Response::new() - } - - fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_map_accessor::<_, ::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeString>( - "sid", - |m: &Response| { &m.sid }, - |m: &mut Response| { &mut m.sid }, - )); - fields.push(::protobuf::reflect::accessor::make_singular_ptr_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( - "error", - |m: &Response| { &m.error }, - |m: &mut Response| { &mut m.error }, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "Response", - fields, - file_descriptor_proto() - ) - }) - } - } - - fn default_instance() -> &'static Response { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const Response, - }; - unsafe { - instance.get(Response::new) - } - } -} - -impl ::protobuf::Clear for Response { - fn clear(&mut self) { - self.sid.clear(); - self.error.clear(); - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for Response { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for Response { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) - } -} - -#[derive(PartialEq,Clone,Default)] -pub struct GetResponse { - // message fields - pub elements: ::std::collections::HashMap<::std::string::String, Element>, - pub error: ::protobuf::SingularPtrField, - // special fields - pub unknown_fields: ::protobuf::UnknownFields, - pub cached_size: ::protobuf::CachedSize, -} - -impl<'a> ::std::default::Default for &'a GetResponse { - fn default() -> &'a GetResponse { - ::default_instance() - } -} - -impl GetResponse { - pub fn new() -> GetResponse { - ::std::default::Default::default() - } - - // repeated .medea.GetResponse.ElementsEntry elements = 1; - - - pub fn get_elements(&self) -> &::std::collections::HashMap<::std::string::String, Element> { - &self.elements - } - pub fn clear_elements(&mut self) { - self.elements.clear(); - } - - // Param is passed by value, moved - pub fn set_elements(&mut self, v: ::std::collections::HashMap<::std::string::String, Element>) { - self.elements = v; - } - - // Mutable pointer to the field. - pub fn mut_elements(&mut self) -> &mut ::std::collections::HashMap<::std::string::String, Element> { - &mut self.elements - } - - // Take field - pub fn take_elements(&mut self) -> ::std::collections::HashMap<::std::string::String, Element> { - ::std::mem::replace(&mut self.elements, ::std::collections::HashMap::new()) - } - - // .medea.Error error = 2; - - - pub fn get_error(&self) -> &Error { - self.error.as_ref().unwrap_or_else(|| Error::default_instance()) - } - pub fn clear_error(&mut self) { - self.error.clear(); - } - - pub fn has_error(&self) -> bool { - self.error.is_some() - } - - // Param is passed by value, moved - pub fn set_error(&mut self, v: Error) { - self.error = ::protobuf::SingularPtrField::some(v); - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_error(&mut self) -> &mut Error { - if self.error.is_none() { - self.error.set_default(); - } - self.error.as_mut().unwrap() - } - - // Take field - pub fn take_error(&mut self) -> Error { - self.error.take().unwrap_or_else(|| Error::new()) - } -} - -impl ::protobuf::Message for GetResponse { - fn is_initialized(&self) -> bool { - for v in &self.error { - if !v.is_initialized() { - return false; - } - }; - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - 1 => { - ::protobuf::rt::read_map_into::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(wire_type, is, &mut self.elements)?; - }, - 2 => { - ::protobuf::rt::read_singular_message_into(wire_type, is, &mut self.error)?; - }, - _ => { - ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - my_size += ::protobuf::rt::compute_map_size::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(1, &self.elements); - if let Some(ref v) = self.error.as_ref() { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - } - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { - ::protobuf::rt::write_map_with_cached_sizes::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(1, &self.elements, os)?; - if let Some(ref v) = self.error.as_ref() { - os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - } - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any - } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any - } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - Self::descriptor_static() - } - - fn new() -> GetResponse { - GetResponse::new() - } - - fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_map_accessor::<_, ::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>( - "elements", - |m: &GetResponse| { &m.elements }, - |m: &mut GetResponse| { &mut m.elements }, - )); - fields.push(::protobuf::reflect::accessor::make_singular_ptr_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( - "error", - |m: &GetResponse| { &m.error }, - |m: &mut GetResponse| { &mut m.error }, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "GetResponse", - fields, - file_descriptor_proto() - ) - }) - } - } - - fn default_instance() -> &'static GetResponse { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const GetResponse, - }; - unsafe { - instance.get(GetResponse::new) - } - } -} - -impl ::protobuf::Clear for GetResponse { - fn clear(&mut self) { - self.elements.clear(); - self.error.clear(); - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for GetResponse { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for GetResponse { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) - } -} - -#[derive(PartialEq,Clone,Default)] -pub struct Error { - // message fields - pub code: u32, - pub text: ::std::string::String, - pub doc: ::std::string::String, - pub element: ::std::string::String, - pub details: ::protobuf::SingularPtrField<::protobuf::well_known_types::Any>, - pub backtrace: ::protobuf::RepeatedField<::std::string::String>, - // special fields - pub unknown_fields: ::protobuf::UnknownFields, - pub cached_size: ::protobuf::CachedSize, -} - -impl<'a> ::std::default::Default for &'a Error { - fn default() -> &'a Error { - ::default_instance() - } -} - -impl Error { - pub fn new() -> Error { - ::std::default::Default::default() - } - - // uint32 code = 2; - - - pub fn get_code(&self) -> u32 { - self.code - } - pub fn clear_code(&mut self) { - self.code = 0; - } - - // Param is passed by value, moved - pub fn set_code(&mut self, v: u32) { - self.code = v; - } - - // string text = 3; - - - pub fn get_text(&self) -> &str { - &self.text - } - pub fn clear_text(&mut self) { - self.text.clear(); - } - - // Param is passed by value, moved - pub fn set_text(&mut self, v: ::std::string::String) { - self.text = v; - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_text(&mut self) -> &mut ::std::string::String { - &mut self.text - } - - // Take field - pub fn take_text(&mut self) -> ::std::string::String { - ::std::mem::replace(&mut self.text, ::std::string::String::new()) - } - - // string doc = 4; - - - pub fn get_doc(&self) -> &str { - &self.doc - } - pub fn clear_doc(&mut self) { - self.doc.clear(); - } - - // Param is passed by value, moved - pub fn set_doc(&mut self, v: ::std::string::String) { - self.doc = v; - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_doc(&mut self) -> &mut ::std::string::String { - &mut self.doc - } - - // Take field - pub fn take_doc(&mut self) -> ::std::string::String { - ::std::mem::replace(&mut self.doc, ::std::string::String::new()) - } - - // string element = 5; - - - pub fn get_element(&self) -> &str { - &self.element - } - pub fn clear_element(&mut self) { - self.element.clear(); - } - - // Param is passed by value, moved - pub fn set_element(&mut self, v: ::std::string::String) { - self.element = v; - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_element(&mut self) -> &mut ::std::string::String { - &mut self.element - } - - // Take field - pub fn take_element(&mut self) -> ::std::string::String { - ::std::mem::replace(&mut self.element, ::std::string::String::new()) - } - - // .google.protobuf.Any details = 6; - - - pub fn get_details(&self) -> &::protobuf::well_known_types::Any { - self.details.as_ref().unwrap_or_else(|| ::protobuf::well_known_types::Any::default_instance()) - } - pub fn clear_details(&mut self) { - self.details.clear(); - } - - pub fn has_details(&self) -> bool { - self.details.is_some() - } - - // Param is passed by value, moved - pub fn set_details(&mut self, v: ::protobuf::well_known_types::Any) { - self.details = ::protobuf::SingularPtrField::some(v); - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_details(&mut self) -> &mut ::protobuf::well_known_types::Any { - if self.details.is_none() { - self.details.set_default(); - } - self.details.as_mut().unwrap() - } - - // Take field - pub fn take_details(&mut self) -> ::protobuf::well_known_types::Any { - self.details.take().unwrap_or_else(|| ::protobuf::well_known_types::Any::new()) - } - - // repeated string backtrace = 7; - - - pub fn get_backtrace(&self) -> &[::std::string::String] { - &self.backtrace - } - pub fn clear_backtrace(&mut self) { - self.backtrace.clear(); - } - - // Param is passed by value, moved - pub fn set_backtrace(&mut self, v: ::protobuf::RepeatedField<::std::string::String>) { - self.backtrace = v; - } - - // Mutable pointer to the field. - pub fn mut_backtrace(&mut self) -> &mut ::protobuf::RepeatedField<::std::string::String> { - &mut self.backtrace - } - - // Take field - pub fn take_backtrace(&mut self) -> ::protobuf::RepeatedField<::std::string::String> { - ::std::mem::replace(&mut self.backtrace, ::protobuf::RepeatedField::new()) - } -} - -impl ::protobuf::Message for Error { - fn is_initialized(&self) -> bool { - for v in &self.details { - if !v.is_initialized() { - return false; - } - }; - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - 2 => { - if wire_type != ::protobuf::wire_format::WireTypeVarint { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - let tmp = is.read_uint32()?; - self.code = tmp; - }, - 3 => { - ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.text)?; - }, - 4 => { - ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.doc)?; - }, - 5 => { - ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.element)?; - }, - 6 => { - ::protobuf::rt::read_singular_message_into(wire_type, is, &mut self.details)?; - }, - 7 => { - ::protobuf::rt::read_repeated_string_into(wire_type, is, &mut self.backtrace)?; - }, - _ => { - ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - if self.code != 0 { - my_size += ::protobuf::rt::value_size(2, self.code, ::protobuf::wire_format::WireTypeVarint); - } - if !self.text.is_empty() { - my_size += ::protobuf::rt::string_size(3, &self.text); - } - if !self.doc.is_empty() { - my_size += ::protobuf::rt::string_size(4, &self.doc); - } - if !self.element.is_empty() { - my_size += ::protobuf::rt::string_size(5, &self.element); - } - if let Some(ref v) = self.details.as_ref() { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - } - for value in &self.backtrace { - my_size += ::protobuf::rt::string_size(7, &value); - }; - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { - if self.code != 0 { - os.write_uint32(2, self.code)?; - } - if !self.text.is_empty() { - os.write_string(3, &self.text)?; - } - if !self.doc.is_empty() { - os.write_string(4, &self.doc)?; - } - if !self.element.is_empty() { - os.write_string(5, &self.element)?; - } - if let Some(ref v) = self.details.as_ref() { - os.write_tag(6, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - } - for v in &self.backtrace { - os.write_string(7, &v)?; - }; - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any - } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any - } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - Self::descriptor_static() - } - - fn new() -> Error { - Error::new() - } - - fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeUint32>( - "code", - |m: &Error| { &m.code }, - |m: &mut Error| { &mut m.code }, - )); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "text", - |m: &Error| { &m.text }, - |m: &mut Error| { &mut m.text }, - )); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "doc", - |m: &Error| { &m.doc }, - |m: &mut Error| { &mut m.doc }, - )); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "element", - |m: &Error| { &m.element }, - |m: &mut Error| { &mut m.element }, - )); - fields.push(::protobuf::reflect::accessor::make_singular_ptr_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage<::protobuf::well_known_types::Any>>( - "details", - |m: &Error| { &m.details }, - |m: &mut Error| { &mut m.details }, - )); - fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "backtrace", - |m: &Error| { &m.backtrace }, - |m: &mut Error| { &mut m.backtrace }, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "Error", - fields, - file_descriptor_proto() - ) - }) - } - } - - fn default_instance() -> &'static Error { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const Error, - }; - unsafe { - instance.get(Error::new) - } - } -} - -impl ::protobuf::Clear for Error { - fn clear(&mut self) { - self.code = 0; - self.text.clear(); - self.doc.clear(); - self.element.clear(); - self.details.clear(); - self.backtrace.clear(); - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for Error { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for Error { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) - } -} - -#[derive(PartialEq,Clone,Default)] -pub struct Element { - // message oneof groups - pub el: ::std::option::Option, - // special fields - pub unknown_fields: ::protobuf::UnknownFields, - pub cached_size: ::protobuf::CachedSize, -} - -impl<'a> ::std::default::Default for &'a Element { - fn default() -> &'a Element { - ::default_instance() - } -} - -#[derive(Clone,PartialEq,Debug)] -pub enum Element_oneof_el { - hub(Hub), - file_recorder(FileRecorder), - member(Member), - relay(Relay), - room(Room), - webrtc_play(WebRtcPlayEndpoint), - webrtc_pub(WebRtcPublishEndpoint), -} - -impl Element { - pub fn new() -> Element { - ::std::default::Default::default() - } - - // .medea.Hub hub = 2; - - - pub fn get_hub(&self) -> &Hub { - match self.el { - ::std::option::Option::Some(Element_oneof_el::hub(ref v)) => v, - _ => Hub::default_instance(), - } - } - pub fn clear_hub(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_hub(&self) -> bool { - match self.el { - ::std::option::Option::Some(Element_oneof_el::hub(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_hub(&mut self, v: Hub) { - self.el = ::std::option::Option::Some(Element_oneof_el::hub(v)) - } - - // Mutable pointer to the field. - pub fn mut_hub(&mut self) -> &mut Hub { - if let ::std::option::Option::Some(Element_oneof_el::hub(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(Element_oneof_el::hub(Hub::new())); - } - match self.el { - ::std::option::Option::Some(Element_oneof_el::hub(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_hub(&mut self) -> Hub { - if self.has_hub() { - match self.el.take() { - ::std::option::Option::Some(Element_oneof_el::hub(v)) => v, - _ => panic!(), - } - } else { - Hub::new() - } - } - - // .medea.FileRecorder file_recorder = 3; - - - pub fn get_file_recorder(&self) -> &FileRecorder { - match self.el { - ::std::option::Option::Some(Element_oneof_el::file_recorder(ref v)) => v, - _ => FileRecorder::default_instance(), - } - } - pub fn clear_file_recorder(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_file_recorder(&self) -> bool { - match self.el { - ::std::option::Option::Some(Element_oneof_el::file_recorder(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_file_recorder(&mut self, v: FileRecorder) { - self.el = ::std::option::Option::Some(Element_oneof_el::file_recorder(v)) - } - - // Mutable pointer to the field. - pub fn mut_file_recorder(&mut self) -> &mut FileRecorder { - if let ::std::option::Option::Some(Element_oneof_el::file_recorder(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(Element_oneof_el::file_recorder(FileRecorder::new())); - } - match self.el { - ::std::option::Option::Some(Element_oneof_el::file_recorder(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_file_recorder(&mut self) -> FileRecorder { - if self.has_file_recorder() { - match self.el.take() { - ::std::option::Option::Some(Element_oneof_el::file_recorder(v)) => v, - _ => panic!(), - } - } else { - FileRecorder::new() - } - } - - // .medea.Member member = 4; - - - pub fn get_member(&self) -> &Member { - match self.el { - ::std::option::Option::Some(Element_oneof_el::member(ref v)) => v, - _ => Member::default_instance(), - } - } - pub fn clear_member(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_member(&self) -> bool { - match self.el { - ::std::option::Option::Some(Element_oneof_el::member(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_member(&mut self, v: Member) { - self.el = ::std::option::Option::Some(Element_oneof_el::member(v)) - } - - // Mutable pointer to the field. - pub fn mut_member(&mut self) -> &mut Member { - if let ::std::option::Option::Some(Element_oneof_el::member(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(Element_oneof_el::member(Member::new())); - } - match self.el { - ::std::option::Option::Some(Element_oneof_el::member(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_member(&mut self) -> Member { - if self.has_member() { - match self.el.take() { - ::std::option::Option::Some(Element_oneof_el::member(v)) => v, - _ => panic!(), - } - } else { - Member::new() - } - } - - // .medea.Relay relay = 5; - - - pub fn get_relay(&self) -> &Relay { - match self.el { - ::std::option::Option::Some(Element_oneof_el::relay(ref v)) => v, - _ => Relay::default_instance(), - } - } - pub fn clear_relay(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_relay(&self) -> bool { - match self.el { - ::std::option::Option::Some(Element_oneof_el::relay(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_relay(&mut self, v: Relay) { - self.el = ::std::option::Option::Some(Element_oneof_el::relay(v)) - } - - // Mutable pointer to the field. - pub fn mut_relay(&mut self) -> &mut Relay { - if let ::std::option::Option::Some(Element_oneof_el::relay(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(Element_oneof_el::relay(Relay::new())); - } - match self.el { - ::std::option::Option::Some(Element_oneof_el::relay(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_relay(&mut self) -> Relay { - if self.has_relay() { - match self.el.take() { - ::std::option::Option::Some(Element_oneof_el::relay(v)) => v, - _ => panic!(), - } - } else { - Relay::new() - } - } - - // .medea.Room room = 6; - - - pub fn get_room(&self) -> &Room { - match self.el { - ::std::option::Option::Some(Element_oneof_el::room(ref v)) => v, - _ => Room::default_instance(), - } - } - pub fn clear_room(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_room(&self) -> bool { - match self.el { - ::std::option::Option::Some(Element_oneof_el::room(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_room(&mut self, v: Room) { - self.el = ::std::option::Option::Some(Element_oneof_el::room(v)) - } - - // Mutable pointer to the field. - pub fn mut_room(&mut self) -> &mut Room { - if let ::std::option::Option::Some(Element_oneof_el::room(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(Element_oneof_el::room(Room::new())); - } - match self.el { - ::std::option::Option::Some(Element_oneof_el::room(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_room(&mut self) -> Room { - if self.has_room() { - match self.el.take() { - ::std::option::Option::Some(Element_oneof_el::room(v)) => v, - _ => panic!(), - } - } else { - Room::new() - } - } - - // .medea.WebRtcPlayEndpoint webrtc_play = 7; - - - pub fn get_webrtc_play(&self) -> &WebRtcPlayEndpoint { - match self.el { - ::std::option::Option::Some(Element_oneof_el::webrtc_play(ref v)) => v, - _ => WebRtcPlayEndpoint::default_instance(), - } - } - pub fn clear_webrtc_play(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_webrtc_play(&self) -> bool { - match self.el { - ::std::option::Option::Some(Element_oneof_el::webrtc_play(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_webrtc_play(&mut self, v: WebRtcPlayEndpoint) { - self.el = ::std::option::Option::Some(Element_oneof_el::webrtc_play(v)) - } - - // Mutable pointer to the field. - pub fn mut_webrtc_play(&mut self) -> &mut WebRtcPlayEndpoint { - if let ::std::option::Option::Some(Element_oneof_el::webrtc_play(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(Element_oneof_el::webrtc_play(WebRtcPlayEndpoint::new())); - } - match self.el { - ::std::option::Option::Some(Element_oneof_el::webrtc_play(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_webrtc_play(&mut self) -> WebRtcPlayEndpoint { - if self.has_webrtc_play() { - match self.el.take() { - ::std::option::Option::Some(Element_oneof_el::webrtc_play(v)) => v, - _ => panic!(), - } - } else { - WebRtcPlayEndpoint::new() - } - } - - // .medea.WebRtcPublishEndpoint webrtc_pub = 8; - - - pub fn get_webrtc_pub(&self) -> &WebRtcPublishEndpoint { - match self.el { - ::std::option::Option::Some(Element_oneof_el::webrtc_pub(ref v)) => v, - _ => WebRtcPublishEndpoint::default_instance(), - } - } - pub fn clear_webrtc_pub(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_webrtc_pub(&self) -> bool { - match self.el { - ::std::option::Option::Some(Element_oneof_el::webrtc_pub(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_webrtc_pub(&mut self, v: WebRtcPublishEndpoint) { - self.el = ::std::option::Option::Some(Element_oneof_el::webrtc_pub(v)) - } - - // Mutable pointer to the field. - pub fn mut_webrtc_pub(&mut self) -> &mut WebRtcPublishEndpoint { - if let ::std::option::Option::Some(Element_oneof_el::webrtc_pub(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(Element_oneof_el::webrtc_pub(WebRtcPublishEndpoint::new())); - } - match self.el { - ::std::option::Option::Some(Element_oneof_el::webrtc_pub(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_webrtc_pub(&mut self) -> WebRtcPublishEndpoint { - if self.has_webrtc_pub() { - match self.el.take() { - ::std::option::Option::Some(Element_oneof_el::webrtc_pub(v)) => v, - _ => panic!(), - } - } else { - WebRtcPublishEndpoint::new() - } - } -} - -impl ::protobuf::Message for Element { - fn is_initialized(&self) -> bool { - if let Some(Element_oneof_el::hub(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(Element_oneof_el::file_recorder(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(Element_oneof_el::member(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(Element_oneof_el::relay(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(Element_oneof_el::room(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(Element_oneof_el::webrtc_play(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(Element_oneof_el::webrtc_pub(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - 2 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(Element_oneof_el::hub(is.read_message()?)); - }, - 3 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(Element_oneof_el::file_recorder(is.read_message()?)); - }, - 4 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(Element_oneof_el::member(is.read_message()?)); - }, - 5 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(Element_oneof_el::relay(is.read_message()?)); - }, - 6 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(Element_oneof_el::room(is.read_message()?)); - }, - 7 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(Element_oneof_el::webrtc_play(is.read_message()?)); - }, - 8 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(Element_oneof_el::webrtc_pub(is.read_message()?)); - }, - _ => { - ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - if let ::std::option::Option::Some(ref v) = self.el { - match v { - &Element_oneof_el::hub(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &Element_oneof_el::file_recorder(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &Element_oneof_el::member(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &Element_oneof_el::relay(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &Element_oneof_el::room(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &Element_oneof_el::webrtc_play(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &Element_oneof_el::webrtc_pub(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - }; - } - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { - if let ::std::option::Option::Some(ref v) = self.el { - match v { - &Element_oneof_el::hub(ref v) => { - os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &Element_oneof_el::file_recorder(ref v) => { - os.write_tag(3, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &Element_oneof_el::member(ref v) => { - os.write_tag(4, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &Element_oneof_el::relay(ref v) => { - os.write_tag(5, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &Element_oneof_el::room(ref v) => { - os.write_tag(6, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &Element_oneof_el::webrtc_play(ref v) => { - os.write_tag(7, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &Element_oneof_el::webrtc_pub(ref v) => { - os.write_tag(8, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - }; - } - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any - } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any - } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - Self::descriptor_static() - } - - fn new() -> Element { - Element::new() - } - - fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Hub>( - "hub", - Element::has_hub, - Element::get_hub, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, FileRecorder>( - "file_recorder", - Element::has_file_recorder, - Element::get_file_recorder, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Member>( - "member", - Element::has_member, - Element::get_member, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Relay>( - "relay", - Element::has_relay, - Element::get_relay, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Room>( - "room", - Element::has_room, - Element::get_room, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPlayEndpoint>( - "webrtc_play", - Element::has_webrtc_play, - Element::get_webrtc_play, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPublishEndpoint>( - "webrtc_pub", - Element::has_webrtc_pub, - Element::get_webrtc_pub, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "Element", - fields, - file_descriptor_proto() - ) - }) - } - } - - fn default_instance() -> &'static Element { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const Element, - }; - unsafe { - instance.get(Element::new) - } - } -} - -impl ::protobuf::Clear for Element { - fn clear(&mut self) { - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for Element { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for Element { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) - } -} - -#[derive(PartialEq,Clone,Default)] -pub struct Room { - // message fields - pub pipeline: ::std::collections::HashMap<::std::string::String, Room_Element>, - // special fields - pub unknown_fields: ::protobuf::UnknownFields, - pub cached_size: ::protobuf::CachedSize, -} - -impl<'a> ::std::default::Default for &'a Room { - fn default() -> &'a Room { - ::default_instance() - } -} - -impl Room { - pub fn new() -> Room { - ::std::default::Default::default() - } - - // repeated .medea.Room.PipelineEntry pipeline = 1; - - - pub fn get_pipeline(&self) -> &::std::collections::HashMap<::std::string::String, Room_Element> { - &self.pipeline - } - pub fn clear_pipeline(&mut self) { - self.pipeline.clear(); - } - - // Param is passed by value, moved - pub fn set_pipeline(&mut self, v: ::std::collections::HashMap<::std::string::String, Room_Element>) { - self.pipeline = v; - } - - // Mutable pointer to the field. - pub fn mut_pipeline(&mut self) -> &mut ::std::collections::HashMap<::std::string::String, Room_Element> { - &mut self.pipeline - } - - // Take field - pub fn take_pipeline(&mut self) -> ::std::collections::HashMap<::std::string::String, Room_Element> { - ::std::mem::replace(&mut self.pipeline, ::std::collections::HashMap::new()) - } -} - -impl ::protobuf::Message for Room { - fn is_initialized(&self) -> bool { - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - 1 => { - ::protobuf::rt::read_map_into::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(wire_type, is, &mut self.pipeline)?; - }, - _ => { - ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - my_size += ::protobuf::rt::compute_map_size::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(1, &self.pipeline); - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { - ::protobuf::rt::write_map_with_cached_sizes::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(1, &self.pipeline, os)?; - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any - } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any - } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - Self::descriptor_static() - } - - fn new() -> Room { - Room::new() - } - - fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_map_accessor::<_, ::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>( - "pipeline", - |m: &Room| { &m.pipeline }, - |m: &mut Room| { &mut m.pipeline }, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "Room", - fields, - file_descriptor_proto() - ) - }) - } - } - - fn default_instance() -> &'static Room { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const Room, - }; - unsafe { - instance.get(Room::new) - } - } -} - -impl ::protobuf::Clear for Room { - fn clear(&mut self) { - self.pipeline.clear(); - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for Room { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for Room { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) - } -} - -#[derive(PartialEq,Clone,Default)] -pub struct Room_Element { - // message oneof groups - pub el: ::std::option::Option, - // special fields - pub unknown_fields: ::protobuf::UnknownFields, - pub cached_size: ::protobuf::CachedSize, -} - -impl<'a> ::std::default::Default for &'a Room_Element { - fn default() -> &'a Room_Element { - ::default_instance() - } -} - -#[derive(Clone,PartialEq,Debug)] -pub enum Room_Element_oneof_el { - hub(Hub), - file_recorder(FileRecorder), - member(Member), - relay(Relay), - webrtc_play(WebRtcPlayEndpoint), - webrtc_pub(WebRtcPublishEndpoint), -} - -impl Room_Element { - pub fn new() -> Room_Element { - ::std::default::Default::default() - } - - // .medea.Hub hub = 1; - - - pub fn get_hub(&self) -> &Hub { - match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::hub(ref v)) => v, - _ => Hub::default_instance(), - } - } - pub fn clear_hub(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_hub(&self) -> bool { - match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::hub(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_hub(&mut self, v: Hub) { - self.el = ::std::option::Option::Some(Room_Element_oneof_el::hub(v)) - } - - // Mutable pointer to the field. - pub fn mut_hub(&mut self) -> &mut Hub { - if let ::std::option::Option::Some(Room_Element_oneof_el::hub(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(Room_Element_oneof_el::hub(Hub::new())); - } - match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::hub(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_hub(&mut self) -> Hub { - if self.has_hub() { - match self.el.take() { - ::std::option::Option::Some(Room_Element_oneof_el::hub(v)) => v, - _ => panic!(), - } - } else { - Hub::new() - } - } - - // .medea.FileRecorder file_recorder = 2; - - - pub fn get_file_recorder(&self) -> &FileRecorder { - match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::file_recorder(ref v)) => v, - _ => FileRecorder::default_instance(), - } - } - pub fn clear_file_recorder(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_file_recorder(&self) -> bool { - match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::file_recorder(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_file_recorder(&mut self, v: FileRecorder) { - self.el = ::std::option::Option::Some(Room_Element_oneof_el::file_recorder(v)) - } - - // Mutable pointer to the field. - pub fn mut_file_recorder(&mut self) -> &mut FileRecorder { - if let ::std::option::Option::Some(Room_Element_oneof_el::file_recorder(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(Room_Element_oneof_el::file_recorder(FileRecorder::new())); - } - match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::file_recorder(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_file_recorder(&mut self) -> FileRecorder { - if self.has_file_recorder() { - match self.el.take() { - ::std::option::Option::Some(Room_Element_oneof_el::file_recorder(v)) => v, - _ => panic!(), - } - } else { - FileRecorder::new() - } - } - - // .medea.Member member = 3; - - - pub fn get_member(&self) -> &Member { - match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::member(ref v)) => v, - _ => Member::default_instance(), - } - } - pub fn clear_member(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_member(&self) -> bool { - match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::member(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_member(&mut self, v: Member) { - self.el = ::std::option::Option::Some(Room_Element_oneof_el::member(v)) - } - - // Mutable pointer to the field. - pub fn mut_member(&mut self) -> &mut Member { - if let ::std::option::Option::Some(Room_Element_oneof_el::member(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(Room_Element_oneof_el::member(Member::new())); - } - match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::member(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_member(&mut self) -> Member { - if self.has_member() { - match self.el.take() { - ::std::option::Option::Some(Room_Element_oneof_el::member(v)) => v, - _ => panic!(), - } - } else { - Member::new() - } - } - - // .medea.Relay relay = 4; - - - pub fn get_relay(&self) -> &Relay { - match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::relay(ref v)) => v, - _ => Relay::default_instance(), - } - } - pub fn clear_relay(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_relay(&self) -> bool { - match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::relay(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_relay(&mut self, v: Relay) { - self.el = ::std::option::Option::Some(Room_Element_oneof_el::relay(v)) - } - - // Mutable pointer to the field. - pub fn mut_relay(&mut self) -> &mut Relay { - if let ::std::option::Option::Some(Room_Element_oneof_el::relay(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(Room_Element_oneof_el::relay(Relay::new())); - } - match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::relay(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_relay(&mut self) -> Relay { - if self.has_relay() { - match self.el.take() { - ::std::option::Option::Some(Room_Element_oneof_el::relay(v)) => v, - _ => panic!(), - } - } else { - Relay::new() - } - } - - // .medea.WebRtcPlayEndpoint webrtc_play = 5; - - - pub fn get_webrtc_play(&self) -> &WebRtcPlayEndpoint { - match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(ref v)) => v, - _ => WebRtcPlayEndpoint::default_instance(), - } - } - pub fn clear_webrtc_play(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_webrtc_play(&self) -> bool { - match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_webrtc_play(&mut self, v: WebRtcPlayEndpoint) { - self.el = ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(v)) - } - - // Mutable pointer to the field. - pub fn mut_webrtc_play(&mut self) -> &mut WebRtcPlayEndpoint { - if let ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(WebRtcPlayEndpoint::new())); - } - match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_webrtc_play(&mut self) -> WebRtcPlayEndpoint { - if self.has_webrtc_play() { - match self.el.take() { - ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(v)) => v, - _ => panic!(), - } - } else { - WebRtcPlayEndpoint::new() - } - } - - // .medea.WebRtcPublishEndpoint webrtc_pub = 6; - - - pub fn get_webrtc_pub(&self) -> &WebRtcPublishEndpoint { - match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(ref v)) => v, - _ => WebRtcPublishEndpoint::default_instance(), - } - } - pub fn clear_webrtc_pub(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_webrtc_pub(&self) -> bool { - match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_webrtc_pub(&mut self, v: WebRtcPublishEndpoint) { - self.el = ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(v)) - } - - // Mutable pointer to the field. - pub fn mut_webrtc_pub(&mut self) -> &mut WebRtcPublishEndpoint { - if let ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(WebRtcPublishEndpoint::new())); - } - match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_webrtc_pub(&mut self) -> WebRtcPublishEndpoint { - if self.has_webrtc_pub() { - match self.el.take() { - ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(v)) => v, - _ => panic!(), - } - } else { - WebRtcPublishEndpoint::new() - } - } -} - -impl ::protobuf::Message for Room_Element { - fn is_initialized(&self) -> bool { - if let Some(Room_Element_oneof_el::hub(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(Room_Element_oneof_el::file_recorder(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(Room_Element_oneof_el::member(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(Room_Element_oneof_el::relay(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(Room_Element_oneof_el::webrtc_play(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(Room_Element_oneof_el::webrtc_pub(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - 1 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(Room_Element_oneof_el::hub(is.read_message()?)); - }, - 2 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(Room_Element_oneof_el::file_recorder(is.read_message()?)); - }, - 3 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(Room_Element_oneof_el::member(is.read_message()?)); - }, - 4 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(Room_Element_oneof_el::relay(is.read_message()?)); - }, - 5 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(is.read_message()?)); - }, - 6 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(is.read_message()?)); - }, - _ => { - ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - if let ::std::option::Option::Some(ref v) = self.el { - match v { - &Room_Element_oneof_el::hub(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &Room_Element_oneof_el::file_recorder(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &Room_Element_oneof_el::member(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &Room_Element_oneof_el::relay(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &Room_Element_oneof_el::webrtc_play(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &Room_Element_oneof_el::webrtc_pub(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - }; - } - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { - if let ::std::option::Option::Some(ref v) = self.el { - match v { - &Room_Element_oneof_el::hub(ref v) => { - os.write_tag(1, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &Room_Element_oneof_el::file_recorder(ref v) => { - os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &Room_Element_oneof_el::member(ref v) => { - os.write_tag(3, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &Room_Element_oneof_el::relay(ref v) => { - os.write_tag(4, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &Room_Element_oneof_el::webrtc_play(ref v) => { - os.write_tag(5, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &Room_Element_oneof_el::webrtc_pub(ref v) => { - os.write_tag(6, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - }; - } - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any - } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any - } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - Self::descriptor_static() - } - - fn new() -> Room_Element { - Room_Element::new() - } - - fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Hub>( - "hub", - Room_Element::has_hub, - Room_Element::get_hub, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, FileRecorder>( - "file_recorder", - Room_Element::has_file_recorder, - Room_Element::get_file_recorder, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Member>( - "member", - Room_Element::has_member, - Room_Element::get_member, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Relay>( - "relay", - Room_Element::has_relay, - Room_Element::get_relay, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPlayEndpoint>( - "webrtc_play", - Room_Element::has_webrtc_play, - Room_Element::get_webrtc_play, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPublishEndpoint>( - "webrtc_pub", - Room_Element::has_webrtc_pub, - Room_Element::get_webrtc_pub, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "Room_Element", - fields, - file_descriptor_proto() - ) - }) - } - } - - fn default_instance() -> &'static Room_Element { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const Room_Element, - }; - unsafe { - instance.get(Room_Element::new) - } - } -} - -impl ::protobuf::Clear for Room_Element { - fn clear(&mut self) { - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for Room_Element { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for Room_Element { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) - } -} - -#[derive(PartialEq,Clone,Default)] -pub struct Member { - // message fields - pub on_join: ::std::string::String, - pub on_leave: ::std::string::String, - pub credentials: ::std::string::String, - pub pipeline: ::std::collections::HashMap<::std::string::String, Member_Element>, - // special fields - pub unknown_fields: ::protobuf::UnknownFields, - pub cached_size: ::protobuf::CachedSize, -} - -impl<'a> ::std::default::Default for &'a Member { - fn default() -> &'a Member { - ::default_instance() - } -} - -impl Member { - pub fn new() -> Member { - ::std::default::Default::default() - } - - // string on_join = 1; - - - pub fn get_on_join(&self) -> &str { - &self.on_join - } - pub fn clear_on_join(&mut self) { - self.on_join.clear(); - } - - // Param is passed by value, moved - pub fn set_on_join(&mut self, v: ::std::string::String) { - self.on_join = v; - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_on_join(&mut self) -> &mut ::std::string::String { - &mut self.on_join - } - - // Take field - pub fn take_on_join(&mut self) -> ::std::string::String { - ::std::mem::replace(&mut self.on_join, ::std::string::String::new()) - } - - // string on_leave = 2; - - - pub fn get_on_leave(&self) -> &str { - &self.on_leave - } - pub fn clear_on_leave(&mut self) { - self.on_leave.clear(); - } - - // Param is passed by value, moved - pub fn set_on_leave(&mut self, v: ::std::string::String) { - self.on_leave = v; - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_on_leave(&mut self) -> &mut ::std::string::String { - &mut self.on_leave - } - - // Take field - pub fn take_on_leave(&mut self) -> ::std::string::String { - ::std::mem::replace(&mut self.on_leave, ::std::string::String::new()) - } - - // string credentials = 3; - - - pub fn get_credentials(&self) -> &str { - &self.credentials - } - pub fn clear_credentials(&mut self) { - self.credentials.clear(); - } - - // Param is passed by value, moved - pub fn set_credentials(&mut self, v: ::std::string::String) { - self.credentials = v; - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_credentials(&mut self) -> &mut ::std::string::String { - &mut self.credentials - } - - // Take field - pub fn take_credentials(&mut self) -> ::std::string::String { - ::std::mem::replace(&mut self.credentials, ::std::string::String::new()) - } - - // repeated .medea.Member.PipelineEntry pipeline = 4; - - - pub fn get_pipeline(&self) -> &::std::collections::HashMap<::std::string::String, Member_Element> { - &self.pipeline - } - pub fn clear_pipeline(&mut self) { - self.pipeline.clear(); - } - - // Param is passed by value, moved - pub fn set_pipeline(&mut self, v: ::std::collections::HashMap<::std::string::String, Member_Element>) { - self.pipeline = v; - } - - // Mutable pointer to the field. - pub fn mut_pipeline(&mut self) -> &mut ::std::collections::HashMap<::std::string::String, Member_Element> { - &mut self.pipeline - } - - // Take field - pub fn take_pipeline(&mut self) -> ::std::collections::HashMap<::std::string::String, Member_Element> { - ::std::mem::replace(&mut self.pipeline, ::std::collections::HashMap::new()) - } -} - -impl ::protobuf::Message for Member { - fn is_initialized(&self) -> bool { - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - 1 => { - ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.on_join)?; - }, - 2 => { - ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.on_leave)?; - }, - 3 => { - ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.credentials)?; - }, - 4 => { - ::protobuf::rt::read_map_into::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(wire_type, is, &mut self.pipeline)?; - }, - _ => { - ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - if !self.on_join.is_empty() { - my_size += ::protobuf::rt::string_size(1, &self.on_join); - } - if !self.on_leave.is_empty() { - my_size += ::protobuf::rt::string_size(2, &self.on_leave); - } - if !self.credentials.is_empty() { - my_size += ::protobuf::rt::string_size(3, &self.credentials); - } - my_size += ::protobuf::rt::compute_map_size::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(4, &self.pipeline); - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { - if !self.on_join.is_empty() { - os.write_string(1, &self.on_join)?; - } - if !self.on_leave.is_empty() { - os.write_string(2, &self.on_leave)?; - } - if !self.credentials.is_empty() { - os.write_string(3, &self.credentials)?; - } - ::protobuf::rt::write_map_with_cached_sizes::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(4, &self.pipeline, os)?; - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any - } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any - } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - Self::descriptor_static() - } - - fn new() -> Member { - Member::new() - } - - fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "on_join", - |m: &Member| { &m.on_join }, - |m: &mut Member| { &mut m.on_join }, - )); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "on_leave", - |m: &Member| { &m.on_leave }, - |m: &mut Member| { &mut m.on_leave }, - )); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "credentials", - |m: &Member| { &m.credentials }, - |m: &mut Member| { &mut m.credentials }, - )); - fields.push(::protobuf::reflect::accessor::make_map_accessor::<_, ::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>( - "pipeline", - |m: &Member| { &m.pipeline }, - |m: &mut Member| { &mut m.pipeline }, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "Member", - fields, - file_descriptor_proto() - ) - }) - } - } - - fn default_instance() -> &'static Member { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const Member, - }; - unsafe { - instance.get(Member::new) - } - } -} - -impl ::protobuf::Clear for Member { - fn clear(&mut self) { - self.on_join.clear(); - self.on_leave.clear(); - self.credentials.clear(); - self.pipeline.clear(); - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for Member { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for Member { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) - } -} - -#[derive(PartialEq,Clone,Default)] -pub struct Member_Element { - // message oneof groups - pub el: ::std::option::Option, - // special fields - pub unknown_fields: ::protobuf::UnknownFields, - pub cached_size: ::protobuf::CachedSize, -} - -impl<'a> ::std::default::Default for &'a Member_Element { - fn default() -> &'a Member_Element { - ::default_instance() - } -} - -#[derive(Clone,PartialEq,Debug)] -pub enum Member_Element_oneof_el { - hub(Hub), - file_recorder(FileRecorder), - relay(Relay), - webrtc_play(WebRtcPlayEndpoint), - webrtc_pub(WebRtcPublishEndpoint), -} - -impl Member_Element { - pub fn new() -> Member_Element { - ::std::default::Default::default() - } - - // .medea.Hub hub = 1; - - - pub fn get_hub(&self) -> &Hub { - match self.el { - ::std::option::Option::Some(Member_Element_oneof_el::hub(ref v)) => v, - _ => Hub::default_instance(), - } - } - pub fn clear_hub(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_hub(&self) -> bool { - match self.el { - ::std::option::Option::Some(Member_Element_oneof_el::hub(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_hub(&mut self, v: Hub) { - self.el = ::std::option::Option::Some(Member_Element_oneof_el::hub(v)) - } - - // Mutable pointer to the field. - pub fn mut_hub(&mut self) -> &mut Hub { - if let ::std::option::Option::Some(Member_Element_oneof_el::hub(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(Member_Element_oneof_el::hub(Hub::new())); - } - match self.el { - ::std::option::Option::Some(Member_Element_oneof_el::hub(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_hub(&mut self) -> Hub { - if self.has_hub() { - match self.el.take() { - ::std::option::Option::Some(Member_Element_oneof_el::hub(v)) => v, - _ => panic!(), - } - } else { - Hub::new() - } - } - - // .medea.FileRecorder file_recorder = 2; - - - pub fn get_file_recorder(&self) -> &FileRecorder { - match self.el { - ::std::option::Option::Some(Member_Element_oneof_el::file_recorder(ref v)) => v, - _ => FileRecorder::default_instance(), - } - } - pub fn clear_file_recorder(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_file_recorder(&self) -> bool { - match self.el { - ::std::option::Option::Some(Member_Element_oneof_el::file_recorder(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_file_recorder(&mut self, v: FileRecorder) { - self.el = ::std::option::Option::Some(Member_Element_oneof_el::file_recorder(v)) - } - - // Mutable pointer to the field. - pub fn mut_file_recorder(&mut self) -> &mut FileRecorder { - if let ::std::option::Option::Some(Member_Element_oneof_el::file_recorder(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(Member_Element_oneof_el::file_recorder(FileRecorder::new())); - } - match self.el { - ::std::option::Option::Some(Member_Element_oneof_el::file_recorder(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_file_recorder(&mut self) -> FileRecorder { - if self.has_file_recorder() { - match self.el.take() { - ::std::option::Option::Some(Member_Element_oneof_el::file_recorder(v)) => v, - _ => panic!(), - } - } else { - FileRecorder::new() - } - } - - // .medea.Relay relay = 3; - - - pub fn get_relay(&self) -> &Relay { - match self.el { - ::std::option::Option::Some(Member_Element_oneof_el::relay(ref v)) => v, - _ => Relay::default_instance(), - } - } - pub fn clear_relay(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_relay(&self) -> bool { - match self.el { - ::std::option::Option::Some(Member_Element_oneof_el::relay(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_relay(&mut self, v: Relay) { - self.el = ::std::option::Option::Some(Member_Element_oneof_el::relay(v)) - } - - // Mutable pointer to the field. - pub fn mut_relay(&mut self) -> &mut Relay { - if let ::std::option::Option::Some(Member_Element_oneof_el::relay(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(Member_Element_oneof_el::relay(Relay::new())); - } - match self.el { - ::std::option::Option::Some(Member_Element_oneof_el::relay(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_relay(&mut self) -> Relay { - if self.has_relay() { - match self.el.take() { - ::std::option::Option::Some(Member_Element_oneof_el::relay(v)) => v, - _ => panic!(), - } - } else { - Relay::new() - } - } - - // .medea.WebRtcPlayEndpoint webrtc_play = 4; - - - pub fn get_webrtc_play(&self) -> &WebRtcPlayEndpoint { - match self.el { - ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(ref v)) => v, - _ => WebRtcPlayEndpoint::default_instance(), - } - } - pub fn clear_webrtc_play(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_webrtc_play(&self) -> bool { - match self.el { - ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_webrtc_play(&mut self, v: WebRtcPlayEndpoint) { - self.el = ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(v)) - } - - // Mutable pointer to the field. - pub fn mut_webrtc_play(&mut self) -> &mut WebRtcPlayEndpoint { - if let ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(WebRtcPlayEndpoint::new())); - } - match self.el { - ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_webrtc_play(&mut self) -> WebRtcPlayEndpoint { - if self.has_webrtc_play() { - match self.el.take() { - ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(v)) => v, - _ => panic!(), - } - } else { - WebRtcPlayEndpoint::new() - } - } - - // .medea.WebRtcPublishEndpoint webrtc_pub = 5; - - - pub fn get_webrtc_pub(&self) -> &WebRtcPublishEndpoint { - match self.el { - ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(ref v)) => v, - _ => WebRtcPublishEndpoint::default_instance(), - } - } - pub fn clear_webrtc_pub(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_webrtc_pub(&self) -> bool { - match self.el { - ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_webrtc_pub(&mut self, v: WebRtcPublishEndpoint) { - self.el = ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(v)) - } - - // Mutable pointer to the field. - pub fn mut_webrtc_pub(&mut self) -> &mut WebRtcPublishEndpoint { - if let ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(WebRtcPublishEndpoint::new())); - } - match self.el { - ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_webrtc_pub(&mut self) -> WebRtcPublishEndpoint { - if self.has_webrtc_pub() { - match self.el.take() { - ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(v)) => v, - _ => panic!(), - } - } else { - WebRtcPublishEndpoint::new() - } - } -} - -impl ::protobuf::Message for Member_Element { - fn is_initialized(&self) -> bool { - if let Some(Member_Element_oneof_el::hub(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(Member_Element_oneof_el::file_recorder(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(Member_Element_oneof_el::relay(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(Member_Element_oneof_el::webrtc_play(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(Member_Element_oneof_el::webrtc_pub(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - 1 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(Member_Element_oneof_el::hub(is.read_message()?)); - }, - 2 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(Member_Element_oneof_el::file_recorder(is.read_message()?)); - }, - 3 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(Member_Element_oneof_el::relay(is.read_message()?)); - }, - 4 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(is.read_message()?)); - }, - 5 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(is.read_message()?)); - }, - _ => { - ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - if let ::std::option::Option::Some(ref v) = self.el { - match v { - &Member_Element_oneof_el::hub(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &Member_Element_oneof_el::file_recorder(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &Member_Element_oneof_el::relay(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &Member_Element_oneof_el::webrtc_play(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &Member_Element_oneof_el::webrtc_pub(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - }; - } - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { - if let ::std::option::Option::Some(ref v) = self.el { - match v { - &Member_Element_oneof_el::hub(ref v) => { - os.write_tag(1, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &Member_Element_oneof_el::file_recorder(ref v) => { - os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &Member_Element_oneof_el::relay(ref v) => { - os.write_tag(3, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &Member_Element_oneof_el::webrtc_play(ref v) => { - os.write_tag(4, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &Member_Element_oneof_el::webrtc_pub(ref v) => { - os.write_tag(5, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - }; - } - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any - } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any - } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - Self::descriptor_static() - } - - fn new() -> Member_Element { - Member_Element::new() - } - - fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Hub>( - "hub", - Member_Element::has_hub, - Member_Element::get_hub, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, FileRecorder>( - "file_recorder", - Member_Element::has_file_recorder, - Member_Element::get_file_recorder, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Relay>( - "relay", - Member_Element::has_relay, - Member_Element::get_relay, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPlayEndpoint>( - "webrtc_play", - Member_Element::has_webrtc_play, - Member_Element::get_webrtc_play, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPublishEndpoint>( - "webrtc_pub", - Member_Element::has_webrtc_pub, - Member_Element::get_webrtc_pub, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "Member_Element", - fields, - file_descriptor_proto() - ) - }) - } - } - - fn default_instance() -> &'static Member_Element { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const Member_Element, - }; - unsafe { - instance.get(Member_Element::new) - } - } -} - -impl ::protobuf::Clear for Member_Element { - fn clear(&mut self) { - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for Member_Element { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for Member_Element { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) - } -} - -#[derive(PartialEq,Clone,Default)] -pub struct WebRtcPublishEndpoint { - // message fields - pub p2p: WebRtcPublishEndpoint_P2P, - pub dst: ::std::string::String, - pub on_start: ::std::string::String, - pub on_stop: ::std::string::String, - // special fields - pub unknown_fields: ::protobuf::UnknownFields, - pub cached_size: ::protobuf::CachedSize, -} - -impl<'a> ::std::default::Default for &'a WebRtcPublishEndpoint { - fn default() -> &'a WebRtcPublishEndpoint { - ::default_instance() - } -} - -impl WebRtcPublishEndpoint { - pub fn new() -> WebRtcPublishEndpoint { - ::std::default::Default::default() - } - - // .medea.WebRtcPublishEndpoint.P2P p2p = 1; - - - pub fn get_p2p(&self) -> WebRtcPublishEndpoint_P2P { - self.p2p - } - pub fn clear_p2p(&mut self) { - self.p2p = WebRtcPublishEndpoint_P2P::NEVER; - } - - // Param is passed by value, moved - pub fn set_p2p(&mut self, v: WebRtcPublishEndpoint_P2P) { - self.p2p = v; - } - - // string dst = 2; - - - pub fn get_dst(&self) -> &str { - &self.dst - } - pub fn clear_dst(&mut self) { - self.dst.clear(); - } - - // Param is passed by value, moved - pub fn set_dst(&mut self, v: ::std::string::String) { - self.dst = v; - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_dst(&mut self) -> &mut ::std::string::String { - &mut self.dst - } - - // Take field - pub fn take_dst(&mut self) -> ::std::string::String { - ::std::mem::replace(&mut self.dst, ::std::string::String::new()) - } - - // string on_start = 3; - - - pub fn get_on_start(&self) -> &str { - &self.on_start - } - pub fn clear_on_start(&mut self) { - self.on_start.clear(); - } - - // Param is passed by value, moved - pub fn set_on_start(&mut self, v: ::std::string::String) { - self.on_start = v; - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_on_start(&mut self) -> &mut ::std::string::String { - &mut self.on_start - } - - // Take field - pub fn take_on_start(&mut self) -> ::std::string::String { - ::std::mem::replace(&mut self.on_start, ::std::string::String::new()) - } - - // string on_stop = 4; - - - pub fn get_on_stop(&self) -> &str { - &self.on_stop - } - pub fn clear_on_stop(&mut self) { - self.on_stop.clear(); - } - - // Param is passed by value, moved - pub fn set_on_stop(&mut self, v: ::std::string::String) { - self.on_stop = v; - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_on_stop(&mut self) -> &mut ::std::string::String { - &mut self.on_stop - } - - // Take field - pub fn take_on_stop(&mut self) -> ::std::string::String { - ::std::mem::replace(&mut self.on_stop, ::std::string::String::new()) - } -} - -impl ::protobuf::Message for WebRtcPublishEndpoint { - fn is_initialized(&self) -> bool { - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - 1 => { - ::protobuf::rt::read_proto3_enum_with_unknown_fields_into(wire_type, is, &mut self.p2p, 1, &mut self.unknown_fields)? - }, - 2 => { - ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.dst)?; - }, - 3 => { - ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.on_start)?; - }, - 4 => { - ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.on_stop)?; - }, - _ => { - ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - if self.p2p != WebRtcPublishEndpoint_P2P::NEVER { - my_size += ::protobuf::rt::enum_size(1, self.p2p); - } - if !self.dst.is_empty() { - my_size += ::protobuf::rt::string_size(2, &self.dst); - } - if !self.on_start.is_empty() { - my_size += ::protobuf::rt::string_size(3, &self.on_start); - } - if !self.on_stop.is_empty() { - my_size += ::protobuf::rt::string_size(4, &self.on_stop); - } - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { - if self.p2p != WebRtcPublishEndpoint_P2P::NEVER { - os.write_enum(1, self.p2p.value())?; - } - if !self.dst.is_empty() { - os.write_string(2, &self.dst)?; - } - if !self.on_start.is_empty() { - os.write_string(3, &self.on_start)?; - } - if !self.on_stop.is_empty() { - os.write_string(4, &self.on_stop)?; - } - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any - } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any - } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - Self::descriptor_static() - } - - fn new() -> WebRtcPublishEndpoint { - WebRtcPublishEndpoint::new() - } - - fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeEnum>( - "p2p", - |m: &WebRtcPublishEndpoint| { &m.p2p }, - |m: &mut WebRtcPublishEndpoint| { &mut m.p2p }, - )); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "dst", - |m: &WebRtcPublishEndpoint| { &m.dst }, - |m: &mut WebRtcPublishEndpoint| { &mut m.dst }, - )); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "on_start", - |m: &WebRtcPublishEndpoint| { &m.on_start }, - |m: &mut WebRtcPublishEndpoint| { &mut m.on_start }, - )); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "on_stop", - |m: &WebRtcPublishEndpoint| { &m.on_stop }, - |m: &mut WebRtcPublishEndpoint| { &mut m.on_stop }, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "WebRtcPublishEndpoint", - fields, - file_descriptor_proto() - ) - }) - } - } - - fn default_instance() -> &'static WebRtcPublishEndpoint { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const WebRtcPublishEndpoint, - }; - unsafe { - instance.get(WebRtcPublishEndpoint::new) - } - } -} - -impl ::protobuf::Clear for WebRtcPublishEndpoint { - fn clear(&mut self) { - self.p2p = WebRtcPublishEndpoint_P2P::NEVER; - self.dst.clear(); - self.on_start.clear(); - self.on_stop.clear(); - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for WebRtcPublishEndpoint { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for WebRtcPublishEndpoint { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) - } -} - -#[derive(Clone,PartialEq,Eq,Debug,Hash)] -pub enum WebRtcPublishEndpoint_P2P { - NEVER = 0, - IF_POSSIBLE = 1, - ALWAYS = 2, -} - -impl ::protobuf::ProtobufEnum for WebRtcPublishEndpoint_P2P { - fn value(&self) -> i32 { - *self as i32 - } - - fn from_i32(value: i32) -> ::std::option::Option { - match value { - 0 => ::std::option::Option::Some(WebRtcPublishEndpoint_P2P::NEVER), - 1 => ::std::option::Option::Some(WebRtcPublishEndpoint_P2P::IF_POSSIBLE), - 2 => ::std::option::Option::Some(WebRtcPublishEndpoint_P2P::ALWAYS), - _ => ::std::option::Option::None - } - } - - fn values() -> &'static [Self] { - static values: &'static [WebRtcPublishEndpoint_P2P] = &[ - WebRtcPublishEndpoint_P2P::NEVER, - WebRtcPublishEndpoint_P2P::IF_POSSIBLE, - WebRtcPublishEndpoint_P2P::ALWAYS, - ]; - values - } - - fn enum_descriptor_static() -> &'static ::protobuf::reflect::EnumDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::EnumDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::EnumDescriptor, - }; - unsafe { - descriptor.get(|| { - ::protobuf::reflect::EnumDescriptor::new("WebRtcPublishEndpoint_P2P", file_descriptor_proto()) - }) - } - } -} - -impl ::std::marker::Copy for WebRtcPublishEndpoint_P2P { -} - -impl ::std::default::Default for WebRtcPublishEndpoint_P2P { - fn default() -> Self { - WebRtcPublishEndpoint_P2P::NEVER - } -} - -impl ::protobuf::reflect::ProtobufValue for WebRtcPublishEndpoint_P2P { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Enum(self.descriptor()) - } -} - -#[derive(PartialEq,Clone,Default)] -pub struct WebRtcPlayEndpoint { - // message fields - pub src: ::std::string::String, - pub on_start: ::std::string::String, - pub on_stop: ::std::string::String, - // special fields - pub unknown_fields: ::protobuf::UnknownFields, - pub cached_size: ::protobuf::CachedSize, -} - -impl<'a> ::std::default::Default for &'a WebRtcPlayEndpoint { - fn default() -> &'a WebRtcPlayEndpoint { - ::default_instance() - } -} - -impl WebRtcPlayEndpoint { - pub fn new() -> WebRtcPlayEndpoint { - ::std::default::Default::default() - } - - // string src = 1; - - - pub fn get_src(&self) -> &str { - &self.src - } - pub fn clear_src(&mut self) { - self.src.clear(); - } - - // Param is passed by value, moved - pub fn set_src(&mut self, v: ::std::string::String) { - self.src = v; - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_src(&mut self) -> &mut ::std::string::String { - &mut self.src - } - - // Take field - pub fn take_src(&mut self) -> ::std::string::String { - ::std::mem::replace(&mut self.src, ::std::string::String::new()) - } - - // string on_start = 2; - - - pub fn get_on_start(&self) -> &str { - &self.on_start - } - pub fn clear_on_start(&mut self) { - self.on_start.clear(); - } - - // Param is passed by value, moved - pub fn set_on_start(&mut self, v: ::std::string::String) { - self.on_start = v; - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_on_start(&mut self) -> &mut ::std::string::String { - &mut self.on_start - } - - // Take field - pub fn take_on_start(&mut self) -> ::std::string::String { - ::std::mem::replace(&mut self.on_start, ::std::string::String::new()) - } - - // string on_stop = 3; - - - pub fn get_on_stop(&self) -> &str { - &self.on_stop - } - pub fn clear_on_stop(&mut self) { - self.on_stop.clear(); - } - - // Param is passed by value, moved - pub fn set_on_stop(&mut self, v: ::std::string::String) { - self.on_stop = v; - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_on_stop(&mut self) -> &mut ::std::string::String { - &mut self.on_stop - } - - // Take field - pub fn take_on_stop(&mut self) -> ::std::string::String { - ::std::mem::replace(&mut self.on_stop, ::std::string::String::new()) - } -} - -impl ::protobuf::Message for WebRtcPlayEndpoint { - fn is_initialized(&self) -> bool { - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - 1 => { - ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.src)?; - }, - 2 => { - ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.on_start)?; - }, - 3 => { - ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.on_stop)?; - }, - _ => { - ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - if !self.src.is_empty() { - my_size += ::protobuf::rt::string_size(1, &self.src); - } - if !self.on_start.is_empty() { - my_size += ::protobuf::rt::string_size(2, &self.on_start); - } - if !self.on_stop.is_empty() { - my_size += ::protobuf::rt::string_size(3, &self.on_stop); - } - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { - if !self.src.is_empty() { - os.write_string(1, &self.src)?; - } - if !self.on_start.is_empty() { - os.write_string(2, &self.on_start)?; - } - if !self.on_stop.is_empty() { - os.write_string(3, &self.on_stop)?; - } - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any - } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any - } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - Self::descriptor_static() - } - - fn new() -> WebRtcPlayEndpoint { - WebRtcPlayEndpoint::new() - } - - fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "src", - |m: &WebRtcPlayEndpoint| { &m.src }, - |m: &mut WebRtcPlayEndpoint| { &mut m.src }, - )); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "on_start", - |m: &WebRtcPlayEndpoint| { &m.on_start }, - |m: &mut WebRtcPlayEndpoint| { &mut m.on_start }, - )); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "on_stop", - |m: &WebRtcPlayEndpoint| { &m.on_stop }, - |m: &mut WebRtcPlayEndpoint| { &mut m.on_stop }, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "WebRtcPlayEndpoint", - fields, - file_descriptor_proto() - ) - }) - } - } - - fn default_instance() -> &'static WebRtcPlayEndpoint { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const WebRtcPlayEndpoint, - }; - unsafe { - instance.get(WebRtcPlayEndpoint::new) - } - } -} - -impl ::protobuf::Clear for WebRtcPlayEndpoint { - fn clear(&mut self) { - self.src.clear(); - self.on_start.clear(); - self.on_stop.clear(); - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for WebRtcPlayEndpoint { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for WebRtcPlayEndpoint { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) - } -} - -#[derive(PartialEq,Clone,Default)] -pub struct Hub { - // special fields - pub unknown_fields: ::protobuf::UnknownFields, - pub cached_size: ::protobuf::CachedSize, -} - -impl<'a> ::std::default::Default for &'a Hub { - fn default() -> &'a Hub { - ::default_instance() - } -} - -impl Hub { - pub fn new() -> Hub { - ::std::default::Default::default() - } -} - -impl ::protobuf::Message for Hub { - fn is_initialized(&self) -> bool { - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - _ => { - ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any - } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any - } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - Self::descriptor_static() - } - - fn new() -> Hub { - Hub::new() - } - - fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let fields = ::std::vec::Vec::new(); - ::protobuf::reflect::MessageDescriptor::new::( - "Hub", - fields, - file_descriptor_proto() - ) - }) - } - } - - fn default_instance() -> &'static Hub { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const Hub, - }; - unsafe { - instance.get(Hub::new) - } - } -} - -impl ::protobuf::Clear for Hub { - fn clear(&mut self) { - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for Hub { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for Hub { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) - } -} - -#[derive(PartialEq,Clone,Default)] -pub struct FileRecorder { - // message fields - pub src: ::std::string::String, - pub dst: ::std::string::String, - pub on_start: ::std::string::String, - pub on_stop: ::std::string::String, - // special fields - pub unknown_fields: ::protobuf::UnknownFields, - pub cached_size: ::protobuf::CachedSize, -} - -impl<'a> ::std::default::Default for &'a FileRecorder { - fn default() -> &'a FileRecorder { - ::default_instance() - } -} - -impl FileRecorder { - pub fn new() -> FileRecorder { - ::std::default::Default::default() - } - - // string src = 1; - - - pub fn get_src(&self) -> &str { - &self.src - } - pub fn clear_src(&mut self) { - self.src.clear(); - } - - // Param is passed by value, moved - pub fn set_src(&mut self, v: ::std::string::String) { - self.src = v; - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_src(&mut self) -> &mut ::std::string::String { - &mut self.src - } - - // Take field - pub fn take_src(&mut self) -> ::std::string::String { - ::std::mem::replace(&mut self.src, ::std::string::String::new()) - } - - // string dst = 2; - - - pub fn get_dst(&self) -> &str { - &self.dst - } - pub fn clear_dst(&mut self) { - self.dst.clear(); - } - - // Param is passed by value, moved - pub fn set_dst(&mut self, v: ::std::string::String) { - self.dst = v; - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_dst(&mut self) -> &mut ::std::string::String { - &mut self.dst - } - - // Take field - pub fn take_dst(&mut self) -> ::std::string::String { - ::std::mem::replace(&mut self.dst, ::std::string::String::new()) - } - - // string on_start = 3; - - - pub fn get_on_start(&self) -> &str { - &self.on_start - } - pub fn clear_on_start(&mut self) { - self.on_start.clear(); - } - - // Param is passed by value, moved - pub fn set_on_start(&mut self, v: ::std::string::String) { - self.on_start = v; - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_on_start(&mut self) -> &mut ::std::string::String { - &mut self.on_start - } - - // Take field - pub fn take_on_start(&mut self) -> ::std::string::String { - ::std::mem::replace(&mut self.on_start, ::std::string::String::new()) - } - - // string on_stop = 4; - - - pub fn get_on_stop(&self) -> &str { - &self.on_stop - } - pub fn clear_on_stop(&mut self) { - self.on_stop.clear(); - } - - // Param is passed by value, moved - pub fn set_on_stop(&mut self, v: ::std::string::String) { - self.on_stop = v; - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_on_stop(&mut self) -> &mut ::std::string::String { - &mut self.on_stop - } - - // Take field - pub fn take_on_stop(&mut self) -> ::std::string::String { - ::std::mem::replace(&mut self.on_stop, ::std::string::String::new()) - } -} - -impl ::protobuf::Message for FileRecorder { - fn is_initialized(&self) -> bool { - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - 1 => { - ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.src)?; - }, - 2 => { - ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.dst)?; - }, - 3 => { - ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.on_start)?; - }, - 4 => { - ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.on_stop)?; - }, - _ => { - ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - if !self.src.is_empty() { - my_size += ::protobuf::rt::string_size(1, &self.src); - } - if !self.dst.is_empty() { - my_size += ::protobuf::rt::string_size(2, &self.dst); - } - if !self.on_start.is_empty() { - my_size += ::protobuf::rt::string_size(3, &self.on_start); - } - if !self.on_stop.is_empty() { - my_size += ::protobuf::rt::string_size(4, &self.on_stop); - } - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { - if !self.src.is_empty() { - os.write_string(1, &self.src)?; - } - if !self.dst.is_empty() { - os.write_string(2, &self.dst)?; - } - if !self.on_start.is_empty() { - os.write_string(3, &self.on_start)?; - } - if !self.on_stop.is_empty() { - os.write_string(4, &self.on_stop)?; - } - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any - } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any - } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - Self::descriptor_static() - } - - fn new() -> FileRecorder { - FileRecorder::new() - } - - fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "src", - |m: &FileRecorder| { &m.src }, - |m: &mut FileRecorder| { &mut m.src }, - )); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "dst", - |m: &FileRecorder| { &m.dst }, - |m: &mut FileRecorder| { &mut m.dst }, - )); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "on_start", - |m: &FileRecorder| { &m.on_start }, - |m: &mut FileRecorder| { &mut m.on_start }, - )); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "on_stop", - |m: &FileRecorder| { &m.on_stop }, - |m: &mut FileRecorder| { &mut m.on_stop }, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "FileRecorder", - fields, - file_descriptor_proto() - ) - }) - } - } - - fn default_instance() -> &'static FileRecorder { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const FileRecorder, - }; - unsafe { - instance.get(FileRecorder::new) - } - } -} - -impl ::protobuf::Clear for FileRecorder { - fn clear(&mut self) { - self.src.clear(); - self.dst.clear(); - self.on_start.clear(); - self.on_stop.clear(); - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for FileRecorder { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for FileRecorder { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) - } -} - -#[derive(PartialEq,Clone,Default)] -pub struct Relay { - // message fields - pub src: ::std::string::String, - pub dst: ::std::string::String, - // special fields - pub unknown_fields: ::protobuf::UnknownFields, - pub cached_size: ::protobuf::CachedSize, -} - -impl<'a> ::std::default::Default for &'a Relay { - fn default() -> &'a Relay { - ::default_instance() - } -} - -impl Relay { - pub fn new() -> Relay { - ::std::default::Default::default() - } - - // string src = 1; - - - pub fn get_src(&self) -> &str { - &self.src - } - pub fn clear_src(&mut self) { - self.src.clear(); - } - - // Param is passed by value, moved - pub fn set_src(&mut self, v: ::std::string::String) { - self.src = v; - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_src(&mut self) -> &mut ::std::string::String { - &mut self.src - } - - // Take field - pub fn take_src(&mut self) -> ::std::string::String { - ::std::mem::replace(&mut self.src, ::std::string::String::new()) - } - - // string dst = 2; - - - pub fn get_dst(&self) -> &str { - &self.dst - } - pub fn clear_dst(&mut self) { - self.dst.clear(); - } - - // Param is passed by value, moved - pub fn set_dst(&mut self, v: ::std::string::String) { - self.dst = v; - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_dst(&mut self) -> &mut ::std::string::String { - &mut self.dst - } - - // Take field - pub fn take_dst(&mut self) -> ::std::string::String { - ::std::mem::replace(&mut self.dst, ::std::string::String::new()) - } -} - -impl ::protobuf::Message for Relay { - fn is_initialized(&self) -> bool { - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - 1 => { - ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.src)?; - }, - 2 => { - ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.dst)?; - }, - _ => { - ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - if !self.src.is_empty() { - my_size += ::protobuf::rt::string_size(1, &self.src); - } - if !self.dst.is_empty() { - my_size += ::protobuf::rt::string_size(2, &self.dst); - } - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { - if !self.src.is_empty() { - os.write_string(1, &self.src)?; - } - if !self.dst.is_empty() { - os.write_string(2, &self.dst)?; - } - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any - } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any - } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - Self::descriptor_static() - } - - fn new() -> Relay { - Relay::new() - } - - fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "src", - |m: &Relay| { &m.src }, - |m: &mut Relay| { &mut m.src }, - )); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "dst", - |m: &Relay| { &m.dst }, - |m: &mut Relay| { &mut m.dst }, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "Relay", - fields, - file_descriptor_proto() - ) - }) - } - } - - fn default_instance() -> &'static Relay { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const Relay, - }; - unsafe { - instance.get(Relay::new) - } - } -} - -impl ::protobuf::Clear for Relay { - fn clear(&mut self) { - self.src.clear(); - self.dst.clear(); - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for Relay { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for Relay { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) - } -} - -static file_descriptor_proto_data: &'static [u8] = b"\ - \n\rcontrol.proto\x12\x05medea\x1a\x19google/protobuf/any.proto\"\xf0\ - \x02\n\rCreateRequest\x12\x0e\n\x02id\x18\x01\x20\x01(\tR\x02id\x12\x1e\ - \n\x03hub\x18\x02\x20\x01(\x0b2\n.medea.HubH\0R\x03hub\x12:\n\rfile_reco\ - rder\x18\x03\x20\x01(\x0b2\x13.medea.FileRecorderH\0R\x0cfileRecorder\ - \x12'\n\x06member\x18\x04\x20\x01(\x0b2\r.medea.MemberH\0R\x06member\x12\ - $\n\x05relay\x18\x05\x20\x01(\x0b2\x0c.medea.RelayH\0R\x05relay\x12!\n\ - \x04room\x18\x06\x20\x01(\x0b2\x0b.medea.RoomH\0R\x04room\x12<\n\x0bwebr\ - tc_play\x18\x07\x20\x01(\x0b2\x19.medea.WebRtcPlayEndpointH\0R\nwebrtcPl\ - ay\x12=\n\nwebrtc_pub\x18\x08\x20\x01(\x0b2\x1c.medea.WebRtcPublishEndpo\ - intH\0R\twebrtcPubB\x04\n\x02el\"\xc4\x03\n\x0cApplyRequest\x12\x0e\n\ - \x02id\x18\x01\x20\x01(\tR\x02id\x12\x1e\n\x03hub\x18\x02\x20\x01(\x0b2\ - \n.medea.HubH\0R\x03hub\x12:\n\rfile_recorder\x18\x03\x20\x01(\x0b2\x13.\ - medea.FileRecorderH\0R\x0cfileRecorder\x12'\n\x06member\x18\x04\x20\x01(\ - \x0b2\r.medea.MemberH\0R\x06member\x12$\n\x05relay\x18\x05\x20\x01(\x0b2\ - \x0c.medea.RelayH\0R\x05relay\x12!\n\x04room\x18\x06\x20\x01(\x0b2\x0b.m\ - edea.RoomH\0R\x04room\x12<\n\x0bwebrtc_play\x18\x07\x20\x01(\x0b2\x19.me\ - dea.WebRtcPlayEndpointH\0R\nwebrtcPlay\x12=\n\nwebrtc_pub\x18\x08\x20\ - \x01(\x0b2\x1c.medea.WebRtcPublishEndpointH\0R\twebrtcPub\x122\n\x06poli\ - cy\x18\t\x20\x01(\x0e2\x1a.medea.ApplyRequest.PolicyR\x06policy\"\x1f\n\ - \x06Policy\x12\t\n\x05APPLY\x10\0\x12\n\n\x06APPEND\x10\x01B\x04\n\x02el\ - \"\x1b\n\tIdRequest\x12\x0e\n\x02id\x18\x01\x20\x03(\tR\x02id\"\x92\x01\ - \n\x08Response\x12*\n\x03sid\x18\x01\x20\x03(\x0b2\x18.medea.Response.Si\ - dEntryR\x03sid\x12\"\n\x05error\x18\x02\x20\x01(\x0b2\x0c.medea.ErrorR\ - \x05error\x1a6\n\x08SidEntry\x12\x10\n\x03key\x18\x01\x20\x01(\tR\x03key\ - \x12\x14\n\x05value\x18\x02\x20\x01(\tR\x05value:\x028\x01\"\xbc\x01\n\ - \x0bGetResponse\x12<\n\x08elements\x18\x01\x20\x03(\x0b2\x20.medea.GetRe\ - sponse.ElementsEntryR\x08elements\x12\"\n\x05error\x18\x02\x20\x01(\x0b2\ - \x0c.medea.ErrorR\x05error\x1aK\n\rElementsEntry\x12\x10\n\x03key\x18\ - \x01\x20\x01(\tR\x03key\x12$\n\x05value\x18\x02\x20\x01(\x0b2\x0e.medea.\ - ElementR\x05value:\x028\x01\"\xa9\x01\n\x05Error\x12\x12\n\x04code\x18\ - \x02\x20\x01(\rR\x04code\x12\x12\n\x04text\x18\x03\x20\x01(\tR\x04text\ - \x12\x10\n\x03doc\x18\x04\x20\x01(\tR\x03doc\x12\x18\n\x07element\x18\ - \x05\x20\x01(\tR\x07element\x12.\n\x07details\x18\x06\x20\x01(\x0b2\x14.\ - google.protobuf.AnyR\x07details\x12\x1c\n\tbacktrace\x18\x07\x20\x03(\tR\ - \tbacktrace\"\xda\x02\n\x07Element\x12\x1e\n\x03hub\x18\x02\x20\x01(\x0b\ - 2\n.medea.HubH\0R\x03hub\x12:\n\rfile_recorder\x18\x03\x20\x01(\x0b2\x13\ - .medea.FileRecorderH\0R\x0cfileRecorder\x12'\n\x06member\x18\x04\x20\x01\ - (\x0b2\r.medea.MemberH\0R\x06member\x12$\n\x05relay\x18\x05\x20\x01(\x0b\ - 2\x0c.medea.RelayH\0R\x05relay\x12!\n\x04room\x18\x06\x20\x01(\x0b2\x0b.\ - medea.RoomH\0R\x04room\x12<\n\x0bwebrtc_play\x18\x07\x20\x01(\x0b2\x19.m\ - edea.WebRtcPlayEndpointH\0R\nwebrtcPlay\x12=\n\nwebrtc_pub\x18\x08\x20\ - \x01(\x0b2\x1c.medea.WebRtcPublishEndpointH\0R\twebrtcPubB\x04\n\x02el\"\ - \xc9\x03\n\x04Room\x125\n\x08pipeline\x18\x01\x20\x03(\x0b2\x19.medea.Ro\ - om.PipelineEntryR\x08pipeline\x1aP\n\rPipelineEntry\x12\x10\n\x03key\x18\ - \x01\x20\x01(\tR\x03key\x12)\n\x05value\x18\x02\x20\x01(\x0b2\x13.medea.\ - Room.ElementR\x05value:\x028\x01\x1a\xb7\x02\n\x07Element\x12\x1e\n\x03h\ - ub\x18\x01\x20\x01(\x0b2\n.medea.HubH\0R\x03hub\x12:\n\rfile_recorder\ - \x18\x02\x20\x01(\x0b2\x13.medea.FileRecorderH\0R\x0cfileRecorder\x12'\n\ - \x06member\x18\x03\x20\x01(\x0b2\r.medea.MemberH\0R\x06member\x12$\n\x05\ - relay\x18\x04\x20\x01(\x0b2\x0c.medea.RelayH\0R\x05relay\x12<\n\x0bwebrt\ - c_play\x18\x05\x20\x01(\x0b2\x19.medea.WebRtcPlayEndpointH\0R\nwebrtcPla\ - y\x12=\n\nwebrtc_pub\x18\x06\x20\x01(\x0b2\x1c.medea.WebRtcPublishEndpoi\ - ntH\0R\twebrtcPubB\x04\n\x02el\"\xfc\x03\n\x06Member\x12\x17\n\x07on_joi\ - n\x18\x01\x20\x01(\tR\x06onJoin\x12\x19\n\x08on_leave\x18\x02\x20\x01(\t\ - R\x07onLeave\x12\x20\n\x0bcredentials\x18\x03\x20\x01(\tR\x0bcredentials\ - \x127\n\x08pipeline\x18\x04\x20\x03(\x0b2\x1b.medea.Member.PipelineEntry\ - R\x08pipeline\x1aR\n\rPipelineEntry\x12\x10\n\x03key\x18\x01\x20\x01(\tR\ - \x03key\x12+\n\x05value\x18\x02\x20\x01(\x0b2\x15.medea.Member.ElementR\ - \x05value:\x028\x01\x1a\x8e\x02\n\x07Element\x12\x1e\n\x03hub\x18\x01\ - \x20\x01(\x0b2\n.medea.HubH\0R\x03hub\x12:\n\rfile_recorder\x18\x02\x20\ - \x01(\x0b2\x13.medea.FileRecorderH\0R\x0cfileRecorder\x12$\n\x05relay\ - \x18\x03\x20\x01(\x0b2\x0c.medea.RelayH\0R\x05relay\x12<\n\x0bwebrtc_pla\ - y\x18\x04\x20\x01(\x0b2\x19.medea.WebRtcPlayEndpointH\0R\nwebrtcPlay\x12\ - =\n\nwebrtc_pub\x18\x05\x20\x01(\x0b2\x1c.medea.WebRtcPublishEndpointH\0\ - R\twebrtcPubB\x04\n\x02el\"\xc0\x01\n\x15WebRtcPublishEndpoint\x122\n\ - \x03p2p\x18\x01\x20\x01(\x0e2\x20.medea.WebRtcPublishEndpoint.P2PR\x03p2\ - p\x12\x10\n\x03dst\x18\x02\x20\x01(\tR\x03dst\x12\x19\n\x08on_start\x18\ - \x03\x20\x01(\tR\x07onStart\x12\x17\n\x07on_stop\x18\x04\x20\x01(\tR\x06\ - onStop\"-\n\x03P2P\x12\t\n\x05NEVER\x10\0\x12\x0f\n\x0bIF_POSSIBLE\x10\ - \x01\x12\n\n\x06ALWAYS\x10\x02\"Z\n\x12WebRtcPlayEndpoint\x12\x10\n\x03s\ - rc\x18\x01\x20\x01(\tR\x03src\x12\x19\n\x08on_start\x18\x02\x20\x01(\tR\ - \x07onStart\x12\x17\n\x07on_stop\x18\x03\x20\x01(\tR\x06onStop\"\x05\n\ - \x03Hub\"f\n\x0cFileRecorder\x12\x10\n\x03src\x18\x01\x20\x01(\tR\x03src\ - \x12\x10\n\x03dst\x18\x02\x20\x01(\tR\x03dst\x12\x19\n\x08on_start\x18\ - \x03\x20\x01(\tR\x07onStart\x12\x17\n\x07on_stop\x18\x04\x20\x01(\tR\x06\ - onStop\"+\n\x05Relay\x12\x10\n\x03src\x18\x01\x20\x01(\tR\x03src\x12\x10\ - \n\x03dst\x18\x02\x20\x01(\tR\x03dst2\xc6\x01\n\nControlApi\x12/\n\x06Cr\ - eate\x12\x14.medea.CreateRequest\x1a\x0f.medea.Response\x12-\n\x05Apply\ - \x12\x13.medea.ApplyRequest\x1a\x0f.medea.Response\x12+\n\x06Delete\x12\ - \x10.medea.IdRequest\x1a\x0f.medea.Response\x12+\n\x03Get\x12\x10.medea.\ - IdRequest\x1a\x12.medea.GetResponseb\x06proto3\ -"; - -static mut file_descriptor_proto_lazy: ::protobuf::lazy::Lazy<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::descriptor::FileDescriptorProto, -}; - -fn parse_descriptor_proto() -> ::protobuf::descriptor::FileDescriptorProto { - ::protobuf::parse_from_bytes(file_descriptor_proto_data).unwrap() -} - -pub fn file_descriptor_proto() -> &'static ::protobuf::descriptor::FileDescriptorProto { - unsafe { - file_descriptor_proto_lazy.get(|| { - parse_descriptor_proto() - }) - } -} diff --git a/src/api/control/grpc/protos/control_grpc.rs b/src/api/control/grpc/protos/control_grpc.rs deleted file mode 100644 index 200c56a85..000000000 --- a/src/api/control/grpc/protos/control_grpc.rs +++ /dev/null @@ -1,155 +0,0 @@ -// This file is generated. Do not edit -// @generated - -// https://github.com/Manishearth/rust-clippy/issues/702 -#![allow(unknown_lints)] -#![allow(clippy::all)] - -#![cfg_attr(rustfmt, rustfmt_skip)] - -#![allow(box_pointers)] -#![allow(dead_code)] -#![allow(missing_docs)] -#![allow(non_camel_case_types)] -#![allow(non_snake_case)] -#![allow(non_upper_case_globals)] -#![allow(trivial_casts)] -#![allow(unsafe_code)] -#![allow(unused_imports)] -#![allow(unused_results)] - -const METHOD_CONTROL_API_CREATE: ::grpcio::Method = ::grpcio::Method { - ty: ::grpcio::MethodType::Unary, - name: "/medea.ControlApi/Create", - req_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, - resp_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, -}; - -const METHOD_CONTROL_API_APPLY: ::grpcio::Method = ::grpcio::Method { - ty: ::grpcio::MethodType::Unary, - name: "/medea.ControlApi/Apply", - req_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, - resp_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, -}; - -const METHOD_CONTROL_API_DELETE: ::grpcio::Method = ::grpcio::Method { - ty: ::grpcio::MethodType::Unary, - name: "/medea.ControlApi/Delete", - req_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, - resp_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, -}; - -const METHOD_CONTROL_API_GET: ::grpcio::Method = ::grpcio::Method { - ty: ::grpcio::MethodType::Unary, - name: "/medea.ControlApi/Get", - req_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, - resp_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, -}; - -#[derive(Clone)] -pub struct ControlApiClient { - client: ::grpcio::Client, -} - -impl ControlApiClient { - pub fn new(channel: ::grpcio::Channel) -> Self { - ControlApiClient { - client: ::grpcio::Client::new(channel), - } - } - - pub fn create_opt(&self, req: &super::control::CreateRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result { - self.client.unary_call(&METHOD_CONTROL_API_CREATE, req, opt) - } - - pub fn create(&self, req: &super::control::CreateRequest) -> ::grpcio::Result { - self.create_opt(req, ::grpcio::CallOption::default()) - } - - pub fn create_async_opt(&self, req: &super::control::CreateRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { - self.client.unary_call_async(&METHOD_CONTROL_API_CREATE, req, opt) - } - - pub fn create_async(&self, req: &super::control::CreateRequest) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { - self.create_async_opt(req, ::grpcio::CallOption::default()) - } - - pub fn apply_opt(&self, req: &super::control::ApplyRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result { - self.client.unary_call(&METHOD_CONTROL_API_APPLY, req, opt) - } - - pub fn apply(&self, req: &super::control::ApplyRequest) -> ::grpcio::Result { - self.apply_opt(req, ::grpcio::CallOption::default()) - } - - pub fn apply_async_opt(&self, req: &super::control::ApplyRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { - self.client.unary_call_async(&METHOD_CONTROL_API_APPLY, req, opt) - } - - pub fn apply_async(&self, req: &super::control::ApplyRequest) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { - self.apply_async_opt(req, ::grpcio::CallOption::default()) - } - - pub fn delete_opt(&self, req: &super::control::IdRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result { - self.client.unary_call(&METHOD_CONTROL_API_DELETE, req, opt) - } - - pub fn delete(&self, req: &super::control::IdRequest) -> ::grpcio::Result { - self.delete_opt(req, ::grpcio::CallOption::default()) - } - - pub fn delete_async_opt(&self, req: &super::control::IdRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { - self.client.unary_call_async(&METHOD_CONTROL_API_DELETE, req, opt) - } - - pub fn delete_async(&self, req: &super::control::IdRequest) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { - self.delete_async_opt(req, ::grpcio::CallOption::default()) - } - - pub fn get_opt(&self, req: &super::control::IdRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result { - self.client.unary_call(&METHOD_CONTROL_API_GET, req, opt) - } - - pub fn get(&self, req: &super::control::IdRequest) -> ::grpcio::Result { - self.get_opt(req, ::grpcio::CallOption::default()) - } - - pub fn get_async_opt(&self, req: &super::control::IdRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { - self.client.unary_call_async(&METHOD_CONTROL_API_GET, req, opt) - } - - pub fn get_async(&self, req: &super::control::IdRequest) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { - self.get_async_opt(req, ::grpcio::CallOption::default()) - } - pub fn spawn(&self, f: F) where F: ::futures::Future + Send + 'static { - self.client.spawn(f) - } -} - -pub trait ControlApi { - fn create(&mut self, ctx: ::grpcio::RpcContext, req: super::control::CreateRequest, sink: ::grpcio::UnarySink); - fn apply(&mut self, ctx: ::grpcio::RpcContext, req: super::control::ApplyRequest, sink: ::grpcio::UnarySink); - fn delete(&mut self, ctx: ::grpcio::RpcContext, req: super::control::IdRequest, sink: ::grpcio::UnarySink); - fn get(&mut self, ctx: ::grpcio::RpcContext, req: super::control::IdRequest, sink: ::grpcio::UnarySink); -} - -pub fn create_control_api(s: S) -> ::grpcio::Service { - let mut builder = ::grpcio::ServiceBuilder::new(); - let mut instance = s.clone(); - builder = builder.add_unary_handler(&METHOD_CONTROL_API_CREATE, move |ctx, req, resp| { - instance.create(ctx, req, resp) - }); - let mut instance = s.clone(); - builder = builder.add_unary_handler(&METHOD_CONTROL_API_APPLY, move |ctx, req, resp| { - instance.apply(ctx, req, resp) - }); - let mut instance = s.clone(); - builder = builder.add_unary_handler(&METHOD_CONTROL_API_DELETE, move |ctx, req, resp| { - instance.delete(ctx, req, resp) - }); - let mut instance = s.clone(); - builder = builder.add_unary_handler(&METHOD_CONTROL_API_GET, move |ctx, req, resp| { - instance.get(ctx, req, resp) - }); - builder.build() -} From 80cfdb34cc66ade82e36b624cc1216d416c48718 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 16 Jul 2019 12:16:04 +0300 Subject: [PATCH 367/735] Remove mutex for TurnAuthService in room --- src/lib.rs | 5 +++-- src/signalling/participants.rs | 14 +++++--------- src/signalling/room.rs | 7 ++++--- src/turn/service.rs | 14 ++++++++------ 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 8f8c74ddd..3ac6682b1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -9,6 +9,8 @@ pub mod media; pub mod signalling; pub mod turn; +use std::sync::Arc; + use actix::prelude::*; use failure::Fail; use hashbrown::HashMap; @@ -20,7 +22,6 @@ use crate::{ turn::{service, TurnServiceErr}, }; use futures::future::Either; -use std::sync::{Arc, Mutex}; /// Errors which can happen while server starting. #[derive(Debug, Fail)] @@ -70,7 +71,7 @@ pub fn start_static_rooms( if let Some(static_specs_path) = config.server.static_specs_path.clone() { Either::A( service::new_turn_auth_service(&config.turn) - .map(|t| Arc::new(Mutex::new(t))) + .map(|t| Arc::new(t)) .map(move |turn_auth_service| { let room_specs = match load_static_specs_from_dir(static_specs_path) { diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 59cc68abb..4e02358d1 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -5,6 +5,7 @@ use std::{ rc::Rc, + sync::Arc, time::{Duration, Instant}, }; @@ -37,7 +38,6 @@ use crate::{ }, turn::{TurnAuthService, TurnServiceErr, UnreachablePolicy}, }; -use std::sync::{Arc, Mutex}; #[derive(Fail, Debug)] #[allow(clippy::module_name_repetitions)] @@ -77,7 +77,7 @@ pub struct ParticipantService { members: HashMap>, /// Service for managing authorization on Turn server. - turn: Arc>>, + turn: Arc>, /// Established [`RpcConnection`]s of [`Members`]s in this [`Room`]. // TODO: Replace Box> with enum, @@ -99,7 +99,7 @@ impl ParticipantService { pub fn new( room_spec: &RoomSpec, reconnect_timeout: Duration, - turn: Arc>>, + turn: Arc>, ) -> Result { Ok(Self { room_id: room_spec.id().clone(), @@ -192,7 +192,7 @@ impl ParticipantService { Box::new(wrap_future(connection.close().then(move |_| Ok(member)))) } else { Box::new( - wrap_future(self.turn.lock().unwrap().create( + wrap_future(self.turn.create( member_id.clone(), self.room_id.clone(), UnreachablePolicy::ReturnErr, @@ -271,9 +271,7 @@ impl ParticipantService { ) -> Box> { match self.get_member_by_id(&member_id) { Some(member) => match member.take_ice_user() { - Some(ice_user) => { - self.turn.lock().unwrap().delete(vec![ice_user]) - } + Some(ice_user) => self.turn.delete(vec![ice_user]), None => Box::new(future::ok(())), }, None => Box::new(future::ok(())), @@ -309,8 +307,6 @@ impl ParticipantService { } }); self.turn - .lock() - .unwrap() .delete(room_users) .map_err(|err| error!("Error removing IceUsers {:?}", err)) }); diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 6e18cc598..b2566bcd5 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -1,7 +1,9 @@ //! Room definitions and implementations. Room is responsible for media //! connection establishment between concrete [`Member`]s. -use std::{collections::HashMap as StdHashMap, rc::Rc, time::Duration}; +use std::{ + collections::HashMap as StdHashMap, rc::Rc, sync::Arc, time::Duration, +}; use actix::{ fut::wrap_future, Actor, ActorFuture, AsyncContext, Context, Handler, @@ -35,7 +37,6 @@ use crate::{ }, turn::TurnAuthService, }; -use std::sync::{Arc, Mutex}; /// Ergonomic type alias for using [`ActorFuture`] for [`Room`]. pub type ActFuture = @@ -108,7 +109,7 @@ impl Room { pub fn new( room_spec: &RoomSpec, reconnect_timeout: Duration, - turn: Arc>>, + turn: Arc>, ) -> Result { Ok(Self { id: room_spec.id().clone(), diff --git a/src/turn/service.rs b/src/turn/service.rs index 7eebaba19..c5e01775d 100644 --- a/src/turn/service.rs +++ b/src/turn/service.rs @@ -150,11 +150,13 @@ struct Service { static_user: Option, } +type SyncTurnAuthService = Box; + /// Create new instance [`TurnAuthService`]. #[allow(clippy::module_name_repetitions)] -pub fn new_turn_auth_service<'a>( +pub fn new_turn_auth_service( cf: &conf::Turn, -) -> impl Future, Error = TurnServiceErr> { +) -> impl Future { let db_pass = cf.db.redis.pass.clone(); let turn_address = cf.addr(); let turn_username = cf.user.clone(); @@ -182,7 +184,7 @@ pub fn new_turn_auth_service<'a>( turn_password, static_user: None, }) - .map::<_, Box>(|service| Box::new(service.start())) + .map::<_, SyncTurnAuthService>(|service| Box::new(service.start())) .map_err(TurnServiceErr::from) } @@ -280,7 +282,7 @@ impl Handler for Service { #[cfg(test)] pub mod test { - use std::sync::{Arc, Mutex}; + use std::sync::Arc; use futures::future; @@ -314,9 +316,9 @@ pub mod test { } #[allow(clippy::module_name_repetitions)] - pub fn new_turn_auth_service_mock() -> Arc>> + pub fn new_turn_auth_service_mock() -> Arc> { - Arc::new(Mutex::new(Box::new(TurnAuthServiceMock {}))) + Arc::new(Box::new(TurnAuthServiceMock {})) } } From a029d9938dd08f0870979e202e693ad7437e7067 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 16 Jul 2019 12:44:54 +0300 Subject: [PATCH 368/735] Some refactor --- src/lib.rs | 2 +- src/signalling/participants.rs | 6 +++--- src/signalling/room.rs | 4 ++-- src/turn/mod.rs | 4 +++- src/turn/service.rs | 13 +++++++------ 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 3ac6682b1..5955c4459 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -71,7 +71,7 @@ pub fn start_static_rooms( if let Some(static_specs_path) = config.server.static_specs_path.clone() { Either::A( service::new_turn_auth_service(&config.turn) - .map(|t| Arc::new(t)) + .map(Arc::new) .map(move |turn_auth_service| { let room_specs = match load_static_specs_from_dir(static_specs_path) { diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 4e02358d1..3d51fc314 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -36,7 +36,7 @@ use crate::{ room::{ActFuture, RoomError}, Room, }, - turn::{TurnAuthService, TurnServiceErr, UnreachablePolicy}, + turn::{BoxedTurnAuthService, TurnServiceErr, UnreachablePolicy}, }; #[derive(Fail, Debug)] @@ -77,7 +77,7 @@ pub struct ParticipantService { members: HashMap>, /// Service for managing authorization on Turn server. - turn: Arc>, + turn: Arc, /// Established [`RpcConnection`]s of [`Members`]s in this [`Room`]. // TODO: Replace Box> with enum, @@ -99,7 +99,7 @@ impl ParticipantService { pub fn new( room_spec: &RoomSpec, reconnect_timeout: Duration, - turn: Arc>, + turn: Arc, ) -> Result { Ok(Self { room_id: room_spec.id().clone(), diff --git a/src/signalling/room.rs b/src/signalling/room.rs index b2566bcd5..6b4b201f2 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -35,7 +35,7 @@ use crate::{ participants::ParticipantService, peers::PeerRepository, }, - turn::TurnAuthService, + turn::BoxedTurnAuthService, }; /// Ergonomic type alias for using [`ActorFuture`] for [`Room`]. @@ -109,7 +109,7 @@ impl Room { pub fn new( room_spec: &RoomSpec, reconnect_timeout: Duration, - turn: Arc>, + turn: Arc, ) -> Result { Ok(Self { id: room_spec.id().clone(), diff --git a/src/turn/mod.rs b/src/turn/mod.rs index aa4b70c18..851b99fe0 100644 --- a/src/turn/mod.rs +++ b/src/turn/mod.rs @@ -1,8 +1,10 @@ pub mod repo; pub mod service; +#[doc(inline)] pub use self::service::{ - new_turn_auth_service, TurnAuthService, TurnServiceErr, UnreachablePolicy, + new_turn_auth_service, BoxedTurnAuthService, TurnAuthService, + TurnServiceErr, UnreachablePolicy, }; #[cfg(test)] diff --git a/src/turn/service.rs b/src/turn/service.rs index c5e01775d..0141ee2d8 100644 --- a/src/turn/service.rs +++ b/src/turn/service.rs @@ -18,6 +18,10 @@ use crate::{ turn::repo::{TurnDatabase, TurnDatabaseErr}, }; +/// Boxed [`TurnAuthService`] which can be [`Sync`] and [`Send`]. +#[allow(clippy::module_name_repetitions)] +pub type BoxedTurnAuthService = Box; + static TURN_PASS_LEN: usize = 16; #[allow(clippy::module_name_repetitions)] @@ -150,13 +154,11 @@ struct Service { static_user: Option, } -type SyncTurnAuthService = Box; - /// Create new instance [`TurnAuthService`]. #[allow(clippy::module_name_repetitions)] pub fn new_turn_auth_service( cf: &conf::Turn, -) -> impl Future { +) -> impl Future { let db_pass = cf.db.redis.pass.clone(); let turn_address = cf.addr(); let turn_username = cf.user.clone(); @@ -184,7 +186,7 @@ pub fn new_turn_auth_service( turn_password, static_user: None, }) - .map::<_, SyncTurnAuthService>(|service| Box::new(service.start())) + .map::<_, BoxedTurnAuthService>(|service| Box::new(service.start())) .map_err(TurnServiceErr::from) } @@ -316,8 +318,7 @@ pub mod test { } #[allow(clippy::module_name_repetitions)] - pub fn new_turn_auth_service_mock() -> Arc> - { + pub fn new_turn_auth_service_mock() -> Arc { Arc::new(Box::new(TurnAuthServiceMock {})) } From c78107804f1ae9d7841060ae38a4a1abf81a115e Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 16 Jul 2019 12:54:00 +0300 Subject: [PATCH 369/735] Remove useless comments and TODOs from e2e tests --- tests/e2e/signalling/mod.rs | 1 - tests/e2e/signalling/pub_sub_signallng.rs | 2 -- tests/e2e/signalling/three_pubs.rs | 1 - 3 files changed, 4 deletions(-) diff --git a/tests/e2e/signalling/mod.rs b/tests/e2e/signalling/mod.rs index 2e4355e24..b0d735de2 100644 --- a/tests/e2e/signalling/mod.rs +++ b/tests/e2e/signalling/mod.rs @@ -52,7 +52,6 @@ impl TestMember { /// Send command to the server. fn send_command(&mut self, msg: Command) { - // self.writer.text(&serde_json::to_string(&msg).unwrap()); let json = serde_json::to_string(&msg).unwrap(); self.writer.start_send(WsMessage::Text(json)).unwrap(); self.writer.poll_complete().unwrap(); diff --git a/tests/e2e/signalling/pub_sub_signallng.rs b/tests/e2e/signalling/pub_sub_signallng.rs index 0a76af3d0..842cc4f84 100644 --- a/tests/e2e/signalling/pub_sub_signallng.rs +++ b/tests/e2e/signalling/pub_sub_signallng.rs @@ -55,12 +55,10 @@ fn pub_sub_video_call() { assert_eq!(tracks.len(), 2); for track in tracks { match &track.direction { - // TODO Direction::Send { receivers, .. } => { assert!(is_caller); assert!(!receivers.contains(&peer_id)); } - // TODO Direction::Recv { sender, .. } => { assert!(!is_caller); assert_ne!(sender, peer_id); diff --git a/tests/e2e/signalling/three_pubs.rs b/tests/e2e/signalling/three_pubs.rs index a1287e601..e18ae60a7 100644 --- a/tests/e2e/signalling/three_pubs.rs +++ b/tests/e2e/signalling/three_pubs.rs @@ -58,7 +58,6 @@ fn three_members_p2p_video_call() { let recv_count = tracks .iter() .filter_map(|t| match &t.direction { - // TODO Direction::Recv { sender, .. } => { Some(sender) } From 7ec244be2b155c6382afb5235fc2de2b1070133b Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 16 Jul 2019 14:15:27 +0300 Subject: [PATCH 370/735] Fix jason's wasm-bingen --- Cargo.lock | 95 ++++++++++++++++++++++++------------------------ jason/Cargo.toml | 5 ++- 2 files changed, 51 insertions(+), 49 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9e54e2f6f..8902a13a0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -563,7 +563,7 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1030,26 +1030,26 @@ version = "0.1.0-dev" dependencies = [ "console_error_panic_hook 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", - "js-sys 0.3.25 (registry+https://github.com/rust-lang/crates.io-index)", + "js-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", "macro-attr 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "medea-client-api-proto 0.1.0-dev", "medea-macro 0.1.0-dev", "newtype_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-futures 0.3.25 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-test 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", - "web-sys 0.3.25 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-futures 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-test 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", + "web-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", "wee_alloc 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "js-sys" -version = "0.3.25" +version = "0.3.22" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "wasm-bindgen 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2502,17 +2502,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "wasm-bindgen" -version = "0.2.48" +version = "0.2.45" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-macro 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-macro 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.48" +version = "0.2.45" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bumpalo 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2521,62 +2521,62 @@ dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-shared 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-shared 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-futures" -version = "0.3.25" +version = "0.3.22" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", - "js-sys 0.3.25 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", + "js-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.48" +version = "0.2.45" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-macro-support 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-macro-support 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.48" +version = "0.2.45" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-backend 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-shared 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-backend 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-shared 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.48" +version = "0.2.45" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "wasm-bindgen-test" -version = "0.2.48" +version = "0.2.45" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "console_error_panic_hook 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", - "js-sys 0.3.25 (registry+https://github.com/rust-lang/crates.io-index)", + "js-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", "scoped-tls 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-futures 0.3.25 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-test-macro 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-futures 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-test-macro 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-test-macro" -version = "0.2.48" +version = "0.2.45" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2585,7 +2585,7 @@ dependencies = [ [[package]] name = "wasm-bindgen-webidl" -version = "0.2.48" +version = "0.2.45" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2594,20 +2594,21 @@ dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-backend 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", - "weedle 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-backend 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", + "weedle 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "web-sys" -version = "0.3.25" +version = "0.3.22" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ + "env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "js-sys 0.3.25 (registry+https://github.com/rust-lang/crates.io-index)", + "js-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", "sourcefile 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-webidl 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-webidl 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2624,7 +2625,7 @@ dependencies = [ [[package]] name = "weedle" -version = "0.10.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "nom 4.2.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2817,7 +2818,7 @@ dependencies = [ "checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08" "checksum ipconfig 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "aa79fa216fbe60834a9c0737d7fcd30425b32d1c58854663e24d4c4b328ed83f" "checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" -"checksum js-sys 0.3.25 (registry+https://github.com/rust-lang/crates.io-index)" = "da3ea71161651a4cd97d999b2da139109c537b15ab33abc8ae4ead38deac8a03" +"checksum js-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "9987e7c13a91d9cf0efe59cca48a3a7a70e2b11695d5a4640f85ae71e28f5e73" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a91d884b6667cd606bb5a69aa0c99ba811a115fc68915e7056ec08a46e93199a" "checksum lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "76f033c7ad61445c5b347c7382dd1237847eb1bce590fe50365dcb33d546be73" @@ -2975,18 +2976,18 @@ dependencies = [ "checksum utf8-ranges 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "9d50aa7650df78abf942826607c62468ce18d9019673d4a2ebe1865dbb96ffde" "checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" "checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" -"checksum wasm-bindgen 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)" = "4de97fa1806bb1a99904216f6ac5e0c050dc4f8c676dc98775047c38e5c01b55" -"checksum wasm-bindgen-backend 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)" = "5d82c170ef9f5b2c63ad4460dfcee93f3ec04a9a36a4cc20bc973c39e59ab8e3" -"checksum wasm-bindgen-futures 0.3.25 (registry+https://github.com/rust-lang/crates.io-index)" = "73c25810ee684c909488c214f55abcbc560beb62146d352b9588519e73c2fed9" -"checksum wasm-bindgen-macro 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)" = "f07d50f74bf7a738304f6b8157f4a581e1512cd9e9cdb5baad8c31bbe8ffd81d" -"checksum wasm-bindgen-macro-support 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)" = "95cf8fe77e45ba5f91bc8f3da0c3aa5d464b3d8ed85d84f4d4c7cc106436b1d7" -"checksum wasm-bindgen-shared 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)" = "d9c2d4d4756b2e46d3a5422e06277d02e4d3e1d62d138b76a4c681e925743623" -"checksum wasm-bindgen-test 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)" = "93241259c89570e107b139d0fb30b5e2c55c226afb813cd6fff04da705a39a3f" -"checksum wasm-bindgen-test-macro 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)" = "74e081d136ad38c1cd52e003fc9b9c784b82bbdbab2c917198c131bb4dae4858" -"checksum wasm-bindgen-webidl 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)" = "24e47859b4eba3d3b9a5c2c299f9d6f8d0b613671315f6f0c5c7f835e524b36a" -"checksum web-sys 0.3.25 (registry+https://github.com/rust-lang/crates.io-index)" = "86d515d2f713d3a6ab198031d2181b7540f8e319e4637ec2d4a41a208335ef29" +"checksum wasm-bindgen 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)" = "b7ccc7b93cfd13e26700a9e2e41e6305f1951b87e166599069f77d10358100e6" +"checksum wasm-bindgen-backend 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)" = "1953f91b1608eb1522513623c7739f047bb0fed4128ce51a93f08e12cc314645" +"checksum wasm-bindgen-futures 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "fa1af11c73eca3dc8c51c76ea475a4416e912da6402064a49fc6c0214701866d" +"checksum wasm-bindgen-macro 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)" = "0f69da5696545d7ca6607a2e4b1a0edf5a6b36b2c49dbb0f1df6ad1d92884047" +"checksum wasm-bindgen-macro-support 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)" = "2d4246f3bc73223bbb846f4f2430a60725826a96c9389adf715ed1d5af46dec6" +"checksum wasm-bindgen-shared 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)" = "c08381e07e7a79e5e229ad7c60d15833d19033542cc5dd91d085df59d235f4a6" +"checksum wasm-bindgen-test 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)" = "2a2a27d7a833564ec141078b3a71fb9ef00573e38e3f2fc1a5bb5221bb41c8bd" +"checksum wasm-bindgen-test-macro 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)" = "e5c0eac6c5b18d1b73614ddd080986bd01fa5c24fa9bd95c92dffe514f207355" +"checksum wasm-bindgen-webidl 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)" = "1f42ff7adb8102bf5ad8adbc45b1635c520c8175f9fdf6eb2c54479d485d435a" +"checksum web-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "540b8259eb242ff3a566fa0140bda03a4ece4e5c226e1284b5c95dddcd4341f6" "checksum wee_alloc 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "31d4e6572d21ac55398bc91db827f48c3fdb8152ae60f4c358f6780e1035ffcc" -"checksum weedle 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3bb43f70885151e629e2a19ce9e50bd730fd436cfd4b666894c9ce4de9141164" +"checksum weedle 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bcc44aa200daee8b1f3a004beaf16554369746f1b4486f0cf93b0caf8a3c2d1e" "checksum widestring 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "effc0e4ff8085673ea7b9b2e3c73f6bd4d118810c9009ed8f1e16bd96c331db6" "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" "checksum winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f10e386af2b13e47c89e7236a7a14a086791a2b88ebad6df9bf42040195cf770" diff --git a/jason/Cargo.toml b/jason/Cargo.toml index d5243c4bf..8a58d9b76 100644 --- a/jason/Cargo.toml +++ b/jason/Cargo.toml @@ -21,13 +21,14 @@ default = ["console_error_panic_hook", "wee_alloc"] console_error_panic_hook = { version = "0.1", optional = true } futures = "0.1" js-sys = "0.3" -macro-attr = "0.2" +macro-attr = "0.2.0" medea-client-api-proto = { path = "../proto/client-api", features = ["jason"] } medea-macro = { path = "../crates/medea-macro" } newtype_derive = "0.1" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" -wasm-bindgen = { version = "0.2", features = ["serde-serialize"] } +# TODO: remove "=" when bug with BitUint64 will be fixed. +wasm-bindgen = { version = "=0.2.45", features = ["serde-serialize"] } wasm-bindgen-futures = "0.3" wee_alloc = { version = "0.4", optional = true } [dependencies.web-sys] From 7aaa243a27eba2c10e4c560d75aaa710b7b8721e Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 16 Jul 2019 14:33:44 +0300 Subject: [PATCH 371/735] Dirty fix for startup gRPC server --- src/bin/client.rs | 22 ++++++++++++---------- src/main.rs | 15 ++++++++++++--- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/src/bin/client.rs b/src/bin/client.rs index a9545a084..4b6e9498e 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -17,13 +17,14 @@ fn main() { let ch = ChannelBuilder::new(env).connect("localhost:50051"); let client = ControlApiClient::new(ch); - create_room(&client); + // create_room(&client); + // delete_endpoint(&client); + // delete_member(&client); + // create_member(&client); + // create_endpoint(&client); + // get_room(&client); delete_room(&client); - delete_endpoint(&client); - delete_member(&client); - create_member(&client); - create_endpoint(&client); - get_room(&client); + // get_room(&client); } fn create_room(client: &ControlApiClient) { @@ -104,7 +105,7 @@ fn create_endpoint(client: &ControlApiClient) { fn delete_room(client: &ControlApiClient) { let mut delete_request = IdRequest::new(); let mut rooms = RepeatedField::new(); - rooms.push("local://pub-sub-video-call".to_string()); + rooms.push("local://pub-pub-video-call".to_string()); delete_request.set_id(rooms); let reply = client.delete(&delete_request).expect("delete room"); @@ -134,9 +135,10 @@ fn delete_member(client: &ControlApiClient) { fn get_room(client: &ControlApiClient) { let mut get_room_request = IdRequest::new(); let mut room = RepeatedField::new(); - room.push("local://grpc-test".to_string()); - room.push("local://video-call-1/responder".to_string()); - room.push("local://grpc-test/publisher/publish".to_string()); + // room.push("local://grpc-test".to_string()); + // room.push("local://video-call-1/responder".to_string()); + // room.push("local://grpc-test/publisher/publish".to_string()); + room.push("local://pub-pub-video-call".to_string()); get_room_request.set_id(room); let reply = client.get(&get_room_request).expect("get room"); diff --git a/src/main.rs b/src/main.rs index 1441ffae7..4a89df343 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,6 @@ use std::sync::Arc; +use actix::Actor as _; use failure::Error; use futures::future::Future; use medea::{ @@ -9,6 +10,7 @@ use medea::{ signalling::room_repo::RoomsRepository, start_static_rooms, App, }; +use std::{cell::Cell, rc::Rc}; fn main() -> Result<(), Error> { dotenv::dotenv().ok(); @@ -19,10 +21,13 @@ fn main() -> Result<(), Error> { let config = Conf::parse()?; info!("{:?}", config); - actix::run(|| { + let grpc_addr = Rc::new(Cell::new(None)); + let grpc_addr_clone = Rc::clone(&grpc_addr); + + actix::run(move || { start_static_rooms(&config) .map_err(|e| error!("Turn: {:?}", e)) - .and_then(|res| { + .and_then(move |res| { let (rooms, turn_service) = res.unwrap(); let app = Arc::new(App { config: config.clone(), @@ -33,7 +38,11 @@ fn main() -> Result<(), Error> { "Loaded rooms: {:?}", rooms.iter().map(|(id, _)| &id.0).collect::>() ); - let room_repo = RoomsRepository::new(rooms, app); + let room_repo = RoomsRepository::new(rooms, Arc::clone(&app)); + let room_repo_addr = room_repo.clone().start(); + grpc_addr_clone.set(Some( + medea::api::control::grpc::server::run(room_repo_addr, app), + )); server::run(room_repo, config) .map_err(|e| error!("Server {:?}", e)) }) From d6863f36dcb7841ecddd634fb380cad6664cfa4e Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 16 Jul 2019 14:49:44 +0300 Subject: [PATCH 372/735] Fix lints --- src/api/control/grpc/protos/mod.rs | 1 + src/api/control/grpc/server.rs | 3 +++ src/api/error_codes.rs | 4 ++-- src/media/peer.rs | 5 +++-- src/signalling/elements/member.rs | 14 +++++--------- src/signalling/room.rs | 2 -- src/signalling/room_repo.rs | 4 ++-- 7 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/api/control/grpc/protos/mod.rs b/src/api/control/grpc/protos/mod.rs index 3dae24491..238b3be6a 100644 --- a/src/api/control/grpc/protos/mod.rs +++ b/src/api/control/grpc/protos/mod.rs @@ -2,6 +2,7 @@ //! Don't edit `*.rs` files in this module because it automatically generated by //! `protoc` in `build.rs` file. +#![allow(bare_trait_objects)] #![allow(clippy::pedantic)] #![allow(clippy::cargo)] #![allow(clippy::nursery)] diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index 76bc4e622..76ce9b5a1 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -1,5 +1,8 @@ //! Implementation of gRPC control API. +// Fix clippy needless_return in macro. +#![allow(clippy::needless_return)] + use std::{collections::HashMap, convert::TryFrom, sync::Arc}; use actix::{Actor, Addr, Arbiter, Context, MailboxError}; diff --git a/src/api/error_codes.rs b/src/api/error_codes.rs index b31450dab..066081a93 100644 --- a/src/api/error_codes.rs +++ b/src/api/error_codes.rs @@ -14,7 +14,7 @@ use crate::api::control::{ }; /// Backtrace of nested errors for debugging purposes. -#[derive(Debug)] +#[derive(Debug, Default)] pub struct Backtrace(pub Vec); impl Backtrace { @@ -29,7 +29,7 @@ impl Backtrace { } /// Merge this [`Backtrace`] with another [`Backtrace`]. - pub fn merge(&mut self, mut another_backtrace: Backtrace) { + pub fn merge(&mut self, mut another_backtrace: Self) { self.0.append(&mut another_backtrace.0); } } diff --git a/src/media/peer.rs b/src/media/peer.rs index 0871cfe7d..c16eb14b0 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -69,8 +69,9 @@ impl Into for &PeerError { fn into(self) -> Backtrace { let mut backtrace = Backtrace::new(); match self { - PeerError::WrongState(..) => backtrace.push(self), - PeerError::MidsMismatch(..) => backtrace.push(self), + PeerError::WrongState(..) | PeerError::MidsMismatch(..) => { + backtrace.push(self) + } } backtrace } diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index 4f77aa52e..ea6336ee7 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -94,11 +94,9 @@ impl Into for &MembersLoadError { fn into(self) -> Backtrace { let mut backtrace = Backtrace::new(); backtrace.push(self); - match self { - MembersLoadError::TryFromError(e, _) => { - backtrace.merge(e.into()); - } - _ => {} + + if let MembersLoadError::TryFromError(e, _) = self { + backtrace.merge(e.into()); } backtrace } @@ -108,10 +106,8 @@ impl Into for &MemberError { fn into(self) -> Backtrace { let mut backtrace = Backtrace::new(); match self { - MemberError::PlayEndpointNotFound(_) => { - backtrace.push(self); - } - MemberError::PublishEndpointNotFound(_) => { + MemberError::PlayEndpointNotFound(_) + | MemberError::PublishEndpointNotFound(_) => { backtrace.push(self); } } diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 7f85962b9..27adce5ab 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -899,8 +899,6 @@ impl Handler for Room { let peer_ids = endpoint.peer_ids(); self.peers.remove_peers(&msg.member_id, peer_ids, ctx); } - } else { - return; } } } diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs index d65c18b75..fe30f8369 100644 --- a/src/signalling/room_repo.rs +++ b/src/signalling/room_repo.rs @@ -75,8 +75,8 @@ impl Into for &RoomRepoError { fn into(self) -> Backtrace { let mut backtrace = Backtrace::new(); match self { - RoomRepoError::RoomNotFound(_) => backtrace.push(self), - RoomRepoError::RoomAlreadyExists(_) => backtrace.push(self), + RoomRepoError::RoomNotFound(_) + | RoomRepoError::RoomAlreadyExists(_) => backtrace.push(self), RoomRepoError::RoomError(e) => { backtrace.push(self); backtrace.merge(e.into()); From 64ebcadd771f3fb51ad69620847c9494c4c03ece Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 16 Jul 2019 15:04:27 +0300 Subject: [PATCH 373/735] Get rid of backtrace --- .../control/endpoints/webrtc_play_endpoint.rs | 19 +-- src/api/control/grpc/server.rs | 20 +-- src/api/control/local_uri.rs | 17 +-- src/api/control/mod.rs | 12 +- src/api/error_codes.rs | 132 ++++++------------ src/media/peer.rs | 14 +- src/signalling/elements/member.rs | 47 ++----- src/signalling/participants.rs | 33 +---- src/signalling/room.rs | 34 +---- src/signalling/room_repo.rs | 31 +--- src/turn/repo.rs | 15 +- src/turn/service.rs | 23 +-- 12 files changed, 74 insertions(+), 323 deletions(-) diff --git a/src/api/control/endpoints/webrtc_play_endpoint.rs b/src/api/control/endpoints/webrtc_play_endpoint.rs index b5801a7cd..c37c5c6cc 100644 --- a/src/api/control/endpoints/webrtc_play_endpoint.rs +++ b/src/api/control/endpoints/webrtc_play_endpoint.rs @@ -17,7 +17,7 @@ use crate::api::{ local_uri::{LocalUri, LocalUriParseError}, MemberId, RoomId, TryFromProtobufError, }, - error_codes::{Backtrace, ErrorCode}, + error_codes::ErrorCode, }; macro_attr! { @@ -63,30 +63,15 @@ pub enum SrcParseError { impl Into for SrcParseError { fn into(self) -> ErrorCode { - let backtrace: Backtrace = (&self).into(); match self { SrcParseError::MissingField(text, fields) => { - ErrorCode::MissingFieldsInSrcUri(text, fields, backtrace) + ErrorCode::MissingFieldsInSrcUri(text, fields) } SrcParseError::LocalUriParseError(_, err) => err.into(), } } } -impl Into for &SrcParseError { - fn into(self) -> Backtrace { - let mut backtrace = Backtrace::new(); - backtrace.push(self); - match self { - SrcParseError::MissingField(..) => {} - SrcParseError::LocalUriParseError(_, e) => { - backtrace.merge(e.into()); - } - } - backtrace - } -} - /// Special uri with pattern `local://{room_id}/{member_id}/{endpoint_id}`. /// This uri can pointing only to [`WebRtcPublishEndpoint`]. #[derive(Clone, Debug)] diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index 76ce9b5a1..f0b4bd6a2 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -21,7 +21,7 @@ use crate::{ Endpoint, MemberSpec, RoomSpec, TryFromElementError, TryFromProtobufError, }, - error_codes::{Backtrace, ErrorCode}, + error_codes::ErrorCode, }, log::prelude::*, signalling::{ @@ -295,7 +295,6 @@ impl ControlApi for ControlApiService { sink, ErrorCode::ElementIdForRoomButElementIsNot( req.get_id().to_string(), - Backtrace::new() ), Response ); @@ -316,7 +315,6 @@ impl ControlApi for ControlApiService { sink, ErrorCode::ElementIdForMemberButElementIsNot( req.get_id().to_string(), - Backtrace::new() ), Response ); @@ -340,7 +338,6 @@ impl ControlApi for ControlApiService { sink, ErrorCode::ElementIdForEndpointButElementIsNot( req.get_id().to_string(), - Backtrace::new() ), Response ); @@ -349,10 +346,7 @@ impl ControlApi for ControlApiService { send_error_response!( ctx, sink, - ErrorCode::InvalidElementUri( - req.get_id().to_string(), - Backtrace::new() - ), + ErrorCode::InvalidElementUri(req.get_id().to_string(),), Response ); } @@ -405,10 +399,7 @@ impl ControlApi for ControlApiService { send_error_response!( ctx, sink, - ErrorCode::InvalidElementUri( - id.to_string(), - Backtrace::new() - ), + ErrorCode::InvalidElementUri(id.to_string(),), Response ); } @@ -496,10 +487,7 @@ impl ControlApi for ControlApiService { send_error_response!( ctx, sink, - ErrorCode::InvalidElementUri( - id.to_string(), - Backtrace::new() - ), + ErrorCode::InvalidElementUri(id.to_string(),), GetResponse ); } diff --git a/src/api/control/local_uri.rs b/src/api/control/local_uri.rs index e7785eaa4..8581abe15 100644 --- a/src/api/control/local_uri.rs +++ b/src/api/control/local_uri.rs @@ -4,7 +4,7 @@ use std::fmt; use failure::Fail; -use crate::api::error_codes::{Backtrace, ErrorCode}; +use crate::api::error_codes::ErrorCode; use super::{MemberId, RoomId}; @@ -26,27 +26,18 @@ pub enum LocalUriParseError { impl Into for LocalUriParseError { fn into(self) -> ErrorCode { - let backtrace: Backtrace = (&self).into(); match self { LocalUriParseError::NotLocal(text) => { - ErrorCode::ElementIdIsNotLocal(text, backtrace) + ErrorCode::ElementIdIsNotLocal(text) } LocalUriParseError::TooManyFields(_, text) => { - ErrorCode::ElementIdIsTooLong(text, backtrace) + ErrorCode::ElementIdIsTooLong(text) } - LocalUriParseError::Empty => ErrorCode::EmptyElementId(backtrace), + LocalUriParseError::Empty => ErrorCode::EmptyElementId, } } } -impl Into for &LocalUriParseError { - fn into(self) -> Backtrace { - let mut backtrace = Backtrace::new(); - backtrace.push(self); - backtrace - } -} - #[allow(clippy::doc_markdown)] /// Uri in format "local://room_id/member_id/endpoint_id" /// This kind of uri used for pointing to some element in spec (`Room`, diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index b80d593d4..00d32efd5 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -12,7 +12,7 @@ use std::{convert::TryFrom as _, fs::File, io::Read as _, path::Path}; use failure::{Error, Fail}; use serde::Deserialize; -use crate::api::error_codes::{Backtrace, ErrorCode}; +use crate::api::error_codes::ErrorCode; use self::{ endpoints::{ @@ -93,16 +93,6 @@ pub enum TryFromElementError { NotMember, } -impl Into for &TryFromElementError { - fn into(self) -> Backtrace { - let mut backtrace = Backtrace::new(); - match self { - _ => backtrace.push(self), - } - backtrace - } -} - /// Entity for parsing Control API request. #[derive(Clone, Deserialize, Debug)] #[serde(tag = "kind")] diff --git a/src/api/error_codes.rs b/src/api/error_codes.rs index 066081a93..b4153558e 100644 --- a/src/api/error_codes.rs +++ b/src/api/error_codes.rs @@ -7,42 +7,10 @@ //! * __1200...1299__ Parse errors //! * __1300...1399__ Conflicts -use protobuf::RepeatedField; - use crate::api::control::{ grpc::protos::control::Error as ErrorProto, local_uri::LocalUri, }; -/// Backtrace of nested errors for debugging purposes. -#[derive(Debug, Default)] -pub struct Backtrace(pub Vec); - -impl Backtrace { - /// Create new empty [`Backtrace`]. - pub fn new() -> Self { - Self(Vec::new()) - } - - /// Add error to [`Backtrace`]. - pub fn push(&mut self, error: &T) { - self.0.push(format!("{:?}", error)); - } - - /// Merge this [`Backtrace`] with another [`Backtrace`]. - pub fn merge(&mut self, mut another_backtrace: Self) { - self.0.append(&mut another_backtrace.0); - } -} - -impl Into> for Backtrace { - fn into(self) -> RepeatedField { - let mut repeated_field = RepeatedField::new(); - self.0.into_iter().for_each(|e| repeated_field.push(e)); - - repeated_field - } -} - /// Medea control API errors. // TODO: write macro for generating error codes. pub enum ErrorCode { @@ -57,23 +25,23 @@ pub enum ErrorCode { /// Publish endpoint not found. /// /// Code: __1001__. - PublishEndpointNotFound(LocalUri, Backtrace), + PublishEndpointNotFound(LocalUri), /// Play endpoint not found. /// /// Code: __1002__. - PlayEndpointNotFound(LocalUri, Backtrace), + PlayEndpointNotFound(LocalUri), /// Member not found. /// /// Code: __1003__. - MemberNotFound(LocalUri, Backtrace), + MemberNotFound(LocalUri), /// Room not found. /// /// Code: __1004__. - RoomNotFound(LocalUri, Backtrace), + RoomNotFound(LocalUri), /// Endpoint not found. /// /// Code: __1005__. - EndpointNotFound(LocalUri, Backtrace), + EndpointNotFound(LocalUri), ////////////////////////////////////// // Spec errors (1100 - 1199 codes) // @@ -81,37 +49,37 @@ pub enum ErrorCode { /// Medea expects `Room` element in pipeline but received not him. /// /// Code: __1100__. - NotRoomInSpec(LocalUri, Backtrace), + NotRoomInSpec(LocalUri), /// Medea expects `Member` element in pipeline but received not him. /// /// Code: __1101__. - NotMemberInSpec(LocalUri, Backtrace), + NotMemberInSpec(LocalUri), /// Medea expects `Endpoint` element in pipeline but received not him. /// /// Code: __1102__. - NotEndpointInSpec(LocalUri, Backtrace), + NotEndpointInSpec(LocalUri), /// Invalid source URI in play endpoint. /// /// Code: __1103__. - InvalidSrcUri(LocalUri, Backtrace), + InvalidSrcUri(LocalUri), /// Provided element ID to Room element but element spec is not for Room. /// /// Code: __1104__. - ElementIdForRoomButElementIsNot(String, Backtrace), + ElementIdForRoomButElementIsNot(String), /// Provided element ID to Member element but element spec is not for /// Member. /// /// Code: __1105__. - ElementIdForMemberButElementIsNot(String, Backtrace), + ElementIdForMemberButElementIsNot(String), /// Provided element ID to Endpoint element but element spec is not for /// Endpoint. /// /// Code: __1106__. - ElementIdForEndpointButElementIsNot(String, Backtrace), + ElementIdForEndpointButElementIsNot(String), /// Invalid ID for element. /// /// Code: __1107__ - InvalidElementUri(String, Backtrace), + InvalidElementUri(String), ///////////////////////////////// // Parse errors (1200 - 1299) // @@ -119,19 +87,19 @@ pub enum ErrorCode { /// Element's ID don't have "local://" prefix. /// /// Code: __1200__. - ElementIdIsNotLocal(String, Backtrace), + ElementIdIsNotLocal(String), /// Element's ID have too many paths (slashes). /// /// Code: __1201__. - ElementIdIsTooLong(String, Backtrace), + ElementIdIsTooLong(String), /// Source URI in publish endpoint missing some fields. /// /// Code: __1202__. - MissingFieldsInSrcUri(String, Vec, Backtrace), + MissingFieldsInSrcUri(String, Vec), /// Empty element ID. /// /// Code: __1203__. - EmptyElementId(Backtrace), + EmptyElementId, ///////////////////////////// // Conflict (1300 - 1399) // @@ -139,15 +107,15 @@ pub enum ErrorCode { /// Member already exists. /// /// Code: __1300__. - MemberAlreadyExists(LocalUri, Backtrace), + MemberAlreadyExists(LocalUri), /// Endpoint already exists. /// /// Code: __1301__. - EndpointAlreadyExists(LocalUri, Backtrace), + EndpointAlreadyExists(LocalUri), /// Room already exists. /// /// Code: __1302__. - RoomAlreadyExists(LocalUri, Backtrace), + RoomAlreadyExists(LocalUri), } impl Into for ErrorCode { @@ -167,73 +135,64 @@ impl Into for ErrorCode { //////////////////////////////////// // Not found (1001 - 1099 codes) // ////////////////////////////////// - ErrorCode::PublishEndpointNotFound(id, backtrace) => { + ErrorCode::PublishEndpointNotFound(id) => { error.set_text("Publish endpoint not found".to_string()); error.set_element(id.to_string()); error.set_code(1001); - error.set_backtrace(backtrace.into()) } - ErrorCode::PlayEndpointNotFound(id, backtrace) => { + ErrorCode::PlayEndpointNotFound(id) => { error.set_text("Play endpoint not found.".to_string()); error.set_element(id.to_string()); error.set_code(1002); - error.set_backtrace(backtrace.into()) } - ErrorCode::MemberNotFound(id, backtrace) => { + ErrorCode::MemberNotFound(id) => { error.set_text("Member not found.".to_string()); error.set_element(id.to_string()); error.set_code(1003); - error.set_backtrace(backtrace.into()) } - ErrorCode::RoomNotFound(id, backtrace) => { + ErrorCode::RoomNotFound(id) => { error.set_text("Room not found.".to_string()); error.set_element(id.to_string()); error.set_code(1004); - error.set_backtrace(backtrace.into()) } - ErrorCode::EndpointNotFound(id, backtrace) => { + ErrorCode::EndpointNotFound(id) => { error.set_text("Endpoint not found.".to_string()); error.set_element(id.to_string()); error.set_code(1005); - error.set_backtrace(backtrace.into()) } ////////////////////////////////////// // Spec errors (1100 - 1199 codes) // //////////////////////////////////// - ErrorCode::NotRoomInSpec(id, backtrace) => { + ErrorCode::NotRoomInSpec(id) => { error.set_text( "Expecting Room element but it's not.".to_string(), ); error.set_element(id.to_string()); error.set_code(1100); - error.set_backtrace(backtrace.into()); } - ErrorCode::NotMemberInSpec(id, backtrace) => { + ErrorCode::NotMemberInSpec(id) => { error.set_text( "Expecting Member element but it's not.".to_string(), ); error.set_element(id.to_string()); error.set_code(1101); - error.set_backtrace(backtrace.into()); } - ErrorCode::NotEndpointInSpec(id, backtrace) => { + ErrorCode::NotEndpointInSpec(id) => { error.set_text( "Expecting Member element but it's not.".to_string(), ); error.set_element(id.to_string()); error.set_code(1102); - error.set_backtrace(backtrace.into()); } - ErrorCode::InvalidSrcUri(id, backtrace) => { + ErrorCode::InvalidSrcUri(id) => { error.set_text( "Invalid source ID in publish endpoint spec.".to_string(), ); error.set_element(id.to_string()); error.set_code(1103); - error.set_backtrace(backtrace.into()); } - ErrorCode::ElementIdForRoomButElementIsNot(id, backtrace) => { + ErrorCode::ElementIdForRoomButElementIsNot(id) => { error.set_text( "You provided ID for Room but element's spec is not for \ Room." @@ -241,9 +200,8 @@ impl Into for ErrorCode { ); error.set_element(id); error.set_code(1104); - error.set_backtrace(backtrace.into()); } - ErrorCode::ElementIdForMemberButElementIsNot(id, backtrace) => { + ErrorCode::ElementIdForMemberButElementIsNot(id) => { error.set_text( "You provided ID for Member but element's spec is not for \ Member." @@ -251,9 +209,8 @@ impl Into for ErrorCode { ); error.set_element(id); error.set_code(1105); - error.set_backtrace(backtrace.into()); } - ErrorCode::ElementIdForEndpointButElementIsNot(id, backtrace) => { + ErrorCode::ElementIdForEndpointButElementIsNot(id) => { error.set_text( "You provided ID for Endpoint but element's spec is not \ for Endpoint." @@ -261,71 +218,62 @@ impl Into for ErrorCode { ); error.set_element(id); error.set_code(1106); - error.set_backtrace(backtrace.into()); } - ErrorCode::InvalidElementUri(id, backtrace) => { + ErrorCode::InvalidElementUri(id) => { error.set_text("Invalid element's URI".to_string()); error.set_element(id); error.set_code(1107); - error.set_backtrace(backtrace.into()); } ///////////////////////////////// // Parse errors (1200 - 1299) // /////////////////////////////// - ErrorCode::ElementIdIsNotLocal(uri, backtrace) => { + ErrorCode::ElementIdIsNotLocal(uri) => { error.set_text( "Element's ID's URI has not have 'local://' protocol." .to_string(), ); error.set_element(uri); error.set_code(1200); - error.set_backtrace(backtrace.into()); } - ErrorCode::ElementIdIsTooLong(uri, backtrace) => { + ErrorCode::ElementIdIsTooLong(uri) => { error.set_text( "In provided element's ID too many slashes.".to_string(), ); error.set_element(uri); error.set_code(1201); - error.set_backtrace(backtrace.into()); } - ErrorCode::MissingFieldsInSrcUri(uri, fields, backtrace) => { + ErrorCode::MissingFieldsInSrcUri(uri, fields) => { error.set_text(format!( "Missing {:?} fields in element ID.", fields )); error.set_element(uri); error.set_code(1202); - error.set_backtrace(backtrace.into()); } - ErrorCode::EmptyElementId(backtrace) => { + ErrorCode::EmptyElementId => { error.set_text("Provided empty element ID.".to_string()); error.set_element(String::new()); error.set_code(1203); - error.set_backtrace(backtrace.into()); } ///////////////////////////// // Conflict (1300 - 1399) // /////////////////////////// - ErrorCode::MemberAlreadyExists(id, backtrace) => { + ErrorCode::MemberAlreadyExists(id) => { error.set_text("Member already exists.".to_string()); error.set_element(id.to_string()); error.set_code(1300); - error.set_backtrace(backtrace.into()); } - ErrorCode::EndpointAlreadyExists(id, backtrace) => { + ErrorCode::EndpointAlreadyExists(id) => { error.set_text("Endpoint already exists.".to_string()); error.set_element(id.to_string()); error.set_code(1301); - error.set_backtrace(backtrace.into()); } - ErrorCode::RoomAlreadyExists(id, backtrace) => { + ErrorCode::RoomAlreadyExists(id) => { error.set_text("Room already exists.".to_string()); error.set_element(id.to_string()); error.set_code(1302); - error.set_backtrace(backtrace.into()); } } diff --git a/src/media/peer.rs b/src/media/peer.rs index c16eb14b0..acb453938 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -14,7 +14,7 @@ use medea_client_api_proto::{ use medea_macro::enum_delegate; use crate::{ - api::{control::MemberId, error_codes::Backtrace}, + api::control::MemberId, media::{MediaTrack, TrackId}, signalling::peers::Counter, }; @@ -65,18 +65,6 @@ impl PeerError { } } -impl Into for &PeerError { - fn into(self) -> Backtrace { - let mut backtrace = Backtrace::new(); - match self { - PeerError::WrongState(..) | PeerError::MidsMismatch(..) => { - backtrace.push(self) - } - } - backtrace - } -} - /// Implementation of ['Peer'] state machine. #[allow(clippy::module_name_repetitions)] #[enum_delegate(pub fn id(&self) -> Id)] diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index ea6336ee7..be02cace6 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -24,7 +24,7 @@ use crate::{ }; use super::endpoints::webrtc::{WebRtcPlayEndpoint, WebRtcPublishEndpoint}; -use crate::api::error_codes::{Backtrace, ErrorCode}; +use crate::api::error_codes::ErrorCode; /// Errors which may occur while loading [`Member`]s from [`RoomSpec`]. #[derive(Debug, Fail)] @@ -64,66 +64,37 @@ pub enum MemberError { impl Into for MembersLoadError { fn into(self) -> ErrorCode { - let backtrace: Backtrace = (&self).into(); match self { MembersLoadError::TryFromError(e, id) => match e { TryFromElementError::NotEndpoint => { - ErrorCode::NotEndpointInSpec(id, backtrace) + ErrorCode::NotEndpointInSpec(id) } TryFromElementError::NotMember => { - ErrorCode::NotMemberInSpec(id, backtrace) - } - TryFromElementError::NotRoom => { - ErrorCode::NotRoomInSpec(id, backtrace) + ErrorCode::NotMemberInSpec(id) } + TryFromElementError::NotRoom => ErrorCode::NotRoomInSpec(id), }, MembersLoadError::MemberNotFound(id) => { - ErrorCode::MemberNotFound(id, backtrace) + ErrorCode::MemberNotFound(id) } MembersLoadError::PublishEndpointNotFound(id) => { - ErrorCode::PublishEndpointNotFound(id, backtrace) + ErrorCode::PublishEndpointNotFound(id) } MembersLoadError::PlayEndpointNotFound(id) => { - ErrorCode::PlayEndpointNotFound(id, backtrace) - } - } - } -} -// TODO: fmt -impl Into for &MembersLoadError { - fn into(self) -> Backtrace { - let mut backtrace = Backtrace::new(); - backtrace.push(self); - - if let MembersLoadError::TryFromError(e, _) = self { - backtrace.merge(e.into()); - } - backtrace - } -} - -impl Into for &MemberError { - fn into(self) -> Backtrace { - let mut backtrace = Backtrace::new(); - match self { - MemberError::PlayEndpointNotFound(_) - | MemberError::PublishEndpointNotFound(_) => { - backtrace.push(self); + ErrorCode::PlayEndpointNotFound(id) } } - backtrace } } impl Into for MemberError { fn into(self) -> ErrorCode { - let backtrace: Backtrace = (&self).into(); match self { MemberError::PlayEndpointNotFound(id) => { - ErrorCode::PlayEndpointNotFound(id, backtrace) + ErrorCode::PlayEndpointNotFound(id) } MemberError::PublishEndpointNotFound(id) => { - ErrorCode::PublishEndpointNotFound(id, backtrace) + ErrorCode::PublishEndpointNotFound(id) } } } diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 61d847122..d72b71e72 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -36,7 +36,7 @@ use crate::{ MemberId, MemberSpec, RoomId, RoomSpec, WebRtcPlayId, WebRtcPublishId, }, - error_codes::{Backtrace, ErrorCode}, + error_codes::ErrorCode, }, log::prelude::*, media::IceUser, @@ -92,41 +92,20 @@ impl From for ParticipantServiceErr { } } -impl Into for &ParticipantServiceErr { - fn into(self) -> Backtrace { - let mut backtrace = Backtrace::new(); - backtrace.push(self); - match self { - ParticipantServiceErr::MemberError(e) => { - backtrace.merge(e.into()); - } - ParticipantServiceErr::TurnServiceErr(e) => { - backtrace.merge(e.into()); - } - ParticipantServiceErr::MailBoxErr(e) => { - backtrace.push(e); - } - _ => {} - } - backtrace - } -} - impl Into for ParticipantServiceErr { fn into(self) -> ErrorCode { - let backtrace: Backtrace = (&self).into(); - match &self { + match self { ParticipantServiceErr::EndpointNotFound(id) => { - ErrorCode::EndpointNotFound(id.clone(), backtrace) + ErrorCode::EndpointNotFound(id) } ParticipantServiceErr::ParticipantNotFound(id) => { - ErrorCode::MemberNotFound(id.clone(), backtrace) + ErrorCode::MemberNotFound(id) } ParticipantServiceErr::ParticipantAlreadyExists(id) => { - ErrorCode::MemberAlreadyExists(id.clone(), backtrace) + ErrorCode::MemberAlreadyExists(id) } ParticipantServiceErr::EndpointAlreadyExists(id) => { - ErrorCode::EndpointAlreadyExists(id.clone(), backtrace) + ErrorCode::EndpointAlreadyExists(id) } _ => ErrorCode::UnknownError(self.to_string()), } diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 27adce5ab..a99a545dc 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -30,7 +30,7 @@ use crate::{ Endpoint as EndpointSpec, MemberId, MemberSpec, RoomId, TryFromElementError, WebRtcPlayId, WebRtcPublishId, }, - error_codes::{Backtrace, ErrorCode}, + error_codes::ErrorCode, }, log::prelude::*, media::{ @@ -123,38 +123,6 @@ impl Into for RoomError { } } -impl Into for &RoomError { - fn into(self) -> Backtrace { - let mut backtrace = Backtrace::new(); - match self { - RoomError::MemberError(e) => { - backtrace.push(self); - backtrace.merge(e.into()); - } - RoomError::MembersLoadError(e) => { - backtrace.push(self); - backtrace.merge(e.into()); - } - RoomError::ParticipantServiceErr(e) => { - backtrace.push(self); - backtrace.merge(e.into()); - } - RoomError::PeerError(e) => { - backtrace.push(self); - backtrace.merge(e.into()); - } - RoomError::TryFromElementError(e) => { - backtrace.push(self); - backtrace.merge(e.into()) - } - _ => { - backtrace.push(self); - } - } - backtrace - } -} - /// Media server room with its [`Member`]s. #[derive(Debug)] pub struct Room { diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs index fe30f8369..89dacce7d 100644 --- a/src/signalling/room_repo.rs +++ b/src/signalling/room_repo.rs @@ -17,7 +17,7 @@ use crate::{ local_uri::LocalUri, room::RoomSpec, Endpoint as EndpointSpec, MemberId, MemberSpec, RoomId, }, - error_codes::{Backtrace, ErrorCode}, + error_codes::ErrorCode, }, log::prelude::*, signalling::{ @@ -57,13 +57,10 @@ impl From for RoomRepoError { impl Into for RoomRepoError { fn into(self) -> ErrorCode { - let backtrace = (&self).into(); match self { - RoomRepoError::RoomNotFound(ref id) => { - ErrorCode::RoomNotFound(id.clone(), backtrace) - } - RoomRepoError::RoomAlreadyExists(ref id) => { - ErrorCode::RoomAlreadyExists(id.clone(), backtrace) + RoomRepoError::RoomNotFound(id) => ErrorCode::RoomNotFound(id), + RoomRepoError::RoomAlreadyExists(id) => { + ErrorCode::RoomAlreadyExists(id) } RoomRepoError::RoomError(e) => e.into(), _ => ErrorCode::UnknownError(self.to_string()), @@ -71,26 +68,6 @@ impl Into for RoomRepoError { } } -impl Into for &RoomRepoError { - fn into(self) -> Backtrace { - let mut backtrace = Backtrace::new(); - match self { - RoomRepoError::RoomNotFound(_) - | RoomRepoError::RoomAlreadyExists(_) => backtrace.push(self), - RoomRepoError::RoomError(e) => { - backtrace.push(self); - backtrace.merge(e.into()); - } - RoomRepoError::MailboxError(e) => { - backtrace.push(self); - backtrace.push(e); - } - RoomRepoError::Unknow => {} - } - backtrace - } -} - impl From for RoomRepoError { fn from(e: MailboxError) -> Self { RoomRepoError::MailboxError(e) diff --git a/src/turn/repo.rs b/src/turn/repo.rs index f3031b446..4daa2eb05 100644 --- a/src/turn/repo.rs +++ b/src/turn/repo.rs @@ -10,7 +10,7 @@ use futures::future::Future; use redis::{ConnectionInfo, RedisError}; use tokio::prelude::*; -use crate::{api::error_codes::Backtrace, log::prelude::*, media::IceUser}; +use crate::{log::prelude::*, media::IceUser}; #[derive(Fail, Debug)] pub enum TurnDatabaseErr { @@ -24,19 +24,6 @@ impl From for TurnDatabaseErr { } } -impl Into for &TurnDatabaseErr { - fn into(self) -> Backtrace { - let mut backtrace = Backtrace::new(); - backtrace.push(self); - match self { - TurnDatabaseErr::RedisError(e) => { - backtrace.push(e); - } - } - backtrace - } -} - // Abstraction over remote Redis database used to store Turn server // credentials. #[allow(clippy::module_name_repetitions)] diff --git a/src/turn/service.rs b/src/turn/service.rs index faec059f3..0141ee2d8 100644 --- a/src/turn/service.rs +++ b/src/turn/service.rs @@ -12,10 +12,7 @@ use rand::{distributions::Alphanumeric, Rng}; use redis::ConnectionInfo; use crate::{ - api::{ - control::{MemberId, RoomId}, - error_codes::Backtrace, - }, + api::control::{MemberId, RoomId}, conf, media::IceUser, turn::repo::{TurnDatabase, TurnDatabaseErr}, @@ -129,24 +126,6 @@ impl From for TurnServiceErr { } } -impl Into for &TurnServiceErr { - fn into(self) -> Backtrace { - let mut backtrace = Backtrace::new(); - backtrace.push(&self); - match self { - TurnServiceErr::TurnAuthRepoErr(e) => { - backtrace.merge(e.into()); - } - TurnServiceErr::MailboxErr(e) => { - backtrace.push(e); - } - TurnServiceErr::TimedOut => {} - } - - backtrace - } -} - /// Defines [`TurnAuthService`] behaviour if remote database is unreachable #[derive(Debug)] pub enum UnreachablePolicy { From f947257b2e787706df046f0588522791b0c1d455 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 16 Jul 2019 15:11:47 +0300 Subject: [PATCH 374/735] Remove destination from WebRtc(Play/Publish)Endpoints, add TODOs to other destinations --- src/api/control/grpc/protos/control.proto | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/api/control/grpc/protos/control.proto b/src/api/control/grpc/protos/control.proto index 6a3de8a9d..84cb9d55c 100644 --- a/src/api/control/grpc/protos/control.proto +++ b/src/api/control/grpc/protos/control.proto @@ -57,7 +57,6 @@ message Error { string doc = 4; string element = 5; google.protobuf.Any details = 6; - repeated string backtrace = 7; } message Element { @@ -106,7 +105,6 @@ message Member { message WebRtcPublishEndpoint { P2P p2p = 1; - string dst = 2; string on_start = 3; string on_stop = 4; @@ -127,6 +125,8 @@ message Hub {} message FileRecorder { string src = 1; + // TODO: Delete if while implementing FileRecorder this field + // did not become useful. string dst = 2; string on_start = 3; string on_stop = 4; @@ -134,5 +134,7 @@ message FileRecorder { message Relay { string src = 1; + // TODO: Delete if while implementing Relay this field + // did not become useful. string dst = 2; } From 80f7513f793a09269dc27d9a38bb1d5a2221cd0f Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 16 Jul 2019 15:33:20 +0300 Subject: [PATCH 375/735] Add log messages --- src/bin/client.rs | 13 ++++----- src/signalling/participants.rs | 20 +++++++++++--- src/signalling/room.rs | 50 ++++++++++++++++++++++++---------- src/signalling/room_repo.rs | 3 ++ 4 files changed, 60 insertions(+), 26 deletions(-) diff --git a/src/bin/client.rs b/src/bin/client.rs index 4b6e9498e..c4820f4a8 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -17,14 +17,13 @@ fn main() { let ch = ChannelBuilder::new(env).connect("localhost:50051"); let client = ControlApiClient::new(ch); - // create_room(&client); - // delete_endpoint(&client); - // delete_member(&client); - // create_member(&client); - // create_endpoint(&client); - // get_room(&client); + create_room(&client); delete_room(&client); - // get_room(&client); + delete_endpoint(&client); + delete_member(&client); + create_member(&client); + create_endpoint(&client); + get_room(&client); } fn create_room(client: &ControlApiClient) { diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index d72b71e72..388392041 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -487,7 +487,7 @@ impl ParticipantService { pub fn create_sink_endpoint( &mut self, member_id: &MemberId, - endpoint_id: WebRtcPlayId, + endpoint_id: &WebRtcPlayId, spec: WebRtcPlayEndpointSpec, ) -> Result<(), ParticipantServiceErr> { let member = self.get_member(&member_id)?; @@ -505,7 +505,7 @@ impl ParticipantService { let src = partner_member.get_src(&spec.src.endpoint_id)?; let sink = Rc::new(WebRtcPlayEndpoint::new( - endpoint_id, + endpoint_id.clone(), spec.src, Rc::downgrade(&src), Rc::downgrade(&member), @@ -514,6 +514,12 @@ impl ParticipantService { src.add_sink(Rc::downgrade(&sink)); member.insert_sink(sink); + debug!( + "Create WebRtcPlayEndpoint [id = {}] for Member [id = {}] in Room \ + [id = {}].", + endpoint_id, member_id, self.room_id + ); + Ok(()) } @@ -527,7 +533,7 @@ impl ParticipantService { pub fn create_src_endpoint( &mut self, member_id: &MemberId, - endpoint_id: WebRtcPublishId, + endpoint_id: &WebRtcPublishId, spec: WebRtcPublishEndpointSpec, ) -> Result<(), ParticipantServiceErr> { let member = self.get_member(&member_id)?; @@ -543,13 +549,19 @@ impl ParticipantService { } let src = Rc::new(WebRtcPublishEndpoint::new( - endpoint_id, + endpoint_id.clone(), spec.p2p, Rc::downgrade(&member), )); member.insert_src(src); + debug!( + "Create WebRtcPublishEndpoint [id = {}] for Member [id = {}] in \ + Room [id = {}]", + endpoint_id, member_id, self.room_id + ); + Ok(()) } } diff --git a/src/signalling/room.rs b/src/signalling/room.rs index a99a545dc..6d000d107 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -835,6 +835,11 @@ impl Handler for Room { } self.members.delete_member(&msg.0, ctx); + + debug!( + "Member [id = {}] removed from Room [id = {}].", + msg.0, self.id + ); } } @@ -854,20 +859,34 @@ impl Handler for Room { msg: DeleteEndpoint, ctx: &mut Self::Context, ) -> Self::Result { - if let Some(member) = self.members.get_member_by_id(&msg.member_id) { - let play_id = WebRtcPlayId(msg.endpoint_id); - if let Some(endpoint) = member.take_sink(&play_id) { - if let Some(peer_id) = endpoint.peer_id() { - self.peers.remove_peer(&msg.member_id, peer_id, ctx); + let member_id = msg.member_id; + let endpoint_id = msg.endpoint_id; + + let endpoint_id = + if let Some(member) = self.members.get_member_by_id(&member_id) { + let play_id = WebRtcPlayId(endpoint_id); + if let Some(endpoint) = member.take_sink(&play_id) { + if let Some(peer_id) = endpoint.peer_id() { + self.peers.remove_peer(&member_id, peer_id, ctx); + } } - } - let publish_id = WebRtcPublishId(play_id.0); - if let Some(endpoint) = member.take_src(&publish_id) { - let peer_ids = endpoint.peer_ids(); - self.peers.remove_peers(&msg.member_id, peer_ids, ctx); - } - } + let publish_id = WebRtcPublishId(play_id.0); + if let Some(endpoint) = member.take_src(&publish_id) { + let peer_ids = endpoint.peer_ids(); + self.peers.remove_peers(&member_id, peer_ids, ctx); + } + + publish_id.0 + } else { + endpoint_id + }; + + debug!( + "Endpoint [id = {}] removed in Member [id = {}] from Room [id = \ + {}].", + endpoint_id, member_id, self.id + ); } } @@ -884,7 +903,8 @@ impl Handler for Room { msg: CreateMember, _ctx: &mut Self::Context, ) -> Self::Result { - self.members.create_member(msg.0, &msg.1)?; + self.members.create_member(msg.0.clone(), &msg.1)?; + debug!("Create Member [id = {}] in Room [id = {}].", msg.0, self.id); Ok(()) } } @@ -910,14 +930,14 @@ impl Handler for Room { EndpointSpec::WebRtcPlay(e) => { self.members.create_sink_endpoint( &msg.member_id, - WebRtcPlayId(msg.endpoint_id), + &WebRtcPlayId(msg.endpoint_id), e, )?; } EndpointSpec::WebRtcPublish(e) => { self.members.create_src_endpoint( &msg.member_id, - WebRtcPublishId(msg.endpoint_id), + &WebRtcPublishId(msg.endpoint_id), e, )?; } diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs index 89dacce7d..d8b07d9db 100644 --- a/src/signalling/room_repo.rs +++ b/src/signalling/room_repo.rs @@ -147,7 +147,9 @@ impl Handler for RoomsRepository { Room::new(&room, self.app.config.rpc.reconnect_timeout, turn)?; let room_addr = room.start(); + debug!("New Room [id = {}] started.", room_id); self.rooms.lock().unwrap().insert(room_id, room_addr); + Ok(()) } } @@ -172,6 +174,7 @@ impl Handler for RoomsRepository { room.send(Close) .map(move |_| { rooms.lock().unwrap().remove(&msg.0); + debug!("Room [id = {}] removed.", msg.0); }) .map_err(|e| warn!("Close room mailbox error {:?}.", e)), )); From dfa6d911db195c26d9bc929b42bf2e966b0e4940 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 16 Jul 2019 16:36:39 +0300 Subject: [PATCH 376/735] Move control logic from room_repo into room_service --- src/api/client/server.rs | 3 +- src/api/control/grpc/server.rs | 13 +- src/main.rs | 12 +- src/signalling/mod.rs | 1 + src/signalling/room_repo.rs | 412 +------------------------------- src/signalling/room_service.rs | 425 +++++++++++++++++++++++++++++++++ 6 files changed, 443 insertions(+), 423 deletions(-) create mode 100644 src/signalling/room_service.rs diff --git a/src/api/client/server.rs b/src/api/client/server.rs index e176dbd52..65c157781 100644 --- a/src/api/client/server.rs +++ b/src/api/client/server.rs @@ -138,7 +138,6 @@ mod test { config: conf, turn_service: new_turn_auth_service_mock(), }); - let app_cloned = Arc::clone(&app); let room_id = room_spec.id.clone(); let client_room = Room::start_in_arbiter(&Arbiter::new(), move |_| { @@ -154,7 +153,7 @@ mod test { room_id => client_room, }; - RoomsRepository::new(room_hash_map, app_cloned) + RoomsRepository::new(room_hash_map) } /// Creates test WebSocket server of Client API which can handle requests. diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index f0b4bd6a2..d11d74c45 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -26,10 +26,10 @@ use crate::{ log::prelude::*, signalling::{ room::RoomError, - room_repo::{ + room_service::{ CreateEndpointInRoom, CreateMemberInRoom, DeleteEndpointFromMember, DeleteMemberFromRoom, DeleteRoom, GetEndpoint, GetMember, GetRoom, - RoomRepoError, RoomsRepository, StartRoom, + RoomService, RoomServiceError, StartRoom, }, }, App, @@ -147,11 +147,11 @@ macro_rules! send_error_response { /// Type alias for result of Create request. type CreateResult = - Result, RoomError>, RoomRepoError>; + Result, RoomError>, RoomServiceError>; #[derive(Clone)] struct ControlApiService { - room_repository: Addr, + room_repository: Addr, app: Arc, } @@ -583,10 +583,7 @@ impl Actor for GrpcServer { } /// Run gRPC server in actix actor. -pub fn run( - room_repo: Addr, - app: Arc, -) -> Addr { +pub fn run(room_repo: Addr, app: Arc) -> Addr { let bind_ip = app.config.grpc.bind_ip.to_string(); let bind_port = app.config.grpc.bind_port; let cq_count = app.config.grpc.completion_queue_count; diff --git a/src/main.rs b/src/main.rs index 4a89df343..3f72699b0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,7 +7,7 @@ use medea::{ api::client::server, conf::Conf, log::{self, prelude::*}, - signalling::room_repo::RoomsRepository, + signalling::{room_repo::RoomsRepository, room_service::RoomService}, start_static_rooms, App, }; use std::{cell::Cell, rc::Rc}; @@ -38,11 +38,15 @@ fn main() -> Result<(), Error> { "Loaded rooms: {:?}", rooms.iter().map(|(id, _)| &id.0).collect::>() ); - let room_repo = RoomsRepository::new(rooms, Arc::clone(&app)); - let room_repo_addr = room_repo.clone().start(); + let room_repo = RoomsRepository::new(rooms); + + let room_service = + RoomService::new(room_repo.clone(), Arc::clone(&app)) + .start(); grpc_addr_clone.set(Some( - medea::api::control::grpc::server::run(room_repo_addr, app), + medea::api::control::grpc::server::run(room_service, app), )); + server::run(room_repo, config) .map_err(|e| error!("Server {:?}", e)) }) diff --git a/src/signalling/mod.rs b/src/signalling/mod.rs index e5d46b817..b7df7d94e 100644 --- a/src/signalling/mod.rs +++ b/src/signalling/mod.rs @@ -3,5 +3,6 @@ pub mod participants; pub mod peers; pub mod room; pub mod room_repo; +pub mod room_service; pub use self::room::Room; diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs index d8b07d9db..358d4b14b 100644 --- a/src/signalling/room_repo.rs +++ b/src/signalling/room_repo.rs @@ -2,77 +2,10 @@ use std::sync::{Arc, Mutex}; -use actix::{ - fut::wrap_future, Actor, ActorFuture, Addr, AsyncContext, Context, Handler, - MailboxError, Message, -}; -use failure::Fail; -use futures::future::{Either, Future}; +use actix::Addr; use hashbrown::HashMap; -use crate::{ - api::{ - control::{ - grpc::protos::control::Element as ElementProto, - local_uri::LocalUri, room::RoomSpec, Endpoint as EndpointSpec, - MemberId, MemberSpec, RoomId, - }, - error_codes::ErrorCode, - }, - log::prelude::*, - signalling::{ - room::{ - Close, CreateEndpoint, CreateMember, DeleteEndpoint, DeleteMember, - RoomError, SerializeProtobufEndpoint, SerializeProtobufMember, - SerializeProtobufRoom, - }, - Room, - }, - App, -}; - -type ActFuture = - Box>; - -#[allow(clippy::module_name_repetitions)] -#[derive(Debug, Fail)] -pub enum RoomRepoError { - #[fail(display = "Room [id = {}] not found.", _0)] - RoomNotFound(LocalUri), - #[fail(display = "Mailbox error: {:?}", _0)] - MailboxError(MailboxError), - #[fail(display = "Room [id = {}] already exists.", _0)] - RoomAlreadyExists(LocalUri), - #[fail(display = "{}", _0)] - RoomError(RoomError), - #[fail(display = "Unknow error.")] - Unknow, -} - -impl From for RoomRepoError { - fn from(err: RoomError) -> Self { - RoomRepoError::RoomError(err) - } -} - -impl Into for RoomRepoError { - fn into(self) -> ErrorCode { - match self { - RoomRepoError::RoomNotFound(id) => ErrorCode::RoomNotFound(id), - RoomRepoError::RoomAlreadyExists(id) => { - ErrorCode::RoomAlreadyExists(id) - } - RoomRepoError::RoomError(e) => e.into(), - _ => ErrorCode::UnknownError(self.to_string()), - } - } -} - -impl From for RoomRepoError { - fn from(e: MailboxError) -> Self { - RoomRepoError::MailboxError(e) - } -} +use crate::{api::control::RoomId, signalling::Room}; /// Repository that stores [`Room`]s addresses. #[derive(Clone, Debug)] @@ -80,15 +13,13 @@ pub struct RoomsRepository { // TODO: Use crossbeam's concurrent hashmap when its done. // [Tracking](https://github.com/crossbeam-rs/rfcs/issues/32). rooms: Arc>>>, - app: Arc, } impl RoomsRepository { /// Creates new [`Room`]s repository with passed-in [`Room`]s. - pub fn new(rooms: HashMap>, app: Arc) -> Self { + pub fn new(rooms: HashMap>) -> Self { Self { rooms: Arc::new(Mutex::new(rooms)), - app, } } @@ -106,340 +37,3 @@ impl RoomsRepository { self.rooms.lock().unwrap().insert(id, room); } } - -impl Actor for RoomsRepository { - type Context = Context; -} - -/// Returns [`LocalUri`] pointing to [`Room`]. -/// -/// __Note__ this function don't check presence of [`Room`] in this -/// [`RoomsRepository`]. -fn get_local_uri_to_room(room_id: RoomId) -> LocalUri { - LocalUri::new(Some(room_id), None, None) -} - -#[derive(Message)] -#[rtype(result = "Result<(), RoomRepoError>")] -pub struct StartRoom(pub RoomId, pub RoomSpec); - -impl Handler for RoomsRepository { - type Result = Result<(), RoomRepoError>; - - fn handle( - &mut self, - msg: StartRoom, - _ctx: &mut Self::Context, - ) -> Self::Result { - let room_id = msg.0; - - if self.rooms.lock().unwrap().get(&room_id).is_some() { - return Err(RoomRepoError::RoomAlreadyExists( - get_local_uri_to_room(room_id), - )); - } - - let room = msg.1; - - let turn = Arc::clone(&self.app.turn_service); - - let room = - Room::new(&room, self.app.config.rpc.reconnect_timeout, turn)?; - let room_addr = room.start(); - - debug!("New Room [id = {}] started.", room_id); - self.rooms.lock().unwrap().insert(room_id, room_addr); - - Ok(()) - } -} - -/// Signal for delete [`Room`]. -#[derive(Message)] -#[rtype(result = "Result<(), RoomRepoError>")] -pub struct DeleteRoom(pub RoomId); - -impl Handler for RoomsRepository { - type Result = Result<(), RoomRepoError>; - - fn handle( - &mut self, - msg: DeleteRoom, - ctx: &mut Self::Context, - ) -> Self::Result { - let room_repo = self.rooms.lock().unwrap(); - if let Some(room) = room_repo.get(&msg.0) { - let rooms = Arc::clone(&self.rooms); - ctx.spawn(wrap_future( - room.send(Close) - .map(move |_| { - rooms.lock().unwrap().remove(&msg.0); - debug!("Room [id = {}] removed.", msg.0); - }) - .map_err(|e| warn!("Close room mailbox error {:?}.", e)), - )); - } - - Ok(()) - } -} - -/// Signal for delete [`Member`] from [`Room`]. -#[derive(Message)] -#[rtype(result = "Result<(), RoomRepoError>")] -pub struct DeleteMemberFromRoom { - pub member_id: MemberId, - pub room_id: RoomId, -} - -impl Handler for RoomsRepository { - type Result = Result<(), RoomRepoError>; - - fn handle( - &mut self, - msg: DeleteMemberFromRoom, - _ctx: &mut Self::Context, - ) -> Self::Result { - if let Some(room) = self.get(&msg.room_id) { - room.do_send(DeleteMember(msg.member_id)); - } else { - return Err(RoomRepoError::RoomNotFound(get_local_uri_to_room( - msg.room_id, - ))); - } - - Ok(()) - } -} - -/// Signal for delete [`Endpoint`] from [`Member`]. -#[derive(Message)] -#[rtype(result = "Result<(), RoomRepoError>")] -pub struct DeleteEndpointFromMember { - pub room_id: RoomId, - pub member_id: MemberId, - pub endpoint_id: String, -} - -impl Handler for RoomsRepository { - type Result = Result<(), RoomRepoError>; - - fn handle( - &mut self, - msg: DeleteEndpointFromMember, - _ctx: &mut Self::Context, - ) -> Self::Result { - if let Some(room) = self.get(&msg.room_id) { - room.do_send(DeleteEndpoint { - endpoint_id: msg.endpoint_id, - member_id: msg.member_id, - }); - } - - Ok(()) - } -} - -/// Type alias for result of Get request. -type GetResults = Vec>; - -/// Signal for get serialized to protobuf object [`Room`]. -#[derive(Message)] -#[rtype(result = "Result")] -pub struct GetRoom(pub Vec); - -impl Handler for RoomsRepository { - type Result = ActFuture; - - fn handle( - &mut self, - msg: GetRoom, - _ctx: &mut Self::Context, - ) -> Self::Result { - let mut futs = Vec::new(); - - for room_id in msg.0 { - if let Some(room) = self.rooms.lock().unwrap().get(&room_id) { - futs.push( - room.send(SerializeProtobufRoom) - .map_err(RoomRepoError::from) - .map(move |result| { - result.map(|r| { - let local_uri = LocalUri { - room_id: Some(room_id), - member_id: None, - endpoint_id: None, - }; - (local_uri.to_string(), r) - }) - }), - ) - } else { - return Box::new(wrap_future(futures::future::err( - RoomRepoError::RoomNotFound(get_local_uri_to_room(room_id)), - ))); - } - } - - Box::new(wrap_future(futures::future::join_all(futs))) - } -} - -/// Signal for get serialized to protobuf object [`Member`]. -#[derive(Message)] -#[rtype(result = "Result")] -pub struct GetMember(pub Vec<(RoomId, MemberId)>); - -impl Handler for RoomsRepository { - type Result = ActFuture; - - fn handle( - &mut self, - msg: GetMember, - _ctx: &mut Self::Context, - ) -> Self::Result { - let mut futs = Vec::new(); - - for (room_id, member_id) in msg.0 { - if let Some(room) = self.rooms.lock().unwrap().get(&room_id) { - futs.push( - room.send(SerializeProtobufMember(member_id.clone())) - .map_err(RoomRepoError::from) - .map(|result| { - result.map(|r| { - let local_uri = LocalUri { - room_id: Some(room_id), - member_id: Some(member_id), - endpoint_id: None, - }; - - (local_uri.to_string(), r) - }) - }), - ) - } else { - return Box::new(wrap_future(futures::future::err( - RoomRepoError::RoomNotFound(get_local_uri_to_room(room_id)), - ))); - } - } - - Box::new(wrap_future(futures::future::join_all(futs))) - } -} - -/// Signal for get serialized to protobuf object `Endpoint`. -#[derive(Message)] -#[rtype(result = "Result")] -pub struct GetEndpoint(pub Vec<(RoomId, MemberId, String)>); - -impl Handler for RoomsRepository { - type Result = ActFuture; - - fn handle( - &mut self, - msg: GetEndpoint, - _ctx: &mut Self::Context, - ) -> Self::Result { - let mut futs = Vec::new(); - - for (room_id, member_id, endpoint_id) in msg.0 { - if let Some(room) = self.rooms.lock().unwrap().get(&room_id) { - futs.push( - room.send(SerializeProtobufEndpoint( - member_id.clone(), - endpoint_id.clone(), - )) - .map_err(RoomRepoError::from) - .map(|result| { - result.map(|r| { - let local_uri = LocalUri { - room_id: Some(room_id), - member_id: Some(member_id), - endpoint_id: Some(endpoint_id), - }; - (local_uri.to_string(), r) - }) - }), - ); - } else { - return Box::new(wrap_future(futures::future::err( - RoomRepoError::RoomNotFound(get_local_uri_to_room(room_id)), - ))); - } - } - - Box::new(wrap_future(futures::future::join_all(futs))) - } -} - -/// Signal for create new [`Member`] in [`Room`] -#[derive(Message)] -#[rtype(result = "Result, RoomRepoError>")] -pub struct CreateMemberInRoom { - pub room_id: RoomId, - pub member_id: MemberId, - pub spec: MemberSpec, -} - -impl Handler for RoomsRepository { - type Result = ActFuture, RoomRepoError>; - - fn handle( - &mut self, - msg: CreateMemberInRoom, - _ctx: &mut Self::Context, - ) -> Self::Result { - let fut = - if let Some(room) = self.rooms.lock().unwrap().get(&msg.room_id) { - Either::A( - room.send(CreateMember(msg.member_id, msg.spec)) - .map_err(RoomRepoError::from), - ) - } else { - Either::B(futures::future::err(RoomRepoError::RoomNotFound( - get_local_uri_to_room(msg.room_id), - ))) - }; - - Box::new(wrap_future(fut)) - } -} - -/// Signal for create new [`Endpoint`] in [`Room`] -#[derive(Message)] -#[rtype(result = "Result, RoomRepoError>")] -pub struct CreateEndpointInRoom { - pub room_id: RoomId, - pub member_id: MemberId, - pub endpoint_id: String, - pub spec: EndpointSpec, -} - -impl Handler for RoomsRepository { - type Result = ActFuture, RoomRepoError>; - - fn handle( - &mut self, - msg: CreateEndpointInRoom, - _ctx: &mut Self::Context, - ) -> Self::Result { - let fut = - if let Some(room) = self.rooms.lock().unwrap().get(&msg.room_id) { - Either::A( - room.send(CreateEndpoint { - member_id: msg.member_id, - endpoint_id: msg.endpoint_id, - spec: msg.spec, - }) - .map_err(RoomRepoError::from), - ) - } else { - Either::B(futures::future::err(RoomRepoError::RoomNotFound( - get_local_uri_to_room(msg.room_id), - ))) - }; - - Box::new(wrap_future(fut)) - } -} diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs new file mode 100644 index 000000000..e5af3aa01 --- /dev/null +++ b/src/signalling/room_service.rs @@ -0,0 +1,425 @@ +use std::sync::Arc; + +use actix::{ + fut::wrap_future, Actor, ActorFuture, AsyncContext as _, Context, Handler, + MailboxError, Message, +}; +use failure::Fail; +use futures::future::{Either, Future}; + +use crate::{ + api::{ + control::{ + endpoints::Endpoint as EndpointSpec, + grpc::protos::control::Element as ElementProto, + local_uri::LocalUri, MemberId, MemberSpec, RoomId, RoomSpec, + }, + error_codes::ErrorCode, + }, + log::prelude::*, + signalling::{ + room::{ + Close, CreateEndpoint, CreateMember, DeleteEndpoint, DeleteMember, + RoomError, SerializeProtobufEndpoint, SerializeProtobufMember, + SerializeProtobufRoom, + }, + room_repo::RoomsRepository, + Room, + }, + App, +}; + +type ActFuture = + Box>; + +#[allow(clippy::module_name_repetitions)] +#[derive(Debug, Fail)] +pub enum RoomServiceError { + #[fail(display = "Room [id = {}] not found.", _0)] + RoomNotFound(LocalUri), + #[fail(display = "Mailbox error: {:?}", _0)] + MailboxError(MailboxError), + #[fail(display = "Room [id = {}] already exists.", _0)] + RoomAlreadyExists(LocalUri), + #[fail(display = "{}", _0)] + RoomError(RoomError), + #[fail(display = "Unknow error.")] + Unknow, +} + +impl From for RoomServiceError { + fn from(err: RoomError) -> Self { + RoomServiceError::RoomError(err) + } +} + +impl Into for RoomServiceError { + fn into(self) -> ErrorCode { + match self { + RoomServiceError::RoomNotFound(id) => ErrorCode::RoomNotFound(id), + RoomServiceError::RoomAlreadyExists(id) => { + ErrorCode::RoomAlreadyExists(id) + } + RoomServiceError::RoomError(e) => e.into(), + _ => ErrorCode::UnknownError(self.to_string()), + } + } +} + +impl From for RoomServiceError { + fn from(e: MailboxError) -> Self { + RoomServiceError::MailboxError(e) + } +} + +/// Service for controlling [`Room`]s. +pub struct RoomService { + room_repo: RoomsRepository, + app: Arc, +} + +impl RoomService { + pub fn new(room_repo: RoomsRepository, app: Arc) -> Self { + Self { room_repo, app } + } +} + +impl Actor for RoomService { + type Context = Context; +} + +/// Returns [`LocalUri`] pointing to [`Room`]. +/// +/// __Note__ this function don't check presence of [`Room`] in this +/// [`RoomService`]. +fn get_local_uri_to_room(room_id: RoomId) -> LocalUri { + LocalUri::new(Some(room_id), None, None) +} + +#[derive(Message)] +#[rtype(result = "Result<(), RoomServiceError>")] +pub struct StartRoom(pub RoomId, pub RoomSpec); + +impl Handler for RoomService { + type Result = Result<(), RoomServiceError>; + + fn handle( + &mut self, + msg: StartRoom, + _ctx: &mut Self::Context, + ) -> Self::Result { + let room_id = msg.0; + + if self.room_repo.get(&room_id).is_some() { + return Err(RoomServiceError::RoomAlreadyExists( + get_local_uri_to_room(room_id), + )); + } + + let room = msg.1; + + let turn = Arc::clone(&self.app.turn_service); + + let room = + Room::new(&room, self.app.config.rpc.reconnect_timeout, turn)?; + let room_addr = room.start(); + + debug!("New Room [id = {}] started.", room_id); + self.room_repo.add(room_id, room_addr); + + Ok(()) + } +} + +/// Signal for delete [`Room`]. +#[derive(Message)] +#[rtype(result = "Result<(), RoomServiceError>")] +pub struct DeleteRoom(pub RoomId); + +impl Handler for RoomService { + type Result = Result<(), RoomServiceError>; + + fn handle( + &mut self, + msg: DeleteRoom, + ctx: &mut Self::Context, + ) -> Self::Result { + if let Some(room) = self.room_repo.get(&msg.0) { + let rooms = self.room_repo.clone(); + ctx.spawn(wrap_future( + room.send(Close) + .map(move |_| { + rooms.remove(&msg.0); + debug!("Room [id = {}] removed.", msg.0); + }) + .map_err(|e| warn!("Close room mailbox error {:?}.", e)), + )); + } + + Ok(()) + } +} + +/// Signal for delete [`Member`] from [`Room`]. +#[derive(Message)] +#[rtype(result = "Result<(), RoomServiceError>")] +pub struct DeleteMemberFromRoom { + pub member_id: MemberId, + pub room_id: RoomId, +} + +impl Handler for RoomService { + type Result = Result<(), RoomServiceError>; + + fn handle( + &mut self, + msg: DeleteMemberFromRoom, + _ctx: &mut Self::Context, + ) -> Self::Result { + if let Some(room) = self.room_repo.get(&msg.room_id) { + room.do_send(DeleteMember(msg.member_id)); + } else { + return Err(RoomServiceError::RoomNotFound(get_local_uri_to_room( + msg.room_id, + ))); + } + + Ok(()) + } +} + +/// Signal for delete [`Endpoint`] from [`Member`]. +#[derive(Message)] +#[rtype(result = "Result<(), RoomServiceError>")] +pub struct DeleteEndpointFromMember { + pub room_id: RoomId, + pub member_id: MemberId, + pub endpoint_id: String, +} + +impl Handler for RoomService { + type Result = Result<(), RoomServiceError>; + + fn handle( + &mut self, + msg: DeleteEndpointFromMember, + _ctx: &mut Self::Context, + ) -> Self::Result { + if let Some(room) = self.room_repo.get(&msg.room_id) { + room.do_send(DeleteEndpoint { + endpoint_id: msg.endpoint_id, + member_id: msg.member_id, + }); + } + + Ok(()) + } +} + +/// Type alias for result of Get request. +type GetResults = Vec>; + +/// Signal for get serialized to protobuf object [`Room`]. +#[derive(Message)] +#[rtype(result = "Result")] +pub struct GetRoom(pub Vec); + +impl Handler for RoomService { + type Result = ActFuture; + + fn handle( + &mut self, + msg: GetRoom, + _ctx: &mut Self::Context, + ) -> Self::Result { + let mut futs = Vec::new(); + + for room_id in msg.0 { + if let Some(room) = self.room_repo.get(&room_id) { + futs.push( + room.send(SerializeProtobufRoom) + .map_err(RoomServiceError::from) + .map(move |result| { + result.map(|r| { + let local_uri = LocalUri { + room_id: Some(room_id), + member_id: None, + endpoint_id: None, + }; + (local_uri.to_string(), r) + }) + }), + ) + } else { + return Box::new(wrap_future(futures::future::err( + RoomServiceError::RoomNotFound(get_local_uri_to_room( + room_id, + )), + ))); + } + } + + Box::new(wrap_future(futures::future::join_all(futs))) + } +} + +/// Signal for get serialized to protobuf object [`Member`]. +#[derive(Message)] +#[rtype(result = "Result")] +pub struct GetMember(pub Vec<(RoomId, MemberId)>); + +impl Handler for RoomService { + type Result = ActFuture; + + fn handle( + &mut self, + msg: GetMember, + _ctx: &mut Self::Context, + ) -> Self::Result { + let mut futs = Vec::new(); + + for (room_id, member_id) in msg.0 { + if let Some(room) = self.room_repo.get(&room_id) { + futs.push( + room.send(SerializeProtobufMember(member_id.clone())) + .map_err(RoomServiceError::from) + .map(|result| { + result.map(|r| { + let local_uri = LocalUri { + room_id: Some(room_id), + member_id: Some(member_id), + endpoint_id: None, + }; + + (local_uri.to_string(), r) + }) + }), + ) + } else { + return Box::new(wrap_future(futures::future::err( + RoomServiceError::RoomNotFound(get_local_uri_to_room( + room_id, + )), + ))); + } + } + + Box::new(wrap_future(futures::future::join_all(futs))) + } +} + +/// Signal for get serialized to protobuf object `Endpoint`. +#[derive(Message)] +#[rtype(result = "Result")] +pub struct GetEndpoint(pub Vec<(RoomId, MemberId, String)>); + +impl Handler for RoomService { + type Result = ActFuture; + + fn handle( + &mut self, + msg: GetEndpoint, + _ctx: &mut Self::Context, + ) -> Self::Result { + let mut futs = Vec::new(); + + for (room_id, member_id, endpoint_id) in msg.0 { + if let Some(room) = self.room_repo.get(&room_id) { + futs.push( + room.send(SerializeProtobufEndpoint( + member_id.clone(), + endpoint_id.clone(), + )) + .map_err(RoomServiceError::from) + .map(|result| { + result.map(|r| { + let local_uri = LocalUri { + room_id: Some(room_id), + member_id: Some(member_id), + endpoint_id: Some(endpoint_id), + }; + (local_uri.to_string(), r) + }) + }), + ); + } else { + return Box::new(wrap_future(futures::future::err( + RoomServiceError::RoomNotFound(get_local_uri_to_room( + room_id, + )), + ))); + } + } + + Box::new(wrap_future(futures::future::join_all(futs))) + } +} + +/// Signal for create new [`Member`] in [`Room`] +#[derive(Message)] +#[rtype(result = "Result, RoomServiceError>")] +pub struct CreateMemberInRoom { + pub room_id: RoomId, + pub member_id: MemberId, + pub spec: MemberSpec, +} + +impl Handler for RoomService { + type Result = ActFuture, RoomServiceError>; + + fn handle( + &mut self, + msg: CreateMemberInRoom, + _ctx: &mut Self::Context, + ) -> Self::Result { + let fut = if let Some(room) = self.room_repo.get(&msg.room_id) { + Either::A( + room.send(CreateMember(msg.member_id, msg.spec)) + .map_err(RoomServiceError::from), + ) + } else { + Either::B(futures::future::err(RoomServiceError::RoomNotFound( + get_local_uri_to_room(msg.room_id), + ))) + }; + + Box::new(wrap_future(fut)) + } +} + +/// Signal for create new [`Endpoint`] in [`Room`] +#[derive(Message)] +#[rtype(result = "Result, RoomServiceError>")] +pub struct CreateEndpointInRoom { + pub room_id: RoomId, + pub member_id: MemberId, + pub endpoint_id: String, + pub spec: EndpointSpec, +} + +impl Handler for RoomService { + type Result = ActFuture, RoomServiceError>; + + fn handle( + &mut self, + msg: CreateEndpointInRoom, + _ctx: &mut Self::Context, + ) -> Self::Result { + let fut = if let Some(room) = self.room_repo.get(&msg.room_id) { + Either::A( + room.send(CreateEndpoint { + member_id: msg.member_id, + endpoint_id: msg.endpoint_id, + spec: msg.spec, + }) + .map_err(RoomServiceError::from), + ) + } else { + Either::B(futures::future::err(RoomServiceError::RoomNotFound( + get_local_uri_to_room(msg.room_id), + ))) + }; + + Box::new(wrap_future(fut)) + } +} From 5d4356d0a0939c539ca2c3feb6233c9c1bfe3aca Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 16 Jul 2019 17:29:53 +0300 Subject: [PATCH 377/735] Refactor loading static rooms --- src/lib.rs | 98 +--------------------------------- src/main.rs | 58 ++++++++++++-------- src/signalling/room_repo.rs | 4 ++ src/signalling/room_service.rs | 56 ++++++++++++++++++- 4 files changed, 97 insertions(+), 119 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 3bf7ac96e..c8f490ae1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -11,16 +11,7 @@ pub mod turn; use std::sync::Arc; -use actix::prelude::*; -use failure::Fail; -use hashbrown::HashMap; - -use crate::{ - api::control::{load_static_specs_from_dir, RoomId}, - conf::Conf, - signalling::{room::RoomError, Room}, - turn::{service, BoxedTurnAuthService, TurnServiceErr}, -}; +use crate::{conf::Conf, turn::BoxedTurnAuthService}; /// Global app context. #[derive(Debug)] @@ -28,90 +19,3 @@ pub struct App { pub config: Conf, pub turn_service: Arc, } - -/// Errors which can happen while server starting. -#[derive(Debug, Fail)] -pub enum ServerStartError { - /// Duplicate [`RoomId`] founded. - #[fail(display = "Duplicate of room ID '{:?}'", _0)] - DuplicateRoomId(RoomId), - - /// Some error happened while loading spec. - #[fail(display = "Failed to load specs. {}", _0)] - LoadSpec(failure::Error), - - /// Some error happened while creating new room from spec. - #[fail(display = "Bad room spec. {}", _0)] - BadRoomSpec(String), - - /// Unexpected error returned from room. - #[fail(display = "Unknown room error.")] - UnknownRoomError, -} - -impl From for ServerStartError { - fn from(err: RoomError) -> Self { - match err { - RoomError::BadRoomSpec(m) => ServerStartError::BadRoomSpec(m), - _ => ServerStartError::UnknownRoomError, - } - } -} - -// TODO: refactor this -/// Parses static [`Room`]s from config and starts them in separate arbiters. -/// -/// Returns [`ServerStartError::DuplicateRoomId`] if find duplicated room ID. -/// -/// Returns [`ServerStartError::LoadSpec`] if some error happened -/// while loading spec. -/// -/// Returns [`ServerStartError::BadRoomSpec`] -/// if some error happened while creating room from spec. -pub fn start_static_rooms( - conf: &Conf, -) -> impl Future< - Item = Result< - (HashMap>, Arc), - ServerStartError, - >, - Error = TurnServiceErr, -> { - let config = conf.clone(); - service::new_turn_auth_service(&conf.turn) - .map(Arc::new) - .map(move |turn_auth_service| { - if let Some(static_specs_path) = - config.server.static_specs_path.clone() - { - let room_specs = - match load_static_specs_from_dir(static_specs_path) { - Ok(r) => r, - Err(e) => return Err(ServerStartError::LoadSpec(e)), - }; - let mut rooms = HashMap::new(); - let arbiter = Arbiter::new(); - - for spec in room_specs { - if rooms.contains_key(spec.id()) { - return Err(ServerStartError::DuplicateRoomId( - spec.id().clone(), - )); - } - - let room_id = spec.id().clone(); - let rpc_reconnect_timeout = config.rpc.reconnect_timeout; - let turn_cloned = Arc::clone(&turn_auth_service); - let room = Room::start_in_arbiter(&arbiter, move |_| { - Room::new(&spec, rpc_reconnect_timeout, turn_cloned) - .unwrap() - }); - rooms.insert(room_id, room); - } - - Ok((rooms, turn_auth_service)) - } else { - Ok((HashMap::new(), turn_auth_service)) - } - }) -} diff --git a/src/main.rs b/src/main.rs index 3f72699b0..3ea0ca4fc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,16 +1,20 @@ -use std::sync::Arc; +use std::{cell::Cell, rc::Rc, sync::Arc}; -use actix::Actor as _; +use actix::Actor; use failure::Error; use futures::future::Future; +use hashbrown::HashMap; use medea::{ - api::client::server, + api::{client, control::grpc}, conf::Conf, log::{self, prelude::*}, - signalling::{room_repo::RoomsRepository, room_service::RoomService}, - start_static_rooms, App, + signalling::{ + room_repo::RoomsRepository, + room_service::{RoomService, StartStaticRooms}, + }, + turn::new_turn_auth_service, + App, }; -use std::{cell::Cell, rc::Rc}; fn main() -> Result<(), Error> { dotenv::dotenv().ok(); @@ -21,34 +25,46 @@ fn main() -> Result<(), Error> { let config = Conf::parse()?; info!("{:?}", config); + // This is crutch for existence of gRPC server throughout the all app's + // lifetime. let grpc_addr = Rc::new(Cell::new(None)); let grpc_addr_clone = Rc::clone(&grpc_addr); actix::run(move || { - start_static_rooms(&config) - .map_err(|e| error!("Turn: {:?}", e)) - .and_then(move |res| { - let (rooms, turn_service) = res.unwrap(); + new_turn_auth_service(&config.turn) + .map_err(|e| error!("{:?}", e)) + .map(Arc::new) + .and_then(move |turn_service| { let app = Arc::new(App { config: config.clone(), turn_service, }); - info!( - "Loaded rooms: {:?}", - rooms.iter().map(|(id, _)| &id.0).collect::>() - ); - let room_repo = RoomsRepository::new(rooms); - + let room_repo = RoomsRepository::new(HashMap::new()); let room_service = RoomService::new(room_repo.clone(), Arc::clone(&app)) .start(); - grpc_addr_clone.set(Some( - medea::api::control::grpc::server::run(room_service, app), - )); - server::run(room_repo, config) - .map_err(|e| error!("Server {:?}", e)) + room_service + .clone() + .send(StartStaticRooms) + .map_err(|e| { + error!("StartStaticRooms mailbox error: {:?}", e) + }) + .map(|result| { + if let Err(e) = result { + panic!("{}", e); + } + }) + .map(move |_| { + let grpc_addr = grpc::server::run(room_service, app); + grpc_addr_clone.set(Some(grpc_addr)); + }) + .and_then(move |_| { + client::server::run(room_repo, config).map_err(|e| { + error!("Client server startup error. {:?}", e) + }) + }) }) }) .unwrap(); diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs index 358d4b14b..2f671bce2 100644 --- a/src/signalling/room_repo.rs +++ b/src/signalling/room_repo.rs @@ -36,4 +36,8 @@ impl RoomsRepository { pub fn add(&self, id: RoomId, room: Addr) { self.rooms.lock().unwrap().insert(id, room); } + + pub fn is_contains_room_with_id(&self, id: &RoomId) -> bool { + self.rooms.lock().unwrap().contains_key(id) + } } diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index e5af3aa01..a4968ba0a 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -12,7 +12,8 @@ use crate::{ control::{ endpoints::Endpoint as EndpointSpec, grpc::protos::control::Element as ElementProto, - local_uri::LocalUri, MemberId, MemberSpec, RoomId, RoomSpec, + load_static_specs_from_dir, local_uri::LocalUri, MemberId, + MemberSpec, RoomId, RoomSpec, }, error_codes::ErrorCode, }, @@ -43,6 +44,8 @@ pub enum RoomServiceError { RoomAlreadyExists(LocalUri), #[fail(display = "{}", _0)] RoomError(RoomError), + #[fail(display = "Failed to load static specs. {:?}", _0)] + FailedToLoadStaticSpecs(failure::Error), #[fail(display = "Unknow error.")] Unknow, } @@ -96,6 +99,57 @@ fn get_local_uri_to_room(room_id: RoomId) -> LocalUri { LocalUri::new(Some(room_id), None, None) } +#[derive(Message)] +#[rtype(result = "Result<(), RoomServiceError>")] +pub struct StartStaticRooms; + +impl Handler for RoomService { + type Result = Result<(), RoomServiceError>; + + fn handle( + &mut self, + _: StartStaticRooms, + _: &mut Self::Context, + ) -> Self::Result { + if let Some(static_specs_path) = + self.app.config.server.static_specs_path.clone() + { + let room_specs = match load_static_specs_from_dir(static_specs_path) + { + Ok(r) => r, + Err(e) => { + return Err(RoomServiceError::FailedToLoadStaticSpecs(e)) + } + }; + + for spec in room_specs { + if self.room_repo.is_contains_room_with_id(spec.id()) { + return Err(RoomServiceError::RoomAlreadyExists( + get_local_uri_to_room(spec.id), + )); + } + + let room_id = spec.id().clone(); + + let rpc_reconnect_timeout = + self.app.config.rpc.reconnect_timeout; + let turn_cloned = Arc::clone(&self.app.turn_service); + + // TODO: app context + let room = + Room::new(&spec, rpc_reconnect_timeout, turn_cloned)? + .start(); + + self.room_repo.add(room_id, room); + } + + Ok(()) + } else { + Ok(()) + } + } +} + #[derive(Message)] #[rtype(result = "Result<(), RoomServiceError>")] pub struct StartRoom(pub RoomId, pub RoomSpec); From 9d11bd35edbf9a01e765bc97b522dd68749b645d Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 16 Jul 2019 17:52:08 +0300 Subject: [PATCH 378/735] Use app context in room --- src/api/client/server.rs | 16 +++------ src/api/control/grpc/server.rs | 28 +++++++-------- src/lib.rs | 15 ++++++-- src/main.rs | 15 ++++---- src/signalling/participants.rs | 63 ++++++++++++++++------------------ src/signalling/room.rs | 15 +++----- src/signalling/room_service.rs | 31 ++++++----------- src/turn/service.rs | 6 ++-- 8 files changed, 82 insertions(+), 107 deletions(-) diff --git a/src/api/client/server.rs b/src/api/client/server.rs index 65c157781..eeaabcd51 100644 --- a/src/api/client/server.rs +++ b/src/api/client/server.rs @@ -113,7 +113,7 @@ pub fn run(rooms: RoomsRepository, config: Conf) -> io::Result<()> { #[cfg(test)] mod test { - use std::{ops::Add, sync::Arc, thread, time::Duration}; + use std::{ops::Add, thread, time::Duration}; use actix::{Actor as _, Arbiter}; use actix_http::{ws::Message, HttpService}; @@ -123,7 +123,7 @@ mod test { use crate::{ api::control, conf::Conf, signalling::Room, - turn::new_turn_auth_service_mock, + turn::new_turn_auth_service_mock, AppContext, }; use super::*; @@ -134,19 +134,11 @@ mod test { control::load_from_yaml_file("tests/specs/pub_sub_video_call.yml") .unwrap(); - let app = Arc::new(crate::App { - config: conf, - turn_service: new_turn_auth_service_mock(), - }); + let app = AppContext::new(conf, new_turn_auth_service_mock()); let room_id = room_spec.id.clone(); let client_room = Room::start_in_arbiter(&Arbiter::new(), move |_| { - let client_room = Room::new( - &room_spec, - app.config.rpc.reconnect_timeout, - new_turn_auth_service_mock(), - ) - .unwrap(); + let client_room = Room::new(&room_spec, app.clone()).unwrap(); client_room }); let room_hash_map = hashmap! { diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index d11d74c45..52669738e 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -32,7 +32,7 @@ use crate::{ RoomService, RoomServiceError, StartRoom, }, }, - App, + AppContext, }; use super::protos::control_grpc::{create_control_api, ControlApi}; @@ -151,8 +151,8 @@ type CreateResult = #[derive(Clone)] struct ControlApiService { - room_repository: Addr, - app: Arc, + room_service: Addr, + app: AppContext, } impl ControlApiService { @@ -187,7 +187,7 @@ impl ControlApiService { .collect(); Either::A( - self.room_repository + self.room_service .send(StartRoom(room_id, room)) .map_err(ControlApiError::from) .map(move |r| r.map(|_| Ok(sid))), @@ -217,7 +217,7 @@ impl ControlApiService { sids.insert(member_id.to_string(), sid); Either::A( - self.room_repository + self.room_service .send(CreateMemberInRoom { room_id, member_id, @@ -237,7 +237,7 @@ impl ControlApiService { ) -> impl Future { let endpoint = fut_try!(Endpoint::try_from(req)); Either::A( - self.room_repository + self.room_service .send(CreateEndpointInRoom { room_id: local_uri.room_id.unwrap(), member_id: local_uri.member_id.unwrap(), @@ -378,17 +378,17 @@ impl ControlApi for ControlApiService { if uri.is_room_uri() { delete_room_futs.push( - self.room_repository.send(DeleteRoom(uri.room_id.unwrap())), + self.room_service.send(DeleteRoom(uri.room_id.unwrap())), ); } else if uri.is_member_uri() { - delete_member_futs.push(self.room_repository.send( + delete_member_futs.push(self.room_service.send( DeleteMemberFromRoom { room_id: uri.room_id.unwrap(), member_id: uri.member_id.unwrap(), }, )); } else if uri.is_endpoint_uri() { - delete_endpoints_futs.push(self.room_repository.send( + delete_endpoints_futs.push(self.room_service.send( DeleteEndpointFromMember { room_id: uri.room_id.unwrap(), member_id: uri.member_id.unwrap(), @@ -493,9 +493,9 @@ impl ControlApi for ControlApiService { } } - let room_fut = self.room_repository.send(GetRoom(room_ids)); - let member_fut = self.room_repository.send(GetMember(member_ids)); - let endpoint_fut = self.room_repository.send(GetEndpoint(endpoint_ids)); + let room_fut = self.room_service.send(GetRoom(room_ids)); + let member_fut = self.room_service.send(GetMember(member_ids)); + let endpoint_fut = self.room_service.send(GetEndpoint(endpoint_ids)); ctx.spawn(room_fut.join3(member_fut, endpoint_fut).then(|result| { let grpc_err_closure = @@ -583,14 +583,14 @@ impl Actor for GrpcServer { } /// Run gRPC server in actix actor. -pub fn run(room_repo: Addr, app: Arc) -> Addr { +pub fn run(room_repo: Addr, app: AppContext) -> Addr { let bind_ip = app.config.grpc.bind_ip.to_string(); let bind_port = app.config.grpc.bind_port; let cq_count = app.config.grpc.completion_queue_count; let service = create_control_api(ControlApiService { app, - room_repository: room_repo, + room_service: room_repo, }); let env = Arc::new(Environment::new(cq_count)); diff --git a/src/lib.rs b/src/lib.rs index c8f490ae1..b53037eeb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -14,8 +14,17 @@ use std::sync::Arc; use crate::{conf::Conf, turn::BoxedTurnAuthService}; /// Global app context. -#[derive(Debug)] -pub struct App { - pub config: Conf, +#[derive(Debug, Clone)] +pub struct AppContext { + pub config: Arc, pub turn_service: Arc, } + +impl AppContext { + pub fn new(config: Conf, turn: BoxedTurnAuthService) -> Self { + Self { + config: Arc::new(config), + turn_service: Arc::new(turn), + } + } +} diff --git a/src/main.rs b/src/main.rs index 3ea0ca4fc..181aa8d30 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,4 @@ -use std::{cell::Cell, rc::Rc, sync::Arc}; +use std::{cell::Cell, rc::Rc}; use actix::Actor; use failure::Error; @@ -13,7 +13,7 @@ use medea::{ room_service::{RoomService, StartStaticRooms}, }, turn::new_turn_auth_service, - App, + AppContext, }; fn main() -> Result<(), Error> { @@ -33,16 +33,12 @@ fn main() -> Result<(), Error> { actix::run(move || { new_turn_auth_service(&config.turn) .map_err(|e| error!("{:?}", e)) - .map(Arc::new) .and_then(move |turn_service| { - let app = Arc::new(App { - config: config.clone(), - turn_service, - }); + let app_context = AppContext::new(config.clone(), turn_service); let room_repo = RoomsRepository::new(HashMap::new()); let room_service = - RoomService::new(room_repo.clone(), Arc::clone(&app)) + RoomService::new(room_repo.clone(), app_context.clone()) .start(); room_service @@ -57,7 +53,8 @@ fn main() -> Result<(), Error> { } }) .map(move |_| { - let grpc_addr = grpc::server::run(room_service, app); + let grpc_addr = + grpc::server::run(room_service, app_context); grpc_addr_clone.set(Some(grpc_addr)); }) .and_then(move |_| { diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 388392041..d51b18a87 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -3,11 +3,7 @@ //! [`RpcConnection`] authorization, establishment, message sending, Turn //! credentials management. -use std::{ - rc::Rc, - sync::Arc, - time::{Duration, Instant}, -}; +use std::{rc::Rc, time::Instant}; use actix::{ fut::wrap_future, ActorFuture, AsyncContext, Context, MailboxError, @@ -49,7 +45,8 @@ use crate::{ room::{ActFuture, RoomError}, Room, }, - turn::{BoxedTurnAuthService, TurnServiceErr, UnreachablePolicy}, + turn::{TurnServiceErr, UnreachablePolicy}, + AppContext, }; #[derive(Fail, Debug)] @@ -123,18 +120,14 @@ pub struct ParticipantService { /// [`Member`]s which currently are present in this [`Room`]. members: HashMap>, - /// Service for managing authorization on Turn server. - turn: Arc, + /// Global app context. + app: AppContext, /// Established [`RpcConnection`]s of [`Members`]s in this [`Room`]. // TODO: Replace Box> with enum, // as the set of all possible RpcConnection types is not closed. connections: HashMap>, - /// Timeout for close [`RpcConnection`] after receiving - /// [`RpcConnectionClosed`] message. - reconnect_timeout: Duration, - /// Stores [`RpcConnection`] drop tasks. /// If [`RpcConnection`] is lost, [`Room`] waits for connection_timeout /// before dropping it irrevocably in case it gets reestablished. @@ -145,15 +138,13 @@ impl ParticipantService { /// Create new [`ParticipantService`] from [`RoomSpec`]. pub fn new( room_spec: &RoomSpec, - reconnect_timeout: Duration, - turn: Arc, + context: AppContext, ) -> Result { Ok(Self { room_id: room_spec.id().clone(), members: parse_members(room_spec)?, - turn, + app: context, connections: HashMap::new(), - reconnect_timeout, drop_connection_tasks: HashMap::new(), }) } @@ -270,7 +261,7 @@ impl ParticipantService { Box::new(wrap_future(connection.close().then(move |_| Ok(member)))) } else { Box::new( - wrap_future(self.turn.create( + wrap_future(self.app.turn_service.create( member_id.clone(), self.room_id.clone(), UnreachablePolicy::ReturnErr, @@ -326,17 +317,20 @@ impl ParticipantService { ClosedReason::Lost => { self.drop_connection_tasks.insert( member_id.clone(), - ctx.run_later(self.reconnect_timeout, move |_, ctx| { - info!( - "Member {} connection lost at {:?}. Room will be \ - stopped.", - &member_id, closed_at - ); - ctx.notify(RpcConnectionClosed { - member_id, - reason: ClosedReason::Closed, - }) - }), + ctx.run_later( + self.app.config.rpc.reconnect_timeout, + move |_, ctx| { + info!( + "Member {} connection lost at {:?}. Room will \ + be stopped.", + &member_id, closed_at + ); + ctx.notify(RpcConnectionClosed { + member_id, + reason: ClosedReason::Closed, + }) + }, + ), ); } } @@ -349,7 +343,7 @@ impl ParticipantService { ) -> Box> { match self.get_member_by_id(&member_id) { Some(member) => match member.take_ice_user() { - Some(ice_user) => self.turn.delete(vec![ice_user]), + Some(ice_user) => self.app.turn_service.delete(vec![ice_user]), None => Box::new(future::ok(())), }, None => Box::new(future::ok(())), @@ -384,7 +378,8 @@ impl ParticipantService { room_users.push(ice_user); } }); - self.turn + self.app + .turn_service .delete(room_users) .map_err(|err| error!("Error removing IceUsers {:?}", err)) }); @@ -411,10 +406,10 @@ impl ParticipantService { if let Some(member) = self.members.remove(member_id) { if let Some(ice_user) = member.take_ice_user() { - let delete_ice_user_fut = self - .turn - .delete(vec![ice_user]) - .map_err(|err| error!("Error removing IceUser {:?}", err)); + let delete_ice_user_fut = + self.app.turn_service.delete(vec![ice_user]).map_err( + |err| error!("Error removing IceUser {:?}", err), + ); ctx.spawn(wrap_future(delete_ice_user_fut)); } } diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 6d000d107..e305d05f2 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -1,9 +1,7 @@ //! Room definitions and implementations. Room is responsible for media //! connection establishment between concrete [`Member`]s. -use std::{ - collections::HashMap as StdHashMap, rc::Rc, sync::Arc, time::Duration, -}; +use std::{collections::HashMap as StdHashMap, rc::Rc}; use actix::{ fut::wrap_future, Actor, ActorFuture, AsyncContext, Context, Handler, @@ -46,7 +44,7 @@ use crate::{ participants::{ParticipantService, ParticipantServiceErr}, peers::PeerRepository, }, - turn::BoxedTurnAuthService, + AppContext, }; /// Ergonomic type alias for using [`ActorFuture`] for [`Room`]. @@ -142,17 +140,12 @@ impl Room { /// transformation happens. pub fn new( room_spec: &RoomSpec, - reconnect_timeout: Duration, - turn: Arc, + context: AppContext, ) -> Result { Ok(Self { id: room_spec.id().clone(), peers: PeerRepository::from(HashMap::new()), - members: ParticipantService::new( - room_spec, - reconnect_timeout, - turn, - )?, + members: ParticipantService::new(room_spec, context)?, }) } diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index a4968ba0a..ab2eeb77e 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -1,4 +1,4 @@ -use std::sync::Arc; +//! Service which control [`Room`]. use actix::{ fut::wrap_future, Actor, ActorFuture, AsyncContext as _, Context, Handler, @@ -27,7 +27,7 @@ use crate::{ room_repo::RoomsRepository, Room, }, - App, + AppContext, }; type ActFuture = @@ -76,13 +76,17 @@ impl From for RoomServiceError { } /// Service for controlling [`Room`]s. +#[derive(Debug)] pub struct RoomService { + /// Repository that stores [`Room`]s addresses. room_repo: RoomsRepository, - app: Arc, + + /// Global app context. + app: AppContext, } impl RoomService { - pub fn new(room_repo: RoomsRepository, app: Arc) -> Self { + pub fn new(room_repo: RoomsRepository, app: AppContext) -> Self { Self { room_repo, app } } } @@ -131,22 +135,12 @@ impl Handler for RoomService { let room_id = spec.id().clone(); - let rpc_reconnect_timeout = - self.app.config.rpc.reconnect_timeout; - let turn_cloned = Arc::clone(&self.app.turn_service); - - // TODO: app context - let room = - Room::new(&spec, rpc_reconnect_timeout, turn_cloned)? - .start(); + let room = Room::new(&spec, self.app.clone())?.start(); self.room_repo.add(room_id, room); } - - Ok(()) - } else { - Ok(()) } + Ok(()) } } @@ -172,10 +166,7 @@ impl Handler for RoomService { let room = msg.1; - let turn = Arc::clone(&self.app.turn_service); - - let room = - Room::new(&room, self.app.config.rpc.reconnect_timeout, turn)?; + let room = Room::new(&room, self.app.clone())?; let room_addr = room.start(); debug!("New Room [id = {}] started.", room_id); diff --git a/src/turn/service.rs b/src/turn/service.rs index 0141ee2d8..c1645de38 100644 --- a/src/turn/service.rs +++ b/src/turn/service.rs @@ -284,8 +284,6 @@ impl Handler for Service { #[cfg(test)] pub mod test { - use std::sync::Arc; - use futures::future; use crate::media::IceUser; @@ -318,8 +316,8 @@ pub mod test { } #[allow(clippy::module_name_repetitions)] - pub fn new_turn_auth_service_mock() -> Arc { - Arc::new(Box::new(TurnAuthServiceMock {})) + pub fn new_turn_auth_service_mock() -> BoxedTurnAuthService { + Box::new(TurnAuthServiceMock {}) } } From fde62ea001559cd4faa4c9754b97322c27007381 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 16 Jul 2019 17:58:15 +0300 Subject: [PATCH 379/735] Rename RoomsRepository --- src/api/client/server.rs | 10 +++++----- src/main.rs | 4 ++-- src/signalling/room_repo.rs | 4 ++-- src/signalling/room_service.rs | 7 ++++--- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/api/client/server.rs b/src/api/client/server.rs index eeaabcd51..3eacf3ace 100644 --- a/src/api/client/server.rs +++ b/src/api/client/server.rs @@ -24,7 +24,7 @@ use crate::{ }, conf::{Conf, Rpc}, log::prelude::*, - signalling::room_repo::RoomsRepository, + signalling::room_repo::RoomRepository, }; /// Parameters of new WebSocket connection creation HTTP request. @@ -80,14 +80,14 @@ fn ws_index( /// Context for [`App`] which holds all the necessary dependencies. pub struct Context { /// Repository of all currently existing [`Room`]s in application. - pub rooms: RoomsRepository, + pub rooms: RoomRepository, /// Settings of application. pub config: Rpc, } /// Starts HTTP server for handling WebSocket connections of Client API. -pub fn run(rooms: RoomsRepository, config: Conf) -> io::Result<()> { +pub fn run(rooms: RoomRepository, config: Conf) -> io::Result<()> { let server_addr = config.server.bind_addr(); HttpServer::new(move || { App::new() @@ -129,7 +129,7 @@ mod test { use super::*; /// Creates [`RoomsRepository`] for tests filled with a single [`Room`]. - fn room(conf: Conf) -> RoomsRepository { + fn room(conf: Conf) -> RoomRepository { let room_spec = control::load_from_yaml_file("tests/specs/pub_sub_video_call.yml") .unwrap(); @@ -145,7 +145,7 @@ mod test { room_id => client_room, }; - RoomsRepository::new(room_hash_map) + RoomRepository::new(room_hash_map) } /// Creates test WebSocket server of Client API which can handle requests. diff --git a/src/main.rs b/src/main.rs index 181aa8d30..53fb79ef7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,7 +9,7 @@ use medea::{ conf::Conf, log::{self, prelude::*}, signalling::{ - room_repo::RoomsRepository, + room_repo::RoomRepository, room_service::{RoomService, StartStaticRooms}, }, turn::new_turn_auth_service, @@ -36,7 +36,7 @@ fn main() -> Result<(), Error> { .and_then(move |turn_service| { let app_context = AppContext::new(config.clone(), turn_service); - let room_repo = RoomsRepository::new(HashMap::new()); + let room_repo = RoomRepository::new(HashMap::new()); let room_service = RoomService::new(room_repo.clone(), app_context.clone()) .start(); diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs index 2f671bce2..1ca195bc1 100644 --- a/src/signalling/room_repo.rs +++ b/src/signalling/room_repo.rs @@ -9,13 +9,13 @@ use crate::{api::control::RoomId, signalling::Room}; /// Repository that stores [`Room`]s addresses. #[derive(Clone, Debug)] -pub struct RoomsRepository { +pub struct RoomRepository { // TODO: Use crossbeam's concurrent hashmap when its done. // [Tracking](https://github.com/crossbeam-rs/rfcs/issues/32). rooms: Arc>>>, } -impl RoomsRepository { +impl RoomRepository { /// Creates new [`Room`]s repository with passed-in [`Room`]s. pub fn new(rooms: HashMap>) -> Self { Self { diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index ab2eeb77e..0c495f854 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -24,7 +24,7 @@ use crate::{ RoomError, SerializeProtobufEndpoint, SerializeProtobufMember, SerializeProtobufRoom, }, - room_repo::RoomsRepository, + room_repo::RoomRepository, Room, }, AppContext, @@ -79,14 +79,14 @@ impl From for RoomServiceError { #[derive(Debug)] pub struct RoomService { /// Repository that stores [`Room`]s addresses. - room_repo: RoomsRepository, + room_repo: RoomRepository, /// Global app context. app: AppContext, } impl RoomService { - pub fn new(room_repo: RoomsRepository, app: AppContext) -> Self { + pub fn new(room_repo: RoomRepository, app: AppContext) -> Self { Self { room_repo, app } } } @@ -103,6 +103,7 @@ fn get_local_uri_to_room(room_id: RoomId) -> LocalUri { LocalUri::new(Some(room_id), None, None) } +/// Signal for load all static specs and start [`Room`]s. #[derive(Message)] #[rtype(result = "Result<(), RoomServiceError>")] pub struct StartStaticRooms; From 5a042ec32a8ec148ad42b10183d64f3277ccae4d Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 16 Jul 2019 20:06:08 +0300 Subject: [PATCH 380/735] Use state machine for local uri --- .../control/endpoints/webrtc_play_endpoint.rs | 36 +-- src/api/control/grpc/server.rs | 282 ++++++++++-------- src/api/control/local_uri.rs | 195 +++++++++--- src/api/error_codes.rs | 48 +-- src/signalling/elements/member.rs | 69 ++--- src/signalling/participants.rs | 17 +- src/signalling/room.rs | 8 +- src/signalling/room_service.rs | 38 ++- 8 files changed, 422 insertions(+), 271 deletions(-) diff --git a/src/api/control/endpoints/webrtc_play_endpoint.rs b/src/api/control/endpoints/webrtc_play_endpoint.rs index c37c5c6cc..226ef9be3 100644 --- a/src/api/control/endpoints/webrtc_play_endpoint.rs +++ b/src/api/control/endpoints/webrtc_play_endpoint.rs @@ -14,7 +14,7 @@ use crate::api::{ control::{ endpoints::webrtc_publish_endpoint::WebRtcPublishId, grpc::protos::control::WebRtcPlayEndpoint as WebRtcPlayEndpointProto, - local_uri::{LocalUri, LocalUriParseError}, + local_uri::{LocalUriParseError, LocalUriType}, MemberId, RoomId, TryFromProtobufError, }, error_codes::ErrorCode, @@ -55,8 +55,8 @@ impl TryFrom<&WebRtcPlayEndpointProto> for WebRtcPlayEndpoint { #[derive(Debug, Fail)] pub enum SrcParseError { - #[fail(display = "Missing fields {:?} in '{}' local URI.", _1, _0)] - MissingField(String, Vec), + #[fail(display = "Provided not src uri {}", _0)] + NotSrcUri(String), #[fail(display = "Local URI '{}' parse error: {:?}", _0, _1)] LocalUriParseError(String, LocalUriParseError), } @@ -64,9 +64,7 @@ pub enum SrcParseError { impl Into for SrcParseError { fn into(self) -> ErrorCode { match self { - SrcParseError::MissingField(text, fields) => { - ErrorCode::MissingFieldsInSrcUri(text, fields) - } + SrcParseError::NotSrcUri(text) => ErrorCode::NotSourceUri(text), SrcParseError::LocalUriParseError(_, err) => err.into(), } } @@ -90,32 +88,14 @@ impl SrcUri { /// Returns [`SrcParseError::LocalUriParseError`] when some error happened /// while parsing URI. pub fn parse(value: &str) -> Result { - let local_uri = LocalUri::parse(value).map_err(|e| { + let local_uri = LocalUriType::parse(value).map_err(|e| { SrcParseError::LocalUriParseError(value.to_string(), e) })?; - let mut missing_fields = Vec::new(); - if local_uri.room_id.is_none() { - missing_fields.push("room_id".to_string()); - } - if local_uri.member_id.is_none() { - missing_fields.push("member_id".to_string()); - } - if local_uri.endpoint_id.is_none() { - missing_fields.push("endpoint_id".to_string()); - } - - if missing_fields.is_empty() { - Ok(Self { - room_id: local_uri.room_id.unwrap(), - member_id: local_uri.member_id.unwrap(), - endpoint_id: WebRtcPublishId(local_uri.endpoint_id.unwrap()), - }) + if let LocalUriType::Endpoint(endpoint_uri) = local_uri { + Ok(endpoint_uri.into()) } else { - Err(SrcParseError::MissingField( - value.to_string(), - missing_fields, - )) + Err(SrcParseError::NotSrcUri(value.to_string())) } } } diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index 52669738e..061819c17 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -17,7 +17,7 @@ use crate::{ ApplyRequest, CreateRequest, Error, GetResponse, IdRequest, Response, }, - local_uri::{LocalUri, LocalUriParseError}, + local_uri::{LocalUri, LocalUriParseError, LocalUriType}, Endpoint, MemberSpec, RoomSpec, TryFromElementError, TryFromProtobufError, }, @@ -36,6 +36,7 @@ use crate::{ }; use super::protos::control_grpc::{create_control_api, ControlApi}; +use crate::api::control::local_uri::{IsEndpointId, IsMemberId, IsRoomId}; #[derive(Debug, Fail)] enum ControlApiError { @@ -114,7 +115,7 @@ macro_rules! fut_try { /// See `send_error_response` doc for details about arguments for this macro. macro_rules! parse_local_uri { ($uri:expr, $ctx:expr, $sink:expr, $response:ty) => { - match LocalUri::parse($uri) { + match LocalUriType::parse($uri) { Ok(o) => o, Err(e) => { let error: ErrorCode = e.into(); @@ -160,9 +161,9 @@ impl ControlApiService { pub fn create_room( &mut self, req: &CreateRequest, - local_uri: LocalUri, + local_uri: LocalUri, ) -> impl Future { - let room_id = local_uri.room_id.unwrap(); + let room_id = local_uri.take_room_id(); let room = fut_try!(RoomSpec::try_from_protobuf( room_id.clone(), @@ -198,12 +199,12 @@ impl ControlApiService { pub fn create_member( &mut self, req: &CreateRequest, - local_uri: LocalUri, + local_uri: LocalUri, ) -> impl Future { let spec = fut_try!(MemberSpec::try_from(req.get_member())); - let room_id = local_uri.room_id.unwrap(); - let member_id = local_uri.member_id.unwrap(); + let (member_id, room_uri) = local_uri.take_member_id(); + let room_id = room_uri.take_room_id(); let base_url = self.app.config.get_base_rpc_url(); let sid = format!( @@ -233,15 +234,19 @@ impl ControlApiService { pub fn create_endpoint( &mut self, req: &CreateRequest, - local_uri: LocalUri, + local_uri: LocalUri, ) -> impl Future { let endpoint = fut_try!(Endpoint::try_from(req)); + let (endpoint_id, member_uri) = local_uri.take_endpoint_id(); + let (member_id, room_uri) = member_uri.take_member_id(); + let room_id = room_uri.take_room_id(); + Either::A( self.room_service .send(CreateEndpointInRoom { - room_id: local_uri.room_id.unwrap(), - member_id: local_uri.member_id.unwrap(), - endpoint_id: local_uri.endpoint_id.unwrap(), + room_id: room_id, + member_id: member_id, + endpoint_id: endpoint_id, spec: endpoint, }) .map_err(ControlApiError::from) @@ -284,72 +289,93 @@ impl ControlApi for ControlApiService { ) { let local_uri = parse_local_uri!(req.get_id(), ctx, sink, Response); - if local_uri.is_room_uri() { - if req.has_room() { - ctx.spawn(self.create_room(&req, local_uri).then(move |r| { - sink.success(get_response_for_create(r)).map_err(|_| ()) - })); - } else { - send_error_response!( - ctx, - sink, - ErrorCode::ElementIdForRoomButElementIsNot( - req.get_id().to_string(), - ), - Response - ); + match local_uri { + LocalUriType::Room(local_uri) => { + if req.has_room() { + ctx.spawn(self.create_room(&req, local_uri).then( + move |r| { + sink.success(get_response_for_create(r)) + .map_err(|_| ()) + }, + )); + } else { + send_error_response!( + ctx, + sink, + ErrorCode::ElementIdForRoomButElementIsNot( + req.get_id().to_string(), + ), + Response + ); + } } - } else if local_uri.is_member_uri() { - if req.has_member() { - ctx.spawn(self.create_member(&req, local_uri).then(move |r| { - sink.success(get_response_for_create(r)).map_err(|e| { - warn!( - "Error while sending Create response by gRPC. {:?}", - e - ) - }) - })); - } else { - send_error_response!( - ctx, - sink, - ErrorCode::ElementIdForMemberButElementIsNot( - req.get_id().to_string(), - ), - Response - ); + LocalUriType::Member(local_uri) => { + if req.has_member() { + ctx.spawn(self.create_member(&req, local_uri).then( + move |r| { + sink.success(get_response_for_create(r)).map_err( + |e| { + warn!( + "Error while sending Create response \ + by gRPC. {:?}", + e + ) + }, + ) + }, + )); + } else { + send_error_response!( + ctx, + sink, + ErrorCode::ElementIdForMemberButElementIsNot( + req.get_id().to_string(), + ), + Response + ); + } } - } else if local_uri.is_endpoint_uri() { - if req.has_webrtc_pub() || req.has_webrtc_play() { - ctx.spawn(self.create_endpoint(&req, local_uri).then( - move |r| { - sink.success(get_response_for_create(r)).map_err(|e| { - warn!( - "Error while sending Create response by gRPC. \ - {:?}", - e + LocalUriType::Endpoint(local_uri) => { + if req.has_webrtc_pub() || req.has_webrtc_play() { + ctx.spawn(self.create_endpoint(&req, local_uri).then( + move |r| { + sink.success(get_response_for_create(r)).map_err( + |e| { + warn!( + "Error while sending Create response \ + by gRPC. {:?}", + e + ) + }, ) - }) - }, - )); - } else { - send_error_response!( - ctx, - sink, - ErrorCode::ElementIdForEndpointButElementIsNot( - req.get_id().to_string(), - ), - Response - ); + }, + )); + } else { + send_error_response!( + ctx, + sink, + ErrorCode::ElementIdForEndpointButElementIsNot( + req.get_id().to_string(), + ), + Response + ); + } } - } else { - send_error_response!( - ctx, - sink, - ErrorCode::InvalidElementUri(req.get_id().to_string(),), - Response - ); } + + // TODO + // if local_uri.is_room_uri() { + // } else if local_uri.is_member_uri() { + // } else if local_uri.is_endpoint_uri() { + // } else { + // send_error_response!( + // ctx, + // sink, + // + // ErrorCode::InvalidElementUri(req.get_id().to_string()), + // Response + // ); + // } } /// Implementation for `Apply` method of gRPC control API. @@ -376,33 +402,45 @@ impl ControlApi for ControlApiService { for id in req.get_id() { let uri = parse_local_uri!(id, ctx, sink, Response); - if uri.is_room_uri() { - delete_room_futs.push( - self.room_service.send(DeleteRoom(uri.room_id.unwrap())), - ); - } else if uri.is_member_uri() { - delete_member_futs.push(self.room_service.send( - DeleteMemberFromRoom { - room_id: uri.room_id.unwrap(), - member_id: uri.member_id.unwrap(), - }, - )); - } else if uri.is_endpoint_uri() { - delete_endpoints_futs.push(self.room_service.send( - DeleteEndpointFromMember { - room_id: uri.room_id.unwrap(), - member_id: uri.member_id.unwrap(), - endpoint_id: uri.endpoint_id.unwrap(), - }, - )); - } else { - send_error_response!( - ctx, - sink, - ErrorCode::InvalidElementUri(id.to_string(),), - Response - ); + match uri { + LocalUriType::Room(uri) => { + delete_room_futs.push( + self.room_service.send(DeleteRoom(uri.take_room_id())), + ); + } + LocalUriType::Member(uri) => { + let (member_id, room_uri) = uri.take_member_id(); + let room_id = room_uri.take_room_id(); + delete_member_futs.push( + self.room_service + .send(DeleteMemberFromRoom { room_id, member_id }), + ); + } + LocalUriType::Endpoint(uri) => { + let (endpoint_id, member_uri) = uri.take_endpoint_id(); + let (member_id, room_uri) = member_uri.take_member_id(); + let room_id = room_uri.take_room_id(); + delete_endpoints_futs.push(self.room_service.send( + DeleteEndpointFromMember { + room_id, + member_id, + endpoint_id, + }, + )); + } } + // TODO + // if uri.is_room_uri() { + // } else if uri.is_member_uri() { + // } else if uri.is_endpoint_uri() { + // } else { + // send_error_response!( + // ctx, + // sink, + // ErrorCode::InvalidElementUri(id.to_string()), + // Response + // ); + // } } ctx.spawn( @@ -470,27 +508,35 @@ impl ControlApi for ControlApiService { for id in req.get_id() { let local_uri = parse_local_uri!(id, ctx, sink, GetResponse); - if local_uri.is_room_uri() { - room_ids.push(local_uri.room_id.unwrap()); - } else if local_uri.is_member_uri() { - member_ids.push(( - local_uri.room_id.unwrap(), - local_uri.member_id.unwrap(), - )); - } else if local_uri.is_endpoint_uri() { - endpoint_ids.push(( - local_uri.room_id.unwrap(), - local_uri.member_id.unwrap(), - local_uri.endpoint_id.unwrap(), - )); - } else { - send_error_response!( - ctx, - sink, - ErrorCode::InvalidElementUri(id.to_string(),), - GetResponse - ); + match local_uri { + LocalUriType::Room(room_uri) => { + room_ids.push(room_uri.take_room_id()); + } + LocalUriType::Member(member_uri) => { + let (member_id, room_uri) = member_uri.take_member_id(); + let room_id = room_uri.take_room_id(); + member_ids.push((room_id, member_id)); + } + LocalUriType::Endpoint(endpoint_uri) => { + let (endpoint_id, member_uri) = + endpoint_uri.take_endpoint_id(); + let (member_id, room_uri) = member_uri.take_member_id(); + let room_id = room_uri.take_room_id(); + endpoint_ids.push((room_id, member_id, endpoint_id)); + } } + // TODO + // if local_uri.is_room_uri() { + // } else if local_uri.is_member_uri() { + // } else if local_uri.is_endpoint_uri() { + // } else { + // send_error_response!( + // ctx, + // sink, + // ErrorCode::InvalidElementUri(id.to_string(),), + // GetResponse + // ); + // } } let room_fut = self.room_service.send(GetRoom(room_ids)); diff --git a/src/api/control/local_uri.rs b/src/api/control/local_uri.rs index 8581abe15..74d113e02 100644 --- a/src/api/control/local_uri.rs +++ b/src/api/control/local_uri.rs @@ -7,6 +7,9 @@ use failure::Fail; use crate::api::error_codes::ErrorCode; use super::{MemberId, RoomId}; +use crate::api::control::{ + endpoints::webrtc_play_endpoint::SrcUri, WebRtcPublishId, +}; #[allow(clippy::module_name_repetitions)] #[derive(Debug, Fail)] @@ -19,6 +22,9 @@ pub enum LocalUriParseError { #[fail(display = "Too many ({}) paths in provided URI.", _0)] TooManyFields(usize, String), + #[fail(display = "Missing fields. {}", _0)] + MissingFields(String), + /// Provided empty `&str`. #[fail(display = "You provided empty local uri.")] Empty, @@ -34,43 +40,153 @@ impl Into for LocalUriParseError { ErrorCode::ElementIdIsTooLong(text) } LocalUriParseError::Empty => ErrorCode::EmptyElementId, + LocalUriParseError::MissingFields(text) => { + ErrorCode::MissingFieldsInSrcUri(text) + } + } + } +} + +#[derive(Debug)] +pub struct IsRoomId(RoomId); +#[derive(Debug)] +pub struct IsMemberId(LocalUri, MemberId); +#[derive(Debug)] +pub struct IsEndpointId(LocalUri, String); + +#[derive(Debug)] +pub struct LocalUri { + state: T, +} + +impl LocalUriType { + pub fn parse(value: &str) -> Result { + let inner = LocalUriInner::parse(value)?; + if inner.is_room_uri() { + Ok(LocalUriType::Room(LocalUri::::new( + inner.room_id.unwrap(), + ))) + } else if inner.is_member_uri() { + Ok(LocalUriType::Member(LocalUri::::new( + inner.room_id.unwrap(), + inner.member_id.unwrap(), + ))) + } else if inner.is_endpoint_uri() { + Ok(LocalUriType::Endpoint(LocalUri::::new( + inner.room_id.unwrap(), + inner.member_id.unwrap(), + inner.endpoint_id.unwrap(), + ))) + } else { + Err(LocalUriParseError::MissingFields(value.to_string())) + } + } +} + +impl LocalUri { + pub fn new(room_id: RoomId) -> LocalUri { + LocalUri { + state: IsRoomId(room_id), + } + } + + pub fn room_id(&self) -> &RoomId { + &self.state.0 + } + + pub fn take_room_id(self) -> RoomId { + self.state.0 + } +} + +impl LocalUri { + pub fn new(room_id: RoomId, member_id: MemberId) -> LocalUri { + LocalUri { + state: IsMemberId(LocalUri::::new(room_id), member_id), + } + } + + pub fn room_id(&self) -> &RoomId { + &self.state.0.room_id() + } + + pub fn member_id(&self) -> &MemberId { + &self.state.1 + } + + pub fn take_member_id(self) -> (MemberId, LocalUri) { + (self.state.1, self.state.0) + } +} + +impl LocalUri { + pub fn new( + room_id: RoomId, + member_id: MemberId, + endpoint_id: String, + ) -> LocalUri { + LocalUri { + state: IsEndpointId( + LocalUri::::new(room_id, member_id), + endpoint_id, + ), + } + } + + pub fn room_id(&self) -> &RoomId { + &self.state.0.room_id() + } + + pub fn member_id(&self) -> &MemberId { + &self.state.0.member_id() + } + + pub fn endpoint_id(&self) -> &str { + &self.state.1 + } + + pub fn take_endpoint_id(self) -> (String, LocalUri) { + (self.state.1, self.state.0) + } +} + +impl Into for LocalUri { + fn into(self) -> SrcUri { + SrcUri { + room_id: self.state.0.state.0.state.0, + member_id: self.state.0.state.1, + endpoint_id: WebRtcPublishId(self.state.1), } } } +#[derive(Debug)] +pub enum LocalUriType { + Room(LocalUri), + Member(LocalUri), + Endpoint(LocalUri), +} + #[allow(clippy::doc_markdown)] /// Uri in format "local://room_id/member_id/endpoint_id" /// This kind of uri used for pointing to some element in spec (`Room`, /// `Member`, `WebRtcPlayEndpoint`, `WebRtcPublishEndpoint`, etc). #[derive(Debug, Clone)] -pub struct LocalUri { +struct LocalUriInner { /// ID of [`Room`] - pub room_id: Option, + room_id: Option, /// ID of `Member` - pub member_id: Option, + member_id: Option, /// Control ID of [`Endpoint`] - pub endpoint_id: Option, + endpoint_id: Option, } -impl LocalUri { - /// Create new [`LocalUri`] with provided IDs. - pub fn new( - room_id: Option, - member_id: Option, - endpoint_id: Option, - ) -> Self { - Self { - room_id, - member_id, - endpoint_id, - } - } - +impl LocalUriInner { /// Parse [`LocalUri`] from str. /// /// Returns [`LocalUriParse::NotLocal`] when uri is not "local://" /// Returns [`LocalUriParse::TooManyFields`] when uri have too many paths. - pub fn parse(value: &str) -> Result { + fn parse(value: &str) -> Result { if value.is_empty() { return Err(LocalUriParseError::Empty); } @@ -111,40 +227,51 @@ impl LocalUri { } /// Return true if this [`LocalUri`] pointing to `Room` element. - pub fn is_room_uri(&self) -> bool { + fn is_room_uri(&self) -> bool { self.room_id.is_some() && self.member_id.is_none() && self.endpoint_id.is_none() } /// Return true if this [`LocalUri`] pointing to `Member` element. - pub fn is_member_uri(&self) -> bool { + fn is_member_uri(&self) -> bool { self.room_id.is_some() && self.member_id.is_some() && self.endpoint_id.is_none() } /// Return true if this [`LocalUri`] pointing to `Endpoint` element. - pub fn is_endpoint_uri(&self) -> bool { + fn is_endpoint_uri(&self) -> bool { self.room_id.is_some() && self.member_id.is_some() && self.endpoint_id.is_some() } } -impl fmt::Display for LocalUri { +impl fmt::Display for LocalUri { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "local://")?; - if let Some(room_id) = &self.room_id { - write!(f, "{}", room_id)?; - if let Some(member_id) = &self.member_id { - write!(f, "/{}", member_id)?; - if let Some(endpoint_id) = &self.endpoint_id { - write!(f, "/{}", endpoint_id)? - } - } - } + write!(f, "local://{}", self.state.0) + } +} - Ok(()) +impl fmt::Display for LocalUri { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{}/{}", self.state.0, self.state.1) + } +} + +impl fmt::Display for LocalUri { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{}/{}", self.state.0, self.state.1) + } +} + +impl fmt::Display for LocalUriType { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + LocalUriType::Room(e) => write!(f, "{}", e), + LocalUriType::Member(e) => write!(f, "{}", e), + LocalUriType::Endpoint(e) => write!(f, "{}", e), + } } } diff --git a/src/api/error_codes.rs b/src/api/error_codes.rs index b4153558e..9364452fd 100644 --- a/src/api/error_codes.rs +++ b/src/api/error_codes.rs @@ -8,7 +8,8 @@ //! * __1300...1399__ Conflicts use crate::api::control::{ - grpc::protos::control::Error as ErrorProto, local_uri::LocalUri, + grpc::protos::control::Error as ErrorProto, + local_uri::{IsEndpointId, IsMemberId, IsRoomId, LocalUri, LocalUriType}, }; /// Medea control API errors. @@ -25,23 +26,23 @@ pub enum ErrorCode { /// Publish endpoint not found. /// /// Code: __1001__. - PublishEndpointNotFound(LocalUri), + PublishEndpointNotFound(LocalUri), /// Play endpoint not found. /// /// Code: __1002__. - PlayEndpointNotFound(LocalUri), + PlayEndpointNotFound(LocalUri), /// Member not found. /// /// Code: __1003__. - MemberNotFound(LocalUri), + MemberNotFound(LocalUri), /// Room not found. /// /// Code: __1004__. - RoomNotFound(LocalUri), + RoomNotFound(LocalUri), /// Endpoint not found. /// /// Code: __1005__. - EndpointNotFound(LocalUri), + EndpointNotFound(LocalUri), ////////////////////////////////////// // Spec errors (1100 - 1199 codes) // @@ -49,19 +50,19 @@ pub enum ErrorCode { /// Medea expects `Room` element in pipeline but received not him. /// /// Code: __1100__. - NotRoomInSpec(LocalUri), + NotRoomInSpec(LocalUriType), /// Medea expects `Member` element in pipeline but received not him. /// /// Code: __1101__. - NotMemberInSpec(LocalUri), + NotMemberInSpec(LocalUriType), /// Medea expects `Endpoint` element in pipeline but received not him. /// /// Code: __1102__. - NotEndpointInSpec(LocalUri), + NotEndpointInSpec(LocalUriType), /// Invalid source URI in play endpoint. /// /// Code: __1103__. - InvalidSrcUri(LocalUri), + InvalidSrcUri(LocalUri), /// Provided element ID to Room element but element spec is not for Room. /// /// Code: __1104__. @@ -80,6 +81,10 @@ pub enum ErrorCode { /// /// Code: __1107__ InvalidElementUri(String), + /// Provided not source URI in [`WebRtcPlayEndpoint`]. + /// + /// Code: __1108__. + NotSourceUri(String), ///////////////////////////////// // Parse errors (1200 - 1299) // @@ -92,10 +97,10 @@ pub enum ErrorCode { /// /// Code: __1201__. ElementIdIsTooLong(String), - /// Source URI in publish endpoint missing some fields. + /// Missing some fields in element's ID. /// /// Code: __1202__. - MissingFieldsInSrcUri(String, Vec), + MissingFieldsInSrcUri(String), /// Empty element ID. /// /// Code: __1203__. @@ -107,15 +112,15 @@ pub enum ErrorCode { /// Member already exists. /// /// Code: __1300__. - MemberAlreadyExists(LocalUri), + MemberAlreadyExists(LocalUri), /// Endpoint already exists. /// /// Code: __1301__. - EndpointAlreadyExists(LocalUri), + EndpointAlreadyExists(LocalUri), /// Room already exists. /// /// Code: __1302__. - RoomAlreadyExists(LocalUri), + RoomAlreadyExists(LocalUri), } impl Into for ErrorCode { @@ -224,6 +229,11 @@ impl Into for ErrorCode { error.set_element(id); error.set_code(1107); } + ErrorCode::NotSourceUri(id) => { + error.set_text("Provided not source URI".to_string()); + error.set_element(id); + error.set_code(1108); + } ///////////////////////////////// // Parse errors (1200 - 1299) // @@ -243,11 +253,9 @@ impl Into for ErrorCode { error.set_element(uri); error.set_code(1201); } - ErrorCode::MissingFieldsInSrcUri(uri, fields) => { - error.set_text(format!( - "Missing {:?} fields in element ID.", - fields - )); + ErrorCode::MissingFieldsInSrcUri(uri) => { + error + .set_text("Missing some fields in element ID.".to_string()); error.set_element(uri); error.set_code(1202); } diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index be02cace6..064c50dc7 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -24,42 +24,45 @@ use crate::{ }; use super::endpoints::webrtc::{WebRtcPlayEndpoint, WebRtcPublishEndpoint}; -use crate::api::error_codes::ErrorCode; +use crate::api::{ + control::local_uri::{IsEndpointId, IsMemberId, IsRoomId, LocalUriType}, + error_codes::ErrorCode, +}; /// Errors which may occur while loading [`Member`]s from [`RoomSpec`]. #[derive(Debug, Fail)] pub enum MembersLoadError { /// Errors that can occur when we try transform some spec from [`Element`]. #[fail(display = "TryFromElementError: {}", _0)] - TryFromError(TryFromElementError, LocalUri), + TryFromError(TryFromElementError, LocalUriType), /// [`Member`] not found. #[fail(display = "Member [id = {}] not found.", _0)] - MemberNotFound(LocalUri), + MemberNotFound(LocalUri), /// [`WebRtcPlayEndpoint`] not found. #[fail( display = "Play endpoint [id = {}] not found while loading spec,", _0 )] - PlayEndpointNotFound(LocalUri), + PlayEndpointNotFound(LocalUri), /// [`WebRtcPublishEndpoint`] not found. #[fail( display = "Publish endpoint [id = {}] not found while loading spec.", _0 )] - PublishEndpointNotFound(LocalUri), + PublishEndpointNotFound(LocalUri), } #[allow(clippy::module_name_repetitions)] #[derive(Debug, Fail)] pub enum MemberError { #[fail(display = "Publish endpoint [id = {}] not found.", _0)] - PublishEndpointNotFound(LocalUri), + PublishEndpointNotFound(LocalUri), #[fail(display = "Play endpoint [id = {}] not found.", _0)] - PlayEndpointNotFound(LocalUri), + PlayEndpointNotFound(LocalUri), } impl Into for MembersLoadError { @@ -151,22 +154,19 @@ impl Member { member_id: &MemberId, ) -> Result { let element = room_spec.pipeline.get(&member_id.0).map_or( - Err(MembersLoadError::MemberNotFound(LocalUri::new( - Some(self.room_id()), - Some(member_id.clone()), - None, - ))), + Err(MembersLoadError::MemberNotFound( + LocalUri::::new(self.room_id(), member_id.clone()), + )), Ok, )?; MemberSpec::try_from(element).map_err(|e| { MembersLoadError::TryFromError( e, - LocalUri::new( - Some(self.room_id()), - Some(member_id.clone()), - None, - ), + LocalUriType::Member(LocalUri::::new( + self.room_id(), + member_id.clone(), + )), ) }) } @@ -193,11 +193,9 @@ impl Member { let publisher_id = MemberId(spec_play_endpoint.src.member_id.to_string()); let publisher_member = store.get(&publisher_id).map_or( - Err(MembersLoadError::MemberNotFound(LocalUri::new( - Some(self.room_id()), - Some(publisher_id), - None, - ))), + Err(MembersLoadError::MemberNotFound( + LocalUri::::new(self.room_id(), publisher_id), + )), Ok, )?; let publisher_spec = self.get_member_from_room_spec( @@ -276,16 +274,19 @@ impl Member { } /// Return [`LocalUri`] to this [`Member`]. - fn get_local_uri(&self) -> LocalUri { - LocalUri::new(Some(self.room_id()), Some(self.id()), None) + fn get_local_uri(&self) -> LocalUri { + LocalUri::::new(self.room_id(), self.id()) } /// Return [`LocalUri`] to some endpoint from this [`Member`]. /// /// __Note__ this function don't check presence of `Endpoint` in this /// [`Member`]. - pub fn get_local_uri_to_endpoint(&self, endpoint_id: String) -> LocalUri { - LocalUri::new(Some(self.room_id()), Some(self.id()), Some(endpoint_id)) + pub fn get_local_uri_to_endpoint( + &self, + endpoint_id: String, + ) -> LocalUri { + LocalUri::::new(self.room_id(), self.id(), endpoint_id) } /// Notify [`Member`] that some [`Peer`]s removed. @@ -466,7 +467,9 @@ pub fn parse_members( Err(e) => { return Err(MembersLoadError::TryFromError( e, - LocalUri::new(Some(room_spec.id.clone()), None, None), + LocalUriType::Room(LocalUri::::new( + room_spec.id.clone(), + )), )) } }; @@ -518,19 +521,11 @@ impl Into for Rc { let mut member_pipeline = StdHashMap::new(); for (id, play) in self.sinks() { - let local_uri = LocalUri { - room_id: Some(self.room_id()), - member_id: Some(self.id()), - endpoint_id: Some(id.to_string()), - }; + let local_uri = self.get_local_uri_to_endpoint(id.to_string()); member_pipeline.insert(local_uri.to_string(), play.into()); } for (id, publish) in self.srcs() { - let local_uri = LocalUri { - room_id: Some(self.room_id()), - member_id: Some(self.id()), - endpoint_id: Some(id.to_string()), - }; + let local_uri = self.get_local_uri_to_endpoint(id.to_string()); member_pipeline.insert(local_uri.to_string(), publish.into()); } diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index d51b18a87..19ec1684a 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -28,7 +28,7 @@ use crate::{ WebRtcPlayEndpoint as WebRtcPlayEndpointSpec, WebRtcPublishEndpoint as WebRtcPublishEndpointSpec, }, - local_uri::LocalUri, + local_uri::{IsEndpointId, IsMemberId, LocalUri}, MemberId, MemberSpec, RoomId, RoomSpec, WebRtcPlayId, WebRtcPublishId, }, @@ -60,15 +60,15 @@ pub enum ParticipantServiceErr { )] MailBoxErr(MailboxError), #[fail(display = "Participant [id = {}] not found", _0)] - ParticipantNotFound(LocalUri), + ParticipantNotFound(LocalUri), #[fail(display = "Endpoint [id = {}] not found.", _0)] - EndpointNotFound(LocalUri), + EndpointNotFound(LocalUri), #[fail(display = "{}", _0)] MemberError(MemberError), #[fail(display = "Participant [id = {}] already exists.", _0)] - ParticipantAlreadyExists(LocalUri), + ParticipantAlreadyExists(LocalUri), #[fail(display = "Endpoint [id = {}] already exists.", _0)] - EndpointAlreadyExists(LocalUri), + EndpointAlreadyExists(LocalUri), } impl From for ParticipantServiceErr { @@ -158,8 +158,11 @@ impl ParticipantService { /// /// __Note__ this function don't check presence of [`Member`] in this /// `Room`. - fn get_local_uri_to_member(&self, member_id: MemberId) -> LocalUri { - LocalUri::new(Some(self.room_id.clone()), Some(member_id), None) + fn get_local_uri_to_member( + &self, + member_id: MemberId, + ) -> LocalUri { + LocalUri::::new(self.room_id.clone(), member_id) } /// Lookup [`Member`] by [`MemberId`]. diff --git a/src/signalling/room.rs b/src/signalling/room.rs index e305d05f2..9ebd8bdf9 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -23,7 +23,7 @@ use crate::{ Element as ElementProto, Member_Element, Room as RoomProto, Room_Element, }, - local_uri::LocalUri, + local_uri::{IsMemberId, LocalUri}, room::RoomSpec, Endpoint as EndpointSpec, MemberId, MemberSpec, RoomId, TryFromElementError, WebRtcPlayId, WebRtcPublishId, @@ -488,11 +488,7 @@ impl Into for &mut Room { let mut pipeline = StdHashMap::new(); for (id, member) in self.members.members() { - let local_uri = LocalUri { - room_id: Some(self.get_id()), - member_id: Some(id), - endpoint_id: None, - }; + let local_uri = LocalUri::::new(self.get_id(), id); pipeline.insert(local_uri.to_string(), member.into()); } diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index 0c495f854..aeeff0c9f 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -12,8 +12,9 @@ use crate::{ control::{ endpoints::Endpoint as EndpointSpec, grpc::protos::control::Element as ElementProto, - load_static_specs_from_dir, local_uri::LocalUri, MemberId, - MemberSpec, RoomId, RoomSpec, + load_static_specs_from_dir, + local_uri::{IsEndpointId, IsMemberId, IsRoomId, LocalUri}, + MemberId, MemberSpec, RoomId, RoomSpec, }, error_codes::ErrorCode, }, @@ -37,11 +38,11 @@ type ActFuture = #[derive(Debug, Fail)] pub enum RoomServiceError { #[fail(display = "Room [id = {}] not found.", _0)] - RoomNotFound(LocalUri), + RoomNotFound(LocalUri), #[fail(display = "Mailbox error: {:?}", _0)] MailboxError(MailboxError), #[fail(display = "Room [id = {}] already exists.", _0)] - RoomAlreadyExists(LocalUri), + RoomAlreadyExists(LocalUri), #[fail(display = "{}", _0)] RoomError(RoomError), #[fail(display = "Failed to load static specs. {:?}", _0)] @@ -99,8 +100,8 @@ impl Actor for RoomService { /// /// __Note__ this function don't check presence of [`Room`] in this /// [`RoomService`]. -fn get_local_uri_to_room(room_id: RoomId) -> LocalUri { - LocalUri::new(Some(room_id), None, None) +fn get_local_uri_to_room(room_id: RoomId) -> LocalUri { + LocalUri::::new(room_id) } /// Signal for load all static specs and start [`Room`]s. @@ -287,11 +288,8 @@ impl Handler for RoomService { .map_err(RoomServiceError::from) .map(move |result| { result.map(|r| { - let local_uri = LocalUri { - room_id: Some(room_id), - member_id: None, - endpoint_id: None, - }; + let local_uri = + LocalUri::::new(room_id); (local_uri.to_string(), r) }) }), @@ -331,11 +329,9 @@ impl Handler for RoomService { .map_err(RoomServiceError::from) .map(|result| { result.map(|r| { - let local_uri = LocalUri { - room_id: Some(room_id), - member_id: Some(member_id), - endpoint_id: None, - }; + let local_uri = LocalUri::::new( + room_id, member_id, + ); (local_uri.to_string(), r) }) @@ -379,11 +375,11 @@ impl Handler for RoomService { .map_err(RoomServiceError::from) .map(|result| { result.map(|r| { - let local_uri = LocalUri { - room_id: Some(room_id), - member_id: Some(member_id), - endpoint_id: Some(endpoint_id), - }; + let local_uri = LocalUri::::new( + room_id, + member_id, + endpoint_id, + ); (local_uri.to_string(), r) }) }), From 691b8fe0b58e9015b10999c50fe58ac3ed2fd94b Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 16 Jul 2019 20:11:10 +0300 Subject: [PATCH 381/735] Fix lints --- src/api/control/grpc/server.rs | 6 +++--- src/api/control/local_uri.rs | 18 +++++++++++------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index 061819c17..f24b313f7 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -244,9 +244,9 @@ impl ControlApiService { Either::A( self.room_service .send(CreateEndpointInRoom { - room_id: room_id, - member_id: member_id, - endpoint_id: endpoint_id, + room_id, + member_id, + endpoint_id, spec: endpoint, }) .map_err(ControlApiError::from) diff --git a/src/api/control/local_uri.rs b/src/api/control/local_uri.rs index 74d113e02..60b9e13c2 100644 --- a/src/api/control/local_uri.rs +++ b/src/api/control/local_uri.rs @@ -1,5 +1,8 @@ //! URI for pointing to some medea element. +// Bug in clippy. +#![allow(clippy::use_self)] + use std::fmt; use failure::Fail; @@ -60,7 +63,7 @@ pub struct LocalUri { } impl LocalUriType { - pub fn parse(value: &str) -> Result { + pub fn parse(value: &str) -> Result { let inner = LocalUriInner::parse(value)?; if inner.is_room_uri() { Ok(LocalUriType::Room(LocalUri::::new( @@ -84,8 +87,8 @@ impl LocalUriType { } impl LocalUri { - pub fn new(room_id: RoomId) -> LocalUri { - LocalUri { + pub fn new(room_id: RoomId) -> Self { + Self { state: IsRoomId(room_id), } } @@ -100,8 +103,8 @@ impl LocalUri { } impl LocalUri { - pub fn new(room_id: RoomId, member_id: MemberId) -> LocalUri { - LocalUri { + pub fn new(room_id: RoomId, member_id: MemberId) -> Self { + Self { state: IsMemberId(LocalUri::::new(room_id), member_id), } } @@ -124,8 +127,8 @@ impl LocalUri { room_id: RoomId, member_id: MemberId, endpoint_id: String, - ) -> LocalUri { - LocalUri { + ) -> Self { + Self { state: IsEndpointId( LocalUri::::new(room_id, member_id), endpoint_id, @@ -160,6 +163,7 @@ impl Into for LocalUri { } } +#[allow(clippy::module_name_repetitions)] #[derive(Debug)] pub enum LocalUriType { Room(LocalUri), From 5519be7d84c4a66ea62adf22b48c36a222880bc9 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 16 Jul 2019 20:25:48 +0300 Subject: [PATCH 382/735] Fmt --- src/api/control/grpc/server.rs | 6 ++++-- src/api/control/local_uri.rs | 8 ++++---- src/signalling/elements/member.rs | 23 ++++++++++++----------- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index f24b313f7..c40c39116 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -17,7 +17,10 @@ use crate::{ ApplyRequest, CreateRequest, Error, GetResponse, IdRequest, Response, }, - local_uri::{LocalUri, LocalUriParseError, LocalUriType}, + local_uri::{ + IsEndpointId, IsMemberId, IsRoomId, LocalUri, + LocalUriParseError, LocalUriType, + }, Endpoint, MemberSpec, RoomSpec, TryFromElementError, TryFromProtobufError, }, @@ -36,7 +39,6 @@ use crate::{ }; use super::protos::control_grpc::{create_control_api, ControlApi}; -use crate::api::control::local_uri::{IsEndpointId, IsMemberId, IsRoomId}; #[derive(Debug, Fail)] enum ControlApiError { diff --git a/src/api/control/local_uri.rs b/src/api/control/local_uri.rs index 60b9e13c2..f605ceef3 100644 --- a/src/api/control/local_uri.rs +++ b/src/api/control/local_uri.rs @@ -7,12 +7,12 @@ use std::fmt; use failure::Fail; -use crate::api::error_codes::ErrorCode; +use crate::api::{ + control::{endpoints::webrtc_play_endpoint::SrcUri, WebRtcPublishId}, + error_codes::ErrorCode, +}; use super::{MemberId, RoomId}; -use crate::api::control::{ - endpoints::webrtc_play_endpoint::SrcUri, WebRtcPublishId, -}; #[allow(clippy::module_name_repetitions)] #[derive(Debug, Fail)] diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index 064c50dc7..3dcd2943b 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -10,24 +10,25 @@ use hashbrown::HashMap; use medea_client_api_proto::IceServer; use crate::{ - api::control::{ - endpoints::WebRtcPlayEndpoint as WebRtcPlayEndpointSpec, - grpc::protos::control::{ - Member as MemberProto, Room_Element as ElementProto, + api::{ + control::{ + endpoints::WebRtcPlayEndpoint as WebRtcPlayEndpointSpec, + grpc::protos::control::{ + Member as MemberProto, Room_Element as ElementProto, + }, + local_uri::{ + IsEndpointId, IsMemberId, IsRoomId, LocalUri, LocalUriType, + }, + MemberId, MemberSpec, RoomId, RoomSpec, TryFromElementError, + WebRtcPlayId, WebRtcPublishId, }, - local_uri::LocalUri, - MemberId, MemberSpec, RoomId, RoomSpec, TryFromElementError, - WebRtcPlayId, WebRtcPublishId, + error_codes::ErrorCode, }, log::prelude::*, media::{IceUser, PeerId}, }; use super::endpoints::webrtc::{WebRtcPlayEndpoint, WebRtcPublishEndpoint}; -use crate::api::{ - control::local_uri::{IsEndpointId, IsMemberId, IsRoomId, LocalUriType}, - error_codes::ErrorCode, -}; /// Errors which may occur while loading [`Member`]s from [`RoomSpec`]. #[derive(Debug, Fail)] From 5553699feae7bc673caa7fb5d119a3aff007160a Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 17 Jul 2019 12:46:27 +0300 Subject: [PATCH 383/735] Add docs, minor refactoring --- .../control/endpoints/webrtc_play_endpoint.rs | 16 +++- src/api/control/local_uri.rs | 78 +++++++++++++++---- src/api/error_codes.rs | 1 - 3 files changed, 79 insertions(+), 16 deletions(-) diff --git a/src/api/control/endpoints/webrtc_play_endpoint.rs b/src/api/control/endpoints/webrtc_play_endpoint.rs index 226ef9be3..48838d5dc 100644 --- a/src/api/control/endpoints/webrtc_play_endpoint.rs +++ b/src/api/control/endpoints/webrtc_play_endpoint.rs @@ -14,7 +14,7 @@ use crate::api::{ control::{ endpoints::webrtc_publish_endpoint::WebRtcPublishId, grpc::protos::control::WebRtcPlayEndpoint as WebRtcPlayEndpointProto, - local_uri::{LocalUriParseError, LocalUriType}, + local_uri::{IsEndpointId, LocalUri, LocalUriParseError, LocalUriType}, MemberId, RoomId, TryFromProtobufError, }, error_codes::ErrorCode, @@ -100,6 +100,20 @@ impl SrcUri { } } +impl From> for SrcUri { + fn from(uri: LocalUri) -> Self { + let (endpoint_id, member_uri) = uri.take_endpoint_id(); + let (member_id, room_uri) = member_uri.take_member_id(); + let room_id = room_uri.take_room_id(); + + Self { + room_id, + member_id, + endpoint_id: WebRtcPublishId(endpoint_id), + } + } +} + /// Serde deserializer for [`SrcUri`]. /// Deserialize URIs with pattern `local://{room_id}/{member_id}/{endpoint_id}`. impl<'de> Deserialize<'de> for SrcUri { diff --git a/src/api/control/local_uri.rs b/src/api/control/local_uri.rs index f605ceef3..8741aba18 100644 --- a/src/api/control/local_uri.rs +++ b/src/api/control/local_uri.rs @@ -7,12 +7,10 @@ use std::fmt; use failure::Fail; -use crate::api::{ - control::{endpoints::webrtc_play_endpoint::SrcUri, WebRtcPublishId}, - error_codes::ErrorCode, -}; +use crate::api::error_codes::ErrorCode; use super::{MemberId, RoomId}; +use crate::api::control::endpoints::webrtc_play_endpoint::SrcUri; #[allow(clippy::module_name_repetitions)] #[derive(Debug, Fail)] @@ -57,6 +55,48 @@ pub struct IsMemberId(LocalUri, MemberId); #[derive(Debug)] pub struct IsEndpointId(LocalUri, String); +/// Uri in format "local://room_id/member_id/endpoint_id" +/// This kind of uri used for pointing to some element in spec (`Room`, +/// `Member`, `WebRtcPlayEndpoint`, `WebRtcPublishEndpoint`, etc) based on his +/// state. +/// +/// [`LocalUri`] can be in three states: [`IsRoomId`], [`IsMemberId`], +/// [`IsRoomId`]. This is used for compile time guarantees that some +/// [`LocalUri`] have all mandatory fields. +/// +/// You also can take value from [`LocalUri`] without copy, but you have to do +/// it consistently. For example, if you wish to get [`RoomId`], [`MemberId`] +/// and [`EndpointId`] from [`LocalUri`] you should to make this +/// steps: +/// +/// ``` +/// # use crate::api::control::local_uri::{LocalUri, IsEndpointId}; +/// # use crate::api::control::{RoomId, MemberId}; +/// let orig_room_id = RoomId("room".to_string()); +/// let orig_member_id = MemberId("member".to_string()); +/// let orig_endpoint_id = "endpoint".to_string(); +/// +/// // Create new LocalUri for endpoint. +/// let local_uri = LocalUri::::new( +/// orig_room_id.clone(), +/// orig_member_id.clone(), +/// orig_endpoint_id.clone() +/// ); +/// +/// // We can get reference to room_id from this LocalUri but can't take room_id +/// // without this consistency. +/// let (endpoint_id, member_uri) = local_uri.take_endpoint_id(); +/// assert_eq!(endpoint_id, orig_endpoint_id); +/// +/// let (member_id, room_uri) = member_uri.take_member_id(); +/// assert_eq!(member_id, orig_member_id); +/// +/// let room_id = room_uri.take_room_id(); +/// assert_eq!(room_id, orig_room_id); +/// ``` +/// +/// This is necessary so that it is not possible to get the address in the +/// wrong state ("local://room_id//endpoint_id" for example). #[derive(Debug)] pub struct LocalUri { state: T, @@ -87,42 +127,50 @@ impl LocalUriType { } impl LocalUri { + /// Create new [`LocalUri`] in [`IsRoomId`] state. pub fn new(room_id: RoomId) -> Self { Self { state: IsRoomId(room_id), } } + /// Returns reference to [`RoomId`]. pub fn room_id(&self) -> &RoomId { &self.state.0 } + /// Returns [`RoomId`]. pub fn take_room_id(self) -> RoomId { self.state.0 } } impl LocalUri { + /// Create new [`LocalUri`] in [`IsMemberId`] state. pub fn new(room_id: RoomId, member_id: MemberId) -> Self { Self { state: IsMemberId(LocalUri::::new(room_id), member_id), } } + /// Returns reference to [`RoomId`]. pub fn room_id(&self) -> &RoomId { &self.state.0.room_id() } + /// Returns reference to [`MemberId`]. pub fn member_id(&self) -> &MemberId { &self.state.1 } + /// Return [`MemberId`] and [`LocalUri`] in state [`IsRoomId`]. pub fn take_member_id(self) -> (MemberId, LocalUri) { (self.state.1, self.state.0) } } impl LocalUri { + /// Create new [`LocalUri`] in [`IsEndpointId`] state. pub fn new( room_id: RoomId, member_id: MemberId, @@ -136,33 +184,38 @@ impl LocalUri { } } + /// Returns reference to [`RoomId`]. pub fn room_id(&self) -> &RoomId { &self.state.0.room_id() } + /// Returns reference to [`MemberId`]. pub fn member_id(&self) -> &MemberId { &self.state.0.member_id() } + /// Returns reference to endpoint ID. pub fn endpoint_id(&self) -> &str { &self.state.1 } + /// Return endpoint id and [`LocalUri`] in state [`IsMemberId`]. pub fn take_endpoint_id(self) -> (String, LocalUri) { (self.state.1, self.state.0) } } -impl Into for LocalUri { - fn into(self) -> SrcUri { - SrcUri { - room_id: self.state.0.state.0.state.0, - member_id: self.state.0.state.1, - endpoint_id: WebRtcPublishId(self.state.1), - } +impl From for LocalUri { + fn from(uri: SrcUri) -> Self { + LocalUri::::new( + uri.room_id, + uri.member_id, + uri.endpoint_id.0, + ) } } +/// Enum for store all kinds of [`LocalUri`]s. #[allow(clippy::module_name_repetitions)] #[derive(Debug)] pub enum LocalUriType { @@ -172,9 +225,6 @@ pub enum LocalUriType { } #[allow(clippy::doc_markdown)] -/// Uri in format "local://room_id/member_id/endpoint_id" -/// This kind of uri used for pointing to some element in spec (`Room`, -/// `Member`, `WebRtcPlayEndpoint`, `WebRtcPublishEndpoint`, etc). #[derive(Debug, Clone)] struct LocalUriInner { /// ID of [`Room`] diff --git a/src/api/error_codes.rs b/src/api/error_codes.rs index 9364452fd..d9734aebe 100644 --- a/src/api/error_codes.rs +++ b/src/api/error_codes.rs @@ -125,7 +125,6 @@ pub enum ErrorCode { impl Into for ErrorCode { fn into(self) -> ErrorProto { - // TODO: configure backtrace let mut error = ErrorProto::new(); match self { ErrorCode::UnknownError(msg) => { From b298ce60325e60f66ef5ee75a637e8ce1edcc89a Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 17 Jul 2019 13:56:45 +0300 Subject: [PATCH 384/735] Minor refactor, remove fix for wasm-bindgen --- jason/Cargo.toml | 5 +-- src/api/control/grpc/server.rs | 38 ---------------- src/api/control/local_uri.rs | 79 ++++++++++++++++++---------------- 3 files changed, 45 insertions(+), 77 deletions(-) diff --git a/jason/Cargo.toml b/jason/Cargo.toml index 8a58d9b76..d5243c4bf 100644 --- a/jason/Cargo.toml +++ b/jason/Cargo.toml @@ -21,14 +21,13 @@ default = ["console_error_panic_hook", "wee_alloc"] console_error_panic_hook = { version = "0.1", optional = true } futures = "0.1" js-sys = "0.3" -macro-attr = "0.2.0" +macro-attr = "0.2" medea-client-api-proto = { path = "../proto/client-api", features = ["jason"] } medea-macro = { path = "../crates/medea-macro" } newtype_derive = "0.1" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" -# TODO: remove "=" when bug with BitUint64 will be fixed. -wasm-bindgen = { version = "=0.2.45", features = ["serde-serialize"] } +wasm-bindgen = { version = "0.2", features = ["serde-serialize"] } wasm-bindgen-futures = "0.3" wee_alloc = { version = "0.4", optional = true } [dependencies.web-sys] diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index c40c39116..b23d98577 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -364,20 +364,6 @@ impl ControlApi for ControlApiService { } } } - - // TODO - // if local_uri.is_room_uri() { - // } else if local_uri.is_member_uri() { - // } else if local_uri.is_endpoint_uri() { - // } else { - // send_error_response!( - // ctx, - // sink, - // - // ErrorCode::InvalidElementUri(req.get_id().to_string()), - // Response - // ); - // } } /// Implementation for `Apply` method of gRPC control API. @@ -431,18 +417,6 @@ impl ControlApi for ControlApiService { )); } } - // TODO - // if uri.is_room_uri() { - // } else if uri.is_member_uri() { - // } else if uri.is_endpoint_uri() { - // } else { - // send_error_response!( - // ctx, - // sink, - // ErrorCode::InvalidElementUri(id.to_string()), - // Response - // ); - // } } ctx.spawn( @@ -527,18 +501,6 @@ impl ControlApi for ControlApiService { endpoint_ids.push((room_id, member_id, endpoint_id)); } } - // TODO - // if local_uri.is_room_uri() { - // } else if local_uri.is_member_uri() { - // } else if local_uri.is_endpoint_uri() { - // } else { - // send_error_response!( - // ctx, - // sink, - // ErrorCode::InvalidElementUri(id.to_string(),), - // GetResponse - // ); - // } } let room_fut = self.room_service.send(GetRoom(room_ids)); diff --git a/src/api/control/local_uri.rs b/src/api/control/local_uri.rs index 8741aba18..0c40b26a6 100644 --- a/src/api/control/local_uri.rs +++ b/src/api/control/local_uri.rs @@ -1,16 +1,17 @@ //! URI for pointing to some medea element. -// Bug in clippy. +// Fix bug in clippy. #![allow(clippy::use_self)] use std::fmt; use failure::Fail; -use crate::api::error_codes::ErrorCode; +use crate::api::{ + control::endpoints::webrtc_play_endpoint::SrcUri, error_codes::ErrorCode, +}; use super::{MemberId, RoomId}; -use crate::api::control::endpoints::webrtc_play_endpoint::SrcUri; #[allow(clippy::module_name_repetitions)] #[derive(Debug, Fail)] @@ -48,13 +49,19 @@ impl Into for LocalUriParseError { } } +/// State of [`LocalUri`] which points to `Room`. #[derive(Debug)] pub struct IsRoomId(RoomId); + +/// State of [`LocalUri`] which points to `Member`. #[derive(Debug)] pub struct IsMemberId(LocalUri, MemberId); + +/// State of [`LocalUri`] which points to `Endpoint`. #[derive(Debug)] pub struct IsEndpointId(LocalUri, String); +#[allow(clippy::doc_markdown)] /// Uri in format "local://room_id/member_id/endpoint_id" /// This kind of uri used for pointing to some element in spec (`Room`, /// `Member`, `WebRtcPlayEndpoint`, `WebRtcPublishEndpoint`, etc) based on his @@ -102,30 +109,6 @@ pub struct LocalUri { state: T, } -impl LocalUriType { - pub fn parse(value: &str) -> Result { - let inner = LocalUriInner::parse(value)?; - if inner.is_room_uri() { - Ok(LocalUriType::Room(LocalUri::::new( - inner.room_id.unwrap(), - ))) - } else if inner.is_member_uri() { - Ok(LocalUriType::Member(LocalUri::::new( - inner.room_id.unwrap(), - inner.member_id.unwrap(), - ))) - } else if inner.is_endpoint_uri() { - Ok(LocalUriType::Endpoint(LocalUri::::new( - inner.room_id.unwrap(), - inner.member_id.unwrap(), - inner.endpoint_id.unwrap(), - ))) - } else { - Err(LocalUriParseError::MissingFields(value.to_string())) - } - } -} - impl LocalUri { /// Create new [`LocalUri`] in [`IsRoomId`] state. pub fn new(room_id: RoomId) -> Self { @@ -215,15 +198,6 @@ impl From for LocalUri { } } -/// Enum for store all kinds of [`LocalUri`]s. -#[allow(clippy::module_name_repetitions)] -#[derive(Debug)] -pub enum LocalUriType { - Room(LocalUri), - Member(LocalUri), - Endpoint(LocalUri), -} - #[allow(clippy::doc_markdown)] #[derive(Debug, Clone)] struct LocalUriInner { @@ -320,6 +294,39 @@ impl fmt::Display for LocalUri { } } +/// Enum for store all kinds of [`LocalUri`]s. +#[allow(clippy::module_name_repetitions)] +#[derive(Debug)] +pub enum LocalUriType { + Room(LocalUri), + Member(LocalUri), + Endpoint(LocalUri), +} + +impl LocalUriType { + pub fn parse(value: &str) -> Result { + let inner = LocalUriInner::parse(value)?; + if inner.is_room_uri() { + Ok(LocalUriType::Room(LocalUri::::new( + inner.room_id.unwrap(), + ))) + } else if inner.is_member_uri() { + Ok(LocalUriType::Member(LocalUri::::new( + inner.room_id.unwrap(), + inner.member_id.unwrap(), + ))) + } else if inner.is_endpoint_uri() { + Ok(LocalUriType::Endpoint(LocalUri::::new( + inner.room_id.unwrap(), + inner.member_id.unwrap(), + inner.endpoint_id.unwrap(), + ))) + } else { + Err(LocalUriParseError::MissingFields(value.to_string())) + } + } +} + impl fmt::Display for LocalUriType { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { From e4d7a4f1a3f2b37ce6a574752b0587524aa20f80 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 17 Jul 2019 14:23:10 +0300 Subject: [PATCH 385/735] Implement From instead of Into for ErrorCode --- .../control/endpoints/webrtc_play_endpoint.rs | 22 +-- src/api/control/local_uri.rs | 21 +-- src/api/control/mod.rs | 11 -- src/api/error_codes.rs | 136 +++++++++++++++++- src/bin/client.rs | 8 +- src/signalling/elements/member.rs | 59 ++------ src/signalling/participants.rs | 21 --- src/signalling/room.rs | 12 -- src/signalling/room_service.rs | 28 +--- 9 files changed, 158 insertions(+), 160 deletions(-) diff --git a/src/api/control/endpoints/webrtc_play_endpoint.rs b/src/api/control/endpoints/webrtc_play_endpoint.rs index 48838d5dc..c66e97fec 100644 --- a/src/api/control/endpoints/webrtc_play_endpoint.rs +++ b/src/api/control/endpoints/webrtc_play_endpoint.rs @@ -10,14 +10,11 @@ use serde::{ Deserialize, }; -use crate::api::{ - control::{ - endpoints::webrtc_publish_endpoint::WebRtcPublishId, - grpc::protos::control::WebRtcPlayEndpoint as WebRtcPlayEndpointProto, - local_uri::{IsEndpointId, LocalUri, LocalUriParseError, LocalUriType}, - MemberId, RoomId, TryFromProtobufError, - }, - error_codes::ErrorCode, +use crate::api::control::{ + endpoints::webrtc_publish_endpoint::WebRtcPublishId, + grpc::protos::control::WebRtcPlayEndpoint as WebRtcPlayEndpointProto, + local_uri::{IsEndpointId, LocalUri, LocalUriParseError, LocalUriType}, + MemberId, RoomId, TryFromProtobufError, }; macro_attr! { @@ -61,15 +58,6 @@ pub enum SrcParseError { LocalUriParseError(String, LocalUriParseError), } -impl Into for SrcParseError { - fn into(self) -> ErrorCode { - match self { - SrcParseError::NotSrcUri(text) => ErrorCode::NotSourceUri(text), - SrcParseError::LocalUriParseError(_, err) => err.into(), - } - } -} - /// Special uri with pattern `local://{room_id}/{member_id}/{endpoint_id}`. /// This uri can pointing only to [`WebRtcPublishEndpoint`]. #[derive(Clone, Debug)] diff --git a/src/api/control/local_uri.rs b/src/api/control/local_uri.rs index 0c40b26a6..92233fb8a 100644 --- a/src/api/control/local_uri.rs +++ b/src/api/control/local_uri.rs @@ -7,9 +7,7 @@ use std::fmt; use failure::Fail; -use crate::api::{ - control::endpoints::webrtc_play_endpoint::SrcUri, error_codes::ErrorCode, -}; +use crate::api::control::endpoints::webrtc_play_endpoint::SrcUri; use super::{MemberId, RoomId}; @@ -32,23 +30,6 @@ pub enum LocalUriParseError { Empty, } -impl Into for LocalUriParseError { - fn into(self) -> ErrorCode { - match self { - LocalUriParseError::NotLocal(text) => { - ErrorCode::ElementIdIsNotLocal(text) - } - LocalUriParseError::TooManyFields(_, text) => { - ErrorCode::ElementIdIsTooLong(text) - } - LocalUriParseError::Empty => ErrorCode::EmptyElementId, - LocalUriParseError::MissingFields(text) => { - ErrorCode::MissingFieldsInSrcUri(text) - } - } - } -} - /// State of [`LocalUri`] which points to `Room`. #[derive(Debug)] pub struct IsRoomId(RoomId); diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index 00d32efd5..39472c859 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -12,8 +12,6 @@ use std::{convert::TryFrom as _, fs::File, io::Read as _, path::Path}; use failure::{Error, Fail}; use serde::Deserialize; -use crate::api::error_codes::ErrorCode; - use self::{ endpoints::{ webrtc_play_endpoint::{SrcParseError, WebRtcPlayEndpoint}, @@ -66,15 +64,6 @@ impl From for TryFromProtobufError { } } -impl Into for TryFromProtobufError { - fn into(self) -> ErrorCode { - match self { - TryFromProtobufError::SrcUriError(e) => e.into(), - _ => ErrorCode::UnknownError(self.to_string()), - } - } -} - /// Errors that can occur when we try transform some spec from [`Element`]. /// This error used in all [`TryFrom`] of Control API. #[allow(clippy::pub_enum_variant_names)] diff --git a/src/api/error_codes.rs b/src/api/error_codes.rs index d9734aebe..257ae17e6 100644 --- a/src/api/error_codes.rs +++ b/src/api/error_codes.rs @@ -7,9 +7,22 @@ //! * __1200...1299__ Parse errors //! * __1300...1399__ Conflicts -use crate::api::control::{ - grpc::protos::control::Error as ErrorProto, - local_uri::{IsEndpointId, IsMemberId, IsRoomId, LocalUri, LocalUriType}, +use crate::{ + api::control::{ + endpoints::webrtc_play_endpoint::SrcParseError, + grpc::protos::control::Error as ErrorProto, + local_uri::{ + IsEndpointId, IsMemberId, IsRoomId, LocalUri, LocalUriParseError, + LocalUriType, + }, + TryFromElementError, TryFromProtobufError, + }, + signalling::{ + elements::{member::MemberError, MembersLoadError}, + participants::ParticipantServiceErr, + room::RoomError, + room_service::RoomServiceError, + }, }; /// Medea control API errors. @@ -287,3 +300,120 @@ impl Into for ErrorCode { error } } + +impl From for ErrorCode { + fn from(err: ParticipantServiceErr) -> Self { + match err { + ParticipantServiceErr::EndpointNotFound(id) => { + ErrorCode::EndpointNotFound(id) + } + ParticipantServiceErr::ParticipantNotFound(id) => { + ErrorCode::MemberNotFound(id) + } + ParticipantServiceErr::ParticipantAlreadyExists(id) => { + ErrorCode::MemberAlreadyExists(id) + } + ParticipantServiceErr::EndpointAlreadyExists(id) => { + ErrorCode::EndpointAlreadyExists(id) + } + _ => ErrorCode::UnknownError(err.to_string()), + } + } +} + +impl From for ErrorCode { + fn from(err: TryFromProtobufError) -> Self { + match err { + TryFromProtobufError::SrcUriError(e) => e.into(), + _ => ErrorCode::UnknownError(err.to_string()), + } + } +} + +impl From for ErrorCode { + fn from(err: LocalUriParseError) -> Self { + match err { + LocalUriParseError::NotLocal(text) => { + ErrorCode::ElementIdIsNotLocal(text) + } + LocalUriParseError::TooManyFields(_, text) => { + ErrorCode::ElementIdIsTooLong(text) + } + LocalUriParseError::Empty => ErrorCode::EmptyElementId, + LocalUriParseError::MissingFields(text) => { + ErrorCode::MissingFieldsInSrcUri(text) + } + } + } +} + +impl From for ErrorCode { + fn from(err: RoomError) -> Self { + match err { + RoomError::MemberError(e) => e.into(), + RoomError::MembersLoadError(e) => e.into(), + RoomError::ParticipantServiceErr(e) => e.into(), + _ => ErrorCode::UnknownError(err.to_string()), + } + } +} + +impl From for ErrorCode { + fn from(err: MembersLoadError) -> Self { + match err { + MembersLoadError::TryFromError(e, id) => match e { + TryFromElementError::NotEndpoint => { + ErrorCode::NotEndpointInSpec(id) + } + TryFromElementError::NotMember => { + ErrorCode::NotMemberInSpec(id) + } + TryFromElementError::NotRoom => ErrorCode::NotRoomInSpec(id), + }, + MembersLoadError::MemberNotFound(id) => { + ErrorCode::MemberNotFound(id) + } + MembersLoadError::PublishEndpointNotFound(id) => { + ErrorCode::PublishEndpointNotFound(id) + } + MembersLoadError::PlayEndpointNotFound(id) => { + ErrorCode::PlayEndpointNotFound(id) + } + } + } +} + +impl From for ErrorCode { + fn from(err: MemberError) -> Self { + match err { + MemberError::PlayEndpointNotFound(id) => { + ErrorCode::PlayEndpointNotFound(id) + } + MemberError::PublishEndpointNotFound(id) => { + ErrorCode::PublishEndpointNotFound(id) + } + } + } +} + +impl From for ErrorCode { + fn from(err: SrcParseError) -> Self { + match err { + SrcParseError::NotSrcUri(text) => ErrorCode::NotSourceUri(text), + SrcParseError::LocalUriParseError(_, err) => err.into(), + } + } +} + +impl From for ErrorCode { + fn from(err: RoomServiceError) -> Self { + match err { + RoomServiceError::RoomNotFound(id) => ErrorCode::RoomNotFound(id), + RoomServiceError::RoomAlreadyExists(id) => { + ErrorCode::RoomAlreadyExists(id) + } + RoomServiceError::RoomError(e) => e.into(), + _ => ErrorCode::UnknownError(err.to_string()), + } + } +} diff --git a/src/bin/client.rs b/src/bin/client.rs index c4820f4a8..98939d305 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -134,10 +134,10 @@ fn delete_member(client: &ControlApiClient) { fn get_room(client: &ControlApiClient) { let mut get_room_request = IdRequest::new(); let mut room = RepeatedField::new(); - // room.push("local://grpc-test".to_string()); - // room.push("local://video-call-1/responder".to_string()); - // room.push("local://grpc-test/publisher/publish".to_string()); - room.push("local://pub-pub-video-call".to_string()); + room.push("local://grpc-test".to_string()); + room.push("local://video-call-1/responder".to_string()); + room.push("local://grpc-test/publisher/publish".to_string()); + // room.push("local://pub-pub-video-call".to_string()); get_room_request.set_id(room); let reply = client.get(&get_room_request).expect("get room"); diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index 3dcd2943b..01d70bd8a 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -10,19 +10,16 @@ use hashbrown::HashMap; use medea_client_api_proto::IceServer; use crate::{ - api::{ - control::{ - endpoints::WebRtcPlayEndpoint as WebRtcPlayEndpointSpec, - grpc::protos::control::{ - Member as MemberProto, Room_Element as ElementProto, - }, - local_uri::{ - IsEndpointId, IsMemberId, IsRoomId, LocalUri, LocalUriType, - }, - MemberId, MemberSpec, RoomId, RoomSpec, TryFromElementError, - WebRtcPlayId, WebRtcPublishId, + api::control::{ + endpoints::WebRtcPlayEndpoint as WebRtcPlayEndpointSpec, + grpc::protos::control::{ + Member as MemberProto, Room_Element as ElementProto, + }, + local_uri::{ + IsEndpointId, IsMemberId, IsRoomId, LocalUri, LocalUriType, }, - error_codes::ErrorCode, + MemberId, MemberSpec, RoomId, RoomSpec, TryFromElementError, + WebRtcPlayId, WebRtcPublishId, }, log::prelude::*, media::{IceUser, PeerId}, @@ -66,44 +63,6 @@ pub enum MemberError { PlayEndpointNotFound(LocalUri), } -impl Into for MembersLoadError { - fn into(self) -> ErrorCode { - match self { - MembersLoadError::TryFromError(e, id) => match e { - TryFromElementError::NotEndpoint => { - ErrorCode::NotEndpointInSpec(id) - } - TryFromElementError::NotMember => { - ErrorCode::NotMemberInSpec(id) - } - TryFromElementError::NotRoom => ErrorCode::NotRoomInSpec(id), - }, - MembersLoadError::MemberNotFound(id) => { - ErrorCode::MemberNotFound(id) - } - MembersLoadError::PublishEndpointNotFound(id) => { - ErrorCode::PublishEndpointNotFound(id) - } - MembersLoadError::PlayEndpointNotFound(id) => { - ErrorCode::PlayEndpointNotFound(id) - } - } - } -} - -impl Into for MemberError { - fn into(self) -> ErrorCode { - match self { - MemberError::PlayEndpointNotFound(id) => { - ErrorCode::PlayEndpointNotFound(id) - } - MemberError::PublishEndpointNotFound(id) => { - ErrorCode::PublishEndpointNotFound(id) - } - } - } -} - /// [`Member`] is member of [`Room`] with [`RpcConnection`]. #[derive(Debug)] pub struct Member(RefCell); diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 19ec1684a..bf2a540c3 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -32,7 +32,6 @@ use crate::{ MemberId, MemberSpec, RoomId, RoomSpec, WebRtcPlayId, WebRtcPublishId, }, - error_codes::ErrorCode, }, log::prelude::*, media::IceUser, @@ -89,26 +88,6 @@ impl From for ParticipantServiceErr { } } -impl Into for ParticipantServiceErr { - fn into(self) -> ErrorCode { - match self { - ParticipantServiceErr::EndpointNotFound(id) => { - ErrorCode::EndpointNotFound(id) - } - ParticipantServiceErr::ParticipantNotFound(id) => { - ErrorCode::MemberNotFound(id) - } - ParticipantServiceErr::ParticipantAlreadyExists(id) => { - ErrorCode::MemberAlreadyExists(id) - } - ParticipantServiceErr::EndpointAlreadyExists(id) => { - ErrorCode::EndpointAlreadyExists(id) - } - _ => ErrorCode::UnknownError(self.to_string()), - } - } -} - /// Participant is [`Member`] with [`RpcConnection`]. [`ParticipantService`] /// stores [`Member`]s and associated [`RpcConnection`]s, handles /// [`RpcConnection`] authorization, establishment, message sending. diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 9ebd8bdf9..86855e76a 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -28,7 +28,6 @@ use crate::{ Endpoint as EndpointSpec, MemberId, MemberSpec, RoomId, TryFromElementError, WebRtcPlayId, WebRtcPublishId, }, - error_codes::ErrorCode, }, log::prelude::*, media::{ @@ -110,17 +109,6 @@ impl From for RoomError { } } -impl Into for RoomError { - fn into(self) -> ErrorCode { - match self { - RoomError::MemberError(e) => e.into(), - RoomError::MembersLoadError(e) => e.into(), - RoomError::ParticipantServiceErr(e) => e.into(), - _ => ErrorCode::UnknownError(self.to_string()), - } - } -} - /// Media server room with its [`Member`]s. #[derive(Debug)] pub struct Room { diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index aeeff0c9f..450c7a7dd 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -8,15 +8,12 @@ use failure::Fail; use futures::future::{Either, Future}; use crate::{ - api::{ - control::{ - endpoints::Endpoint as EndpointSpec, - grpc::protos::control::Element as ElementProto, - load_static_specs_from_dir, - local_uri::{IsEndpointId, IsMemberId, IsRoomId, LocalUri}, - MemberId, MemberSpec, RoomId, RoomSpec, - }, - error_codes::ErrorCode, + api::control::{ + endpoints::Endpoint as EndpointSpec, + grpc::protos::control::Element as ElementProto, + load_static_specs_from_dir, + local_uri::{IsEndpointId, IsMemberId, IsRoomId, LocalUri}, + MemberId, MemberSpec, RoomId, RoomSpec, }, log::prelude::*, signalling::{ @@ -57,19 +54,6 @@ impl From for RoomServiceError { } } -impl Into for RoomServiceError { - fn into(self) -> ErrorCode { - match self { - RoomServiceError::RoomNotFound(id) => ErrorCode::RoomNotFound(id), - RoomServiceError::RoomAlreadyExists(id) => { - ErrorCode::RoomAlreadyExists(id) - } - RoomServiceError::RoomError(e) => e.into(), - _ => ErrorCode::UnknownError(self.to_string()), - } - } -} - impl From for RoomServiceError { fn from(e: MailboxError) -> Self { RoomServiceError::MailboxError(e) From ccf63b5f96ec4f8e8eaf5346c15e6cd1115236a9 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 17 Jul 2019 17:05:48 +0300 Subject: [PATCH 386/735] Fix Dockerfile --- .dockerignore | 1 + Dockerfile | 16 ++-------------- Makefile | 12 +++++++++++- build/medea/Dockerfile | 23 +++++++++++++++++++++++ docker-compose.medea.yml | 2 +- src/api/control/grpc/protos/control.proto | 3 --- 6 files changed, 38 insertions(+), 19 deletions(-) create mode 100644 build/medea/Dockerfile diff --git a/.dockerignore b/.dockerignore index 4a36a0500..a231909c5 100644 --- a/.dockerignore +++ b/.dockerignore @@ -7,3 +7,4 @@ !jason/src !proto !Makefile +!build.rs diff --git a/Dockerfile b/Dockerfile index 95db9b381..078e841c7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,8 +3,7 @@ # # https://hub.docker.com/_/rust -ARG rust_ver=latest -FROM rust:${rust_ver} AS dist +FROM medea-build AS dist ARG rustc_mode=release ARG rustc_opts=--release ARG cargo_home=/usr/local/cargo @@ -17,22 +16,12 @@ RUN mkdir -p /out/etc/ \ COPY / /app/ -RUN mkdir -p /app/target -RUN mkdir -p /usr/local/cargo - -VOLUME .cache/medea:/app/target -VOLUME .cache/cargo:/usr/local/cargo - -RUN touch /app/target -RUN ls /app - # Build project distribution. RUN cd /app \ # Compile project. && CARGO_HOME="${cargo_home}" \ # TODO: use --out-dir once stabilized - # TODO: use --offline once stabilized - # TODO: https://github.com/rust-lang/cargo/issues/5655 + # TODO: https://github.com/rust-lang/cargo/issues/6790 cargo build --bin=medea ${rustc_opts} \ # Prepare the binary and all dependent dynamic libraries. && cp /app/target/${rustc_mode}/medea /out/medea \ @@ -57,4 +46,3 @@ COPY --from=dist /out/ / USER nobody:nobody ENTRYPOINT ["/medea"] - diff --git a/Makefile b/Makefile index 73ca804c3..2e2d75f7e 100644 --- a/Makefile +++ b/Makefile @@ -46,6 +46,14 @@ test: test.unit test.e2e +########## +# Docker # +########## + +# Build base project Docker image. +docker.build: + docker build -t medea-build -f build/medea/Dockerfile . + ################## # Cargo commands # ################## @@ -185,10 +193,11 @@ else @make down.medea dockerized=no @make up.coturn + docker build -t medea-build -f build/medea/Dockerfile . docker run --rm --network=host -v "$(PWD)":/app -w /app \ -v "$(PWD)/.cache/medea/registry":/usr/local/cargo/registry \ -v "$(PWD)/.cache/medea/target":/app/target \ - rust:latest \ + medea-build:latest \ make test.e2e dockerized=no coturn=no release=yes @make down.coturn @@ -236,6 +245,7 @@ up.jason: up.medea: up.coturn ifeq ($(dockerized),yes) @make down.medea + @make docker.build docker-compose -f docker-compose.medea.yml up @make down.coturn else diff --git a/build/medea/Dockerfile b/build/medea/Dockerfile new file mode 100644 index 000000000..19e9444c8 --- /dev/null +++ b/build/medea/Dockerfile @@ -0,0 +1,23 @@ +# +# Stage 'dist' creates project distribution. +# + +# https://hub.docker.com/_/rust +ARG rust_ver=latest +FROM rust:${rust_ver} AS dist +ARG rustc_mode=release +ARG rustc_opts=--release +ARG cargo_home=/usr/local/cargo + +# Create the user and group files that will be used in the running container to +# run the process as an unprivileged user. +RUN mkdir -p /out/etc/ \ + && echo 'nobody:x:65534:65534:nobody:/:' > /out/etc/passwd \ + && echo 'nobody:x:65534:' > /out/etc/group + +RUN apt-get update +RUN apt-get install -y cmake protobuf-compiler golang +ENV GOPATH /usr/lib/go + +COPY / /app/ +WORKDIR "/app" diff --git a/docker-compose.medea.yml b/docker-compose.medea.yml index 435387df6..d44552280 100644 --- a/docker-compose.medea.yml +++ b/docker-compose.medea.yml @@ -2,7 +2,7 @@ version: "2" services: medea: - container_name: ${COMPOSE_PROJECT_NAME}-backend + container_name: ${COMPOSE_PROJECT_NAME} image: ${COMPOSE_IMAGE_NAME}:${COMPOSE_IMAGE_VER} build: . ports: diff --git a/src/api/control/grpc/protos/control.proto b/src/api/control/grpc/protos/control.proto index 84cb9d55c..d05be273a 100644 --- a/src/api/control/grpc/protos/control.proto +++ b/src/api/control/grpc/protos/control.proto @@ -1,7 +1,5 @@ syntax = "proto3"; -import "google/protobuf/any.proto"; - package medea; service ControlApi { @@ -56,7 +54,6 @@ message Error { string text = 3; string doc = 4; string element = 5; - google.protobuf.Any details = 6; } message Element { From 8e8918902d5ed2a6240a8d8c40f409c5f55135f9 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 19 Jul 2019 13:46:23 +0300 Subject: [PATCH 387/735] Add subscribe graceful shutdown for rooms --- src/lib.rs | 21 ++++++++++++++++++--- src/main.rs | 12 +++++------- src/signalling/room.rs | 1 - 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index c1713f115..20ae4c1ad 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -19,6 +19,7 @@ use hashbrown::HashMap; use crate::{ api::control::{load_static_specs_from_dir, RoomId}, conf::Conf, + shutdown::GracefulShutdown, signalling::{room::RoomError, Room}, turn::{service, TurnServiceErr}, }; @@ -62,12 +63,20 @@ impl From for ServerStartError { /// /// Returns [`ServerStartError::BadRoomSpec`] /// if some error happened while creating room from spec. +// This is not the most beautiful solution, but at the moment let it be. In the +// 32-grpc-dynamic-control-api branch, this logic is changed and everything will +// look better. pub fn start_static_rooms( conf: &Conf, ) -> impl Future< - Item = Result>, ServerStartError>, + Item = Result< + (HashMap>, Addr), + ServerStartError, + >, Error = TurnServiceErr, > { + let graceful_shutdown = + GracefulShutdown::new(conf.shutdown.timeout).start(); let config = conf.clone(); if let Some(static_specs_path) = config.server.static_specs_path.clone() { Either::A( @@ -104,13 +113,19 @@ pub fn start_static_rooms( ) .unwrap() }); + graceful_shutdown.do_send(shutdown::Subscribe( + shutdown::Subscriber { + addr: room.clone().recipient(), + priority: shutdown::Priority(2), + }, + )); rooms.insert(room_id, room); } - Ok(rooms) + Ok((rooms, graceful_shutdown)) }), ) } else { - Either::B(futures::future::ok(Ok(HashMap::new()))) + Either::B(futures::future::ok(Ok((HashMap::new(), graceful_shutdown)))) } } diff --git a/src/main.rs b/src/main.rs index 056f4ad1a..b48d6a812 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,11 +1,10 @@ -use actix::Actor; use failure::Error; use futures::future::{Future, IntoFuture as _}; use medea::{ - api::client::server::{self, Server}, + api::client::server::Server, conf::Conf, log::{self, prelude::*}, - shutdown::{self, GracefulShutdown}, + shutdown, signalling::room_repo::RoomsRepository, start_static_rooms, }; @@ -22,13 +21,12 @@ fn main() -> Result<(), Error> { actix::run(|| { start_static_rooms(&config) .map_err(|e| error!("Turn: {:?}", e)) - .map(|res| { - let graceful_shutdown = - GracefulShutdown::new(config.shutdown.timeout).start(); + .map(Result::unwrap) + .map(move |(res, graceful_shutdown)| { (res, graceful_shutdown, config) }) .map(|(res, graceful_shutdown, config)| { - let rooms = res.unwrap(); + let rooms = res; info!( "Loaded rooms: {:?}", rooms.iter().map(|(id, _)| &id.0).collect::>() diff --git a/src/signalling/room.rs b/src/signalling/room.rs index c41d45ed2..fb18a43cf 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -38,7 +38,6 @@ use crate::{ }, turn::BoxedTurnAuthService, }; -use futures::future::Either; /// Ergonomic type alias for using [`ActorFuture`] for [`Room`]. pub type ActFuture = From 9cbb66cdba38f5de9a56fdd4709159f55db107c6 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 19 Jul 2019 15:46:09 +0300 Subject: [PATCH 388/735] Add unsub from graceful shutdown when room deleted --- src/main.rs | 5 +---- src/signalling/room_service.rs | 6 ++++++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index e0310ce90..532f3862a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,10 +5,7 @@ use failure::Error; use futures::future::Future; use hashbrown::HashMap; use medea::{ - api::{ - client::{self, server::Server}, - control::grpc, - }, + api::{client::server::Server, control::grpc}, conf::Conf, log::{self, prelude::*}, shutdown::{self, GracefulShutdown}, diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index 7a9dc936f..017ab6858 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -199,6 +199,12 @@ impl Handler for RoomService { ctx: &mut Self::Context, ) -> Self::Result { if let Some(room) = self.room_repo.get(&msg.0) { + self.graceful_shutdown.do_send(shutdown::Unsubscribe( + shutdown::Subscriber { + priority: shutdown::Priority(2), + addr: room.clone().recipient(), + }, + )); let rooms = self.room_repo.clone(); ctx.spawn(wrap_future( room.send(Close) From 8526bf5de577af34446463b2186d52c986bf6eb8 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 19 Jul 2019 15:54:58 +0300 Subject: [PATCH 389/735] Add graceful shutdown for gRPC server --- src/api/control/grpc/server.rs | 26 +++++++++++++++++++++++++- src/main.rs | 9 +++++++-- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index b23d98577..293cd1204 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -5,7 +5,10 @@ use std::{collections::HashMap, convert::TryFrom, sync::Arc}; -use actix::{Actor, Addr, Arbiter, Context, MailboxError}; +use actix::{ + Actor, Addr, Arbiter, Context, Handler, MailboxError, ResponseActFuture, + WrapFuture as _, +}; use failure::Fail; use futures::future::{self, Either, Future}; use grpcio::{Environment, RpcContext, Server, ServerBuilder, UnarySink}; @@ -39,6 +42,7 @@ use crate::{ }; use super::protos::control_grpc::{create_control_api, ControlApi}; +use crate::shutdown::ShutdownGracefully; #[derive(Debug, Fail)] enum ControlApiError { @@ -592,6 +596,26 @@ impl Actor for GrpcServer { } } +impl Handler for GrpcServer { + type Result = ResponseActFuture; + + fn handle( + &mut self, + _: ShutdownGracefully, + _: &mut Self::Context, + ) -> Self::Result { + info!( + "gRPC server received ShutdownGracefully message so shutting down.", + ); + Box::new( + self.server + .shutdown() + .map_err(|e| warn!("{:?}", e)) + .into_actor(self), + ) + } +} + /// Run gRPC server in actix actor. pub fn run(room_repo: Addr, app: AppContext) -> Addr { let bind_ip = app.config.grpc.bind_ip.to_string(); diff --git a/src/main.rs b/src/main.rs index 532f3862a..cb09a98c9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -64,9 +64,14 @@ fn main() -> Result<(), Error> { .map(move |_| { let grpc_addr = grpc::server::run(room_service, app_context); + graceful_shutdown.do_send(shutdown::Subscribe( + shutdown::Subscriber { + priority: shutdown::Priority(1), + addr: grpc_addr.clone().recipient(), + }, + )); grpc_addr_clone.set(Some(grpc_addr)); - }) - .map(move |_| { + let server = Server::run(room_repo, config).unwrap(); graceful_shutdown.do_send(shutdown::Subscribe( shutdown::Subscriber { From 1a3a014d15080664b5d1772953216968d6603cd1 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 19 Jul 2019 16:51:14 +0300 Subject: [PATCH 390/735] Make credentials optional --- src/api/control/member.rs | 19 ++++++++++++++++++- src/bin/client.rs | 2 +- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/api/control/member.rs b/src/api/control/member.rs index 5f31bc67c..fdf7e2daa 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -17,6 +17,9 @@ use crate::api::control::{ }; use super::{pipeline::Pipeline, Element, TryFromElementError}; +use rand::{distributions::Alphanumeric, Rng}; + +const MEMBER_CREDENTIALS_LEN: usize = 32; macro_attr! { /// ID of [`Member`]. @@ -87,6 +90,13 @@ impl MemberSpec { } } +fn generate_member_credentials() -> String { + rand::thread_rng() + .sample_iter(&Alphanumeric) + .take(MEMBER_CREDENTIALS_LEN) + .collect() +} + impl TryFrom<&MemberProto> for MemberSpec { type Error = TryFromProtobufError; @@ -99,10 +109,17 @@ impl TryFrom<&MemberProto> for MemberSpec { } let pipeline = Pipeline::new(pipeline); + let proto_credentials = value.get_credentials(); + let credentials = if proto_credentials.is_empty() { + generate_member_credentials() + } else { + proto_credentials.to_string() + }; + // Credentials here maybe absent. Ok(Self { pipeline, - credentials: value.get_credentials().to_string(), + credentials, }) } } diff --git a/src/bin/client.rs b/src/bin/client.rs index 98939d305..3e377f321 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -48,7 +48,7 @@ fn create_room(client: &ControlApiClient) { let mut publisher_pipeline = HashMap::new(); publisher_pipeline.insert("publish".to_string(), publish_endpoint_element); publisher.set_pipeline(publisher_pipeline); - publisher.set_credentials("test".to_string()); + // publisher.set_credentials("test".to_string()); let mut publisher_member_element = Room_Element::new(); publisher_member_element.set_member(publisher); From b2aa05caf467ec8c4382fb980bc21567bf90b360 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 19 Jul 2019 16:54:41 +0300 Subject: [PATCH 391/735] Delete crutch for gRPC server existence --- src/api/control/grpc/server.rs | 5 ----- src/main.rs | 8 -------- 2 files changed, 13 deletions(-) diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index 293cd1204..4796b9006 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -589,11 +589,6 @@ impl Actor for GrpcServer { self.server.start(); debug!("gRPC server started."); } - - fn stopped(&mut self, _ctx: &mut Self::Context) { - debug!("Shutdown gRPC."); - self.server.shutdown().wait().unwrap(); - } } impl Handler for GrpcServer { diff --git a/src/main.rs b/src/main.rs index cb09a98c9..35768cb1a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,3 @@ -use std::{cell::Cell, rc::Rc}; - use actix::Actor; use failure::Error; use futures::future::Future; @@ -26,11 +24,6 @@ fn main() -> Result<(), Error> { let config = Conf::parse()?; info!("{:?}", config); - // This is crutch for existence of gRPC server throughout the all app's - // lifetime. - let grpc_addr = Rc::new(Cell::new(None)); - let grpc_addr_clone = Rc::clone(&grpc_addr); - actix::run(move || { new_turn_auth_service(&config.turn) .map_err(move |e| error!("{:?}", e)) @@ -70,7 +63,6 @@ fn main() -> Result<(), Error> { addr: grpc_addr.clone().recipient(), }, )); - grpc_addr_clone.set(Some(grpc_addr)); let server = Server::run(room_repo, config).unwrap(); graceful_shutdown.do_send(shutdown::Subscribe( From 5ebace2a3c3d3013a322e45e5c2200a1dd74117b Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 19 Jul 2019 17:05:23 +0300 Subject: [PATCH 392/735] Fix test --- src/api/client/server.rs | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/src/api/client/server.rs b/src/api/client/server.rs index 43a7ef7fc..8eb1463e9 100644 --- a/src/api/client/server.rs +++ b/src/api/client/server.rs @@ -145,35 +145,30 @@ mod test { use futures::{future::IntoFuture as _, sink::Sink as _, Stream as _}; use crate::{ - api::control::Member, conf::Conf, media::create_peers, - signalling::Room, turn::new_turn_auth_service_mock, + api::control, conf::Conf, signalling::Room, + turn::new_turn_auth_service_mock, }; use super::*; /// Creates [`RoomsRepository`] for tests filled with a single [`Room`]. fn room(conf: Rpc) -> RoomsRepository { - let members = hashmap! { - 1 => Member{ - id: 1, - credentials: "caller_credentials".into(), - ice_user: None - }, - 2 => Member{ - id: 2, - credentials: "responder_credentials".into(), - ice_user: None - }, - }; - let room = Room::new( - 1, - members, - create_peers(1, 2), + let room_spec = + control::load_from_yaml_file("tests/specs/pub_sub_video_call.yml") + .unwrap(); + + let room_id = room_spec.id.clone(); + let client_room = Room::new( + &room_spec, conf.reconnect_timeout, new_turn_auth_service_mock(), ) + .unwrap() .start(); - let rooms = hashmap! {1 => room}; + let rooms = hashmap! { + room_id => client_room, + }; + RoomsRepository::new(rooms) } @@ -203,7 +198,8 @@ mod test { }; let mut server = ws_server(conf.clone()); - let socket = server.ws_at("/ws/1/1/caller_credentials").unwrap(); + let socket = + server.ws_at("/ws/pub-sub-video-call/caller/test").unwrap(); server .block_on( From 2671aa80d45875928d94d7de81241d72463f97cb Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 19 Jul 2019 19:48:52 +0300 Subject: [PATCH 393/735] Move grpc's generated protos into sub-crate (this commit breaks building) --- Cargo.lock | 10 + Cargo.toml | 2 + build.rs | 5 +- proto/grpc/Cargo.toml | 14 + .../grpc/protos => proto/grpc}/control.proto | 0 proto/grpc/src/control.rs | 5966 +++++++++++++++++ proto/grpc/src/control_grpc.rs | 155 + proto/grpc/src/lib.rs | 2 + src/api/control/endpoints/mod.rs | 2 +- .../control/endpoints/webrtc_play_endpoint.rs | 2 +- .../endpoints/webrtc_publish_endpoint.rs | 2 +- src/api/control/grpc/mod.rs | 1 - src/api/control/grpc/protos/mod.rs | 11 - src/api/control/grpc/server.rs | 12 +- src/api/control/member.rs | 2 +- src/api/control/room.rs | 3 +- src/api/error_codes.rs | 5 +- src/lib.rs | 16 +- .../endpoints/webrtc/play_endpoint.rs | 9 +- .../endpoints/webrtc/publish_endpoint.rs | 8 +- src/signalling/elements/member.rs | 6 +- src/signalling/room.rs | 8 +- src/signalling/room_service.rs | 2 +- 23 files changed, 6194 insertions(+), 49 deletions(-) create mode 100644 proto/grpc/Cargo.toml rename {src/api/control/grpc/protos => proto/grpc}/control.proto (100%) create mode 100644 proto/grpc/src/control.rs create mode 100644 proto/grpc/src/control_grpc.rs create mode 100644 proto/grpc/src/lib.rs delete mode 100644 src/api/control/grpc/protos/mod.rs diff --git a/Cargo.lock b/Cargo.lock index bb2c42a9a..566286c92 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1157,6 +1157,7 @@ dependencies = [ "humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "macro-attr 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "medea-client-api-proto 0.1.0-dev", + "medea-grpc-proto 0.1.0-dev", "medea-macro 0.1.0-dev", "newtype_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.7.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1191,6 +1192,15 @@ dependencies = [ "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "medea-grpc-proto" +version = "0.1.0-dev" +dependencies = [ + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", + "grpcio 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf 2.7.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "medea-macro" version = "0.1.0-dev" diff --git a/Cargo.toml b/Cargo.toml index f8bd1c829..303737117 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,6 +15,7 @@ members = [ "crates/medea-macro", "jason", "proto/client-api", + "proto/grpc", ] [profile.release] @@ -38,6 +39,7 @@ hashbrown = "0.1" humantime = "1.2" macro-attr = "0.2" medea-client-api-proto = { path = "proto/client-api", features = ["medea"] } +medea-grpc-proto = { path = "proto/grpc" } medea-macro = { path = "crates/medea-macro" } newtype_derive = "0.1" protobuf = "2.7" diff --git a/build.rs b/build.rs index a5f03f581..50c6e4a00 100644 --- a/build.rs +++ b/build.rs @@ -1,10 +1,11 @@ fn main() { - let proto_root = "src/api/control/grpc/protos"; + let proto_root = "proto/grpc"; + let proto_output = "proto/grpc/src"; println!("cargo:rerun-if-changed={}", proto_root); protoc_grpcio::compile_grpc_protos( &["control.proto"], &[proto_root], - &proto_root, + &proto_output, ) .expect("Failed to compile gRPC definitions!"); } diff --git a/proto/grpc/Cargo.toml b/proto/grpc/Cargo.toml new file mode 100644 index 000000000..c024b7625 --- /dev/null +++ b/proto/grpc/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "medea-grpc-proto" +version = "0.1.0-dev" +edition = "2018" +description = "Client API protocol implementation for Medea media server" +authors = ["Instrumentisto Team "] +homepage = "https://github.com/instrumentisto/medea" +readme = "README.md" +repository = "https://github.com/instrumentisto/medea" + +[dependencies] +grpcio = "0.4" +futures = "0.1" +protobuf = "2.7" diff --git a/src/api/control/grpc/protos/control.proto b/proto/grpc/control.proto similarity index 100% rename from src/api/control/grpc/protos/control.proto rename to proto/grpc/control.proto diff --git a/proto/grpc/src/control.rs b/proto/grpc/src/control.rs new file mode 100644 index 000000000..c6ee0063d --- /dev/null +++ b/proto/grpc/src/control.rs @@ -0,0 +1,5966 @@ +// This file is generated by rust-protobuf 2.7.0. Do not edit +// @generated + +// https://github.com/Manishearth/rust-clippy/issues/702 +#![allow(unknown_lints)] +#![allow(clippy::all)] + +#![cfg_attr(rustfmt, rustfmt_skip)] + +#![allow(box_pointers)] +#![allow(dead_code)] +#![allow(missing_docs)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] +#![allow(non_upper_case_globals)] +#![allow(trivial_casts)] +#![allow(unsafe_code)] +#![allow(unused_imports)] +#![allow(unused_results)] +//! Generated file from `control.proto` + +use protobuf::Message as Message_imported_for_functions; +use protobuf::ProtobufEnum as ProtobufEnum_imported_for_functions; + +/// Generated files are compatible only with the same version +/// of protobuf runtime. +const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_7_0; + +#[derive(PartialEq,Clone,Default)] +pub struct CreateRequest { + // message fields + pub id: ::std::string::String, + // message oneof groups + pub el: ::std::option::Option, + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a CreateRequest { + fn default() -> &'a CreateRequest { + ::default_instance() + } +} + +#[derive(Clone,PartialEq,Debug)] +pub enum CreateRequest_oneof_el { + hub(Hub), + file_recorder(FileRecorder), + member(Member), + relay(Relay), + room(Room), + webrtc_play(WebRtcPlayEndpoint), + webrtc_pub(WebRtcPublishEndpoint), +} + +impl CreateRequest { + pub fn new() -> CreateRequest { + ::std::default::Default::default() + } + + // string id = 1; + + + pub fn get_id(&self) -> &str { + &self.id + } + pub fn clear_id(&mut self) { + self.id.clear(); + } + + // Param is passed by value, moved + pub fn set_id(&mut self, v: ::std::string::String) { + self.id = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_id(&mut self) -> &mut ::std::string::String { + &mut self.id + } + + // Take field + pub fn take_id(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.id, ::std::string::String::new()) + } + + // .medea.Hub hub = 2; + + + pub fn get_hub(&self) -> &Hub { + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::hub(ref v)) => v, + _ => Hub::default_instance(), + } + } + pub fn clear_hub(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_hub(&self) -> bool { + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::hub(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_hub(&mut self, v: Hub) { + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::hub(v)) + } + + // Mutable pointer to the field. + pub fn mut_hub(&mut self) -> &mut Hub { + if let ::std::option::Option::Some(CreateRequest_oneof_el::hub(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::hub(Hub::new())); + } + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::hub(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_hub(&mut self) -> Hub { + if self.has_hub() { + match self.el.take() { + ::std::option::Option::Some(CreateRequest_oneof_el::hub(v)) => v, + _ => panic!(), + } + } else { + Hub::new() + } + } + + // .medea.FileRecorder file_recorder = 3; + + + pub fn get_file_recorder(&self) -> &FileRecorder { + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::file_recorder(ref v)) => v, + _ => FileRecorder::default_instance(), + } + } + pub fn clear_file_recorder(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_file_recorder(&self) -> bool { + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::file_recorder(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_file_recorder(&mut self, v: FileRecorder) { + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::file_recorder(v)) + } + + // Mutable pointer to the field. + pub fn mut_file_recorder(&mut self) -> &mut FileRecorder { + if let ::std::option::Option::Some(CreateRequest_oneof_el::file_recorder(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::file_recorder(FileRecorder::new())); + } + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::file_recorder(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_file_recorder(&mut self) -> FileRecorder { + if self.has_file_recorder() { + match self.el.take() { + ::std::option::Option::Some(CreateRequest_oneof_el::file_recorder(v)) => v, + _ => panic!(), + } + } else { + FileRecorder::new() + } + } + + // .medea.Member member = 4; + + + pub fn get_member(&self) -> &Member { + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::member(ref v)) => v, + _ => Member::default_instance(), + } + } + pub fn clear_member(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_member(&self) -> bool { + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::member(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_member(&mut self, v: Member) { + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::member(v)) + } + + // Mutable pointer to the field. + pub fn mut_member(&mut self) -> &mut Member { + if let ::std::option::Option::Some(CreateRequest_oneof_el::member(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::member(Member::new())); + } + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::member(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_member(&mut self) -> Member { + if self.has_member() { + match self.el.take() { + ::std::option::Option::Some(CreateRequest_oneof_el::member(v)) => v, + _ => panic!(), + } + } else { + Member::new() + } + } + + // .medea.Relay relay = 5; + + + pub fn get_relay(&self) -> &Relay { + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::relay(ref v)) => v, + _ => Relay::default_instance(), + } + } + pub fn clear_relay(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_relay(&self) -> bool { + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::relay(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_relay(&mut self, v: Relay) { + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::relay(v)) + } + + // Mutable pointer to the field. + pub fn mut_relay(&mut self) -> &mut Relay { + if let ::std::option::Option::Some(CreateRequest_oneof_el::relay(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::relay(Relay::new())); + } + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::relay(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_relay(&mut self) -> Relay { + if self.has_relay() { + match self.el.take() { + ::std::option::Option::Some(CreateRequest_oneof_el::relay(v)) => v, + _ => panic!(), + } + } else { + Relay::new() + } + } + + // .medea.Room room = 6; + + + pub fn get_room(&self) -> &Room { + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::room(ref v)) => v, + _ => Room::default_instance(), + } + } + pub fn clear_room(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_room(&self) -> bool { + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::room(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_room(&mut self, v: Room) { + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::room(v)) + } + + // Mutable pointer to the field. + pub fn mut_room(&mut self) -> &mut Room { + if let ::std::option::Option::Some(CreateRequest_oneof_el::room(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::room(Room::new())); + } + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::room(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_room(&mut self) -> Room { + if self.has_room() { + match self.el.take() { + ::std::option::Option::Some(CreateRequest_oneof_el::room(v)) => v, + _ => panic!(), + } + } else { + Room::new() + } + } + + // .medea.WebRtcPlayEndpoint webrtc_play = 7; + + + pub fn get_webrtc_play(&self) -> &WebRtcPlayEndpoint { + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_play(ref v)) => v, + _ => WebRtcPlayEndpoint::default_instance(), + } + } + pub fn clear_webrtc_play(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_webrtc_play(&self) -> bool { + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_play(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_webrtc_play(&mut self, v: WebRtcPlayEndpoint) { + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_play(v)) + } + + // Mutable pointer to the field. + pub fn mut_webrtc_play(&mut self) -> &mut WebRtcPlayEndpoint { + if let ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_play(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_play(WebRtcPlayEndpoint::new())); + } + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_play(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_webrtc_play(&mut self) -> WebRtcPlayEndpoint { + if self.has_webrtc_play() { + match self.el.take() { + ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_play(v)) => v, + _ => panic!(), + } + } else { + WebRtcPlayEndpoint::new() + } + } + + // .medea.WebRtcPublishEndpoint webrtc_pub = 8; + + + pub fn get_webrtc_pub(&self) -> &WebRtcPublishEndpoint { + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_pub(ref v)) => v, + _ => WebRtcPublishEndpoint::default_instance(), + } + } + pub fn clear_webrtc_pub(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_webrtc_pub(&self) -> bool { + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_pub(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_webrtc_pub(&mut self, v: WebRtcPublishEndpoint) { + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_pub(v)) + } + + // Mutable pointer to the field. + pub fn mut_webrtc_pub(&mut self) -> &mut WebRtcPublishEndpoint { + if let ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_pub(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_pub(WebRtcPublishEndpoint::new())); + } + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_pub(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_webrtc_pub(&mut self) -> WebRtcPublishEndpoint { + if self.has_webrtc_pub() { + match self.el.take() { + ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_pub(v)) => v, + _ => panic!(), + } + } else { + WebRtcPublishEndpoint::new() + } + } +} + +impl ::protobuf::Message for CreateRequest { + fn is_initialized(&self) -> bool { + if let Some(CreateRequest_oneof_el::hub(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(CreateRequest_oneof_el::file_recorder(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(CreateRequest_oneof_el::member(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(CreateRequest_oneof_el::relay(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(CreateRequest_oneof_el::room(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(CreateRequest_oneof_el::webrtc_play(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(CreateRequest_oneof_el::webrtc_pub(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.id)?; + }, + 2 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::hub(is.read_message()?)); + }, + 3 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::file_recorder(is.read_message()?)); + }, + 4 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::member(is.read_message()?)); + }, + 5 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::relay(is.read_message()?)); + }, + 6 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::room(is.read_message()?)); + }, + 7 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_play(is.read_message()?)); + }, + 8 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_pub(is.read_message()?)); + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if !self.id.is_empty() { + my_size += ::protobuf::rt::string_size(1, &self.id); + } + if let ::std::option::Option::Some(ref v) = self.el { + match v { + &CreateRequest_oneof_el::hub(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &CreateRequest_oneof_el::file_recorder(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &CreateRequest_oneof_el::member(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &CreateRequest_oneof_el::relay(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &CreateRequest_oneof_el::room(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &CreateRequest_oneof_el::webrtc_play(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &CreateRequest_oneof_el::webrtc_pub(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + }; + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + if !self.id.is_empty() { + os.write_string(1, &self.id)?; + } + if let ::std::option::Option::Some(ref v) = self.el { + match v { + &CreateRequest_oneof_el::hub(ref v) => { + os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &CreateRequest_oneof_el::file_recorder(ref v) => { + os.write_tag(3, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &CreateRequest_oneof_el::member(ref v) => { + os.write_tag(4, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &CreateRequest_oneof_el::relay(ref v) => { + os.write_tag(5, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &CreateRequest_oneof_el::room(ref v) => { + os.write_tag(6, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &CreateRequest_oneof_el::webrtc_play(ref v) => { + os.write_tag(7, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &CreateRequest_oneof_el::webrtc_pub(ref v) => { + os.write_tag(8, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + }; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> CreateRequest { + CreateRequest::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "id", + |m: &CreateRequest| { &m.id }, + |m: &mut CreateRequest| { &mut m.id }, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Hub>( + "hub", + CreateRequest::has_hub, + CreateRequest::get_hub, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, FileRecorder>( + "file_recorder", + CreateRequest::has_file_recorder, + CreateRequest::get_file_recorder, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Member>( + "member", + CreateRequest::has_member, + CreateRequest::get_member, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Relay>( + "relay", + CreateRequest::has_relay, + CreateRequest::get_relay, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Room>( + "room", + CreateRequest::has_room, + CreateRequest::get_room, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPlayEndpoint>( + "webrtc_play", + CreateRequest::has_webrtc_play, + CreateRequest::get_webrtc_play, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPublishEndpoint>( + "webrtc_pub", + CreateRequest::has_webrtc_pub, + CreateRequest::get_webrtc_pub, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "CreateRequest", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static CreateRequest { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const CreateRequest, + }; + unsafe { + instance.get(CreateRequest::new) + } + } +} + +impl ::protobuf::Clear for CreateRequest { + fn clear(&mut self) { + self.id.clear(); + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for CreateRequest { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for CreateRequest { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct ApplyRequest { + // message fields + pub id: ::std::string::String, + pub policy: ApplyRequest_Policy, + // message oneof groups + pub el: ::std::option::Option, + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a ApplyRequest { + fn default() -> &'a ApplyRequest { + ::default_instance() + } +} + +#[derive(Clone,PartialEq,Debug)] +pub enum ApplyRequest_oneof_el { + hub(Hub), + file_recorder(FileRecorder), + member(Member), + relay(Relay), + room(Room), + webrtc_play(WebRtcPlayEndpoint), + webrtc_pub(WebRtcPublishEndpoint), +} + +impl ApplyRequest { + pub fn new() -> ApplyRequest { + ::std::default::Default::default() + } + + // string id = 1; + + + pub fn get_id(&self) -> &str { + &self.id + } + pub fn clear_id(&mut self) { + self.id.clear(); + } + + // Param is passed by value, moved + pub fn set_id(&mut self, v: ::std::string::String) { + self.id = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_id(&mut self) -> &mut ::std::string::String { + &mut self.id + } + + // Take field + pub fn take_id(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.id, ::std::string::String::new()) + } + + // .medea.Hub hub = 2; + + + pub fn get_hub(&self) -> &Hub { + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::hub(ref v)) => v, + _ => Hub::default_instance(), + } + } + pub fn clear_hub(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_hub(&self) -> bool { + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::hub(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_hub(&mut self, v: Hub) { + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::hub(v)) + } + + // Mutable pointer to the field. + pub fn mut_hub(&mut self) -> &mut Hub { + if let ::std::option::Option::Some(ApplyRequest_oneof_el::hub(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::hub(Hub::new())); + } + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::hub(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_hub(&mut self) -> Hub { + if self.has_hub() { + match self.el.take() { + ::std::option::Option::Some(ApplyRequest_oneof_el::hub(v)) => v, + _ => panic!(), + } + } else { + Hub::new() + } + } + + // .medea.FileRecorder file_recorder = 3; + + + pub fn get_file_recorder(&self) -> &FileRecorder { + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::file_recorder(ref v)) => v, + _ => FileRecorder::default_instance(), + } + } + pub fn clear_file_recorder(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_file_recorder(&self) -> bool { + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::file_recorder(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_file_recorder(&mut self, v: FileRecorder) { + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::file_recorder(v)) + } + + // Mutable pointer to the field. + pub fn mut_file_recorder(&mut self) -> &mut FileRecorder { + if let ::std::option::Option::Some(ApplyRequest_oneof_el::file_recorder(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::file_recorder(FileRecorder::new())); + } + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::file_recorder(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_file_recorder(&mut self) -> FileRecorder { + if self.has_file_recorder() { + match self.el.take() { + ::std::option::Option::Some(ApplyRequest_oneof_el::file_recorder(v)) => v, + _ => panic!(), + } + } else { + FileRecorder::new() + } + } + + // .medea.Member member = 4; + + + pub fn get_member(&self) -> &Member { + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::member(ref v)) => v, + _ => Member::default_instance(), + } + } + pub fn clear_member(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_member(&self) -> bool { + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::member(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_member(&mut self, v: Member) { + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::member(v)) + } + + // Mutable pointer to the field. + pub fn mut_member(&mut self) -> &mut Member { + if let ::std::option::Option::Some(ApplyRequest_oneof_el::member(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::member(Member::new())); + } + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::member(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_member(&mut self) -> Member { + if self.has_member() { + match self.el.take() { + ::std::option::Option::Some(ApplyRequest_oneof_el::member(v)) => v, + _ => panic!(), + } + } else { + Member::new() + } + } + + // .medea.Relay relay = 5; + + + pub fn get_relay(&self) -> &Relay { + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::relay(ref v)) => v, + _ => Relay::default_instance(), + } + } + pub fn clear_relay(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_relay(&self) -> bool { + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::relay(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_relay(&mut self, v: Relay) { + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::relay(v)) + } + + // Mutable pointer to the field. + pub fn mut_relay(&mut self) -> &mut Relay { + if let ::std::option::Option::Some(ApplyRequest_oneof_el::relay(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::relay(Relay::new())); + } + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::relay(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_relay(&mut self) -> Relay { + if self.has_relay() { + match self.el.take() { + ::std::option::Option::Some(ApplyRequest_oneof_el::relay(v)) => v, + _ => panic!(), + } + } else { + Relay::new() + } + } + + // .medea.Room room = 6; + + + pub fn get_room(&self) -> &Room { + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::room(ref v)) => v, + _ => Room::default_instance(), + } + } + pub fn clear_room(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_room(&self) -> bool { + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::room(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_room(&mut self, v: Room) { + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::room(v)) + } + + // Mutable pointer to the field. + pub fn mut_room(&mut self) -> &mut Room { + if let ::std::option::Option::Some(ApplyRequest_oneof_el::room(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::room(Room::new())); + } + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::room(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_room(&mut self) -> Room { + if self.has_room() { + match self.el.take() { + ::std::option::Option::Some(ApplyRequest_oneof_el::room(v)) => v, + _ => panic!(), + } + } else { + Room::new() + } + } + + // .medea.WebRtcPlayEndpoint webrtc_play = 7; + + + pub fn get_webrtc_play(&self) -> &WebRtcPlayEndpoint { + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(ref v)) => v, + _ => WebRtcPlayEndpoint::default_instance(), + } + } + pub fn clear_webrtc_play(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_webrtc_play(&self) -> bool { + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_webrtc_play(&mut self, v: WebRtcPlayEndpoint) { + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(v)) + } + + // Mutable pointer to the field. + pub fn mut_webrtc_play(&mut self) -> &mut WebRtcPlayEndpoint { + if let ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(WebRtcPlayEndpoint::new())); + } + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_webrtc_play(&mut self) -> WebRtcPlayEndpoint { + if self.has_webrtc_play() { + match self.el.take() { + ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(v)) => v, + _ => panic!(), + } + } else { + WebRtcPlayEndpoint::new() + } + } + + // .medea.WebRtcPublishEndpoint webrtc_pub = 8; + + + pub fn get_webrtc_pub(&self) -> &WebRtcPublishEndpoint { + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(ref v)) => v, + _ => WebRtcPublishEndpoint::default_instance(), + } + } + pub fn clear_webrtc_pub(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_webrtc_pub(&self) -> bool { + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_webrtc_pub(&mut self, v: WebRtcPublishEndpoint) { + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(v)) + } + + // Mutable pointer to the field. + pub fn mut_webrtc_pub(&mut self) -> &mut WebRtcPublishEndpoint { + if let ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(WebRtcPublishEndpoint::new())); + } + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_webrtc_pub(&mut self) -> WebRtcPublishEndpoint { + if self.has_webrtc_pub() { + match self.el.take() { + ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(v)) => v, + _ => panic!(), + } + } else { + WebRtcPublishEndpoint::new() + } + } + + // .medea.ApplyRequest.Policy policy = 9; + + + pub fn get_policy(&self) -> ApplyRequest_Policy { + self.policy + } + pub fn clear_policy(&mut self) { + self.policy = ApplyRequest_Policy::APPLY; + } + + // Param is passed by value, moved + pub fn set_policy(&mut self, v: ApplyRequest_Policy) { + self.policy = v; + } +} + +impl ::protobuf::Message for ApplyRequest { + fn is_initialized(&self) -> bool { + if let Some(ApplyRequest_oneof_el::hub(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(ApplyRequest_oneof_el::file_recorder(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(ApplyRequest_oneof_el::member(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(ApplyRequest_oneof_el::relay(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(ApplyRequest_oneof_el::room(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(ApplyRequest_oneof_el::webrtc_play(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(ApplyRequest_oneof_el::webrtc_pub(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.id)?; + }, + 2 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::hub(is.read_message()?)); + }, + 3 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::file_recorder(is.read_message()?)); + }, + 4 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::member(is.read_message()?)); + }, + 5 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::relay(is.read_message()?)); + }, + 6 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::room(is.read_message()?)); + }, + 7 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(is.read_message()?)); + }, + 8 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(is.read_message()?)); + }, + 9 => { + ::protobuf::rt::read_proto3_enum_with_unknown_fields_into(wire_type, is, &mut self.policy, 9, &mut self.unknown_fields)? + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if !self.id.is_empty() { + my_size += ::protobuf::rt::string_size(1, &self.id); + } + if self.policy != ApplyRequest_Policy::APPLY { + my_size += ::protobuf::rt::enum_size(9, self.policy); + } + if let ::std::option::Option::Some(ref v) = self.el { + match v { + &ApplyRequest_oneof_el::hub(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &ApplyRequest_oneof_el::file_recorder(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &ApplyRequest_oneof_el::member(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &ApplyRequest_oneof_el::relay(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &ApplyRequest_oneof_el::room(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &ApplyRequest_oneof_el::webrtc_play(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &ApplyRequest_oneof_el::webrtc_pub(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + }; + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + if !self.id.is_empty() { + os.write_string(1, &self.id)?; + } + if self.policy != ApplyRequest_Policy::APPLY { + os.write_enum(9, self.policy.value())?; + } + if let ::std::option::Option::Some(ref v) = self.el { + match v { + &ApplyRequest_oneof_el::hub(ref v) => { + os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &ApplyRequest_oneof_el::file_recorder(ref v) => { + os.write_tag(3, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &ApplyRequest_oneof_el::member(ref v) => { + os.write_tag(4, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &ApplyRequest_oneof_el::relay(ref v) => { + os.write_tag(5, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &ApplyRequest_oneof_el::room(ref v) => { + os.write_tag(6, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &ApplyRequest_oneof_el::webrtc_play(ref v) => { + os.write_tag(7, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &ApplyRequest_oneof_el::webrtc_pub(ref v) => { + os.write_tag(8, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + }; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> ApplyRequest { + ApplyRequest::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "id", + |m: &ApplyRequest| { &m.id }, + |m: &mut ApplyRequest| { &mut m.id }, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Hub>( + "hub", + ApplyRequest::has_hub, + ApplyRequest::get_hub, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, FileRecorder>( + "file_recorder", + ApplyRequest::has_file_recorder, + ApplyRequest::get_file_recorder, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Member>( + "member", + ApplyRequest::has_member, + ApplyRequest::get_member, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Relay>( + "relay", + ApplyRequest::has_relay, + ApplyRequest::get_relay, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Room>( + "room", + ApplyRequest::has_room, + ApplyRequest::get_room, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPlayEndpoint>( + "webrtc_play", + ApplyRequest::has_webrtc_play, + ApplyRequest::get_webrtc_play, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPublishEndpoint>( + "webrtc_pub", + ApplyRequest::has_webrtc_pub, + ApplyRequest::get_webrtc_pub, + )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeEnum>( + "policy", + |m: &ApplyRequest| { &m.policy }, + |m: &mut ApplyRequest| { &mut m.policy }, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "ApplyRequest", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static ApplyRequest { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ApplyRequest, + }; + unsafe { + instance.get(ApplyRequest::new) + } + } +} + +impl ::protobuf::Clear for ApplyRequest { + fn clear(&mut self) { + self.id.clear(); + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.policy = ApplyRequest_Policy::APPLY; + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for ApplyRequest { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for ApplyRequest { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(Clone,PartialEq,Eq,Debug,Hash)] +pub enum ApplyRequest_Policy { + APPLY = 0, + APPEND = 1, +} + +impl ::protobuf::ProtobufEnum for ApplyRequest_Policy { + fn value(&self) -> i32 { + *self as i32 + } + + fn from_i32(value: i32) -> ::std::option::Option { + match value { + 0 => ::std::option::Option::Some(ApplyRequest_Policy::APPLY), + 1 => ::std::option::Option::Some(ApplyRequest_Policy::APPEND), + _ => ::std::option::Option::None + } + } + + fn values() -> &'static [Self] { + static values: &'static [ApplyRequest_Policy] = &[ + ApplyRequest_Policy::APPLY, + ApplyRequest_Policy::APPEND, + ]; + values + } + + fn enum_descriptor_static() -> &'static ::protobuf::reflect::EnumDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::EnumDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::EnumDescriptor, + }; + unsafe { + descriptor.get(|| { + ::protobuf::reflect::EnumDescriptor::new("ApplyRequest_Policy", file_descriptor_proto()) + }) + } + } +} + +impl ::std::marker::Copy for ApplyRequest_Policy { +} + +impl ::std::default::Default for ApplyRequest_Policy { + fn default() -> Self { + ApplyRequest_Policy::APPLY + } +} + +impl ::protobuf::reflect::ProtobufValue for ApplyRequest_Policy { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Enum(self.descriptor()) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct IdRequest { + // message fields + pub id: ::protobuf::RepeatedField<::std::string::String>, + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a IdRequest { + fn default() -> &'a IdRequest { + ::default_instance() + } +} + +impl IdRequest { + pub fn new() -> IdRequest { + ::std::default::Default::default() + } + + // repeated string id = 1; + + + pub fn get_id(&self) -> &[::std::string::String] { + &self.id + } + pub fn clear_id(&mut self) { + self.id.clear(); + } + + // Param is passed by value, moved + pub fn set_id(&mut self, v: ::protobuf::RepeatedField<::std::string::String>) { + self.id = v; + } + + // Mutable pointer to the field. + pub fn mut_id(&mut self) -> &mut ::protobuf::RepeatedField<::std::string::String> { + &mut self.id + } + + // Take field + pub fn take_id(&mut self) -> ::protobuf::RepeatedField<::std::string::String> { + ::std::mem::replace(&mut self.id, ::protobuf::RepeatedField::new()) + } +} + +impl ::protobuf::Message for IdRequest { + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_repeated_string_into(wire_type, is, &mut self.id)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + for value in &self.id { + my_size += ::protobuf::rt::string_size(1, &value); + }; + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + for v in &self.id { + os.write_string(1, &v)?; + }; + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> IdRequest { + IdRequest::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "id", + |m: &IdRequest| { &m.id }, + |m: &mut IdRequest| { &mut m.id }, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "IdRequest", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static IdRequest { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const IdRequest, + }; + unsafe { + instance.get(IdRequest::new) + } + } +} + +impl ::protobuf::Clear for IdRequest { + fn clear(&mut self) { + self.id.clear(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for IdRequest { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for IdRequest { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct Response { + // message fields + pub sid: ::std::collections::HashMap<::std::string::String, ::std::string::String>, + pub error: ::protobuf::SingularPtrField, + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a Response { + fn default() -> &'a Response { + ::default_instance() + } +} + +impl Response { + pub fn new() -> Response { + ::std::default::Default::default() + } + + // repeated .medea.Response.SidEntry sid = 1; + + + pub fn get_sid(&self) -> &::std::collections::HashMap<::std::string::String, ::std::string::String> { + &self.sid + } + pub fn clear_sid(&mut self) { + self.sid.clear(); + } + + // Param is passed by value, moved + pub fn set_sid(&mut self, v: ::std::collections::HashMap<::std::string::String, ::std::string::String>) { + self.sid = v; + } + + // Mutable pointer to the field. + pub fn mut_sid(&mut self) -> &mut ::std::collections::HashMap<::std::string::String, ::std::string::String> { + &mut self.sid + } + + // Take field + pub fn take_sid(&mut self) -> ::std::collections::HashMap<::std::string::String, ::std::string::String> { + ::std::mem::replace(&mut self.sid, ::std::collections::HashMap::new()) + } + + // .medea.Error error = 2; + + + pub fn get_error(&self) -> &Error { + self.error.as_ref().unwrap_or_else(|| Error::default_instance()) + } + pub fn clear_error(&mut self) { + self.error.clear(); + } + + pub fn has_error(&self) -> bool { + self.error.is_some() + } + + // Param is passed by value, moved + pub fn set_error(&mut self, v: Error) { + self.error = ::protobuf::SingularPtrField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_error(&mut self) -> &mut Error { + if self.error.is_none() { + self.error.set_default(); + } + self.error.as_mut().unwrap() + } + + // Take field + pub fn take_error(&mut self) -> Error { + self.error.take().unwrap_or_else(|| Error::new()) + } +} + +impl ::protobuf::Message for Response { + fn is_initialized(&self) -> bool { + for v in &self.error { + if !v.is_initialized() { + return false; + } + }; + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_map_into::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeString>(wire_type, is, &mut self.sid)?; + }, + 2 => { + ::protobuf::rt::read_singular_message_into(wire_type, is, &mut self.error)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + my_size += ::protobuf::rt::compute_map_size::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeString>(1, &self.sid); + if let Some(ref v) = self.error.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + ::protobuf::rt::write_map_with_cached_sizes::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeString>(1, &self.sid, os)?; + if let Some(ref v) = self.error.as_ref() { + os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> Response { + Response::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_map_accessor::<_, ::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeString>( + "sid", + |m: &Response| { &m.sid }, + |m: &mut Response| { &mut m.sid }, + )); + fields.push(::protobuf::reflect::accessor::make_singular_ptr_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( + "error", + |m: &Response| { &m.error }, + |m: &mut Response| { &mut m.error }, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "Response", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static Response { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const Response, + }; + unsafe { + instance.get(Response::new) + } + } +} + +impl ::protobuf::Clear for Response { + fn clear(&mut self) { + self.sid.clear(); + self.error.clear(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for Response { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for Response { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct GetResponse { + // message fields + pub elements: ::std::collections::HashMap<::std::string::String, Element>, + pub error: ::protobuf::SingularPtrField, + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a GetResponse { + fn default() -> &'a GetResponse { + ::default_instance() + } +} + +impl GetResponse { + pub fn new() -> GetResponse { + ::std::default::Default::default() + } + + // repeated .medea.GetResponse.ElementsEntry elements = 1; + + + pub fn get_elements(&self) -> &::std::collections::HashMap<::std::string::String, Element> { + &self.elements + } + pub fn clear_elements(&mut self) { + self.elements.clear(); + } + + // Param is passed by value, moved + pub fn set_elements(&mut self, v: ::std::collections::HashMap<::std::string::String, Element>) { + self.elements = v; + } + + // Mutable pointer to the field. + pub fn mut_elements(&mut self) -> &mut ::std::collections::HashMap<::std::string::String, Element> { + &mut self.elements + } + + // Take field + pub fn take_elements(&mut self) -> ::std::collections::HashMap<::std::string::String, Element> { + ::std::mem::replace(&mut self.elements, ::std::collections::HashMap::new()) + } + + // .medea.Error error = 2; + + + pub fn get_error(&self) -> &Error { + self.error.as_ref().unwrap_or_else(|| Error::default_instance()) + } + pub fn clear_error(&mut self) { + self.error.clear(); + } + + pub fn has_error(&self) -> bool { + self.error.is_some() + } + + // Param is passed by value, moved + pub fn set_error(&mut self, v: Error) { + self.error = ::protobuf::SingularPtrField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_error(&mut self) -> &mut Error { + if self.error.is_none() { + self.error.set_default(); + } + self.error.as_mut().unwrap() + } + + // Take field + pub fn take_error(&mut self) -> Error { + self.error.take().unwrap_or_else(|| Error::new()) + } +} + +impl ::protobuf::Message for GetResponse { + fn is_initialized(&self) -> bool { + for v in &self.error { + if !v.is_initialized() { + return false; + } + }; + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_map_into::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(wire_type, is, &mut self.elements)?; + }, + 2 => { + ::protobuf::rt::read_singular_message_into(wire_type, is, &mut self.error)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + my_size += ::protobuf::rt::compute_map_size::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(1, &self.elements); + if let Some(ref v) = self.error.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + ::protobuf::rt::write_map_with_cached_sizes::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(1, &self.elements, os)?; + if let Some(ref v) = self.error.as_ref() { + os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> GetResponse { + GetResponse::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_map_accessor::<_, ::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>( + "elements", + |m: &GetResponse| { &m.elements }, + |m: &mut GetResponse| { &mut m.elements }, + )); + fields.push(::protobuf::reflect::accessor::make_singular_ptr_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( + "error", + |m: &GetResponse| { &m.error }, + |m: &mut GetResponse| { &mut m.error }, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "GetResponse", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static GetResponse { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const GetResponse, + }; + unsafe { + instance.get(GetResponse::new) + } + } +} + +impl ::protobuf::Clear for GetResponse { + fn clear(&mut self) { + self.elements.clear(); + self.error.clear(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for GetResponse { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for GetResponse { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct Error { + // message fields + pub code: u32, + pub text: ::std::string::String, + pub doc: ::std::string::String, + pub element: ::std::string::String, + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a Error { + fn default() -> &'a Error { + ::default_instance() + } +} + +impl Error { + pub fn new() -> Error { + ::std::default::Default::default() + } + + // uint32 code = 2; + + + pub fn get_code(&self) -> u32 { + self.code + } + pub fn clear_code(&mut self) { + self.code = 0; + } + + // Param is passed by value, moved + pub fn set_code(&mut self, v: u32) { + self.code = v; + } + + // string text = 3; + + + pub fn get_text(&self) -> &str { + &self.text + } + pub fn clear_text(&mut self) { + self.text.clear(); + } + + // Param is passed by value, moved + pub fn set_text(&mut self, v: ::std::string::String) { + self.text = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_text(&mut self) -> &mut ::std::string::String { + &mut self.text + } + + // Take field + pub fn take_text(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.text, ::std::string::String::new()) + } + + // string doc = 4; + + + pub fn get_doc(&self) -> &str { + &self.doc + } + pub fn clear_doc(&mut self) { + self.doc.clear(); + } + + // Param is passed by value, moved + pub fn set_doc(&mut self, v: ::std::string::String) { + self.doc = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_doc(&mut self) -> &mut ::std::string::String { + &mut self.doc + } + + // Take field + pub fn take_doc(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.doc, ::std::string::String::new()) + } + + // string element = 5; + + + pub fn get_element(&self) -> &str { + &self.element + } + pub fn clear_element(&mut self) { + self.element.clear(); + } + + // Param is passed by value, moved + pub fn set_element(&mut self, v: ::std::string::String) { + self.element = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_element(&mut self) -> &mut ::std::string::String { + &mut self.element + } + + // Take field + pub fn take_element(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.element, ::std::string::String::new()) + } +} + +impl ::protobuf::Message for Error { + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 2 => { + if wire_type != ::protobuf::wire_format::WireTypeVarint { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + let tmp = is.read_uint32()?; + self.code = tmp; + }, + 3 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.text)?; + }, + 4 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.doc)?; + }, + 5 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.element)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if self.code != 0 { + my_size += ::protobuf::rt::value_size(2, self.code, ::protobuf::wire_format::WireTypeVarint); + } + if !self.text.is_empty() { + my_size += ::protobuf::rt::string_size(3, &self.text); + } + if !self.doc.is_empty() { + my_size += ::protobuf::rt::string_size(4, &self.doc); + } + if !self.element.is_empty() { + my_size += ::protobuf::rt::string_size(5, &self.element); + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + if self.code != 0 { + os.write_uint32(2, self.code)?; + } + if !self.text.is_empty() { + os.write_string(3, &self.text)?; + } + if !self.doc.is_empty() { + os.write_string(4, &self.doc)?; + } + if !self.element.is_empty() { + os.write_string(5, &self.element)?; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> Error { + Error::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeUint32>( + "code", + |m: &Error| { &m.code }, + |m: &mut Error| { &mut m.code }, + )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "text", + |m: &Error| { &m.text }, + |m: &mut Error| { &mut m.text }, + )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "doc", + |m: &Error| { &m.doc }, + |m: &mut Error| { &mut m.doc }, + )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "element", + |m: &Error| { &m.element }, + |m: &mut Error| { &mut m.element }, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "Error", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static Error { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const Error, + }; + unsafe { + instance.get(Error::new) + } + } +} + +impl ::protobuf::Clear for Error { + fn clear(&mut self) { + self.code = 0; + self.text.clear(); + self.doc.clear(); + self.element.clear(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for Error { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for Error { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct Element { + // message oneof groups + pub el: ::std::option::Option, + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a Element { + fn default() -> &'a Element { + ::default_instance() + } +} + +#[derive(Clone,PartialEq,Debug)] +pub enum Element_oneof_el { + hub(Hub), + file_recorder(FileRecorder), + member(Member), + relay(Relay), + room(Room), + webrtc_play(WebRtcPlayEndpoint), + webrtc_pub(WebRtcPublishEndpoint), +} + +impl Element { + pub fn new() -> Element { + ::std::default::Default::default() + } + + // .medea.Hub hub = 2; + + + pub fn get_hub(&self) -> &Hub { + match self.el { + ::std::option::Option::Some(Element_oneof_el::hub(ref v)) => v, + _ => Hub::default_instance(), + } + } + pub fn clear_hub(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_hub(&self) -> bool { + match self.el { + ::std::option::Option::Some(Element_oneof_el::hub(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_hub(&mut self, v: Hub) { + self.el = ::std::option::Option::Some(Element_oneof_el::hub(v)) + } + + // Mutable pointer to the field. + pub fn mut_hub(&mut self) -> &mut Hub { + if let ::std::option::Option::Some(Element_oneof_el::hub(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Element_oneof_el::hub(Hub::new())); + } + match self.el { + ::std::option::Option::Some(Element_oneof_el::hub(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_hub(&mut self) -> Hub { + if self.has_hub() { + match self.el.take() { + ::std::option::Option::Some(Element_oneof_el::hub(v)) => v, + _ => panic!(), + } + } else { + Hub::new() + } + } + + // .medea.FileRecorder file_recorder = 3; + + + pub fn get_file_recorder(&self) -> &FileRecorder { + match self.el { + ::std::option::Option::Some(Element_oneof_el::file_recorder(ref v)) => v, + _ => FileRecorder::default_instance(), + } + } + pub fn clear_file_recorder(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_file_recorder(&self) -> bool { + match self.el { + ::std::option::Option::Some(Element_oneof_el::file_recorder(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_file_recorder(&mut self, v: FileRecorder) { + self.el = ::std::option::Option::Some(Element_oneof_el::file_recorder(v)) + } + + // Mutable pointer to the field. + pub fn mut_file_recorder(&mut self) -> &mut FileRecorder { + if let ::std::option::Option::Some(Element_oneof_el::file_recorder(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Element_oneof_el::file_recorder(FileRecorder::new())); + } + match self.el { + ::std::option::Option::Some(Element_oneof_el::file_recorder(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_file_recorder(&mut self) -> FileRecorder { + if self.has_file_recorder() { + match self.el.take() { + ::std::option::Option::Some(Element_oneof_el::file_recorder(v)) => v, + _ => panic!(), + } + } else { + FileRecorder::new() + } + } + + // .medea.Member member = 4; + + + pub fn get_member(&self) -> &Member { + match self.el { + ::std::option::Option::Some(Element_oneof_el::member(ref v)) => v, + _ => Member::default_instance(), + } + } + pub fn clear_member(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_member(&self) -> bool { + match self.el { + ::std::option::Option::Some(Element_oneof_el::member(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_member(&mut self, v: Member) { + self.el = ::std::option::Option::Some(Element_oneof_el::member(v)) + } + + // Mutable pointer to the field. + pub fn mut_member(&mut self) -> &mut Member { + if let ::std::option::Option::Some(Element_oneof_el::member(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Element_oneof_el::member(Member::new())); + } + match self.el { + ::std::option::Option::Some(Element_oneof_el::member(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_member(&mut self) -> Member { + if self.has_member() { + match self.el.take() { + ::std::option::Option::Some(Element_oneof_el::member(v)) => v, + _ => panic!(), + } + } else { + Member::new() + } + } + + // .medea.Relay relay = 5; + + + pub fn get_relay(&self) -> &Relay { + match self.el { + ::std::option::Option::Some(Element_oneof_el::relay(ref v)) => v, + _ => Relay::default_instance(), + } + } + pub fn clear_relay(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_relay(&self) -> bool { + match self.el { + ::std::option::Option::Some(Element_oneof_el::relay(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_relay(&mut self, v: Relay) { + self.el = ::std::option::Option::Some(Element_oneof_el::relay(v)) + } + + // Mutable pointer to the field. + pub fn mut_relay(&mut self) -> &mut Relay { + if let ::std::option::Option::Some(Element_oneof_el::relay(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Element_oneof_el::relay(Relay::new())); + } + match self.el { + ::std::option::Option::Some(Element_oneof_el::relay(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_relay(&mut self) -> Relay { + if self.has_relay() { + match self.el.take() { + ::std::option::Option::Some(Element_oneof_el::relay(v)) => v, + _ => panic!(), + } + } else { + Relay::new() + } + } + + // .medea.Room room = 6; + + + pub fn get_room(&self) -> &Room { + match self.el { + ::std::option::Option::Some(Element_oneof_el::room(ref v)) => v, + _ => Room::default_instance(), + } + } + pub fn clear_room(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_room(&self) -> bool { + match self.el { + ::std::option::Option::Some(Element_oneof_el::room(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_room(&mut self, v: Room) { + self.el = ::std::option::Option::Some(Element_oneof_el::room(v)) + } + + // Mutable pointer to the field. + pub fn mut_room(&mut self) -> &mut Room { + if let ::std::option::Option::Some(Element_oneof_el::room(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Element_oneof_el::room(Room::new())); + } + match self.el { + ::std::option::Option::Some(Element_oneof_el::room(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_room(&mut self) -> Room { + if self.has_room() { + match self.el.take() { + ::std::option::Option::Some(Element_oneof_el::room(v)) => v, + _ => panic!(), + } + } else { + Room::new() + } + } + + // .medea.WebRtcPlayEndpoint webrtc_play = 7; + + + pub fn get_webrtc_play(&self) -> &WebRtcPlayEndpoint { + match self.el { + ::std::option::Option::Some(Element_oneof_el::webrtc_play(ref v)) => v, + _ => WebRtcPlayEndpoint::default_instance(), + } + } + pub fn clear_webrtc_play(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_webrtc_play(&self) -> bool { + match self.el { + ::std::option::Option::Some(Element_oneof_el::webrtc_play(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_webrtc_play(&mut self, v: WebRtcPlayEndpoint) { + self.el = ::std::option::Option::Some(Element_oneof_el::webrtc_play(v)) + } + + // Mutable pointer to the field. + pub fn mut_webrtc_play(&mut self) -> &mut WebRtcPlayEndpoint { + if let ::std::option::Option::Some(Element_oneof_el::webrtc_play(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Element_oneof_el::webrtc_play(WebRtcPlayEndpoint::new())); + } + match self.el { + ::std::option::Option::Some(Element_oneof_el::webrtc_play(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_webrtc_play(&mut self) -> WebRtcPlayEndpoint { + if self.has_webrtc_play() { + match self.el.take() { + ::std::option::Option::Some(Element_oneof_el::webrtc_play(v)) => v, + _ => panic!(), + } + } else { + WebRtcPlayEndpoint::new() + } + } + + // .medea.WebRtcPublishEndpoint webrtc_pub = 8; + + + pub fn get_webrtc_pub(&self) -> &WebRtcPublishEndpoint { + match self.el { + ::std::option::Option::Some(Element_oneof_el::webrtc_pub(ref v)) => v, + _ => WebRtcPublishEndpoint::default_instance(), + } + } + pub fn clear_webrtc_pub(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_webrtc_pub(&self) -> bool { + match self.el { + ::std::option::Option::Some(Element_oneof_el::webrtc_pub(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_webrtc_pub(&mut self, v: WebRtcPublishEndpoint) { + self.el = ::std::option::Option::Some(Element_oneof_el::webrtc_pub(v)) + } + + // Mutable pointer to the field. + pub fn mut_webrtc_pub(&mut self) -> &mut WebRtcPublishEndpoint { + if let ::std::option::Option::Some(Element_oneof_el::webrtc_pub(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Element_oneof_el::webrtc_pub(WebRtcPublishEndpoint::new())); + } + match self.el { + ::std::option::Option::Some(Element_oneof_el::webrtc_pub(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_webrtc_pub(&mut self) -> WebRtcPublishEndpoint { + if self.has_webrtc_pub() { + match self.el.take() { + ::std::option::Option::Some(Element_oneof_el::webrtc_pub(v)) => v, + _ => panic!(), + } + } else { + WebRtcPublishEndpoint::new() + } + } +} + +impl ::protobuf::Message for Element { + fn is_initialized(&self) -> bool { + if let Some(Element_oneof_el::hub(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(Element_oneof_el::file_recorder(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(Element_oneof_el::member(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(Element_oneof_el::relay(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(Element_oneof_el::room(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(Element_oneof_el::webrtc_play(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(Element_oneof_el::webrtc_pub(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 2 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Element_oneof_el::hub(is.read_message()?)); + }, + 3 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Element_oneof_el::file_recorder(is.read_message()?)); + }, + 4 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Element_oneof_el::member(is.read_message()?)); + }, + 5 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Element_oneof_el::relay(is.read_message()?)); + }, + 6 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Element_oneof_el::room(is.read_message()?)); + }, + 7 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Element_oneof_el::webrtc_play(is.read_message()?)); + }, + 8 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Element_oneof_el::webrtc_pub(is.read_message()?)); + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if let ::std::option::Option::Some(ref v) = self.el { + match v { + &Element_oneof_el::hub(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &Element_oneof_el::file_recorder(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &Element_oneof_el::member(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &Element_oneof_el::relay(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &Element_oneof_el::room(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &Element_oneof_el::webrtc_play(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &Element_oneof_el::webrtc_pub(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + }; + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + if let ::std::option::Option::Some(ref v) = self.el { + match v { + &Element_oneof_el::hub(ref v) => { + os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &Element_oneof_el::file_recorder(ref v) => { + os.write_tag(3, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &Element_oneof_el::member(ref v) => { + os.write_tag(4, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &Element_oneof_el::relay(ref v) => { + os.write_tag(5, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &Element_oneof_el::room(ref v) => { + os.write_tag(6, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &Element_oneof_el::webrtc_play(ref v) => { + os.write_tag(7, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &Element_oneof_el::webrtc_pub(ref v) => { + os.write_tag(8, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + }; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> Element { + Element::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Hub>( + "hub", + Element::has_hub, + Element::get_hub, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, FileRecorder>( + "file_recorder", + Element::has_file_recorder, + Element::get_file_recorder, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Member>( + "member", + Element::has_member, + Element::get_member, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Relay>( + "relay", + Element::has_relay, + Element::get_relay, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Room>( + "room", + Element::has_room, + Element::get_room, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPlayEndpoint>( + "webrtc_play", + Element::has_webrtc_play, + Element::get_webrtc_play, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPublishEndpoint>( + "webrtc_pub", + Element::has_webrtc_pub, + Element::get_webrtc_pub, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "Element", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static Element { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const Element, + }; + unsafe { + instance.get(Element::new) + } + } +} + +impl ::protobuf::Clear for Element { + fn clear(&mut self) { + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for Element { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for Element { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct Room { + // message fields + pub pipeline: ::std::collections::HashMap<::std::string::String, Room_Element>, + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a Room { + fn default() -> &'a Room { + ::default_instance() + } +} + +impl Room { + pub fn new() -> Room { + ::std::default::Default::default() + } + + // repeated .medea.Room.PipelineEntry pipeline = 1; + + + pub fn get_pipeline(&self) -> &::std::collections::HashMap<::std::string::String, Room_Element> { + &self.pipeline + } + pub fn clear_pipeline(&mut self) { + self.pipeline.clear(); + } + + // Param is passed by value, moved + pub fn set_pipeline(&mut self, v: ::std::collections::HashMap<::std::string::String, Room_Element>) { + self.pipeline = v; + } + + // Mutable pointer to the field. + pub fn mut_pipeline(&mut self) -> &mut ::std::collections::HashMap<::std::string::String, Room_Element> { + &mut self.pipeline + } + + // Take field + pub fn take_pipeline(&mut self) -> ::std::collections::HashMap<::std::string::String, Room_Element> { + ::std::mem::replace(&mut self.pipeline, ::std::collections::HashMap::new()) + } +} + +impl ::protobuf::Message for Room { + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_map_into::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(wire_type, is, &mut self.pipeline)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + my_size += ::protobuf::rt::compute_map_size::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(1, &self.pipeline); + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + ::protobuf::rt::write_map_with_cached_sizes::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(1, &self.pipeline, os)?; + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> Room { + Room::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_map_accessor::<_, ::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>( + "pipeline", + |m: &Room| { &m.pipeline }, + |m: &mut Room| { &mut m.pipeline }, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "Room", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static Room { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const Room, + }; + unsafe { + instance.get(Room::new) + } + } +} + +impl ::protobuf::Clear for Room { + fn clear(&mut self) { + self.pipeline.clear(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for Room { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for Room { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct Room_Element { + // message oneof groups + pub el: ::std::option::Option, + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a Room_Element { + fn default() -> &'a Room_Element { + ::default_instance() + } +} + +#[derive(Clone,PartialEq,Debug)] +pub enum Room_Element_oneof_el { + hub(Hub), + file_recorder(FileRecorder), + member(Member), + relay(Relay), + webrtc_play(WebRtcPlayEndpoint), + webrtc_pub(WebRtcPublishEndpoint), +} + +impl Room_Element { + pub fn new() -> Room_Element { + ::std::default::Default::default() + } + + // .medea.Hub hub = 1; + + + pub fn get_hub(&self) -> &Hub { + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::hub(ref v)) => v, + _ => Hub::default_instance(), + } + } + pub fn clear_hub(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_hub(&self) -> bool { + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::hub(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_hub(&mut self, v: Hub) { + self.el = ::std::option::Option::Some(Room_Element_oneof_el::hub(v)) + } + + // Mutable pointer to the field. + pub fn mut_hub(&mut self) -> &mut Hub { + if let ::std::option::Option::Some(Room_Element_oneof_el::hub(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Room_Element_oneof_el::hub(Hub::new())); + } + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::hub(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_hub(&mut self) -> Hub { + if self.has_hub() { + match self.el.take() { + ::std::option::Option::Some(Room_Element_oneof_el::hub(v)) => v, + _ => panic!(), + } + } else { + Hub::new() + } + } + + // .medea.FileRecorder file_recorder = 2; + + + pub fn get_file_recorder(&self) -> &FileRecorder { + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::file_recorder(ref v)) => v, + _ => FileRecorder::default_instance(), + } + } + pub fn clear_file_recorder(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_file_recorder(&self) -> bool { + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::file_recorder(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_file_recorder(&mut self, v: FileRecorder) { + self.el = ::std::option::Option::Some(Room_Element_oneof_el::file_recorder(v)) + } + + // Mutable pointer to the field. + pub fn mut_file_recorder(&mut self) -> &mut FileRecorder { + if let ::std::option::Option::Some(Room_Element_oneof_el::file_recorder(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Room_Element_oneof_el::file_recorder(FileRecorder::new())); + } + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::file_recorder(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_file_recorder(&mut self) -> FileRecorder { + if self.has_file_recorder() { + match self.el.take() { + ::std::option::Option::Some(Room_Element_oneof_el::file_recorder(v)) => v, + _ => panic!(), + } + } else { + FileRecorder::new() + } + } + + // .medea.Member member = 3; + + + pub fn get_member(&self) -> &Member { + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::member(ref v)) => v, + _ => Member::default_instance(), + } + } + pub fn clear_member(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_member(&self) -> bool { + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::member(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_member(&mut self, v: Member) { + self.el = ::std::option::Option::Some(Room_Element_oneof_el::member(v)) + } + + // Mutable pointer to the field. + pub fn mut_member(&mut self) -> &mut Member { + if let ::std::option::Option::Some(Room_Element_oneof_el::member(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Room_Element_oneof_el::member(Member::new())); + } + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::member(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_member(&mut self) -> Member { + if self.has_member() { + match self.el.take() { + ::std::option::Option::Some(Room_Element_oneof_el::member(v)) => v, + _ => panic!(), + } + } else { + Member::new() + } + } + + // .medea.Relay relay = 4; + + + pub fn get_relay(&self) -> &Relay { + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::relay(ref v)) => v, + _ => Relay::default_instance(), + } + } + pub fn clear_relay(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_relay(&self) -> bool { + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::relay(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_relay(&mut self, v: Relay) { + self.el = ::std::option::Option::Some(Room_Element_oneof_el::relay(v)) + } + + // Mutable pointer to the field. + pub fn mut_relay(&mut self) -> &mut Relay { + if let ::std::option::Option::Some(Room_Element_oneof_el::relay(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Room_Element_oneof_el::relay(Relay::new())); + } + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::relay(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_relay(&mut self) -> Relay { + if self.has_relay() { + match self.el.take() { + ::std::option::Option::Some(Room_Element_oneof_el::relay(v)) => v, + _ => panic!(), + } + } else { + Relay::new() + } + } + + // .medea.WebRtcPlayEndpoint webrtc_play = 5; + + + pub fn get_webrtc_play(&self) -> &WebRtcPlayEndpoint { + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(ref v)) => v, + _ => WebRtcPlayEndpoint::default_instance(), + } + } + pub fn clear_webrtc_play(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_webrtc_play(&self) -> bool { + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_webrtc_play(&mut self, v: WebRtcPlayEndpoint) { + self.el = ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(v)) + } + + // Mutable pointer to the field. + pub fn mut_webrtc_play(&mut self) -> &mut WebRtcPlayEndpoint { + if let ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(WebRtcPlayEndpoint::new())); + } + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_webrtc_play(&mut self) -> WebRtcPlayEndpoint { + if self.has_webrtc_play() { + match self.el.take() { + ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(v)) => v, + _ => panic!(), + } + } else { + WebRtcPlayEndpoint::new() + } + } + + // .medea.WebRtcPublishEndpoint webrtc_pub = 6; + + + pub fn get_webrtc_pub(&self) -> &WebRtcPublishEndpoint { + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(ref v)) => v, + _ => WebRtcPublishEndpoint::default_instance(), + } + } + pub fn clear_webrtc_pub(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_webrtc_pub(&self) -> bool { + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_webrtc_pub(&mut self, v: WebRtcPublishEndpoint) { + self.el = ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(v)) + } + + // Mutable pointer to the field. + pub fn mut_webrtc_pub(&mut self) -> &mut WebRtcPublishEndpoint { + if let ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(WebRtcPublishEndpoint::new())); + } + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_webrtc_pub(&mut self) -> WebRtcPublishEndpoint { + if self.has_webrtc_pub() { + match self.el.take() { + ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(v)) => v, + _ => panic!(), + } + } else { + WebRtcPublishEndpoint::new() + } + } +} + +impl ::protobuf::Message for Room_Element { + fn is_initialized(&self) -> bool { + if let Some(Room_Element_oneof_el::hub(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(Room_Element_oneof_el::file_recorder(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(Room_Element_oneof_el::member(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(Room_Element_oneof_el::relay(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(Room_Element_oneof_el::webrtc_play(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(Room_Element_oneof_el::webrtc_pub(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Room_Element_oneof_el::hub(is.read_message()?)); + }, + 2 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Room_Element_oneof_el::file_recorder(is.read_message()?)); + }, + 3 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Room_Element_oneof_el::member(is.read_message()?)); + }, + 4 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Room_Element_oneof_el::relay(is.read_message()?)); + }, + 5 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(is.read_message()?)); + }, + 6 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(is.read_message()?)); + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if let ::std::option::Option::Some(ref v) = self.el { + match v { + &Room_Element_oneof_el::hub(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &Room_Element_oneof_el::file_recorder(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &Room_Element_oneof_el::member(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &Room_Element_oneof_el::relay(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &Room_Element_oneof_el::webrtc_play(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &Room_Element_oneof_el::webrtc_pub(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + }; + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + if let ::std::option::Option::Some(ref v) = self.el { + match v { + &Room_Element_oneof_el::hub(ref v) => { + os.write_tag(1, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &Room_Element_oneof_el::file_recorder(ref v) => { + os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &Room_Element_oneof_el::member(ref v) => { + os.write_tag(3, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &Room_Element_oneof_el::relay(ref v) => { + os.write_tag(4, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &Room_Element_oneof_el::webrtc_play(ref v) => { + os.write_tag(5, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &Room_Element_oneof_el::webrtc_pub(ref v) => { + os.write_tag(6, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + }; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> Room_Element { + Room_Element::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Hub>( + "hub", + Room_Element::has_hub, + Room_Element::get_hub, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, FileRecorder>( + "file_recorder", + Room_Element::has_file_recorder, + Room_Element::get_file_recorder, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Member>( + "member", + Room_Element::has_member, + Room_Element::get_member, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Relay>( + "relay", + Room_Element::has_relay, + Room_Element::get_relay, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPlayEndpoint>( + "webrtc_play", + Room_Element::has_webrtc_play, + Room_Element::get_webrtc_play, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPublishEndpoint>( + "webrtc_pub", + Room_Element::has_webrtc_pub, + Room_Element::get_webrtc_pub, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "Room_Element", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static Room_Element { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const Room_Element, + }; + unsafe { + instance.get(Room_Element::new) + } + } +} + +impl ::protobuf::Clear for Room_Element { + fn clear(&mut self) { + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for Room_Element { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for Room_Element { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct Member { + // message fields + pub on_join: ::std::string::String, + pub on_leave: ::std::string::String, + pub credentials: ::std::string::String, + pub pipeline: ::std::collections::HashMap<::std::string::String, Member_Element>, + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a Member { + fn default() -> &'a Member { + ::default_instance() + } +} + +impl Member { + pub fn new() -> Member { + ::std::default::Default::default() + } + + // string on_join = 1; + + + pub fn get_on_join(&self) -> &str { + &self.on_join + } + pub fn clear_on_join(&mut self) { + self.on_join.clear(); + } + + // Param is passed by value, moved + pub fn set_on_join(&mut self, v: ::std::string::String) { + self.on_join = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_on_join(&mut self) -> &mut ::std::string::String { + &mut self.on_join + } + + // Take field + pub fn take_on_join(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.on_join, ::std::string::String::new()) + } + + // string on_leave = 2; + + + pub fn get_on_leave(&self) -> &str { + &self.on_leave + } + pub fn clear_on_leave(&mut self) { + self.on_leave.clear(); + } + + // Param is passed by value, moved + pub fn set_on_leave(&mut self, v: ::std::string::String) { + self.on_leave = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_on_leave(&mut self) -> &mut ::std::string::String { + &mut self.on_leave + } + + // Take field + pub fn take_on_leave(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.on_leave, ::std::string::String::new()) + } + + // string credentials = 3; + + + pub fn get_credentials(&self) -> &str { + &self.credentials + } + pub fn clear_credentials(&mut self) { + self.credentials.clear(); + } + + // Param is passed by value, moved + pub fn set_credentials(&mut self, v: ::std::string::String) { + self.credentials = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_credentials(&mut self) -> &mut ::std::string::String { + &mut self.credentials + } + + // Take field + pub fn take_credentials(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.credentials, ::std::string::String::new()) + } + + // repeated .medea.Member.PipelineEntry pipeline = 4; + + + pub fn get_pipeline(&self) -> &::std::collections::HashMap<::std::string::String, Member_Element> { + &self.pipeline + } + pub fn clear_pipeline(&mut self) { + self.pipeline.clear(); + } + + // Param is passed by value, moved + pub fn set_pipeline(&mut self, v: ::std::collections::HashMap<::std::string::String, Member_Element>) { + self.pipeline = v; + } + + // Mutable pointer to the field. + pub fn mut_pipeline(&mut self) -> &mut ::std::collections::HashMap<::std::string::String, Member_Element> { + &mut self.pipeline + } + + // Take field + pub fn take_pipeline(&mut self) -> ::std::collections::HashMap<::std::string::String, Member_Element> { + ::std::mem::replace(&mut self.pipeline, ::std::collections::HashMap::new()) + } +} + +impl ::protobuf::Message for Member { + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.on_join)?; + }, + 2 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.on_leave)?; + }, + 3 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.credentials)?; + }, + 4 => { + ::protobuf::rt::read_map_into::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(wire_type, is, &mut self.pipeline)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if !self.on_join.is_empty() { + my_size += ::protobuf::rt::string_size(1, &self.on_join); + } + if !self.on_leave.is_empty() { + my_size += ::protobuf::rt::string_size(2, &self.on_leave); + } + if !self.credentials.is_empty() { + my_size += ::protobuf::rt::string_size(3, &self.credentials); + } + my_size += ::protobuf::rt::compute_map_size::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(4, &self.pipeline); + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + if !self.on_join.is_empty() { + os.write_string(1, &self.on_join)?; + } + if !self.on_leave.is_empty() { + os.write_string(2, &self.on_leave)?; + } + if !self.credentials.is_empty() { + os.write_string(3, &self.credentials)?; + } + ::protobuf::rt::write_map_with_cached_sizes::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(4, &self.pipeline, os)?; + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> Member { + Member::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "on_join", + |m: &Member| { &m.on_join }, + |m: &mut Member| { &mut m.on_join }, + )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "on_leave", + |m: &Member| { &m.on_leave }, + |m: &mut Member| { &mut m.on_leave }, + )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "credentials", + |m: &Member| { &m.credentials }, + |m: &mut Member| { &mut m.credentials }, + )); + fields.push(::protobuf::reflect::accessor::make_map_accessor::<_, ::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>( + "pipeline", + |m: &Member| { &m.pipeline }, + |m: &mut Member| { &mut m.pipeline }, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "Member", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static Member { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const Member, + }; + unsafe { + instance.get(Member::new) + } + } +} + +impl ::protobuf::Clear for Member { + fn clear(&mut self) { + self.on_join.clear(); + self.on_leave.clear(); + self.credentials.clear(); + self.pipeline.clear(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for Member { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for Member { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct Member_Element { + // message oneof groups + pub el: ::std::option::Option, + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a Member_Element { + fn default() -> &'a Member_Element { + ::default_instance() + } +} + +#[derive(Clone,PartialEq,Debug)] +pub enum Member_Element_oneof_el { + hub(Hub), + file_recorder(FileRecorder), + relay(Relay), + webrtc_play(WebRtcPlayEndpoint), + webrtc_pub(WebRtcPublishEndpoint), +} + +impl Member_Element { + pub fn new() -> Member_Element { + ::std::default::Default::default() + } + + // .medea.Hub hub = 1; + + + pub fn get_hub(&self) -> &Hub { + match self.el { + ::std::option::Option::Some(Member_Element_oneof_el::hub(ref v)) => v, + _ => Hub::default_instance(), + } + } + pub fn clear_hub(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_hub(&self) -> bool { + match self.el { + ::std::option::Option::Some(Member_Element_oneof_el::hub(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_hub(&mut self, v: Hub) { + self.el = ::std::option::Option::Some(Member_Element_oneof_el::hub(v)) + } + + // Mutable pointer to the field. + pub fn mut_hub(&mut self) -> &mut Hub { + if let ::std::option::Option::Some(Member_Element_oneof_el::hub(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Member_Element_oneof_el::hub(Hub::new())); + } + match self.el { + ::std::option::Option::Some(Member_Element_oneof_el::hub(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_hub(&mut self) -> Hub { + if self.has_hub() { + match self.el.take() { + ::std::option::Option::Some(Member_Element_oneof_el::hub(v)) => v, + _ => panic!(), + } + } else { + Hub::new() + } + } + + // .medea.FileRecorder file_recorder = 2; + + + pub fn get_file_recorder(&self) -> &FileRecorder { + match self.el { + ::std::option::Option::Some(Member_Element_oneof_el::file_recorder(ref v)) => v, + _ => FileRecorder::default_instance(), + } + } + pub fn clear_file_recorder(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_file_recorder(&self) -> bool { + match self.el { + ::std::option::Option::Some(Member_Element_oneof_el::file_recorder(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_file_recorder(&mut self, v: FileRecorder) { + self.el = ::std::option::Option::Some(Member_Element_oneof_el::file_recorder(v)) + } + + // Mutable pointer to the field. + pub fn mut_file_recorder(&mut self) -> &mut FileRecorder { + if let ::std::option::Option::Some(Member_Element_oneof_el::file_recorder(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Member_Element_oneof_el::file_recorder(FileRecorder::new())); + } + match self.el { + ::std::option::Option::Some(Member_Element_oneof_el::file_recorder(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_file_recorder(&mut self) -> FileRecorder { + if self.has_file_recorder() { + match self.el.take() { + ::std::option::Option::Some(Member_Element_oneof_el::file_recorder(v)) => v, + _ => panic!(), + } + } else { + FileRecorder::new() + } + } + + // .medea.Relay relay = 3; + + + pub fn get_relay(&self) -> &Relay { + match self.el { + ::std::option::Option::Some(Member_Element_oneof_el::relay(ref v)) => v, + _ => Relay::default_instance(), + } + } + pub fn clear_relay(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_relay(&self) -> bool { + match self.el { + ::std::option::Option::Some(Member_Element_oneof_el::relay(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_relay(&mut self, v: Relay) { + self.el = ::std::option::Option::Some(Member_Element_oneof_el::relay(v)) + } + + // Mutable pointer to the field. + pub fn mut_relay(&mut self) -> &mut Relay { + if let ::std::option::Option::Some(Member_Element_oneof_el::relay(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Member_Element_oneof_el::relay(Relay::new())); + } + match self.el { + ::std::option::Option::Some(Member_Element_oneof_el::relay(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_relay(&mut self) -> Relay { + if self.has_relay() { + match self.el.take() { + ::std::option::Option::Some(Member_Element_oneof_el::relay(v)) => v, + _ => panic!(), + } + } else { + Relay::new() + } + } + + // .medea.WebRtcPlayEndpoint webrtc_play = 4; + + + pub fn get_webrtc_play(&self) -> &WebRtcPlayEndpoint { + match self.el { + ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(ref v)) => v, + _ => WebRtcPlayEndpoint::default_instance(), + } + } + pub fn clear_webrtc_play(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_webrtc_play(&self) -> bool { + match self.el { + ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_webrtc_play(&mut self, v: WebRtcPlayEndpoint) { + self.el = ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(v)) + } + + // Mutable pointer to the field. + pub fn mut_webrtc_play(&mut self) -> &mut WebRtcPlayEndpoint { + if let ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(WebRtcPlayEndpoint::new())); + } + match self.el { + ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_webrtc_play(&mut self) -> WebRtcPlayEndpoint { + if self.has_webrtc_play() { + match self.el.take() { + ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(v)) => v, + _ => panic!(), + } + } else { + WebRtcPlayEndpoint::new() + } + } + + // .medea.WebRtcPublishEndpoint webrtc_pub = 5; + + + pub fn get_webrtc_pub(&self) -> &WebRtcPublishEndpoint { + match self.el { + ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(ref v)) => v, + _ => WebRtcPublishEndpoint::default_instance(), + } + } + pub fn clear_webrtc_pub(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_webrtc_pub(&self) -> bool { + match self.el { + ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_webrtc_pub(&mut self, v: WebRtcPublishEndpoint) { + self.el = ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(v)) + } + + // Mutable pointer to the field. + pub fn mut_webrtc_pub(&mut self) -> &mut WebRtcPublishEndpoint { + if let ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(WebRtcPublishEndpoint::new())); + } + match self.el { + ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_webrtc_pub(&mut self) -> WebRtcPublishEndpoint { + if self.has_webrtc_pub() { + match self.el.take() { + ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(v)) => v, + _ => panic!(), + } + } else { + WebRtcPublishEndpoint::new() + } + } +} + +impl ::protobuf::Message for Member_Element { + fn is_initialized(&self) -> bool { + if let Some(Member_Element_oneof_el::hub(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(Member_Element_oneof_el::file_recorder(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(Member_Element_oneof_el::relay(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(Member_Element_oneof_el::webrtc_play(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(Member_Element_oneof_el::webrtc_pub(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Member_Element_oneof_el::hub(is.read_message()?)); + }, + 2 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Member_Element_oneof_el::file_recorder(is.read_message()?)); + }, + 3 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Member_Element_oneof_el::relay(is.read_message()?)); + }, + 4 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(is.read_message()?)); + }, + 5 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(is.read_message()?)); + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if let ::std::option::Option::Some(ref v) = self.el { + match v { + &Member_Element_oneof_el::hub(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &Member_Element_oneof_el::file_recorder(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &Member_Element_oneof_el::relay(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &Member_Element_oneof_el::webrtc_play(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &Member_Element_oneof_el::webrtc_pub(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + }; + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + if let ::std::option::Option::Some(ref v) = self.el { + match v { + &Member_Element_oneof_el::hub(ref v) => { + os.write_tag(1, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &Member_Element_oneof_el::file_recorder(ref v) => { + os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &Member_Element_oneof_el::relay(ref v) => { + os.write_tag(3, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &Member_Element_oneof_el::webrtc_play(ref v) => { + os.write_tag(4, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &Member_Element_oneof_el::webrtc_pub(ref v) => { + os.write_tag(5, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + }; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> Member_Element { + Member_Element::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Hub>( + "hub", + Member_Element::has_hub, + Member_Element::get_hub, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, FileRecorder>( + "file_recorder", + Member_Element::has_file_recorder, + Member_Element::get_file_recorder, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Relay>( + "relay", + Member_Element::has_relay, + Member_Element::get_relay, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPlayEndpoint>( + "webrtc_play", + Member_Element::has_webrtc_play, + Member_Element::get_webrtc_play, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPublishEndpoint>( + "webrtc_pub", + Member_Element::has_webrtc_pub, + Member_Element::get_webrtc_pub, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "Member_Element", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static Member_Element { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const Member_Element, + }; + unsafe { + instance.get(Member_Element::new) + } + } +} + +impl ::protobuf::Clear for Member_Element { + fn clear(&mut self) { + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for Member_Element { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for Member_Element { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct WebRtcPublishEndpoint { + // message fields + pub p2p: WebRtcPublishEndpoint_P2P, + pub on_start: ::std::string::String, + pub on_stop: ::std::string::String, + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a WebRtcPublishEndpoint { + fn default() -> &'a WebRtcPublishEndpoint { + ::default_instance() + } +} + +impl WebRtcPublishEndpoint { + pub fn new() -> WebRtcPublishEndpoint { + ::std::default::Default::default() + } + + // .medea.WebRtcPublishEndpoint.P2P p2p = 1; + + + pub fn get_p2p(&self) -> WebRtcPublishEndpoint_P2P { + self.p2p + } + pub fn clear_p2p(&mut self) { + self.p2p = WebRtcPublishEndpoint_P2P::NEVER; + } + + // Param is passed by value, moved + pub fn set_p2p(&mut self, v: WebRtcPublishEndpoint_P2P) { + self.p2p = v; + } + + // string on_start = 3; + + + pub fn get_on_start(&self) -> &str { + &self.on_start + } + pub fn clear_on_start(&mut self) { + self.on_start.clear(); + } + + // Param is passed by value, moved + pub fn set_on_start(&mut self, v: ::std::string::String) { + self.on_start = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_on_start(&mut self) -> &mut ::std::string::String { + &mut self.on_start + } + + // Take field + pub fn take_on_start(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.on_start, ::std::string::String::new()) + } + + // string on_stop = 4; + + + pub fn get_on_stop(&self) -> &str { + &self.on_stop + } + pub fn clear_on_stop(&mut self) { + self.on_stop.clear(); + } + + // Param is passed by value, moved + pub fn set_on_stop(&mut self, v: ::std::string::String) { + self.on_stop = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_on_stop(&mut self) -> &mut ::std::string::String { + &mut self.on_stop + } + + // Take field + pub fn take_on_stop(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.on_stop, ::std::string::String::new()) + } +} + +impl ::protobuf::Message for WebRtcPublishEndpoint { + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_proto3_enum_with_unknown_fields_into(wire_type, is, &mut self.p2p, 1, &mut self.unknown_fields)? + }, + 3 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.on_start)?; + }, + 4 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.on_stop)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if self.p2p != WebRtcPublishEndpoint_P2P::NEVER { + my_size += ::protobuf::rt::enum_size(1, self.p2p); + } + if !self.on_start.is_empty() { + my_size += ::protobuf::rt::string_size(3, &self.on_start); + } + if !self.on_stop.is_empty() { + my_size += ::protobuf::rt::string_size(4, &self.on_stop); + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + if self.p2p != WebRtcPublishEndpoint_P2P::NEVER { + os.write_enum(1, self.p2p.value())?; + } + if !self.on_start.is_empty() { + os.write_string(3, &self.on_start)?; + } + if !self.on_stop.is_empty() { + os.write_string(4, &self.on_stop)?; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> WebRtcPublishEndpoint { + WebRtcPublishEndpoint::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeEnum>( + "p2p", + |m: &WebRtcPublishEndpoint| { &m.p2p }, + |m: &mut WebRtcPublishEndpoint| { &mut m.p2p }, + )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "on_start", + |m: &WebRtcPublishEndpoint| { &m.on_start }, + |m: &mut WebRtcPublishEndpoint| { &mut m.on_start }, + )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "on_stop", + |m: &WebRtcPublishEndpoint| { &m.on_stop }, + |m: &mut WebRtcPublishEndpoint| { &mut m.on_stop }, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "WebRtcPublishEndpoint", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static WebRtcPublishEndpoint { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const WebRtcPublishEndpoint, + }; + unsafe { + instance.get(WebRtcPublishEndpoint::new) + } + } +} + +impl ::protobuf::Clear for WebRtcPublishEndpoint { + fn clear(&mut self) { + self.p2p = WebRtcPublishEndpoint_P2P::NEVER; + self.on_start.clear(); + self.on_stop.clear(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for WebRtcPublishEndpoint { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for WebRtcPublishEndpoint { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(Clone,PartialEq,Eq,Debug,Hash)] +pub enum WebRtcPublishEndpoint_P2P { + NEVER = 0, + IF_POSSIBLE = 1, + ALWAYS = 2, +} + +impl ::protobuf::ProtobufEnum for WebRtcPublishEndpoint_P2P { + fn value(&self) -> i32 { + *self as i32 + } + + fn from_i32(value: i32) -> ::std::option::Option { + match value { + 0 => ::std::option::Option::Some(WebRtcPublishEndpoint_P2P::NEVER), + 1 => ::std::option::Option::Some(WebRtcPublishEndpoint_P2P::IF_POSSIBLE), + 2 => ::std::option::Option::Some(WebRtcPublishEndpoint_P2P::ALWAYS), + _ => ::std::option::Option::None + } + } + + fn values() -> &'static [Self] { + static values: &'static [WebRtcPublishEndpoint_P2P] = &[ + WebRtcPublishEndpoint_P2P::NEVER, + WebRtcPublishEndpoint_P2P::IF_POSSIBLE, + WebRtcPublishEndpoint_P2P::ALWAYS, + ]; + values + } + + fn enum_descriptor_static() -> &'static ::protobuf::reflect::EnumDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::EnumDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::EnumDescriptor, + }; + unsafe { + descriptor.get(|| { + ::protobuf::reflect::EnumDescriptor::new("WebRtcPublishEndpoint_P2P", file_descriptor_proto()) + }) + } + } +} + +impl ::std::marker::Copy for WebRtcPublishEndpoint_P2P { +} + +impl ::std::default::Default for WebRtcPublishEndpoint_P2P { + fn default() -> Self { + WebRtcPublishEndpoint_P2P::NEVER + } +} + +impl ::protobuf::reflect::ProtobufValue for WebRtcPublishEndpoint_P2P { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Enum(self.descriptor()) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct WebRtcPlayEndpoint { + // message fields + pub src: ::std::string::String, + pub on_start: ::std::string::String, + pub on_stop: ::std::string::String, + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a WebRtcPlayEndpoint { + fn default() -> &'a WebRtcPlayEndpoint { + ::default_instance() + } +} + +impl WebRtcPlayEndpoint { + pub fn new() -> WebRtcPlayEndpoint { + ::std::default::Default::default() + } + + // string src = 1; + + + pub fn get_src(&self) -> &str { + &self.src + } + pub fn clear_src(&mut self) { + self.src.clear(); + } + + // Param is passed by value, moved + pub fn set_src(&mut self, v: ::std::string::String) { + self.src = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_src(&mut self) -> &mut ::std::string::String { + &mut self.src + } + + // Take field + pub fn take_src(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.src, ::std::string::String::new()) + } + + // string on_start = 2; + + + pub fn get_on_start(&self) -> &str { + &self.on_start + } + pub fn clear_on_start(&mut self) { + self.on_start.clear(); + } + + // Param is passed by value, moved + pub fn set_on_start(&mut self, v: ::std::string::String) { + self.on_start = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_on_start(&mut self) -> &mut ::std::string::String { + &mut self.on_start + } + + // Take field + pub fn take_on_start(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.on_start, ::std::string::String::new()) + } + + // string on_stop = 3; + + + pub fn get_on_stop(&self) -> &str { + &self.on_stop + } + pub fn clear_on_stop(&mut self) { + self.on_stop.clear(); + } + + // Param is passed by value, moved + pub fn set_on_stop(&mut self, v: ::std::string::String) { + self.on_stop = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_on_stop(&mut self) -> &mut ::std::string::String { + &mut self.on_stop + } + + // Take field + pub fn take_on_stop(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.on_stop, ::std::string::String::new()) + } +} + +impl ::protobuf::Message for WebRtcPlayEndpoint { + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.src)?; + }, + 2 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.on_start)?; + }, + 3 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.on_stop)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if !self.src.is_empty() { + my_size += ::protobuf::rt::string_size(1, &self.src); + } + if !self.on_start.is_empty() { + my_size += ::protobuf::rt::string_size(2, &self.on_start); + } + if !self.on_stop.is_empty() { + my_size += ::protobuf::rt::string_size(3, &self.on_stop); + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + if !self.src.is_empty() { + os.write_string(1, &self.src)?; + } + if !self.on_start.is_empty() { + os.write_string(2, &self.on_start)?; + } + if !self.on_stop.is_empty() { + os.write_string(3, &self.on_stop)?; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> WebRtcPlayEndpoint { + WebRtcPlayEndpoint::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "src", + |m: &WebRtcPlayEndpoint| { &m.src }, + |m: &mut WebRtcPlayEndpoint| { &mut m.src }, + )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "on_start", + |m: &WebRtcPlayEndpoint| { &m.on_start }, + |m: &mut WebRtcPlayEndpoint| { &mut m.on_start }, + )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "on_stop", + |m: &WebRtcPlayEndpoint| { &m.on_stop }, + |m: &mut WebRtcPlayEndpoint| { &mut m.on_stop }, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "WebRtcPlayEndpoint", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static WebRtcPlayEndpoint { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const WebRtcPlayEndpoint, + }; + unsafe { + instance.get(WebRtcPlayEndpoint::new) + } + } +} + +impl ::protobuf::Clear for WebRtcPlayEndpoint { + fn clear(&mut self) { + self.src.clear(); + self.on_start.clear(); + self.on_stop.clear(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for WebRtcPlayEndpoint { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for WebRtcPlayEndpoint { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct Hub { + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a Hub { + fn default() -> &'a Hub { + ::default_instance() + } +} + +impl Hub { + pub fn new() -> Hub { + ::std::default::Default::default() + } +} + +impl ::protobuf::Message for Hub { + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> Hub { + Hub::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let fields = ::std::vec::Vec::new(); + ::protobuf::reflect::MessageDescriptor::new::( + "Hub", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static Hub { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const Hub, + }; + unsafe { + instance.get(Hub::new) + } + } +} + +impl ::protobuf::Clear for Hub { + fn clear(&mut self) { + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for Hub { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for Hub { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct FileRecorder { + // message fields + pub src: ::std::string::String, + pub dst: ::std::string::String, + pub on_start: ::std::string::String, + pub on_stop: ::std::string::String, + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a FileRecorder { + fn default() -> &'a FileRecorder { + ::default_instance() + } +} + +impl FileRecorder { + pub fn new() -> FileRecorder { + ::std::default::Default::default() + } + + // string src = 1; + + + pub fn get_src(&self) -> &str { + &self.src + } + pub fn clear_src(&mut self) { + self.src.clear(); + } + + // Param is passed by value, moved + pub fn set_src(&mut self, v: ::std::string::String) { + self.src = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_src(&mut self) -> &mut ::std::string::String { + &mut self.src + } + + // Take field + pub fn take_src(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.src, ::std::string::String::new()) + } + + // string dst = 2; + + + pub fn get_dst(&self) -> &str { + &self.dst + } + pub fn clear_dst(&mut self) { + self.dst.clear(); + } + + // Param is passed by value, moved + pub fn set_dst(&mut self, v: ::std::string::String) { + self.dst = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_dst(&mut self) -> &mut ::std::string::String { + &mut self.dst + } + + // Take field + pub fn take_dst(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.dst, ::std::string::String::new()) + } + + // string on_start = 3; + + + pub fn get_on_start(&self) -> &str { + &self.on_start + } + pub fn clear_on_start(&mut self) { + self.on_start.clear(); + } + + // Param is passed by value, moved + pub fn set_on_start(&mut self, v: ::std::string::String) { + self.on_start = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_on_start(&mut self) -> &mut ::std::string::String { + &mut self.on_start + } + + // Take field + pub fn take_on_start(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.on_start, ::std::string::String::new()) + } + + // string on_stop = 4; + + + pub fn get_on_stop(&self) -> &str { + &self.on_stop + } + pub fn clear_on_stop(&mut self) { + self.on_stop.clear(); + } + + // Param is passed by value, moved + pub fn set_on_stop(&mut self, v: ::std::string::String) { + self.on_stop = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_on_stop(&mut self) -> &mut ::std::string::String { + &mut self.on_stop + } + + // Take field + pub fn take_on_stop(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.on_stop, ::std::string::String::new()) + } +} + +impl ::protobuf::Message for FileRecorder { + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.src)?; + }, + 2 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.dst)?; + }, + 3 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.on_start)?; + }, + 4 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.on_stop)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if !self.src.is_empty() { + my_size += ::protobuf::rt::string_size(1, &self.src); + } + if !self.dst.is_empty() { + my_size += ::protobuf::rt::string_size(2, &self.dst); + } + if !self.on_start.is_empty() { + my_size += ::protobuf::rt::string_size(3, &self.on_start); + } + if !self.on_stop.is_empty() { + my_size += ::protobuf::rt::string_size(4, &self.on_stop); + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + if !self.src.is_empty() { + os.write_string(1, &self.src)?; + } + if !self.dst.is_empty() { + os.write_string(2, &self.dst)?; + } + if !self.on_start.is_empty() { + os.write_string(3, &self.on_start)?; + } + if !self.on_stop.is_empty() { + os.write_string(4, &self.on_stop)?; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> FileRecorder { + FileRecorder::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "src", + |m: &FileRecorder| { &m.src }, + |m: &mut FileRecorder| { &mut m.src }, + )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "dst", + |m: &FileRecorder| { &m.dst }, + |m: &mut FileRecorder| { &mut m.dst }, + )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "on_start", + |m: &FileRecorder| { &m.on_start }, + |m: &mut FileRecorder| { &mut m.on_start }, + )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "on_stop", + |m: &FileRecorder| { &m.on_stop }, + |m: &mut FileRecorder| { &mut m.on_stop }, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "FileRecorder", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static FileRecorder { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const FileRecorder, + }; + unsafe { + instance.get(FileRecorder::new) + } + } +} + +impl ::protobuf::Clear for FileRecorder { + fn clear(&mut self) { + self.src.clear(); + self.dst.clear(); + self.on_start.clear(); + self.on_stop.clear(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for FileRecorder { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for FileRecorder { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct Relay { + // message fields + pub src: ::std::string::String, + pub dst: ::std::string::String, + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a Relay { + fn default() -> &'a Relay { + ::default_instance() + } +} + +impl Relay { + pub fn new() -> Relay { + ::std::default::Default::default() + } + + // string src = 1; + + + pub fn get_src(&self) -> &str { + &self.src + } + pub fn clear_src(&mut self) { + self.src.clear(); + } + + // Param is passed by value, moved + pub fn set_src(&mut self, v: ::std::string::String) { + self.src = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_src(&mut self) -> &mut ::std::string::String { + &mut self.src + } + + // Take field + pub fn take_src(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.src, ::std::string::String::new()) + } + + // string dst = 2; + + + pub fn get_dst(&self) -> &str { + &self.dst + } + pub fn clear_dst(&mut self) { + self.dst.clear(); + } + + // Param is passed by value, moved + pub fn set_dst(&mut self, v: ::std::string::String) { + self.dst = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_dst(&mut self) -> &mut ::std::string::String { + &mut self.dst + } + + // Take field + pub fn take_dst(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.dst, ::std::string::String::new()) + } +} + +impl ::protobuf::Message for Relay { + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.src)?; + }, + 2 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.dst)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if !self.src.is_empty() { + my_size += ::protobuf::rt::string_size(1, &self.src); + } + if !self.dst.is_empty() { + my_size += ::protobuf::rt::string_size(2, &self.dst); + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + if !self.src.is_empty() { + os.write_string(1, &self.src)?; + } + if !self.dst.is_empty() { + os.write_string(2, &self.dst)?; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> Relay { + Relay::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "src", + |m: &Relay| { &m.src }, + |m: &mut Relay| { &mut m.src }, + )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "dst", + |m: &Relay| { &m.dst }, + |m: &mut Relay| { &mut m.dst }, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "Relay", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static Relay { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const Relay, + }; + unsafe { + instance.get(Relay::new) + } + } +} + +impl ::protobuf::Clear for Relay { + fn clear(&mut self) { + self.src.clear(); + self.dst.clear(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for Relay { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for Relay { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +static file_descriptor_proto_data: &'static [u8] = b"\ + \n\rcontrol.proto\x12\x05medea\"\xf0\x02\n\rCreateRequest\x12\x0e\n\x02i\ + d\x18\x01\x20\x01(\tR\x02id\x12\x1e\n\x03hub\x18\x02\x20\x01(\x0b2\n.med\ + ea.HubH\0R\x03hub\x12:\n\rfile_recorder\x18\x03\x20\x01(\x0b2\x13.medea.\ + FileRecorderH\0R\x0cfileRecorder\x12'\n\x06member\x18\x04\x20\x01(\x0b2\ + \r.medea.MemberH\0R\x06member\x12$\n\x05relay\x18\x05\x20\x01(\x0b2\x0c.\ + medea.RelayH\0R\x05relay\x12!\n\x04room\x18\x06\x20\x01(\x0b2\x0b.medea.\ + RoomH\0R\x04room\x12<\n\x0bwebrtc_play\x18\x07\x20\x01(\x0b2\x19.medea.W\ + ebRtcPlayEndpointH\0R\nwebrtcPlay\x12=\n\nwebrtc_pub\x18\x08\x20\x01(\ + \x0b2\x1c.medea.WebRtcPublishEndpointH\0R\twebrtcPubB\x04\n\x02el\"\xc4\ + \x03\n\x0cApplyRequest\x12\x0e\n\x02id\x18\x01\x20\x01(\tR\x02id\x12\x1e\ + \n\x03hub\x18\x02\x20\x01(\x0b2\n.medea.HubH\0R\x03hub\x12:\n\rfile_reco\ + rder\x18\x03\x20\x01(\x0b2\x13.medea.FileRecorderH\0R\x0cfileRecorder\ + \x12'\n\x06member\x18\x04\x20\x01(\x0b2\r.medea.MemberH\0R\x06member\x12\ + $\n\x05relay\x18\x05\x20\x01(\x0b2\x0c.medea.RelayH\0R\x05relay\x12!\n\ + \x04room\x18\x06\x20\x01(\x0b2\x0b.medea.RoomH\0R\x04room\x12<\n\x0bwebr\ + tc_play\x18\x07\x20\x01(\x0b2\x19.medea.WebRtcPlayEndpointH\0R\nwebrtcPl\ + ay\x12=\n\nwebrtc_pub\x18\x08\x20\x01(\x0b2\x1c.medea.WebRtcPublishEndpo\ + intH\0R\twebrtcPub\x122\n\x06policy\x18\t\x20\x01(\x0e2\x1a.medea.ApplyR\ + equest.PolicyR\x06policy\"\x1f\n\x06Policy\x12\t\n\x05APPLY\x10\0\x12\n\ + \n\x06APPEND\x10\x01B\x04\n\x02el\"\x1b\n\tIdRequest\x12\x0e\n\x02id\x18\ + \x01\x20\x03(\tR\x02id\"\x92\x01\n\x08Response\x12*\n\x03sid\x18\x01\x20\ + \x03(\x0b2\x18.medea.Response.SidEntryR\x03sid\x12\"\n\x05error\x18\x02\ + \x20\x01(\x0b2\x0c.medea.ErrorR\x05error\x1a6\n\x08SidEntry\x12\x10\n\ + \x03key\x18\x01\x20\x01(\tR\x03key\x12\x14\n\x05value\x18\x02\x20\x01(\t\ + R\x05value:\x028\x01\"\xbc\x01\n\x0bGetResponse\x12<\n\x08elements\x18\ + \x01\x20\x03(\x0b2\x20.medea.GetResponse.ElementsEntryR\x08elements\x12\ + \"\n\x05error\x18\x02\x20\x01(\x0b2\x0c.medea.ErrorR\x05error\x1aK\n\rEl\ + ementsEntry\x12\x10\n\x03key\x18\x01\x20\x01(\tR\x03key\x12$\n\x05value\ + \x18\x02\x20\x01(\x0b2\x0e.medea.ElementR\x05value:\x028\x01\"[\n\x05Err\ + or\x12\x12\n\x04code\x18\x02\x20\x01(\rR\x04code\x12\x12\n\x04text\x18\ + \x03\x20\x01(\tR\x04text\x12\x10\n\x03doc\x18\x04\x20\x01(\tR\x03doc\x12\ + \x18\n\x07element\x18\x05\x20\x01(\tR\x07element\"\xda\x02\n\x07Element\ + \x12\x1e\n\x03hub\x18\x02\x20\x01(\x0b2\n.medea.HubH\0R\x03hub\x12:\n\rf\ + ile_recorder\x18\x03\x20\x01(\x0b2\x13.medea.FileRecorderH\0R\x0cfileRec\ + order\x12'\n\x06member\x18\x04\x20\x01(\x0b2\r.medea.MemberH\0R\x06membe\ + r\x12$\n\x05relay\x18\x05\x20\x01(\x0b2\x0c.medea.RelayH\0R\x05relay\x12\ + !\n\x04room\x18\x06\x20\x01(\x0b2\x0b.medea.RoomH\0R\x04room\x12<\n\x0bw\ + ebrtc_play\x18\x07\x20\x01(\x0b2\x19.medea.WebRtcPlayEndpointH\0R\nwebrt\ + cPlay\x12=\n\nwebrtc_pub\x18\x08\x20\x01(\x0b2\x1c.medea.WebRtcPublishEn\ + dpointH\0R\twebrtcPubB\x04\n\x02el\"\xc9\x03\n\x04Room\x125\n\x08pipelin\ + e\x18\x01\x20\x03(\x0b2\x19.medea.Room.PipelineEntryR\x08pipeline\x1aP\n\ + \rPipelineEntry\x12\x10\n\x03key\x18\x01\x20\x01(\tR\x03key\x12)\n\x05va\ + lue\x18\x02\x20\x01(\x0b2\x13.medea.Room.ElementR\x05value:\x028\x01\x1a\ + \xb7\x02\n\x07Element\x12\x1e\n\x03hub\x18\x01\x20\x01(\x0b2\n.medea.Hub\ + H\0R\x03hub\x12:\n\rfile_recorder\x18\x02\x20\x01(\x0b2\x13.medea.FileRe\ + corderH\0R\x0cfileRecorder\x12'\n\x06member\x18\x03\x20\x01(\x0b2\r.mede\ + a.MemberH\0R\x06member\x12$\n\x05relay\x18\x04\x20\x01(\x0b2\x0c.medea.R\ + elayH\0R\x05relay\x12<\n\x0bwebrtc_play\x18\x05\x20\x01(\x0b2\x19.medea.\ + WebRtcPlayEndpointH\0R\nwebrtcPlay\x12=\n\nwebrtc_pub\x18\x06\x20\x01(\ + \x0b2\x1c.medea.WebRtcPublishEndpointH\0R\twebrtcPubB\x04\n\x02el\"\xfc\ + \x03\n\x06Member\x12\x17\n\x07on_join\x18\x01\x20\x01(\tR\x06onJoin\x12\ + \x19\n\x08on_leave\x18\x02\x20\x01(\tR\x07onLeave\x12\x20\n\x0bcredentia\ + ls\x18\x03\x20\x01(\tR\x0bcredentials\x127\n\x08pipeline\x18\x04\x20\x03\ + (\x0b2\x1b.medea.Member.PipelineEntryR\x08pipeline\x1aR\n\rPipelineEntry\ + \x12\x10\n\x03key\x18\x01\x20\x01(\tR\x03key\x12+\n\x05value\x18\x02\x20\ + \x01(\x0b2\x15.medea.Member.ElementR\x05value:\x028\x01\x1a\x8e\x02\n\ + \x07Element\x12\x1e\n\x03hub\x18\x01\x20\x01(\x0b2\n.medea.HubH\0R\x03hu\ + b\x12:\n\rfile_recorder\x18\x02\x20\x01(\x0b2\x13.medea.FileRecorderH\0R\ + \x0cfileRecorder\x12$\n\x05relay\x18\x03\x20\x01(\x0b2\x0c.medea.RelayH\ + \0R\x05relay\x12<\n\x0bwebrtc_play\x18\x04\x20\x01(\x0b2\x19.medea.WebRt\ + cPlayEndpointH\0R\nwebrtcPlay\x12=\n\nwebrtc_pub\x18\x05\x20\x01(\x0b2\ + \x1c.medea.WebRtcPublishEndpointH\0R\twebrtcPubB\x04\n\x02el\"\xae\x01\n\ + \x15WebRtcPublishEndpoint\x122\n\x03p2p\x18\x01\x20\x01(\x0e2\x20.medea.\ + WebRtcPublishEndpoint.P2PR\x03p2p\x12\x19\n\x08on_start\x18\x03\x20\x01(\ + \tR\x07onStart\x12\x17\n\x07on_stop\x18\x04\x20\x01(\tR\x06onStop\"-\n\ + \x03P2P\x12\t\n\x05NEVER\x10\0\x12\x0f\n\x0bIF_POSSIBLE\x10\x01\x12\n\n\ + \x06ALWAYS\x10\x02\"Z\n\x12WebRtcPlayEndpoint\x12\x10\n\x03src\x18\x01\ + \x20\x01(\tR\x03src\x12\x19\n\x08on_start\x18\x02\x20\x01(\tR\x07onStart\ + \x12\x17\n\x07on_stop\x18\x03\x20\x01(\tR\x06onStop\"\x05\n\x03Hub\"f\n\ + \x0cFileRecorder\x12\x10\n\x03src\x18\x01\x20\x01(\tR\x03src\x12\x10\n\ + \x03dst\x18\x02\x20\x01(\tR\x03dst\x12\x19\n\x08on_start\x18\x03\x20\x01\ + (\tR\x07onStart\x12\x17\n\x07on_stop\x18\x04\x20\x01(\tR\x06onStop\"+\n\ + \x05Relay\x12\x10\n\x03src\x18\x01\x20\x01(\tR\x03src\x12\x10\n\x03dst\ + \x18\x02\x20\x01(\tR\x03dst2\xc6\x01\n\nControlApi\x12/\n\x06Create\x12\ + \x14.medea.CreateRequest\x1a\x0f.medea.Response\x12-\n\x05Apply\x12\x13.\ + medea.ApplyRequest\x1a\x0f.medea.Response\x12+\n\x06Delete\x12\x10.medea\ + .IdRequest\x1a\x0f.medea.Response\x12+\n\x03Get\x12\x10.medea.IdRequest\ + \x1a\x12.medea.GetResponseb\x06proto3\ +"; + +static mut file_descriptor_proto_lazy: ::protobuf::lazy::Lazy<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::descriptor::FileDescriptorProto, +}; + +fn parse_descriptor_proto() -> ::protobuf::descriptor::FileDescriptorProto { + ::protobuf::parse_from_bytes(file_descriptor_proto_data).unwrap() +} + +pub fn file_descriptor_proto() -> &'static ::protobuf::descriptor::FileDescriptorProto { + unsafe { + file_descriptor_proto_lazy.get(|| { + parse_descriptor_proto() + }) + } +} diff --git a/proto/grpc/src/control_grpc.rs b/proto/grpc/src/control_grpc.rs new file mode 100644 index 000000000..200c56a85 --- /dev/null +++ b/proto/grpc/src/control_grpc.rs @@ -0,0 +1,155 @@ +// This file is generated. Do not edit +// @generated + +// https://github.com/Manishearth/rust-clippy/issues/702 +#![allow(unknown_lints)] +#![allow(clippy::all)] + +#![cfg_attr(rustfmt, rustfmt_skip)] + +#![allow(box_pointers)] +#![allow(dead_code)] +#![allow(missing_docs)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] +#![allow(non_upper_case_globals)] +#![allow(trivial_casts)] +#![allow(unsafe_code)] +#![allow(unused_imports)] +#![allow(unused_results)] + +const METHOD_CONTROL_API_CREATE: ::grpcio::Method = ::grpcio::Method { + ty: ::grpcio::MethodType::Unary, + name: "/medea.ControlApi/Create", + req_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, + resp_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, +}; + +const METHOD_CONTROL_API_APPLY: ::grpcio::Method = ::grpcio::Method { + ty: ::grpcio::MethodType::Unary, + name: "/medea.ControlApi/Apply", + req_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, + resp_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, +}; + +const METHOD_CONTROL_API_DELETE: ::grpcio::Method = ::grpcio::Method { + ty: ::grpcio::MethodType::Unary, + name: "/medea.ControlApi/Delete", + req_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, + resp_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, +}; + +const METHOD_CONTROL_API_GET: ::grpcio::Method = ::grpcio::Method { + ty: ::grpcio::MethodType::Unary, + name: "/medea.ControlApi/Get", + req_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, + resp_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, +}; + +#[derive(Clone)] +pub struct ControlApiClient { + client: ::grpcio::Client, +} + +impl ControlApiClient { + pub fn new(channel: ::grpcio::Channel) -> Self { + ControlApiClient { + client: ::grpcio::Client::new(channel), + } + } + + pub fn create_opt(&self, req: &super::control::CreateRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result { + self.client.unary_call(&METHOD_CONTROL_API_CREATE, req, opt) + } + + pub fn create(&self, req: &super::control::CreateRequest) -> ::grpcio::Result { + self.create_opt(req, ::grpcio::CallOption::default()) + } + + pub fn create_async_opt(&self, req: &super::control::CreateRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { + self.client.unary_call_async(&METHOD_CONTROL_API_CREATE, req, opt) + } + + pub fn create_async(&self, req: &super::control::CreateRequest) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { + self.create_async_opt(req, ::grpcio::CallOption::default()) + } + + pub fn apply_opt(&self, req: &super::control::ApplyRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result { + self.client.unary_call(&METHOD_CONTROL_API_APPLY, req, opt) + } + + pub fn apply(&self, req: &super::control::ApplyRequest) -> ::grpcio::Result { + self.apply_opt(req, ::grpcio::CallOption::default()) + } + + pub fn apply_async_opt(&self, req: &super::control::ApplyRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { + self.client.unary_call_async(&METHOD_CONTROL_API_APPLY, req, opt) + } + + pub fn apply_async(&self, req: &super::control::ApplyRequest) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { + self.apply_async_opt(req, ::grpcio::CallOption::default()) + } + + pub fn delete_opt(&self, req: &super::control::IdRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result { + self.client.unary_call(&METHOD_CONTROL_API_DELETE, req, opt) + } + + pub fn delete(&self, req: &super::control::IdRequest) -> ::grpcio::Result { + self.delete_opt(req, ::grpcio::CallOption::default()) + } + + pub fn delete_async_opt(&self, req: &super::control::IdRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { + self.client.unary_call_async(&METHOD_CONTROL_API_DELETE, req, opt) + } + + pub fn delete_async(&self, req: &super::control::IdRequest) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { + self.delete_async_opt(req, ::grpcio::CallOption::default()) + } + + pub fn get_opt(&self, req: &super::control::IdRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result { + self.client.unary_call(&METHOD_CONTROL_API_GET, req, opt) + } + + pub fn get(&self, req: &super::control::IdRequest) -> ::grpcio::Result { + self.get_opt(req, ::grpcio::CallOption::default()) + } + + pub fn get_async_opt(&self, req: &super::control::IdRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { + self.client.unary_call_async(&METHOD_CONTROL_API_GET, req, opt) + } + + pub fn get_async(&self, req: &super::control::IdRequest) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { + self.get_async_opt(req, ::grpcio::CallOption::default()) + } + pub fn spawn(&self, f: F) where F: ::futures::Future + Send + 'static { + self.client.spawn(f) + } +} + +pub trait ControlApi { + fn create(&mut self, ctx: ::grpcio::RpcContext, req: super::control::CreateRequest, sink: ::grpcio::UnarySink); + fn apply(&mut self, ctx: ::grpcio::RpcContext, req: super::control::ApplyRequest, sink: ::grpcio::UnarySink); + fn delete(&mut self, ctx: ::grpcio::RpcContext, req: super::control::IdRequest, sink: ::grpcio::UnarySink); + fn get(&mut self, ctx: ::grpcio::RpcContext, req: super::control::IdRequest, sink: ::grpcio::UnarySink); +} + +pub fn create_control_api(s: S) -> ::grpcio::Service { + let mut builder = ::grpcio::ServiceBuilder::new(); + let mut instance = s.clone(); + builder = builder.add_unary_handler(&METHOD_CONTROL_API_CREATE, move |ctx, req, resp| { + instance.create(ctx, req, resp) + }); + let mut instance = s.clone(); + builder = builder.add_unary_handler(&METHOD_CONTROL_API_APPLY, move |ctx, req, resp| { + instance.apply(ctx, req, resp) + }); + let mut instance = s.clone(); + builder = builder.add_unary_handler(&METHOD_CONTROL_API_DELETE, move |ctx, req, resp| { + instance.delete(ctx, req, resp) + }); + let mut instance = s.clone(); + builder = builder.add_unary_handler(&METHOD_CONTROL_API_GET, move |ctx, req, resp| { + instance.get(ctx, req, resp) + }); + builder.build() +} diff --git a/proto/grpc/src/lib.rs b/proto/grpc/src/lib.rs new file mode 100644 index 000000000..3053d7002 --- /dev/null +++ b/proto/grpc/src/lib.rs @@ -0,0 +1,2 @@ +pub mod control; +pub mod control_grpc; diff --git a/src/api/control/endpoints/mod.rs b/src/api/control/endpoints/mod.rs index 768029ee9..774018088 100644 --- a/src/api/control/endpoints/mod.rs +++ b/src/api/control/endpoints/mod.rs @@ -5,7 +5,7 @@ pub mod webrtc_publish_endpoint; use std::convert::TryFrom; -use crate::api::control::grpc::protos::control::{ +use medea_grpc_proto::control::{ CreateRequest, Member_Element as MemberElementProto, }; diff --git a/src/api/control/endpoints/webrtc_play_endpoint.rs b/src/api/control/endpoints/webrtc_play_endpoint.rs index c66e97fec..e48e4cb47 100644 --- a/src/api/control/endpoints/webrtc_play_endpoint.rs +++ b/src/api/control/endpoints/webrtc_play_endpoint.rs @@ -9,10 +9,10 @@ use serde::{ de::{self, Deserializer, Error, Visitor}, Deserialize, }; +use medea_grpc_proto::control::WebRtcPlayEndpoint as WebRtcPlayEndpointProto; use crate::api::control::{ endpoints::webrtc_publish_endpoint::WebRtcPublishId, - grpc::protos::control::WebRtcPlayEndpoint as WebRtcPlayEndpointProto, local_uri::{IsEndpointId, LocalUri, LocalUriParseError, LocalUriType}, MemberId, RoomId, TryFromProtobufError, }; diff --git a/src/api/control/endpoints/webrtc_publish_endpoint.rs b/src/api/control/endpoints/webrtc_publish_endpoint.rs index a4357add2..8bffaec97 100644 --- a/src/api/control/endpoints/webrtc_publish_endpoint.rs +++ b/src/api/control/endpoints/webrtc_publish_endpoint.rs @@ -4,7 +4,7 @@ use macro_attr::*; use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; use serde::Deserialize; -use crate::api::control::grpc::protos::control::{ +use medea_grpc_proto::control::{ WebRtcPublishEndpoint as WebRtcPublishEndpointProto, WebRtcPublishEndpoint_P2P as WebRtcPublishEndpointP2pProto, }; diff --git a/src/api/control/grpc/mod.rs b/src/api/control/grpc/mod.rs index 1b990a386..03e5f96fc 100644 --- a/src/api/control/grpc/mod.rs +++ b/src/api/control/grpc/mod.rs @@ -1,4 +1,3 @@ //! Implementation of gRPC server and generated gRPC protos. -pub mod protos; pub mod server; diff --git a/src/api/control/grpc/protos/mod.rs b/src/api/control/grpc/protos/mod.rs deleted file mode 100644 index 238b3be6a..000000000 --- a/src/api/control/grpc/protos/mod.rs +++ /dev/null @@ -1,11 +0,0 @@ -//! gRPC generated specs. -//! Don't edit `*.rs` files in this module because it automatically generated by -//! `protoc` in `build.rs` file. - -#![allow(bare_trait_objects)] -#![allow(clippy::pedantic)] -#![allow(clippy::cargo)] -#![allow(clippy::nursery)] - -pub mod control; -pub mod control_grpc; diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index 4796b9006..df9a5b60c 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -12,14 +12,17 @@ use actix::{ use failure::Fail; use futures::future::{self, Either, Future}; use grpcio::{Environment, RpcContext, Server, ServerBuilder, UnarySink}; +use medea_grpc_proto::{ + control::{ + ApplyRequest, CreateRequest, Error, GetResponse, IdRequest, + Response, + }, + control_grpc::{create_control_api, ControlApi}, +}; use crate::{ api::{ control::{ - grpc::protos::control::{ - ApplyRequest, CreateRequest, Error, GetResponse, IdRequest, - Response, - }, local_uri::{ IsEndpointId, IsMemberId, IsRoomId, LocalUri, LocalUriParseError, LocalUriType, @@ -41,7 +44,6 @@ use crate::{ AppContext, }; -use super::protos::control_grpc::{create_control_api, ControlApi}; use crate::shutdown::ShutdownGracefully; #[derive(Debug, Fail)] diff --git a/src/api/control/member.rs b/src/api/control/member.rs index fdf7e2daa..fcd2cd8d8 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -6,13 +6,13 @@ use hashbrown::HashMap; use macro_attr::*; use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; use serde::Deserialize; +use medea_grpc_proto::control::Member as MemberProto; use crate::api::control::{ endpoints::{ webrtc_play_endpoint::WebRtcPlayEndpoint, webrtc_publish_endpoint::{WebRtcPublishEndpoint, WebRtcPublishId}, }, - grpc::protos::control::Member as MemberProto, Endpoint, TryFromProtobufError, WebRtcPlayId, }; diff --git a/src/api/control/room.rs b/src/api/control/room.rs index a0cf19e2f..c75a4c661 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -6,9 +6,10 @@ use hashbrown::HashMap; use macro_attr::*; use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; use serde::Deserialize; +use medea_grpc_proto::control::Room as RoomProto; use crate::api::control::{ - grpc::protos::control::Room as RoomProto, TryFromProtobufError, + TryFromProtobufError, }; use super::{ diff --git a/src/api/error_codes.rs b/src/api/error_codes.rs index 257ae17e6..cde208dbe 100644 --- a/src/api/error_codes.rs +++ b/src/api/error_codes.rs @@ -7,10 +7,13 @@ //! * __1200...1299__ Parse errors //! * __1300...1399__ Conflicts +use medea_grpc_proto::control::{ + Error as ErrorProto, +}; + use crate::{ api::control::{ endpoints::webrtc_play_endpoint::SrcParseError, - grpc::protos::control::Error as ErrorProto, local_uri::{ IsEndpointId, IsMemberId, IsRoomId, LocalUri, LocalUriParseError, LocalUriType, diff --git a/src/lib.rs b/src/lib.rs index f171df493..3c3233986 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,14 +1,14 @@ //! Medea media server application. #[macro_use] -pub mod utils; -pub mod api; -pub mod conf; -pub mod log; -pub mod media; -pub mod shutdown; -pub mod signalling; -pub mod turn; +mod utils; +mod api; +mod conf; +mod log; +mod media; +mod shutdown; +mod signalling; +mod turn; use std::sync::Arc; diff --git a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs index f0a20a7e3..f639e4521 100644 --- a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs @@ -5,13 +5,14 @@ use std::{ rc::{Rc, Weak}, }; +use medea_grpc_proto::control::{ + Member_Element as ElementProto, + WebRtcPlayEndpoint as WebRtcPlayEndpointProto, +}; + use crate::{ api::control::{ endpoints::webrtc_play_endpoint::{SrcUri, WebRtcPlayId as Id}, - grpc::protos::control::{ - Member_Element as ElementProto, - WebRtcPlayEndpoint as WebRtcPlayEndpointProto, - }, }, media::PeerId, signalling::elements::Member, diff --git a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs index 5bba1c3d4..7288467e6 100644 --- a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs @@ -6,14 +6,14 @@ use std::{ }; use hashbrown::HashSet; +use medea_grpc_proto::control::{ + Member_Element as ElementProto, + WebRtcPublishEndpoint as WebRtcPublishEndpointProto, +}; use crate::{ api::control::{ endpoints::webrtc_publish_endpoint::{P2pMode, WebRtcPublishId as Id}, - grpc::protos::control::{ - Member_Element as ElementProto, - WebRtcPublishEndpoint as WebRtcPublishEndpointProto, - }, }, media::PeerId, signalling::elements::Member, diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index 01d70bd8a..1bd4ea62a 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -8,13 +8,13 @@ use std::{ use failure::Fail; use hashbrown::HashMap; use medea_client_api_proto::IceServer; +use medea_grpc_proto::control::{ + Member as MemberProto, Room_Element as ElementProto, +}; use crate::{ api::control::{ endpoints::WebRtcPlayEndpoint as WebRtcPlayEndpointSpec, - grpc::protos::control::{ - Member as MemberProto, Room_Element as ElementProto, - }, local_uri::{ IsEndpointId, IsMemberId, IsRoomId, LocalUri, LocalUriType, }, diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 93bd53853..3ecd59cf8 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -11,6 +11,10 @@ use failure::Fail; use futures::future; use hashbrown::{HashMap, HashSet}; use medea_client_api_proto::{Command, Event, IceCandidate}; +use medea_grpc_proto::control::{ + Element as ElementProto, Member_Element, Room as RoomProto, + Room_Element, +}; use crate::{ api::{ @@ -19,10 +23,6 @@ use crate::{ RpcConnectionClosed, RpcConnectionEstablished, }, control::{ - grpc::protos::control::{ - Element as ElementProto, Member_Element, Room as RoomProto, - Room_Element, - }, local_uri::{IsMemberId, LocalUri}, room::RoomSpec, Endpoint as EndpointSpec, MemberId, MemberSpec, RoomId, diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index 017ab6858..9cf05ef42 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -6,11 +6,11 @@ use actix::{ }; use failure::Fail; use futures::future::{Either, Future}; +use medea_grpc_proto::control::Element as ElementProto; use crate::{ api::control::{ endpoints::Endpoint as EndpointSpec, - grpc::protos::control::Element as ElementProto, load_static_specs_from_dir, local_uri::{IsEndpointId, IsMemberId, IsRoomId, LocalUri}, MemberId, MemberSpec, RoomId, RoomSpec, From 73c2c1dfe5dacde23ec3d51377639c0f54d039f8 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 19 Jul 2019 20:03:03 +0300 Subject: [PATCH 394/735] Refactor WebRtcPlayEndpoint --- .../endpoints/webrtc/play_endpoint.rs | 25 ++++++++++++--- .../endpoints/webrtc/publish_endpoint.rs | 31 ++++++++++--------- src/signalling/elements/member.rs | 22 ++++++------- src/signalling/room.rs | 2 +- 4 files changed, 50 insertions(+), 30 deletions(-) diff --git a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs index b9c5c5b90..43bd25a6a 100644 --- a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs @@ -88,8 +88,8 @@ impl Drop for WebRtcPlayEndpointInner { /// Signalling representation of `WebRtcPlayEndpoint`. #[allow(clippy::module_name_repetitions)] -#[derive(Debug)] -pub struct WebRtcPlayEndpoint(RefCell); +#[derive(Debug, Clone)] +pub struct WebRtcPlayEndpoint(Rc>); impl WebRtcPlayEndpoint { /// Create new [`WebRtcPlayEndpoint`]. @@ -99,13 +99,13 @@ impl WebRtcPlayEndpoint { publisher: Weak, owner: Weak, ) -> Self { - Self(RefCell::new(WebRtcPlayEndpointInner { + Self(Rc::new(RefCell::new(WebRtcPlayEndpointInner { id, src_uri, src: publisher, owner, peer_id: None, - })) + }))) } /// Returns [`SrcUri`] of this [`WebRtcPlayEndpoint`]. @@ -154,4 +154,21 @@ impl WebRtcPlayEndpoint { pub fn id(&self) -> Id { self.0.borrow().id.clone() } + + pub fn downgrade(&self) -> WeakWebRtcPlayEndpoint { + WeakWebRtcPlayEndpoint(Rc::downgrade(&self.0)) + } +} + +#[derive(Debug, Clone)] +pub struct WeakWebRtcPlayEndpoint(Weak>); + +impl WeakWebRtcPlayEndpoint { + pub fn upgrade(&self) -> WebRtcPlayEndpoint { + WebRtcPlayEndpoint(self.0.upgrade().unwrap()) + } + + pub fn safe_upgrade(&self) -> Option { + self.0.upgrade().map(|i| WebRtcPlayEndpoint(i)) + } } diff --git a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs index a39e3108d..58b59d74e 100644 --- a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs @@ -10,8 +10,11 @@ use macro_attr::*; use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; use crate::{ - api::control::endpoint::P2pMode, media::PeerId, - signalling::elements::Member, + api::control::endpoint::P2pMode, + media::PeerId, + signalling::elements::{ + endpoints::webrtc::play_endpoint::WeakWebRtcPlayEndpoint, Member, + }, }; use super::play_endpoint::WebRtcPlayEndpoint; @@ -33,7 +36,7 @@ struct WebRtcPublishEndpointInner { p2p: P2pMode, /// All sinks of this [`WebRtcPublishEndpoint`]. - sinks: Vec>, + sinks: Vec, /// Owner [`Member`] of this [`WebRtcPublishEndpoint`]. owner: Weak, @@ -48,7 +51,7 @@ struct WebRtcPublishEndpointInner { impl Drop for WebRtcPublishEndpointInner { fn drop(&mut self) { - for receiver in self.sinks.iter().filter_map(|r| Weak::upgrade(r)) { + for receiver in self.sinks.iter().filter_map(|r| r.safe_upgrade()) { if let Some(receiver_owner) = receiver.weak_owner().upgrade() { receiver_owner.remove_sink(&receiver.id()) } @@ -57,15 +60,12 @@ impl Drop for WebRtcPublishEndpointInner { } impl WebRtcPublishEndpointInner { - fn add_sinks(&mut self, sink: Weak) { + fn add_sinks(&mut self, sink: WeakWebRtcPlayEndpoint) { self.sinks.push(sink); } - fn sinks(&self) -> Vec> { - self.sinks - .iter() - .map(|p| Weak::upgrade(p).unwrap()) - .collect() + fn sinks(&self) -> Vec { + self.sinks.iter().map(|p| p.upgrade()).collect() } fn owner(&self) -> Rc { @@ -106,7 +106,7 @@ impl WebRtcPublishEndpoint { pub fn new( id: Id, p2p: P2pMode, - sinks: Vec>, + sinks: Vec, owner: Weak, ) -> Self { Self(RefCell::new(WebRtcPublishEndpointInner { @@ -119,14 +119,14 @@ impl WebRtcPublishEndpoint { } /// Add sink for this [`WebRtcPublishEndpoint`]. - pub fn add_sink(&self, sink: Weak) { + pub fn add_sink(&self, sink: WeakWebRtcPlayEndpoint) { self.0.borrow_mut().add_sinks(sink) } /// Returns all sinks of this [`WebRtcPublishEndpoint`]. /// /// __This function will panic if meet empty pointer.__ - pub fn sinks(&self) -> Vec> { + pub fn sinks(&self) -> Vec { self.0.borrow().sinks() } @@ -173,6 +173,9 @@ impl WebRtcPublishEndpoint { /// Remove all empty Weak pointers from sinks of this /// [`WebRtcPublishEndpoint`]. pub fn remove_empty_weaks_from_sinks(&self) { - self.0.borrow_mut().sinks.retain(|e| e.upgrade().is_some()); + self.0 + .borrow_mut() + .sinks + .retain(|e| e.safe_upgrade().is_some()); } } diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index 9f994e60b..6ec475aa2 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -51,7 +51,7 @@ struct MemberInner { srcs: HashMap>, /// All [`WebRtcPlayEndpoint`]s of this [`Member`]. - sinks: HashMap>, + sinks: HashMap, /// Credentials for this [`Member`]. credentials: String, @@ -130,16 +130,16 @@ impl Member { { let new_play_endpoint_id = WebRtcPlayId(spec_play_name.to_string()); - let new_play_endpoint = Rc::new(WebRtcPlayEndpoint::new( + let new_play_endpoint = WebRtcPlayEndpoint::new( new_play_endpoint_id.clone(), spec_play_endpoint.src.clone(), Rc::downgrade(&publisher), Rc::downgrade(&this_member), - )); + ); - self.insert_sink(Rc::clone(&new_play_endpoint)); + self.insert_sink(new_play_endpoint.clone()); - publisher.add_sink(Rc::downgrade(&new_play_endpoint)); + publisher.add_sink(new_play_endpoint.downgrade()); } else { let new_publish_id = WebRtcPublishId( spec_play_endpoint.src.endpoint_id.to_string(), @@ -152,14 +152,14 @@ impl Member { )); let new_self_play_id = WebRtcPlayId(spec_play_name.to_string()); - let new_self_play = Rc::new(WebRtcPlayEndpoint::new( + let new_self_play = WebRtcPlayEndpoint::new( new_self_play_id.clone(), spec_play_endpoint.src.clone(), Rc::downgrade(&new_publish), Rc::downgrade(&this_member), - )); + ); - new_publish.add_sink(Rc::downgrade(&new_self_play)); + new_publish.add_sink(new_self_play.downgrade()); publisher_member.insert_src(new_publish); @@ -232,12 +232,12 @@ impl Member { } /// Returns all sinks endpoints of this [`Member`]. - pub fn sinks(&self) -> HashMap> { + pub fn sinks(&self) -> HashMap { self.0.borrow().sinks.clone() } /// Insert sink endpoint into this [`Member`]. - pub fn insert_sink(&self, endpoint: Rc) { + pub fn insert_sink(&self, endpoint: WebRtcPlayEndpoint) { self.0.borrow_mut().sinks.insert(endpoint.id(), endpoint); } @@ -258,7 +258,7 @@ impl Member { pub fn get_sink_by_id( &self, id: &WebRtcPlayId, - ) -> Option> { + ) -> Option { self.0.borrow().sinks.get(id).cloned() } diff --git a/src/signalling/room.rs b/src/signalling/room.rs index fb18a43cf..e928096f0 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -334,7 +334,7 @@ impl Room { fn connect_endpoints( &mut self, src: &Rc, - sink: &Rc, + sink: &WebRtcPlayEndpoint, ) -> Option<(PeerId, PeerId)> { let src_owner = src.owner(); let sink_owner = sink.owner(); From 1ce546180c4c18bf6baffb5f6f5fa17dbaf51690 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 19 Jul 2019 20:15:35 +0300 Subject: [PATCH 395/735] Refactor WebRtcPublishEndpoint --- .../endpoints/webrtc/play_endpoint.rs | 25 +++++++++++---- .../endpoints/webrtc/publish_endpoint.rs | 32 ++++++++++++++++--- src/signalling/elements/member.rs | 20 ++++++------ src/signalling/room.rs | 6 ++-- 4 files changed, 58 insertions(+), 25 deletions(-) diff --git a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs index 43bd25a6a..ef218df70 100644 --- a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs @@ -9,7 +9,11 @@ use macro_attr::*; use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; use crate::{ - api::control::endpoint::SrcUri, media::PeerId, signalling::elements::Member, + api::control::endpoint::SrcUri, + media::PeerId, + signalling::elements::{ + endpoints::webrtc::publish_endpoint::WeakWebRtcPublishEndpoint, Member, + }, }; use super::publish_endpoint::WebRtcPublishEndpoint; @@ -33,7 +37,7 @@ struct WebRtcPlayEndpointInner { /// Publisher [`WebRtcPublishEndpoint`] from which this /// [`WebRtcPlayEndpoint`] receive data. - src: Weak, + src: WeakWebRtcPublishEndpoint, /// Owner [`Member`] of this [`WebRtcPlayEndpoint`]. owner: Weak, @@ -61,8 +65,8 @@ impl WebRtcPlayEndpointInner { Weak::clone(&self.owner) } - fn src(&self) -> Rc { - Weak::upgrade(&self.src).unwrap() + fn src(&self) -> WebRtcPublishEndpoint { + self.src.upgrade() } fn set_peer_id(&mut self, peer_id: PeerId) { @@ -80,7 +84,7 @@ impl WebRtcPlayEndpointInner { impl Drop for WebRtcPlayEndpointInner { fn drop(&mut self) { - if let Some(receiver_publisher) = self.src.upgrade() { + if let Some(receiver_publisher) = self.src.safe_upgrade() { receiver_publisher.remove_empty_weaks_from_sinks(); } } @@ -96,7 +100,7 @@ impl WebRtcPlayEndpoint { pub fn new( id: Id, src_uri: SrcUri, - publisher: Weak, + publisher: WeakWebRtcPublishEndpoint, owner: Weak, ) -> Self { Self(Rc::new(RefCell::new(WebRtcPlayEndpointInner { @@ -129,7 +133,7 @@ impl WebRtcPlayEndpoint { /// Returns source's [`WebRtcPublishEndpoint`]. /// /// __This function will panic if pointer is empty.__ - pub fn src(&self) -> Rc { + pub fn src(&self) -> WebRtcPublishEndpoint { self.0.borrow().src() } @@ -155,19 +159,26 @@ impl WebRtcPlayEndpoint { self.0.borrow().id.clone() } + /// Downgrade [`WeakWebRtcPlayEndpoint`] to weak pointer + /// [`WeakWebRtcPlayEndpoint`]. pub fn downgrade(&self) -> WeakWebRtcPlayEndpoint { WeakWebRtcPlayEndpoint(Rc::downgrade(&self.0)) } } +/// Weak pointer to [`WebRtcPlayEndpoint`]. #[derive(Debug, Clone)] pub struct WeakWebRtcPlayEndpoint(Weak>); impl WeakWebRtcPlayEndpoint { + /// Upgrade weak pointer to strong pointer. + /// + /// This function will __panic__ if weak pointer is `None`. pub fn upgrade(&self) -> WebRtcPlayEndpoint { WebRtcPlayEndpoint(self.0.upgrade().unwrap()) } + /// Safe upgrade to [`WebRtcPlayEndpoint`]. pub fn safe_upgrade(&self) -> Option { self.0.upgrade().map(|i| WebRtcPlayEndpoint(i)) } diff --git a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs index 58b59d74e..a699d97c8 100644 --- a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs @@ -98,8 +98,8 @@ impl WebRtcPublishEndpointInner { /// Signalling representation of `WebRtcPublishEndpoint`. #[allow(clippy::module_name_repetitions)] -#[derive(Debug)] -pub struct WebRtcPublishEndpoint(RefCell); +#[derive(Debug, Clone)] +pub struct WebRtcPublishEndpoint(Rc>); impl WebRtcPublishEndpoint { /// Create new [`WebRtcPublishEndpoint`]. @@ -109,13 +109,13 @@ impl WebRtcPublishEndpoint { sinks: Vec, owner: Weak, ) -> Self { - Self(RefCell::new(WebRtcPublishEndpointInner { + Self(Rc::new(RefCell::new(WebRtcPublishEndpointInner { id, p2p, sinks, owner, peer_ids: HashSet::new(), - })) + }))) } /// Add sink for this [`WebRtcPublishEndpoint`]. @@ -178,4 +178,28 @@ impl WebRtcPublishEndpoint { .sinks .retain(|e| e.safe_upgrade().is_some()); } + + /// Downgrade [`WeakWebRtcPublishEndpoint`] to weak pointer + /// [`WeakWebRtcPublishEndpoint`]. + pub fn downgrade(&self) -> WeakWebRtcPublishEndpoint { + WeakWebRtcPublishEndpoint(Rc::downgrade(&self.0)) + } +} + +/// Weak pointer to [`WebRtcPublishEndpoint`]. +#[derive(Debug, Clone)] +pub struct WeakWebRtcPublishEndpoint(Weak>); + +impl WeakWebRtcPublishEndpoint { + /// Upgrade weak pointer to strong pointer. + /// + /// This function will __panic__ if weak pointer is `None`. + pub fn upgrade(&self) -> WebRtcPublishEndpoint { + WebRtcPublishEndpoint(self.0.upgrade().unwrap()) + } + + /// Safe upgrade to [`WebRtcPlayEndpoint`]. + pub fn safe_upgrade(&self) -> Option { + self.0.upgrade().map(|i| WebRtcPublishEndpoint(i)) + } } diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index 6ec475aa2..6cf697009 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -48,7 +48,7 @@ struct MemberInner { id: MemberId, /// All [`WebRtcPublishEndpoint`]s of this [`Member`]. - srcs: HashMap>, + srcs: HashMap, /// All [`WebRtcPlayEndpoint`]s of this [`Member`]. sinks: HashMap, @@ -133,7 +133,7 @@ impl Member { let new_play_endpoint = WebRtcPlayEndpoint::new( new_play_endpoint_id.clone(), spec_play_endpoint.src.clone(), - Rc::downgrade(&publisher), + publisher.downgrade(), Rc::downgrade(&this_member), ); @@ -144,18 +144,18 @@ impl Member { let new_publish_id = WebRtcPublishId( spec_play_endpoint.src.endpoint_id.to_string(), ); - let new_publish = Rc::new(WebRtcPublishEndpoint::new( + let new_publish = WebRtcPublishEndpoint::new( new_publish_id.clone(), publisher_endpoint.p2p.clone(), Vec::new(), Rc::downgrade(&publisher_member), - )); + ); let new_self_play_id = WebRtcPlayId(spec_play_name.to_string()); let new_self_play = WebRtcPlayEndpoint::new( new_self_play_id.clone(), spec_play_endpoint.src.clone(), - Rc::downgrade(&new_publish), + new_publish.downgrade(), Rc::downgrade(&this_member), ); @@ -173,12 +173,12 @@ impl Member { |(name, e)| { let endpoint_id = WebRtcPublishId(name.clone()); if self.srcs().get(&endpoint_id).is_none() { - self.insert_src(Rc::new(WebRtcPublishEndpoint::new( + self.insert_src(WebRtcPublishEndpoint::new( endpoint_id, e.p2p.clone(), Vec::new(), Rc::downgrade(&this_member), - ))); + )); } }, ); @@ -227,7 +227,7 @@ impl Member { } /// Returns all publishers of this [`Member`]. - pub fn srcs(&self) -> HashMap> { + pub fn srcs(&self) -> HashMap { self.0.borrow().srcs.clone() } @@ -242,7 +242,7 @@ impl Member { } /// Insert source endpoint into this [`Member`]. - pub fn insert_src(&self, endpoint: Rc) { + pub fn insert_src(&self, endpoint: WebRtcPublishEndpoint) { self.0.borrow_mut().srcs.insert(endpoint.id(), endpoint); } @@ -250,7 +250,7 @@ impl Member { pub fn get_src_by_id( &self, id: &WebRtcPublishId, - ) -> Option> { + ) -> Option { self.0.borrow().srcs.get(id).cloned() } diff --git a/src/signalling/room.rs b/src/signalling/room.rs index e928096f0..55758b31e 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -1,9 +1,7 @@ //! Room definitions and implementations. Room is responsible for media //! connection establishment between concrete [`Member`]s. -use std::{ - collections::HashMap as StdHashMap, rc::Rc, sync::Arc, time::Duration, -}; +use std::{collections::HashMap as StdHashMap, sync::Arc, time::Duration}; use actix::{ fut::wrap_future, Actor, ActorFuture, AsyncContext, Context, Handler, @@ -333,7 +331,7 @@ impl Room { /// [`Peer`]s!__ fn connect_endpoints( &mut self, - src: &Rc, + src: &WebRtcPublishEndpoint, sink: &WebRtcPlayEndpoint, ) -> Option<(PeerId, PeerId)> { let src_owner = src.owner(); From 392c740bf7fcbdca378a197bece47ba72dd22cc9 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 22 Jul 2019 12:04:09 +0300 Subject: [PATCH 396/735] Load bb8-redis from crates.io --- Cargo.lock | 92 +++++++++++++++++++++++++++--------------------------- Cargo.toml | 3 +- 2 files changed, 47 insertions(+), 48 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 566286c92..7d2421f5f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6,7 +6,7 @@ version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -100,7 +100,7 @@ dependencies = [ "mime 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", "percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "serde_urlencoded 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -149,7 +149,7 @@ dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "string 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -261,7 +261,7 @@ dependencies = [ "mime 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "serde_urlencoded 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -271,7 +271,7 @@ dependencies = [ [[package]] name = "actix-web-actors" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "actix 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -288,7 +288,7 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.40 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -298,7 +298,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.40 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -415,7 +415,7 @@ dependencies = [ [[package]] name = "bb8" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", @@ -425,10 +425,10 @@ dependencies = [ [[package]] name = "bb8-redis" -version = "0.3.0" -source = "git+https://github.com/khuey/bb8#fb1c5288b045d4522361e2a7ac37dca2e3c3aa51" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bb8 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "bb8 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "redis 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", @@ -646,7 +646,7 @@ dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.40 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -657,9 +657,9 @@ dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.40 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -679,7 +679,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -764,7 +764,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.40 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -775,7 +775,7 @@ dependencies = [ "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", "humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -795,7 +795,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.40 (registry+https://github.com/rust-lang/crates.io-index)", "synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1143,10 +1143,10 @@ dependencies = [ "actix-http 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", "actix-http-test 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "actix-web 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-web-actors 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-web-actors 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "awc 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "bb8 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "bb8-redis 0.3.0 (git+https://github.com/khuey/bb8)", + "bb8 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "bb8-redis 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "config 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", "dotenv 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1208,7 +1208,7 @@ dependencies = [ "Inflector 0.11.4 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.40 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1253,7 +1253,7 @@ dependencies = [ [[package]] name = "miniz_oxide" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1267,7 +1267,7 @@ dependencies = [ "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", - "miniz_oxide 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "miniz_oxide 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1734,12 +1734,12 @@ dependencies = [ [[package]] name = "regex" -version = "1.1.9" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aho-corasick 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "utf8-ranges 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1751,10 +1751,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "regex-syntax" -version = "0.6.8" +version = "0.6.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "ucd-util 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1881,7 +1881,7 @@ dependencies = [ "lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "linked-hash-map 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1901,7 +1901,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.40 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1958,7 +1958,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.40 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2074,7 +2074,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.40 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2113,7 +2113,7 @@ dependencies = [ [[package]] name = "syn" -version = "0.15.39" +version = "0.15.40" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2128,7 +2128,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.40 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2448,7 +2448,7 @@ dependencies = [ [[package]] name = "ucd-util" -version = "0.1.3" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -2544,7 +2544,7 @@ dependencies = [ "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.40 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-shared 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2574,7 +2574,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.40 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-backend 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-shared 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2617,7 +2617,7 @@ dependencies = [ "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.40 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-backend 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", "weedle 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2753,7 +2753,7 @@ dependencies = [ "checksum actix-threadpool 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1c29f7c554d56b3841f4bb85d5b3dee01ba536e1307679f56eb54de28aaec3fb" "checksum actix-utils 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6ea501068a0173533704be321f149853f702d9e3c3ce9d57e7a96d94b1ab5aca" "checksum actix-web 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0147b2fd52ced64145c8370af627f12f098222a1c6ba67d021e21cd0d806f574" -"checksum actix-web-actors 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8197aa04b8950ed9e37340cd46fe7ad3ccb8b1c4bbcef881ee5f6d149a425608" +"checksum actix-web-actors 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "008c1b686048a16fef4ef2fc6b6e5fcf5f29829891ad87fc0848ade26b285627" "checksum actix-web-codegen 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3fe9e3cdec1e645b675f354766e0688c5705021c85ab3cf739be1c8999b91c76" "checksum actix_derive 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0bf5f6d7bf2d220ae8b4a7ae02a572bb35b7c4806b24049af905ab8110de156c" "checksum adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7e522997b529f05601e05166c07ed17789691f562762c7f3b987263d2dedee5c" @@ -2769,8 +2769,8 @@ dependencies = [ "checksum backtrace 0.3.33 (registry+https://github.com/rust-lang/crates.io-index)" = "88fb679bc9af8fa639198790a77f52d345fe13656c08b43afa9424c206b731c6" "checksum backtrace-sys 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)" = "82a830b4ef2d1124a711c71d263c5abdc710ef8e907bd508c88be475cebc422b" "checksum base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" -"checksum bb8 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6ac04c3b2d3327a583c9a93b6c5ab4316e6609f5ec84b71b89ebe518e0edbad2" -"checksum bb8-redis 0.3.0 (git+https://github.com/khuey/bb8)" = "" +"checksum bb8 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0ac73ee3406f475415bba792942016291b87bac08839c38a032de56085a73b2c" +"checksum bb8-redis 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "39945a33c03edfba8c353d330b921961e2137d4fc4215331c1b2397f32acff80" "checksum bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3d155346769a6855b86399e9bc3814ab343cd3d62c7e985113d46a0ec3c281fd" "checksum blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "5d6d530bdd2d52966a6d03b7a964add7ae1a288d25214066fd4b600f0f796400" "checksum brotli-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4445dea95f4c2b41cde57cc9fee236ae4dbae88d8fcbdb4750fc1bb5d86aaecd" @@ -2861,7 +2861,7 @@ dependencies = [ "checksum memory_units 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8452105ba047068f40ff7093dd1d9da90898e63dd61736462e9cdda6a90ad3c3" "checksum mime 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)" = "3e27ca21f40a310bd06d9031785f4801710d566c184a6e15bad4f1d9b65f9425" "checksum miniz-sys 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "1e9e3ae51cea1576ceba0dde3d484d30e6e5b86dee0b2d412fe3a16a15c98202" -"checksum miniz_oxide 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b6c3756d66cf286314d5f7ebe74886188a9a92f5eee68b06f31ac2b4f314c99d" +"checksum miniz_oxide 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "5f6d7b3dd914b70db7cef7ab9dc74339ffcadf4d033464a987237bb0b9418cd4" "checksum miniz_oxide_c_api 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5b78ca5446dd9fe0dab00e058731b6b08a8c1d2b9cdb8efb10876e24e9ae2494" "checksum mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)" = "83f51996a3ed004ef184e16818edc51fadffe8e7ca68be67f9dee67d84d0ff23" "checksum mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)" = "966257a94e196b11bb43aca423754d87429960a768de9414f3691d6957abf125" @@ -2912,9 +2912,9 @@ dependencies = [ "checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" "checksum redox_users 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3fe5204c3a17e97dde73f285d49be585df59ed84b50a872baf416e73b62c3828" "checksum regex 0.1.80 (registry+https://github.com/rust-lang/crates.io-index)" = "4fd4ace6a8cf7860714a2c2280d6c1f7e6a413486c13298bbc86fd3da019402f" -"checksum regex 1.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "d9d8297cc20bbb6184f8b45ff61c8ee6a9ac56c156cec8e38c3e5084773c44ad" +"checksum regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6b23da8dfd98a84bd7e08700190a5d9f7d2d38abd4369dd1dae651bc40bfd2cc" "checksum regex-syntax 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "f9ec002c35e86791825ed294b50008eea9ddfc8def4420124fbc6b08db834957" -"checksum regex-syntax 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)" = "9b01330cce219c1c6b2e209e5ed64ccd587ae5c67bed91c0b49eecf02ae40e21" +"checksum regex-syntax 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "cd5485bf1523a9ed51c4964273f22f63f24e31632adb5dad134f488f86a3875c" "checksum remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e" "checksum resolv-conf 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b263b4aa1b5de9ffc0054a2386f96992058bb6870aab516f8cdeb8a667d56dcb" "checksum rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)" = "f76d05d3993fd5f4af9434e8e436db163a12a9d40e1a58a726f27a01dfd12a2a" @@ -2960,7 +2960,7 @@ dependencies = [ "checksum spin 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44363f6f51401c34e7be73db0db371c04705d35efbe9f7d6082e03a921a32c55" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" "checksum string 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d24114bfcceb867ca7f71a0d3fe45d45619ec47a6fbfa98cb14e14250bfa5d6d" -"checksum syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)" = "b4d960b829a55e56db167e861ddb43602c003c7be0bee1d345021703fac2fb7c" +"checksum syn 0.15.40 (registry+https://github.com/rust-lang/crates.io-index)" = "bc945221ccf4a7e8c31222b9d1fc77aefdd6638eb901a6ce457a3dc29d4c31e8" "checksum synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f" "checksum take_mut 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f764005d11ee5f36500a149ace24e00e3da98b0158b3e2d53a7495660d3f4d60" "checksum tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" @@ -2988,7 +2988,7 @@ dependencies = [ "checksum toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "758664fc71a3a69038656bee8b6be6477d2a6c315a6b81f7081f591bffa4111f" "checksum trust-dns-proto 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5559ebdf6c2368ddd11e20b11d6bbaf9e46deb803acd7815e93f5a7b4a6d2901" "checksum trust-dns-resolver 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6c9992e58dba365798803c0b91018ff6c8d3fc77e06977c4539af2a6bfe0a039" -"checksum ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "535c204ee4d8434478593480b8f86ab45ec9aae0e83c568ca81abf0fd0e88f86" +"checksum ucd-util 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fa9b3b49edd3468c0e6565d85783f51af95212b6fa3986a5500954f00b460874" "checksum unicase 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a84e5511b2a947f3ae965dcb29b13b7b1691b6e7332cf5dbc1744138d5acb7f6" "checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" "checksum unicode-normalization 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "141339a08b982d942be2ca06ff8b076563cbe223d1befd5450716790d44e2426" diff --git a/Cargo.toml b/Cargo.toml index 303737117..81318f3c0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,8 +27,7 @@ actix-web = "1.0" actix-web-actors = "1.0" awc = "0.2" bb8 = "0.3" -# TODO: delete this when https://github.com/khuey/bb8/pull/25 will be released. -bb8-redis = { git = "https://github.com/khuey/bb8" } +bb8-redis = "0.3" chrono = "0.4" config = "0.9" dotenv = "0.13" From 0cd8045179205cd95c085114fefd6e57c0f7350b Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 22 Jul 2019 12:18:17 +0300 Subject: [PATCH 397/735] Refactor member --- .../endpoints/webrtc/play_endpoint.rs | 17 +++---- .../endpoints/webrtc/publish_endpoint.rs | 13 +++--- src/signalling/elements/member.rs | 46 ++++++++++++++----- src/signalling/participants.rs | 9 ++-- 4 files changed, 55 insertions(+), 30 deletions(-) diff --git a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs index ef218df70..b0b2e61cd 100644 --- a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs @@ -18,6 +18,7 @@ use crate::{ use super::publish_endpoint::WebRtcPublishEndpoint; +use crate::signalling::elements::member::WeakMember; pub use Id as WebRtcPlayId; macro_attr! { @@ -40,7 +41,7 @@ struct WebRtcPlayEndpointInner { src: WeakWebRtcPublishEndpoint, /// Owner [`Member`] of this [`WebRtcPlayEndpoint`]. - owner: Weak, + owner: WeakMember, /// [`PeerId`] of [`Peer`] created for this [`WebRtcPlayEndpoint`]. /// @@ -57,12 +58,12 @@ impl WebRtcPlayEndpointInner { self.src_uri.clone() } - fn owner(&self) -> Rc { - Weak::upgrade(&self.owner).unwrap() + fn owner(&self) -> Member { + self.owner.upgrade() } - fn weak_owner(&self) -> Weak { - Weak::clone(&self.owner) + fn weak_owner(&self) -> WeakMember { + self.owner.clone() } fn src(&self) -> WebRtcPublishEndpoint { @@ -101,7 +102,7 @@ impl WebRtcPlayEndpoint { id: Id, src_uri: SrcUri, publisher: WeakWebRtcPublishEndpoint, - owner: Weak, + owner: WeakMember, ) -> Self { Self(Rc::new(RefCell::new(WebRtcPlayEndpointInner { id, @@ -120,13 +121,13 @@ impl WebRtcPlayEndpoint { /// Returns owner [`Member`] of this [`WebRtcPlayEndpoint`]. /// /// __This function will panic if pointer is empty.__ - pub fn owner(&self) -> Rc { + pub fn owner(&self) -> Member { self.0.borrow().owner() } /// Returns `Weak` pointer to owner [`Member`] of this /// [`WebRtcPlayEndpoint`]. - pub fn weak_owner(&self) -> Weak { + pub fn weak_owner(&self) -> WeakMember { self.0.borrow().weak_owner() } diff --git a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs index a699d97c8..de65ebb11 100644 --- a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs @@ -19,6 +19,7 @@ use crate::{ use super::play_endpoint::WebRtcPlayEndpoint; +use crate::signalling::elements::member::WeakMember; pub use Id as WebRtcPublishId; macro_attr! { @@ -39,7 +40,7 @@ struct WebRtcPublishEndpointInner { sinks: Vec, /// Owner [`Member`] of this [`WebRtcPublishEndpoint`]. - owner: Weak, + owner: WeakMember, /// [`PeerId`] of all [`Peer`]s created for this [`WebRtcPublishEndpoint`]. /// @@ -52,7 +53,7 @@ struct WebRtcPublishEndpointInner { impl Drop for WebRtcPublishEndpointInner { fn drop(&mut self) { for receiver in self.sinks.iter().filter_map(|r| r.safe_upgrade()) { - if let Some(receiver_owner) = receiver.weak_owner().upgrade() { + if let Some(receiver_owner) = receiver.weak_owner().safe_upgrade() { receiver_owner.remove_sink(&receiver.id()) } } @@ -68,8 +69,8 @@ impl WebRtcPublishEndpointInner { self.sinks.iter().map(|p| p.upgrade()).collect() } - fn owner(&self) -> Rc { - Weak::upgrade(&self.owner).unwrap() + fn owner(&self) -> Member { + self.owner.upgrade() } fn add_peer_id(&mut self, peer_id: PeerId) { @@ -107,7 +108,7 @@ impl WebRtcPublishEndpoint { id: Id, p2p: P2pMode, sinks: Vec, - owner: Weak, + owner: WeakMember, ) -> Self { Self(Rc::new(RefCell::new(WebRtcPublishEndpointInner { id, @@ -133,7 +134,7 @@ impl WebRtcPublishEndpoint { /// Returns owner [`Member`] of this [`WebRtcPublishEndpoint`]. /// /// __This function will panic if pointer is empty.__ - pub fn owner(&self) -> Rc { + pub fn owner(&self) -> Member { self.0.borrow().owner() } diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index 6cf697009..bb17300b9 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -15,6 +15,7 @@ use crate::{ use super::endpoints::webrtc::{ WebRtcPlayEndpoint, WebRtcPlayId, WebRtcPublishEndpoint, WebRtcPublishId, }; +use std::rc::Weak; /// Errors which may occur while loading [`Member`]s from [`RoomSpec`]. #[derive(Debug, Fail)] @@ -39,8 +40,8 @@ impl From for MembersLoadError { } /// [`Member`] is member of [`Room`] with [`RpcConnection`]. -#[derive(Debug)] -pub struct Member(RefCell); +#[derive(Clone, Debug)] +pub struct Member(Rc>); #[allow(clippy::module_name_repetitions)] #[derive(Debug)] @@ -66,20 +67,20 @@ impl Member { /// To fill this [`Member`], you need to call the [`Member::load`] /// function. fn new(id: MemberId, credentials: String) -> Self { - Self(RefCell::new(MemberInner { + Self(Rc::new(RefCell::new(MemberInner { id, srcs: HashMap::new(), sinks: HashMap::new(), credentials, ice_user: None, - })) + }))) } /// Load all srcs and sinks of this [`Member`]. fn load( &self, room_spec: &RoomSpec, - store: &HashMap>, + store: &HashMap, ) -> Result<(), MembersLoadError> { let this_member_spec = MemberSpec::try_from( room_spec @@ -134,7 +135,7 @@ impl Member { new_play_endpoint_id.clone(), spec_play_endpoint.src.clone(), publisher.downgrade(), - Rc::downgrade(&this_member), + this_member.downgrade(), ); self.insert_sink(new_play_endpoint.clone()); @@ -148,7 +149,7 @@ impl Member { new_publish_id.clone(), publisher_endpoint.p2p.clone(), Vec::new(), - Rc::downgrade(&publisher_member), + publisher_member.downgrade(), ); let new_self_play_id = WebRtcPlayId(spec_play_name.to_string()); @@ -156,7 +157,7 @@ impl Member { new_self_play_id.clone(), spec_play_endpoint.src.clone(), new_publish.downgrade(), - Rc::downgrade(&this_member), + this_member.downgrade(), ); new_publish.add_sink(new_self_play.downgrade()); @@ -177,7 +178,7 @@ impl Member { endpoint_id, e.p2p.clone(), Vec::new(), - Rc::downgrade(&this_member), + this_member.downgrade(), )); } }, @@ -271,6 +272,29 @@ impl Member { pub fn remove_src(&self, id: &WebRtcPublishId) { self.0.borrow_mut().srcs.remove(id); } + + /// Downgrade strong [`Member`]'s pointer to weak [`WeakMember`] pointer. + pub fn downgrade(&self) -> WeakMember { + WeakMember(Rc::downgrade(&self.0)) + } +} + +/// Weak pointer to [`Member`]. +#[derive(Clone, Debug)] +pub struct WeakMember(Weak>); + +impl WeakMember { + /// Upgrade weak pointer to strong pointer. + /// + /// This function will __panic__ if weak pointer is `None`. + pub fn upgrade(&self) -> Member { + Member(Weak::upgrade(&self.0).unwrap()) + } + + /// Safe upgrade to [`Member`]. + pub fn safe_upgrade(&self) -> Option { + Weak::upgrade(&self.0).map(|m| Member(m)) + } } /// Creates all empty [`Member`] from [`RoomSpec`] and then @@ -279,14 +303,14 @@ impl Member { /// Returns store of all [`Member`]s loaded from [`RoomSpec`]. pub fn parse_members( room_spec: &RoomSpec, -) -> Result>, MembersLoadError> { +) -> Result, MembersLoadError> { let members_spec = room_spec.members()?; let mut members = HashMap::new(); for (id, member) in &members_spec { members.insert( id.clone(), - Rc::new(Member::new(id.clone(), member.credentials().to_string())), + Member::new(id.clone(), member.credentials().to_string()), ); } diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index c17f7d721..b8bc282be 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -4,7 +4,6 @@ //! credentials management. use std::{ - rc::Rc, sync::Arc, time::{Duration, Instant}, }; @@ -74,7 +73,7 @@ pub struct ParticipantService { room_id: RoomId, /// [`Member`]s which currently are present in this [`Room`]. - members: HashMap>, + members: HashMap, /// Service for managing authorization on Turn server. turn: Arc, @@ -112,7 +111,7 @@ impl ParticipantService { } /// Lookup [`Member`] by provided id. - pub fn get_member_by_id(&self, id: &MemberId) -> Option> { + pub fn get_member_by_id(&self, id: &MemberId) -> Option { self.members.get(id).cloned() } @@ -125,7 +124,7 @@ impl ParticipantService { &self, member_id: &MemberId, credentials: &str, - ) -> Result, AuthorizationError> { + ) -> Result { match self.get_member_by_id(member_id) { Some(member) => { if member.credentials().eq(credentials) { @@ -169,7 +168,7 @@ impl ParticipantService { ctx: &mut Context, member_id: MemberId, con: Box, - ) -> ActFuture, ParticipantServiceErr> { + ) -> ActFuture { let member = match self.get_member_by_id(&member_id) { None => { return Box::new(wrap_future(future::err( From 41fd58a8bc5dc28544cb469fa1d756635e86ab2b Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 22 Jul 2019 12:29:50 +0300 Subject: [PATCH 398/735] Fix tests --- .../endpoints/webrtc/play_endpoint.rs | 7 ++++++ .../endpoints/webrtc/publish_endpoint.rs | 7 ++++++ src/signalling/elements/member.rs | 22 +++++++++++-------- 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs index b0b2e61cd..62daa2268 100644 --- a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs @@ -165,6 +165,13 @@ impl WebRtcPlayEndpoint { pub fn downgrade(&self) -> WeakWebRtcPlayEndpoint { WeakWebRtcPlayEndpoint(Rc::downgrade(&self.0)) } + + /// Compares pointers. If both pointers point to the same address, then + /// returns true. + #[cfg(test)] + pub fn ptr_eq(&self, another_play: &Self) -> bool { + Rc::ptr_eq(&self.0, &another_play.0) + } } /// Weak pointer to [`WebRtcPlayEndpoint`]. diff --git a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs index de65ebb11..f97f45a86 100644 --- a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs @@ -185,6 +185,13 @@ impl WebRtcPublishEndpoint { pub fn downgrade(&self) -> WeakWebRtcPublishEndpoint { WeakWebRtcPublishEndpoint(Rc::downgrade(&self.0)) } + + /// Compares pointers. If both pointers point to the same address, then + /// returns true. + #[cfg(test)] + pub fn ptr_eq(&self, another_publish: &Self) -> bool { + Rc::ptr_eq(&self.0, &another_publish.0) + } } /// Weak pointer to [`WebRtcPublishEndpoint`]. diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index bb17300b9..0aaa37544 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -277,6 +277,13 @@ impl Member { pub fn downgrade(&self) -> WeakMember { WeakMember(Rc::downgrade(&self.0)) } + + /// Compares pointers. If both pointers point to the same address, then + /// returns true. + #[cfg(test)] + pub fn ptr_eq(&self, another_member: &Self) -> bool { + Rc::ptr_eq(&self.0, &another_member.0) + } } /// Weak pointer to [`Member`]. @@ -344,8 +351,6 @@ pub fn parse_members( #[cfg(test)] mod tests { - use std::rc::Rc; - use crate::api::control::{Element, MemberId}; use super::*; @@ -393,7 +398,7 @@ mod tests { T::from(s.to_string()) } - fn get_test_store() -> HashMap> { + fn get_test_store() -> HashMap { let room_element: Element = serde_yaml::from_str(TEST_SPEC).unwrap(); let room_spec = RoomSpec::try_from(&room_element).unwrap(); parse_members(&room_spec).unwrap() @@ -414,15 +419,14 @@ mod tests { let is_caller_has_responder_in_sinks = caller_publish_endpoint .sinks() .into_iter() - .filter(|p| Rc::ptr_eq(p, &responder_play_endpoint)) + .filter(|p| p.ptr_eq(&responder_play_endpoint)) .count() == 1; assert!(is_caller_has_responder_in_sinks); - assert!(Rc::ptr_eq( - &responder_play_endpoint.src(), - &caller_publish_endpoint - )); + assert!(responder_play_endpoint + .src() + .ptr_eq(&caller_publish_endpoint)); let some_member = store.get(&id("some-member")).unwrap(); assert!(some_member.sinks().is_empty()); @@ -436,7 +440,7 @@ mod tests { let is_some_member_has_responder_in_sinks = some_member_publisher .sinks() .into_iter() - .filter(|p| Rc::ptr_eq(p, &responder_play2_endpoint)) + .filter(|p| p.ptr_eq(&responder_play2_endpoint)) .count() == 1; assert!(is_some_member_has_responder_in_sinks); From 090a825a969e5a83dd0929c14d1d144cfa0505d9 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 22 Jul 2019 12:33:57 +0300 Subject: [PATCH 399/735] Fix lints --- .../elements/endpoints/webrtc/play_endpoint.rs | 3 ++- .../elements/endpoints/webrtc/publish_endpoint.rs | 14 +++++++++++--- src/signalling/elements/member.rs | 3 ++- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs index 62daa2268..02a06f172 100644 --- a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs @@ -175,6 +175,7 @@ impl WebRtcPlayEndpoint { } /// Weak pointer to [`WebRtcPlayEndpoint`]. +#[allow(clippy::module_name_repetitions)] #[derive(Debug, Clone)] pub struct WeakWebRtcPlayEndpoint(Weak>); @@ -188,6 +189,6 @@ impl WeakWebRtcPlayEndpoint { /// Safe upgrade to [`WebRtcPlayEndpoint`]. pub fn safe_upgrade(&self) -> Option { - self.0.upgrade().map(|i| WebRtcPlayEndpoint(i)) + self.0.upgrade().map(WebRtcPlayEndpoint) } } diff --git a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs index f97f45a86..59eceb702 100644 --- a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs @@ -52,7 +52,11 @@ struct WebRtcPublishEndpointInner { impl Drop for WebRtcPublishEndpointInner { fn drop(&mut self) { - for receiver in self.sinks.iter().filter_map(|r| r.safe_upgrade()) { + for receiver in self + .sinks + .iter() + .filter_map(WeakWebRtcPlayEndpoint::safe_upgrade) + { if let Some(receiver_owner) = receiver.weak_owner().safe_upgrade() { receiver_owner.remove_sink(&receiver.id()) } @@ -66,7 +70,10 @@ impl WebRtcPublishEndpointInner { } fn sinks(&self) -> Vec { - self.sinks.iter().map(|p| p.upgrade()).collect() + self.sinks + .iter() + .map(WeakWebRtcPlayEndpoint::upgrade) + .collect() } fn owner(&self) -> Member { @@ -195,6 +202,7 @@ impl WebRtcPublishEndpoint { } /// Weak pointer to [`WebRtcPublishEndpoint`]. +#[allow(clippy::module_name_repetitions)] #[derive(Debug, Clone)] pub struct WeakWebRtcPublishEndpoint(Weak>); @@ -208,6 +216,6 @@ impl WeakWebRtcPublishEndpoint { /// Safe upgrade to [`WebRtcPlayEndpoint`]. pub fn safe_upgrade(&self) -> Option { - self.0.upgrade().map(|i| WebRtcPublishEndpoint(i)) + self.0.upgrade().map(WebRtcPublishEndpoint) } } diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index 0aaa37544..4e2226a97 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -287,6 +287,7 @@ impl Member { } /// Weak pointer to [`Member`]. +#[allow(clippy::module_name_repetitions)] #[derive(Clone, Debug)] pub struct WeakMember(Weak>); @@ -300,7 +301,7 @@ impl WeakMember { /// Safe upgrade to [`Member`]. pub fn safe_upgrade(&self) -> Option { - Weak::upgrade(&self.0).map(|m| Member(m)) + Weak::upgrade(&self.0).map(Member) } } From fd1da6e7d71302e226792eb34fe430425803a472 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 22 Jul 2019 13:03:31 +0300 Subject: [PATCH 400/735] Refactor, fix broken build --- .../control/endpoints/webrtc_play_endpoint.rs | 2 +- src/api/control/grpc/server.rs | 3 +- src/api/control/member.rs | 4 +- src/api/control/room.rs | 6 +-- src/api/error_codes.rs | 4 +- src/bin/client.rs | 2 +- src/lib.rs | 16 +++---- .../endpoints/webrtc/play_endpoint.rs | 13 +++--- .../endpoints/webrtc/publish_endpoint.rs | 27 ++++++------ src/signalling/elements/member.rs | 25 ++++++----- src/signalling/participants.rs | 42 +++++++++---------- src/signalling/room.rs | 5 +-- 12 files changed, 70 insertions(+), 79 deletions(-) diff --git a/src/api/control/endpoints/webrtc_play_endpoint.rs b/src/api/control/endpoints/webrtc_play_endpoint.rs index e48e4cb47..f0e278780 100644 --- a/src/api/control/endpoints/webrtc_play_endpoint.rs +++ b/src/api/control/endpoints/webrtc_play_endpoint.rs @@ -4,12 +4,12 @@ use std::{convert::TryFrom, fmt}; use failure::Fail; use macro_attr::*; +use medea_grpc_proto::control::WebRtcPlayEndpoint as WebRtcPlayEndpointProto; use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; use serde::{ de::{self, Deserializer, Error, Visitor}, Deserialize, }; -use medea_grpc_proto::control::WebRtcPlayEndpoint as WebRtcPlayEndpointProto; use crate::api::control::{ endpoints::webrtc_publish_endpoint::WebRtcPublishId, diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index df9a5b60c..cb9c42f57 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -14,8 +14,7 @@ use futures::future::{self, Either, Future}; use grpcio::{Environment, RpcContext, Server, ServerBuilder, UnarySink}; use medea_grpc_proto::{ control::{ - ApplyRequest, CreateRequest, Error, GetResponse, IdRequest, - Response, + ApplyRequest, CreateRequest, Error, GetResponse, IdRequest, Response, }, control_grpc::{create_control_api, ControlApi}, }; diff --git a/src/api/control/member.rs b/src/api/control/member.rs index fcd2cd8d8..eb6fd0275 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -4,9 +4,10 @@ use std::{collections::HashMap as StdHashMap, convert::TryFrom}; use hashbrown::HashMap; use macro_attr::*; +use medea_grpc_proto::control::Member as MemberProto; use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; +use rand::{distributions::Alphanumeric, Rng}; use serde::Deserialize; -use medea_grpc_proto::control::Member as MemberProto; use crate::api::control::{ endpoints::{ @@ -17,7 +18,6 @@ use crate::api::control::{ }; use super::{pipeline::Pipeline, Element, TryFromElementError}; -use rand::{distributions::Alphanumeric, Rng}; const MEMBER_CREDENTIALS_LEN: usize = 32; diff --git a/src/api/control/room.rs b/src/api/control/room.rs index c75a4c661..e3dc46a1d 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -4,13 +4,11 @@ use std::{collections::HashMap as StdHashMap, convert::TryFrom}; use hashbrown::HashMap; use macro_attr::*; +use medea_grpc_proto::control::Room as RoomProto; use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; use serde::Deserialize; -use medea_grpc_proto::control::Room as RoomProto; -use crate::api::control::{ - TryFromProtobufError, -}; +use crate::api::control::TryFromProtobufError; use super::{ member::MemberSpec, pipeline::Pipeline, Element, MemberId, diff --git a/src/api/error_codes.rs b/src/api/error_codes.rs index cde208dbe..716641b98 100644 --- a/src/api/error_codes.rs +++ b/src/api/error_codes.rs @@ -7,9 +7,7 @@ //! * __1200...1299__ Parse errors //! * __1300...1399__ Conflicts -use medea_grpc_proto::control::{ - Error as ErrorProto, -}; +use medea_grpc_proto::control::Error as ErrorProto; use crate::{ api::control::{ diff --git a/src/bin/client.rs b/src/bin/client.rs index 3e377f321..81d483b4b 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -3,7 +3,7 @@ use std::{collections::HashMap, sync::Arc}; use grpcio::{ChannelBuilder, EnvBuilder}; -use medea::api::control::grpc::protos::{ +use medea_grpc_proto::{ control::{ CreateRequest, IdRequest, Member, Member_Element, Room, Room_Element, WebRtcPlayEndpoint, WebRtcPublishEndpoint, WebRtcPublishEndpoint_P2P, diff --git a/src/lib.rs b/src/lib.rs index 3c3233986..f171df493 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,14 +1,14 @@ //! Medea media server application. #[macro_use] -mod utils; -mod api; -mod conf; -mod log; -mod media; -mod shutdown; -mod signalling; -mod turn; +pub mod utils; +pub mod api; +pub mod conf; +pub mod log; +pub mod media; +pub mod shutdown; +pub mod signalling; +pub mod turn; use std::sync::Arc; diff --git a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs index 537c25305..dec9edfbb 100644 --- a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs @@ -11,16 +11,17 @@ use medea_grpc_proto::control::{ }; use crate::{ - api::control::{ - endpoints::webrtc_play_endpoint::{SrcUri, WebRtcPlayId as Id}, + api::control::endpoints::webrtc_play_endpoint::{ + SrcUri, WebRtcPlayId as Id, }, media::PeerId, - signalling::elements::Member, + signalling::elements::{ + endpoints::webrtc::publish_endpoint::WeakWebRtcPublishEndpoint, + member::WeakMember, Member, + }, }; use super::publish_endpoint::WebRtcPublishEndpoint; -use crate::signalling::elements::endpoints::webrtc::publish_endpoint::WeakWebRtcPublishEndpoint; -use crate::signalling::elements::member::WeakMember; #[derive(Debug, Clone)] struct WebRtcPlayEndpointInner { @@ -188,7 +189,7 @@ impl WeakWebRtcPlayEndpoint { } } -impl Into for Rc { +impl Into for WebRtcPlayEndpoint { fn into(self) -> ElementProto { let mut element = ElementProto::new(); let mut play = WebRtcPlayEndpointProto::new(); diff --git a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs index daadd7050..8d4b897f3 100644 --- a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs @@ -12,16 +12,17 @@ use medea_grpc_proto::control::{ }; use crate::{ - api::control::{ - endpoints::webrtc_publish_endpoint::{P2pMode, WebRtcPublishId as Id}, + api::control::endpoints::webrtc_publish_endpoint::{ + P2pMode, WebRtcPublishId as Id, }, media::PeerId, - signalling::elements::Member, + signalling::elements::{ + endpoints::webrtc::play_endpoint::WeakWebRtcPlayEndpoint, + member::WeakMember, Member, + }, }; use super::play_endpoint::WebRtcPlayEndpoint; -use crate::signalling::elements::endpoints::webrtc::play_endpoint::WeakWebRtcPlayEndpoint; -use crate::signalling::elements::member::WeakMember; #[derive(Debug, Clone)] struct WebRtcPublishEndpointInner { @@ -106,11 +107,7 @@ pub struct WebRtcPublishEndpoint(Rc>); impl WebRtcPublishEndpoint { /// Create new [`WebRtcPublishEndpoint`]. - pub fn new( - id: Id, - p2p: P2pMode, - owner: WeakMember, - ) -> Self { + pub fn new(id: Id, p2p: P2pMode, owner: WeakMember) -> Self { Self(Rc::new(RefCell::new(WebRtcPublishEndpointInner { id, p2p, @@ -181,6 +178,10 @@ impl WebRtcPublishEndpoint { .retain(|e| e.safe_upgrade().is_some()); } + pub fn p2p(&self) -> P2pMode { + self.0.borrow().p2p.clone() + } + /// Downgrade [`WeakWebRtcPublishEndpoint`] to weak pointer /// [`WeakWebRtcPublishEndpoint`]. pub fn downgrade(&self) -> WeakWebRtcPublishEndpoint { @@ -212,13 +213,9 @@ impl WeakWebRtcPublishEndpoint { pub fn safe_upgrade(&self) -> Option { self.0.upgrade().map(WebRtcPublishEndpoint) } - - pub fn p2p(&self) -> P2pMode { - self.0.borrow().p2p.clone() - } } -impl Into for Rc { +impl Into for WebRtcPublishEndpoint { fn into(self) -> ElementProto { let mut element = ElementProto::new(); let mut publish = WebRtcPublishEndpointProto::new(); diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index 0a7b60f93..435e4cae4 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -1,8 +1,10 @@ //! [`Member`] is member of [`Room`] with [`RpcConnection`]. use std::{ - cell::RefCell, collections::HashMap as StdHashMap, convert::TryFrom as _, - rc::Rc, + cell::RefCell, + collections::HashMap as StdHashMap, + convert::TryFrom as _, + rc::{Rc, Weak}, }; use failure::Fail; @@ -26,7 +28,6 @@ use crate::{ }; use super::endpoints::webrtc::{WebRtcPlayEndpoint, WebRtcPublishEndpoint}; -use std::rc::Weak; /// Errors which may occur while loading [`Member`]s from [`RoomSpec`]. #[derive(Debug, Fail)] @@ -195,11 +196,11 @@ impl Member { publisher.add_sink(new_play_endpoint.downgrade()); } else { let new_publish_id = &spec_play_endpoint.src.endpoint_id; - let new_publish = Rc::new(WebRtcPublishEndpoint::new( + let new_publish = WebRtcPublishEndpoint::new( new_publish_id.clone(), publisher_endpoint.p2p.clone(), publisher_member.downgrade(), - )); + ); let new_self_play_id = WebRtcPlayId(spec_play_name.to_string()); let new_self_play = WebRtcPlayEndpoint::new( @@ -325,7 +326,7 @@ impl Member { pub fn get_src( &self, id: &WebRtcPublishId, - ) -> Result, MemberError> { + ) -> Result { self.0.borrow().srcs.get(id).cloned().map_or_else( || { Err(MemberError::PublishEndpointNotFound( @@ -351,7 +352,7 @@ impl Member { pub fn get_sink( &self, id: &WebRtcPlayId, - ) -> Result, MemberError> { + ) -> Result { self.0.borrow().sinks.get(id).cloned().map_or_else( || { Err(MemberError::PlayEndpointNotFound( @@ -373,10 +374,7 @@ impl Member { } /// Take sink from [`Member`]'s `sinks`. - pub fn take_sink( - &self, - id: &WebRtcPlayId, - ) -> Option> { + pub fn take_sink(&self, id: &WebRtcPlayId) -> Option { self.0.borrow_mut().sinks.remove(id) } @@ -384,7 +382,7 @@ impl Member { pub fn take_src( &self, id: &WebRtcPublishId, - ) -> Option> { + ) -> Option { self.0.borrow_mut().srcs.remove(id) } @@ -414,6 +412,7 @@ impl Member { src.add_sink(sink.downgrade()); member.insert_sink(sink); } + /// Downgrade strong [`Member`]'s pointer to weak [`WeakMember`] pointer. pub fn downgrade(&self) -> WeakMember { WeakMember(Rc::downgrade(&self.0)) @@ -505,7 +504,7 @@ pub fn parse_members( Ok(members) } -impl Into for Rc { +impl Into for Member { fn into(self) -> ElementProto { let mut element = ElementProto::new(); let mut member = MemberProto::new(); diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 195c68bb7..838df45e4 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -3,7 +3,7 @@ //! [`RpcConnection`] authorization, establishment, message sending, Turn //! credentials management. -use std::{rc::Rc, time::Instant}; +use std::time::Instant; use actix::{ fut::wrap_future, ActorFuture, AsyncContext, Context, MailboxError, @@ -151,7 +151,7 @@ impl ParticipantService { pub fn get_member( &self, id: &MemberId, - ) -> Result, ParticipantServiceErr> { + ) -> Result { self.members.get(id).cloned().map_or( Err(ParticipantServiceErr::ParticipantNotFound( self.get_local_uri_to_member(id.clone()), @@ -161,7 +161,7 @@ impl ParticipantService { } /// Returns all [`Member`] from this [`ParticipantService`]. - pub fn members(&self) -> HashMap> { + pub fn members(&self) -> HashMap { self.members.clone() } @@ -414,18 +414,18 @@ impl ParticipantService { self.get_local_uri_to_member(id), )); } - let signalling_member = Rc::new(Member::new( + let signalling_member = Member::new( id.clone(), spec.credentials().to_string(), self.room_id.clone(), - )); + ); for (id, publish) in spec.publish_endpoints() { - let signalling_publish = Rc::new(WebRtcPublishEndpoint::new( + let signalling_publish = WebRtcPublishEndpoint::new( id.clone(), publish.p2p.clone(), - Rc::downgrade(&signalling_member), - )); + signalling_member.downgrade(), + ); signalling_member.insert_src(signalling_publish); } @@ -433,12 +433,12 @@ impl ParticipantService { let partner_member = self.get_member(&play.src.member_id)?; let src = partner_member.get_src(&play.src.endpoint_id)?; - let sink = Rc::new(WebRtcPlayEndpoint::new( + let sink = WebRtcPlayEndpoint::new( id.clone(), play.src.clone(), - Rc::downgrade(&src), - Rc::downgrade(&signalling_member), - )); + src.downgrade(), + signalling_member.downgrade(), + ); signalling_member.insert_sink(sink); } @@ -446,7 +446,7 @@ impl ParticipantService { // This is needed for atomicity. for (_, sink) in signalling_member.sinks() { let src = sink.src(); - src.add_sink(Rc::downgrade(&sink)); + src.add_sink(sink.downgrade()); } self.members.insert(id, signalling_member); @@ -481,14 +481,14 @@ impl ParticipantService { let partner_member = self.get_member(&spec.src.member_id)?; let src = partner_member.get_src(&spec.src.endpoint_id)?; - let sink = Rc::new(WebRtcPlayEndpoint::new( + let sink = WebRtcPlayEndpoint::new( endpoint_id.clone(), spec.src, - Rc::downgrade(&src), - Rc::downgrade(&member), - )); + src.downgrade(), + member.downgrade(), + ); - src.add_sink(Rc::downgrade(&sink)); + src.add_sink(sink.downgrade()); member.insert_sink(sink); debug!( @@ -525,11 +525,11 @@ impl ParticipantService { )); } - let src = Rc::new(WebRtcPublishEndpoint::new( + let src = WebRtcPublishEndpoint::new( endpoint_id.clone(), spec.p2p, - Rc::downgrade(&member), - )); + member.downgrade(), + ); member.insert_src(src); diff --git a/src/signalling/room.rs b/src/signalling/room.rs index eb1dc9cf2..b51921b9f 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -1,7 +1,7 @@ //! Room definitions and implementations. Room is responsible for media //! connection establishment between concrete [`Member`]s. -use std::{collections::HashMap as StdHashMap}; +use std::collections::HashMap as StdHashMap; use actix::{ fut::wrap_future, Actor, ActorFuture, AsyncContext, Context, Handler, @@ -12,8 +12,7 @@ use futures::future; use hashbrown::{HashMap, HashSet}; use medea_client_api_proto::{Command, Event, IceCandidate}; use medea_grpc_proto::control::{ - Element as ElementProto, Member_Element, Room as RoomProto, - Room_Element, + Element as ElementProto, Member_Element, Room as RoomProto, Room_Element, }; use crate::{ From bb9b6b19814b9a15c5414f281b8a2b9be459eb04 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 22 Jul 2019 13:05:35 +0300 Subject: [PATCH 401/735] Remove generated protobuf from git --- .gitignore | 5 +- proto/grpc/src/control.rs | 5966 -------------------------------- proto/grpc/src/control_grpc.rs | 155 - 3 files changed, 2 insertions(+), 6124 deletions(-) delete mode 100644 proto/grpc/src/control.rs delete mode 100644 proto/grpc/src/control_grpc.rs diff --git a/.gitignore b/.gitignore index ddd4d7b05..54745b8de 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,5 @@ /target/ **/*.rs.bk -/src/api/control/grpc/protos -!/src/api/control/grpc/protos/mod.rs -!/src/api/control/grpc/protos/control.proto +!/proto/grpc/src +!/proto/grpc/src/lib.rs diff --git a/proto/grpc/src/control.rs b/proto/grpc/src/control.rs deleted file mode 100644 index c6ee0063d..000000000 --- a/proto/grpc/src/control.rs +++ /dev/null @@ -1,5966 +0,0 @@ -// This file is generated by rust-protobuf 2.7.0. Do not edit -// @generated - -// https://github.com/Manishearth/rust-clippy/issues/702 -#![allow(unknown_lints)] -#![allow(clippy::all)] - -#![cfg_attr(rustfmt, rustfmt_skip)] - -#![allow(box_pointers)] -#![allow(dead_code)] -#![allow(missing_docs)] -#![allow(non_camel_case_types)] -#![allow(non_snake_case)] -#![allow(non_upper_case_globals)] -#![allow(trivial_casts)] -#![allow(unsafe_code)] -#![allow(unused_imports)] -#![allow(unused_results)] -//! Generated file from `control.proto` - -use protobuf::Message as Message_imported_for_functions; -use protobuf::ProtobufEnum as ProtobufEnum_imported_for_functions; - -/// Generated files are compatible only with the same version -/// of protobuf runtime. -const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_7_0; - -#[derive(PartialEq,Clone,Default)] -pub struct CreateRequest { - // message fields - pub id: ::std::string::String, - // message oneof groups - pub el: ::std::option::Option, - // special fields - pub unknown_fields: ::protobuf::UnknownFields, - pub cached_size: ::protobuf::CachedSize, -} - -impl<'a> ::std::default::Default for &'a CreateRequest { - fn default() -> &'a CreateRequest { - ::default_instance() - } -} - -#[derive(Clone,PartialEq,Debug)] -pub enum CreateRequest_oneof_el { - hub(Hub), - file_recorder(FileRecorder), - member(Member), - relay(Relay), - room(Room), - webrtc_play(WebRtcPlayEndpoint), - webrtc_pub(WebRtcPublishEndpoint), -} - -impl CreateRequest { - pub fn new() -> CreateRequest { - ::std::default::Default::default() - } - - // string id = 1; - - - pub fn get_id(&self) -> &str { - &self.id - } - pub fn clear_id(&mut self) { - self.id.clear(); - } - - // Param is passed by value, moved - pub fn set_id(&mut self, v: ::std::string::String) { - self.id = v; - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_id(&mut self) -> &mut ::std::string::String { - &mut self.id - } - - // Take field - pub fn take_id(&mut self) -> ::std::string::String { - ::std::mem::replace(&mut self.id, ::std::string::String::new()) - } - - // .medea.Hub hub = 2; - - - pub fn get_hub(&self) -> &Hub { - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::hub(ref v)) => v, - _ => Hub::default_instance(), - } - } - pub fn clear_hub(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_hub(&self) -> bool { - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::hub(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_hub(&mut self, v: Hub) { - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::hub(v)) - } - - // Mutable pointer to the field. - pub fn mut_hub(&mut self) -> &mut Hub { - if let ::std::option::Option::Some(CreateRequest_oneof_el::hub(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::hub(Hub::new())); - } - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::hub(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_hub(&mut self) -> Hub { - if self.has_hub() { - match self.el.take() { - ::std::option::Option::Some(CreateRequest_oneof_el::hub(v)) => v, - _ => panic!(), - } - } else { - Hub::new() - } - } - - // .medea.FileRecorder file_recorder = 3; - - - pub fn get_file_recorder(&self) -> &FileRecorder { - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::file_recorder(ref v)) => v, - _ => FileRecorder::default_instance(), - } - } - pub fn clear_file_recorder(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_file_recorder(&self) -> bool { - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::file_recorder(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_file_recorder(&mut self, v: FileRecorder) { - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::file_recorder(v)) - } - - // Mutable pointer to the field. - pub fn mut_file_recorder(&mut self) -> &mut FileRecorder { - if let ::std::option::Option::Some(CreateRequest_oneof_el::file_recorder(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::file_recorder(FileRecorder::new())); - } - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::file_recorder(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_file_recorder(&mut self) -> FileRecorder { - if self.has_file_recorder() { - match self.el.take() { - ::std::option::Option::Some(CreateRequest_oneof_el::file_recorder(v)) => v, - _ => panic!(), - } - } else { - FileRecorder::new() - } - } - - // .medea.Member member = 4; - - - pub fn get_member(&self) -> &Member { - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::member(ref v)) => v, - _ => Member::default_instance(), - } - } - pub fn clear_member(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_member(&self) -> bool { - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::member(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_member(&mut self, v: Member) { - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::member(v)) - } - - // Mutable pointer to the field. - pub fn mut_member(&mut self) -> &mut Member { - if let ::std::option::Option::Some(CreateRequest_oneof_el::member(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::member(Member::new())); - } - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::member(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_member(&mut self) -> Member { - if self.has_member() { - match self.el.take() { - ::std::option::Option::Some(CreateRequest_oneof_el::member(v)) => v, - _ => panic!(), - } - } else { - Member::new() - } - } - - // .medea.Relay relay = 5; - - - pub fn get_relay(&self) -> &Relay { - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::relay(ref v)) => v, - _ => Relay::default_instance(), - } - } - pub fn clear_relay(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_relay(&self) -> bool { - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::relay(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_relay(&mut self, v: Relay) { - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::relay(v)) - } - - // Mutable pointer to the field. - pub fn mut_relay(&mut self) -> &mut Relay { - if let ::std::option::Option::Some(CreateRequest_oneof_el::relay(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::relay(Relay::new())); - } - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::relay(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_relay(&mut self) -> Relay { - if self.has_relay() { - match self.el.take() { - ::std::option::Option::Some(CreateRequest_oneof_el::relay(v)) => v, - _ => panic!(), - } - } else { - Relay::new() - } - } - - // .medea.Room room = 6; - - - pub fn get_room(&self) -> &Room { - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::room(ref v)) => v, - _ => Room::default_instance(), - } - } - pub fn clear_room(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_room(&self) -> bool { - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::room(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_room(&mut self, v: Room) { - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::room(v)) - } - - // Mutable pointer to the field. - pub fn mut_room(&mut self) -> &mut Room { - if let ::std::option::Option::Some(CreateRequest_oneof_el::room(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::room(Room::new())); - } - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::room(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_room(&mut self) -> Room { - if self.has_room() { - match self.el.take() { - ::std::option::Option::Some(CreateRequest_oneof_el::room(v)) => v, - _ => panic!(), - } - } else { - Room::new() - } - } - - // .medea.WebRtcPlayEndpoint webrtc_play = 7; - - - pub fn get_webrtc_play(&self) -> &WebRtcPlayEndpoint { - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_play(ref v)) => v, - _ => WebRtcPlayEndpoint::default_instance(), - } - } - pub fn clear_webrtc_play(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_webrtc_play(&self) -> bool { - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_play(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_webrtc_play(&mut self, v: WebRtcPlayEndpoint) { - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_play(v)) - } - - // Mutable pointer to the field. - pub fn mut_webrtc_play(&mut self) -> &mut WebRtcPlayEndpoint { - if let ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_play(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_play(WebRtcPlayEndpoint::new())); - } - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_play(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_webrtc_play(&mut self) -> WebRtcPlayEndpoint { - if self.has_webrtc_play() { - match self.el.take() { - ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_play(v)) => v, - _ => panic!(), - } - } else { - WebRtcPlayEndpoint::new() - } - } - - // .medea.WebRtcPublishEndpoint webrtc_pub = 8; - - - pub fn get_webrtc_pub(&self) -> &WebRtcPublishEndpoint { - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_pub(ref v)) => v, - _ => WebRtcPublishEndpoint::default_instance(), - } - } - pub fn clear_webrtc_pub(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_webrtc_pub(&self) -> bool { - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_pub(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_webrtc_pub(&mut self, v: WebRtcPublishEndpoint) { - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_pub(v)) - } - - // Mutable pointer to the field. - pub fn mut_webrtc_pub(&mut self) -> &mut WebRtcPublishEndpoint { - if let ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_pub(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_pub(WebRtcPublishEndpoint::new())); - } - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_pub(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_webrtc_pub(&mut self) -> WebRtcPublishEndpoint { - if self.has_webrtc_pub() { - match self.el.take() { - ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_pub(v)) => v, - _ => panic!(), - } - } else { - WebRtcPublishEndpoint::new() - } - } -} - -impl ::protobuf::Message for CreateRequest { - fn is_initialized(&self) -> bool { - if let Some(CreateRequest_oneof_el::hub(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(CreateRequest_oneof_el::file_recorder(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(CreateRequest_oneof_el::member(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(CreateRequest_oneof_el::relay(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(CreateRequest_oneof_el::room(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(CreateRequest_oneof_el::webrtc_play(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(CreateRequest_oneof_el::webrtc_pub(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - 1 => { - ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.id)?; - }, - 2 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::hub(is.read_message()?)); - }, - 3 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::file_recorder(is.read_message()?)); - }, - 4 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::member(is.read_message()?)); - }, - 5 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::relay(is.read_message()?)); - }, - 6 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::room(is.read_message()?)); - }, - 7 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_play(is.read_message()?)); - }, - 8 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_pub(is.read_message()?)); - }, - _ => { - ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - if !self.id.is_empty() { - my_size += ::protobuf::rt::string_size(1, &self.id); - } - if let ::std::option::Option::Some(ref v) = self.el { - match v { - &CreateRequest_oneof_el::hub(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &CreateRequest_oneof_el::file_recorder(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &CreateRequest_oneof_el::member(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &CreateRequest_oneof_el::relay(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &CreateRequest_oneof_el::room(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &CreateRequest_oneof_el::webrtc_play(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &CreateRequest_oneof_el::webrtc_pub(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - }; - } - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { - if !self.id.is_empty() { - os.write_string(1, &self.id)?; - } - if let ::std::option::Option::Some(ref v) = self.el { - match v { - &CreateRequest_oneof_el::hub(ref v) => { - os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &CreateRequest_oneof_el::file_recorder(ref v) => { - os.write_tag(3, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &CreateRequest_oneof_el::member(ref v) => { - os.write_tag(4, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &CreateRequest_oneof_el::relay(ref v) => { - os.write_tag(5, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &CreateRequest_oneof_el::room(ref v) => { - os.write_tag(6, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &CreateRequest_oneof_el::webrtc_play(ref v) => { - os.write_tag(7, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &CreateRequest_oneof_el::webrtc_pub(ref v) => { - os.write_tag(8, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - }; - } - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any - } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any - } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - Self::descriptor_static() - } - - fn new() -> CreateRequest { - CreateRequest::new() - } - - fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "id", - |m: &CreateRequest| { &m.id }, - |m: &mut CreateRequest| { &mut m.id }, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Hub>( - "hub", - CreateRequest::has_hub, - CreateRequest::get_hub, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, FileRecorder>( - "file_recorder", - CreateRequest::has_file_recorder, - CreateRequest::get_file_recorder, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Member>( - "member", - CreateRequest::has_member, - CreateRequest::get_member, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Relay>( - "relay", - CreateRequest::has_relay, - CreateRequest::get_relay, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Room>( - "room", - CreateRequest::has_room, - CreateRequest::get_room, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPlayEndpoint>( - "webrtc_play", - CreateRequest::has_webrtc_play, - CreateRequest::get_webrtc_play, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPublishEndpoint>( - "webrtc_pub", - CreateRequest::has_webrtc_pub, - CreateRequest::get_webrtc_pub, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "CreateRequest", - fields, - file_descriptor_proto() - ) - }) - } - } - - fn default_instance() -> &'static CreateRequest { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const CreateRequest, - }; - unsafe { - instance.get(CreateRequest::new) - } - } -} - -impl ::protobuf::Clear for CreateRequest { - fn clear(&mut self) { - self.id.clear(); - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for CreateRequest { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for CreateRequest { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) - } -} - -#[derive(PartialEq,Clone,Default)] -pub struct ApplyRequest { - // message fields - pub id: ::std::string::String, - pub policy: ApplyRequest_Policy, - // message oneof groups - pub el: ::std::option::Option, - // special fields - pub unknown_fields: ::protobuf::UnknownFields, - pub cached_size: ::protobuf::CachedSize, -} - -impl<'a> ::std::default::Default for &'a ApplyRequest { - fn default() -> &'a ApplyRequest { - ::default_instance() - } -} - -#[derive(Clone,PartialEq,Debug)] -pub enum ApplyRequest_oneof_el { - hub(Hub), - file_recorder(FileRecorder), - member(Member), - relay(Relay), - room(Room), - webrtc_play(WebRtcPlayEndpoint), - webrtc_pub(WebRtcPublishEndpoint), -} - -impl ApplyRequest { - pub fn new() -> ApplyRequest { - ::std::default::Default::default() - } - - // string id = 1; - - - pub fn get_id(&self) -> &str { - &self.id - } - pub fn clear_id(&mut self) { - self.id.clear(); - } - - // Param is passed by value, moved - pub fn set_id(&mut self, v: ::std::string::String) { - self.id = v; - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_id(&mut self) -> &mut ::std::string::String { - &mut self.id - } - - // Take field - pub fn take_id(&mut self) -> ::std::string::String { - ::std::mem::replace(&mut self.id, ::std::string::String::new()) - } - - // .medea.Hub hub = 2; - - - pub fn get_hub(&self) -> &Hub { - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::hub(ref v)) => v, - _ => Hub::default_instance(), - } - } - pub fn clear_hub(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_hub(&self) -> bool { - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::hub(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_hub(&mut self, v: Hub) { - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::hub(v)) - } - - // Mutable pointer to the field. - pub fn mut_hub(&mut self) -> &mut Hub { - if let ::std::option::Option::Some(ApplyRequest_oneof_el::hub(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::hub(Hub::new())); - } - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::hub(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_hub(&mut self) -> Hub { - if self.has_hub() { - match self.el.take() { - ::std::option::Option::Some(ApplyRequest_oneof_el::hub(v)) => v, - _ => panic!(), - } - } else { - Hub::new() - } - } - - // .medea.FileRecorder file_recorder = 3; - - - pub fn get_file_recorder(&self) -> &FileRecorder { - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::file_recorder(ref v)) => v, - _ => FileRecorder::default_instance(), - } - } - pub fn clear_file_recorder(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_file_recorder(&self) -> bool { - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::file_recorder(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_file_recorder(&mut self, v: FileRecorder) { - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::file_recorder(v)) - } - - // Mutable pointer to the field. - pub fn mut_file_recorder(&mut self) -> &mut FileRecorder { - if let ::std::option::Option::Some(ApplyRequest_oneof_el::file_recorder(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::file_recorder(FileRecorder::new())); - } - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::file_recorder(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_file_recorder(&mut self) -> FileRecorder { - if self.has_file_recorder() { - match self.el.take() { - ::std::option::Option::Some(ApplyRequest_oneof_el::file_recorder(v)) => v, - _ => panic!(), - } - } else { - FileRecorder::new() - } - } - - // .medea.Member member = 4; - - - pub fn get_member(&self) -> &Member { - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::member(ref v)) => v, - _ => Member::default_instance(), - } - } - pub fn clear_member(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_member(&self) -> bool { - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::member(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_member(&mut self, v: Member) { - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::member(v)) - } - - // Mutable pointer to the field. - pub fn mut_member(&mut self) -> &mut Member { - if let ::std::option::Option::Some(ApplyRequest_oneof_el::member(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::member(Member::new())); - } - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::member(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_member(&mut self) -> Member { - if self.has_member() { - match self.el.take() { - ::std::option::Option::Some(ApplyRequest_oneof_el::member(v)) => v, - _ => panic!(), - } - } else { - Member::new() - } - } - - // .medea.Relay relay = 5; - - - pub fn get_relay(&self) -> &Relay { - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::relay(ref v)) => v, - _ => Relay::default_instance(), - } - } - pub fn clear_relay(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_relay(&self) -> bool { - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::relay(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_relay(&mut self, v: Relay) { - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::relay(v)) - } - - // Mutable pointer to the field. - pub fn mut_relay(&mut self) -> &mut Relay { - if let ::std::option::Option::Some(ApplyRequest_oneof_el::relay(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::relay(Relay::new())); - } - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::relay(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_relay(&mut self) -> Relay { - if self.has_relay() { - match self.el.take() { - ::std::option::Option::Some(ApplyRequest_oneof_el::relay(v)) => v, - _ => panic!(), - } - } else { - Relay::new() - } - } - - // .medea.Room room = 6; - - - pub fn get_room(&self) -> &Room { - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::room(ref v)) => v, - _ => Room::default_instance(), - } - } - pub fn clear_room(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_room(&self) -> bool { - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::room(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_room(&mut self, v: Room) { - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::room(v)) - } - - // Mutable pointer to the field. - pub fn mut_room(&mut self) -> &mut Room { - if let ::std::option::Option::Some(ApplyRequest_oneof_el::room(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::room(Room::new())); - } - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::room(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_room(&mut self) -> Room { - if self.has_room() { - match self.el.take() { - ::std::option::Option::Some(ApplyRequest_oneof_el::room(v)) => v, - _ => panic!(), - } - } else { - Room::new() - } - } - - // .medea.WebRtcPlayEndpoint webrtc_play = 7; - - - pub fn get_webrtc_play(&self) -> &WebRtcPlayEndpoint { - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(ref v)) => v, - _ => WebRtcPlayEndpoint::default_instance(), - } - } - pub fn clear_webrtc_play(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_webrtc_play(&self) -> bool { - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_webrtc_play(&mut self, v: WebRtcPlayEndpoint) { - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(v)) - } - - // Mutable pointer to the field. - pub fn mut_webrtc_play(&mut self) -> &mut WebRtcPlayEndpoint { - if let ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(WebRtcPlayEndpoint::new())); - } - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_webrtc_play(&mut self) -> WebRtcPlayEndpoint { - if self.has_webrtc_play() { - match self.el.take() { - ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(v)) => v, - _ => panic!(), - } - } else { - WebRtcPlayEndpoint::new() - } - } - - // .medea.WebRtcPublishEndpoint webrtc_pub = 8; - - - pub fn get_webrtc_pub(&self) -> &WebRtcPublishEndpoint { - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(ref v)) => v, - _ => WebRtcPublishEndpoint::default_instance(), - } - } - pub fn clear_webrtc_pub(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_webrtc_pub(&self) -> bool { - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_webrtc_pub(&mut self, v: WebRtcPublishEndpoint) { - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(v)) - } - - // Mutable pointer to the field. - pub fn mut_webrtc_pub(&mut self) -> &mut WebRtcPublishEndpoint { - if let ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(WebRtcPublishEndpoint::new())); - } - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_webrtc_pub(&mut self) -> WebRtcPublishEndpoint { - if self.has_webrtc_pub() { - match self.el.take() { - ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(v)) => v, - _ => panic!(), - } - } else { - WebRtcPublishEndpoint::new() - } - } - - // .medea.ApplyRequest.Policy policy = 9; - - - pub fn get_policy(&self) -> ApplyRequest_Policy { - self.policy - } - pub fn clear_policy(&mut self) { - self.policy = ApplyRequest_Policy::APPLY; - } - - // Param is passed by value, moved - pub fn set_policy(&mut self, v: ApplyRequest_Policy) { - self.policy = v; - } -} - -impl ::protobuf::Message for ApplyRequest { - fn is_initialized(&self) -> bool { - if let Some(ApplyRequest_oneof_el::hub(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(ApplyRequest_oneof_el::file_recorder(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(ApplyRequest_oneof_el::member(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(ApplyRequest_oneof_el::relay(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(ApplyRequest_oneof_el::room(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(ApplyRequest_oneof_el::webrtc_play(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(ApplyRequest_oneof_el::webrtc_pub(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - 1 => { - ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.id)?; - }, - 2 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::hub(is.read_message()?)); - }, - 3 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::file_recorder(is.read_message()?)); - }, - 4 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::member(is.read_message()?)); - }, - 5 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::relay(is.read_message()?)); - }, - 6 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::room(is.read_message()?)); - }, - 7 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(is.read_message()?)); - }, - 8 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(is.read_message()?)); - }, - 9 => { - ::protobuf::rt::read_proto3_enum_with_unknown_fields_into(wire_type, is, &mut self.policy, 9, &mut self.unknown_fields)? - }, - _ => { - ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - if !self.id.is_empty() { - my_size += ::protobuf::rt::string_size(1, &self.id); - } - if self.policy != ApplyRequest_Policy::APPLY { - my_size += ::protobuf::rt::enum_size(9, self.policy); - } - if let ::std::option::Option::Some(ref v) = self.el { - match v { - &ApplyRequest_oneof_el::hub(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &ApplyRequest_oneof_el::file_recorder(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &ApplyRequest_oneof_el::member(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &ApplyRequest_oneof_el::relay(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &ApplyRequest_oneof_el::room(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &ApplyRequest_oneof_el::webrtc_play(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &ApplyRequest_oneof_el::webrtc_pub(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - }; - } - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { - if !self.id.is_empty() { - os.write_string(1, &self.id)?; - } - if self.policy != ApplyRequest_Policy::APPLY { - os.write_enum(9, self.policy.value())?; - } - if let ::std::option::Option::Some(ref v) = self.el { - match v { - &ApplyRequest_oneof_el::hub(ref v) => { - os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &ApplyRequest_oneof_el::file_recorder(ref v) => { - os.write_tag(3, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &ApplyRequest_oneof_el::member(ref v) => { - os.write_tag(4, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &ApplyRequest_oneof_el::relay(ref v) => { - os.write_tag(5, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &ApplyRequest_oneof_el::room(ref v) => { - os.write_tag(6, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &ApplyRequest_oneof_el::webrtc_play(ref v) => { - os.write_tag(7, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &ApplyRequest_oneof_el::webrtc_pub(ref v) => { - os.write_tag(8, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - }; - } - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any - } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any - } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - Self::descriptor_static() - } - - fn new() -> ApplyRequest { - ApplyRequest::new() - } - - fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "id", - |m: &ApplyRequest| { &m.id }, - |m: &mut ApplyRequest| { &mut m.id }, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Hub>( - "hub", - ApplyRequest::has_hub, - ApplyRequest::get_hub, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, FileRecorder>( - "file_recorder", - ApplyRequest::has_file_recorder, - ApplyRequest::get_file_recorder, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Member>( - "member", - ApplyRequest::has_member, - ApplyRequest::get_member, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Relay>( - "relay", - ApplyRequest::has_relay, - ApplyRequest::get_relay, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Room>( - "room", - ApplyRequest::has_room, - ApplyRequest::get_room, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPlayEndpoint>( - "webrtc_play", - ApplyRequest::has_webrtc_play, - ApplyRequest::get_webrtc_play, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPublishEndpoint>( - "webrtc_pub", - ApplyRequest::has_webrtc_pub, - ApplyRequest::get_webrtc_pub, - )); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeEnum>( - "policy", - |m: &ApplyRequest| { &m.policy }, - |m: &mut ApplyRequest| { &mut m.policy }, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "ApplyRequest", - fields, - file_descriptor_proto() - ) - }) - } - } - - fn default_instance() -> &'static ApplyRequest { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ApplyRequest, - }; - unsafe { - instance.get(ApplyRequest::new) - } - } -} - -impl ::protobuf::Clear for ApplyRequest { - fn clear(&mut self) { - self.id.clear(); - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.policy = ApplyRequest_Policy::APPLY; - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for ApplyRequest { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for ApplyRequest { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) - } -} - -#[derive(Clone,PartialEq,Eq,Debug,Hash)] -pub enum ApplyRequest_Policy { - APPLY = 0, - APPEND = 1, -} - -impl ::protobuf::ProtobufEnum for ApplyRequest_Policy { - fn value(&self) -> i32 { - *self as i32 - } - - fn from_i32(value: i32) -> ::std::option::Option { - match value { - 0 => ::std::option::Option::Some(ApplyRequest_Policy::APPLY), - 1 => ::std::option::Option::Some(ApplyRequest_Policy::APPEND), - _ => ::std::option::Option::None - } - } - - fn values() -> &'static [Self] { - static values: &'static [ApplyRequest_Policy] = &[ - ApplyRequest_Policy::APPLY, - ApplyRequest_Policy::APPEND, - ]; - values - } - - fn enum_descriptor_static() -> &'static ::protobuf::reflect::EnumDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::EnumDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::EnumDescriptor, - }; - unsafe { - descriptor.get(|| { - ::protobuf::reflect::EnumDescriptor::new("ApplyRequest_Policy", file_descriptor_proto()) - }) - } - } -} - -impl ::std::marker::Copy for ApplyRequest_Policy { -} - -impl ::std::default::Default for ApplyRequest_Policy { - fn default() -> Self { - ApplyRequest_Policy::APPLY - } -} - -impl ::protobuf::reflect::ProtobufValue for ApplyRequest_Policy { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Enum(self.descriptor()) - } -} - -#[derive(PartialEq,Clone,Default)] -pub struct IdRequest { - // message fields - pub id: ::protobuf::RepeatedField<::std::string::String>, - // special fields - pub unknown_fields: ::protobuf::UnknownFields, - pub cached_size: ::protobuf::CachedSize, -} - -impl<'a> ::std::default::Default for &'a IdRequest { - fn default() -> &'a IdRequest { - ::default_instance() - } -} - -impl IdRequest { - pub fn new() -> IdRequest { - ::std::default::Default::default() - } - - // repeated string id = 1; - - - pub fn get_id(&self) -> &[::std::string::String] { - &self.id - } - pub fn clear_id(&mut self) { - self.id.clear(); - } - - // Param is passed by value, moved - pub fn set_id(&mut self, v: ::protobuf::RepeatedField<::std::string::String>) { - self.id = v; - } - - // Mutable pointer to the field. - pub fn mut_id(&mut self) -> &mut ::protobuf::RepeatedField<::std::string::String> { - &mut self.id - } - - // Take field - pub fn take_id(&mut self) -> ::protobuf::RepeatedField<::std::string::String> { - ::std::mem::replace(&mut self.id, ::protobuf::RepeatedField::new()) - } -} - -impl ::protobuf::Message for IdRequest { - fn is_initialized(&self) -> bool { - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - 1 => { - ::protobuf::rt::read_repeated_string_into(wire_type, is, &mut self.id)?; - }, - _ => { - ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - for value in &self.id { - my_size += ::protobuf::rt::string_size(1, &value); - }; - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { - for v in &self.id { - os.write_string(1, &v)?; - }; - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any - } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any - } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - Self::descriptor_static() - } - - fn new() -> IdRequest { - IdRequest::new() - } - - fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "id", - |m: &IdRequest| { &m.id }, - |m: &mut IdRequest| { &mut m.id }, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "IdRequest", - fields, - file_descriptor_proto() - ) - }) - } - } - - fn default_instance() -> &'static IdRequest { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const IdRequest, - }; - unsafe { - instance.get(IdRequest::new) - } - } -} - -impl ::protobuf::Clear for IdRequest { - fn clear(&mut self) { - self.id.clear(); - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for IdRequest { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for IdRequest { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) - } -} - -#[derive(PartialEq,Clone,Default)] -pub struct Response { - // message fields - pub sid: ::std::collections::HashMap<::std::string::String, ::std::string::String>, - pub error: ::protobuf::SingularPtrField, - // special fields - pub unknown_fields: ::protobuf::UnknownFields, - pub cached_size: ::protobuf::CachedSize, -} - -impl<'a> ::std::default::Default for &'a Response { - fn default() -> &'a Response { - ::default_instance() - } -} - -impl Response { - pub fn new() -> Response { - ::std::default::Default::default() - } - - // repeated .medea.Response.SidEntry sid = 1; - - - pub fn get_sid(&self) -> &::std::collections::HashMap<::std::string::String, ::std::string::String> { - &self.sid - } - pub fn clear_sid(&mut self) { - self.sid.clear(); - } - - // Param is passed by value, moved - pub fn set_sid(&mut self, v: ::std::collections::HashMap<::std::string::String, ::std::string::String>) { - self.sid = v; - } - - // Mutable pointer to the field. - pub fn mut_sid(&mut self) -> &mut ::std::collections::HashMap<::std::string::String, ::std::string::String> { - &mut self.sid - } - - // Take field - pub fn take_sid(&mut self) -> ::std::collections::HashMap<::std::string::String, ::std::string::String> { - ::std::mem::replace(&mut self.sid, ::std::collections::HashMap::new()) - } - - // .medea.Error error = 2; - - - pub fn get_error(&self) -> &Error { - self.error.as_ref().unwrap_or_else(|| Error::default_instance()) - } - pub fn clear_error(&mut self) { - self.error.clear(); - } - - pub fn has_error(&self) -> bool { - self.error.is_some() - } - - // Param is passed by value, moved - pub fn set_error(&mut self, v: Error) { - self.error = ::protobuf::SingularPtrField::some(v); - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_error(&mut self) -> &mut Error { - if self.error.is_none() { - self.error.set_default(); - } - self.error.as_mut().unwrap() - } - - // Take field - pub fn take_error(&mut self) -> Error { - self.error.take().unwrap_or_else(|| Error::new()) - } -} - -impl ::protobuf::Message for Response { - fn is_initialized(&self) -> bool { - for v in &self.error { - if !v.is_initialized() { - return false; - } - }; - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - 1 => { - ::protobuf::rt::read_map_into::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeString>(wire_type, is, &mut self.sid)?; - }, - 2 => { - ::protobuf::rt::read_singular_message_into(wire_type, is, &mut self.error)?; - }, - _ => { - ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - my_size += ::protobuf::rt::compute_map_size::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeString>(1, &self.sid); - if let Some(ref v) = self.error.as_ref() { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - } - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { - ::protobuf::rt::write_map_with_cached_sizes::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeString>(1, &self.sid, os)?; - if let Some(ref v) = self.error.as_ref() { - os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - } - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any - } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any - } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - Self::descriptor_static() - } - - fn new() -> Response { - Response::new() - } - - fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_map_accessor::<_, ::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeString>( - "sid", - |m: &Response| { &m.sid }, - |m: &mut Response| { &mut m.sid }, - )); - fields.push(::protobuf::reflect::accessor::make_singular_ptr_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( - "error", - |m: &Response| { &m.error }, - |m: &mut Response| { &mut m.error }, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "Response", - fields, - file_descriptor_proto() - ) - }) - } - } - - fn default_instance() -> &'static Response { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const Response, - }; - unsafe { - instance.get(Response::new) - } - } -} - -impl ::protobuf::Clear for Response { - fn clear(&mut self) { - self.sid.clear(); - self.error.clear(); - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for Response { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for Response { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) - } -} - -#[derive(PartialEq,Clone,Default)] -pub struct GetResponse { - // message fields - pub elements: ::std::collections::HashMap<::std::string::String, Element>, - pub error: ::protobuf::SingularPtrField, - // special fields - pub unknown_fields: ::protobuf::UnknownFields, - pub cached_size: ::protobuf::CachedSize, -} - -impl<'a> ::std::default::Default for &'a GetResponse { - fn default() -> &'a GetResponse { - ::default_instance() - } -} - -impl GetResponse { - pub fn new() -> GetResponse { - ::std::default::Default::default() - } - - // repeated .medea.GetResponse.ElementsEntry elements = 1; - - - pub fn get_elements(&self) -> &::std::collections::HashMap<::std::string::String, Element> { - &self.elements - } - pub fn clear_elements(&mut self) { - self.elements.clear(); - } - - // Param is passed by value, moved - pub fn set_elements(&mut self, v: ::std::collections::HashMap<::std::string::String, Element>) { - self.elements = v; - } - - // Mutable pointer to the field. - pub fn mut_elements(&mut self) -> &mut ::std::collections::HashMap<::std::string::String, Element> { - &mut self.elements - } - - // Take field - pub fn take_elements(&mut self) -> ::std::collections::HashMap<::std::string::String, Element> { - ::std::mem::replace(&mut self.elements, ::std::collections::HashMap::new()) - } - - // .medea.Error error = 2; - - - pub fn get_error(&self) -> &Error { - self.error.as_ref().unwrap_or_else(|| Error::default_instance()) - } - pub fn clear_error(&mut self) { - self.error.clear(); - } - - pub fn has_error(&self) -> bool { - self.error.is_some() - } - - // Param is passed by value, moved - pub fn set_error(&mut self, v: Error) { - self.error = ::protobuf::SingularPtrField::some(v); - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_error(&mut self) -> &mut Error { - if self.error.is_none() { - self.error.set_default(); - } - self.error.as_mut().unwrap() - } - - // Take field - pub fn take_error(&mut self) -> Error { - self.error.take().unwrap_or_else(|| Error::new()) - } -} - -impl ::protobuf::Message for GetResponse { - fn is_initialized(&self) -> bool { - for v in &self.error { - if !v.is_initialized() { - return false; - } - }; - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - 1 => { - ::protobuf::rt::read_map_into::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(wire_type, is, &mut self.elements)?; - }, - 2 => { - ::protobuf::rt::read_singular_message_into(wire_type, is, &mut self.error)?; - }, - _ => { - ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - my_size += ::protobuf::rt::compute_map_size::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(1, &self.elements); - if let Some(ref v) = self.error.as_ref() { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - } - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { - ::protobuf::rt::write_map_with_cached_sizes::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(1, &self.elements, os)?; - if let Some(ref v) = self.error.as_ref() { - os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - } - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any - } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any - } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - Self::descriptor_static() - } - - fn new() -> GetResponse { - GetResponse::new() - } - - fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_map_accessor::<_, ::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>( - "elements", - |m: &GetResponse| { &m.elements }, - |m: &mut GetResponse| { &mut m.elements }, - )); - fields.push(::protobuf::reflect::accessor::make_singular_ptr_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( - "error", - |m: &GetResponse| { &m.error }, - |m: &mut GetResponse| { &mut m.error }, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "GetResponse", - fields, - file_descriptor_proto() - ) - }) - } - } - - fn default_instance() -> &'static GetResponse { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const GetResponse, - }; - unsafe { - instance.get(GetResponse::new) - } - } -} - -impl ::protobuf::Clear for GetResponse { - fn clear(&mut self) { - self.elements.clear(); - self.error.clear(); - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for GetResponse { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for GetResponse { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) - } -} - -#[derive(PartialEq,Clone,Default)] -pub struct Error { - // message fields - pub code: u32, - pub text: ::std::string::String, - pub doc: ::std::string::String, - pub element: ::std::string::String, - // special fields - pub unknown_fields: ::protobuf::UnknownFields, - pub cached_size: ::protobuf::CachedSize, -} - -impl<'a> ::std::default::Default for &'a Error { - fn default() -> &'a Error { - ::default_instance() - } -} - -impl Error { - pub fn new() -> Error { - ::std::default::Default::default() - } - - // uint32 code = 2; - - - pub fn get_code(&self) -> u32 { - self.code - } - pub fn clear_code(&mut self) { - self.code = 0; - } - - // Param is passed by value, moved - pub fn set_code(&mut self, v: u32) { - self.code = v; - } - - // string text = 3; - - - pub fn get_text(&self) -> &str { - &self.text - } - pub fn clear_text(&mut self) { - self.text.clear(); - } - - // Param is passed by value, moved - pub fn set_text(&mut self, v: ::std::string::String) { - self.text = v; - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_text(&mut self) -> &mut ::std::string::String { - &mut self.text - } - - // Take field - pub fn take_text(&mut self) -> ::std::string::String { - ::std::mem::replace(&mut self.text, ::std::string::String::new()) - } - - // string doc = 4; - - - pub fn get_doc(&self) -> &str { - &self.doc - } - pub fn clear_doc(&mut self) { - self.doc.clear(); - } - - // Param is passed by value, moved - pub fn set_doc(&mut self, v: ::std::string::String) { - self.doc = v; - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_doc(&mut self) -> &mut ::std::string::String { - &mut self.doc - } - - // Take field - pub fn take_doc(&mut self) -> ::std::string::String { - ::std::mem::replace(&mut self.doc, ::std::string::String::new()) - } - - // string element = 5; - - - pub fn get_element(&self) -> &str { - &self.element - } - pub fn clear_element(&mut self) { - self.element.clear(); - } - - // Param is passed by value, moved - pub fn set_element(&mut self, v: ::std::string::String) { - self.element = v; - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_element(&mut self) -> &mut ::std::string::String { - &mut self.element - } - - // Take field - pub fn take_element(&mut self) -> ::std::string::String { - ::std::mem::replace(&mut self.element, ::std::string::String::new()) - } -} - -impl ::protobuf::Message for Error { - fn is_initialized(&self) -> bool { - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - 2 => { - if wire_type != ::protobuf::wire_format::WireTypeVarint { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - let tmp = is.read_uint32()?; - self.code = tmp; - }, - 3 => { - ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.text)?; - }, - 4 => { - ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.doc)?; - }, - 5 => { - ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.element)?; - }, - _ => { - ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - if self.code != 0 { - my_size += ::protobuf::rt::value_size(2, self.code, ::protobuf::wire_format::WireTypeVarint); - } - if !self.text.is_empty() { - my_size += ::protobuf::rt::string_size(3, &self.text); - } - if !self.doc.is_empty() { - my_size += ::protobuf::rt::string_size(4, &self.doc); - } - if !self.element.is_empty() { - my_size += ::protobuf::rt::string_size(5, &self.element); - } - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { - if self.code != 0 { - os.write_uint32(2, self.code)?; - } - if !self.text.is_empty() { - os.write_string(3, &self.text)?; - } - if !self.doc.is_empty() { - os.write_string(4, &self.doc)?; - } - if !self.element.is_empty() { - os.write_string(5, &self.element)?; - } - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any - } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any - } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - Self::descriptor_static() - } - - fn new() -> Error { - Error::new() - } - - fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeUint32>( - "code", - |m: &Error| { &m.code }, - |m: &mut Error| { &mut m.code }, - )); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "text", - |m: &Error| { &m.text }, - |m: &mut Error| { &mut m.text }, - )); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "doc", - |m: &Error| { &m.doc }, - |m: &mut Error| { &mut m.doc }, - )); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "element", - |m: &Error| { &m.element }, - |m: &mut Error| { &mut m.element }, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "Error", - fields, - file_descriptor_proto() - ) - }) - } - } - - fn default_instance() -> &'static Error { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const Error, - }; - unsafe { - instance.get(Error::new) - } - } -} - -impl ::protobuf::Clear for Error { - fn clear(&mut self) { - self.code = 0; - self.text.clear(); - self.doc.clear(); - self.element.clear(); - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for Error { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for Error { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) - } -} - -#[derive(PartialEq,Clone,Default)] -pub struct Element { - // message oneof groups - pub el: ::std::option::Option, - // special fields - pub unknown_fields: ::protobuf::UnknownFields, - pub cached_size: ::protobuf::CachedSize, -} - -impl<'a> ::std::default::Default for &'a Element { - fn default() -> &'a Element { - ::default_instance() - } -} - -#[derive(Clone,PartialEq,Debug)] -pub enum Element_oneof_el { - hub(Hub), - file_recorder(FileRecorder), - member(Member), - relay(Relay), - room(Room), - webrtc_play(WebRtcPlayEndpoint), - webrtc_pub(WebRtcPublishEndpoint), -} - -impl Element { - pub fn new() -> Element { - ::std::default::Default::default() - } - - // .medea.Hub hub = 2; - - - pub fn get_hub(&self) -> &Hub { - match self.el { - ::std::option::Option::Some(Element_oneof_el::hub(ref v)) => v, - _ => Hub::default_instance(), - } - } - pub fn clear_hub(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_hub(&self) -> bool { - match self.el { - ::std::option::Option::Some(Element_oneof_el::hub(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_hub(&mut self, v: Hub) { - self.el = ::std::option::Option::Some(Element_oneof_el::hub(v)) - } - - // Mutable pointer to the field. - pub fn mut_hub(&mut self) -> &mut Hub { - if let ::std::option::Option::Some(Element_oneof_el::hub(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(Element_oneof_el::hub(Hub::new())); - } - match self.el { - ::std::option::Option::Some(Element_oneof_el::hub(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_hub(&mut self) -> Hub { - if self.has_hub() { - match self.el.take() { - ::std::option::Option::Some(Element_oneof_el::hub(v)) => v, - _ => panic!(), - } - } else { - Hub::new() - } - } - - // .medea.FileRecorder file_recorder = 3; - - - pub fn get_file_recorder(&self) -> &FileRecorder { - match self.el { - ::std::option::Option::Some(Element_oneof_el::file_recorder(ref v)) => v, - _ => FileRecorder::default_instance(), - } - } - pub fn clear_file_recorder(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_file_recorder(&self) -> bool { - match self.el { - ::std::option::Option::Some(Element_oneof_el::file_recorder(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_file_recorder(&mut self, v: FileRecorder) { - self.el = ::std::option::Option::Some(Element_oneof_el::file_recorder(v)) - } - - // Mutable pointer to the field. - pub fn mut_file_recorder(&mut self) -> &mut FileRecorder { - if let ::std::option::Option::Some(Element_oneof_el::file_recorder(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(Element_oneof_el::file_recorder(FileRecorder::new())); - } - match self.el { - ::std::option::Option::Some(Element_oneof_el::file_recorder(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_file_recorder(&mut self) -> FileRecorder { - if self.has_file_recorder() { - match self.el.take() { - ::std::option::Option::Some(Element_oneof_el::file_recorder(v)) => v, - _ => panic!(), - } - } else { - FileRecorder::new() - } - } - - // .medea.Member member = 4; - - - pub fn get_member(&self) -> &Member { - match self.el { - ::std::option::Option::Some(Element_oneof_el::member(ref v)) => v, - _ => Member::default_instance(), - } - } - pub fn clear_member(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_member(&self) -> bool { - match self.el { - ::std::option::Option::Some(Element_oneof_el::member(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_member(&mut self, v: Member) { - self.el = ::std::option::Option::Some(Element_oneof_el::member(v)) - } - - // Mutable pointer to the field. - pub fn mut_member(&mut self) -> &mut Member { - if let ::std::option::Option::Some(Element_oneof_el::member(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(Element_oneof_el::member(Member::new())); - } - match self.el { - ::std::option::Option::Some(Element_oneof_el::member(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_member(&mut self) -> Member { - if self.has_member() { - match self.el.take() { - ::std::option::Option::Some(Element_oneof_el::member(v)) => v, - _ => panic!(), - } - } else { - Member::new() - } - } - - // .medea.Relay relay = 5; - - - pub fn get_relay(&self) -> &Relay { - match self.el { - ::std::option::Option::Some(Element_oneof_el::relay(ref v)) => v, - _ => Relay::default_instance(), - } - } - pub fn clear_relay(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_relay(&self) -> bool { - match self.el { - ::std::option::Option::Some(Element_oneof_el::relay(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_relay(&mut self, v: Relay) { - self.el = ::std::option::Option::Some(Element_oneof_el::relay(v)) - } - - // Mutable pointer to the field. - pub fn mut_relay(&mut self) -> &mut Relay { - if let ::std::option::Option::Some(Element_oneof_el::relay(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(Element_oneof_el::relay(Relay::new())); - } - match self.el { - ::std::option::Option::Some(Element_oneof_el::relay(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_relay(&mut self) -> Relay { - if self.has_relay() { - match self.el.take() { - ::std::option::Option::Some(Element_oneof_el::relay(v)) => v, - _ => panic!(), - } - } else { - Relay::new() - } - } - - // .medea.Room room = 6; - - - pub fn get_room(&self) -> &Room { - match self.el { - ::std::option::Option::Some(Element_oneof_el::room(ref v)) => v, - _ => Room::default_instance(), - } - } - pub fn clear_room(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_room(&self) -> bool { - match self.el { - ::std::option::Option::Some(Element_oneof_el::room(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_room(&mut self, v: Room) { - self.el = ::std::option::Option::Some(Element_oneof_el::room(v)) - } - - // Mutable pointer to the field. - pub fn mut_room(&mut self) -> &mut Room { - if let ::std::option::Option::Some(Element_oneof_el::room(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(Element_oneof_el::room(Room::new())); - } - match self.el { - ::std::option::Option::Some(Element_oneof_el::room(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_room(&mut self) -> Room { - if self.has_room() { - match self.el.take() { - ::std::option::Option::Some(Element_oneof_el::room(v)) => v, - _ => panic!(), - } - } else { - Room::new() - } - } - - // .medea.WebRtcPlayEndpoint webrtc_play = 7; - - - pub fn get_webrtc_play(&self) -> &WebRtcPlayEndpoint { - match self.el { - ::std::option::Option::Some(Element_oneof_el::webrtc_play(ref v)) => v, - _ => WebRtcPlayEndpoint::default_instance(), - } - } - pub fn clear_webrtc_play(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_webrtc_play(&self) -> bool { - match self.el { - ::std::option::Option::Some(Element_oneof_el::webrtc_play(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_webrtc_play(&mut self, v: WebRtcPlayEndpoint) { - self.el = ::std::option::Option::Some(Element_oneof_el::webrtc_play(v)) - } - - // Mutable pointer to the field. - pub fn mut_webrtc_play(&mut self) -> &mut WebRtcPlayEndpoint { - if let ::std::option::Option::Some(Element_oneof_el::webrtc_play(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(Element_oneof_el::webrtc_play(WebRtcPlayEndpoint::new())); - } - match self.el { - ::std::option::Option::Some(Element_oneof_el::webrtc_play(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_webrtc_play(&mut self) -> WebRtcPlayEndpoint { - if self.has_webrtc_play() { - match self.el.take() { - ::std::option::Option::Some(Element_oneof_el::webrtc_play(v)) => v, - _ => panic!(), - } - } else { - WebRtcPlayEndpoint::new() - } - } - - // .medea.WebRtcPublishEndpoint webrtc_pub = 8; - - - pub fn get_webrtc_pub(&self) -> &WebRtcPublishEndpoint { - match self.el { - ::std::option::Option::Some(Element_oneof_el::webrtc_pub(ref v)) => v, - _ => WebRtcPublishEndpoint::default_instance(), - } - } - pub fn clear_webrtc_pub(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_webrtc_pub(&self) -> bool { - match self.el { - ::std::option::Option::Some(Element_oneof_el::webrtc_pub(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_webrtc_pub(&mut self, v: WebRtcPublishEndpoint) { - self.el = ::std::option::Option::Some(Element_oneof_el::webrtc_pub(v)) - } - - // Mutable pointer to the field. - pub fn mut_webrtc_pub(&mut self) -> &mut WebRtcPublishEndpoint { - if let ::std::option::Option::Some(Element_oneof_el::webrtc_pub(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(Element_oneof_el::webrtc_pub(WebRtcPublishEndpoint::new())); - } - match self.el { - ::std::option::Option::Some(Element_oneof_el::webrtc_pub(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_webrtc_pub(&mut self) -> WebRtcPublishEndpoint { - if self.has_webrtc_pub() { - match self.el.take() { - ::std::option::Option::Some(Element_oneof_el::webrtc_pub(v)) => v, - _ => panic!(), - } - } else { - WebRtcPublishEndpoint::new() - } - } -} - -impl ::protobuf::Message for Element { - fn is_initialized(&self) -> bool { - if let Some(Element_oneof_el::hub(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(Element_oneof_el::file_recorder(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(Element_oneof_el::member(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(Element_oneof_el::relay(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(Element_oneof_el::room(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(Element_oneof_el::webrtc_play(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(Element_oneof_el::webrtc_pub(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - 2 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(Element_oneof_el::hub(is.read_message()?)); - }, - 3 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(Element_oneof_el::file_recorder(is.read_message()?)); - }, - 4 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(Element_oneof_el::member(is.read_message()?)); - }, - 5 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(Element_oneof_el::relay(is.read_message()?)); - }, - 6 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(Element_oneof_el::room(is.read_message()?)); - }, - 7 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(Element_oneof_el::webrtc_play(is.read_message()?)); - }, - 8 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(Element_oneof_el::webrtc_pub(is.read_message()?)); - }, - _ => { - ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - if let ::std::option::Option::Some(ref v) = self.el { - match v { - &Element_oneof_el::hub(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &Element_oneof_el::file_recorder(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &Element_oneof_el::member(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &Element_oneof_el::relay(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &Element_oneof_el::room(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &Element_oneof_el::webrtc_play(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &Element_oneof_el::webrtc_pub(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - }; - } - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { - if let ::std::option::Option::Some(ref v) = self.el { - match v { - &Element_oneof_el::hub(ref v) => { - os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &Element_oneof_el::file_recorder(ref v) => { - os.write_tag(3, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &Element_oneof_el::member(ref v) => { - os.write_tag(4, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &Element_oneof_el::relay(ref v) => { - os.write_tag(5, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &Element_oneof_el::room(ref v) => { - os.write_tag(6, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &Element_oneof_el::webrtc_play(ref v) => { - os.write_tag(7, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &Element_oneof_el::webrtc_pub(ref v) => { - os.write_tag(8, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - }; - } - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any - } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any - } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - Self::descriptor_static() - } - - fn new() -> Element { - Element::new() - } - - fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Hub>( - "hub", - Element::has_hub, - Element::get_hub, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, FileRecorder>( - "file_recorder", - Element::has_file_recorder, - Element::get_file_recorder, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Member>( - "member", - Element::has_member, - Element::get_member, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Relay>( - "relay", - Element::has_relay, - Element::get_relay, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Room>( - "room", - Element::has_room, - Element::get_room, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPlayEndpoint>( - "webrtc_play", - Element::has_webrtc_play, - Element::get_webrtc_play, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPublishEndpoint>( - "webrtc_pub", - Element::has_webrtc_pub, - Element::get_webrtc_pub, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "Element", - fields, - file_descriptor_proto() - ) - }) - } - } - - fn default_instance() -> &'static Element { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const Element, - }; - unsafe { - instance.get(Element::new) - } - } -} - -impl ::protobuf::Clear for Element { - fn clear(&mut self) { - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for Element { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for Element { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) - } -} - -#[derive(PartialEq,Clone,Default)] -pub struct Room { - // message fields - pub pipeline: ::std::collections::HashMap<::std::string::String, Room_Element>, - // special fields - pub unknown_fields: ::protobuf::UnknownFields, - pub cached_size: ::protobuf::CachedSize, -} - -impl<'a> ::std::default::Default for &'a Room { - fn default() -> &'a Room { - ::default_instance() - } -} - -impl Room { - pub fn new() -> Room { - ::std::default::Default::default() - } - - // repeated .medea.Room.PipelineEntry pipeline = 1; - - - pub fn get_pipeline(&self) -> &::std::collections::HashMap<::std::string::String, Room_Element> { - &self.pipeline - } - pub fn clear_pipeline(&mut self) { - self.pipeline.clear(); - } - - // Param is passed by value, moved - pub fn set_pipeline(&mut self, v: ::std::collections::HashMap<::std::string::String, Room_Element>) { - self.pipeline = v; - } - - // Mutable pointer to the field. - pub fn mut_pipeline(&mut self) -> &mut ::std::collections::HashMap<::std::string::String, Room_Element> { - &mut self.pipeline - } - - // Take field - pub fn take_pipeline(&mut self) -> ::std::collections::HashMap<::std::string::String, Room_Element> { - ::std::mem::replace(&mut self.pipeline, ::std::collections::HashMap::new()) - } -} - -impl ::protobuf::Message for Room { - fn is_initialized(&self) -> bool { - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - 1 => { - ::protobuf::rt::read_map_into::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(wire_type, is, &mut self.pipeline)?; - }, - _ => { - ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - my_size += ::protobuf::rt::compute_map_size::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(1, &self.pipeline); - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { - ::protobuf::rt::write_map_with_cached_sizes::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(1, &self.pipeline, os)?; - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any - } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any - } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - Self::descriptor_static() - } - - fn new() -> Room { - Room::new() - } - - fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_map_accessor::<_, ::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>( - "pipeline", - |m: &Room| { &m.pipeline }, - |m: &mut Room| { &mut m.pipeline }, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "Room", - fields, - file_descriptor_proto() - ) - }) - } - } - - fn default_instance() -> &'static Room { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const Room, - }; - unsafe { - instance.get(Room::new) - } - } -} - -impl ::protobuf::Clear for Room { - fn clear(&mut self) { - self.pipeline.clear(); - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for Room { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for Room { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) - } -} - -#[derive(PartialEq,Clone,Default)] -pub struct Room_Element { - // message oneof groups - pub el: ::std::option::Option, - // special fields - pub unknown_fields: ::protobuf::UnknownFields, - pub cached_size: ::protobuf::CachedSize, -} - -impl<'a> ::std::default::Default for &'a Room_Element { - fn default() -> &'a Room_Element { - ::default_instance() - } -} - -#[derive(Clone,PartialEq,Debug)] -pub enum Room_Element_oneof_el { - hub(Hub), - file_recorder(FileRecorder), - member(Member), - relay(Relay), - webrtc_play(WebRtcPlayEndpoint), - webrtc_pub(WebRtcPublishEndpoint), -} - -impl Room_Element { - pub fn new() -> Room_Element { - ::std::default::Default::default() - } - - // .medea.Hub hub = 1; - - - pub fn get_hub(&self) -> &Hub { - match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::hub(ref v)) => v, - _ => Hub::default_instance(), - } - } - pub fn clear_hub(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_hub(&self) -> bool { - match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::hub(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_hub(&mut self, v: Hub) { - self.el = ::std::option::Option::Some(Room_Element_oneof_el::hub(v)) - } - - // Mutable pointer to the field. - pub fn mut_hub(&mut self) -> &mut Hub { - if let ::std::option::Option::Some(Room_Element_oneof_el::hub(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(Room_Element_oneof_el::hub(Hub::new())); - } - match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::hub(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_hub(&mut self) -> Hub { - if self.has_hub() { - match self.el.take() { - ::std::option::Option::Some(Room_Element_oneof_el::hub(v)) => v, - _ => panic!(), - } - } else { - Hub::new() - } - } - - // .medea.FileRecorder file_recorder = 2; - - - pub fn get_file_recorder(&self) -> &FileRecorder { - match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::file_recorder(ref v)) => v, - _ => FileRecorder::default_instance(), - } - } - pub fn clear_file_recorder(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_file_recorder(&self) -> bool { - match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::file_recorder(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_file_recorder(&mut self, v: FileRecorder) { - self.el = ::std::option::Option::Some(Room_Element_oneof_el::file_recorder(v)) - } - - // Mutable pointer to the field. - pub fn mut_file_recorder(&mut self) -> &mut FileRecorder { - if let ::std::option::Option::Some(Room_Element_oneof_el::file_recorder(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(Room_Element_oneof_el::file_recorder(FileRecorder::new())); - } - match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::file_recorder(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_file_recorder(&mut self) -> FileRecorder { - if self.has_file_recorder() { - match self.el.take() { - ::std::option::Option::Some(Room_Element_oneof_el::file_recorder(v)) => v, - _ => panic!(), - } - } else { - FileRecorder::new() - } - } - - // .medea.Member member = 3; - - - pub fn get_member(&self) -> &Member { - match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::member(ref v)) => v, - _ => Member::default_instance(), - } - } - pub fn clear_member(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_member(&self) -> bool { - match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::member(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_member(&mut self, v: Member) { - self.el = ::std::option::Option::Some(Room_Element_oneof_el::member(v)) - } - - // Mutable pointer to the field. - pub fn mut_member(&mut self) -> &mut Member { - if let ::std::option::Option::Some(Room_Element_oneof_el::member(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(Room_Element_oneof_el::member(Member::new())); - } - match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::member(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_member(&mut self) -> Member { - if self.has_member() { - match self.el.take() { - ::std::option::Option::Some(Room_Element_oneof_el::member(v)) => v, - _ => panic!(), - } - } else { - Member::new() - } - } - - // .medea.Relay relay = 4; - - - pub fn get_relay(&self) -> &Relay { - match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::relay(ref v)) => v, - _ => Relay::default_instance(), - } - } - pub fn clear_relay(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_relay(&self) -> bool { - match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::relay(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_relay(&mut self, v: Relay) { - self.el = ::std::option::Option::Some(Room_Element_oneof_el::relay(v)) - } - - // Mutable pointer to the field. - pub fn mut_relay(&mut self) -> &mut Relay { - if let ::std::option::Option::Some(Room_Element_oneof_el::relay(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(Room_Element_oneof_el::relay(Relay::new())); - } - match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::relay(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_relay(&mut self) -> Relay { - if self.has_relay() { - match self.el.take() { - ::std::option::Option::Some(Room_Element_oneof_el::relay(v)) => v, - _ => panic!(), - } - } else { - Relay::new() - } - } - - // .medea.WebRtcPlayEndpoint webrtc_play = 5; - - - pub fn get_webrtc_play(&self) -> &WebRtcPlayEndpoint { - match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(ref v)) => v, - _ => WebRtcPlayEndpoint::default_instance(), - } - } - pub fn clear_webrtc_play(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_webrtc_play(&self) -> bool { - match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_webrtc_play(&mut self, v: WebRtcPlayEndpoint) { - self.el = ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(v)) - } - - // Mutable pointer to the field. - pub fn mut_webrtc_play(&mut self) -> &mut WebRtcPlayEndpoint { - if let ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(WebRtcPlayEndpoint::new())); - } - match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_webrtc_play(&mut self) -> WebRtcPlayEndpoint { - if self.has_webrtc_play() { - match self.el.take() { - ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(v)) => v, - _ => panic!(), - } - } else { - WebRtcPlayEndpoint::new() - } - } - - // .medea.WebRtcPublishEndpoint webrtc_pub = 6; - - - pub fn get_webrtc_pub(&self) -> &WebRtcPublishEndpoint { - match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(ref v)) => v, - _ => WebRtcPublishEndpoint::default_instance(), - } - } - pub fn clear_webrtc_pub(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_webrtc_pub(&self) -> bool { - match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_webrtc_pub(&mut self, v: WebRtcPublishEndpoint) { - self.el = ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(v)) - } - - // Mutable pointer to the field. - pub fn mut_webrtc_pub(&mut self) -> &mut WebRtcPublishEndpoint { - if let ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(WebRtcPublishEndpoint::new())); - } - match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_webrtc_pub(&mut self) -> WebRtcPublishEndpoint { - if self.has_webrtc_pub() { - match self.el.take() { - ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(v)) => v, - _ => panic!(), - } - } else { - WebRtcPublishEndpoint::new() - } - } -} - -impl ::protobuf::Message for Room_Element { - fn is_initialized(&self) -> bool { - if let Some(Room_Element_oneof_el::hub(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(Room_Element_oneof_el::file_recorder(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(Room_Element_oneof_el::member(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(Room_Element_oneof_el::relay(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(Room_Element_oneof_el::webrtc_play(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(Room_Element_oneof_el::webrtc_pub(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - 1 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(Room_Element_oneof_el::hub(is.read_message()?)); - }, - 2 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(Room_Element_oneof_el::file_recorder(is.read_message()?)); - }, - 3 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(Room_Element_oneof_el::member(is.read_message()?)); - }, - 4 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(Room_Element_oneof_el::relay(is.read_message()?)); - }, - 5 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(is.read_message()?)); - }, - 6 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(is.read_message()?)); - }, - _ => { - ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - if let ::std::option::Option::Some(ref v) = self.el { - match v { - &Room_Element_oneof_el::hub(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &Room_Element_oneof_el::file_recorder(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &Room_Element_oneof_el::member(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &Room_Element_oneof_el::relay(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &Room_Element_oneof_el::webrtc_play(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &Room_Element_oneof_el::webrtc_pub(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - }; - } - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { - if let ::std::option::Option::Some(ref v) = self.el { - match v { - &Room_Element_oneof_el::hub(ref v) => { - os.write_tag(1, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &Room_Element_oneof_el::file_recorder(ref v) => { - os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &Room_Element_oneof_el::member(ref v) => { - os.write_tag(3, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &Room_Element_oneof_el::relay(ref v) => { - os.write_tag(4, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &Room_Element_oneof_el::webrtc_play(ref v) => { - os.write_tag(5, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &Room_Element_oneof_el::webrtc_pub(ref v) => { - os.write_tag(6, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - }; - } - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any - } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any - } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - Self::descriptor_static() - } - - fn new() -> Room_Element { - Room_Element::new() - } - - fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Hub>( - "hub", - Room_Element::has_hub, - Room_Element::get_hub, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, FileRecorder>( - "file_recorder", - Room_Element::has_file_recorder, - Room_Element::get_file_recorder, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Member>( - "member", - Room_Element::has_member, - Room_Element::get_member, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Relay>( - "relay", - Room_Element::has_relay, - Room_Element::get_relay, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPlayEndpoint>( - "webrtc_play", - Room_Element::has_webrtc_play, - Room_Element::get_webrtc_play, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPublishEndpoint>( - "webrtc_pub", - Room_Element::has_webrtc_pub, - Room_Element::get_webrtc_pub, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "Room_Element", - fields, - file_descriptor_proto() - ) - }) - } - } - - fn default_instance() -> &'static Room_Element { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const Room_Element, - }; - unsafe { - instance.get(Room_Element::new) - } - } -} - -impl ::protobuf::Clear for Room_Element { - fn clear(&mut self) { - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for Room_Element { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for Room_Element { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) - } -} - -#[derive(PartialEq,Clone,Default)] -pub struct Member { - // message fields - pub on_join: ::std::string::String, - pub on_leave: ::std::string::String, - pub credentials: ::std::string::String, - pub pipeline: ::std::collections::HashMap<::std::string::String, Member_Element>, - // special fields - pub unknown_fields: ::protobuf::UnknownFields, - pub cached_size: ::protobuf::CachedSize, -} - -impl<'a> ::std::default::Default for &'a Member { - fn default() -> &'a Member { - ::default_instance() - } -} - -impl Member { - pub fn new() -> Member { - ::std::default::Default::default() - } - - // string on_join = 1; - - - pub fn get_on_join(&self) -> &str { - &self.on_join - } - pub fn clear_on_join(&mut self) { - self.on_join.clear(); - } - - // Param is passed by value, moved - pub fn set_on_join(&mut self, v: ::std::string::String) { - self.on_join = v; - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_on_join(&mut self) -> &mut ::std::string::String { - &mut self.on_join - } - - // Take field - pub fn take_on_join(&mut self) -> ::std::string::String { - ::std::mem::replace(&mut self.on_join, ::std::string::String::new()) - } - - // string on_leave = 2; - - - pub fn get_on_leave(&self) -> &str { - &self.on_leave - } - pub fn clear_on_leave(&mut self) { - self.on_leave.clear(); - } - - // Param is passed by value, moved - pub fn set_on_leave(&mut self, v: ::std::string::String) { - self.on_leave = v; - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_on_leave(&mut self) -> &mut ::std::string::String { - &mut self.on_leave - } - - // Take field - pub fn take_on_leave(&mut self) -> ::std::string::String { - ::std::mem::replace(&mut self.on_leave, ::std::string::String::new()) - } - - // string credentials = 3; - - - pub fn get_credentials(&self) -> &str { - &self.credentials - } - pub fn clear_credentials(&mut self) { - self.credentials.clear(); - } - - // Param is passed by value, moved - pub fn set_credentials(&mut self, v: ::std::string::String) { - self.credentials = v; - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_credentials(&mut self) -> &mut ::std::string::String { - &mut self.credentials - } - - // Take field - pub fn take_credentials(&mut self) -> ::std::string::String { - ::std::mem::replace(&mut self.credentials, ::std::string::String::new()) - } - - // repeated .medea.Member.PipelineEntry pipeline = 4; - - - pub fn get_pipeline(&self) -> &::std::collections::HashMap<::std::string::String, Member_Element> { - &self.pipeline - } - pub fn clear_pipeline(&mut self) { - self.pipeline.clear(); - } - - // Param is passed by value, moved - pub fn set_pipeline(&mut self, v: ::std::collections::HashMap<::std::string::String, Member_Element>) { - self.pipeline = v; - } - - // Mutable pointer to the field. - pub fn mut_pipeline(&mut self) -> &mut ::std::collections::HashMap<::std::string::String, Member_Element> { - &mut self.pipeline - } - - // Take field - pub fn take_pipeline(&mut self) -> ::std::collections::HashMap<::std::string::String, Member_Element> { - ::std::mem::replace(&mut self.pipeline, ::std::collections::HashMap::new()) - } -} - -impl ::protobuf::Message for Member { - fn is_initialized(&self) -> bool { - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - 1 => { - ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.on_join)?; - }, - 2 => { - ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.on_leave)?; - }, - 3 => { - ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.credentials)?; - }, - 4 => { - ::protobuf::rt::read_map_into::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(wire_type, is, &mut self.pipeline)?; - }, - _ => { - ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - if !self.on_join.is_empty() { - my_size += ::protobuf::rt::string_size(1, &self.on_join); - } - if !self.on_leave.is_empty() { - my_size += ::protobuf::rt::string_size(2, &self.on_leave); - } - if !self.credentials.is_empty() { - my_size += ::protobuf::rt::string_size(3, &self.credentials); - } - my_size += ::protobuf::rt::compute_map_size::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(4, &self.pipeline); - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { - if !self.on_join.is_empty() { - os.write_string(1, &self.on_join)?; - } - if !self.on_leave.is_empty() { - os.write_string(2, &self.on_leave)?; - } - if !self.credentials.is_empty() { - os.write_string(3, &self.credentials)?; - } - ::protobuf::rt::write_map_with_cached_sizes::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(4, &self.pipeline, os)?; - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any - } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any - } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - Self::descriptor_static() - } - - fn new() -> Member { - Member::new() - } - - fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "on_join", - |m: &Member| { &m.on_join }, - |m: &mut Member| { &mut m.on_join }, - )); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "on_leave", - |m: &Member| { &m.on_leave }, - |m: &mut Member| { &mut m.on_leave }, - )); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "credentials", - |m: &Member| { &m.credentials }, - |m: &mut Member| { &mut m.credentials }, - )); - fields.push(::protobuf::reflect::accessor::make_map_accessor::<_, ::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>( - "pipeline", - |m: &Member| { &m.pipeline }, - |m: &mut Member| { &mut m.pipeline }, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "Member", - fields, - file_descriptor_proto() - ) - }) - } - } - - fn default_instance() -> &'static Member { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const Member, - }; - unsafe { - instance.get(Member::new) - } - } -} - -impl ::protobuf::Clear for Member { - fn clear(&mut self) { - self.on_join.clear(); - self.on_leave.clear(); - self.credentials.clear(); - self.pipeline.clear(); - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for Member { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for Member { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) - } -} - -#[derive(PartialEq,Clone,Default)] -pub struct Member_Element { - // message oneof groups - pub el: ::std::option::Option, - // special fields - pub unknown_fields: ::protobuf::UnknownFields, - pub cached_size: ::protobuf::CachedSize, -} - -impl<'a> ::std::default::Default for &'a Member_Element { - fn default() -> &'a Member_Element { - ::default_instance() - } -} - -#[derive(Clone,PartialEq,Debug)] -pub enum Member_Element_oneof_el { - hub(Hub), - file_recorder(FileRecorder), - relay(Relay), - webrtc_play(WebRtcPlayEndpoint), - webrtc_pub(WebRtcPublishEndpoint), -} - -impl Member_Element { - pub fn new() -> Member_Element { - ::std::default::Default::default() - } - - // .medea.Hub hub = 1; - - - pub fn get_hub(&self) -> &Hub { - match self.el { - ::std::option::Option::Some(Member_Element_oneof_el::hub(ref v)) => v, - _ => Hub::default_instance(), - } - } - pub fn clear_hub(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_hub(&self) -> bool { - match self.el { - ::std::option::Option::Some(Member_Element_oneof_el::hub(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_hub(&mut self, v: Hub) { - self.el = ::std::option::Option::Some(Member_Element_oneof_el::hub(v)) - } - - // Mutable pointer to the field. - pub fn mut_hub(&mut self) -> &mut Hub { - if let ::std::option::Option::Some(Member_Element_oneof_el::hub(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(Member_Element_oneof_el::hub(Hub::new())); - } - match self.el { - ::std::option::Option::Some(Member_Element_oneof_el::hub(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_hub(&mut self) -> Hub { - if self.has_hub() { - match self.el.take() { - ::std::option::Option::Some(Member_Element_oneof_el::hub(v)) => v, - _ => panic!(), - } - } else { - Hub::new() - } - } - - // .medea.FileRecorder file_recorder = 2; - - - pub fn get_file_recorder(&self) -> &FileRecorder { - match self.el { - ::std::option::Option::Some(Member_Element_oneof_el::file_recorder(ref v)) => v, - _ => FileRecorder::default_instance(), - } - } - pub fn clear_file_recorder(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_file_recorder(&self) -> bool { - match self.el { - ::std::option::Option::Some(Member_Element_oneof_el::file_recorder(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_file_recorder(&mut self, v: FileRecorder) { - self.el = ::std::option::Option::Some(Member_Element_oneof_el::file_recorder(v)) - } - - // Mutable pointer to the field. - pub fn mut_file_recorder(&mut self) -> &mut FileRecorder { - if let ::std::option::Option::Some(Member_Element_oneof_el::file_recorder(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(Member_Element_oneof_el::file_recorder(FileRecorder::new())); - } - match self.el { - ::std::option::Option::Some(Member_Element_oneof_el::file_recorder(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_file_recorder(&mut self) -> FileRecorder { - if self.has_file_recorder() { - match self.el.take() { - ::std::option::Option::Some(Member_Element_oneof_el::file_recorder(v)) => v, - _ => panic!(), - } - } else { - FileRecorder::new() - } - } - - // .medea.Relay relay = 3; - - - pub fn get_relay(&self) -> &Relay { - match self.el { - ::std::option::Option::Some(Member_Element_oneof_el::relay(ref v)) => v, - _ => Relay::default_instance(), - } - } - pub fn clear_relay(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_relay(&self) -> bool { - match self.el { - ::std::option::Option::Some(Member_Element_oneof_el::relay(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_relay(&mut self, v: Relay) { - self.el = ::std::option::Option::Some(Member_Element_oneof_el::relay(v)) - } - - // Mutable pointer to the field. - pub fn mut_relay(&mut self) -> &mut Relay { - if let ::std::option::Option::Some(Member_Element_oneof_el::relay(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(Member_Element_oneof_el::relay(Relay::new())); - } - match self.el { - ::std::option::Option::Some(Member_Element_oneof_el::relay(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_relay(&mut self) -> Relay { - if self.has_relay() { - match self.el.take() { - ::std::option::Option::Some(Member_Element_oneof_el::relay(v)) => v, - _ => panic!(), - } - } else { - Relay::new() - } - } - - // .medea.WebRtcPlayEndpoint webrtc_play = 4; - - - pub fn get_webrtc_play(&self) -> &WebRtcPlayEndpoint { - match self.el { - ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(ref v)) => v, - _ => WebRtcPlayEndpoint::default_instance(), - } - } - pub fn clear_webrtc_play(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_webrtc_play(&self) -> bool { - match self.el { - ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_webrtc_play(&mut self, v: WebRtcPlayEndpoint) { - self.el = ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(v)) - } - - // Mutable pointer to the field. - pub fn mut_webrtc_play(&mut self) -> &mut WebRtcPlayEndpoint { - if let ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(WebRtcPlayEndpoint::new())); - } - match self.el { - ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_webrtc_play(&mut self) -> WebRtcPlayEndpoint { - if self.has_webrtc_play() { - match self.el.take() { - ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(v)) => v, - _ => panic!(), - } - } else { - WebRtcPlayEndpoint::new() - } - } - - // .medea.WebRtcPublishEndpoint webrtc_pub = 5; - - - pub fn get_webrtc_pub(&self) -> &WebRtcPublishEndpoint { - match self.el { - ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(ref v)) => v, - _ => WebRtcPublishEndpoint::default_instance(), - } - } - pub fn clear_webrtc_pub(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_webrtc_pub(&self) -> bool { - match self.el { - ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_webrtc_pub(&mut self, v: WebRtcPublishEndpoint) { - self.el = ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(v)) - } - - // Mutable pointer to the field. - pub fn mut_webrtc_pub(&mut self) -> &mut WebRtcPublishEndpoint { - if let ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(WebRtcPublishEndpoint::new())); - } - match self.el { - ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_webrtc_pub(&mut self) -> WebRtcPublishEndpoint { - if self.has_webrtc_pub() { - match self.el.take() { - ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(v)) => v, - _ => panic!(), - } - } else { - WebRtcPublishEndpoint::new() - } - } -} - -impl ::protobuf::Message for Member_Element { - fn is_initialized(&self) -> bool { - if let Some(Member_Element_oneof_el::hub(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(Member_Element_oneof_el::file_recorder(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(Member_Element_oneof_el::relay(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(Member_Element_oneof_el::webrtc_play(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(Member_Element_oneof_el::webrtc_pub(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - 1 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(Member_Element_oneof_el::hub(is.read_message()?)); - }, - 2 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(Member_Element_oneof_el::file_recorder(is.read_message()?)); - }, - 3 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(Member_Element_oneof_el::relay(is.read_message()?)); - }, - 4 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(is.read_message()?)); - }, - 5 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(is.read_message()?)); - }, - _ => { - ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - if let ::std::option::Option::Some(ref v) = self.el { - match v { - &Member_Element_oneof_el::hub(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &Member_Element_oneof_el::file_recorder(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &Member_Element_oneof_el::relay(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &Member_Element_oneof_el::webrtc_play(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &Member_Element_oneof_el::webrtc_pub(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - }; - } - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { - if let ::std::option::Option::Some(ref v) = self.el { - match v { - &Member_Element_oneof_el::hub(ref v) => { - os.write_tag(1, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &Member_Element_oneof_el::file_recorder(ref v) => { - os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &Member_Element_oneof_el::relay(ref v) => { - os.write_tag(3, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &Member_Element_oneof_el::webrtc_play(ref v) => { - os.write_tag(4, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &Member_Element_oneof_el::webrtc_pub(ref v) => { - os.write_tag(5, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - }; - } - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any - } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any - } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - Self::descriptor_static() - } - - fn new() -> Member_Element { - Member_Element::new() - } - - fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Hub>( - "hub", - Member_Element::has_hub, - Member_Element::get_hub, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, FileRecorder>( - "file_recorder", - Member_Element::has_file_recorder, - Member_Element::get_file_recorder, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Relay>( - "relay", - Member_Element::has_relay, - Member_Element::get_relay, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPlayEndpoint>( - "webrtc_play", - Member_Element::has_webrtc_play, - Member_Element::get_webrtc_play, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPublishEndpoint>( - "webrtc_pub", - Member_Element::has_webrtc_pub, - Member_Element::get_webrtc_pub, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "Member_Element", - fields, - file_descriptor_proto() - ) - }) - } - } - - fn default_instance() -> &'static Member_Element { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const Member_Element, - }; - unsafe { - instance.get(Member_Element::new) - } - } -} - -impl ::protobuf::Clear for Member_Element { - fn clear(&mut self) { - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for Member_Element { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for Member_Element { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) - } -} - -#[derive(PartialEq,Clone,Default)] -pub struct WebRtcPublishEndpoint { - // message fields - pub p2p: WebRtcPublishEndpoint_P2P, - pub on_start: ::std::string::String, - pub on_stop: ::std::string::String, - // special fields - pub unknown_fields: ::protobuf::UnknownFields, - pub cached_size: ::protobuf::CachedSize, -} - -impl<'a> ::std::default::Default for &'a WebRtcPublishEndpoint { - fn default() -> &'a WebRtcPublishEndpoint { - ::default_instance() - } -} - -impl WebRtcPublishEndpoint { - pub fn new() -> WebRtcPublishEndpoint { - ::std::default::Default::default() - } - - // .medea.WebRtcPublishEndpoint.P2P p2p = 1; - - - pub fn get_p2p(&self) -> WebRtcPublishEndpoint_P2P { - self.p2p - } - pub fn clear_p2p(&mut self) { - self.p2p = WebRtcPublishEndpoint_P2P::NEVER; - } - - // Param is passed by value, moved - pub fn set_p2p(&mut self, v: WebRtcPublishEndpoint_P2P) { - self.p2p = v; - } - - // string on_start = 3; - - - pub fn get_on_start(&self) -> &str { - &self.on_start - } - pub fn clear_on_start(&mut self) { - self.on_start.clear(); - } - - // Param is passed by value, moved - pub fn set_on_start(&mut self, v: ::std::string::String) { - self.on_start = v; - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_on_start(&mut self) -> &mut ::std::string::String { - &mut self.on_start - } - - // Take field - pub fn take_on_start(&mut self) -> ::std::string::String { - ::std::mem::replace(&mut self.on_start, ::std::string::String::new()) - } - - // string on_stop = 4; - - - pub fn get_on_stop(&self) -> &str { - &self.on_stop - } - pub fn clear_on_stop(&mut self) { - self.on_stop.clear(); - } - - // Param is passed by value, moved - pub fn set_on_stop(&mut self, v: ::std::string::String) { - self.on_stop = v; - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_on_stop(&mut self) -> &mut ::std::string::String { - &mut self.on_stop - } - - // Take field - pub fn take_on_stop(&mut self) -> ::std::string::String { - ::std::mem::replace(&mut self.on_stop, ::std::string::String::new()) - } -} - -impl ::protobuf::Message for WebRtcPublishEndpoint { - fn is_initialized(&self) -> bool { - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - 1 => { - ::protobuf::rt::read_proto3_enum_with_unknown_fields_into(wire_type, is, &mut self.p2p, 1, &mut self.unknown_fields)? - }, - 3 => { - ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.on_start)?; - }, - 4 => { - ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.on_stop)?; - }, - _ => { - ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - if self.p2p != WebRtcPublishEndpoint_P2P::NEVER { - my_size += ::protobuf::rt::enum_size(1, self.p2p); - } - if !self.on_start.is_empty() { - my_size += ::protobuf::rt::string_size(3, &self.on_start); - } - if !self.on_stop.is_empty() { - my_size += ::protobuf::rt::string_size(4, &self.on_stop); - } - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { - if self.p2p != WebRtcPublishEndpoint_P2P::NEVER { - os.write_enum(1, self.p2p.value())?; - } - if !self.on_start.is_empty() { - os.write_string(3, &self.on_start)?; - } - if !self.on_stop.is_empty() { - os.write_string(4, &self.on_stop)?; - } - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any - } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any - } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - Self::descriptor_static() - } - - fn new() -> WebRtcPublishEndpoint { - WebRtcPublishEndpoint::new() - } - - fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeEnum>( - "p2p", - |m: &WebRtcPublishEndpoint| { &m.p2p }, - |m: &mut WebRtcPublishEndpoint| { &mut m.p2p }, - )); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "on_start", - |m: &WebRtcPublishEndpoint| { &m.on_start }, - |m: &mut WebRtcPublishEndpoint| { &mut m.on_start }, - )); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "on_stop", - |m: &WebRtcPublishEndpoint| { &m.on_stop }, - |m: &mut WebRtcPublishEndpoint| { &mut m.on_stop }, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "WebRtcPublishEndpoint", - fields, - file_descriptor_proto() - ) - }) - } - } - - fn default_instance() -> &'static WebRtcPublishEndpoint { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const WebRtcPublishEndpoint, - }; - unsafe { - instance.get(WebRtcPublishEndpoint::new) - } - } -} - -impl ::protobuf::Clear for WebRtcPublishEndpoint { - fn clear(&mut self) { - self.p2p = WebRtcPublishEndpoint_P2P::NEVER; - self.on_start.clear(); - self.on_stop.clear(); - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for WebRtcPublishEndpoint { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for WebRtcPublishEndpoint { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) - } -} - -#[derive(Clone,PartialEq,Eq,Debug,Hash)] -pub enum WebRtcPublishEndpoint_P2P { - NEVER = 0, - IF_POSSIBLE = 1, - ALWAYS = 2, -} - -impl ::protobuf::ProtobufEnum for WebRtcPublishEndpoint_P2P { - fn value(&self) -> i32 { - *self as i32 - } - - fn from_i32(value: i32) -> ::std::option::Option { - match value { - 0 => ::std::option::Option::Some(WebRtcPublishEndpoint_P2P::NEVER), - 1 => ::std::option::Option::Some(WebRtcPublishEndpoint_P2P::IF_POSSIBLE), - 2 => ::std::option::Option::Some(WebRtcPublishEndpoint_P2P::ALWAYS), - _ => ::std::option::Option::None - } - } - - fn values() -> &'static [Self] { - static values: &'static [WebRtcPublishEndpoint_P2P] = &[ - WebRtcPublishEndpoint_P2P::NEVER, - WebRtcPublishEndpoint_P2P::IF_POSSIBLE, - WebRtcPublishEndpoint_P2P::ALWAYS, - ]; - values - } - - fn enum_descriptor_static() -> &'static ::protobuf::reflect::EnumDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::EnumDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::EnumDescriptor, - }; - unsafe { - descriptor.get(|| { - ::protobuf::reflect::EnumDescriptor::new("WebRtcPublishEndpoint_P2P", file_descriptor_proto()) - }) - } - } -} - -impl ::std::marker::Copy for WebRtcPublishEndpoint_P2P { -} - -impl ::std::default::Default for WebRtcPublishEndpoint_P2P { - fn default() -> Self { - WebRtcPublishEndpoint_P2P::NEVER - } -} - -impl ::protobuf::reflect::ProtobufValue for WebRtcPublishEndpoint_P2P { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Enum(self.descriptor()) - } -} - -#[derive(PartialEq,Clone,Default)] -pub struct WebRtcPlayEndpoint { - // message fields - pub src: ::std::string::String, - pub on_start: ::std::string::String, - pub on_stop: ::std::string::String, - // special fields - pub unknown_fields: ::protobuf::UnknownFields, - pub cached_size: ::protobuf::CachedSize, -} - -impl<'a> ::std::default::Default for &'a WebRtcPlayEndpoint { - fn default() -> &'a WebRtcPlayEndpoint { - ::default_instance() - } -} - -impl WebRtcPlayEndpoint { - pub fn new() -> WebRtcPlayEndpoint { - ::std::default::Default::default() - } - - // string src = 1; - - - pub fn get_src(&self) -> &str { - &self.src - } - pub fn clear_src(&mut self) { - self.src.clear(); - } - - // Param is passed by value, moved - pub fn set_src(&mut self, v: ::std::string::String) { - self.src = v; - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_src(&mut self) -> &mut ::std::string::String { - &mut self.src - } - - // Take field - pub fn take_src(&mut self) -> ::std::string::String { - ::std::mem::replace(&mut self.src, ::std::string::String::new()) - } - - // string on_start = 2; - - - pub fn get_on_start(&self) -> &str { - &self.on_start - } - pub fn clear_on_start(&mut self) { - self.on_start.clear(); - } - - // Param is passed by value, moved - pub fn set_on_start(&mut self, v: ::std::string::String) { - self.on_start = v; - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_on_start(&mut self) -> &mut ::std::string::String { - &mut self.on_start - } - - // Take field - pub fn take_on_start(&mut self) -> ::std::string::String { - ::std::mem::replace(&mut self.on_start, ::std::string::String::new()) - } - - // string on_stop = 3; - - - pub fn get_on_stop(&self) -> &str { - &self.on_stop - } - pub fn clear_on_stop(&mut self) { - self.on_stop.clear(); - } - - // Param is passed by value, moved - pub fn set_on_stop(&mut self, v: ::std::string::String) { - self.on_stop = v; - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_on_stop(&mut self) -> &mut ::std::string::String { - &mut self.on_stop - } - - // Take field - pub fn take_on_stop(&mut self) -> ::std::string::String { - ::std::mem::replace(&mut self.on_stop, ::std::string::String::new()) - } -} - -impl ::protobuf::Message for WebRtcPlayEndpoint { - fn is_initialized(&self) -> bool { - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - 1 => { - ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.src)?; - }, - 2 => { - ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.on_start)?; - }, - 3 => { - ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.on_stop)?; - }, - _ => { - ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - if !self.src.is_empty() { - my_size += ::protobuf::rt::string_size(1, &self.src); - } - if !self.on_start.is_empty() { - my_size += ::protobuf::rt::string_size(2, &self.on_start); - } - if !self.on_stop.is_empty() { - my_size += ::protobuf::rt::string_size(3, &self.on_stop); - } - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { - if !self.src.is_empty() { - os.write_string(1, &self.src)?; - } - if !self.on_start.is_empty() { - os.write_string(2, &self.on_start)?; - } - if !self.on_stop.is_empty() { - os.write_string(3, &self.on_stop)?; - } - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any - } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any - } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - Self::descriptor_static() - } - - fn new() -> WebRtcPlayEndpoint { - WebRtcPlayEndpoint::new() - } - - fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "src", - |m: &WebRtcPlayEndpoint| { &m.src }, - |m: &mut WebRtcPlayEndpoint| { &mut m.src }, - )); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "on_start", - |m: &WebRtcPlayEndpoint| { &m.on_start }, - |m: &mut WebRtcPlayEndpoint| { &mut m.on_start }, - )); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "on_stop", - |m: &WebRtcPlayEndpoint| { &m.on_stop }, - |m: &mut WebRtcPlayEndpoint| { &mut m.on_stop }, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "WebRtcPlayEndpoint", - fields, - file_descriptor_proto() - ) - }) - } - } - - fn default_instance() -> &'static WebRtcPlayEndpoint { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const WebRtcPlayEndpoint, - }; - unsafe { - instance.get(WebRtcPlayEndpoint::new) - } - } -} - -impl ::protobuf::Clear for WebRtcPlayEndpoint { - fn clear(&mut self) { - self.src.clear(); - self.on_start.clear(); - self.on_stop.clear(); - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for WebRtcPlayEndpoint { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for WebRtcPlayEndpoint { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) - } -} - -#[derive(PartialEq,Clone,Default)] -pub struct Hub { - // special fields - pub unknown_fields: ::protobuf::UnknownFields, - pub cached_size: ::protobuf::CachedSize, -} - -impl<'a> ::std::default::Default for &'a Hub { - fn default() -> &'a Hub { - ::default_instance() - } -} - -impl Hub { - pub fn new() -> Hub { - ::std::default::Default::default() - } -} - -impl ::protobuf::Message for Hub { - fn is_initialized(&self) -> bool { - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - _ => { - ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any - } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any - } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - Self::descriptor_static() - } - - fn new() -> Hub { - Hub::new() - } - - fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let fields = ::std::vec::Vec::new(); - ::protobuf::reflect::MessageDescriptor::new::( - "Hub", - fields, - file_descriptor_proto() - ) - }) - } - } - - fn default_instance() -> &'static Hub { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const Hub, - }; - unsafe { - instance.get(Hub::new) - } - } -} - -impl ::protobuf::Clear for Hub { - fn clear(&mut self) { - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for Hub { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for Hub { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) - } -} - -#[derive(PartialEq,Clone,Default)] -pub struct FileRecorder { - // message fields - pub src: ::std::string::String, - pub dst: ::std::string::String, - pub on_start: ::std::string::String, - pub on_stop: ::std::string::String, - // special fields - pub unknown_fields: ::protobuf::UnknownFields, - pub cached_size: ::protobuf::CachedSize, -} - -impl<'a> ::std::default::Default for &'a FileRecorder { - fn default() -> &'a FileRecorder { - ::default_instance() - } -} - -impl FileRecorder { - pub fn new() -> FileRecorder { - ::std::default::Default::default() - } - - // string src = 1; - - - pub fn get_src(&self) -> &str { - &self.src - } - pub fn clear_src(&mut self) { - self.src.clear(); - } - - // Param is passed by value, moved - pub fn set_src(&mut self, v: ::std::string::String) { - self.src = v; - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_src(&mut self) -> &mut ::std::string::String { - &mut self.src - } - - // Take field - pub fn take_src(&mut self) -> ::std::string::String { - ::std::mem::replace(&mut self.src, ::std::string::String::new()) - } - - // string dst = 2; - - - pub fn get_dst(&self) -> &str { - &self.dst - } - pub fn clear_dst(&mut self) { - self.dst.clear(); - } - - // Param is passed by value, moved - pub fn set_dst(&mut self, v: ::std::string::String) { - self.dst = v; - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_dst(&mut self) -> &mut ::std::string::String { - &mut self.dst - } - - // Take field - pub fn take_dst(&mut self) -> ::std::string::String { - ::std::mem::replace(&mut self.dst, ::std::string::String::new()) - } - - // string on_start = 3; - - - pub fn get_on_start(&self) -> &str { - &self.on_start - } - pub fn clear_on_start(&mut self) { - self.on_start.clear(); - } - - // Param is passed by value, moved - pub fn set_on_start(&mut self, v: ::std::string::String) { - self.on_start = v; - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_on_start(&mut self) -> &mut ::std::string::String { - &mut self.on_start - } - - // Take field - pub fn take_on_start(&mut self) -> ::std::string::String { - ::std::mem::replace(&mut self.on_start, ::std::string::String::new()) - } - - // string on_stop = 4; - - - pub fn get_on_stop(&self) -> &str { - &self.on_stop - } - pub fn clear_on_stop(&mut self) { - self.on_stop.clear(); - } - - // Param is passed by value, moved - pub fn set_on_stop(&mut self, v: ::std::string::String) { - self.on_stop = v; - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_on_stop(&mut self) -> &mut ::std::string::String { - &mut self.on_stop - } - - // Take field - pub fn take_on_stop(&mut self) -> ::std::string::String { - ::std::mem::replace(&mut self.on_stop, ::std::string::String::new()) - } -} - -impl ::protobuf::Message for FileRecorder { - fn is_initialized(&self) -> bool { - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - 1 => { - ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.src)?; - }, - 2 => { - ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.dst)?; - }, - 3 => { - ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.on_start)?; - }, - 4 => { - ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.on_stop)?; - }, - _ => { - ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - if !self.src.is_empty() { - my_size += ::protobuf::rt::string_size(1, &self.src); - } - if !self.dst.is_empty() { - my_size += ::protobuf::rt::string_size(2, &self.dst); - } - if !self.on_start.is_empty() { - my_size += ::protobuf::rt::string_size(3, &self.on_start); - } - if !self.on_stop.is_empty() { - my_size += ::protobuf::rt::string_size(4, &self.on_stop); - } - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { - if !self.src.is_empty() { - os.write_string(1, &self.src)?; - } - if !self.dst.is_empty() { - os.write_string(2, &self.dst)?; - } - if !self.on_start.is_empty() { - os.write_string(3, &self.on_start)?; - } - if !self.on_stop.is_empty() { - os.write_string(4, &self.on_stop)?; - } - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any - } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any - } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - Self::descriptor_static() - } - - fn new() -> FileRecorder { - FileRecorder::new() - } - - fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "src", - |m: &FileRecorder| { &m.src }, - |m: &mut FileRecorder| { &mut m.src }, - )); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "dst", - |m: &FileRecorder| { &m.dst }, - |m: &mut FileRecorder| { &mut m.dst }, - )); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "on_start", - |m: &FileRecorder| { &m.on_start }, - |m: &mut FileRecorder| { &mut m.on_start }, - )); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "on_stop", - |m: &FileRecorder| { &m.on_stop }, - |m: &mut FileRecorder| { &mut m.on_stop }, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "FileRecorder", - fields, - file_descriptor_proto() - ) - }) - } - } - - fn default_instance() -> &'static FileRecorder { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const FileRecorder, - }; - unsafe { - instance.get(FileRecorder::new) - } - } -} - -impl ::protobuf::Clear for FileRecorder { - fn clear(&mut self) { - self.src.clear(); - self.dst.clear(); - self.on_start.clear(); - self.on_stop.clear(); - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for FileRecorder { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for FileRecorder { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) - } -} - -#[derive(PartialEq,Clone,Default)] -pub struct Relay { - // message fields - pub src: ::std::string::String, - pub dst: ::std::string::String, - // special fields - pub unknown_fields: ::protobuf::UnknownFields, - pub cached_size: ::protobuf::CachedSize, -} - -impl<'a> ::std::default::Default for &'a Relay { - fn default() -> &'a Relay { - ::default_instance() - } -} - -impl Relay { - pub fn new() -> Relay { - ::std::default::Default::default() - } - - // string src = 1; - - - pub fn get_src(&self) -> &str { - &self.src - } - pub fn clear_src(&mut self) { - self.src.clear(); - } - - // Param is passed by value, moved - pub fn set_src(&mut self, v: ::std::string::String) { - self.src = v; - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_src(&mut self) -> &mut ::std::string::String { - &mut self.src - } - - // Take field - pub fn take_src(&mut self) -> ::std::string::String { - ::std::mem::replace(&mut self.src, ::std::string::String::new()) - } - - // string dst = 2; - - - pub fn get_dst(&self) -> &str { - &self.dst - } - pub fn clear_dst(&mut self) { - self.dst.clear(); - } - - // Param is passed by value, moved - pub fn set_dst(&mut self, v: ::std::string::String) { - self.dst = v; - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_dst(&mut self) -> &mut ::std::string::String { - &mut self.dst - } - - // Take field - pub fn take_dst(&mut self) -> ::std::string::String { - ::std::mem::replace(&mut self.dst, ::std::string::String::new()) - } -} - -impl ::protobuf::Message for Relay { - fn is_initialized(&self) -> bool { - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - 1 => { - ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.src)?; - }, - 2 => { - ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.dst)?; - }, - _ => { - ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - if !self.src.is_empty() { - my_size += ::protobuf::rt::string_size(1, &self.src); - } - if !self.dst.is_empty() { - my_size += ::protobuf::rt::string_size(2, &self.dst); - } - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { - if !self.src.is_empty() { - os.write_string(1, &self.src)?; - } - if !self.dst.is_empty() { - os.write_string(2, &self.dst)?; - } - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any - } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any - } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - Self::descriptor_static() - } - - fn new() -> Relay { - Relay::new() - } - - fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "src", - |m: &Relay| { &m.src }, - |m: &mut Relay| { &mut m.src }, - )); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "dst", - |m: &Relay| { &m.dst }, - |m: &mut Relay| { &mut m.dst }, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "Relay", - fields, - file_descriptor_proto() - ) - }) - } - } - - fn default_instance() -> &'static Relay { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const Relay, - }; - unsafe { - instance.get(Relay::new) - } - } -} - -impl ::protobuf::Clear for Relay { - fn clear(&mut self) { - self.src.clear(); - self.dst.clear(); - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for Relay { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for Relay { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) - } -} - -static file_descriptor_proto_data: &'static [u8] = b"\ - \n\rcontrol.proto\x12\x05medea\"\xf0\x02\n\rCreateRequest\x12\x0e\n\x02i\ - d\x18\x01\x20\x01(\tR\x02id\x12\x1e\n\x03hub\x18\x02\x20\x01(\x0b2\n.med\ - ea.HubH\0R\x03hub\x12:\n\rfile_recorder\x18\x03\x20\x01(\x0b2\x13.medea.\ - FileRecorderH\0R\x0cfileRecorder\x12'\n\x06member\x18\x04\x20\x01(\x0b2\ - \r.medea.MemberH\0R\x06member\x12$\n\x05relay\x18\x05\x20\x01(\x0b2\x0c.\ - medea.RelayH\0R\x05relay\x12!\n\x04room\x18\x06\x20\x01(\x0b2\x0b.medea.\ - RoomH\0R\x04room\x12<\n\x0bwebrtc_play\x18\x07\x20\x01(\x0b2\x19.medea.W\ - ebRtcPlayEndpointH\0R\nwebrtcPlay\x12=\n\nwebrtc_pub\x18\x08\x20\x01(\ - \x0b2\x1c.medea.WebRtcPublishEndpointH\0R\twebrtcPubB\x04\n\x02el\"\xc4\ - \x03\n\x0cApplyRequest\x12\x0e\n\x02id\x18\x01\x20\x01(\tR\x02id\x12\x1e\ - \n\x03hub\x18\x02\x20\x01(\x0b2\n.medea.HubH\0R\x03hub\x12:\n\rfile_reco\ - rder\x18\x03\x20\x01(\x0b2\x13.medea.FileRecorderH\0R\x0cfileRecorder\ - \x12'\n\x06member\x18\x04\x20\x01(\x0b2\r.medea.MemberH\0R\x06member\x12\ - $\n\x05relay\x18\x05\x20\x01(\x0b2\x0c.medea.RelayH\0R\x05relay\x12!\n\ - \x04room\x18\x06\x20\x01(\x0b2\x0b.medea.RoomH\0R\x04room\x12<\n\x0bwebr\ - tc_play\x18\x07\x20\x01(\x0b2\x19.medea.WebRtcPlayEndpointH\0R\nwebrtcPl\ - ay\x12=\n\nwebrtc_pub\x18\x08\x20\x01(\x0b2\x1c.medea.WebRtcPublishEndpo\ - intH\0R\twebrtcPub\x122\n\x06policy\x18\t\x20\x01(\x0e2\x1a.medea.ApplyR\ - equest.PolicyR\x06policy\"\x1f\n\x06Policy\x12\t\n\x05APPLY\x10\0\x12\n\ - \n\x06APPEND\x10\x01B\x04\n\x02el\"\x1b\n\tIdRequest\x12\x0e\n\x02id\x18\ - \x01\x20\x03(\tR\x02id\"\x92\x01\n\x08Response\x12*\n\x03sid\x18\x01\x20\ - \x03(\x0b2\x18.medea.Response.SidEntryR\x03sid\x12\"\n\x05error\x18\x02\ - \x20\x01(\x0b2\x0c.medea.ErrorR\x05error\x1a6\n\x08SidEntry\x12\x10\n\ - \x03key\x18\x01\x20\x01(\tR\x03key\x12\x14\n\x05value\x18\x02\x20\x01(\t\ - R\x05value:\x028\x01\"\xbc\x01\n\x0bGetResponse\x12<\n\x08elements\x18\ - \x01\x20\x03(\x0b2\x20.medea.GetResponse.ElementsEntryR\x08elements\x12\ - \"\n\x05error\x18\x02\x20\x01(\x0b2\x0c.medea.ErrorR\x05error\x1aK\n\rEl\ - ementsEntry\x12\x10\n\x03key\x18\x01\x20\x01(\tR\x03key\x12$\n\x05value\ - \x18\x02\x20\x01(\x0b2\x0e.medea.ElementR\x05value:\x028\x01\"[\n\x05Err\ - or\x12\x12\n\x04code\x18\x02\x20\x01(\rR\x04code\x12\x12\n\x04text\x18\ - \x03\x20\x01(\tR\x04text\x12\x10\n\x03doc\x18\x04\x20\x01(\tR\x03doc\x12\ - \x18\n\x07element\x18\x05\x20\x01(\tR\x07element\"\xda\x02\n\x07Element\ - \x12\x1e\n\x03hub\x18\x02\x20\x01(\x0b2\n.medea.HubH\0R\x03hub\x12:\n\rf\ - ile_recorder\x18\x03\x20\x01(\x0b2\x13.medea.FileRecorderH\0R\x0cfileRec\ - order\x12'\n\x06member\x18\x04\x20\x01(\x0b2\r.medea.MemberH\0R\x06membe\ - r\x12$\n\x05relay\x18\x05\x20\x01(\x0b2\x0c.medea.RelayH\0R\x05relay\x12\ - !\n\x04room\x18\x06\x20\x01(\x0b2\x0b.medea.RoomH\0R\x04room\x12<\n\x0bw\ - ebrtc_play\x18\x07\x20\x01(\x0b2\x19.medea.WebRtcPlayEndpointH\0R\nwebrt\ - cPlay\x12=\n\nwebrtc_pub\x18\x08\x20\x01(\x0b2\x1c.medea.WebRtcPublishEn\ - dpointH\0R\twebrtcPubB\x04\n\x02el\"\xc9\x03\n\x04Room\x125\n\x08pipelin\ - e\x18\x01\x20\x03(\x0b2\x19.medea.Room.PipelineEntryR\x08pipeline\x1aP\n\ - \rPipelineEntry\x12\x10\n\x03key\x18\x01\x20\x01(\tR\x03key\x12)\n\x05va\ - lue\x18\x02\x20\x01(\x0b2\x13.medea.Room.ElementR\x05value:\x028\x01\x1a\ - \xb7\x02\n\x07Element\x12\x1e\n\x03hub\x18\x01\x20\x01(\x0b2\n.medea.Hub\ - H\0R\x03hub\x12:\n\rfile_recorder\x18\x02\x20\x01(\x0b2\x13.medea.FileRe\ - corderH\0R\x0cfileRecorder\x12'\n\x06member\x18\x03\x20\x01(\x0b2\r.mede\ - a.MemberH\0R\x06member\x12$\n\x05relay\x18\x04\x20\x01(\x0b2\x0c.medea.R\ - elayH\0R\x05relay\x12<\n\x0bwebrtc_play\x18\x05\x20\x01(\x0b2\x19.medea.\ - WebRtcPlayEndpointH\0R\nwebrtcPlay\x12=\n\nwebrtc_pub\x18\x06\x20\x01(\ - \x0b2\x1c.medea.WebRtcPublishEndpointH\0R\twebrtcPubB\x04\n\x02el\"\xfc\ - \x03\n\x06Member\x12\x17\n\x07on_join\x18\x01\x20\x01(\tR\x06onJoin\x12\ - \x19\n\x08on_leave\x18\x02\x20\x01(\tR\x07onLeave\x12\x20\n\x0bcredentia\ - ls\x18\x03\x20\x01(\tR\x0bcredentials\x127\n\x08pipeline\x18\x04\x20\x03\ - (\x0b2\x1b.medea.Member.PipelineEntryR\x08pipeline\x1aR\n\rPipelineEntry\ - \x12\x10\n\x03key\x18\x01\x20\x01(\tR\x03key\x12+\n\x05value\x18\x02\x20\ - \x01(\x0b2\x15.medea.Member.ElementR\x05value:\x028\x01\x1a\x8e\x02\n\ - \x07Element\x12\x1e\n\x03hub\x18\x01\x20\x01(\x0b2\n.medea.HubH\0R\x03hu\ - b\x12:\n\rfile_recorder\x18\x02\x20\x01(\x0b2\x13.medea.FileRecorderH\0R\ - \x0cfileRecorder\x12$\n\x05relay\x18\x03\x20\x01(\x0b2\x0c.medea.RelayH\ - \0R\x05relay\x12<\n\x0bwebrtc_play\x18\x04\x20\x01(\x0b2\x19.medea.WebRt\ - cPlayEndpointH\0R\nwebrtcPlay\x12=\n\nwebrtc_pub\x18\x05\x20\x01(\x0b2\ - \x1c.medea.WebRtcPublishEndpointH\0R\twebrtcPubB\x04\n\x02el\"\xae\x01\n\ - \x15WebRtcPublishEndpoint\x122\n\x03p2p\x18\x01\x20\x01(\x0e2\x20.medea.\ - WebRtcPublishEndpoint.P2PR\x03p2p\x12\x19\n\x08on_start\x18\x03\x20\x01(\ - \tR\x07onStart\x12\x17\n\x07on_stop\x18\x04\x20\x01(\tR\x06onStop\"-\n\ - \x03P2P\x12\t\n\x05NEVER\x10\0\x12\x0f\n\x0bIF_POSSIBLE\x10\x01\x12\n\n\ - \x06ALWAYS\x10\x02\"Z\n\x12WebRtcPlayEndpoint\x12\x10\n\x03src\x18\x01\ - \x20\x01(\tR\x03src\x12\x19\n\x08on_start\x18\x02\x20\x01(\tR\x07onStart\ - \x12\x17\n\x07on_stop\x18\x03\x20\x01(\tR\x06onStop\"\x05\n\x03Hub\"f\n\ - \x0cFileRecorder\x12\x10\n\x03src\x18\x01\x20\x01(\tR\x03src\x12\x10\n\ - \x03dst\x18\x02\x20\x01(\tR\x03dst\x12\x19\n\x08on_start\x18\x03\x20\x01\ - (\tR\x07onStart\x12\x17\n\x07on_stop\x18\x04\x20\x01(\tR\x06onStop\"+\n\ - \x05Relay\x12\x10\n\x03src\x18\x01\x20\x01(\tR\x03src\x12\x10\n\x03dst\ - \x18\x02\x20\x01(\tR\x03dst2\xc6\x01\n\nControlApi\x12/\n\x06Create\x12\ - \x14.medea.CreateRequest\x1a\x0f.medea.Response\x12-\n\x05Apply\x12\x13.\ - medea.ApplyRequest\x1a\x0f.medea.Response\x12+\n\x06Delete\x12\x10.medea\ - .IdRequest\x1a\x0f.medea.Response\x12+\n\x03Get\x12\x10.medea.IdRequest\ - \x1a\x12.medea.GetResponseb\x06proto3\ -"; - -static mut file_descriptor_proto_lazy: ::protobuf::lazy::Lazy<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::descriptor::FileDescriptorProto, -}; - -fn parse_descriptor_proto() -> ::protobuf::descriptor::FileDescriptorProto { - ::protobuf::parse_from_bytes(file_descriptor_proto_data).unwrap() -} - -pub fn file_descriptor_proto() -> &'static ::protobuf::descriptor::FileDescriptorProto { - unsafe { - file_descriptor_proto_lazy.get(|| { - parse_descriptor_proto() - }) - } -} diff --git a/proto/grpc/src/control_grpc.rs b/proto/grpc/src/control_grpc.rs deleted file mode 100644 index 200c56a85..000000000 --- a/proto/grpc/src/control_grpc.rs +++ /dev/null @@ -1,155 +0,0 @@ -// This file is generated. Do not edit -// @generated - -// https://github.com/Manishearth/rust-clippy/issues/702 -#![allow(unknown_lints)] -#![allow(clippy::all)] - -#![cfg_attr(rustfmt, rustfmt_skip)] - -#![allow(box_pointers)] -#![allow(dead_code)] -#![allow(missing_docs)] -#![allow(non_camel_case_types)] -#![allow(non_snake_case)] -#![allow(non_upper_case_globals)] -#![allow(trivial_casts)] -#![allow(unsafe_code)] -#![allow(unused_imports)] -#![allow(unused_results)] - -const METHOD_CONTROL_API_CREATE: ::grpcio::Method = ::grpcio::Method { - ty: ::grpcio::MethodType::Unary, - name: "/medea.ControlApi/Create", - req_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, - resp_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, -}; - -const METHOD_CONTROL_API_APPLY: ::grpcio::Method = ::grpcio::Method { - ty: ::grpcio::MethodType::Unary, - name: "/medea.ControlApi/Apply", - req_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, - resp_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, -}; - -const METHOD_CONTROL_API_DELETE: ::grpcio::Method = ::grpcio::Method { - ty: ::grpcio::MethodType::Unary, - name: "/medea.ControlApi/Delete", - req_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, - resp_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, -}; - -const METHOD_CONTROL_API_GET: ::grpcio::Method = ::grpcio::Method { - ty: ::grpcio::MethodType::Unary, - name: "/medea.ControlApi/Get", - req_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, - resp_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, -}; - -#[derive(Clone)] -pub struct ControlApiClient { - client: ::grpcio::Client, -} - -impl ControlApiClient { - pub fn new(channel: ::grpcio::Channel) -> Self { - ControlApiClient { - client: ::grpcio::Client::new(channel), - } - } - - pub fn create_opt(&self, req: &super::control::CreateRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result { - self.client.unary_call(&METHOD_CONTROL_API_CREATE, req, opt) - } - - pub fn create(&self, req: &super::control::CreateRequest) -> ::grpcio::Result { - self.create_opt(req, ::grpcio::CallOption::default()) - } - - pub fn create_async_opt(&self, req: &super::control::CreateRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { - self.client.unary_call_async(&METHOD_CONTROL_API_CREATE, req, opt) - } - - pub fn create_async(&self, req: &super::control::CreateRequest) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { - self.create_async_opt(req, ::grpcio::CallOption::default()) - } - - pub fn apply_opt(&self, req: &super::control::ApplyRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result { - self.client.unary_call(&METHOD_CONTROL_API_APPLY, req, opt) - } - - pub fn apply(&self, req: &super::control::ApplyRequest) -> ::grpcio::Result { - self.apply_opt(req, ::grpcio::CallOption::default()) - } - - pub fn apply_async_opt(&self, req: &super::control::ApplyRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { - self.client.unary_call_async(&METHOD_CONTROL_API_APPLY, req, opt) - } - - pub fn apply_async(&self, req: &super::control::ApplyRequest) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { - self.apply_async_opt(req, ::grpcio::CallOption::default()) - } - - pub fn delete_opt(&self, req: &super::control::IdRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result { - self.client.unary_call(&METHOD_CONTROL_API_DELETE, req, opt) - } - - pub fn delete(&self, req: &super::control::IdRequest) -> ::grpcio::Result { - self.delete_opt(req, ::grpcio::CallOption::default()) - } - - pub fn delete_async_opt(&self, req: &super::control::IdRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { - self.client.unary_call_async(&METHOD_CONTROL_API_DELETE, req, opt) - } - - pub fn delete_async(&self, req: &super::control::IdRequest) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { - self.delete_async_opt(req, ::grpcio::CallOption::default()) - } - - pub fn get_opt(&self, req: &super::control::IdRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result { - self.client.unary_call(&METHOD_CONTROL_API_GET, req, opt) - } - - pub fn get(&self, req: &super::control::IdRequest) -> ::grpcio::Result { - self.get_opt(req, ::grpcio::CallOption::default()) - } - - pub fn get_async_opt(&self, req: &super::control::IdRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { - self.client.unary_call_async(&METHOD_CONTROL_API_GET, req, opt) - } - - pub fn get_async(&self, req: &super::control::IdRequest) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { - self.get_async_opt(req, ::grpcio::CallOption::default()) - } - pub fn spawn(&self, f: F) where F: ::futures::Future + Send + 'static { - self.client.spawn(f) - } -} - -pub trait ControlApi { - fn create(&mut self, ctx: ::grpcio::RpcContext, req: super::control::CreateRequest, sink: ::grpcio::UnarySink); - fn apply(&mut self, ctx: ::grpcio::RpcContext, req: super::control::ApplyRequest, sink: ::grpcio::UnarySink); - fn delete(&mut self, ctx: ::grpcio::RpcContext, req: super::control::IdRequest, sink: ::grpcio::UnarySink); - fn get(&mut self, ctx: ::grpcio::RpcContext, req: super::control::IdRequest, sink: ::grpcio::UnarySink); -} - -pub fn create_control_api(s: S) -> ::grpcio::Service { - let mut builder = ::grpcio::ServiceBuilder::new(); - let mut instance = s.clone(); - builder = builder.add_unary_handler(&METHOD_CONTROL_API_CREATE, move |ctx, req, resp| { - instance.create(ctx, req, resp) - }); - let mut instance = s.clone(); - builder = builder.add_unary_handler(&METHOD_CONTROL_API_APPLY, move |ctx, req, resp| { - instance.apply(ctx, req, resp) - }); - let mut instance = s.clone(); - builder = builder.add_unary_handler(&METHOD_CONTROL_API_DELETE, move |ctx, req, resp| { - instance.delete(ctx, req, resp) - }); - let mut instance = s.clone(); - builder = builder.add_unary_handler(&METHOD_CONTROL_API_GET, move |ctx, req, resp| { - instance.get(ctx, req, resp) - }); - builder.build() -} From fce98968c13eecedc61d4eb849223461fd3e85e6 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 22 Jul 2019 13:09:03 +0300 Subject: [PATCH 402/735] Fix building protobuf spec --- .gitignore | 2 +- Cargo.lock | 2 +- Cargo.toml | 3 --- proto/grpc/Cargo.toml | 4 ++++ build.rs => proto/grpc/build.rs | 4 ++-- 5 files changed, 8 insertions(+), 7 deletions(-) rename build.rs => proto/grpc/build.rs (76%) diff --git a/.gitignore b/.gitignore index 54745b8de..eb10e6182 100644 --- a/.gitignore +++ b/.gitignore @@ -7,5 +7,5 @@ /target/ **/*.rs.bk -!/proto/grpc/src +/proto/grpc/src !/proto/grpc/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index 7d2421f5f..e1876c74f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1161,7 +1161,6 @@ dependencies = [ "medea-macro 0.1.0-dev", "newtype_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "protoc-grpcio 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "redis 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1199,6 +1198,7 @@ dependencies = [ "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "grpcio 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "protoc-grpcio 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 81318f3c0..d8a74641f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,6 @@ homepage = "https://github.com/instrumentisto/medea" # documentation = "https://docs.rs/medea" readme = "README.md" repository = "https://github.com/instrumentisto/medea" -build = "build.rs" [workspace] members = [ @@ -69,5 +68,3 @@ serial_test = "0.2" serial_test_derive = "0.2" actix-codec = "0.1.2" -[build-dependencies] -protoc-grpcio = "0.3" diff --git a/proto/grpc/Cargo.toml b/proto/grpc/Cargo.toml index c024b7625..07f416252 100644 --- a/proto/grpc/Cargo.toml +++ b/proto/grpc/Cargo.toml @@ -7,8 +7,12 @@ authors = ["Instrumentisto Team "] homepage = "https://github.com/instrumentisto/medea" readme = "README.md" repository = "https://github.com/instrumentisto/medea" +build = "build.rs" [dependencies] grpcio = "0.4" futures = "0.1" protobuf = "2.7" + +[build-dependencies] +protoc-grpcio = "0.3" diff --git a/build.rs b/proto/grpc/build.rs similarity index 76% rename from build.rs rename to proto/grpc/build.rs index 50c6e4a00..08ec39ecb 100644 --- a/build.rs +++ b/proto/grpc/build.rs @@ -1,6 +1,6 @@ fn main() { - let proto_root = "proto/grpc"; - let proto_output = "proto/grpc/src"; + let proto_root = "."; + let proto_output = "./src"; println!("cargo:rerun-if-changed={}", proto_root); protoc_grpcio::compile_grpc_protos( &["control.proto"], From 485907d109a2d7376d395bf5131fa8346e7cd631 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 22 Jul 2019 13:21:38 +0300 Subject: [PATCH 403/735] Ignore lints for medea_grpc_proto --- proto/grpc/src/lib.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/proto/grpc/src/lib.rs b/proto/grpc/src/lib.rs index 3053d7002..56a1f42cd 100644 --- a/proto/grpc/src/lib.rs +++ b/proto/grpc/src/lib.rs @@ -1,2 +1,11 @@ +//! gRPC generated specs. +//! Don't edit `*.rs` files (except `lib.rs`) in this crate because it +//! automatically generated by `protoc` in `build.rs` file. + +#![allow(bare_trait_objects)] +#![allow(clippy::pedantic)] +#![allow(clippy::cargo)] +#![allow(clippy::nursery)] + pub mod control; pub mod control_grpc; From 77725795aa81677b2b8c759e21661dd487cdf78f Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 31 Jul 2019 12:18:18 +0300 Subject: [PATCH 404/735] Use generic in Pipeline --- src/api/control/member.rs | 2 +- src/api/control/mod.rs | 7 +++++-- src/api/control/pipeline.rs | 22 +++++++++++----------- src/api/control/room.rs | 2 +- 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/api/control/member.rs b/src/api/control/member.rs index 530a22da8..b53005088 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -33,7 +33,7 @@ macro_attr! { #[derive(Clone, Debug)] pub struct MemberSpec { /// Spec of this `Member`. - pipeline: Pipeline, + pipeline: Pipeline, /// Credentials to authorize `Member` with. credentials: String, diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index a93966747..f637014c4 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -40,11 +40,14 @@ pub enum TryFromElementError { pub enum Element { /// Represent [`RoomSpec`]. /// Can transform into [`RoomSpec`] by `RoomSpec::try_from`. - Room { id: RoomId, spec: Pipeline }, + Room { id: RoomId, spec: Pipeline }, /// Represent [`MemberSpec`]. /// Can transform into [`MemberSpec`] by `MemberSpec::try_from`. - Member { spec: Pipeline, credentials: String }, + Member { + spec: Pipeline, + credentials: String, + }, /// Represent [`WebRtcPublishEndpoint`]. /// Can transform into [`Endpoint`] enum by `Endpoint::try_from`. diff --git a/src/api/control/pipeline.rs b/src/api/control/pipeline.rs index 1456ae7d2..e58ecc803 100644 --- a/src/api/control/pipeline.rs +++ b/src/api/control/pipeline.rs @@ -14,32 +14,32 @@ use crate::api::control::Element; /// Entity that represents some pipeline of spec. #[derive(Clone, Deserialize, Debug)] -pub struct Pipeline { - pipeline: HashMap, +pub struct Pipeline { + pipeline: HashMap, } -impl Pipeline { - pub fn iter(&self) -> impl Iterator { +impl Pipeline { + pub fn iter(&self) -> impl Iterator { self.into_iter() } - pub fn get(&self, id: &str) -> Option<&Element> { + pub fn get(&self, id: &str) -> Option<&T> { self.pipeline.get(id) } } -impl IntoIterator for Pipeline { - type IntoIter = IntoIter; - type Item = (String, Element); +impl IntoIterator for Pipeline { + type IntoIter = IntoIter; + type Item = (String, T); fn into_iter(self) -> Self::IntoIter { self.pipeline.into_iter() } } -impl<'a> IntoIterator for &'a Pipeline { - type IntoIter = Iter<'a, String, Element>; - type Item = (&'a String, &'a Element); +impl<'a, T> IntoIterator for &'a Pipeline { + type IntoIter = Iter<'a, String, T>; + type Item = (&'a String, &'a T); fn into_iter(self) -> Self::IntoIter { self.pipeline.iter() diff --git a/src/api/control/room.rs b/src/api/control/room.rs index ab67c6c4f..ee1135fbe 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -33,7 +33,7 @@ macro_attr! { #[derive(Clone, Debug)] pub struct RoomSpec { pub id: Id, - pub pipeline: Pipeline, + pub pipeline: Pipeline, } impl RoomSpec { From 0cb685f2da0f86e7e50d106c16790ac5093ff379 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 31 Jul 2019 12:32:37 +0300 Subject: [PATCH 405/735] Use individual Element enum for every element --- src/api/control/member.rs | 31 ++++++++++++++++++++++++------- src/api/control/mod.rs | 14 +++++++++++++- src/api/control/pipeline.rs | 2 -- src/api/control/room.rs | 26 ++++++++++++++++++++------ 4 files changed, 57 insertions(+), 16 deletions(-) diff --git a/src/api/control/member.rs b/src/api/control/member.rs index b53005088..32be0d661 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -10,8 +10,9 @@ use serde::Deserialize; use super::{ endpoint::{WebRtcPlayEndpoint, WebRtcPublishEndpoint}, pipeline::Pipeline, - Element, TryFromElementError, + TryFromElementError, }; +use crate::api::control::room::RoomElement; macro_attr! { /// ID of `Member`. @@ -28,12 +29,24 @@ macro_attr! { pub struct Id(pub String); } +#[derive(Clone, Deserialize, Debug)] +#[serde(tag = "kind")] +pub enum MemberElement { + /// Represent [`WebRtcPublishEndpoint`]. + /// Can transform into [`Endpoint`] enum by `Endpoint::try_from`. + WebRtcPublishEndpoint { spec: WebRtcPublishEndpoint }, + + /// Represent [`WebRtcPlayEndpoint`]. + /// Can transform into [`Endpoint`] enum by `Endpoint::try_from`. + WebRtcPlayEndpoint { spec: WebRtcPlayEndpoint }, +} + /// Newtype for [`Element::Member`] variant. #[allow(clippy::module_name_repetitions)] #[derive(Clone, Debug)] pub struct MemberSpec { /// Spec of this `Member`. - pipeline: Pipeline, + pipeline: Pipeline, /// Credentials to authorize `Member` with. credentials: String, @@ -45,7 +58,7 @@ impl MemberSpec { self.pipeline .iter() .filter_map(|(id, e)| match e { - Element::WebRtcPlayEndpoint { spec } => Some((id, spec)), + MemberElement::WebRtcPlayEndpoint { spec } => Some((id, spec)), _ => None, }) .collect() @@ -58,7 +71,9 @@ impl MemberSpec { self.pipeline .iter() .filter_map(|(id, e)| match e { - Element::WebRtcPublishEndpoint { spec } => Some((id, spec)), + MemberElement::WebRtcPublishEndpoint { spec } => { + Some((id, spec)) + } _ => None, }) .collect() @@ -69,12 +84,14 @@ impl MemberSpec { } } -impl TryFrom<&Element> for MemberSpec { +impl TryFrom<&RoomElement> for MemberSpec { type Error = TryFromElementError; - fn try_from(from: &Element) -> Result { + // TODO: delete this allow when some new RoomElement will be added. + #[allow(unreachable_patterns)] + fn try_from(from: &RoomElement) -> Result { match from { - Element::Member { spec, credentials } => Ok(Self { + RoomElement::Member { spec, credentials } => Ok(Self { pipeline: spec.clone(), credentials: credentials.clone(), }), diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index f637014c4..e09ea7648 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -20,6 +20,18 @@ pub use self::{ member::{Id as MemberId, MemberSpec}, room::{Id as RoomId, RoomSpec}, }; +use crate::api::control::room::RoomElement; + +#[derive(Clone, Deserialize, Debug)] +#[serde(tag = "kind")] +pub enum RootElement { + /// Represent [`RoomSpec`]. + /// Can transform into [`RoomSpec`] by `RoomSpec::try_from`. + Room { + id: RoomId, + spec: Pipeline, + }, +} /// Errors that can occur when we try transform some spec from [`Element`]. /// This error used in all [`TryFrom`] of Control API. @@ -63,7 +75,7 @@ pub fn load_from_yaml_file>(path: P) -> Result { let mut file = File::open(path)?; let mut buf = String::new(); file.read_to_string(&mut buf)?; - let parsed: Element = serde_yaml::from_str(&buf)?; + let parsed: RootElement = serde_yaml::from_str(&buf)?; let room = RoomSpec::try_from(&parsed)?; Ok(room) diff --git a/src/api/control/pipeline.rs b/src/api/control/pipeline.rs index e58ecc803..96fbad5ec 100644 --- a/src/api/control/pipeline.rs +++ b/src/api/control/pipeline.rs @@ -10,8 +10,6 @@ use std::{ use serde::Deserialize; -use crate::api::control::Element; - /// Entity that represents some pipeline of spec. #[derive(Clone, Deserialize, Debug)] pub struct Pipeline { diff --git a/src/api/control/room.rs b/src/api/control/room.rs index ee1135fbe..c80212766 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -8,8 +8,9 @@ use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; use serde::Deserialize; use super::{ - member::MemberSpec, pipeline::Pipeline, Element, MemberId, - TryFromElementError, + member::{MemberElement, MemberSpec}, + pipeline::Pipeline, + MemberId, RootElement, TryFromElementError, }; macro_attr! { @@ -27,13 +28,24 @@ macro_attr! { pub struct Id(pub String); } +#[derive(Clone, Deserialize, Debug)] +#[serde(tag = "kind")] +pub enum RoomElement { + /// Represent [`MemberSpec`]. + /// Can transform into [`MemberSpec`] by `MemberSpec::try_from`. + Member { + spec: Pipeline, + credentials: String, + }, +} + /// [`crate::signalling::room::Room`] specification. /// Newtype for [`Element::Room`] #[allow(clippy::module_name_repetitions)] #[derive(Clone, Debug)] pub struct RoomSpec { pub id: Id, - pub pipeline: Pipeline, + pub pipeline: Pipeline, } impl RoomSpec { @@ -58,12 +70,14 @@ impl RoomSpec { } } -impl TryFrom<&Element> for RoomSpec { +impl TryFrom<&RootElement> for RoomSpec { type Error = TryFromElementError; - fn try_from(from: &Element) -> Result { + // TODO: delete this allow when some new RootElement will be added. + #[allow(unreachable_patterns)] + fn try_from(from: &RootElement) -> Result { match from { - Element::Room { id, spec } => Ok(Self { + RootElement::Room { id, spec } => Ok(Self { id: id.clone(), pipeline: spec.clone(), }), From 5805ea7a4c6cf84497e007860c61d56026b0823e Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 31 Jul 2019 12:39:49 +0300 Subject: [PATCH 406/735] Remove old Element enum --- src/api/control/endpoint.rs | 11 +++++------ src/api/control/member.rs | 2 +- src/api/control/mod.rs | 34 ++-------------------------------- 3 files changed, 8 insertions(+), 39 deletions(-) diff --git a/src/api/control/endpoint.rs b/src/api/control/endpoint.rs index 1139b37d0..326c3fb30 100644 --- a/src/api/control/endpoint.rs +++ b/src/api/control/endpoint.rs @@ -9,7 +9,7 @@ use serde::{ use crate::api::control::MemberId; -use super::{Element, TryFromElementError}; +use super::{member::MemberElement, TryFromElementError}; /// [`Endpoint`] represents a media element that one or more media data streams /// flow through. @@ -19,18 +19,17 @@ pub enum Endpoint { WebRtcPlay(WebRtcPlayEndpoint), } -impl TryFrom<&Element> for Endpoint { +impl TryFrom<&MemberElement> for Endpoint { type Error = TryFromElementError; - fn try_from(from: &Element) -> Result { + fn try_from(from: &MemberElement) -> Result { match from { - Element::WebRtcPlayEndpoint { spec } => { + MemberElement::WebRtcPlayEndpoint { spec } => { Ok(Endpoint::WebRtcPlay(spec.clone())) } - Element::WebRtcPublishEndpoint { spec } => { + MemberElement::WebRtcPublishEndpoint { spec } => { Ok(Endpoint::WebRtcPublish(spec.clone())) } - _ => Err(TryFromElementError::NotEndpoint), } } } diff --git a/src/api/control/member.rs b/src/api/control/member.rs index 32be0d661..4f0ccd563 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -10,9 +10,9 @@ use serde::Deserialize; use super::{ endpoint::{WebRtcPlayEndpoint, WebRtcPublishEndpoint}, pipeline::Pipeline, + room::RoomElement, TryFromElementError, }; -use crate::api::control::room::RoomElement; macro_attr! { /// ID of `Member`. diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index e09ea7648..083faa7d4 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -10,17 +10,13 @@ use std::{convert::TryFrom as _, fs::File, io::Read as _, path::Path}; use failure::{Error, Fail}; use serde::Deserialize; -use self::{ - endpoint::{WebRtcPlayEndpoint, WebRtcPublishEndpoint}, - pipeline::Pipeline, -}; +use self::pipeline::Pipeline; pub use self::{ endpoint::Endpoint, member::{Id as MemberId, MemberSpec}, - room::{Id as RoomId, RoomSpec}, + room::{Id as RoomId, RoomElement, RoomSpec}, }; -use crate::api::control::room::RoomElement; #[derive(Clone, Deserialize, Debug)] #[serde(tag = "kind")] @@ -38,38 +34,12 @@ pub enum RootElement { #[allow(clippy::pub_enum_variant_names)] #[derive(Debug, Fail)] pub enum TryFromElementError { - #[fail(display = "Element is not Endpoint")] - NotEndpoint, #[fail(display = "Element is not Room")] NotRoom, #[fail(display = "Element is not Member")] NotMember, } -/// Entity for parsing Control API request. -#[derive(Clone, Deserialize, Debug)] -#[serde(tag = "kind")] -pub enum Element { - /// Represent [`RoomSpec`]. - /// Can transform into [`RoomSpec`] by `RoomSpec::try_from`. - Room { id: RoomId, spec: Pipeline }, - - /// Represent [`MemberSpec`]. - /// Can transform into [`MemberSpec`] by `MemberSpec::try_from`. - Member { - spec: Pipeline, - credentials: String, - }, - - /// Represent [`WebRtcPublishEndpoint`]. - /// Can transform into [`Endpoint`] enum by `Endpoint::try_from`. - WebRtcPublishEndpoint { spec: WebRtcPublishEndpoint }, - - /// Represent [`WebRtcPlayEndpoint`]. - /// Can transform into [`Endpoint`] enum by `Endpoint::try_from`. - WebRtcPlayEndpoint { spec: WebRtcPlayEndpoint }, -} - /// Load [`RoomSpec`] from file with YAML format. pub fn load_from_yaml_file>(path: P) -> Result { let mut file = File::open(path)?; From 40f2e4d8563a82b1224d733e46772dbb1235916c Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 31 Jul 2019 12:41:29 +0300 Subject: [PATCH 407/735] Fix lints --- src/api/control/member.rs | 1 + src/api/control/room.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/src/api/control/member.rs b/src/api/control/member.rs index 4f0ccd563..8929c84e5 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -29,6 +29,7 @@ macro_attr! { pub struct Id(pub String); } +#[allow(clippy::module_name_repetitions)] #[derive(Clone, Deserialize, Debug)] #[serde(tag = "kind")] pub enum MemberElement { diff --git a/src/api/control/room.rs b/src/api/control/room.rs index c80212766..d2562f4a4 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -28,6 +28,7 @@ macro_attr! { pub struct Id(pub String); } +#[allow(clippy::module_name_repetitions)] #[derive(Clone, Deserialize, Debug)] #[serde(tag = "kind")] pub enum RoomElement { From c3180438c859ca812f91256429eaf405f449bee1 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 31 Jul 2019 13:02:28 +0300 Subject: [PATCH 408/735] Fix test --- src/signalling/elements/member.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index 4e2226a97..2d78e296b 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -352,7 +352,7 @@ pub fn parse_members( #[cfg(test)] mod tests { - use crate::api::control::{Element, MemberId}; + use crate::api::control::{MemberId, RootElement}; use super::*; @@ -400,7 +400,8 @@ mod tests { } fn get_test_store() -> HashMap { - let room_element: Element = serde_yaml::from_str(TEST_SPEC).unwrap(); + let room_element: RootElement = + serde_yaml::from_str(TEST_SPEC).unwrap(); let room_spec = RoomSpec::try_from(&room_element).unwrap(); parse_members(&room_spec).unwrap() } From 8df76a2e5bb9b8d028d4780a0324cc181c953686 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 1 Aug 2019 12:47:42 +0300 Subject: [PATCH 409/735] Add unit tests for LocalUri parsing --- src/api/control/local_uri.rs | 108 +++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) diff --git a/src/api/control/local_uri.rs b/src/api/control/local_uri.rs index 92233fb8a..8a94494aa 100644 --- a/src/api/control/local_uri.rs +++ b/src/api/control/local_uri.rs @@ -317,3 +317,111 @@ impl fmt::Display for LocalUriType { } } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn parse_local_uri_to_room_element() { + let local_uri = LocalUriType::parse("local://room_id").unwrap(); + if let LocalUriType::Room(room) = local_uri { + assert_eq!(room.take_room_id(), RoomId("room_id".to_string())); + } else { + unreachable!(); + } + } + + #[test] + fn parse_local_uri_to_element_of_room() { + let local_uri = + LocalUriType::parse("local://room_id/room_element_id").unwrap(); + if let LocalUriType::Member(member) = local_uri { + let (element_id, room_uri) = member.take_member_id(); + assert_eq!(element_id, MemberId("room_element_id".to_string())); + let room_id = room_uri.take_room_id(); + assert_eq!(room_id, RoomId("room_id".to_string())); + } else { + unreachable!(); + } + } + + #[test] + fn parse_local_uri_to_endpoint() { + let local_uri = + LocalUriType::parse("local://room_id/room_element_id/endpoint_id") + .unwrap(); + if let LocalUriType::Endpoint(endpoint) = local_uri { + let (endpoint_id, member_uri) = endpoint.take_endpoint_id(); + assert_eq!(endpoint_id, "endpoint_id".to_string()); + let (member_id, room_uri) = member_uri.take_member_id(); + assert_eq!(member_id, MemberId("room_element_id".to_string())); + let room_id = room_uri.take_room_id(); + assert_eq!(room_id, RoomId("room_id".to_string())); + } else { + unreachable!(); + } + } + + #[test] + fn returns_parse_error_if_local_uri_not_local() { + match LocalUriType::parse("not_local://room_id") { + Ok(_) => unreachable!(), + Err(e) => match e { + LocalUriParseError::NotLocal(_) => (), + _ => unreachable!(), + }, + } + } + + #[test] + fn returns_parse_error_if_local_uri_empty() { + match LocalUriType::parse("") { + Ok(_) => unreachable!(), + Err(e) => match e { + LocalUriParseError::Empty => (), + _ => unreachable!(), + }, + } + } + + #[test] + fn returns_error_if_local_uri_have_too_many_paths() { + match LocalUriType::parse("local://room/member/endpoint/too_many") { + Ok(_) => unreachable!(), + Err(e) => match e { + LocalUriParseError::TooManyFields(_, _) => (), + _ => unreachable!(), + }, + } + } + + #[test] + fn properly_serialize() { + for local_uri_str in vec![ + "local://room_id", + "local://room_id/member_id", + "local://room_id/member_id/endpoint_id", + ] { + let local_uri = LocalUriType::parse(&local_uri_str).unwrap(); + assert_eq!(local_uri_str.to_string(), local_uri.to_string()); + } + } + + #[test] + fn return_error_when_local_uri_not_full() { + for local_uri_str in vec![ + "local://room_id//endpoint_id", + "local:////endpoint_id", + "local:///member_id/endpoint_id", + ] { + match LocalUriType::parse(local_uri_str) { + Ok(_) => unreachable!(local_uri_str), + Err(e) => match e { + LocalUriParseError::MissingFields(_) => (), + _ => unreachable!(local_uri_str), + }, + } + } + } +} From ec7a5ad011796f180ece602194de37aac29a9c4f Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 1 Aug 2019 13:51:53 +0300 Subject: [PATCH 410/735] Upd deps --- Cargo.lock | 397 ++++++++++++++++++++++++++--------------------------- Cargo.toml | 8 +- 2 files changed, 200 insertions(+), 205 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a7744c927..840c50dab 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6,7 +6,7 @@ version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -19,12 +19,12 @@ dependencies = [ "actix_derive 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-channel 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "hashbrown 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -42,14 +42,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "actix-connect" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -58,8 +58,8 @@ dependencies = [ "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", "either 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", - "http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "http 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-current-thread 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "trust-dns-resolver 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -71,7 +71,7 @@ version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-connect 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-connect 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "actix-server-config 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "actix-service 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "actix-threadpool 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -89,19 +89,19 @@ dependencies = [ "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "flate2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", - "h2 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "h2 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", "hashbrown 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", + "http 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", "httparse 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "mime 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", "percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "serde_urlencoded 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", "sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -128,10 +128,10 @@ dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", - "http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "http 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "serde_urlencoded 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", "sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -147,10 +147,10 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "http 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "string 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -177,7 +177,7 @@ dependencies = [ "actix-server-config 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "actix-service 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -215,7 +215,7 @@ dependencies = [ "derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "threadpool 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -231,7 +231,7 @@ dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "either 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-current-thread 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -257,12 +257,12 @@ dependencies = [ "encoding_rs 0.8.17 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "hashbrown 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "mime 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "serde_urlencoded 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", @@ -271,7 +271,7 @@ dependencies = [ [[package]] name = "actix-web-actors" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "actix 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -288,7 +288,7 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -298,7 +298,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -375,11 +375,11 @@ dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "mime 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", "percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "serde_urlencoded 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", @@ -387,7 +387,7 @@ dependencies = [ [[package]] name = "backtrace" -version = "0.3.33" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "backtrace-sys 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)", @@ -401,7 +401,7 @@ name = "backtrace-sys" version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -415,7 +415,7 @@ dependencies = [ [[package]] name = "bb8" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", @@ -425,12 +425,12 @@ dependencies = [ [[package]] name = "bb8-redis" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bb8 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "bb8 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", - "redis 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "redis 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -453,7 +453,7 @@ name = "brotli-sys" version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -496,7 +496,7 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.37" +version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -543,7 +543,7 @@ dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "nom 4.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "rust-ini 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "serde-hjson 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", @@ -584,11 +584,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "crossbeam-channel" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -596,21 +595,21 @@ name = "crossbeam-deque" version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "crossbeam-epoch 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-epoch 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "crossbeam-epoch" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "memoffset 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -618,12 +617,12 @@ name = "crossbeam-queue" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "crossbeam-utils" -version = "0.6.5" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -638,7 +637,7 @@ dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -649,9 +648,9 @@ dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -666,12 +665,12 @@ dependencies = [ [[package]] name = "dotenv" -version = "0.13.0" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -756,7 +755,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -766,8 +765,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", "humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -776,7 +775,7 @@ name = "failure" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "backtrace 0.3.33 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace 0.3.34 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -787,7 +786,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", "synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -799,7 +798,7 @@ dependencies = [ "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "miniz-sys 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "miniz_oxide_c_api 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "miniz_oxide_c_api 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -838,39 +837,30 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "getrandom" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "h2" -version = "0.1.25" +version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", - "http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", + "http 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "string 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "hashbrown" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "hashbrown" version = "0.3.1" @@ -900,7 +890,7 @@ dependencies = [ [[package]] name = "http" -version = "0.1.17" +version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -950,10 +940,10 @@ name = "ipconfig" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "socket2 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "socket2 0.3.10 (registry+https://github.com/rust-lang/crates.io-index)", "widestring 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", - "winreg 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "winreg 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -972,7 +962,7 @@ dependencies = [ "medea-client-api-proto 0.1.0-dev", "medea-macro 0.1.0-dev", "newtype_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-futures 0.3.25 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1012,9 +1002,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "lazy_static" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "spin 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", -] [[package]] name = "libc" @@ -1065,12 +1052,12 @@ name = "log" version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "log" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1103,40 +1090,40 @@ dependencies = [ "actix-http 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", "actix-http-test 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "actix-web 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-web-actors 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-web-actors 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "awc 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "bb8 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "bb8-redis 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "bb8 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "bb8-redis 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "config 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", - "dotenv 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", + "dotenv 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", - "hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "hashbrown 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "macro-attr 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "medea-client-api-proto 0.1.0-dev", "medea-macro 0.1.0-dev", "newtype_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "redis 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "redis 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "serde-humantime 0.1.1 (git+https://github.com/tailhook/serde-humantime?branch=serde_wrapper)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "serde_yaml 0.8.9 (registry+https://github.com/rust-lang/crates.io-index)", "serial_test 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "serial_test_derive 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "slog 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "slog-async 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "slog-envlogger 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "slog-json 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "slog-scope 4.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "slog-stdlog 3.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "slog-stdlog 3.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "smart-default 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-signal 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", + "toml 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1144,7 +1131,7 @@ name = "medea-client-api-proto" version = "0.1.0-dev" dependencies = [ "medea-macro 0.1.0-dev", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1155,7 +1142,7 @@ dependencies = [ "Inflector 0.11.4 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1173,8 +1160,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "memoffset" -version = "0.2.1" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "memory_units" @@ -1194,13 +1184,13 @@ name = "miniz-sys" version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "miniz_oxide" -version = "0.2.2" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1208,13 +1198,13 @@ dependencies = [ [[package]] name = "miniz_oxide_c_api" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)", "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", - "miniz_oxide 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "miniz_oxide 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1227,7 +1217,7 @@ dependencies = [ "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1353,7 +1343,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lock_api 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot_core 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot_core 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1386,7 +1376,7 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.6.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1473,9 +1463,9 @@ name = "rand" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "getrandom 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "getrandom 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_chacha 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1491,10 +1481,9 @@ dependencies = [ [[package]] name = "rand_chacha" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "c2-chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1517,7 +1506,7 @@ name = "rand_core" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "getrandom 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "getrandom 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1594,17 +1583,21 @@ dependencies = [ [[package]] name = "redis" -version = "0.10.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "combine 3.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "dtoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", + "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-sync 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-uds 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1638,12 +1631,12 @@ dependencies = [ [[package]] name = "regex" -version = "1.1.9" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aho-corasick 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "utf8-ranges 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1655,10 +1648,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "regex-syntax" -version = "0.6.8" +version = "0.6.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "ucd-util 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1763,10 +1756,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde" -version = "1.0.97" +version = "1.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde_derive 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1777,7 +1770,7 @@ dependencies = [ "lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "linked-hash-map 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1787,17 +1780,17 @@ version = "0.1.1" source = "git+https://github.com/tailhook/serde-humantime?branch=serde_wrapper#36b86d5ca09db3caf2edb06e0d46b505d0915792" dependencies = [ "humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "serde_derive" -version = "1.0.97" +version = "1.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1807,7 +1800,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1825,7 +1818,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "dtoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1836,7 +1829,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "dtoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "yaml-rust 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1854,7 +1847,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1868,12 +1861,12 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", - "signal-hook-registry 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "signal-hook-registry 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "signal-hook-registry" -version = "1.0.1" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arc-swap 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1887,7 +1880,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "slog" -version = "2.5.0" +version = "2.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1895,7 +1888,7 @@ name = "slog-async" version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "slog 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "take_mut 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1907,10 +1900,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.1.80 (registry+https://github.com/rust-lang/crates.io-index)", - "slog 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "slog-async 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "slog-scope 4.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "slog-stdlog 3.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "slog-stdlog 3.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "slog-term 2.4.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1920,9 +1913,9 @@ version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", - "slog 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1932,17 +1925,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arc-swap 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "slog 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "slog-stdlog" -version = "3.0.2" +version = "3.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "slog 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "slog-scope 4.1.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1953,7 +1946,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", "chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", - "slog 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "term 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1970,12 +1963,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "socket2" -version = "0.3.9" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1989,11 +1982,6 @@ name = "sourcefile" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "spin" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "stable_deref_trait" version = "1.1.1" @@ -2009,7 +1997,7 @@ dependencies = [ [[package]] name = "syn" -version = "0.15.39" +version = "0.15.42" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2024,7 +2012,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2141,7 +2129,7 @@ name = "tokio-executor" version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2162,7 +2150,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2170,10 +2158,10 @@ name = "tokio-reactor" version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2228,9 +2216,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-deque 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2242,7 +2230,7 @@ name = "tokio-timer" version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2255,7 +2243,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2271,7 +2259,7 @@ dependencies = [ "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", "mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2284,7 +2272,15 @@ name = "toml" version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "toml" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2298,10 +2294,10 @@ dependencies = [ "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", - "socket2 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "socket2 0.3.10 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2321,7 +2317,7 @@ dependencies = [ "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "ipconfig 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "lru-cache 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "resolv-conf 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2331,7 +2327,7 @@ dependencies = [ [[package]] name = "ucd-util" -version = "0.1.3" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -2412,7 +2408,7 @@ name = "wasm-bindgen" version = "0.2.48" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-macro 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2424,10 +2420,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bumpalo 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-shared 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2457,7 +2453,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-backend 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-shared 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2497,10 +2493,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-backend 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", "weedle 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2590,7 +2586,7 @@ dependencies = [ [[package]] name = "winreg" -version = "0.6.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2625,7 +2621,7 @@ dependencies = [ "checksum Inflector 0.11.4 (registry+https://github.com/rust-lang/crates.io-index)" = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" "checksum actix 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)" = "671ce3d27313f236827a5dd153a1073ad03ef31fc77f562020263e7830cf1ef7" "checksum actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9f2c11af4b06dc935d8e1b1491dad56bfb32febc49096a91e773f8535c176453" -"checksum actix-connect 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d161322a26e6b76d6598f48654afbdcfee644c900d4368e9962ec68abd0713b" +"checksum actix-connect 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "818f0901d2188c8c75a489c42db6e8d9e1b020f0ca2baaa4c940e08e1817eed0" "checksum actix-http 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "59698e11ceb42ea16a2e491bd5a9b48adc7268323a5b600522d408d09783828c" "checksum actix-http-test 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "beafa31d71c8fa8204ede1602a3dd221e5cf30ff354180f8ee87274ab81cf607" "checksum actix-router 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "23224bb527e204261d0291102cb9b52713084def67d94f7874923baefe04ccf7" @@ -2636,7 +2632,7 @@ dependencies = [ "checksum actix-threadpool 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1c29f7c554d56b3841f4bb85d5b3dee01ba536e1307679f56eb54de28aaec3fb" "checksum actix-utils 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6ea501068a0173533704be321f149853f702d9e3c3ce9d57e7a96d94b1ab5aca" "checksum actix-web 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0147b2fd52ced64145c8370af627f12f098222a1c6ba67d021e21cd0d806f574" -"checksum actix-web-actors 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8197aa04b8950ed9e37340cd46fe7ad3ccb8b1c4bbcef881ee5f6d149a425608" +"checksum actix-web-actors 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "008c1b686048a16fef4ef2fc6b6e5fcf5f29829891ad87fc0848ade26b285627" "checksum actix-web-codegen 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3fe9e3cdec1e645b675f354766e0688c5705021c85ab3cf739be1c8999b91c76" "checksum actix_derive 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0bf5f6d7bf2d220ae8b4a7ae02a572bb35b7c4806b24049af905ab8110de156c" "checksum adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7e522997b529f05601e05166c07ed17789691f562762c7f3b987263d2dedee5c" @@ -2649,11 +2645,11 @@ dependencies = [ "checksum atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1803c647a3ec87095e7ae7acfca019e98de5ec9a7d01343f611cf3152ed71a90" "checksum autocfg 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "22130e92352b948e7e82a49cdb0aa94f2211761117f29e052dd397c1ac33542b" "checksum awc 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4c4763e6aa29a801d761dc3464f081d439ea5249ba90c3c3bdfc8dd3f739d233" -"checksum backtrace 0.3.33 (registry+https://github.com/rust-lang/crates.io-index)" = "88fb679bc9af8fa639198790a77f52d345fe13656c08b43afa9424c206b731c6" +"checksum backtrace 0.3.34 (registry+https://github.com/rust-lang/crates.io-index)" = "b5164d292487f037ece34ec0de2fcede2faa162f085dd96d2385ab81b12765ba" "checksum backtrace-sys 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)" = "82a830b4ef2d1124a711c71d263c5abdc710ef8e907bd508c88be475cebc422b" "checksum base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" -"checksum bb8 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6ac04c3b2d3327a583c9a93b6c5ab4316e6609f5ec84b71b89ebe518e0edbad2" -"checksum bb8-redis 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9817f38c173f0da1581b923b90e66750a090413ad67a20980d5ad64141bab476" +"checksum bb8 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0ac73ee3406f475415bba792942016291b87bac08839c38a032de56085a73b2c" +"checksum bb8-redis 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "39945a33c03edfba8c353d330b921961e2137d4fc4215331c1b2397f32acff80" "checksum bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3d155346769a6855b86399e9bc3814ab343cd3d62c7e985113d46a0ec3c281fd" "checksum blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "5d6d530bdd2d52966a6d03b7a964add7ae1a288d25214066fd4b600f0f796400" "checksum brotli-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4445dea95f4c2b41cde57cc9fee236ae4dbae88d8fcbdb4750fc1bb5d86aaecd" @@ -2662,7 +2658,7 @@ dependencies = [ "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" "checksum bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" "checksum c2-chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7d64d04786e0f528460fc884753cf8dddcc466be308f6026f8e355c41a0e4101" -"checksum cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)" = "39f75544d7bbaf57560d2168f28fd649ff9c76153874db88bdbdfd839b1a7e7d" +"checksum cc 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)" = "ce400c638d48ee0e9ab75aef7997609ec57367ccfe1463f21bf53c3eca67bf46" "checksum cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b486ce3ccf7ffd79fdeb678eac06a9e6c09fc88d33836340becb8fffe87c5e33" "checksum chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "77d81f58b7301084de3b958691458a53c3f7e0b1d702f77e550b6a88e3a88abe" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" @@ -2673,15 +2669,15 @@ dependencies = [ "checksum copyless 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "6ff9c56c9fb2a49c05ef0e431485a22400af20d33226dc0764d891d09e724127" "checksum crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" "checksum crossbeam 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)" = "bd66663db5a988098a89599d4857919b3acf7f61402e61365acfd3919857b9be" -"checksum crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "0f0ed1a4de2235cabda8558ff5840bffb97fcb64c97827f354a451307df5f72b" +"checksum crossbeam-channel 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "c8ec7fcd21571dc78f96cc96243cab8d8f035247c3efd16c687be154c3fa9efa" "checksum crossbeam-deque 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b18cd2e169ad86297e6bc0ad9aa679aee9daa4f19e8163860faf7c164e4f5a71" -"checksum crossbeam-epoch 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "04c9e3102cc2d69cd681412141b390abd55a362afc1540965dad0ad4d34280b4" +"checksum crossbeam-epoch 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "fedcd6772e37f3da2a9af9bf12ebe046c0dfe657992377b4df982a2b54cd37a9" "checksum crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7c979cd6cfe72335896575c6b5688da489e420d36a27a0b9eb0c73db574b4a4b" -"checksum crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f8306fcef4a7b563b76b7dd949ca48f52bc1141aa067d2ea09565f3e2652aa5c" +"checksum crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "04973fa96e96579258a5091af6003abde64af786b860f18622b82e026cca60e6" "checksum derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6d944ac6003ed268757ef1ee686753b57efc5fcf0ebe7b64c9fc81e7e32ff839" "checksum derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a141330240c921ec6d074a3e188a7c7ef95668bb95e7d44fa0e5778ec2a7afe" "checksum dirs 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3fd78930633bd1c6e35c4b42b1df7b0cbc6bc191146e512bb3bedf243fcc3901" -"checksum dotenv 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c0d0a1279c96732bc6800ce6337b6a614697b0e74ae058dc03c62ebeb78b4d86" +"checksum dotenv 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4424bad868b0ffe6ae351ee463526ba625bbca817978293bbe6bb7dc1804a175" "checksum dtoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "ea57b42383d091c85abcc2706240b94ab2a8fa1fc81c10ff23c4de06e2a90b5e" "checksum either 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5527cfe0d098f36e3f8839852688e63c8fff1c90b2b405aef730615f9a7bcf7b" "checksum encoding 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "6b0d943856b990d12d3b55b359144ff341533e516d94098b1d3fc1ac666d36ec" @@ -2703,14 +2699,13 @@ dependencies = [ "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" "checksum futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "45dc39533a6cae6da2b56da48edae506bb767ec07370f86f70fc062e9d435869" "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" -"checksum getrandom 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "e65cce4e5084b14874c4e7097f38cab54f47ee554f9194673456ea379dcc4c55" -"checksum h2 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)" = "a539b63339fbbb00e081e84b6e11bd1d9634a82d91da2984a18ac74a8823f392" -"checksum hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3bae29b6653b3412c2e71e9d486db9f9df5d701941d86683005efb9f2d28e3da" +"checksum getrandom 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "cd8e190892c840661957ba9f32dacfb3eb405e657f9f9f60485605f0bb37d6f8" +"checksum h2 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)" = "a5b34c246847f938a410a03c5458c7fee2274436675e76d8b903c08efc29c462" "checksum hashbrown 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "29fba9abe4742d586dfd0c06ae4f7e73a1c2d86b856933509b269d82cdf06e18" "checksum hashbrown 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e1de41fb8dba9714efd92241565cdff73f78508c95697dd56787d3cba27e2353" "checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" "checksum hostname 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "21ceb46a83a85e824ef93669c8b390009623863b5c195d1ba747292c0c72f94e" -"checksum http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)" = "eed324f0f0daf6ec10c474f150505af2c143f251722bf9dbd1261bd1f2ee2c1a" +"checksum http 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)" = "372bcb56f939e449117fb0869c2e8fd8753a8223d92a172c6e808cf123a5b6e4" "checksum httparse 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "cd179ae861f0c2e53da70d892f5f3029f9594be0c41dc5269cd371691b1dc2f9" "checksum humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ca7e5f2e110db35f93b837c81797f3714500b81d517bf20c431b16d3ca4f114" "checksum idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e" @@ -2730,18 +2725,18 @@ dependencies = [ "checksum lock_api 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ed946d4529956a20f2d63ebe1b69996d5a2137c91913fe3ebbeff957f5bca7ff" "checksum lock_api 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f8912e782533a93a167888781b836336a6ca5da6175c05944c86cf28c31104dc" "checksum log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b" -"checksum log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "c275b6ad54070ac2d665eef9197db647b32239c9d244bfb6f041a766d00da5b3" +"checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" "checksum lru-cache 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "31e24f1ad8321ca0e8a1e0ac13f23cb668e6f5466c2c57319f6a5cf1cc8e3b1c" "checksum macro-attr 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "00e51c6f0e2bf862b01b3d784fc32b02feb248a69062c51fb0b6d14cd526cc2a" "checksum matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" "checksum memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d8b629fb514376c675b98c1421e80b151d3817ac42d7c667717d282761418d20" "checksum memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "88579771288728879b57485cc7d6b07d648c9f0141eb955f8ab7f9d45394468e" -"checksum memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0f9dc261e2b62d7a622bf416ea3c5245cdd5d9a7fcc428c0d06804dfce1775b3" +"checksum memoffset 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ce6075db033bbbb7ee5a0bbd3a3186bbae616f57fb001c485c7ff77955f8177f" "checksum memory_units 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8452105ba047068f40ff7093dd1d9da90898e63dd61736462e9cdda6a90ad3c3" "checksum mime 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)" = "3e27ca21f40a310bd06d9031785f4801710d566c184a6e15bad4f1d9b65f9425" "checksum miniz-sys 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "1e9e3ae51cea1576ceba0dde3d484d30e6e5b86dee0b2d412fe3a16a15c98202" -"checksum miniz_oxide 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b6c3756d66cf286314d5f7ebe74886188a9a92f5eee68b06f31ac2b4f314c99d" -"checksum miniz_oxide_c_api 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5b78ca5446dd9fe0dab00e058731b6b08a8c1d2b9cdb8efb10876e24e9ae2494" +"checksum miniz_oxide 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c061edee74a88eb35d876ce88b94d77a0448a201de111c244b70d047f5820516" +"checksum miniz_oxide_c_api 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6c675792957b0d19933816c4e1d56663c341dd9bfa31cb2140ff2267c1d8ecf4" "checksum mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)" = "83f51996a3ed004ef184e16818edc51fadffe8e7ca68be67f9dee67d84d0ff23" "checksum mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)" = "966257a94e196b11bb43aca423754d87429960a768de9414f3691d6957abf125" "checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" @@ -2759,7 +2754,7 @@ dependencies = [ "checksum parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f842b1982eb6c2fe34036a4fbfb06dd185a3f5c8edfaacdf7d1ea10b07de6252" "checksum parking_lot_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "94c8c7923936b28d546dfd14d4472eaf34c99b14e1c973a32b3e6d4eb04298c9" "checksum parking_lot_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cb88cb1cb3790baa6776844f968fea3be44956cf184fa1be5a03341f5491278c" -"checksum parking_lot_core 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1a7bbaa05312363e0480e1efee133fff1a09ef4a6406b65e226b9a793c223a32" +"checksum parking_lot_core 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b876b1b9e7ac6e1a74a6da34d25c42e17e8862aa409cbbbdcfc8d86c6f3bc62b" "checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" "checksum ppv-lite86 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e3cbf9f658cdb5000fcf6f362b8ea2ba154b9f146a61c7a20d647034c6b6561b" "checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" @@ -2770,7 +2765,7 @@ dependencies = [ "checksum rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" "checksum rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d47eab0e83d9693d40f825f86948aa16eff6750ead4bdffc4ab95b8b3a7f052c" "checksum rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" -"checksum rand_chacha 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e193067942ef6f485a349a113329140d0ab9e2168ce92274499bb0e9a4190d9d" +"checksum rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "03a2a90da8c7523f554344f921aa97283eadf6ac484a6d2a7d0212fa7f8d6853" "checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" "checksum rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0e7a549d590831370895ab7ba4ea0c1b6b011d106b5ff2da6eee112615e6dc0" "checksum rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "615e683324e75af5d43d8f7a39ffe3ee4a9dc42c5c701167a71dc59c3a493aca" @@ -2782,13 +2777,13 @@ dependencies = [ "checksum rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" "checksum rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" "checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" -"checksum redis 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b543b95de413ac964ca609e91fd9fd58419312e69988fb197f3ff8770312a1af" +"checksum redis 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1b03b599645e2db97724125cdff11196b56a70b21837a6e68f0e55955989e0cc" "checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" "checksum redox_users 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3fe5204c3a17e97dde73f285d49be585df59ed84b50a872baf416e73b62c3828" "checksum regex 0.1.80 (registry+https://github.com/rust-lang/crates.io-index)" = "4fd4ace6a8cf7860714a2c2280d6c1f7e6a413486c13298bbc86fd3da019402f" -"checksum regex 1.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "d9d8297cc20bbb6184f8b45ff61c8ee6a9ac56c156cec8e38c3e5084773c44ad" +"checksum regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6b23da8dfd98a84bd7e08700190a5d9f7d2d38abd4369dd1dae651bc40bfd2cc" "checksum regex-syntax 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "f9ec002c35e86791825ed294b50008eea9ddfc8def4420124fbc6b08db834957" -"checksum regex-syntax 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)" = "9b01330cce219c1c6b2e209e5ed64ccd587ae5c67bed91c0b49eecf02ae40e21" +"checksum regex-syntax 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "cd5485bf1523a9ed51c4964273f22f63f24e31632adb5dad134f488f86a3875c" "checksum resolv-conf 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b263b4aa1b5de9ffc0054a2386f96992058bb6870aab516f8cdeb8a667d56dcb" "checksum rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)" = "f76d05d3993fd5f4af9434e8e436db163a12a9d40e1a58a726f27a01dfd12a2a" "checksum rust-ini 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3e52c148ef37f8c375d49d5a73aa70713125b7f19095948a923f80afdeb22ec2" @@ -2805,10 +2800,10 @@ dependencies = [ "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" "checksum serde 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)" = "9dad3f759919b92c3068c696c15c3d17238234498bbdcc80f2c469606f948ac8" -"checksum serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)" = "d46b3dfedb19360a74316866cef04687cd4d6a70df8e6a506c63512790769b72" +"checksum serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)" = "7fe5626ac617da2f2d9c48af5515a21d5a480dbd151e01bb1c355e26a3e68113" "checksum serde-hjson 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0b833c5ad67d52ced5f5938b2980f32a9c1c5ef047f0b4fb3127e7a423c76153" "checksum serde-humantime 0.1.1 (git+https://github.com/tailhook/serde-humantime?branch=serde_wrapper)" = "" -"checksum serde_derive 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)" = "c22a0820adfe2f257b098714323563dd06426502abbbce4f51b72ef544c5027f" +"checksum serde_derive 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)" = "01e69e1b8a631f245467ee275b8c757b818653c6d704cdbcaeb56b56767b529c" "checksum serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)" = "051c49229f282f7c6f3813f8286cc1e3323e8051823fce42c7ea80fe13521704" "checksum serde_test 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)" = "110b3dbdf8607ec493c22d5d947753282f3bae73c0f56d322af1e8c78e4c23d5" "checksum serde_urlencoded 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "642dd69105886af2efd227f75a520ec9b44a820d65bc133a9131f7d229fd165a" @@ -2817,23 +2812,22 @@ dependencies = [ "checksum serial_test_derive 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "89dd85be2e2ad75b041c9df2892ac078fa6e0b90024028b2b9fb4125b7530f01" "checksum sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d" "checksum signal-hook 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4f61c4d59f3aaa9f61bba6450a9b80ba48362fd7d651689e7a10c453b1f6dc68" -"checksum signal-hook-registry 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cded4ffa32146722ec54ab1f16320568465aa922aa9ab4708129599740da85d7" +"checksum signal-hook-registry 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "913661ac8848a61e39684a3c3e7a7a14a4deec7f54b4976d0641e70dda3939b1" "checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" -"checksum slog 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "36d9e85f8df625a6ac087188d0826546df56e07190bede661c10c95a95890cad" +"checksum slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1cc9c640a4adbfbcc11ffb95efe5aa7af7309e002adab54b185507dbf2377b99" "checksum slog-async 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e544d16c6b230d84c866662fe55e31aacfca6ae71e6fc49ae9a311cb379bfc2f" "checksum slog-envlogger 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f7c6685180086bf58624e92cb3da5d5f013bebd609454926fc8e2ac6345d384b" "checksum slog-json 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ddc0d2aff1f8f325ef660d9a0eb6e6dcd20b30b3f581a5897f58bf42d061c37a" "checksum slog-scope 4.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d1d3ec6214d46e57a7ec87c1972bbca66c59172a0cfffa5233c54726afb946bf" -"checksum slog-stdlog 3.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ac42f8254ae996cc7d640f9410d3b048dcdf8887a10df4d5d4c44966de24c4a8" +"checksum slog-stdlog 3.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f1c469573d1e3f36f9eee66cd132206caf47b50c94b1f6c6e7b4d8235e9ecf01" "checksum slog-term 2.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cb9b3fd9a3c2c86580fce3558a98ed7c69039da0288b08a3f15b371635254e08" "checksum smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "ab606a9c5e214920bb66c458cd7be8ef094f813f20fe77a54cc7dbfff220d4b7" "checksum smart-default 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5a9dbd5f03d04e80355cbbe3ce5cf1f65c421eac575402e3d4d6e95d5a44edaa" -"checksum socket2 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "4e626972d3593207547f14bf5fc9efa4d0e7283deb73fef1dff313dae9ab8878" +"checksum socket2 0.3.10 (registry+https://github.com/rust-lang/crates.io-index)" = "df028e0e632c2a1823d920ad74895e7f9128e6438cbc4bc6fd1f180e644767b9" "checksum sourcefile 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4bf77cb82ba8453b42b6ae1d692e4cdc92f9a47beaf89a847c8be83f4e328ad3" -"checksum spin 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44363f6f51401c34e7be73db0db371c04705d35efbe9f7d6082e03a921a32c55" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" "checksum string 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d24114bfcceb867ca7f71a0d3fe45d45619ec47a6fbfa98cb14e14250bfa5d6d" -"checksum syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)" = "b4d960b829a55e56db167e861ddb43602c003c7be0bee1d345021703fac2fb7c" +"checksum syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)" = "eadc09306ca51a40555dd6fc2b415538e9e18bc9f870e47b1a524a79fe2dcf5e" "checksum synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f" "checksum take_mut 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f764005d11ee5f36500a149ace24e00e3da98b0158b3e2d53a7495660d3f4d60" "checksum term 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "edd106a334b7657c10b7c540a0106114feadeb4dc314513e97df481d5d966f42" @@ -2858,9 +2852,10 @@ dependencies = [ "checksum tokio-udp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "66268575b80f4a4a710ef83d087fdfeeabdce9b74c797535fbac18a2cb906e92" "checksum tokio-uds 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "037ffc3ba0e12a0ab4aca92e5234e0dedeb48fddf6ccd260f1f150a36a9f2445" "checksum toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "758664fc71a3a69038656bee8b6be6477d2a6c315a6b81f7081f591bffa4111f" +"checksum toml 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b8c96d7873fa7ef8bdeb3a9cda3ac48389b4154f32b9803b4bc26220b677b039" "checksum trust-dns-proto 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5559ebdf6c2368ddd11e20b11d6bbaf9e46deb803acd7815e93f5a7b4a6d2901" "checksum trust-dns-resolver 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6c9992e58dba365798803c0b91018ff6c8d3fc77e06977c4539af2a6bfe0a039" -"checksum ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "535c204ee4d8434478593480b8f86ab45ec9aae0e83c568ca81abf0fd0e88f86" +"checksum ucd-util 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fa9b3b49edd3468c0e6565d85783f51af95212b6fa3986a5500954f00b460874" "checksum unicase 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a84e5511b2a947f3ae965dcb29b13b7b1691b6e7332cf5dbc1744138d5acb7f6" "checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" "checksum unicode-normalization 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "141339a08b982d942be2ca06ff8b076563cbe223d1befd5450716790d44e2426" @@ -2892,7 +2887,7 @@ dependencies = [ "checksum winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7168bab6e1daee33b4557efd0e95d5ca70a03706d39fa5f3fe7a236f584b03c9" "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" "checksum wincolor 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "561ed901ae465d6185fa7864d63fbd5720d0ef718366c9a4dc83cf6170d7e9ba" -"checksum winreg 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73f1f3c6c4d3cab118551b96c476a2caab920701e28875b64a458f2ecb96ec9d" +"checksum winreg 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b2986deb581c4fe11b621998a5e53361efe6b48a151178d0cd9eeffa4dc6acc9" "checksum winutil 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7daf138b6b14196e3830a588acf1e86966c694d3e8fb026fb105b8b5dca07e6e" "checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" "checksum yaml-rust 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "65923dd1784f44da1d2c3dbbc5e822045628c590ba72123e1c73d3c230c4434d" diff --git a/Cargo.toml b/Cargo.toml index 03e4412b4..6c82792e0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,17 +28,17 @@ bb8 = "0.3" bb8-redis = "0.3" chrono = "0.4" config = "0.9" -dotenv = "0.13" +dotenv = "0.14" failure = "0.1" futures = "0.1" -hashbrown = "0.1" +hashbrown = "0.5" humantime = "1.2" macro-attr = "0.2" medea-client-api-proto = { path = "proto/client-api", features = ["medea"] } medea-macro = { path = "crates/medea-macro" } newtype_derive = "0.1" rand = "0.7" -redis = "0.10" +redis = "0.11" rust-crypto = "0.2" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" @@ -52,7 +52,7 @@ slog-stdlog = "3.0" smart-default = "0.5" tokio = "0.1" tokio-signal = "0.2" -toml = "0.4" +toml = "0.5" [dependencies.serde-humantime] git = "https://github.com/tailhook/serde-humantime" branch = "serde_wrapper" From 62f7b6a9cc691bd31122e9cdcf94ddc209c5438b Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 1 Aug 2019 14:00:03 +0300 Subject: [PATCH 411/735] Bump deps --- Cargo.lock | 25 +++++++++++++++++++------ proto/grpc/Cargo.toml | 2 +- proto/grpc/build.rs | 1 + 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a75d2f217..1a2fe1d39 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -637,6 +637,16 @@ dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "derive-new" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "derive_more" version = "0.14.1" @@ -866,11 +876,13 @@ dependencies = [ [[package]] name = "grpcio-compiler" -version = "0.4.3" +version = "0.5.0-alpha.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ + "derive-new 0.5.7 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf-codegen 2.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1185,7 +1197,7 @@ dependencies = [ "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "grpcio 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "protoc-grpcio 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "protoc-grpcio 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1487,11 +1499,11 @@ dependencies = [ [[package]] name = "protoc-grpcio" -version = "0.3.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "grpcio-compiler 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "grpcio-compiler 0.5.0-alpha.2 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf-codegen 2.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "protoc 2.8.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2788,6 +2800,7 @@ dependencies = [ "checksum crossbeam-epoch 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "fedcd6772e37f3da2a9af9bf12ebe046c0dfe657992377b4df982a2b54cd37a9" "checksum crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7c979cd6cfe72335896575c6b5688da489e420d36a27a0b9eb0c73db574b4a4b" "checksum crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "04973fa96e96579258a5091af6003abde64af786b860f18622b82e026cca60e6" +"checksum derive-new 0.5.7 (registry+https://github.com/rust-lang/crates.io-index)" = "c3fd04571b29c91cfbe1e7c9a228e069ac8635f180ffb4ccd6a6907617ee8bb0" "checksum derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6d944ac6003ed268757ef1ee686753b57efc5fcf0ebe7b64c9fc81e7e32ff839" "checksum derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a141330240c921ec6d074a3e188a7c7ef95668bb95e7d44fa0e5778ec2a7afe" "checksum dirs 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3fd78930633bd1c6e35c4b42b1df7b0cbc6bc191146e512bb3bedf243fcc3901" @@ -2815,7 +2828,7 @@ dependencies = [ "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" "checksum getrandom 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "cd8e190892c840661957ba9f32dacfb3eb405e657f9f9f60485605f0bb37d6f8" "checksum grpcio 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c02fb3c9c44615973814c838f75d7898695d4d4b97a3e8cf52e9ccca30664b6f" -"checksum grpcio-compiler 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "373a14f0f994d4c235770f4bb5558be00626844db130a82a70142b8fc5996fc3" +"checksum grpcio-compiler 0.5.0-alpha.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dd8b3213a332a2865a307e553f43d632bc4a81f0e0f5a90d194dee5b9c02d8a7" "checksum grpcio-sys 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "9d8d3b6d1a70b9dcb2545d1aff5b2c74652cb635f6ab6426be8fd201e9566b7e" "checksum h2 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)" = "a5b34c246847f938a410a03c5458c7fee2274436675e76d8b903c08efc29c462" "checksum hashbrown 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "29fba9abe4742d586dfd0c06ae4f7e73a1c2d86b856933509b269d82cdf06e18" @@ -2879,7 +2892,7 @@ dependencies = [ "checksum protobuf 2.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8aefcec9f142b524d98fc81d07827743be89dd6586a1ba6ab21fa66a500b3fa5" "checksum protobuf-codegen 2.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "31539be8028d6b9e8e1b3b7c74e2fa3555302e27b2cc20dbaee6ffba648f75e2" "checksum protoc 2.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d60e39b07eb4039379829c55c11eba3fd8bd72b265b9ece8cc623b106908c08d" -"checksum protoc-grpcio 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a9798b534614b71d780778b1508410826073b5a1ca111a090f1f3fd3ac663ef6" +"checksum protoc-grpcio 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "da4389258ed4b768438edec1e1e813cc7fa29e70c1b1cb4eb2f8fc341dc562dd" "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" "checksum quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" "checksum rand 0.3.23 (registry+https://github.com/rust-lang/crates.io-index)" = "64ac302d8f83c0c1974bf758f6b041c6c8ada916fbb44a609158ca8b064cc76c" diff --git a/proto/grpc/Cargo.toml b/proto/grpc/Cargo.toml index 07f416252..d981a5cf3 100644 --- a/proto/grpc/Cargo.toml +++ b/proto/grpc/Cargo.toml @@ -15,4 +15,4 @@ futures = "0.1" protobuf = "2.7" [build-dependencies] -protoc-grpcio = "0.3" +protoc-grpcio = "1.0" diff --git a/proto/grpc/build.rs b/proto/grpc/build.rs index 08ec39ecb..13799655d 100644 --- a/proto/grpc/build.rs +++ b/proto/grpc/build.rs @@ -6,6 +6,7 @@ fn main() { &["control.proto"], &[proto_root], &proto_output, + None, ) .expect("Failed to compile gRPC definitions!"); } From 54f86cf8ef254fdf5daa0dc5c748b24cc696c61f Mon Sep 17 00:00:00 2001 From: alexlapa Date: Thu, 1 Aug 2019 19:30:54 +0300 Subject: [PATCH 412/735] refactor --- src/media/peer.rs | 10 ---------- src/signalling/peers.rs | 13 +++++-------- 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/src/media/peer.rs b/src/media/peer.rs index acb453938..2c6813377 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -217,16 +217,6 @@ impl Peer { }) } - /// Returns all senders [`MediaTrack`]. - pub fn get_senders(&self) -> Vec> { - self.context - .senders - .iter() - .map(|(_key, value)| value) - .cloned() - .collect() - } - /// Checks if this [`Peer`] has any send tracks. pub fn is_sender(&self) -> bool { !self.context.senders.is_empty() diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index d3b60a2a4..5683e2722 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -142,20 +142,19 @@ impl PeerRepository { } /// Returns all [`Peer`]s of specified [`Member`]. - pub fn get_peers_by_member_id( - &self, - member_id: &MemberId, - ) -> Vec<&PeerStateMachine> { + pub fn get_peers_by_member_id<'a>( + &'a self, + member_id: &'a MemberId, + ) -> impl Iterator { self.peers .iter() - .filter_map(|(_, peer)| { + .filter_map(move |(_, peer)| { if &peer.member_id() == member_id { Some(peer) } else { None } }) - .collect() } /// Returns owned [`Peer`] by its ID. @@ -186,10 +185,8 @@ impl PeerRepository { HashMap::new(); self.get_peers_by_member_id(member_id) - .into_iter() .for_each(|peer| { self.get_peers_by_member_id(&peer.partner_member_id()) - .into_iter() .filter(|partner_peer| { &partner_peer.partner_member_id() == member_id }) From c3a3a23c529ab86935ff110260c21dd7be112d38 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 1 Aug 2019 19:44:27 +0300 Subject: [PATCH 413/735] Rewrite gRPC control API errors --- Cargo.lock | 1 + Cargo.toml | 1 + src/api/control/grpc/server.rs | 43 ++-- src/api/error_codes.rs | 388 +++++++++++++++------------------ 4 files changed, 192 insertions(+), 241 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1a2fe1d39..6ab4af88a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1148,6 +1148,7 @@ dependencies = [ "bb8-redis 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "config 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", "dotenv 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index ef8773240..4dc7e3e26 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,6 +29,7 @@ bb8 = "0.3" bb8-redis = "0.3" chrono = "0.4" config = "0.9" +derive_more = "0.15" dotenv = "0.14" failure = "0.1" futures = "0.1" diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index cb9c42f57..15cc80958 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -29,7 +29,7 @@ use crate::{ Endpoint, MemberSpec, RoomSpec, TryFromElementError, TryFromProtobufError, }, - error_codes::ErrorCode, + error_codes::{ErrorCode, ErrorResponse}, }, log::prelude::*, signalling::{ @@ -46,7 +46,7 @@ use crate::{ use crate::shutdown::ShutdownGracefully; #[derive(Debug, Fail)] -enum ControlApiError { +pub enum ControlApiError { /// Error when parsing ID of element. #[fail(display = "{:?}", _0)] LocalUri(LocalUriParseError), @@ -90,16 +90,6 @@ impl From for ControlApiError { } } -impl Into for ControlApiError { - fn into(self) -> ErrorCode { - match self { - ControlApiError::LocalUri(e) => e.into(), - ControlApiError::TryFromProtobuf(e) => e.into(), - _ => ErrorCode::UnknownError(self.to_string()), - } - } -} - /// Try to unwrap some [`Result`] and if it `Err` then return err future with /// [`ControlApiError`]. /// @@ -125,7 +115,7 @@ macro_rules! parse_local_uri { match LocalUriType::parse($uri) { Ok(o) => o, Err(e) => { - let error: ErrorCode = e.into(); + let error: ErrorResponse = e.into(); send_error_response!($ctx, $sink, error, $response); } } @@ -266,7 +256,7 @@ impl ControlApiService { fn get_response_for_create( result: Result, ) -> Response { - let error: ErrorCode = match result { + let error: ErrorResponse = match result { Ok(r) => match r { Ok(r) => match r { Ok(sid) => { @@ -309,8 +299,9 @@ impl ControlApi for ControlApiService { send_error_response!( ctx, sink, - ErrorCode::ElementIdForRoomButElementIsNot( - req.get_id().to_string(), + ErrorResponse::new( + ErrorCode::ElementIdForRoomButElementIsNot, + &req.get_id(), ), Response ); @@ -335,8 +326,9 @@ impl ControlApi for ControlApiService { send_error_response!( ctx, sink, - ErrorCode::ElementIdForMemberButElementIsNot( - req.get_id().to_string(), + ErrorResponse::new( + ErrorCode::ElementIdForMemberButElementIsNot, + &req.get_id(), ), Response ); @@ -361,8 +353,9 @@ impl ControlApi for ControlApiService { send_error_response!( ctx, sink, - ErrorCode::ElementIdForEndpointButElementIsNot( - req.get_id().to_string(), + ErrorResponse::new( + ErrorCode::ElementIdForEndpointButElementIsNot, + &req.get_id(), ), Response ); @@ -446,7 +439,7 @@ impl ControlApi for ControlApiService { for result in results { if let Err(e) = result { let mut response = Response::new(); - let error: ErrorCode = e.into(); + let error: ErrorResponse = e.into(); response.set_error(error.into()); return sink .success(response) @@ -465,7 +458,7 @@ impl ControlApi for ControlApiService { ); let mut response = Response::new(); let error: Error = - ErrorCode::UnknownError(format!("{:?}", e)) + ErrorResponse::unknown(&format!("{:?}", e)) .into(); response.set_error(error); sink.success(response).map_err(map_err_closure) @@ -530,7 +523,7 @@ impl ControlApi for ControlApiService { } Err(e) => { let mut response = GetResponse::new(); - let error: ErrorCode = e.into(); + let error: ErrorResponse = e.into(); response.set_error(error.into()); return sink .success(response) @@ -550,7 +543,7 @@ impl ControlApi for ControlApiService { } Err(e) => { let mut response = GetResponse::new(); - let error: ErrorCode = e.into(); + let error: ErrorResponse = e.into(); response.set_error(error.into()); return sink .success(response) @@ -568,7 +561,7 @@ impl ControlApi for ControlApiService { warn!("Control API Get method mailbox error. {:?}", e); let mut response = GetResponse::new(); let error: Error = - ErrorCode::UnknownError(format!("{:?}", e)).into(); + ErrorResponse::unknown(&format!("{:?}", e)).into(); response.set_error(error); sink.success(response).map_err(grpc_err_closure) } diff --git a/src/api/error_codes.rs b/src/api/error_codes.rs index c1de74ba0..101bfe959 100644 --- a/src/api/error_codes.rs +++ b/src/api/error_codes.rs @@ -7,16 +7,19 @@ //! * __1200...1299__ Parse errors //! * __1300...1399__ Conflicts +use std::string::ToString; + +use derive_more::Display; use medea_grpc_proto::control::Error as ErrorProto; use crate::{ - api::control::{ - endpoints::webrtc_play_endpoint::SrcParseError, - local_uri::{ - IsEndpointId, IsMemberId, IsRoomId, LocalUri, LocalUriParseError, - LocalUriType, + api::{ + control::{ + endpoints::webrtc_play_endpoint::SrcParseError, + grpc::server::ControlApiError, local_uri::LocalUriParseError, + TryFromElementError, TryFromProtobufError, }, - TryFromElementError, TryFromProtobufError, + error_codes::ErrorCode::ElementIdIsNotLocal, }, signalling::{ elements::{member::MemberError, MembersLoadError}, @@ -26,13 +29,81 @@ use crate::{ }, }; +/// Medea's control API error response. +pub struct ErrorResponse { + /// [`ErrorCode`] which will be returned with code and message. + error_code: ErrorCode, + + /// Element ID where some error happened. May be empty. + element_id: String, + + /// If some unexpected error will be throwed then this field will + /// store this error converted to [`String`]. + /// + /// Normally this field should be [`None`]. + unknown_error: Option, +} + +impl ErrorResponse { + /// New normal [`ErrorResponse`] with [`ErrorCode`] and element ID. + pub fn new(error_code: ErrorCode, element_id: &T) -> Self { + Self { + error_code, + element_id: element_id.to_string(), + unknown_error: None, + } + } + + /// New [`ErrorResponse`] only with [`ErrorCode`]. + pub fn new_empty(error_code: ErrorCode) -> Self { + Self { + error_code, + element_id: String::new(), + unknown_error: None, + } + } + + /// [`ErrorResponse`] for all unexpected errors. + /// + /// Provide unexpected `Error` in this function. + pub fn unknown(unknown_error: &B) -> Self { + Self { + error_code: ErrorCode::UnknownError, + unknown_error: Some(unknown_error.to_string()), + element_id: String::new(), + } + } +} + +impl Into for ErrorResponse { + fn into(self) -> ErrorProto { + let mut error = ErrorProto::new(); + + if let Some(unknown_error) = &self.unknown_error { + error.set_text(format!( + "{} Here is error: '{}'", + self.error_code.to_string(), + unknown_error + )); + } else { + error.set_text(self.error_code.to_string()); + } + + error.set_element(self.element_id.to_string()); + error.set_code(self.error_code as u32); + + error + } +} + /// Medea control API errors. -// TODO: write macro for generating error codes. +#[derive(Display)] pub enum ErrorCode { /// Unknown server error. /// /// Code: __1000__. - UnknownError(String), + #[display(fmt = "Unexpected error happened.")] + UnknownError = 1000, //////////////////////////////////// // Not found (1001 - 1099 codes) // @@ -40,23 +111,28 @@ pub enum ErrorCode { /// Publish endpoint not found. /// /// Code: __1001__. - PublishEndpointNotFound(LocalUri), + #[display(fmt = "Publish endpoint not found.")] + PublishEndpointNotFound = 1001, /// Play endpoint not found. /// /// Code: __1002__. - PlayEndpointNotFound(LocalUri), + #[display(fmt = "Play endpoint not found.")] + PlayEndpointNotFound = 1002, /// Member not found. /// /// Code: __1003__. - MemberNotFound(LocalUri), + #[display(fmt = "Member not found.")] + MemberNotFound = 1003, /// Room not found. /// /// Code: __1004__. - RoomNotFound(LocalUri), + #[display(fmt = "Room not found.")] + RoomNotFound = 1004, /// Endpoint not found. /// /// Code: __1005__. - EndpointNotFound(LocalUri), + #[display(fmt = "Endpoint not found.")] + EndpointNotFound = 1005, ////////////////////////////////////// // Spec errors (1100 - 1199 codes) // @@ -64,37 +140,50 @@ pub enum ErrorCode { /// Medea expects `Room` element in pipeline but received not him. /// /// Code: __1100__. - NotRoomInSpec(LocalUriType), + #[display(fmt = "Expecting Room element but it's not.")] + NotRoomInSpec = 1100, /// Medea expects `Member` element in pipeline but received not him. /// /// Code: __1101__. - NotMemberInSpec(LocalUriType), + #[display(fmt = "Expecting Member element but it's not.")] + NotMemberInSpec = 1101, /// Invalid source URI in play endpoint. /// /// Code: __1102__. - InvalidSrcUri(LocalUri), + #[display(fmt = "Invalid source ID in publish endpoint spec.")] + InvalidSrcUri = 1102, /// Provided element ID to Room element but element spec is not for Room. /// /// Code: __1103__. - ElementIdForRoomButElementIsNot(String), + #[display( + fmt = "You provided ID for Room but element's spec is not for Room." + )] + ElementIdForRoomButElementIsNot = 1103, /// Provided element ID to Member element but element spec is not for /// Member. /// /// Code: __1104__. - ElementIdForMemberButElementIsNot(String), + #[display( + fmt = "You provided ID for Member but element's spec is not for Room." + )] + ElementIdForMemberButElementIsNot = 1104, /// Provided element ID to Endpoint element but element spec is not for /// Endpoint. /// /// Code: __1105__. - ElementIdForEndpointButElementIsNot(String), + #[display(fmt = "You provided ID for Endpoint but element's spec is not \ + for Room.")] + ElementIdForEndpointButElementIsNot = 1105, /// Invalid ID for element. /// /// Code: __1106__ - InvalidElementUri(String), + #[display(fmt = "Invalid element's URI.")] + InvalidElementUri = 1106, /// Provided not source URI in [`WebRtcPlayEndpoint`]. /// /// Code: __1107__. - NotSourceUri(String), + #[display(fmt = "Provided not source URI.")] + NotSourceUri = 1107, ///////////////////////////////// // Parse errors (1200 - 1299) // @@ -102,19 +191,23 @@ pub enum ErrorCode { /// Element's ID don't have "local://" prefix. /// /// Code: __1200__. - ElementIdIsNotLocal(String), + #[display(fmt = "Element's ID's URI not have 'local://' protocol.")] + ElementIdIsNotLocal = 1200, /// Element's ID have too many paths (slashes). /// /// Code: __1201__. - ElementIdIsTooLong(String), + #[display(fmt = "In provided element's ID too many slashes.")] + ElementIdIsTooLong = 1201, /// Missing some fields in element's ID. /// /// Code: __1202__. - MissingFieldsInSrcUri(String), + #[display(fmt = "Missing some fields in element ID.")] + MissingFieldsInSrcUri = 1202, /// Empty element ID. /// /// Code: __1203__. - EmptyElementId, + #[display(fmt = "Provided empty element ID.")] + EmptyElementId = 1203, ///////////////////////////// // Conflict (1300 - 1399) // @@ -122,285 +215,148 @@ pub enum ErrorCode { /// Member already exists. /// /// Code: __1300__. - MemberAlreadyExists(LocalUri), + #[display(fmt = "Member already exists.")] + MemberAlreadyExists = 1300, /// Endpoint already exists. /// /// Code: __1301__. - EndpointAlreadyExists(LocalUri), + #[display(fmt = "Endpoint already exists.")] + EndpointAlreadyExists = 1301, /// Room already exists. /// /// Code: __1302__. - RoomAlreadyExists(LocalUri), + #[display(fmt = "Room already exists.")] + RoomAlreadyExists = 1302, } -impl Into for ErrorCode { - fn into(self) -> ErrorProto { - let mut error = ErrorProto::new(); - match self { - ErrorCode::UnknownError(msg) => { - error.set_text(format!( - "Unexpected error happened. Here is it '{}'.", - msg - )); - error.set_element(String::new()); - error.set_code(1000); - } - - //////////////////////////////////// - // Not found (1001 - 1099 codes) // - ////////////////////////////////// - ErrorCode::PublishEndpointNotFound(id) => { - error.set_text("Publish endpoint not found".to_string()); - error.set_element(id.to_string()); - error.set_code(1001); - } - ErrorCode::PlayEndpointNotFound(id) => { - error.set_text("Play endpoint not found.".to_string()); - error.set_element(id.to_string()); - error.set_code(1002); - } - ErrorCode::MemberNotFound(id) => { - error.set_text("Member not found.".to_string()); - error.set_element(id.to_string()); - error.set_code(1003); - } - ErrorCode::RoomNotFound(id) => { - error.set_text("Room not found.".to_string()); - error.set_element(id.to_string()); - error.set_code(1004); - } - ErrorCode::EndpointNotFound(id) => { - error.set_text("Endpoint not found.".to_string()); - error.set_element(id.to_string()); - error.set_code(1005); - } - - ////////////////////////////////////// - // Spec errors (1100 - 1199 codes) // - //////////////////////////////////// - ErrorCode::NotRoomInSpec(id) => { - error.set_text( - "Expecting Room element but it's not.".to_string(), - ); - error.set_element(id.to_string()); - error.set_code(1100); - } - ErrorCode::NotMemberInSpec(id) => { - error.set_text( - "Expecting Member element but it's not.".to_string(), - ); - error.set_element(id.to_string()); - error.set_code(1101); - } - ErrorCode::InvalidSrcUri(id) => { - error.set_text( - "Invalid source ID in publish endpoint spec.".to_string(), - ); - error.set_element(id.to_string()); - error.set_code(1102); - } - ErrorCode::ElementIdForRoomButElementIsNot(id) => { - error.set_text( - "You provided ID for Room but element's spec is not for \ - Room." - .to_string(), - ); - error.set_element(id); - error.set_code(1103); - } - ErrorCode::ElementIdForMemberButElementIsNot(id) => { - error.set_text( - "You provided ID for Member but element's spec is not for \ - Member." - .to_string(), - ); - error.set_element(id); - error.set_code(1104); - } - ErrorCode::ElementIdForEndpointButElementIsNot(id) => { - error.set_text( - "You provided ID for Endpoint but element's spec is not \ - for Endpoint." - .to_string(), - ); - error.set_element(id); - error.set_code(1105); - } - ErrorCode::InvalidElementUri(id) => { - error.set_text("Invalid element's URI".to_string()); - error.set_element(id); - error.set_code(1106); - } - ErrorCode::NotSourceUri(id) => { - error.set_text("Provided not source URI".to_string()); - error.set_element(id); - error.set_code(1107); - } - - ///////////////////////////////// - // Parse errors (1200 - 1299) // - /////////////////////////////// - ErrorCode::ElementIdIsNotLocal(uri) => { - error.set_text( - "Element's ID's URI has not have 'local://' protocol." - .to_string(), - ); - error.set_element(uri); - error.set_code(1200); - } - ErrorCode::ElementIdIsTooLong(uri) => { - error.set_text( - "In provided element's ID too many slashes.".to_string(), - ); - error.set_element(uri); - error.set_code(1201); - } - ErrorCode::MissingFieldsInSrcUri(uri) => { - error - .set_text("Missing some fields in element ID.".to_string()); - error.set_element(uri); - error.set_code(1202); - } - ErrorCode::EmptyElementId => { - error.set_text("Provided empty element ID.".to_string()); - error.set_element(String::new()); - error.set_code(1203); - } - - ///////////////////////////// - // Conflict (1300 - 1399) // - /////////////////////////// - ErrorCode::MemberAlreadyExists(id) => { - error.set_text("Member already exists.".to_string()); - error.set_element(id.to_string()); - error.set_code(1300); - } - ErrorCode::EndpointAlreadyExists(id) => { - error.set_text("Endpoint already exists.".to_string()); - error.set_element(id.to_string()); - error.set_code(1301); - } - ErrorCode::RoomAlreadyExists(id) => { - error.set_text("Room already exists.".to_string()); - error.set_element(id.to_string()); - error.set_code(1302); - } - } - - error - } -} - -impl From for ErrorCode { +impl From for ErrorResponse { fn from(err: ParticipantServiceErr) -> Self { match err { ParticipantServiceErr::EndpointNotFound(id) => { - ErrorCode::EndpointNotFound(id) + Self::new(ErrorCode::EndpointNotFound, &id) } ParticipantServiceErr::ParticipantNotFound(id) => { - ErrorCode::MemberNotFound(id) + Self::new(ErrorCode::MemberNotFound, &id) } ParticipantServiceErr::ParticipantAlreadyExists(id) => { - ErrorCode::MemberAlreadyExists(id) + Self::new(ErrorCode::MemberAlreadyExists, &id) } ParticipantServiceErr::EndpointAlreadyExists(id) => { - ErrorCode::EndpointAlreadyExists(id) + Self::new(ErrorCode::EndpointAlreadyExists, &id) } - _ => ErrorCode::UnknownError(err.to_string()), + _ => Self::unknown(&err), } } } -impl From for ErrorCode { +impl From for ErrorResponse { fn from(err: TryFromProtobufError) -> Self { match err { TryFromProtobufError::SrcUriError(e) => e.into(), - _ => ErrorCode::UnknownError(err.to_string()), + _ => Self::unknown(&err), } } } -impl From for ErrorCode { +impl From for ErrorResponse { fn from(err: LocalUriParseError) -> Self { match err { LocalUriParseError::NotLocal(text) => { - ErrorCode::ElementIdIsNotLocal(text) + Self::new(ElementIdIsNotLocal, &text) } LocalUriParseError::TooManyFields(_, text) => { - ErrorCode::ElementIdIsTooLong(text) + Self::new(ErrorCode::ElementIdIsTooLong, &text) + } + LocalUriParseError::Empty => { + Self::new_empty(ErrorCode::EmptyElementId) } - LocalUriParseError::Empty => ErrorCode::EmptyElementId, LocalUriParseError::MissingFields(text) => { - ErrorCode::MissingFieldsInSrcUri(text) + Self::new(ErrorCode::MissingFieldsInSrcUri, &text) } } } } -impl From for ErrorCode { +impl From for ErrorResponse { fn from(err: RoomError) -> Self { match err { RoomError::MemberError(e) => e.into(), RoomError::MembersLoadError(e) => e.into(), RoomError::ParticipantServiceErr(e) => e.into(), - _ => ErrorCode::UnknownError(err.to_string()), + _ => Self::unknown(&err), } } } -impl From for ErrorCode { +impl From for ErrorResponse { fn from(err: MembersLoadError) -> Self { match err { MembersLoadError::TryFromError(e, id) => match e { TryFromElementError::NotMember => { - ErrorCode::NotMemberInSpec(id) + Self::new(ErrorCode::NotMemberInSpec, &id) + } + TryFromElementError::NotRoom => { + Self::new(ErrorCode::NotRoomInSpec, &id) } - TryFromElementError::NotRoom => ErrorCode::NotRoomInSpec(id), }, MembersLoadError::MemberNotFound(id) => { - ErrorCode::MemberNotFound(id) + Self::new(ErrorCode::MemberNotFound, &id) } MembersLoadError::PublishEndpointNotFound(id) => { - ErrorCode::PublishEndpointNotFound(id) + Self::new(ErrorCode::PublishEndpointNotFound, &id) } MembersLoadError::PlayEndpointNotFound(id) => { - ErrorCode::PlayEndpointNotFound(id) + Self::new(ErrorCode::PlayEndpointNotFound, &id) } } } } -impl From for ErrorCode { +impl From for ErrorResponse { fn from(err: MemberError) -> Self { match err { MemberError::PlayEndpointNotFound(id) => { - ErrorCode::PlayEndpointNotFound(id) + Self::new(ErrorCode::PlayEndpointNotFound, &id) } MemberError::PublishEndpointNotFound(id) => { - ErrorCode::PublishEndpointNotFound(id) + Self::new(ErrorCode::PublishEndpointNotFound, &id) } } } } -impl From for ErrorCode { +impl From for ErrorResponse { fn from(err: SrcParseError) -> Self { match err { - SrcParseError::NotSrcUri(text) => ErrorCode::NotSourceUri(text), + SrcParseError::NotSrcUri(text) => { + Self::new(ErrorCode::NotSourceUri, &text) + } SrcParseError::LocalUriParseError(_, err) => err.into(), } } } -impl From for ErrorCode { +impl From for ErrorResponse { fn from(err: RoomServiceError) -> Self { match err { - RoomServiceError::RoomNotFound(id) => ErrorCode::RoomNotFound(id), + RoomServiceError::RoomNotFound(id) => { + Self::new(ErrorCode::RoomNotFound, &id) + } RoomServiceError::RoomAlreadyExists(id) => { - ErrorCode::RoomAlreadyExists(id) + Self::new(ErrorCode::RoomAlreadyExists, &id) } RoomServiceError::RoomError(e) => e.into(), - _ => ErrorCode::UnknownError(err.to_string()), + _ => Self::unknown(&err), + } + } +} + +impl From for ErrorResponse { + fn from(err: ControlApiError) -> Self { + match err { + ControlApiError::LocalUri(e) => e.into(), + ControlApiError::TryFromProtobuf(e) => e.into(), + _ => Self::unknown(&err), } } } From fdf101061ed4aafc016aa13b1f76eee688ab9596 Mon Sep 17 00:00:00 2001 From: alexlapa Date: Thu, 1 Aug 2019 20:24:39 +0300 Subject: [PATCH 414/735] fix impl_peer_converts --- src/media/peer.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/media/peer.rs b/src/media/peer.rs index 2c6813377..571b19cd1 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -105,7 +105,7 @@ macro_rules! impl_peer_converts { match peer { PeerStateMachine::$peer_type(peer) => Ok(peer), _ => Err(PeerError::WrongState( - 1, + peer.id(), stringify!($peer_type), format!("{}", peer), )), @@ -120,7 +120,7 @@ macro_rules! impl_peer_converts { match peer { PeerStateMachine::$peer_type(peer) => Ok(peer), _ => Err(PeerError::WrongState( - 1, + peer.id(), stringify!($peer_type), format!("{}", peer), )), From a3008957d87a25e5bb5e6aadda5dcc794f36260a Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 2 Aug 2019 14:37:49 +0300 Subject: [PATCH 415/735] PeerId newtype --- Cargo.lock | 2 ++ proto/client-api/Cargo.toml | 4 +++ proto/client-api/src/lib.rs | 30 ++++++++++++----- src/media/peer.rs | 9 +++-- src/signalling/peers.rs | 65 ++++++++++++++++++------------------- 5 files changed, 64 insertions(+), 46 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 840c50dab..79e41742a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1130,7 +1130,9 @@ dependencies = [ name = "medea-client-api-proto" version = "0.1.0-dev" dependencies = [ + "macro-attr 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "medea-macro 0.1.0-dev", + "newtype_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", ] diff --git a/proto/client-api/Cargo.toml b/proto/client-api/Cargo.toml index ab0d0e3f0..043d09e08 100644 --- a/proto/client-api/Cargo.toml +++ b/proto/client-api/Cargo.toml @@ -17,3 +17,7 @@ medea = [] medea-macro = { path = "../../crates/medea-macro" } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" + +# TODO: move it into features +newtype_derive = "0.1" +macro-attr = "0.2" diff --git a/proto/client-api/src/lib.rs b/proto/client-api/src/lib.rs index a207b1e1a..ecd2ef722 100644 --- a/proto/client-api/src/lib.rs +++ b/proto/client-api/src/lib.rs @@ -2,6 +2,18 @@ use std::collections::HashMap; use medea_macro::dispatchable; use serde::{de::Deserializer, ser::Serializer, Deserialize, Serialize}; +// TODO: cfg_attr +use macro_attr::*; +use newtype_derive::*; + +// TODO: cfg_attr +macro_attr! { + #[cfg_attr(feature = "medea", derive(Deserialize))] + #[cfg_attr(feature = "jason", derive(Serialize))] + #[cfg_attr(test, derive(Debug, PartialEq ))] + #[derive(Clone, Copy, NewtypeFrom!, NewtypeAddAssign!, NewtypeDisplay!, PartialEq, Debug, Hash, Eq)] + pub struct PeerId(pub u64); +} // TODO: should be properly shared between medea and jason #[allow(dead_code)] @@ -36,7 +48,7 @@ pub enum ClientMsg { pub enum Command { /// Web Client sends SDP Offer. MakeSdpOffer { - peer_id: u64, + peer_id: PeerId, sdp_offer: String, /// Associations between [`Track`] and transceiver's [media /// description][1]. @@ -47,10 +59,10 @@ pub enum Command { mids: HashMap, }, /// Web Client sends SDP Answer. - MakeSdpAnswer { peer_id: u64, sdp_answer: String }, + MakeSdpAnswer { peer_id: PeerId, sdp_answer: String }, /// Web Client sends Ice Candidate. SetIceCandidate { - peer_id: u64, + peer_id: PeerId, candidate: IceCandidate, }, } @@ -65,25 +77,25 @@ pub enum Event { /// Media Server notifies Web Client about necessity of RTCPeerConnection /// creation. PeerCreated { - peer_id: u64, + peer_id: PeerId, sdp_offer: Option, tracks: Vec, ice_servers: Vec, }, /// Media Server notifies Web Client about necessity to apply specified SDP /// Answer to Web Client's RTCPeerConnection. - SdpAnswerMade { peer_id: u64, sdp_answer: String }, + SdpAnswerMade { peer_id: PeerId, sdp_answer: String }, /// Media Server notifies Web Client about necessity to apply specified /// ICE Candidate. IceCandidateDiscovered { - peer_id: u64, + peer_id: PeerId, candidate: IceCandidate, }, /// Media Server notifies Web Client about necessity of RTCPeerConnection /// close. - PeersRemoved { peer_ids: Vec }, + PeersRemoved { peer_ids: Vec }, } /// Represents [RTCIceCandidateInit][1] object. @@ -127,11 +139,11 @@ pub struct IceServer { // TODO: Use different struct without mids in TracksApplied event. pub enum Direction { Send { - receivers: Vec, + receivers: Vec, mid: Option, }, Recv { - sender: u64, + sender: PeerId, mid: Option, }, } diff --git a/src/media/peer.rs b/src/media/peer.rs index 571b19cd1..8eb062ef9 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -143,7 +143,9 @@ impl_peer_converts!(WaitRemoteSdp); impl_peer_converts!(Stable); /// ID of [`Peer`]. -pub type Id = u64; +pub use medea_client_api_proto::PeerId as Id; +// TODO: remove pub use +pub use Id as PeerId; #[derive(Debug)] pub struct Context { @@ -254,12 +256,13 @@ impl Peer { partner_peer: &mut Peer, tracks_count: &mut Counter, ) { + // TODO: fix it let track_audio = Rc::new(MediaTrack::new( - tracks_count.next_id(), + tracks_count.next_id().0, MediaType::Audio(AudioSettings {}), )); let track_video = Rc::new(MediaTrack::new( - tracks_count.next_id(), + tracks_count.next_id().0, MediaType::Video(VideoSettings {}), )); diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index 5683e2722..bda840fc3 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -38,11 +38,11 @@ pub struct Counter { impl Counter { /// Returns id and increase counter. - pub fn next_id(&mut self) -> u64 { + pub fn next_id(&mut self) -> PeerId { let id = self.count; self.count += 1; - id + PeerId(id) } } @@ -146,15 +146,13 @@ impl PeerRepository { &'a self, member_id: &'a MemberId, ) -> impl Iterator { - self.peers - .iter() - .filter_map(move |(_, peer)| { - if &peer.member_id() == member_id { - Some(peer) - } else { - None - } - }) + self.peers.iter().filter_map(move |(_, peer)| { + if &peer.member_id() == member_id { + Some(peer) + } else { + None + } + }) } /// Returns owned [`Peer`] by its ID. @@ -184,29 +182,28 @@ impl PeerRepository { let mut peers_to_remove: HashMap> = HashMap::new(); - self.get_peers_by_member_id(member_id) - .for_each(|peer| { - self.get_peers_by_member_id(&peer.partner_member_id()) - .filter(|partner_peer| { - &partner_peer.partner_member_id() == member_id - }) - .for_each(|partner_peer| { - peers_to_remove - .entry(partner_peer.member_id()) - .or_insert(Vec::new()) - .push(partner_peer.id()); - }); - - peers_to_remove - .entry(peer.partner_member_id()) - .or_insert(Vec::new()) - .push(peer.id()); - - peers_to_remove - .entry(peer.member_id()) - .or_insert(Vec::new()) - .push(peer.id()); - }); + self.get_peers_by_member_id(member_id).for_each(|peer| { + self.get_peers_by_member_id(&peer.partner_member_id()) + .filter(|partner_peer| { + &partner_peer.partner_member_id() == member_id + }) + .for_each(|partner_peer| { + peers_to_remove + .entry(partner_peer.member_id()) + .or_insert(Vec::new()) + .push(partner_peer.id()); + }); + + peers_to_remove + .entry(peer.partner_member_id()) + .or_insert(Vec::new()) + .push(peer.id()); + + peers_to_remove + .entry(peer.member_id()) + .or_insert(Vec::new()) + .push(peer.id()); + }); for (peer_member_id, peers_id) in peers_to_remove { for peer_id in &peers_id { From 7f131b6180a7ed039bd7bf06cce279d1c68ce202 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 2 Aug 2019 15:11:37 +0300 Subject: [PATCH 416/735] Add Incrementable and Counter generic --- proto/client-api/src/lib.rs | 18 +++++++++++++++++- src/media/peer.rs | 6 +++--- src/signalling/peers.rs | 23 ++++++++++++----------- 3 files changed, 32 insertions(+), 15 deletions(-) diff --git a/proto/client-api/src/lib.rs b/proto/client-api/src/lib.rs index ecd2ef722..486ad1f9f 100644 --- a/proto/client-api/src/lib.rs +++ b/proto/client-api/src/lib.rs @@ -11,10 +11,26 @@ macro_attr! { #[cfg_attr(feature = "medea", derive(Deserialize))] #[cfg_attr(feature = "jason", derive(Serialize))] #[cfg_attr(test, derive(Debug, PartialEq ))] - #[derive(Clone, Copy, NewtypeFrom!, NewtypeAddAssign!, NewtypeDisplay!, PartialEq, Debug, Hash, Eq)] + #[derive(Clone, Copy, NewtypeDisplay!, PartialEq, Debug, Hash, Eq, Default)] pub struct PeerId(pub u64); } +pub trait Incrementable: Sized + Clone { + fn increment(&self) -> Self; +} + +impl Incrementable for PeerId { + fn increment(&self) -> Self { + PeerId(self.0 + 1) + } +} + +impl Incrementable for u64 { + fn increment(&self) -> Self { + self + 1 + } +} + // TODO: should be properly shared between medea and jason #[allow(dead_code)] #[cfg_attr(test, derive(Debug, PartialEq))] diff --git a/src/media/peer.rs b/src/media/peer.rs index 8eb062ef9..061fee586 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -254,15 +254,15 @@ impl Peer { pub fn add_publisher( &mut self, partner_peer: &mut Peer, - tracks_count: &mut Counter, + tracks_count: &mut Counter, ) { // TODO: fix it let track_audio = Rc::new(MediaTrack::new( - tracks_count.next_id().0, + tracks_count.next_id(), MediaType::Audio(AudioSettings {}), )); let track_video = Rc::new(MediaTrack::new( - tracks_count.next_id().0, + tracks_count.next_id(), MediaType::Video(VideoSettings {}), )); diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index bda840fc3..c184ebd12 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -7,11 +7,12 @@ use std::{ use actix::{AsyncContext as _, Context}; use hashbrown::HashMap; +use medea_client_api_proto::Incrementable; use crate::{ api::control::MemberId, log::prelude::*, - media::{New, Peer, PeerId, PeerStateMachine}, + media::{New, Peer, PeerId, PeerStateMachine, TrackId}, signalling::{ elements::Member, room::{PeersRemoved, Room, RoomError}, @@ -24,29 +25,29 @@ pub struct PeerRepository { peers: HashMap, /// Count of [`Peer`]s in this [`Room`]. - peers_count: Counter, + peers_count: Counter, /// Count of [`MediaTrack`]s in this [`Room`]. - tracks_count: Counter, + tracks_count: Counter, } /// Simple ID counter. #[derive(Default, Debug)] -pub struct Counter { - count: u64, +pub struct Counter { + count: T, } -impl Counter { +impl Counter { /// Returns id and increase counter. - pub fn next_id(&mut self) -> PeerId { + pub fn next_id(&mut self) -> T { let id = self.count; - self.count += 1; + self.count = self.count.increment(); - PeerId(id) + id } } -impl fmt::Display for Counter { +impl fmt::Display for Counter { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", self.count) } @@ -100,7 +101,7 @@ impl PeerRepository { } /// Returns mutable reference to track counter. - pub fn get_tracks_counter(&mut self) -> &mut Counter { + pub fn get_tracks_counter(&mut self) -> &mut Counter { &mut self.tracks_count } From 9c7fe12909b76deae68c8d7f3bae58f156420ddd Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 2 Aug 2019 15:16:50 +0300 Subject: [PATCH 417/735] TrackId newtype --- proto/client-api/src/lib.rs | 17 +++++++++++++---- src/media/track.rs | 5 +++-- src/signalling/room.rs | 4 ++-- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/proto/client-api/src/lib.rs b/proto/client-api/src/lib.rs index 486ad1f9f..1339d54ba 100644 --- a/proto/client-api/src/lib.rs +++ b/proto/client-api/src/lib.rs @@ -15,6 +15,15 @@ macro_attr! { pub struct PeerId(pub u64); } +macro_attr! { + /// ID of [`MediaTrack`]. + #[cfg_attr(feature = "medea", derive(Deserialize))] + #[cfg_attr(feature = "jason", derive(Serialize))] + #[cfg_attr(test, derive(Debug, PartialEq ))] + #[derive(Clone, Copy, NewtypeDisplay!, PartialEq, Debug, Hash, Eq, Default)] + pub struct TrackId(pub u64); +} + pub trait Incrementable: Sized + Clone { fn increment(&self) -> Self; } @@ -25,9 +34,9 @@ impl Incrementable for PeerId { } } -impl Incrementable for u64 { +impl Incrementable for TrackId { fn increment(&self) -> Self { - self + 1 + TrackId(self.0 + 1) } } @@ -72,7 +81,7 @@ pub enum Command { /// `mid` is basically an ID of [`m=` section][1] in SDP. /// /// [1]: https://tools.ietf.org/html/rfc4566#section-5.14 - mids: HashMap, + mids: HashMap, }, /// Web Client sends SDP Answer. MakeSdpAnswer { peer_id: PeerId, sdp_answer: String }, @@ -128,7 +137,7 @@ pub struct IceCandidate { #[cfg_attr(feature = "medea", derive(Serialize, Debug, Clone, PartialEq))] #[cfg_attr(feature = "jason", derive(Deserialize))] pub struct Track { - pub id: u64, + pub id: TrackId, pub direction: Direction, pub media_type: MediaType, } diff --git a/src/media/track.rs b/src/media/track.rs index c3792bf81..601b1002b 100644 --- a/src/media/track.rs +++ b/src/media/track.rs @@ -6,8 +6,9 @@ use std::cell::RefCell; use medea_client_api_proto::MediaType; -/// ID of [`MediaTrack`]. -pub type Id = u64; +// TODO +pub use medea_client_api_proto::TrackId as Id; +pub use Id as TrackId; /// Representation of [MediaStreamTrack][1] object. /// diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 55758b31e..02274e16d 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -10,7 +10,7 @@ use actix::{ use failure::Fail; use futures::future; use hashbrown::HashMap; -use medea_client_api_proto::{Command, Event, IceCandidate}; +use medea_client_api_proto::{Command, Event, IceCandidate, TrackId}; use crate::{ api::{ @@ -210,7 +210,7 @@ impl Room { &mut self, from_peer_id: PeerId, sdp_offer: String, - mids: StdHashMap, + mids: StdHashMap, ) -> Result, RoomError> { let mut from_peer: Peer = self.peers.take_inner_peer(from_peer_id)?; From 5deb2ccf10f29edc730d64da5a20b71462abd977 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 2 Aug 2019 15:39:11 +0300 Subject: [PATCH 418/735] Refactor Jason to use newtypes --- jason/src/api/connection.rs | 7 ++++--- jason/src/api/room.rs | 6 +++--- jason/src/media/stream.rs | 4 ++-- jason/src/media/stream_request.rs | 8 ++++---- jason/src/media/track.rs | 6 +++--- jason/src/peer/media.rs | 12 ++++++------ jason/src/peer/mod.rs | 15 +++++++++------ proto/client-api/src/lib.rs | 2 +- 8 files changed, 32 insertions(+), 28 deletions(-) diff --git a/jason/src/api/connection.rs b/jason/src/api/connection.rs index 5a43079e2..d542e9ed7 100644 --- a/jason/src/api/connection.rs +++ b/jason/src/api/connection.rs @@ -11,13 +11,14 @@ use crate::{ media::{MediaStream, MediaStreamHandle}, utils::{Callback, WasmErr}, }; +use medea_client_api_proto::PeerId; /// Actual data of a connection with a specific remote [`Member`]. /// /// Shared between JS side ([`ConnectionHandle`]) and /// Rust side ([`Connection`]). struct InnerConnection { - remote_member: u64, + remote_member: PeerId, on_remote_stream: Callback, } @@ -48,7 +49,7 @@ impl ConnectionHandle { pub fn member_id(&self) -> Result { self.0 .upgrade() - .map(|conn| conn.borrow().remote_member) + .map(|conn| conn.borrow().remote_member.0) .ok_or_else(|| WasmErr::from("Detached state").into()) } } @@ -61,7 +62,7 @@ pub(crate) struct Connection(Rc>); impl Connection { /// Instantiates new [`Connection`] for a given [`Member`]. #[inline] - pub(crate) fn new(member_id: u64) -> Self { + pub(crate) fn new(member_id: PeerId) -> Self { Self(Rc::new(RefCell::new(InnerConnection { remote_member: member_id, on_remote_stream: Callback::default(), diff --git a/jason/src/api/room.rs b/jason/src/api/room.rs index 89ecfa3fd..d02f14cbb 100644 --- a/jason/src/api/room.rs +++ b/jason/src/api/room.rs @@ -123,7 +123,7 @@ impl Room { struct InnerRoom { rpc: Rc, peers: PeerRepository, - connections: HashMap, + connections: HashMap, on_new_connection: Rc>, } @@ -146,7 +146,7 @@ impl InnerRoom { /// Creates new [`Connection`]s basing on senders and receivers of provided /// [`Track`]s. fn create_connections_from_tracks(&mut self, tracks: &[Track]) { - let create_connection = |room: &mut Self, member_id: &u64| { + let create_connection = |room: &mut Self, member_id: &PeerId| { if !room.connections.contains_key(member_id) { let con = Connection::new(*member_id); room.on_new_connection.call1(con.new_handle()); @@ -297,7 +297,7 @@ impl PeerEventHandler for InnerRoom { fn on_new_remote_stream( &mut self, _: PeerId, - sender_id: u64, + sender_id: PeerId, remote_stream: MediaStream, ) { match self.connections.get(&sender_id) { diff --git a/jason/src/media/stream.rs b/jason/src/media/stream.rs index f480a71aa..43043151c 100644 --- a/jason/src/media/stream.rs +++ b/jason/src/media/stream.rs @@ -26,10 +26,10 @@ struct InnerStream { stream: SysMediaStream, /// List of audio tracks. - audio_tracks: HashMap>, + audio_tracks: HashMap>, /// List of video tracks. - video_tracks: HashMap>, + video_tracks: HashMap>, } impl InnerStream { diff --git a/jason/src/media/stream_request.rs b/jason/src/media/stream_request.rs index 02f24f701..dbaf95e72 100644 --- a/jason/src/media/stream_request.rs +++ b/jason/src/media/stream_request.rs @@ -23,8 +23,8 @@ use super::{MediaStream, MediaTrack, TrackId}; /// [3]: https://www.w3.org/TR/mediacapture-streams/#mediastream #[derive(Default)] pub struct StreamRequest { - audio: HashMap, - video: HashMap, + audio: HashMap, + video: HashMap, } impl StreamRequest { @@ -45,8 +45,8 @@ impl StreamRequest { /// and must have at least one track of any kind. #[allow(clippy::module_name_repetitions)] pub struct SimpleStreamRequest { - audio: Option<(u64, AudioSettings)>, - video: Option<(u64, VideoSettings)>, + audio: Option<(TrackId, AudioSettings)>, + video: Option<(TrackId, VideoSettings)>, } impl SimpleStreamRequest { diff --git a/jason/src/media/track.rs b/jason/src/media/track.rs index 36bbfae9c..0ee4b48b8 100644 --- a/jason/src/media/track.rs +++ b/jason/src/media/track.rs @@ -7,8 +7,8 @@ use std::rc::Rc; use medea_client_api_proto::MediaType; use web_sys::MediaStreamTrack; -/// ID of [`MediaTrack`]. -pub type Id = u64; +pub use medea_client_api_proto::TrackId as Id; +pub use Id as TrackId; /// Representation of [MediaStreamTrack][1]. /// @@ -22,7 +22,7 @@ pub struct MediaTrack { impl MediaTrack { /// Instantiates new [`MediaTrack`]. - pub fn new(id: u64, track: MediaStreamTrack, caps: MediaType) -> Rc { + pub fn new(id: Id, track: MediaStreamTrack, caps: MediaType) -> Rc { Rc::new(Self { id, track, caps }) } diff --git a/jason/src/peer/media.rs b/jason/src/peer/media.rs index 4b4d907b4..16a7675b4 100644 --- a/jason/src/peer/media.rs +++ b/jason/src/peer/media.rs @@ -3,7 +3,7 @@ use std::{borrow::ToOwned, cell::RefCell, collections::HashMap, rc::Rc}; use futures::{future, Future}; -use medea_client_api_proto::{Direction, MediaType, Track}; +use medea_client_api_proto::{Direction, MediaType, PeerId, Track}; use wasm_bindgen_futures::JsFuture; use web_sys::{ MediaStreamTrack, RtcRtpTransceiver, RtcRtpTransceiverDirection, @@ -47,7 +47,7 @@ impl MediaConnections { /// Returns mapping from a [`MediaTrack`] ID to a `mid` of /// this track's [`RtcRtpTransceiver`]. - pub fn get_mids(&self) -> Result, WasmErr> { + pub fn get_mids(&self) -> Result, WasmErr> { let mut s = self.0.borrow_mut(); let mut mids = HashMap::with_capacity(s.senders.len() + s.receivers.len()); @@ -164,7 +164,7 @@ impl MediaConnections { &self, transceiver: RtcRtpTransceiver, track: MediaStreamTrack, - ) -> Option { + ) -> Option { let mut s = self.0.borrow_mut(); if let Some(mid) = transceiver.mid() { for receiver in &mut s.receivers.values_mut() { @@ -189,7 +189,7 @@ impl MediaConnections { /// but only if all receiving [`MediaTrack`]s are present already. pub fn get_tracks_by_sender( &self, - sender_id: u64, + sender_id: PeerId, ) -> Option>> { let s = self.0.borrow(); let mut tracks: Vec> = Vec::new(); @@ -258,7 +258,7 @@ impl Sender { pub struct Receiver { track_id: TrackId, caps: MediaType, - sender_id: u64, + sender_id: PeerId, transceiver: Option, mid: Option, track: Option>, @@ -276,7 +276,7 @@ impl Receiver { fn new( track_id: TrackId, caps: MediaType, - sender_id: u64, + sender_id: PeerId, peer: &RtcPeerConnection, mid: Option, ) -> Self { diff --git a/jason/src/peer/mod.rs b/jason/src/peer/mod.rs index 981df698a..725cbc3f8 100644 --- a/jason/src/peer/mod.rs +++ b/jason/src/peer/mod.rs @@ -10,7 +10,7 @@ mod repo; use std::{collections::HashMap, rc::Rc}; use futures::{future, sync::mpsc::UnboundedSender, Future}; -use medea_client_api_proto::{Direction, IceServer, Track}; +use medea_client_api_proto::{Direction, IceServer, Track, TrackId}; use medea_macro::dispatchable; use web_sys::RtcTrackEvent; @@ -25,9 +25,12 @@ use self::{ }; #[doc(inline)] -pub use self::{repo::PeerRepository, Id as PeerId}; - -pub type Id = u64; +pub use self::repo::PeerRepository; +// TODO: +#[doc(inline)] +pub use medea_client_api_proto::PeerId as Id; +#[doc(inline)] +pub use Id as PeerId; #[dispatchable] #[allow(clippy::module_name_repetitions)] @@ -44,7 +47,7 @@ pub enum PeerEvent { /// [`RtcPeerConnection`] received new stream from remote sender. NewRemoteStream { peer_id: Id, - sender_id: u64, + sender_id: Id, remote_stream: MediaStream, }, } @@ -157,7 +160,7 @@ impl PeerConnection { /// /// [1]: https://tools.ietf.org/html/rfc4566#section-5.14 /// [2]: https://www.w3.org/TR/webrtc/#rtcrtptransceiver-interface - pub fn get_mids(&self) -> Result, WasmErr> { + pub fn get_mids(&self) -> Result, WasmErr> { self.0.media_connections.get_mids() } diff --git a/proto/client-api/src/lib.rs b/proto/client-api/src/lib.rs index 1339d54ba..31152970d 100644 --- a/proto/client-api/src/lib.rs +++ b/proto/client-api/src/lib.rs @@ -20,7 +20,7 @@ macro_attr! { #[cfg_attr(feature = "medea", derive(Deserialize))] #[cfg_attr(feature = "jason", derive(Serialize))] #[cfg_attr(test, derive(Debug, PartialEq ))] - #[derive(Clone, Copy, NewtypeDisplay!, PartialEq, Debug, Hash, Eq, Default)] + #[derive(Clone, Copy, NewtypeDisplay!, NewtypeDeref!, PartialEq, Debug, Hash, Eq, Default)] pub struct TrackId(pub u64); } From 445e1df5b243e70e62e7cf3448fc8ef457a05d3e Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 2 Aug 2019 15:48:25 +0300 Subject: [PATCH 419/735] Get rid of hashbrown --- Cargo.lock | 1 - Cargo.toml | 1 - src/api/control/member.rs | 3 +-- src/api/control/room.rs | 2 +- src/lib.rs | 2 +- src/media/peer.rs | 2 +- src/signalling/elements/endpoints/webrtc/publish_endpoint.rs | 2 +- src/signalling/elements/member.rs | 2 +- src/signalling/participants.rs | 2 +- src/signalling/peers.rs | 2 +- src/signalling/room.rs | 2 +- src/signalling/room_repo.rs | 2 +- src/utils/mod.rs | 4 ++-- 13 files changed, 12 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 79e41742a..f7a44d444 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1099,7 +1099,6 @@ dependencies = [ "dotenv 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", - "hashbrown 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "macro-attr 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "medea-client-api-proto 0.1.0-dev", diff --git a/Cargo.toml b/Cargo.toml index 6c82792e0..4de20ebe8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,7 +31,6 @@ config = "0.9" dotenv = "0.14" failure = "0.1" futures = "0.1" -hashbrown = "0.5" humantime = "1.2" macro-attr = "0.2" medea-client-api-proto = { path = "proto/client-api", features = ["medea"] } diff --git a/src/api/control/member.rs b/src/api/control/member.rs index 8929c84e5..4e026d089 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -1,8 +1,7 @@ //! Member definitions and implementations. -use std::convert::TryFrom; +use std::{collections::HashMap, convert::TryFrom}; -use hashbrown::HashMap; use macro_attr::*; use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; use serde::Deserialize; diff --git a/src/api/control/room.rs b/src/api/control/room.rs index d2562f4a4..9f20ba87f 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -2,10 +2,10 @@ use std::convert::TryFrom; -use hashbrown::HashMap; use macro_attr::*; use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; use serde::Deserialize; +use std::collections::HashMap; use super::{ member::{MemberElement, MemberSpec}, diff --git a/src/lib.rs b/src/lib.rs index 20ae4c1ad..302f13b61 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -14,7 +14,7 @@ use std::sync::Arc; use actix::prelude::*; use failure::Fail; -use hashbrown::HashMap; +use std::collections::HashMap; use crate::{ api::control::{load_static_specs_from_dir, RoomId}, diff --git a/src/media/peer.rs b/src/media/peer.rs index 061fee586..8dfaeea56 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -7,11 +7,11 @@ use std::{collections::HashMap as StdHashMap, convert::TryFrom, fmt, rc::Rc}; use failure::Fail; -use hashbrown::HashMap; use medea_client_api_proto::{ AudioSettings, Direction, MediaType, Track, VideoSettings, }; use medea_macro::enum_delegate; +use std::collections::HashMap; use crate::{ api::control::MemberId, diff --git a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs index 59eceb702..d09c2c674 100644 --- a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs @@ -5,9 +5,9 @@ use std::{ rc::{Rc, Weak}, }; -use hashbrown::HashSet; use macro_attr::*; use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; +use std::collections::HashSet; use crate::{ api::control::endpoint::P2pMode, diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index 2d78e296b..ee986cef2 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -3,8 +3,8 @@ use std::{cell::RefCell, convert::TryFrom as _, rc::Rc}; use failure::Fail; -use hashbrown::HashMap; use medea_client_api_proto::IceServer; +use std::collections::HashMap; use crate::{ api::control::{MemberId, MemberSpec, RoomSpec, TryFromElementError}, diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index b8bc282be..c46f9075e 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -17,8 +17,8 @@ use futures::{ future::{self, join_all, Either}, Future, }; -use hashbrown::HashMap; use medea_client_api_proto::Event; +use std::collections::HashMap; use crate::{ api::{ diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index c184ebd12..672cf7b61 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -6,8 +6,8 @@ use std::{ }; use actix::{AsyncContext as _, Context}; -use hashbrown::HashMap; use medea_client_api_proto::Incrementable; +use std::collections::HashMap; use crate::{ api::control::MemberId, diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 02274e16d..356b0c3cc 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -9,8 +9,8 @@ use actix::{ }; use failure::Fail; use futures::future; -use hashbrown::HashMap; use medea_client_api_proto::{Command, Event, IceCandidate, TrackId}; +use std::collections::HashMap; use crate::{ api::{ diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs index 6f628dca5..2589c4bd8 100644 --- a/src/signalling/room_repo.rs +++ b/src/signalling/room_repo.rs @@ -3,7 +3,7 @@ use std::sync::{Arc, Mutex}; use actix::Addr; -use hashbrown::HashMap; +use std::collections::HashMap; use crate::{api::control::RoomId, signalling::Room}; diff --git a/src/utils/mod.rs b/src/utils/mod.rs index ab2452b6f..8b40d27d2 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -1,6 +1,6 @@ //! Helper utils used in project. -/// Creates new [`hashbrown::HashMap`] from a list of key-value pairs. +/// Creates new [`std::collections::HashMap`] from a list of key-value pairs. /// /// ## Example /// @@ -23,7 +23,7 @@ macro_rules! hashmap { ($($key:expr => $value:expr),*) => { { let _cap = hashmap!(@count $($key),*); - let mut _map = ::hashbrown::HashMap::with_capacity(_cap); + let mut _map = ::std::collections::HashMap::with_capacity(_cap); $( let _ = _map.insert($key, $value); )* From 74b353d68f6ed8c835d82dc5412b4a1dd66f718d Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 2 Aug 2019 15:50:41 +0300 Subject: [PATCH 420/735] Update deps --- Cargo.lock | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f7a44d444..3f78b7cd0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -14,7 +14,7 @@ name = "actix" version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "actix-http 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-http 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "actix-rt 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "actix_derive 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -67,7 +67,7 @@ dependencies = [ [[package]] name = "actix-http" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -123,7 +123,7 @@ dependencies = [ "actix-server 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "actix-service 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "actix-utils 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "awc 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "awc 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -242,7 +242,7 @@ version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-http 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-http 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "actix-router 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "actix-rt 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "actix-server 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -251,7 +251,7 @@ dependencies = [ "actix-threadpool 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "actix-utils 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "actix-web-codegen 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "awc 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "awc 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", "encoding_rs 0.8.17 (registry+https://github.com/rust-lang/crates.io-index)", @@ -276,7 +276,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "actix 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)", "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-http 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-http 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "actix-web 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", @@ -365,11 +365,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "awc" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-http 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-http 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "actix-service 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1087,11 +1087,11 @@ version = "0.1.0-dev" dependencies = [ "actix 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)", "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-http 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-http 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "actix-http-test 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "actix-web 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "actix-web-actors 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "awc 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "awc 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "bb8 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "bb8-redis 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2623,7 +2623,7 @@ dependencies = [ "checksum actix 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)" = "671ce3d27313f236827a5dd153a1073ad03ef31fc77f562020263e7830cf1ef7" "checksum actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9f2c11af4b06dc935d8e1b1491dad56bfb32febc49096a91e773f8535c176453" "checksum actix-connect 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "818f0901d2188c8c75a489c42db6e8d9e1b020f0ca2baaa4c940e08e1817eed0" -"checksum actix-http 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "59698e11ceb42ea16a2e491bd5a9b48adc7268323a5b600522d408d09783828c" +"checksum actix-http 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "4d45d3f033fb7ff73467dad0ef1d12afb532b39953d50f4124f4d89451670583" "checksum actix-http-test 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "beafa31d71c8fa8204ede1602a3dd221e5cf30ff354180f8ee87274ab81cf607" "checksum actix-router 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "23224bb527e204261d0291102cb9b52713084def67d94f7874923baefe04ccf7" "checksum actix-rt 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "18d9054b1cfacfa441846b9b99001010cb8fbb02130e6cfdb25cea36d3e98e87" @@ -2645,7 +2645,7 @@ dependencies = [ "checksum ascii 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "91e320562a8fa3286a481b7189f89578ace6b20df99e123c87f2f509c957c5d6" "checksum atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1803c647a3ec87095e7ae7acfca019e98de5ec9a7d01343f611cf3152ed71a90" "checksum autocfg 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "22130e92352b948e7e82a49cdb0aa94f2211761117f29e052dd397c1ac33542b" -"checksum awc 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4c4763e6aa29a801d761dc3464f081d439ea5249ba90c3c3bdfc8dd3f739d233" +"checksum awc 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "07859dcd6ac7b7c05df9fd9beb5919ae9e6bbfbf0746fbdd92e131ee950552a4" "checksum backtrace 0.3.34 (registry+https://github.com/rust-lang/crates.io-index)" = "b5164d292487f037ece34ec0de2fcede2faa162f085dd96d2385ab81b12765ba" "checksum backtrace-sys 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)" = "82a830b4ef2d1124a711c71d263c5abdc710ef8e907bd508c88be475cebc422b" "checksum base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" From e834f67d3d5faaa8e7fb7abea7d554319a37f421 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 2 Aug 2019 15:53:07 +0300 Subject: [PATCH 421/735] Fmt --- jason/src/api/connection.rs | 2 +- proto/client-api/src/lib.rs | 2 +- src/api/control/room.rs | 3 +-- src/conf/log.rs | 1 + src/conf/rpc.rs | 5 +++-- src/media/peer.rs | 9 ++++----- .../elements/endpoints/webrtc/play_endpoint.rs | 4 ++-- .../elements/endpoints/webrtc/publish_endpoint.rs | 6 +++--- src/signalling/elements/member.rs | 9 ++++++--- src/signalling/participants.rs | 2 +- src/signalling/peers.rs | 2 +- src/signalling/room.rs | 5 ++--- src/signalling/room_repo.rs | 6 ++++-- 13 files changed, 30 insertions(+), 26 deletions(-) diff --git a/jason/src/api/connection.rs b/jason/src/api/connection.rs index d542e9ed7..8b7c52cc8 100644 --- a/jason/src/api/connection.rs +++ b/jason/src/api/connection.rs @@ -5,13 +5,13 @@ use std::{ rc::{Rc, Weak}, }; +use medea_client_api_proto::PeerId; use wasm_bindgen::prelude::*; use crate::{ media::{MediaStream, MediaStreamHandle}, utils::{Callback, WasmErr}, }; -use medea_client_api_proto::PeerId; /// Actual data of a connection with a specific remote [`Member`]. /// diff --git a/proto/client-api/src/lib.rs b/proto/client-api/src/lib.rs index 31152970d..1339d54ba 100644 --- a/proto/client-api/src/lib.rs +++ b/proto/client-api/src/lib.rs @@ -20,7 +20,7 @@ macro_attr! { #[cfg_attr(feature = "medea", derive(Deserialize))] #[cfg_attr(feature = "jason", derive(Serialize))] #[cfg_attr(test, derive(Debug, PartialEq ))] - #[derive(Clone, Copy, NewtypeDisplay!, NewtypeDeref!, PartialEq, Debug, Hash, Eq, Default)] + #[derive(Clone, Copy, NewtypeDisplay!, PartialEq, Debug, Hash, Eq, Default)] pub struct TrackId(pub u64); } diff --git a/src/api/control/room.rs b/src/api/control/room.rs index 9f20ba87f..6044068d0 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -1,11 +1,10 @@ //! Room definitions and implementations. -use std::convert::TryFrom; +use std::{collections::HashMap, convert::TryFrom}; use macro_attr::*; use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; use serde::Deserialize; -use std::collections::HashMap; use super::{ member::{MemberElement, MemberSpec}, diff --git a/src/conf/log.rs b/src/conf/log.rs index f35a7c408..086603d08 100644 --- a/src/conf/log.rs +++ b/src/conf/log.rs @@ -1,4 +1,5 @@ //! Logging settings. + use std::str::FromStr as _; use serde::{Deserialize, Serialize}; diff --git a/src/conf/rpc.rs b/src/conf/rpc.rs index 0408de3ef..7a7972d5d 100644 --- a/src/conf/rpc.rs +++ b/src/conf/rpc.rs @@ -1,9 +1,10 @@ //! RPC connection settings. -use serde::{Deserialize, Serialize}; -use smart_default::SmartDefault; use std::time::Duration; +use serde::{Deserialize, Serialize}; +use smart_default::SmartDefault; + /// RPC connection settings. #[derive(Clone, Debug, Deserialize, Serialize, SmartDefault)] #[serde(default)] diff --git a/src/media/peer.rs b/src/media/peer.rs index 8dfaeea56..b2d5dcd08 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -4,14 +4,13 @@ #![allow(clippy::use_self)] -use std::{collections::HashMap as StdHashMap, convert::TryFrom, fmt, rc::Rc}; +use std::{collections::HashMap, convert::TryFrom, fmt, rc::Rc}; use failure::Fail; use medea_client_api_proto::{ AudioSettings, Direction, MediaType, Track, VideoSettings, }; use medea_macro::enum_delegate; -use std::collections::HashMap; use crate::{ api::control::MemberId, @@ -322,7 +321,7 @@ impl Peer { /// Provided `mids` must have entries for all [`Peer`]s tracks. pub fn set_mids( &mut self, - mut mids: StdHashMap, + mut mids: HashMap, ) -> Result<(), PeerError> { for (id, track) in self .context @@ -364,8 +363,8 @@ impl Peer { } impl Peer { - pub fn get_mids(&self) -> Result, PeerError> { - let mut mids = StdHashMap::with_capacity(self.context.senders.len()); + pub fn get_mids(&self) -> Result, PeerError> { + let mut mids = HashMap::with_capacity(self.context.senders.len()); for (track_id, track) in self.context.senders.iter() { mids.insert( *track_id, diff --git a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs index 02a06f172..2faf3d3e8 100644 --- a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs @@ -12,13 +12,13 @@ use crate::{ api::control::endpoint::SrcUri, media::PeerId, signalling::elements::{ - endpoints::webrtc::publish_endpoint::WeakWebRtcPublishEndpoint, Member, + endpoints::webrtc::publish_endpoint::WeakWebRtcPublishEndpoint, + member::WeakMember, Member, }, }; use super::publish_endpoint::WebRtcPublishEndpoint; -use crate::signalling::elements::member::WeakMember; pub use Id as WebRtcPlayId; macro_attr! { diff --git a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs index d09c2c674..763921ed9 100644 --- a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs @@ -2,24 +2,24 @@ use std::{ cell::RefCell, + collections::HashSet, rc::{Rc, Weak}, }; use macro_attr::*; use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; -use std::collections::HashSet; use crate::{ api::control::endpoint::P2pMode, media::PeerId, signalling::elements::{ - endpoints::webrtc::play_endpoint::WeakWebRtcPlayEndpoint, Member, + endpoints::webrtc::play_endpoint::WeakWebRtcPlayEndpoint, + member::WeakMember, Member, }, }; use super::play_endpoint::WebRtcPlayEndpoint; -use crate::signalling::elements::member::WeakMember; pub use Id as WebRtcPublishId; macro_attr! { diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index ee986cef2..0bc91a72f 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -1,10 +1,14 @@ //! [`Member`] is member of [`Room`] with [`RpcConnection`]. -use std::{cell::RefCell, convert::TryFrom as _, rc::Rc}; +use std::{ + cell::RefCell, + collections::HashMap, + convert::TryFrom as _, + rc::{Rc, Weak}, +}; use failure::Fail; use medea_client_api_proto::IceServer; -use std::collections::HashMap; use crate::{ api::control::{MemberId, MemberSpec, RoomSpec, TryFromElementError}, @@ -15,7 +19,6 @@ use crate::{ use super::endpoints::webrtc::{ WebRtcPlayEndpoint, WebRtcPlayId, WebRtcPublishEndpoint, WebRtcPublishId, }; -use std::rc::Weak; /// Errors which may occur while loading [`Member`]s from [`RoomSpec`]. #[derive(Debug, Fail)] diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index c46f9075e..9662e4ceb 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -4,6 +4,7 @@ //! credentials management. use std::{ + collections::HashMap, sync::Arc, time::{Duration, Instant}, }; @@ -18,7 +19,6 @@ use futures::{ Future, }; use medea_client_api_proto::Event; -use std::collections::HashMap; use crate::{ api::{ diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index 672cf7b61..fa8de287a 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -1,13 +1,13 @@ //! Repository that stores [`Room`]s [`Peer`]s. use std::{ + collections::HashMap, convert::{TryFrom, TryInto}, fmt, }; use actix::{AsyncContext as _, Context}; use medea_client_api_proto::Incrementable; -use std::collections::HashMap; use crate::{ api::control::MemberId, diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 356b0c3cc..3d0ccca76 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -1,7 +1,7 @@ //! Room definitions and implementations. Room is responsible for media //! connection establishment between concrete [`Member`]s. -use std::{collections::HashMap as StdHashMap, sync::Arc, time::Duration}; +use std::{collections::HashMap, sync::Arc, time::Duration}; use actix::{ fut::wrap_future, Actor, ActorFuture, AsyncContext, Context, Handler, @@ -10,7 +10,6 @@ use actix::{ use failure::Fail; use futures::future; use medea_client_api_proto::{Command, Event, IceCandidate, TrackId}; -use std::collections::HashMap; use crate::{ api::{ @@ -210,7 +209,7 @@ impl Room { &mut self, from_peer_id: PeerId, sdp_offer: String, - mids: StdHashMap, + mids: HashMap, ) -> Result, RoomError> { let mut from_peer: Peer = self.peers.take_inner_peer(from_peer_id)?; diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs index 2589c4bd8..67dca91b4 100644 --- a/src/signalling/room_repo.rs +++ b/src/signalling/room_repo.rs @@ -1,9 +1,11 @@ //! Repository that stores [`Room`]s addresses. -use std::sync::{Arc, Mutex}; +use std::{ + collections::HashMap, + sync::{Arc, Mutex}, +}; use actix::Addr; -use std::collections::HashMap; use crate::{api::control::RoomId, signalling::Room}; From a46d6e41a9d5d4fcca1ca6e17547e2886d960e42 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 2 Aug 2019 17:06:17 +0300 Subject: [PATCH 422/735] Fix TODOs --- jason/src/api/room.rs | 4 ++-- jason/src/media/mod.rs | 2 +- jason/src/media/stream.rs | 4 ++-- jason/src/media/stream_request.rs | 6 ++++-- jason/src/media/track.rs | 3 +-- jason/src/peer/media.rs | 4 ++-- jason/src/peer/mod.rs | 9 +++------ jason/src/peer/repo.rs | 4 ++-- proto/client-api/src/lib.rs | 7 +++---- src/api/control/member.rs | 1 + src/api/control/room.rs | 1 + src/media/mod.rs | 6 +++--- src/media/peer.rs | 13 +++---------- src/media/track.rs | 4 +--- .../elements/endpoints/webrtc/play_endpoint.rs | 2 +- .../elements/endpoints/webrtc/publish_endpoint.rs | 2 +- src/signalling/elements/member.rs | 4 ++-- src/signalling/peers.rs | 4 ++-- src/signalling/room.rs | 4 ++-- 19 files changed, 37 insertions(+), 47 deletions(-) diff --git a/jason/src/api/room.rs b/jason/src/api/room.rs index d02f14cbb..47ad06a1c 100644 --- a/jason/src/api/room.rs +++ b/jason/src/api/room.rs @@ -13,14 +13,14 @@ use futures::{ sync::mpsc::{unbounded, UnboundedSender}, }; use medea_client_api_proto::{ - Command, Direction, EventHandler, IceCandidate, IceServer, Track, + Command, Direction, EventHandler, IceCandidate, IceServer, PeerId, Track, }; use wasm_bindgen::prelude::*; use wasm_bindgen_futures::spawn_local; use crate::{ media::{MediaManager, MediaStream}, - peer::{PeerEvent, PeerEventHandler, PeerId, PeerRepository}, + peer::{PeerEvent, PeerEventHandler, PeerRepository}, rpc::RpcClient, utils::{Callback2, WasmErr}, }; diff --git a/jason/src/media/mod.rs b/jason/src/media/mod.rs index 5215daf20..7f17f785a 100644 --- a/jason/src/media/mod.rs +++ b/jason/src/media/mod.rs @@ -12,5 +12,5 @@ pub use self::{ manager::MediaManager, stream::{MediaStream, MediaStreamHandle}, stream_request::{SimpleStreamRequest, StreamRequest}, - track::{Id as TrackId, MediaTrack}, + track::MediaTrack, }; diff --git a/jason/src/media/stream.rs b/jason/src/media/stream.rs index 43043151c..e99929b08 100644 --- a/jason/src/media/stream.rs +++ b/jason/src/media/stream.rs @@ -7,13 +7,13 @@ use std::{ rc::{Rc, Weak}, }; -use medea_client_api_proto::MediaType; +use medea_client_api_proto::{MediaType, TrackId}; use wasm_bindgen::{prelude::*, JsValue}; use web_sys::MediaStream as SysMediaStream; use crate::utils::WasmErr; -use super::{MediaTrack, TrackId}; +use super::MediaTrack; /// Actual data of a [`MediaStream`]. /// diff --git a/jason/src/media/stream_request.rs b/jason/src/media/stream_request.rs index dbaf95e72..115ca942c 100644 --- a/jason/src/media/stream_request.rs +++ b/jason/src/media/stream_request.rs @@ -4,12 +4,14 @@ use std::{collections::HashMap, convert::TryFrom}; -use medea_client_api_proto::{AudioSettings, MediaType, VideoSettings}; +use medea_client_api_proto::{ + AudioSettings, MediaType, TrackId, VideoSettings, +}; use wasm_bindgen::JsValue; use crate::utils::WasmErr; -use super::{MediaStream, MediaTrack, TrackId}; +use super::{MediaStream, MediaTrack}; /// Representation of [MediaStreamConstraints][1] object. /// diff --git a/jason/src/media/track.rs b/jason/src/media/track.rs index 0ee4b48b8..9ea8bf1c8 100644 --- a/jason/src/media/track.rs +++ b/jason/src/media/track.rs @@ -7,8 +7,7 @@ use std::rc::Rc; use medea_client_api_proto::MediaType; use web_sys::MediaStreamTrack; -pub use medea_client_api_proto::TrackId as Id; -pub use Id as TrackId; +use medea_client_api_proto::TrackId as Id; /// Representation of [MediaStreamTrack][1]. /// diff --git a/jason/src/peer/media.rs b/jason/src/peer/media.rs index 16a7675b4..956d1be1d 100644 --- a/jason/src/peer/media.rs +++ b/jason/src/peer/media.rs @@ -3,14 +3,14 @@ use std::{borrow::ToOwned, cell::RefCell, collections::HashMap, rc::Rc}; use futures::{future, Future}; -use medea_client_api_proto::{Direction, MediaType, PeerId, Track}; +use medea_client_api_proto::{Direction, MediaType, PeerId, Track, TrackId}; use wasm_bindgen_futures::JsFuture; use web_sys::{ MediaStreamTrack, RtcRtpTransceiver, RtcRtpTransceiverDirection, }; use crate::{ - media::{MediaStream, MediaTrack, StreamRequest, TrackId}, + media::{MediaStream, MediaTrack, StreamRequest}, utils::WasmErr, }; diff --git a/jason/src/peer/mod.rs b/jason/src/peer/mod.rs index 725cbc3f8..342a07641 100644 --- a/jason/src/peer/mod.rs +++ b/jason/src/peer/mod.rs @@ -10,7 +10,9 @@ mod repo; use std::{collections::HashMap, rc::Rc}; use futures::{future, sync::mpsc::UnboundedSender, Future}; -use medea_client_api_proto::{Direction, IceServer, Track, TrackId}; +use medea_client_api_proto::{ + Direction, IceServer, PeerId as Id, Track, TrackId, +}; use medea_macro::dispatchable; use web_sys::RtcTrackEvent; @@ -26,11 +28,6 @@ use self::{ #[doc(inline)] pub use self::repo::PeerRepository; -// TODO: -#[doc(inline)] -pub use medea_client_api_proto::PeerId as Id; -#[doc(inline)] -pub use Id as PeerId; #[dispatchable] #[allow(clippy::module_name_repetitions)] diff --git a/jason/src/peer/repo.rs b/jason/src/peer/repo.rs index d88f3d60a..6c420b85b 100644 --- a/jason/src/peer/repo.rs +++ b/jason/src/peer/repo.rs @@ -1,11 +1,11 @@ use std::{collections::HashMap, rc::Rc}; use futures::sync::mpsc::UnboundedSender; -use medea_client_api_proto::IceServer; +use medea_client_api_proto::{IceServer, PeerId}; use crate::{media::MediaManager, utils::WasmErr}; -use super::{PeerConnection, PeerEvent, PeerId}; +use super::{PeerConnection, PeerEvent}; /// [`PeerConnection`] factory and repository. #[allow(clippy::module_name_repetitions)] diff --git a/proto/client-api/src/lib.rs b/proto/client-api/src/lib.rs index 1339d54ba..d163ae999 100644 --- a/proto/client-api/src/lib.rs +++ b/proto/client-api/src/lib.rs @@ -1,13 +1,12 @@ use std::collections::HashMap; -use medea_macro::dispatchable; -use serde::{de::Deserializer, ser::Serializer, Deserialize, Serialize}; -// TODO: cfg_attr use macro_attr::*; +use medea_macro::dispatchable; use newtype_derive::*; +use serde::{de::Deserializer, ser::Serializer, Deserialize, Serialize}; -// TODO: cfg_attr macro_attr! { + /// ID of [`Peer`]. #[cfg_attr(feature = "medea", derive(Deserialize))] #[cfg_attr(feature = "jason", derive(Serialize))] #[cfg_attr(test, derive(Debug, PartialEq ))] diff --git a/src/api/control/member.rs b/src/api/control/member.rs index 4e026d089..987e513cc 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -28,6 +28,7 @@ macro_attr! { pub struct Id(pub String); } +/// Element of [`Member`]'s [`Pipeline`]. #[allow(clippy::module_name_repetitions)] #[derive(Clone, Deserialize, Debug)] #[serde(tag = "kind")] diff --git a/src/api/control/room.rs b/src/api/control/room.rs index 6044068d0..ccc914697 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -27,6 +27,7 @@ macro_attr! { pub struct Id(pub String); } +/// Element of [`Room`]'s [`Pipeline`]. #[allow(clippy::module_name_repetitions)] #[derive(Clone, Deserialize, Debug)] #[serde(tag = "kind")] diff --git a/src/media/mod.rs b/src/media/mod.rs index c66c9ea1c..fa04ae198 100644 --- a/src/media/mod.rs +++ b/src/media/mod.rs @@ -6,8 +6,8 @@ pub mod track; pub use self::{ ice_user::IceUser, peer::{ - Id as PeerId, New, Peer, PeerError, PeerStateMachine, - WaitLocalHaveRemote, WaitLocalSdp, WaitRemoteSdp, + New, Peer, PeerError, PeerStateMachine, WaitLocalHaveRemote, + WaitLocalSdp, WaitRemoteSdp, }, - track::{Id as TrackId, MediaTrack}, + track::MediaTrack, }; diff --git a/src/media/peer.rs b/src/media/peer.rs index b2d5dcd08..7e6c8f187 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -8,14 +8,13 @@ use std::{collections::HashMap, convert::TryFrom, fmt, rc::Rc}; use failure::Fail; use medea_client_api_proto::{ - AudioSettings, Direction, MediaType, Track, VideoSettings, + AudioSettings, Direction, MediaType, PeerId as Id, Track, TrackId, + VideoSettings, }; use medea_macro::enum_delegate; use crate::{ - api::control::MemberId, - media::{MediaTrack, TrackId}, - signalling::peers::Counter, + api::control::MemberId, media::MediaTrack, signalling::peers::Counter, }; /// Newly initialized [`Peer`] ready to signalling. @@ -141,11 +140,6 @@ impl_peer_converts!(WaitLocalHaveRemote); impl_peer_converts!(WaitRemoteSdp); impl_peer_converts!(Stable); -/// ID of [`Peer`]. -pub use medea_client_api_proto::PeerId as Id; -// TODO: remove pub use -pub use Id as PeerId; - #[derive(Debug)] pub struct Context { id: Id, @@ -255,7 +249,6 @@ impl Peer { partner_peer: &mut Peer, tracks_count: &mut Counter, ) { - // TODO: fix it let track_audio = Rc::new(MediaTrack::new( tracks_count.next_id(), MediaType::Audio(AudioSettings {}), diff --git a/src/media/track.rs b/src/media/track.rs index 601b1002b..30f990192 100644 --- a/src/media/track.rs +++ b/src/media/track.rs @@ -6,9 +6,7 @@ use std::cell::RefCell; use medea_client_api_proto::MediaType; -// TODO -pub use medea_client_api_proto::TrackId as Id; -pub use Id as TrackId; +use medea_client_api_proto::TrackId as Id; /// Representation of [MediaStreamTrack][1] object. /// diff --git a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs index 2faf3d3e8..ca6978ae1 100644 --- a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs @@ -6,11 +6,11 @@ use std::{ }; use macro_attr::*; +use medea_client_api_proto::PeerId; use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; use crate::{ api::control::endpoint::SrcUri, - media::PeerId, signalling::elements::{ endpoints::webrtc::publish_endpoint::WeakWebRtcPublishEndpoint, member::WeakMember, Member, diff --git a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs index 763921ed9..59b834f39 100644 --- a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs @@ -7,11 +7,11 @@ use std::{ }; use macro_attr::*; +use medea_client_api_proto::PeerId; use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; use crate::{ api::control::endpoint::P2pMode, - media::PeerId, signalling::elements::{ endpoints::webrtc::play_endpoint::WeakWebRtcPlayEndpoint, member::WeakMember, Member, diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index 0bc91a72f..54c2c5be8 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -8,12 +8,12 @@ use std::{ }; use failure::Fail; -use medea_client_api_proto::IceServer; +use medea_client_api_proto::{IceServer, PeerId}; use crate::{ api::control::{MemberId, MemberSpec, RoomSpec, TryFromElementError}, log::prelude::*, - media::{IceUser, PeerId}, + media::IceUser, }; use super::endpoints::webrtc::{ diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index fa8de287a..7ea082121 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -7,12 +7,12 @@ use std::{ }; use actix::{AsyncContext as _, Context}; -use medea_client_api_proto::Incrementable; +use medea_client_api_proto::{Incrementable, PeerId, TrackId}; use crate::{ api::control::MemberId, log::prelude::*, - media::{New, Peer, PeerId, PeerStateMachine, TrackId}, + media::{New, Peer, PeerStateMachine}, signalling::{ elements::Member, room::{PeersRemoved, Room, RoomError}, diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 3d0ccca76..5c505a656 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -9,7 +9,7 @@ use actix::{ }; use failure::Fail; use futures::future; -use medea_client_api_proto::{Command, Event, IceCandidate, TrackId}; +use medea_client_api_proto::{Command, Event, IceCandidate, PeerId, TrackId}; use crate::{ api::{ @@ -21,7 +21,7 @@ use crate::{ }, log::prelude::*, media::{ - New, Peer, PeerError, PeerId, PeerStateMachine, WaitLocalHaveRemote, + New, Peer, PeerError, PeerStateMachine, WaitLocalHaveRemote, WaitLocalSdp, WaitRemoteSdp, }, shutdown::ShutdownGracefully, From d5aac4bb0c7fa6bb02ace391f1b8a3718afb5f67 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 2 Aug 2019 17:12:23 +0300 Subject: [PATCH 423/735] Fix lints --- proto/client-api/src/lib.rs | 4 ++-- src/media/peer.rs | 2 +- src/signalling/elements/member.rs | 2 +- src/signalling/peers.rs | 8 ++++---- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/proto/client-api/src/lib.rs b/proto/client-api/src/lib.rs index d163ae999..65a8bb32c 100644 --- a/proto/client-api/src/lib.rs +++ b/proto/client-api/src/lib.rs @@ -29,13 +29,13 @@ pub trait Incrementable: Sized + Clone { impl Incrementable for PeerId { fn increment(&self) -> Self { - PeerId(self.0 + 1) + Self(self.0 + 1) } } impl Incrementable for TrackId { fn increment(&self) -> Self { - TrackId(self.0 + 1) + Self(self.0 + 1) } } diff --git a/src/media/peer.rs b/src/media/peer.rs index 7e6c8f187..d58ed5641 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -358,7 +358,7 @@ impl Peer { impl Peer { pub fn get_mids(&self) -> Result, PeerError> { let mut mids = HashMap::with_capacity(self.context.senders.len()); - for (track_id, track) in self.context.senders.iter() { + for (track_id, track) in &self.context.senders { mids.insert( *track_id, track diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index 54c2c5be8..2aa815dbc 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -325,7 +325,7 @@ pub fn parse_members( ); } - for (_, member) in &members { + for member in members.values() { member.load(room_spec, &members)?; } diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index 7ea082121..83ee0dcf6 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -116,7 +116,7 @@ impl PeerRepository { member_id: &MemberId, partner_member_id: &MemberId, ) -> Option<(PeerId, PeerId)> { - for (_, peer) in &self.peers { + for peer in self.peers.values() { if &peer.member_id() == member_id && &peer.partner_member_id() == partner_member_id { @@ -191,18 +191,18 @@ impl PeerRepository { .for_each(|partner_peer| { peers_to_remove .entry(partner_peer.member_id()) - .or_insert(Vec::new()) + .or_insert_with(Vec::new) .push(partner_peer.id()); }); peers_to_remove .entry(peer.partner_member_id()) - .or_insert(Vec::new()) + .or_insert_with(Vec::new) .push(peer.id()); peers_to_remove .entry(peer.member_id()) - .or_insert(Vec::new()) + .or_insert_with(Vec::new) .push(peer.id()); }); From 1e37b014ef6d868ef98142a3c42fb3b8285bea66 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 2 Aug 2019 17:45:10 +0300 Subject: [PATCH 424/735] Use impl Iterator --- src/api/control/member.rs | 32 ++++++++++++++++++++----------- src/signalling/elements/member.rs | 7 +++---- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/src/api/control/member.rs b/src/api/control/member.rs index 987e513cc..9b282cc11 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -1,6 +1,6 @@ //! Member definitions and implementations. -use std::{collections::HashMap, convert::TryFrom}; +use std::{convert::TryFrom}; use macro_attr::*; use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; @@ -55,20 +55,31 @@ pub struct MemberSpec { impl MemberSpec { /// Returns all [`WebRtcPlayEndpoint`]s of this [`MemberSpec`]. - pub fn play_endpoints(&self) -> HashMap<&String, &WebRtcPlayEndpoint> { - self.pipeline - .iter() - .filter_map(|(id, e)| match e { - MemberElement::WebRtcPlayEndpoint { spec } => Some((id, spec)), - _ => None, - }) - .collect() + pub fn play_endpoints( + &self, + ) -> impl Iterator { + self.pipeline.iter().filter_map(|(id, e)| match e { + MemberElement::WebRtcPlayEndpoint { spec } => Some((id, spec)), + _ => None, + }) + } + + pub fn get_publish_endpoint( + &self, + id: &str, + ) -> Option<&WebRtcPublishEndpoint> { + let e = self.pipeline.get(id)?; + if let MemberElement::WebRtcPublishEndpoint { spec } = e { + Some(spec) + } else { + None + } } /// Returns all [`WebRtcPublishEndpoint`]s of this [`MemberSpec`]. pub fn publish_endpoints( &self, - ) -> HashMap<&String, &WebRtcPublishEndpoint> { + ) -> impl Iterator { self.pipeline .iter() .filter_map(|(id, e)| match e { @@ -77,7 +88,6 @@ impl MemberSpec { } _ => None, }) - .collect() } pub fn credentials(&self) -> &str { diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index 2aa815dbc..280540473 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -117,9 +117,8 @@ impl Member { )?, )?; - let publisher_endpoint = *publisher_spec - .publish_endpoints() - .get(&spec_play_endpoint.src.endpoint_id) + let publisher_endpoint = publisher_spec + .get_publish_endpoint(&spec_play_endpoint.src.endpoint_id) .map_or( Err(MembersLoadError::EndpointNotFound( spec_play_endpoint.src.endpoint_id.clone(), @@ -173,7 +172,7 @@ impl Member { // This is necessary to create [`WebRtcPublishEndpoint`], // to which none [`WebRtcPlayEndpoint`] refers. - this_member_spec.publish_endpoints().into_iter().for_each( + this_member_spec.publish_endpoints().for_each( |(name, e)| { let endpoint_id = WebRtcPublishId(name.clone()); if self.srcs().get(&endpoint_id).is_none() { From 759246372e7bf9f651a0a8737a1e12ac0b8caff5 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 2 Aug 2019 19:41:49 +0300 Subject: [PATCH 425/735] Cfg attr for TrackId, PeerId and incrementable --- proto/client-api/src/lib.rs | 21 +++++++++++++++++---- src/api/control/member.rs | 14 +++++--------- src/signalling/elements/member.rs | 24 +++++++++++------------- 3 files changed, 33 insertions(+), 26 deletions(-) diff --git a/proto/client-api/src/lib.rs b/proto/client-api/src/lib.rs index 65a8bb32c..2f9693296 100644 --- a/proto/client-api/src/lib.rs +++ b/proto/client-api/src/lib.rs @@ -7,32 +7,45 @@ use serde::{de::Deserializer, ser::Serializer, Deserialize, Serialize}; macro_attr! { /// ID of [`Peer`]. - #[cfg_attr(feature = "medea", derive(Deserialize))] + #[cfg_attr( + feature = "medea", + derive(Deserialize, Debug, Hash, Eq, Default, PartialEq) + )] #[cfg_attr(feature = "jason", derive(Serialize))] #[cfg_attr(test, derive(Debug, PartialEq ))] - #[derive(Clone, Copy, NewtypeDisplay!, PartialEq, Debug, Hash, Eq, Default)] + #[derive(Clone, Copy, NewtypeDisplay!)] pub struct PeerId(pub u64); } macro_attr! { /// ID of [`MediaTrack`]. - #[cfg_attr(feature = "medea", derive(Deserialize))] + #[cfg_attr( + feature = "medea", + derive(Deserialize, Debug, Hash, Eq, Default, PartialEq) + )] #[cfg_attr(feature = "jason", derive(Serialize))] #[cfg_attr(test, derive(Debug, PartialEq ))] - #[derive(Clone, Copy, NewtypeDisplay!, PartialEq, Debug, Hash, Eq, Default)] + #[derive(Clone, Copy, NewtypeDisplay!)] pub struct TrackId(pub u64); } +/// Trait for providing function `increment()` which return current value + 1. +#[cfg(feature = "medea")] pub trait Incrementable: Sized + Clone { + /// Returns current value + 1. + /// + /// This function don't mutate `self`. fn increment(&self) -> Self; } +#[cfg(feature = "medea")] impl Incrementable for PeerId { fn increment(&self) -> Self { Self(self.0 + 1) } } +#[cfg(feature = "medea")] impl Incrementable for TrackId { fn increment(&self) -> Self { Self(self.0 + 1) diff --git a/src/api/control/member.rs b/src/api/control/member.rs index 9b282cc11..7d5052d5c 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -1,6 +1,6 @@ //! Member definitions and implementations. -use std::{convert::TryFrom}; +use std::convert::TryFrom; use macro_attr::*; use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; @@ -80,14 +80,10 @@ impl MemberSpec { pub fn publish_endpoints( &self, ) -> impl Iterator { - self.pipeline - .iter() - .filter_map(|(id, e)| match e { - MemberElement::WebRtcPublishEndpoint { spec } => { - Some((id, spec)) - } - _ => None, - }) + self.pipeline.iter().filter_map(|(id, e)| match e { + MemberElement::WebRtcPublishEndpoint { spec } => Some((id, spec)), + _ => None, + }) } pub fn credentials(&self) -> &str { diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index 280540473..e9b3e76f5 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -172,19 +172,17 @@ impl Member { // This is necessary to create [`WebRtcPublishEndpoint`], // to which none [`WebRtcPlayEndpoint`] refers. - this_member_spec.publish_endpoints().for_each( - |(name, e)| { - let endpoint_id = WebRtcPublishId(name.clone()); - if self.srcs().get(&endpoint_id).is_none() { - self.insert_src(WebRtcPublishEndpoint::new( - endpoint_id, - e.p2p.clone(), - Vec::new(), - this_member.downgrade(), - )); - } - }, - ); + this_member_spec.publish_endpoints().for_each(|(name, e)| { + let endpoint_id = WebRtcPublishId(name.clone()); + if self.srcs().get(&endpoint_id).is_none() { + self.insert_src(WebRtcPublishEndpoint::new( + endpoint_id, + e.p2p.clone(), + Vec::new(), + this_member.downgrade(), + )); + } + }); Ok(()) } From 95672fc9ba3b3c233dfaf79d98ab2d26b738fa21 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 5 Aug 2019 12:41:42 +0300 Subject: [PATCH 426/735] Fix tests --- tests/e2e/signalling/three_pubs.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/e2e/signalling/three_pubs.rs b/tests/e2e/signalling/three_pubs.rs index e18ae60a7..afdd5e2b1 100644 --- a/tests/e2e/signalling/three_pubs.rs +++ b/tests/e2e/signalling/three_pubs.rs @@ -1,8 +1,7 @@ use std::{cell::Cell, rc::Rc}; use actix::{AsyncContext as _, Context, System}; -use medea::media::PeerId; -use medea_client_api_proto::{Direction, Event}; +use medea_client_api_proto::{Direction, Event, PeerId}; use crate::signalling::{CloseSocket, TestMember}; From b78ecd1fd2ccc92d66057790f2227d6037d7a61f Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 5 Aug 2019 13:45:50 +0300 Subject: [PATCH 427/735] Fix PeerId and TrackId in tests --- proto/client-api/src/lib.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/proto/client-api/src/lib.rs b/proto/client-api/src/lib.rs index 2f9693296..b0054366f 100644 --- a/proto/client-api/src/lib.rs +++ b/proto/client-api/src/lib.rs @@ -12,7 +12,6 @@ macro_attr! { derive(Deserialize, Debug, Hash, Eq, Default, PartialEq) )] #[cfg_attr(feature = "jason", derive(Serialize))] - #[cfg_attr(test, derive(Debug, PartialEq ))] #[derive(Clone, Copy, NewtypeDisplay!)] pub struct PeerId(pub u64); } @@ -24,7 +23,6 @@ macro_attr! { derive(Deserialize, Debug, Hash, Eq, Default, PartialEq) )] #[cfg_attr(feature = "jason", derive(Serialize))] - #[cfg_attr(test, derive(Debug, PartialEq ))] #[derive(Clone, Copy, NewtypeDisplay!)] pub struct TrackId(pub u64); } @@ -315,10 +313,10 @@ mod test { #[test] fn command() { let mut mids = HashMap::new(); - mids.insert(0, String::from("1")); + mids.insert(TrackId(0), String::from("1")); let command = ClientMsg::Command(Command::MakeSdpOffer { - peer_id: 77, + peer_id: PeerId(77), sdp_offer: "offer".to_owned(), mids, }); @@ -357,7 +355,7 @@ mod test { #[test] fn event() { let event = ServerMsg::Event(Event::SdpAnswerMade { - peer_id: 45, + peer_id: PeerId(45), sdp_answer: "answer".to_owned(), }); #[cfg_attr(nightly, rustfmt::skip)] From f8afc57b1cdc347ea1a1310900ff0c26249fada5 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 5 Aug 2019 20:06:41 +0300 Subject: [PATCH 428/735] Use macro for generating Incrementable trait implementation --- proto/client-api/src/lib.rs | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/proto/client-api/src/lib.rs b/proto/client-api/src/lib.rs index b0054366f..75e35bc20 100644 --- a/proto/client-api/src/lib.rs +++ b/proto/client-api/src/lib.rs @@ -36,19 +36,21 @@ pub trait Incrementable: Sized + Clone { fn increment(&self) -> Self; } -#[cfg(feature = "medea")] -impl Incrementable for PeerId { - fn increment(&self) -> Self { - Self(self.0 + 1) - } +/// Implement [`Incrementable`] trait for newtype with any numeric type. +macro_rules! impl_incrementable { + ($name:ty) => { + impl Incrementable for $name { + fn increment(&self) -> Self { + Self(self.0 + 1) + } + } + }; } #[cfg(feature = "medea")] -impl Incrementable for TrackId { - fn increment(&self) -> Self { - Self(self.0 + 1) - } -} +impl_incrementable!(PeerId); +#[cfg(feature = "medea")] +impl_incrementable!(TrackId); // TODO: should be properly shared between medea and jason #[allow(dead_code)] From 6a5ddac1ff97415897a71b48df989630964ac056 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 6 Aug 2019 16:39:29 +0300 Subject: [PATCH 429/735] Fix e2e test --- src/turn/service.rs | 28 +++++++++++------------ tests/e2e/signalling/pub_sub_signallng.rs | 6 ++--- tests/e2e/signalling/three_pubs.rs | 6 ++--- 3 files changed, 19 insertions(+), 21 deletions(-) diff --git a/src/turn/service.rs b/src/turn/service.rs index 8cfd14068..f8bffbfe7 100644 --- a/src/turn/service.rs +++ b/src/turn/service.rs @@ -242,21 +242,19 @@ impl Handler for Service { self.new_password(TURN_PASS_LEN), ); - Box::new( - self.turn_db.insert(&ice_user).into_actor(self).then( - move |result, act, _| { - wrap_future(match result { - Ok(_) => ok(ice_user), - Err(e) => match msg.policy { - UnreachablePolicy::ReturnErr => err(e.into()), - UnreachablePolicy::ReturnStatic => { - ok(act.static_user()) - } - }, - }) - }, - ), - ) + Box::new(self.turn_db.insert(&ice_user).into_actor(self).then( + move |result, act, _| { + wrap_future(match result { + Ok(_) => ok(ice_user), + Err(e) => match msg.policy { + UnreachablePolicy::ReturnErr => err(e.into()), + UnreachablePolicy::ReturnStatic => { + ok(act.static_user()) + } + }, + }) + }, + )) } } diff --git a/tests/e2e/signalling/pub_sub_signallng.rs b/tests/e2e/signalling/pub_sub_signallng.rs index 842cc4f84..fbd512e39 100644 --- a/tests/e2e/signalling/pub_sub_signallng.rs +++ b/tests/e2e/signalling/pub_sub_signallng.rs @@ -36,15 +36,15 @@ fn pub_sub_video_call() { assert_eq!(ice_servers.len(), 2); assert_eq!( ice_servers[0].urls[0], - "stun:127.0.0.1:3478".to_string() + "stun:localhost:3478".to_string() ); assert_eq!( ice_servers[1].urls[0], - "turn:127.0.0.1:3478".to_string() + "turn:localhost:3478".to_string() ); assert_eq!( ice_servers[1].urls[1], - "turn:127.0.0.1:3478?transport=tcp".to_string() + "turn:localhost:3478?transport=tcp".to_string() ); if sdp_offer.is_some() { diff --git a/tests/e2e/signalling/three_pubs.rs b/tests/e2e/signalling/three_pubs.rs index afdd5e2b1..be5112478 100644 --- a/tests/e2e/signalling/three_pubs.rs +++ b/tests/e2e/signalling/three_pubs.rs @@ -28,15 +28,15 @@ fn three_members_p2p_video_call() { assert_eq!(ice_servers.len(), 2); assert_eq!( ice_servers[0].urls[0], - "stun:127.0.0.1:3478".to_string() + "stun:localhost:3478".to_string() ); assert_eq!( ice_servers[1].urls[0], - "turn:127.0.0.1:3478".to_string() + "turn:localhost:3478".to_string() ); assert_eq!( ice_servers[1].urls[1], - "turn:127.0.0.1:3478?transport=tcp".to_string() + "turn:localhost:3478?transport=tcp".to_string() ); peer_created_count += 1; From 5f74b078cc23a86621a1dd64d8d30e77d0fbaeb9 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 6 Aug 2019 20:03:53 +0300 Subject: [PATCH 430/735] Add Travis CI file --- .travis.yml | 37 +++++++++++++++++++++++++++++++++++++ Makefile | 4 ---- 2 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..230ae9b5b --- /dev/null +++ b/.travis.yml @@ -0,0 +1,37 @@ +language: rust + +matrix: + include: + - rust: stable + - rust: beta + - rust: nightly + + - rust: stable + name: clippy + before_script: + - rustup component add clippy + script: + - cargo clippy + + - rust: nightly + name: rustfmt + before_script: + - rustup component add rustfmt + script: + make fmt check=yes + + allow_failures: + - rust: nightly + +install: + - rustc -vV + - cargo -vV + +script: + - cargo build + - make test.unit + +notifications: + email: + on_success: never + on_failure: always diff --git a/Makefile b/Makefile index cf1d461b9..69b6d730e 100644 --- a/Makefile +++ b/Makefile @@ -206,14 +206,10 @@ ifeq ($(test-unit-crate),@all) @make test.unit crate=medea-client-api-proto @make test.unit crate=medea-macro @make test.unit crate=medea - @make test.unit crate=jason else ifeq ($(test-unit-crate),medea) cargo test --bin medea else -ifeq ($(test-unit-crate),jason) - wasm-pack test --headless --firefox jason -endif cargo test -p $(test-unit-crate) endif endif From 1687129f3724f2482e49d67b594d3503e9c87840 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 7 Aug 2019 12:05:21 +0300 Subject: [PATCH 431/735] Add docker service --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 230ae9b5b..443b9d046 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,8 @@ language: rust +services: + - docker + matrix: include: - rust: stable From 3eb1512ecb03c6e07c0cfbe47bbf34a3833696c7 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 7 Aug 2019 13:55:25 +0300 Subject: [PATCH 432/735] Fix all docs --- .clippy.toml | 3 ++- jason/src/api/connection.rs | 8 +++---- jason/src/api/mod.rs | 5 +++-- jason/src/peer/mod.rs | 12 +++++------ jason/src/rpc/mod.rs | 2 +- src/api/client/mod.rs | 4 +++- src/api/client/rpc_connection.rs | 22 ++++++++++++++++++- src/api/client/server.rs | 2 ++ src/api/client/session.rs | 2 ++ src/api/control/member.rs | 2 +- src/api/control/mod.rs | 4 +++- src/conf/mod.rs | 1 + src/conf/turn.rs | 4 ++++ src/media/ice_user.rs | 4 ++++ src/media/mod.rs | 1 + src/media/peer.rs | 14 +++++++++++-- src/shutdown.rs | 1 + src/signalling/mod.rs | 6 ++++++ src/signalling/participants.rs | 12 +++++++---- src/signalling/peers.rs | 10 +++++++++ src/signalling/room.rs | 8 ++++++- src/turn/mod.rs | 5 +++++ src/turn/service.rs | 36 ++++++++++++++++++-------------- src/utils/mod.rs | 4 +++- 24 files changed, 130 insertions(+), 42 deletions(-) diff --git a/.clippy.toml b/.clippy.toml index 3d6b6c5d3..1117319cd 100644 --- a/.clippy.toml +++ b/.clippy.toml @@ -13,5 +13,6 @@ doc-valid-idents = [ "RTCConfiguration", "RTCIceCandidate", "RTCIceServer", "RTCPeerConnection", "RTCPeerConnectionIceEvent", "RTCRtpTransceiver", "RTCRtpTransceiverDirection", - "RTCSdpType", "RTCIceCandidateInit" + "RTCSdpType", "RTCIceCandidateInit", + "WebRTC", "RtcPeerConnection", ] diff --git a/jason/src/api/connection.rs b/jason/src/api/connection.rs index 5a43079e2..db134ab53 100644 --- a/jason/src/api/connection.rs +++ b/jason/src/api/connection.rs @@ -1,4 +1,4 @@ -//! Connection with specific remote [`Member`]. +//! Connection with specific remote `Member`. use std::{ cell::RefCell, @@ -21,7 +21,7 @@ struct InnerConnection { on_remote_stream: Callback, } -/// Connection with a specific remote [`Member`], that is used on JS side. +/// Connection with a specific remote `Member`, that is used on JS side. /// /// Actually, represents a [`Weak`]-based handle to [`InnerConnection`]. #[allow(clippy::module_name_repetitions)] @@ -30,7 +30,7 @@ pub struct ConnectionHandle(Weak>); #[wasm_bindgen] impl ConnectionHandle { - /// Sets callback, which will be invoked on remote [`Member`] media stream + /// Sets callback, which will be invoked on remote `Member` media stream /// arrival. pub fn on_remote_stream( &mut self, @@ -44,7 +44,7 @@ impl ConnectionHandle { .ok_or_else(|| WasmErr::from("Detached state").into()) } - /// Returns ID of the remote [`Member`]. + /// Returns ID of the remote `Member`. pub fn member_id(&self) -> Result { self.0 .upgrade() diff --git a/jason/src/api/mod.rs b/jason/src/api/mod.rs index 0a0251856..6e94ee111 100644 --- a/jason/src/api/mod.rs +++ b/jason/src/api/mod.rs @@ -70,8 +70,9 @@ impl Jason { } /// Sets `on_local_stream` callback, which will be invoked once media - /// acquisition request will resolve returning [`MediaStreamHandle`] or - /// [`WasmErr`]. + /// acquisition request will resolve returning + /// [`MediaStreamHandle`](crate::media::MediaStreamHandle) or + /// [`WasmErr`](crate::utils::errors::WasmErr). pub fn on_local_stream(&self, f: js_sys::Function) { self.0.borrow_mut().media_manager.set_on_local_stream(f); } diff --git a/jason/src/peer/mod.rs b/jason/src/peer/mod.rs index 981df698a..a17f584a4 100644 --- a/jason/src/peer/mod.rs +++ b/jason/src/peer/mod.rs @@ -161,8 +161,8 @@ impl PeerConnection { self.0.media_connections.get_mids() } - /// Sync provided tracks creating all required [`Sender`]s and - /// [`Receiver`]s, request local stream if required, get, set and return + /// Sync provided tracks creating all required `Sender`s and + /// `Receiver`s, request local stream if required, get, set and return /// sdp offer. pub fn get_offer( &self, @@ -215,11 +215,11 @@ impl PeerConnection { self.0.peer.set_remote_description(SdpType::Answer(answer)) } - /// Sync provided tracks creating all required [`Sender`]s and - /// [`Receiver`]s, request local stream if required. + /// Sync provided tracks creating all required `Sender`s and + /// `Receiver`s, request local stream if required. /// `set_remote_description` will create all transceivers and fire all - /// `on_track` events, so it updates [`Receiver`]s before - /// `set_remote_description` and update [`Sender`]s after. + /// `on_track` events, so it updates `Receiver`s before + /// `set_remote_description` and update `Sender`s after. /// /// [1]: https://www.w3.org/TR/webrtc/#rtcpeerconnection-interface pub fn process_offer( diff --git a/jason/src/rpc/mod.rs b/jason/src/rpc/mod.rs index 87c0a52f6..79e8ff246 100644 --- a/jason/src/rpc/mod.rs +++ b/jason/src/rpc/mod.rs @@ -102,7 +102,7 @@ impl RpcClient { } /// Creates new WebSocket connection to remote media server. - /// Starts [`Heatbeat`] if connection succeeds and binds handlers + /// Starts `Heartbeat` if connection succeeds and binds handlers /// on receiving messages from server and closing socket. pub fn init(&mut self) -> impl Future { let inner = Rc::clone(&self.0); diff --git a/src/api/client/mod.rs b/src/api/client/mod.rs index 81bf83f8e..c1157a9e5 100644 --- a/src/api/client/mod.rs +++ b/src/api/client/mod.rs @@ -1,4 +1,6 @@ -//! Implementation of Client API. +//! Implementation of [Client API]. +//! +//! [Client API]: http://tiny.cc/c80uaz mod session; diff --git a/src/api/client/rpc_connection.rs b/src/api/client/rpc_connection.rs index a5e6a8c64..611a12155 100644 --- a/src/api/client/rpc_connection.rs +++ b/src/api/client/rpc_connection.rs @@ -1,4 +1,5 @@ -//! [`RpcConnection`] with related messages. +//! [`RpcConnection`](crate::api::client::rpc_connection::RpcConnection) with +//! related messages. use std::fmt; @@ -23,6 +24,8 @@ macro_attr! { } /// Abstraction over RPC connection with some remote [`Member`]. +/// +/// [`Member`]: crate::api::control::member::Member pub trait RpcConnection: fmt::Debug + Send { /// Closes [`RpcConnection`]. /// No [`RpcConnectionClosed`] signals should be emitted. @@ -30,6 +33,8 @@ pub trait RpcConnection: fmt::Debug + Send { fn close(&mut self) -> Box>; /// Sends [`Event`] to remote [`Member`]. + /// + /// [`Member`]: crate::api::control::member::Member fn send_event( &self, msg: EventMessage, @@ -41,15 +46,22 @@ pub trait RpcConnection: fmt::Debug + Send { #[rtype(result = "Result<(), AuthorizationError>")] pub struct Authorize { /// ID of [`Member`] to authorize [`RpcConnection`] for. + /// + /// [`Member`]: crate::api::control::member::Member pub member_id: MemberId, /// Credentials to authorize [`RpcConnection`] with. pub credentials: String, // TODO: &str when futures will allow references } /// Error of authorization [`RpcConnection`] in [`Room`]. +/// +/// [`Room`]: crate::signalling::Room #[derive(Debug)] pub enum AuthorizationError { /// Authorizing [`Member`] does not exists in the [`Room`]. + /// + /// [`Member`]: crate::api::control::member::Member + /// [`Room`]: crate::signalling::Room MemberNotExists, /// Provided credentials are invalid. InvalidCredentials, @@ -57,20 +69,28 @@ pub enum AuthorizationError { /// Signal of new [`RpcConnection`] being established with specified [`Member`]. /// Transport should consider dropping connection if message result is err. +/// +/// [`Member`]: crate::api::control::member::Member #[derive(Debug, Message)] #[rtype(result = "Result<(), ()>")] #[allow(clippy::module_name_repetitions)] pub struct RpcConnectionEstablished { /// ID of [`Member`] that establishes [`RpcConnection`]. + /// + /// [`Member`]: crate::api::control::member::Member pub member_id: MemberId, /// Established [`RpcConnection`]. pub connection: Box, } /// Signal of existing [`RpcConnection`] of specified [`Member`] being closed. +/// +/// [`Member`]: crate::api::control::member::Member #[derive(Debug, Message)] #[allow(clippy::module_name_repetitions)] pub struct RpcConnectionClosed { /// ID of [`Member`] which [`RpcConnection`] is closed. + /// + /// [`Member`]: crate::api::control::member::Member pub member_id: MemberId, /// Reason of why [`RpcConnection`] is closed. pub reason: ClosedReason, diff --git a/src/api/client/server.rs b/src/api/client/server.rs index 7f1fe7d7f..2e555928b 100644 --- a/src/api/client/server.rs +++ b/src/api/client/server.rs @@ -83,6 +83,8 @@ fn ws_index( /// Context for [`App`] which holds all the necessary dependencies. pub struct Context { /// Repository of all currently existing [`Room`]s in application. + /// + /// [`Room`]: crate::signalling::Room pub rooms: RoomsRepository, /// Settings of application. diff --git a/src/api/client/session.rs b/src/api/client/session.rs index 56e460f5c..bdcc4ca46 100644 --- a/src/api/client/session.rs +++ b/src/api/client/session.rs @@ -159,6 +159,8 @@ impl RpcConnection for Addr { } /// Sends [`Event`] to Web Client. + /// + /// [`Event`]: medea_client_api_proto::Event fn send_event( &self, msg: EventMessage, diff --git a/src/api/control/member.rs b/src/api/control/member.rs index 318483547..dfacdfbe4 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -19,7 +19,7 @@ pub struct Member { } impl Member { - /// Returns new instance of [`Memebr`] with given credentials. + /// Returns new instance of [`Member`] with given credentials. pub fn new(id: Id, credentials: String) -> Self { Self { id, diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index db3c38fcd..929e0fd13 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -1,4 +1,6 @@ -//! Implementation of Control API. +//! Implementation of [Control API]. +//! +//! [Control API]: http://tiny.cc/380uaz mod member; diff --git a/src/conf/mod.rs b/src/conf/mod.rs index dc10a2b83..ac5f29a6a 100644 --- a/src/conf/mod.rs +++ b/src/conf/mod.rs @@ -12,6 +12,7 @@ use config::{Config, Environment, File}; use failure::Error; use serde::{Deserialize, Serialize}; +#[doc(inline)] pub use self::{ log::Log, rpc::Rpc, diff --git a/src/conf/turn.rs b/src/conf/turn.rs index 4a6bc373a..56b5394f9 100644 --- a/src/conf/turn.rs +++ b/src/conf/turn.rs @@ -44,6 +44,10 @@ pub struct Db { pub redis: Redis, } +/// Setting of [Redis] server which used by [coturn]. +/// +/// [Redis]: https://redis.io/ +/// [coturn]: https://github.com/coturn/coturn #[derive(Clone, Debug, Deserialize, Serialize, SmartDefault)] #[serde(default)] pub struct Redis { diff --git a/src/media/ice_user.rs b/src/media/ice_user.rs index ba0de8129..e102ac605 100644 --- a/src/media/ice_user.rs +++ b/src/media/ice_user.rs @@ -1,3 +1,7 @@ +//! Representation of [coturn]'s user. +//! +//! [coturn]: https://github.com/coturn/coturn + use medea_client_api_proto::IceServer; use crate::signalling::RoomId; diff --git a/src/media/mod.rs b/src/media/mod.rs index e2f3f9f8a..54adde694 100644 --- a/src/media/mod.rs +++ b/src/media/mod.rs @@ -3,6 +3,7 @@ pub mod ice_user; pub mod peer; pub mod track; +#[doc(inline)] pub use self::{ ice_user::IceUser, peer::{ diff --git a/src/media/peer.rs b/src/media/peer.rs index 366291b26..a6bf67c9b 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -158,7 +158,9 @@ pub struct Context { senders: HashMap>, } -/// [`RTCPeerConnection`] representation. +/// [RtcPeerConnection] representation. +/// +/// [RtcPeerConnection]: https://webrtcglossary.com/peerconnection/ #[derive(Debug)] pub struct Peer { context: Context, @@ -167,6 +169,8 @@ pub struct Peer { impl Peer { /// Returns ID of [`Member`] associated with this [`Peer`]. + /// + /// [`Member`]: crate::api::control::member::Member pub fn member_id(&self) -> MemberId { self.context.member_id } @@ -182,6 +186,8 @@ impl Peer { } /// Returns ID of interconnected [`Member`]. + /// + /// [`Member`]: crate::api::control::member::Member pub fn partner_member_id(&self) -> Id { self.context.partner_member } @@ -226,6 +232,8 @@ impl Peer { impl Peer { /// Creates new [`Peer`] for [`Member`]. + /// + /// [`Member`]: crate::api::control::member::Member pub fn new( id: Id, member_id: MemberId, @@ -282,7 +290,7 @@ impl Peer { impl Peer { /// Sets local description and transition [`Peer`] - /// to [`WaitRemoteSDP`] state. + /// to [`WaitRemoteSdp`] state. pub fn set_local_sdp(self, sdp_offer: String) -> Peer { let mut context = self.context; context.sdp_offer = Some(sdp_offer); @@ -354,6 +362,8 @@ impl Peer { } /// Creates 1<=>1 [`Room`]. +/// +/// [`Room`]: crate::signalling::Room #[cfg(not(test))] pub fn create_peers( caller: MemberId, diff --git a/src/shutdown.rs b/src/shutdown.rs index 83091a2dc..11d2192ac 100644 --- a/src/shutdown.rs +++ b/src/shutdown.rs @@ -199,6 +199,7 @@ impl Handler for GracefulShutdown { } } +/// Error which indicates that process is shutting down at this moment. #[derive(Clone, Copy, Debug, Fail)] #[fail(display = "Process is shutting down at the moment")] pub struct ShuttingDownError; diff --git a/src/signalling/mod.rs b/src/signalling/mod.rs index ddf76119c..cad32e4b0 100644 --- a/src/signalling/mod.rs +++ b/src/signalling/mod.rs @@ -1,8 +1,14 @@ +//! [WebRTC] [signalling] related implementations. +//! +//! [WebRTC]: https://webrtcglossary.com/webrtc/ +//! [signalling]: https://webrtcglossary.com/signaling/ + pub mod participants; pub mod peers; pub mod room; pub mod room_repo; +#[doc(inline)] pub use self::{ room::{Id as RoomId, Room}, room_repo::RoomsRepository, diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 13a48f3a3..7936a85ee 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -1,7 +1,11 @@ //! Participant is [`Member`] with [`RpcConnection`]. [`ParticipantService`] -//! stores [`Members`] and associated [`RpcConnection`]s, handles +//! stores [`Member`]s and associated [`RpcConnection`]s, handles //! [`RpcConnection`] authorization, establishment, message sending, Turn //! credentials management. +//! +//! [`Member`]: crate::api::control::member::Member +//! [`RpcConnection`]: crate::api::client::rpc_connection::RpcConnection +//! [`ParticipantService`]: crate::signalling::participants::ParticipantService use std::{ sync::Arc, @@ -63,7 +67,7 @@ impl From for ParticipantServiceErr { } /// Participant is [`Member`] with [`RpcConnection`]. [`ParticipantService`] -/// stores [`Members`] and associated [`RpcConnection`]s, handles +/// stores [`Member`]s and associated [`RpcConnection`]s, handles /// [`RpcConnection`] authorization, establishment, message sending. #[derive(Debug)] pub struct ParticipantService { @@ -141,7 +145,7 @@ impl ParticipantService { self.members.insert(member.id, member); } - /// Checks if [`Member`] has **active** [`RcpConnection`]. + /// Checks if [`Member`] has **active** [`RpcConnection`]. pub fn member_has_connection(&self, member_id: MemberId) -> bool { self.connections.contains_key(&member_id) && !self.drop_connection_tasks.contains_key(&member_id) @@ -164,7 +168,7 @@ impl ParticipantService { } } - /// Saves provided [`RpcConnection`], registers [`ICEUser`]. + /// Saves provided [`RpcConnection`], registers [`IceUser`]. /// If [`Member`] already has any other [`RpcConnection`], /// then it will be closed. pub fn connection_established( diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index 506c0ac04..c041dcec6 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -1,4 +1,7 @@ //! Repository that stores [`Room`]s [`Peer`]s. +//! +//! [`Room`]: crate::signalling::Room +//! [`Peer`]: crate::media::peer::Peer use hashbrown::HashMap; @@ -13,11 +16,16 @@ use crate::{ #[derive(Debug)] pub struct PeerRepository { /// [`Peer`]s of [`Member`]s in this [`Room`]. + /// + /// [`Member`]: crate::api::control::member::Member + /// [`Room`]: crate::signalling::Room peers: HashMap, } impl PeerRepository { /// Store [`Peer`] in [`Room`]. + /// + /// [`Room`]: crate::signalling::Room pub fn add_peer>(&mut self, peer: S) { let peer = peer.into(); self.peers.insert(peer.id(), peer); @@ -51,6 +59,8 @@ impl PeerRepository { /// Returns [`Peer`] of specified [`Member`]. /// /// Panic if [`Peer`] not exists. + /// + /// [`Member`]: crate::api::control::member::Member pub fn get_peers_by_member_id( &self, member_id: MemberId, diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 9286ee56c..77d53ff0b 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -1,5 +1,7 @@ //! Room definitions and implementations. Room is responsible for media //! connection establishment between concrete [`Member`]s. +//! +//! [`Member`]: crate::api::control::member::Member use std::{collections::HashMap as StdHashMap, sync::Arc, time::Duration}; @@ -83,6 +85,8 @@ pub struct Room { id: Id, /// [`RpcConnection`]s of [`Member`]s in this [`Room`]. + /// + /// [`RpcConnection`]: crate::api::client::rpc_connection::RpcConnection pub participants: ParticipantService, /// [`Peer`]s of [`Member`]s in this [`Room`]. @@ -372,7 +376,7 @@ impl Handler for Room { type Result = ActFuture<(), ()>; /// Receives [`Command`] from Web client and passes it to corresponding - /// handlers. Will emit [`CloseRoom`] on any error. + /// handlers. Will emit `CloseRoom` on any error. fn handle( &mut self, msg: CommandMessage, @@ -423,6 +427,8 @@ impl Handler for Room { /// Saves new [`RpcConnection`] in [`ParticipantService`], initiates media /// establishment between members. + /// + /// [`RpcConnection`]: crate::api::client::rpc_connection::RpcConnection fn handle( &mut self, msg: RpcConnectionEstablished, diff --git a/src/turn/mod.rs b/src/turn/mod.rs index aa4b70c18..b62c656cb 100644 --- a/src/turn/mod.rs +++ b/src/turn/mod.rs @@ -1,6 +1,11 @@ +//! [TURN] server managing implementation. +//! +//! [TURN]: https://webrtcglossary.com/turn/ + pub mod repo; pub mod service; +#[doc(inline)] pub use self::service::{ new_turn_auth_service, TurnAuthService, TurnServiceErr, UnreachablePolicy, }; diff --git a/src/turn/service.rs b/src/turn/service.rs index 70050deec..0f1719c6a 100644 --- a/src/turn/service.rs +++ b/src/turn/service.rs @@ -1,3 +1,8 @@ +//! Implementation of managing [coturn] [TURN] server. +//! +//! [coturn]: https://github.com/coturn/coturn +//! [TURN]: https://webrtcglossary.com/turn/ + use std::{fmt, sync::Arc}; use actix::{ @@ -64,7 +69,7 @@ impl TurnAuthService for Addr { ) } - /// Sends [`DeleteRoom`] to [`Service`]. + /// Sends `DeleteRoom` to [`Service`]. fn delete( &self, users: Vec, @@ -91,6 +96,7 @@ impl TurnAuthService for Addr { type ActFuture = Box>; +/// Error which can happen in [`TurnAuthService`]. #[derive(Debug, Fail)] pub enum TurnServiceErr { #[fail(display = "Error accessing TurnAuthRepo: {}", _0)] @@ -239,21 +245,19 @@ impl Handler for Service { self.new_password(TURN_PASS_LEN), ); - Box::new( - self.turn_db.insert(&ice_user).into_actor(self).then( - move |result, act, _| { - wrap_future(match result { - Ok(_) => ok(ice_user), - Err(e) => match msg.policy { - UnreachablePolicy::ReturnErr => err(e.into()), - UnreachablePolicy::ReturnStatic => { - ok(act.static_user()) - } - }, - }) - }, - ), - ) + Box::new(self.turn_db.insert(&ice_user).into_actor(self).then( + move |result, act, _| { + wrap_future(match result { + Ok(_) => ok(ice_user), + Err(e) => match msg.policy { + UnreachablePolicy::ReturnErr => err(e.into()), + UnreachablePolicy::ReturnStatic => { + ok(act.static_user()) + } + }, + }) + }, + )) } } diff --git a/src/utils/mod.rs b/src/utils/mod.rs index 82d6712ad..e5ca8a211 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -1,6 +1,6 @@ //! Helper utils used in project. -/// Creates new [`hashbrown::HashMap`] from a list of key-value pairs. +/// Creates new [hashbrown] `HashMap` from a list of key-value pairs. /// /// ## Example /// @@ -13,6 +13,8 @@ /// assert_eq!(map["b"], 2); /// assert_eq!(map.get("c"), None); /// ``` +/// +/// [hashbrown]:https://crates.io/crates/hashbrown #[macro_export] macro_rules! hashmap { (@single $($x:tt)*) => (()); From da16b76180caaf4f3f6d637c27b0762549400083 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 7 Aug 2019 16:48:23 +0300 Subject: [PATCH 433/735] Rewrite travis CI with jobs --- .travis.yml | 63 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 36 insertions(+), 27 deletions(-) diff --git a/.travis.yml b/.travis.yml index 443b9d046..d23362cb8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,40 +1,49 @@ language: rust -services: - - docker - -matrix: - include: - - rust: stable - - rust: beta +jobs: + allow_failures: - rust: nightly + stage: build - - rust: stable - name: clippy - before_script: - - rustup component add clippy - script: - - cargo clippy - - - rust: nightly - name: rustfmt - before_script: - - rustup component add rustfmt - script: - make fmt check=yes + include: + - stage: lints + rust: nightly + name: "Clippy" + before_script: rustup component add clippy + script: make lint + + - stage: formatting + rust: nightly + name: "Rustfmt" + before_script: rustup component add rustfmt + script: make fmt check=yes + + - stage: build + rust: stable + name: "Build medea (Rust stable)" + script: cargo build + + - stage: build + rust: beta + name: "Build medea (Rust beta)" + script: cargo build + + - stage: build + rust: nightly + name: "Build medea (Rust nightly)" + script: cargo build + + - stage: tests + rust: stable + name: "Unit tests (Rust stable)" + script: make test.unit - allow_failures: - - rust: nightly install: - rustc -vV - cargo -vV -script: - - cargo build - - make test.unit - notifications: email: on_success: never - on_failure: always + on_failure: never # TODO: set to always when .travis.yml will be debugged From fbb93c06bccf98e5ebee38e65196680538dfea0b Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 7 Aug 2019 16:54:13 +0300 Subject: [PATCH 434/735] Fix clippy check on nightly --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d23362cb8..7420c7e85 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ jobs: include: - stage: lints - rust: nightly + rust: nightly-2019-08-03 # TODO: use nightly when clippy will be fixed name: "Clippy" before_script: rustup component add clippy script: make lint From be9ebc36138adf4883496b799574e823f0d3622a Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 7 Aug 2019 16:57:27 +0300 Subject: [PATCH 435/735] Fix clippy in Makefile --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 69b6d730e..90076920f 100644 --- a/Makefile +++ b/Makefile @@ -131,7 +131,7 @@ cargo.fmt: # make cargo.lint cargo.lint: - cargo +nightly clippy --all -- -D clippy::pedantic -D warnings + cargo +nightly-2019-08-03 clippy --all -- -D clippy::pedantic -D warnings From a04202fd99303849e150ca54657a713700151ce4 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 7 Aug 2019 17:18:52 +0300 Subject: [PATCH 436/735] Fix formatting with new version of rustfmt --- src/turn/service.rs | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/turn/service.rs b/src/turn/service.rs index 0f1719c6a..16faa570d 100644 --- a/src/turn/service.rs +++ b/src/turn/service.rs @@ -245,19 +245,21 @@ impl Handler for Service { self.new_password(TURN_PASS_LEN), ); - Box::new(self.turn_db.insert(&ice_user).into_actor(self).then( - move |result, act, _| { - wrap_future(match result { - Ok(_) => ok(ice_user), - Err(e) => match msg.policy { - UnreachablePolicy::ReturnErr => err(e.into()), - UnreachablePolicy::ReturnStatic => { - ok(act.static_user()) - } - }, - }) - }, - )) + Box::new( + self.turn_db.insert(&ice_user).into_actor(self).then( + move |result, act, _| { + wrap_future(match result { + Ok(_) => ok(ice_user), + Err(e) => match msg.policy { + UnreachablePolicy::ReturnErr => err(e.into()), + UnreachablePolicy::ReturnStatic => { + ok(act.static_user()) + } + }, + }) + }, + ), + ) } } From e10280aa21610d925d3af43b3d6dd44c9760953b Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 7 Aug 2019 17:25:41 +0300 Subject: [PATCH 437/735] Add cargo caching, build jason --- .travis.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.travis.yml b/.travis.yml index 7420c7e85..a3191c7aa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,7 @@ language: rust +cache: cargo + jobs: allow_failures: - rust: nightly @@ -18,6 +20,15 @@ jobs: before_script: rustup component add rustfmt script: make fmt check=yes + - stage: build + rust: stable + name: "Build jason (Rust stable)" + before_script: + - make yarn dockerized=no + - curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh + script: + - wasm-pack build -t web jason + - stage: build rust: stable name: "Build medea (Rust stable)" From 37508e5dc7b4bd6dce59585f4a369fdaa5ac005e Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 7 Aug 2019 19:51:42 +0300 Subject: [PATCH 438/735] Rename jason to medea-jason --- Cargo.lock | 40 ++++++++++++++++++++-------------------- jason/Cargo.toml | 2 +- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3b91c81e0..ce41421f5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -985,26 +985,6 @@ name = "itoa" version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "jason" -version = "0.1.0-dev" -dependencies = [ - "console_error_panic_hook 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", - "js-sys 0.3.25 (registry+https://github.com/rust-lang/crates.io-index)", - "macro-attr 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "medea-client-api-proto 0.1.0-dev", - "medea-macro 0.1.0-dev", - "newtype_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-futures 0.3.25 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-test 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", - "web-sys 0.3.25 (registry+https://github.com/rust-lang/crates.io-index)", - "wee_alloc 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "js-sys" version = "0.3.25" @@ -1169,6 +1149,26 @@ dependencies = [ "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "medea-jason" +version = "0.1.0-dev" +dependencies = [ + "console_error_panic_hook 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", + "js-sys 0.3.25 (registry+https://github.com/rust-lang/crates.io-index)", + "macro-attr 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "medea-client-api-proto 0.1.0-dev", + "medea-macro 0.1.0-dev", + "newtype_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-futures 0.3.25 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-test 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", + "web-sys 0.3.25 (registry+https://github.com/rust-lang/crates.io-index)", + "wee_alloc 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "medea-macro" version = "0.1.0-dev" diff --git a/jason/Cargo.toml b/jason/Cargo.toml index d5243c4bf..877a78931 100644 --- a/jason/Cargo.toml +++ b/jason/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "jason" +name = "medea-jason" version = "0.1.0-dev" edition = "2018" description = "Medea media server client application" From 6b21162b42a3a0a5915a85a2717008f97e0b97d9 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 7 Aug 2019 20:07:50 +0300 Subject: [PATCH 439/735] Fix wasm-pack installation --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index a3191c7aa..b06302b09 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,6 +24,7 @@ jobs: rust: stable name: "Build jason (Rust stable)" before_script: + - rm -f /home/travis/.cargo/bin/wasm-pack - make yarn dockerized=no - curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh script: From d9aa3e59dabd40a7d25abf7c44bcb95aca787baa Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 8 Aug 2019 12:20:00 +0300 Subject: [PATCH 440/735] Remove dev postfix from all versions, notifications in travis CI --- .travis.yml | 2 +- Cargo.lock | 18 +++++++++--------- Cargo.toml | 2 +- README.md | 4 +--- crates/medea-macro/Cargo.toml | 2 +- jason/Cargo.toml | 2 +- proto/client-api/Cargo.toml | 2 +- 7 files changed, 15 insertions(+), 17 deletions(-) diff --git a/.travis.yml b/.travis.yml index b06302b09..1e0a5164b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -58,4 +58,4 @@ install: notifications: email: on_success: never - on_failure: never # TODO: set to always when .travis.yml will be debugged + on_failure: always diff --git a/Cargo.lock b/Cargo.lock index ce41421f5..8ca548ff5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1100,7 +1100,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "medea" -version = "0.1.0-dev" +version = "0.1.0" dependencies = [ "actix 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)", "actix-http 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1117,8 +1117,8 @@ dependencies = [ "hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "macro-attr 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "medea-client-api-proto 0.1.0-dev", - "medea-macro 0.1.0-dev", + "medea-client-api-proto 0.1.0", + "medea-macro 0.1.0", "newtype_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "redis 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1142,23 +1142,23 @@ dependencies = [ [[package]] name = "medea-client-api-proto" -version = "0.1.0-dev" +version = "0.1.0" dependencies = [ - "medea-macro 0.1.0-dev", + "medea-macro 0.1.0", "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "medea-jason" -version = "0.1.0-dev" +version = "0.1.0" dependencies = [ "console_error_panic_hook 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "js-sys 0.3.25 (registry+https://github.com/rust-lang/crates.io-index)", "macro-attr 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "medea-client-api-proto 0.1.0-dev", - "medea-macro 0.1.0-dev", + "medea-client-api-proto 0.1.0", + "medea-macro 0.1.0", "newtype_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1171,7 +1171,7 @@ dependencies = [ [[package]] name = "medea-macro" -version = "0.1.0-dev" +version = "0.1.0" dependencies = [ "Inflector 0.11.4 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index 3882377d9..927ecd98f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "medea" -version = "0.1.0-dev" +version = "0.1.0" edition = "2018" description = "Medea media server" authors = ["Instrumentisto Team "] diff --git a/README.md b/README.md index b9f8434f3..13927d04e 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,6 @@ Medea -Medea media server +Medea media server. __DEVELOPMENT IN PROGRESS__ - -{"MakeSdpOffer":{"peer":0,"sdp_offer":"caller_offer"}} diff --git a/crates/medea-macro/Cargo.toml b/crates/medea-macro/Cargo.toml index a5332dca0..070a2a77a 100644 --- a/crates/medea-macro/Cargo.toml +++ b/crates/medea-macro/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "medea-macro" -version = "0.1.0-dev" +version = "0.1.0" edition = "2018" description = "Macros for Medea media server project" authors = ["Instrumentisto Team "] diff --git a/jason/Cargo.toml b/jason/Cargo.toml index 877a78931..e701e8594 100644 --- a/jason/Cargo.toml +++ b/jason/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "medea-jason" -version = "0.1.0-dev" +version = "0.1.0" edition = "2018" description = "Medea media server client application" authors = ["Instrumentisto Team "] diff --git a/proto/client-api/Cargo.toml b/proto/client-api/Cargo.toml index ab0d0e3f0..460626fb9 100644 --- a/proto/client-api/Cargo.toml +++ b/proto/client-api/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "medea-client-api-proto" -version = "0.1.0-dev" +version = "0.1.0" edition = "2018" description = "Client API protocol implementation for Medea media server" authors = ["Instrumentisto Team "] From ead9b505017592889bec9337f555ebd8ff0b9c64 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 8 Aug 2019 12:27:51 +0300 Subject: [PATCH 441/735] Add travis CI --- .travis.yml | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..e89f14fc3 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,69 @@ +language: rust + +cache: + cargo: true + directories: + - .cache + +jobs: + allow_failures: + - rust: nightly + stage: build + + include: + - stage: lints + rust: nightly-2019-08-03 # TODO: use nightly when clippy will be fixed + name: "Clippy" + before_script: rustup component add clippy + script: make lint + + - stage: formatting + rust: nightly + name: "Rustfmt" + before_script: rustup component add rustfmt + script: make fmt check=yes + + - stage: build + rust: stable + name: "Build jason (Rust stable)" + before_script: + - rm -f /home/travis/.cargo/bin/wasm-pack + - make yarn dockerized=no + - curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh + script: + - wasm-pack build -t web jason + + - stage: build + rust: stable + name: "Build medea (Rust stable)" + script: cargo build + + - stage: build + rust: beta + name: "Build medea (Rust beta)" + script: cargo build + + - stage: build + rust: nightly + name: "Build medea (Rust nightly)" + script: cargo build + + - stage: tests + rust: stable + name: "Unit tests (Rust stable)" + script: make test.unit + + - stage: tests + rust: stable + name: "E2E tests (Rust stable)" + script: make test.e2e + + +install: + - rustc -vV + - cargo -vV + +notifications: + email: + on_success: never + on_failure: never # TODO: set to always From 90840c2693a2f119a83f57178c4831b2b975e147 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 8 Aug 2019 12:31:06 +0300 Subject: [PATCH 442/735] Remove dummy jason test --- Makefile | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Makefile b/Makefile index fd08642de..dba3fd6dc 100644 --- a/Makefile +++ b/Makefile @@ -261,14 +261,10 @@ ifeq ($(test-unit-crate),@all) @make test.unit crate=medea-client-api-proto @make test.unit crate=medea-macro @make test.unit crate=medea - @make test.unit crate=jason else ifeq ($(test-unit-crate),medea) cargo test --lib --bin medea else -ifeq ($(test-unit-crate),jason) - wasm-pack test --headless --firefox jason -endif cargo test -p $(test-unit-crate) endif endif From 622afe12a3578c16088c7d8bf2d04a7b2d11fc50 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 8 Aug 2019 12:33:00 +0300 Subject: [PATCH 443/735] Add docker service to Travis CI configuration --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index e89f14fc3..76c431f00 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,8 @@ language: rust +services: + - docker + cache: cargo: true directories: From 749fcc59034baaf050ab39332595f8c082e87d17 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 8 Aug 2019 12:36:55 +0300 Subject: [PATCH 444/735] Fix lint, fmt --- Makefile | 2 +- src/turn/service.rs | 28 ++++++++++++----------- tests/e2e/signalling/pub_sub_signallng.rs | 1 - 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index dba3fd6dc..e19451c0e 100644 --- a/Makefile +++ b/Makefile @@ -186,7 +186,7 @@ cargo.fmt: # make cargo.lint cargo.lint: - cargo +nightly clippy --all -- -D clippy::pedantic -D warnings + cargo +nightly-2019-08-03 clippy --all -- -D clippy::pedantic -D warnings diff --git a/src/turn/service.rs b/src/turn/service.rs index f8bffbfe7..8cfd14068 100644 --- a/src/turn/service.rs +++ b/src/turn/service.rs @@ -242,19 +242,21 @@ impl Handler for Service { self.new_password(TURN_PASS_LEN), ); - Box::new(self.turn_db.insert(&ice_user).into_actor(self).then( - move |result, act, _| { - wrap_future(match result { - Ok(_) => ok(ice_user), - Err(e) => match msg.policy { - UnreachablePolicy::ReturnErr => err(e.into()), - UnreachablePolicy::ReturnStatic => { - ok(act.static_user()) - } - }, - }) - }, - )) + Box::new( + self.turn_db.insert(&ice_user).into_actor(self).then( + move |result, act, _| { + wrap_future(match result { + Ok(_) => ok(ice_user), + Err(e) => match msg.policy { + UnreachablePolicy::ReturnErr => err(e.into()), + UnreachablePolicy::ReturnStatic => { + ok(act.static_user()) + } + }, + }) + }, + ), + ) } } diff --git a/tests/e2e/signalling/pub_sub_signallng.rs b/tests/e2e/signalling/pub_sub_signallng.rs index fbd512e39..90cfa968d 100644 --- a/tests/e2e/signalling/pub_sub_signallng.rs +++ b/tests/e2e/signalling/pub_sub_signallng.rs @@ -81,7 +81,6 @@ fn pub_sub_video_call() { } } else if let Event::IceCandidateDiscovered { .. } = &events[1] { - } else { unreachable!(); } From 481bb405606352de7fc89e029d1ca36fe4243fde Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 8 Aug 2019 13:31:58 +0300 Subject: [PATCH 445/735] Remove flag for old version of docker-compose in Travis CI --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index e19451c0e..44c79487c 100644 --- a/Makefile +++ b/Makefile @@ -153,7 +153,7 @@ endif # make down.coturn down.coturn: - docker-compose -f docker-compose.coturn.yml down -t 1 + docker-compose -f docker-compose.coturn.yml down From a01ee2b8691a9fdb7d0d8425c3a38ad39bc34710 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 8 Aug 2019 13:36:49 +0300 Subject: [PATCH 446/735] Add license --- Cargo.toml | 1 + crates/medea-macro/Cargo.toml | 1 + jason/Cargo.toml | 1 + proto/client-api/Cargo.toml | 1 + 4 files changed, 4 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 927ecd98f..d75913650 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,6 +5,7 @@ edition = "2018" description = "Medea media server" authors = ["Instrumentisto Team "] homepage = "https://github.com/instrumentisto/medea" +license = "MPL 2.0" # documentation = "https://docs.rs/medea" readme = "README.md" repository = "https://github.com/instrumentisto/medea" diff --git a/crates/medea-macro/Cargo.toml b/crates/medea-macro/Cargo.toml index 070a2a77a..dae5ae2be 100644 --- a/crates/medea-macro/Cargo.toml +++ b/crates/medea-macro/Cargo.toml @@ -6,6 +6,7 @@ description = "Macros for Medea media server project" authors = ["Instrumentisto Team "] homepage = "https://github.com/instrumentisto/medea" # documentation = "https://docs.rs/medea-macro" +publish = false repository = "https://github.com/instrumentisto/medea" [lib] diff --git a/jason/Cargo.toml b/jason/Cargo.toml index e701e8594..621c5e306 100644 --- a/jason/Cargo.toml +++ b/jason/Cargo.toml @@ -5,6 +5,7 @@ edition = "2018" description = "Medea media server client application" authors = ["Instrumentisto Team "] homepage = "https://github.com/instrumentisto/medea" +license = "MPL 2.0" readme = "README.md" repository = "https://github.com/instrumentisto/medea" diff --git a/proto/client-api/Cargo.toml b/proto/client-api/Cargo.toml index 460626fb9..585f2382b 100644 --- a/proto/client-api/Cargo.toml +++ b/proto/client-api/Cargo.toml @@ -5,6 +5,7 @@ edition = "2018" description = "Client API protocol implementation for Medea media server" authors = ["Instrumentisto Team "] homepage = "https://github.com/instrumentisto/medea" +license = "MIT/Apache 2.0" readme = "README.md" repository = "https://github.com/instrumentisto/medea" From c014bb17b1b433a151762e05474702dcab0e36ce Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 8 Aug 2019 13:37:07 +0300 Subject: [PATCH 447/735] Convert medea to lib for docs.rs --- src/lib.rs | 122 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/main.rs | 123 +--------------------------------------------------- 2 files changed, 124 insertions(+), 121 deletions(-) create mode 100644 src/lib.rs diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 000000000..ed845d888 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,122 @@ +//! Medea media server application. + +#[macro_use] +pub mod utils; +pub mod api; +pub mod conf; +pub mod log; +pub mod media; +pub mod shutdown; +pub mod signalling; +pub mod turn; + +use std::{env, io, sync::Arc}; + +use actix::prelude::*; +use dotenv::dotenv; +use futures::IntoFuture as _; +use log::prelude::*; + +use crate::{ + api::{client::server::Server, control::Member}, + conf::Conf, + media::create_peers, + shutdown::GracefulShutdown, + signalling::{Room, RoomsRepository}, + turn::new_turn_auth_service, +}; + +pub fn run() -> io::Result<()> { + dotenv().ok(); + let config = Conf::parse().unwrap(); + + if let Some(lvl) = config.log.level() { + env::set_var("RUST_LOG", lvl.as_str()); + } + let logger = log::new_dual_logger(std::io::stdout(), std::io::stderr()); + let _scope_guard = slog_scope::set_global_logger(logger); + slog_stdlog::init().unwrap(); + + info!("{:?}", config); + + actix::run(|| { + new_turn_auth_service(&config.turn) + .map_err(|err| error!("Error creating TurnAuthService {:?}", err)) + .and_then(|turn_auth_service| { + let members = hashmap! { + 1 => Member::new(1, "caller_credentials".to_owned()), + 2 => Member::new(2, "responder_credentials".to_owned()), + }; + + let rooms = (0..1000) + .map(|i: u64| { + ( + i, + Room::new( + i, + members.clone(), + create_peers(1, 2), + config.rpc.reconnect_timeout, + Arc::clone(&turn_auth_service), + ) + .start(), + ) + }) + .collect(); + + Ok((rooms, config)) + }) + .and_then(|(rooms, config): (Vec<(u64, Addr)>, _)| { + let graceful_shutdown = + GracefulShutdown::new(config.shutdown.timeout).start(); + + let futures: Vec<_> = rooms + .iter() + .map(|(_, room)| { + graceful_shutdown + .send(shutdown::Subscribe(shutdown::Subscriber { + addr: room.clone().recipient(), + priority: shutdown::Priority(2), + })) + .map_err(|e| { + error!( + "Shutdown subscription failed for Room: {}", + e + ) + }) + }) + .collect(); + + futures::future::join_all(futures) + .map(move |_| (rooms, graceful_shutdown, config)) + }) + .map(|(rooms, graceful_shutdown, config)| { + let rooms_repo = + RoomsRepository::new(rooms.into_iter().collect()); + (rooms_repo, graceful_shutdown, config) + }) + .and_then(|(rooms_repo, graceful_shutdown, config)| { + Server::run(rooms_repo, config) + .map_err(|e| { + error!("Error starting Client API HTTP server {:?}", e) + }) + .map(|server| { + graceful_shutdown + .send(shutdown::Subscribe(shutdown::Subscriber { + addr: server.recipient(), + priority: shutdown::Priority(1), + })) + .map_err(|e| { + error!( + "Shutdown subscription failed for Client \ + API HTTP server: {}", + e + ) + }) + .map(|_| ()) + }) + .into_future() + .flatten() + }) + }) +} diff --git a/src/main.rs b/src/main.rs index 8237c1f82..0882a8978 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,122 +1,3 @@ -//! Medea media server application. - -#[macro_use] -pub mod utils; -pub mod api; -pub mod conf; -pub mod log; -pub mod media; -pub mod shutdown; -pub mod signalling; -pub mod turn; - -use std::{env, io, sync::Arc}; - -use actix::prelude::*; -use dotenv::dotenv; -use futures::IntoFuture as _; -use log::prelude::*; - -use crate::{ - api::{client::server::Server, control::Member}, - conf::Conf, - media::create_peers, - shutdown::GracefulShutdown, - signalling::{Room, RoomsRepository}, - turn::new_turn_auth_service, -}; - -fn main() -> io::Result<()> { - dotenv().ok(); - let config = Conf::parse().unwrap(); - - if let Some(lvl) = config.log.level() { - env::set_var("RUST_LOG", lvl.as_str()); - } - let logger = log::new_dual_logger(std::io::stdout(), std::io::stderr()); - let _scope_guard = slog_scope::set_global_logger(logger); - slog_stdlog::init().unwrap(); - - info!("{:?}", config); - - actix::run(|| { - new_turn_auth_service(&config.turn) - .map_err(|err| error!("Error creating TurnAuthService {:?}", err)) - .and_then(|turn_auth_service| { - let members = hashmap! { - 1 => Member::new(1, "caller_credentials".to_owned()), - 2 => Member::new(2, "responder_credentials".to_owned()), - }; - - let rooms = (0..1000) - .map(|i: u64| { - ( - i, - Room::new( - i, - members.clone(), - create_peers(1, 2), - config.rpc.reconnect_timeout, - Arc::clone(&turn_auth_service), - ) - .start(), - ) - }) - .collect(); - - Ok((rooms, config)) - }) - .and_then(|(rooms, config): (Vec<(u64, Addr)>, _)| { - let graceful_shutdown = - GracefulShutdown::new(config.shutdown.timeout).start(); - - let futures: Vec<_> = rooms - .iter() - .map(|(_, room)| { - graceful_shutdown - .send(shutdown::Subscribe(shutdown::Subscriber { - addr: room.clone().recipient(), - priority: shutdown::Priority(2), - })) - .map_err(|e| { - error!( - "Shutdown subscription failed for Room: {}", - e - ) - }) - }) - .collect(); - - futures::future::join_all(futures) - .map(move |_| (rooms, graceful_shutdown, config)) - }) - .map(|(rooms, graceful_shutdown, config)| { - let rooms_repo = - RoomsRepository::new(rooms.into_iter().collect()); - (rooms_repo, graceful_shutdown, config) - }) - .and_then(|(rooms_repo, graceful_shutdown, config)| { - Server::run(rooms_repo, config) - .map_err(|e| { - error!("Error starting Client API HTTP server {:?}", e) - }) - .map(|server| { - graceful_shutdown - .send(shutdown::Subscribe(shutdown::Subscriber { - addr: server.recipient(), - priority: shutdown::Priority(1), - })) - .map_err(|e| { - error!( - "Shutdown subscription failed for Client \ - API HTTP server: {}", - e - ) - }) - .map(|_| ()) - }) - .into_future() - .flatten() - }) - }) +fn main() -> std::io::Result<()> { + medea::run() } From 594639edda3cdf2068558bec5ba28f9d45517229 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 8 Aug 2019 14:07:34 +0300 Subject: [PATCH 448/735] Try to fix travis CI e2e tests --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 44c79487c..01b845cbb 100644 --- a/Makefile +++ b/Makefile @@ -303,9 +303,9 @@ else @make down.medea dockerized=no @make up.coturn - docker run --rm --network=host -v "$(PWD)":/app -w /app \ - -v "$(PWD)/.cache/medea/registry":/usr/local/cargo/registry \ - -v "$(PWD)/.cache/medea/target":/app/target \ + docker run --rm --network=host -v "./":/app -w /app \ + -v "./.cache/medea/registry":/usr/local/cargo/registry \ + -v "./.cache/medea/target":/app/target \ rust:latest \ make test.e2e dockerized=no coturn=no release=yes From 3e5d68e2f944c8242f3a0e03a2745af549ebcecd Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 8 Aug 2019 14:33:18 +0300 Subject: [PATCH 449/735] Revert "Try to fix travis CI e2e tests" This reverts commit 594639edda3cdf2068558bec5ba28f9d45517229. --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 01b845cbb..44c79487c 100644 --- a/Makefile +++ b/Makefile @@ -303,9 +303,9 @@ else @make down.medea dockerized=no @make up.coturn - docker run --rm --network=host -v "./":/app -w /app \ - -v "./.cache/medea/registry":/usr/local/cargo/registry \ - -v "./.cache/medea/target":/app/target \ + docker run --rm --network=host -v "$(PWD)":/app -w /app \ + -v "$(PWD)/.cache/medea/registry":/usr/local/cargo/registry \ + -v "$(PWD)/.cache/medea/target":/app/target \ rust:latest \ make test.e2e dockerized=no coturn=no release=yes From 7780c480221371a2ab3400d5b0a32a2e3c55c3c5 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 8 Aug 2019 16:45:41 +0300 Subject: [PATCH 450/735] Try without caching --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 76c431f00..cd2cf7c8e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,8 +5,6 @@ services: cache: cargo: true - directories: - - .cache jobs: allow_failures: From b9c3b4b78d319cdcfd44dd54f7a4275d547eadf6 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 8 Aug 2019 18:42:03 +0300 Subject: [PATCH 451/735] Add releasing from CI --- .travis.yml | 32 +++++++++++++++++++++++++++++++ Makefile | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 85 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1e0a5164b..8505af4c8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -55,6 +55,38 @@ install: - rustc -vV - cargo -vV +before_deploy: + - echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc + - curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh + +deploy: + - provider: script + script: make release.crates.medea + on: + tags: true + branch: master + condition: $TRAVIS_TAG =~ ^medea-[0-9]+\.[0-9]+\.[0-9] + + - provider: script + script: make release.jason + on: + tags: true + branch: master + condition: $TRAVIS_TAG =~ ^medea-jason-[0-9]+\.[0-9]+\.[0-9] + + - provider: script + script: make release.crates.medea-client-api-proto + on: + tags: true + branch: master + condition: $TRAVIS_TAG =~ ^medea-client-api-proto-[0-9]+\.[0-9]+\.[0-9] + + - provider: releases + api_key: $GH_TOKEN + on: + tags: true + branch: master + notifications: email: on_success: never diff --git a/Makefile b/Makefile index 90076920f..6f4869446 100644 --- a/Makefile +++ b/Makefile @@ -221,17 +221,67 @@ endif # Releasing commands # ###################### +# Build and publish Jason to NPM and crates.io. +# +# Note that this command will use CARGO_TOKEN and NPM_TOKEN enviroment +# variables for publishing. +# +# Usage: +# make release.jason + +release.jason: release.npm.jason release.crates.jason + + # Build and publish Jason application to npm # +# Note that this command will use NPM_TOKEN enviroment +# variable for publishing. +# # Usage: # make release.jason -release.jason: +release.npm.jason: @rm -rf jason/pkg/ wasm-pack build -t web jason wasm-pack publish +# Build and publish Jason to crates.io +# +# Note that this command will use CARGO_TOKEN enviroment +# variable for publishing. +# +# Usage: +# make release.crates.jason + +release.crates.jason: + cd jason && cargo publish --token ${CARGO_TOKEN} + + +# Build and publish Medea to crates.io +# +# Note that this command will use CARGO_TOKEN enviroment +# variable for publishing. +# +# Usage: +# make release.crates.medea + +release.crates.medea: + cargo publish --token ${CARGO_TOKEN} + + +# Build and publish Medea client API proto to crates.io +# +# Note that this command will use CARGO_TOKEN enviroment +# variable for publishing. +# +# Usage: +# make release.crates.medea-client-api-proto + +release.crates.medea-client-api-proto: + cd proto/client-api && cargo publish --token ${CARGO_TOKEN} + + release.helm: helm.package.release @@ -508,7 +558,8 @@ endef helm helm.down helm.init helm.lint helm.list \ helm.package helm.package.release helm.up \ minikube.boot \ - release.jason release.helm \ + release.jason release.crates.jason release.npm.jason release.helm \ + release.crates.medea release.crates.medea-client-api-proto \ test test.unit \ up up.coturn up.demo up.dev up.jason up.medea \ yarn From 7f2542a6281ff5e2f81db818bf2545d1cad5085e Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 8 Aug 2019 19:13:22 +0300 Subject: [PATCH 452/735] Add changelogs [skip ci] --- CHANGELOG.md | 20 ++++++++++++++++++++ jason/CHANGELOG.md | 27 +++++++++++++++++++++++++++ proto/client-api/CHANGELOG.md | 25 +++++++++++++++++++++++++ 3 files changed, 72 insertions(+) create mode 100644 CHANGELOG.md create mode 100644 jason/CHANGELOG.md create mode 100644 proto/client-api/CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 000000000..e2700f5da --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,20 @@ +## [0.1.0] - 2019-08-09 +[Milestone](https://github.com/instrumentisto/medea/milestone/1) | +[Roadmap](https://github.com/instrumentisto/medea/issues/8) + +Initial release. + +#### Implemented + +- P2P video calls +- Structured logging (#12) +- Application configuration (#15) +- [WebRTC signalling] (#16) +- [Coturn] integration (#20, #42) +- Dockerized medea (#45) +- Graceful shutdown (#30) + + +[0.1.0]: https://github.com/instrumentisto/medea/releases/tag/medea-0.1.0 +[Coturn]: https://github.com/coturn/coturn +[WebRTC signalling]: https://webrtcglossary.com/signaling/ diff --git a/jason/CHANGELOG.md b/jason/CHANGELOG.md new file mode 100644 index 000000000..b8f78adaa --- /dev/null +++ b/jason/CHANGELOG.md @@ -0,0 +1,27 @@ +## [0.1.0] - 2019-08-09 +[Milestone](https://github.com/instrumentisto/medea/milestone/1) | +[Roadmap](https://github.com/instrumentisto/medea/issues/8) + +Initial release. + +#### Implemented + +- Setup toolchain (#17) +- Setup transport and messaging (#18) +- Signalling (#22): + - handle RPC events: + - `PeerCreated` + - `SdpAnswerMade` + - `IceCandidateDiscovered` + - `PeersRemoved` + - emit RPC commands: + - `MakeSdpOffer` + - `MakeSdpAnswer` + - `SetIceCandidate` +- Media management (#22): + - `MediaStream` management + - `RTCPeerConnection` management +- P2P video calls (#22) + + +[0.1.0]: https://github.com/instrumentisto/medea/releases/tag/medea-jason-0.1.0 diff --git a/proto/client-api/CHANGELOG.md b/proto/client-api/CHANGELOG.md new file mode 100644 index 000000000..cd67b3b5d --- /dev/null +++ b/proto/client-api/CHANGELOG.md @@ -0,0 +1,25 @@ +## [0.1.0] - 2019-08-09 +[Milestone](https://github.com/instrumentisto/medea/milestone/1) | +[Roadmap](https://github.com/instrumentisto/medea/issues/8) + +Initial release. + +#### Implemented + +- Server messages: + - `Pong` + - `Event` +- Client messages: + - `Ping` + - `Command` +- Client commands: + - `MakeSdpOffer` + - `MakeSdpAnswer` + - `SetIceCandidate` +- Server events: + - `PeerCreated` + - `SdpAnswerMade` + - `IceCandidateDiscovered` + - `PeersRemoved` + +[0.1.0]: https://github.com/instrumentisto/medea/releases/tag/medea-client-api-proto-0.1.0 From 0bb5ab34855b8a03306e31955cf142f8836c73dd Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 8 Aug 2019 19:20:04 +0300 Subject: [PATCH 453/735] Fix links to PRs [skip ci] --- CHANGELOG.md | 21 ++++++++++++++------- jason/CHANGELOG.md | 15 +++++++++------ proto/client-api/CHANGELOG.md | 2 +- 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e2700f5da..89b7fb3cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,17 +4,24 @@ Initial release. -#### Implemented +### Implemented - P2P video calls -- Structured logging (#12) -- Application configuration (#15) -- [WebRTC signalling] (#16) -- [Coturn] integration (#20, #42) -- Dockerized medea (#45) -- Graceful shutdown (#30) +- Structured logging ([#12]) +- Application configuration ([#15]) +- [WebRTC signalling] ([#16]) +- [Coturn] integration ([#20], [#42]) +- Dockerized medea ([#35]) +- Graceful shutdown ([#30]) [0.1.0]: https://github.com/instrumentisto/medea/releases/tag/medea-0.1.0 [Coturn]: https://github.com/coturn/coturn [WebRTC signalling]: https://webrtcglossary.com/signaling/ +[#12]: https://github.com/instrumentisto/medea/pull/18 +[#15]: https://github.com/instrumentisto/medea/pull/15 +[#16]: https://github.com/instrumentisto/medea/pull/16 +[#20]: https://github.com/instrumentisto/medea/pull/20 +[#42]: https://github.com/instrumentisto/medea/pull/42 +[#35]: https://github.com/instrumentisto/medea/pull/35 +[#30]: https://github.com/instrumentisto/medea/pull/30 diff --git a/jason/CHANGELOG.md b/jason/CHANGELOG.md index b8f78adaa..409c36949 100644 --- a/jason/CHANGELOG.md +++ b/jason/CHANGELOG.md @@ -4,11 +4,11 @@ Initial release. -#### Implemented +### Implemented -- Setup toolchain (#17) -- Setup transport and messaging (#18) -- Signalling (#22): +- Setup toolchain ([#17]) +- Setup transport and messaging ([#18]) +- Signalling ([#22]): - handle RPC events: - `PeerCreated` - `SdpAnswerMade` @@ -18,10 +18,13 @@ Initial release. - `MakeSdpOffer` - `MakeSdpAnswer` - `SetIceCandidate` -- Media management (#22): +- Media management ([#22]): - `MediaStream` management - `RTCPeerConnection` management -- P2P video calls (#22) +- P2P video calls ([#22]) [0.1.0]: https://github.com/instrumentisto/medea/releases/tag/medea-jason-0.1.0 +[#17]: https://github.com/instrumentisto/medea/pull/17 +[#18]: https://github.com/instrumentisto/medea/pull/18 +[#22]: https://github.com/instrumentisto/medea/pull/22 diff --git a/proto/client-api/CHANGELOG.md b/proto/client-api/CHANGELOG.md index cd67b3b5d..818a1da3d 100644 --- a/proto/client-api/CHANGELOG.md +++ b/proto/client-api/CHANGELOG.md @@ -4,7 +4,7 @@ Initial release. -#### Implemented +### Implemented - Server messages: - `Pong` From b1074fffd5b0f84cc8ae56ad0e002bde133f8065 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 8 Aug 2019 19:44:22 +0300 Subject: [PATCH 454/735] Fix PR links [skip ci] --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 89b7fb3cd..521e89b80 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,7 +18,7 @@ Initial release. [0.1.0]: https://github.com/instrumentisto/medea/releases/tag/medea-0.1.0 [Coturn]: https://github.com/coturn/coturn [WebRTC signalling]: https://webrtcglossary.com/signaling/ -[#12]: https://github.com/instrumentisto/medea/pull/18 +[#12]: https://github.com/instrumentisto/medea/pull/12 [#15]: https://github.com/instrumentisto/medea/pull/15 [#16]: https://github.com/instrumentisto/medea/pull/16 [#20]: https://github.com/instrumentisto/medea/pull/20 From 2b76c86f1d76dc1ee97af2a542a145d200d7bfc4 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 9 Aug 2019 12:03:55 +0300 Subject: [PATCH 455/735] Fix TRAVIS_TAG regex [skip ci] --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8505af4c8..f3b4a2e27 100644 --- a/.travis.yml +++ b/.travis.yml @@ -65,21 +65,21 @@ deploy: on: tags: true branch: master - condition: $TRAVIS_TAG =~ ^medea-[0-9]+\.[0-9]+\.[0-9] + condition: $TRAVIS_TAG =~ ^medea-[0-9]+\.[0-9]+\.[0-9]+ - provider: script script: make release.jason on: tags: true branch: master - condition: $TRAVIS_TAG =~ ^medea-jason-[0-9]+\.[0-9]+\.[0-9] + condition: $TRAVIS_TAG =~ ^medea-jason-[0-9]+\.[0-9]+\.[0-9]+ - provider: script script: make release.crates.medea-client-api-proto on: tags: true branch: master - condition: $TRAVIS_TAG =~ ^medea-client-api-proto-[0-9]+\.[0-9]+\.[0-9] + condition: $TRAVIS_TAG =~ ^medea-client-api-proto-[0-9]+\.[0-9]+\.[0-9]+ - provider: releases api_key: $GH_TOKEN From ef9d7967c094e94a7d106bede5e214e9120e35a4 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 9 Aug 2019 12:10:55 +0300 Subject: [PATCH 456/735] Small style fix --- src/api/client/rpc_connection.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/api/client/rpc_connection.rs b/src/api/client/rpc_connection.rs index 611a12155..a793077fd 100644 --- a/src/api/client/rpc_connection.rs +++ b/src/api/client/rpc_connection.rs @@ -1,5 +1,6 @@ -//! [`RpcConnection`](crate::api::client::rpc_connection::RpcConnection) with -//! related messages. +//! [`RpcConnection`] with related messages. +//! +//! [`RpcConnection`]: crate::api::client::rpc_connection::RpcConnection use std::fmt; From 5ac71ab8a56305ed6ae3c0faada68a6289bb7898 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 9 Aug 2019 12:54:56 +0300 Subject: [PATCH 457/735] Add version for local crates --- Cargo.toml | 7 +++++-- jason/Cargo.toml | 4 ++-- proto/client-api/Cargo.toml | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d75913650..baa6e9b4d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,8 +34,8 @@ futures = "0.1" hashbrown = "0.1" humantime = "1.2" macro-attr = "0.2" -medea-client-api-proto = { path = "proto/client-api", features = ["medea"] } -medea-macro = { path = "crates/medea-macro" } +medea-client-api-proto = { version = "0.1.0", features = ["medea"] } +medea-macro = { path = "crates/medea-macro", version = "0.1.0" } newtype_derive = "0.1" rand = "0.7" redis = "0.10" @@ -61,3 +61,6 @@ actix-http = "0.2" actix-http-test = "0.2" serial_test = "0.2" serial_test_derive = "0.2" + +[patch.crates-io] +medea-client-api-proto = { path = "proto/client-api" } diff --git a/jason/Cargo.toml b/jason/Cargo.toml index 621c5e306..e28606fc0 100644 --- a/jason/Cargo.toml +++ b/jason/Cargo.toml @@ -23,8 +23,8 @@ console_error_panic_hook = { version = "0.1", optional = true } futures = "0.1" js-sys = "0.3" macro-attr = "0.2" -medea-client-api-proto = { path = "../proto/client-api", features = ["jason"] } -medea-macro = { path = "../crates/medea-macro" } +medea-client-api-proto = { path = "../proto/client-api", features = ["jason"], version = "0.1.0" } +medea-macro = { path = "../crates/medea-macro", version = "0.1.0" } newtype_derive = "0.1" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" diff --git a/proto/client-api/Cargo.toml b/proto/client-api/Cargo.toml index 585f2382b..ef6685e19 100644 --- a/proto/client-api/Cargo.toml +++ b/proto/client-api/Cargo.toml @@ -15,6 +15,6 @@ jason = [] medea = [] [dependencies] -medea-macro = { path = "../../crates/medea-macro" } +medea-macro = { path = "../../crates/medea-macro", version = "0.1.0" } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" From 7c0ca54e3f41642a24a74d98059b34b68f7cd9c4 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 9 Aug 2019 14:04:03 +0300 Subject: [PATCH 458/735] Try to fix e2e test caching --- Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 44c79487c..0bec8417b 100644 --- a/Makefile +++ b/Makefile @@ -304,8 +304,9 @@ else @make up.coturn docker run --rm --network=host -v "$(PWD)":/app -w /app \ - -v "$(PWD)/.cache/medea/registry":/usr/local/cargo/registry \ - -v "$(PWD)/.cache/medea/target":/app/target \ + -u $(shell id -u):$(shell id -g) \ + -v "$(HOME).cargo/registry":/usr/local/cargo/registry \ + -v "$(PWD)/target":/app/target \ rust:latest \ make test.e2e dockerized=no coturn=no release=yes From 0bdb027d5d982626bf27ca5668d1f053e001cdc3 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 9 Aug 2019 14:09:20 +0300 Subject: [PATCH 459/735] Fix path for Travis --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 0bec8417b..6a69e3eee 100644 --- a/Makefile +++ b/Makefile @@ -305,7 +305,7 @@ else docker run --rm --network=host -v "$(PWD)":/app -w /app \ -u $(shell id -u):$(shell id -g) \ - -v "$(HOME).cargo/registry":/usr/local/cargo/registry \ + -v "$(HOME)/.cargo/registry":/usr/local/cargo/registry \ -v "$(PWD)/target":/app/target \ rust:latest \ make test.e2e dockerized=no coturn=no release=yes From cb870716268ba2abc0501a7e19b82fbd29386696 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 9 Aug 2019 18:43:14 +0300 Subject: [PATCH 460/735] Fix travis --- .travis.yml | 14 +++++++++----- src/signalling/peers.rs | 4 ++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index cd2cf7c8e..a99b1eecc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,15 @@ services: cache: cargo: true +install: + - PROTOBUF_VERSION=3.3.0 + - PROTOC_FILENAME=protoc-${PROTOBUF_VERSION}-linux-x86_64.zip + - pushd /home/travis + - wget https://github.com/google/protobuf/releases/download/v${PROTOBUF_VERSION}/${PROTOC_FILENAME} + - unzip ${PROTOC_FILENAME} + - bin/protoc --version + - popd + jobs: allow_failures: - rust: nightly @@ -59,11 +68,6 @@ jobs: name: "E2E tests (Rust stable)" script: make test.e2e - -install: - - rustc -vV - - cargo -vV - notifications: email: on_success: never diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index f9237fecf..66a0a9eac 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -189,12 +189,12 @@ impl PeerRepository { if self.peers.remove(&partner_peer_id).is_some() { removed_peers .entry(partner_member_id) - .or_insert(Vec::new()) + .or_insert_with(Vec::new) .push(partner_peer_id); } removed_peers .entry(member_id.clone()) - .or_insert(Vec::new()) + .or_insert_with(Vec::new) .push(peer_id); } } From a6715bd12a4ffe308e1346bbd715c456b537d48e Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 9 Aug 2019 19:00:23 +0300 Subject: [PATCH 461/735] Fix cargo.fmt --- .travis.yml | 2 +- Makefile | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index a99b1eecc..5eaab5ed7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,7 +31,7 @@ jobs: rust: nightly name: "Rustfmt" before_script: rustup component add rustfmt - script: make fmt check=yes + script: make fmt check=yes build=yes - stage: build rust: stable diff --git a/Makefile b/Makefile index c361b845b..17f630eae 100644 --- a/Makefile +++ b/Makefile @@ -174,9 +174,12 @@ cargo: # Format Rust sources with rustfmt. # # Usage: -# make cargo.fmt [check=(no|yes)] +# make cargo.fmt [check=(no|yes)] [build=(no|yes)] cargo.fmt: +ifeq ($(build),yes) + cargo build +endif cargo +nightly fmt --all $(if $(call eq,$(check),yes),-- --check,) From 8cce5830e6a542fb10832182610843ce72dd29b3 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 12 Aug 2019 12:22:58 +0300 Subject: [PATCH 462/735] Add publishing medea-macro to crates.io --- .travis.yml | 7 +++++++ Cargo.toml | 3 ++- Makefile | 12 ++++++++++++ crates/medea-macro/Cargo.toml | 4 ++-- jason/Cargo.toml | 4 ++-- proto/client-api/Cargo.toml | 2 +- 6 files changed, 26 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index f3b4a2e27..fa892150b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -81,6 +81,13 @@ deploy: branch: master condition: $TRAVIS_TAG =~ ^medea-client-api-proto-[0-9]+\.[0-9]+\.[0-9]+ + - provider: script + script: make release.crates.medea-macro + on: + tags: true + branch: master + condition: $TRAVIS_TAG =~ ^medea-macro-[0-9]+\.[0-9]+\.[0-9]+ + - provider: releases api_key: $GH_TOKEN on: diff --git a/Cargo.toml b/Cargo.toml index baa6e9b4d..06caedaa8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,7 +35,7 @@ hashbrown = "0.1" humantime = "1.2" macro-attr = "0.2" medea-client-api-proto = { version = "0.1.0", features = ["medea"] } -medea-macro = { path = "crates/medea-macro", version = "0.1.0" } +medea-macro = "0.1.0" newtype_derive = "0.1" rand = "0.7" redis = "0.10" @@ -64,3 +64,4 @@ serial_test_derive = "0.2" [patch.crates-io] medea-client-api-proto = { path = "proto/client-api" } +medea-macro = { path = "crates/medea-macro" } diff --git a/Makefile b/Makefile index 6f4869446..a462e5aff 100644 --- a/Makefile +++ b/Makefile @@ -282,6 +282,18 @@ release.crates.medea-client-api-proto: cd proto/client-api && cargo publish --token ${CARGO_TOKEN} +# Build and publish Medea's macro to crates.io +# +# Note that this command will use CARGO_TOKEN enviroment +# variable for publishing. +# +# Usage: +# make release.crates.medea-macro + +release.crates.medea-macro: + cd crates/medea-macro && cargo publish --token ${CARGO_TOKEN} + + release.helm: helm.package.release diff --git a/crates/medea-macro/Cargo.toml b/crates/medea-macro/Cargo.toml index dae5ae2be..e586c1c8b 100644 --- a/crates/medea-macro/Cargo.toml +++ b/crates/medea-macro/Cargo.toml @@ -2,11 +2,11 @@ name = "medea-macro" version = "0.1.0" edition = "2018" -description = "Macros for Medea media server project" +description = "Don't use this crate directly. It is internal to Medea." authors = ["Instrumentisto Team "] homepage = "https://github.com/instrumentisto/medea" +license = "MPL 2.0" # documentation = "https://docs.rs/medea-macro" -publish = false repository = "https://github.com/instrumentisto/medea" [lib] diff --git a/jason/Cargo.toml b/jason/Cargo.toml index e28606fc0..766238889 100644 --- a/jason/Cargo.toml +++ b/jason/Cargo.toml @@ -23,8 +23,8 @@ console_error_panic_hook = { version = "0.1", optional = true } futures = "0.1" js-sys = "0.3" macro-attr = "0.2" -medea-client-api-proto = { path = "../proto/client-api", features = ["jason"], version = "0.1.0" } -medea-macro = { path = "../crates/medea-macro", version = "0.1.0" } +medea-client-api-proto = { features = ["jason"], version = "0.1.0" } +medea-macro = "0.1.0" newtype_derive = "0.1" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" diff --git a/proto/client-api/Cargo.toml b/proto/client-api/Cargo.toml index ef6685e19..28ab1c415 100644 --- a/proto/client-api/Cargo.toml +++ b/proto/client-api/Cargo.toml @@ -15,6 +15,6 @@ jason = [] medea = [] [dependencies] -medea-macro = { path = "../../crates/medea-macro", version = "0.1.0" } +medea-macro = "0.1.0" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" From 329dd2e8e154100da656d0c57e428f1cbad74ee1 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 12 Aug 2019 12:37:31 +0300 Subject: [PATCH 463/735] Don't hardcode nightly date for clippy --- .travis.yml | 2 +- Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index fa892150b..ed3877455 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,7 @@ jobs: include: - stage: lints - rust: nightly-2019-08-03 # TODO: use nightly when clippy will be fixed + rust: nightly name: "Clippy" before_script: rustup component add clippy script: make lint diff --git a/Makefile b/Makefile index a462e5aff..c0dddc318 100644 --- a/Makefile +++ b/Makefile @@ -131,7 +131,7 @@ cargo.fmt: # make cargo.lint cargo.lint: - cargo +nightly-2019-08-03 clippy --all -- -D clippy::pedantic -D warnings + cargo +nightly clippy --all -- -D clippy::pedantic -D warnings From 90521faa50ae840828ce96775e6a5794b66f93d7 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 12 Aug 2019 13:03:06 +0300 Subject: [PATCH 464/735] Fix clippy --- jason/src/lib.rs | 3 +++ proto/client-api/src/lib.rs | 5 +++++ src/lib.rs | 3 +++ 3 files changed, 11 insertions(+) diff --git a/jason/src/lib.rs b/jason/src/lib.rs index 846efad6c..5b46cb81a 100644 --- a/jason/src/lib.rs +++ b/jason/src/lib.rs @@ -1,3 +1,6 @@ +// TODO: when using enum's Self will be in stable, remove it. +#![allow(clippy::use_self)] + pub mod api; pub mod media; pub mod peer; diff --git a/proto/client-api/src/lib.rs b/proto/client-api/src/lib.rs index 7029bc6a0..121011137 100644 --- a/proto/client-api/src/lib.rs +++ b/proto/client-api/src/lib.rs @@ -1,3 +1,8 @@ +//! Client API protocol implementation for Medea media server. + +// TODO: when using enum's Self will be in stable, remove it. +#![allow(clippy::use_self)] + use std::collections::HashMap; use medea_macro::dispatchable; diff --git a/src/lib.rs b/src/lib.rs index ed845d888..4076fd302 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,8 @@ //! Medea media server application. +// TODO: when using enum's Self will be in stable, remove it. +#![allow(clippy::use_self)] + #[macro_use] pub mod utils; pub mod api; From f14d047feef238ee85b3acb1343f7723ce23e67b Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 12 Aug 2019 13:30:04 +0300 Subject: [PATCH 465/735] Use path instead of patch --- Cargo.toml | 8 ++------ jason/Cargo.toml | 4 ++-- proto/client-api/Cargo.toml | 2 +- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 06caedaa8..d75913650 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,8 +34,8 @@ futures = "0.1" hashbrown = "0.1" humantime = "1.2" macro-attr = "0.2" -medea-client-api-proto = { version = "0.1.0", features = ["medea"] } -medea-macro = "0.1.0" +medea-client-api-proto = { path = "proto/client-api", features = ["medea"] } +medea-macro = { path = "crates/medea-macro" } newtype_derive = "0.1" rand = "0.7" redis = "0.10" @@ -61,7 +61,3 @@ actix-http = "0.2" actix-http-test = "0.2" serial_test = "0.2" serial_test_derive = "0.2" - -[patch.crates-io] -medea-client-api-proto = { path = "proto/client-api" } -medea-macro = { path = "crates/medea-macro" } diff --git a/jason/Cargo.toml b/jason/Cargo.toml index 766238889..4316fa6b0 100644 --- a/jason/Cargo.toml +++ b/jason/Cargo.toml @@ -23,8 +23,8 @@ console_error_panic_hook = { version = "0.1", optional = true } futures = "0.1" js-sys = "0.3" macro-attr = "0.2" -medea-client-api-proto = { features = ["jason"], version = "0.1.0" } -medea-macro = "0.1.0" +medea-client-api-proto = { features = ["jason"], path = "../proto/client-api" } +medea-macro = { path = "../crates/medea-macro" } newtype_derive = "0.1" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" diff --git a/proto/client-api/Cargo.toml b/proto/client-api/Cargo.toml index 28ab1c415..585f2382b 100644 --- a/proto/client-api/Cargo.toml +++ b/proto/client-api/Cargo.toml @@ -15,6 +15,6 @@ jason = [] medea = [] [dependencies] -medea-macro = "0.1.0" +medea-macro = { path = "../../crates/medea-macro" } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" From 14bb6fcf677675c9406a242a63793003b29c3c45 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 12 Aug 2019 13:58:07 +0300 Subject: [PATCH 466/735] Fix .PHONY in Makefile [skip ci] --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index c0dddc318..31d0a2670 100644 --- a/Makefile +++ b/Makefile @@ -572,6 +572,7 @@ endef minikube.boot \ release.jason release.crates.jason release.npm.jason release.helm \ release.crates.medea release.crates.medea-client-api-proto \ + release.crates.medea-macro \ test test.unit \ up up.coturn up.demo up.dev up.jason up.medea \ yarn From e5ef47903a064632c45527cbe4098e9804d17f47 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 12 Aug 2019 19:11:02 +0300 Subject: [PATCH 467/735] Add releasing documentation --- RELEASING.md | 115 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 RELEASING.md diff --git a/RELEASING.md b/RELEASING.md new file mode 100644 index 000000000..325480581 --- /dev/null +++ b/RELEASING.md @@ -0,0 +1,115 @@ +## How to release this repository + +All releases in this repository normally are made with [Travis CI] using git tags. +Read [this][2] if you don't understand what is git tag. + +__Before publishing every crate (no matters how) run `cargo package` in crate directory.__ +This will check crate for some errors important for publishing. + +### Git tags for releasing +These tags will only be searched on the master branch. + +`x.y.z` - is version of crate. Note that this version will not be checked for +sameness with version from `Cargo.toml`. This only affect on git releasing tag +and triggering deploy job on [Travis CI]. + +- `medea-macro-x.y.z` - publish medea-macro crate to [crates.io] +- `medea-x.y.z` - publish medea to [crates.io] +- `medea-jason-x.y.z` - publish medea-jason to [crates.io] and [NPM] +- `medea-client-api-proto-x.y.z` - publish medea-client-api-proto to [crates.io] +- all tags (including those listed above) - create release on Github with specified tag + +### Preparation of crate to release +#### 1. Change declaration of internal dependencies from path to version. +Internal dependencies probably will be declared like this: +`medea-macro = { path = "crates/medea-macro" }`. This declaration is good +for developing but when we release crate all it deps should be published on +[crates.io]. Simply change this declaration to something like that: +`medea-macro = "1.2.3"`. Most likely in place of "1.2.3" there will be the +latest version of the crate that you previously released. + +__Be sure to follow the rules in the "Order of releasing" section of this guide.__ + +#### 2. Remove `-dev` postfix from version of crate +Simply remove `-dev` in `version` field in `Cargo.toml` of crate which +you want release. For example, `1.2.3-dev` to `1.2.3`. + +#### 3. Check with `$ cargo package` +Fix all errors (if any will) which this command will output. + +#### 4. Set version in `CHANGELOG.md` of crate + +### Order of releasing +__The order of releasing of the crates can be important.__ For example, you want to +release `medea-1.2.3` which uses latest unreleased `medea-macro` (version will be 1.3.6). +In such case [Travis CI] deploy job will fail because cargo can't find +specified version of `medea-macro`. + +For avoid it use following flow: + +1. Prepare and release `medea-macro-1.3.6` (apply `medea-macro-1.3.6` git tag) +2. Change `medea-macro = { path = crates/medea-macro }` to `medea-macro = "1.3.6"` + in medea's `Cargo.toml` and `medea-client-api-proto`'s `Cargo.toml`. +3. Prepare and release `medea-client-api-proto` (apply `medea-client-api-proto-1.2.4` git tag) +4. Change `medea-client-api-proto = { path = "proto/client-api" }` to + `medea-client-api-proto = "1.2.4"` in `medea`'s `Cargo.toml` +5. Prepare and release `medea` (apply `medea-1.2.3` git tag) + +If you wish also release `medea-jason` which uses same version of `medea-macro`, then +you can simply do it (prepare `medea-jason` for release and apply +`medea-jason-x.y.z` tag). + +#### Current releasing priority +1. `medea-macro` (used by `medea`, `medea-client-api-proto` and `medea-jason`) +2. `medea-client-api-proto` (used by `medea` and `medea-jason`) +3. `medea` and `medea-jason` + +### Releasing with Makefile +__Use it only if publishing with [Travis CI] is not possible for some reason +([Travis CI] is down for example).__ + +For publishing to [crates.io] will be used token from `CARGO_TOKEN` environment variable. +And for [NPM] will be used your local token for npm. + +`Makefile` contains the following recipes for releasing: + +- `$ make release.jason` - publish `medea-jason` to [crates.io] and [NPM] +- `$ make release.crates.jason` - publish `medea-jason` __only__ to [crates.io] +- `$ make release.npm.jason` - publish `medea-jason` __only__ to [NPM] +- `$ make release.crates.medea` - publish `medea` to [crates.io] +- `$ make release.crates.medea-client-api-proto` - publish `medea-client-api-proto` + to [crates.io] +- `$ make release.crates.medea-macro` - publish `medea-macro` to [crates.io] + +For manually create Github release you can follow [this guide][1]. + +### After release +When you released everything you wanted you should transfer everything to dev state. + +1. Set version according milestone and add `-dev` postfix to it +2. Add section for next milestone in `CHANGELOG.md` +3. Change all internal deps declaration from version to path + (`medea-macro = "1.0.0"` -> `medea-macro = { path = "crates/medea-macro" }`) +4. Commit it to master + +### I broke everything. Help! +#### If broken crate released to [crates.io] +1. Yank broken version of crate on [crates.io] + (read [this][3] if you don't know what is it) +2. Fix crate +3. Bump PATCH version of this crate everywhere +4. Publish it + +#### If some error occurred when releasing in CI +1. Fix errors from CI and commit +2. Force set tag to commit with fix (`$ git tag -fa {{YOUR_TAG_HERE}}`) +3. Force push this tag (`$ git push -f origin {{YOUR_TAG_HERE}}`) +4. Profit! [Travis CI] will rerun deploy job + + +[1]: https://help.github.com/en/articles/creating-releases +[2]: https://git-scm.com/book/en/v2/Git-Basics-Tagging +[3]: https://doc.rust-lang.org/cargo/reference/publishing.html#cargo-yank +[crates.io]: https://crates.io/ +[NPM]: https://www.npmjs.com/ +[Travis CI]: https://travis-ci.org/ From acc9190767b37f2c943604459d81eb20fddfc78e Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 12 Aug 2019 19:48:38 +0300 Subject: [PATCH 468/735] Fix unit tests --- Makefile | 4 ---- src/log/prelude.rs | 2 +- src/utils/mod.rs | 1 + 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 31d0a2670..3f707a01e 100644 --- a/Makefile +++ b/Makefile @@ -206,13 +206,9 @@ ifeq ($(test-unit-crate),@all) @make test.unit crate=medea-client-api-proto @make test.unit crate=medea-macro @make test.unit crate=medea -else -ifeq ($(test-unit-crate),medea) - cargo test --bin medea else cargo test -p $(test-unit-crate) endif -endif diff --git a/src/log/prelude.rs b/src/log/prelude.rs index a09db6ec8..537645ab0 100644 --- a/src/log/prelude.rs +++ b/src/log/prelude.rs @@ -2,7 +2,7 @@ //! //! Use this module as following: //! ```rust -//! use crate::log::prelude::*; +//! use medea::log::prelude::*; //! ``` pub use slog::{slog_debug, slog_error, slog_info, slog_trace, slog_warn}; diff --git a/src/utils/mod.rs b/src/utils/mod.rs index e5ca8a211..c9f4b619f 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -5,6 +5,7 @@ /// ## Example /// /// ```rust +/// # use medea::hashmap; /// let map = hashmap! { /// "a" => 1, /// "b" => 2, From d6ad09000326d0c2bd6e8a8304cab59fa6a7d36e Mon Sep 17 00:00:00 2001 From: alexlapa Date: Mon, 12 Aug 2019 23:45:26 +0300 Subject: [PATCH 469/735] changelog --- CHANGELOG.md | 40 +++++++++++----------- jason/CHANGELOG.md | 63 ++++++++++++++++++++++------------- proto/client-api/CHANGELOG.md | 54 ++++++++++++++++++------------ 3 files changed, 94 insertions(+), 63 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 521e89b80..12168679d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,27 +1,29 @@ -## [0.1.0] - 2019-08-09 +Change Log +========== + +All user visible changes to this project will be documented in this file. This project uses to [Semantic Versioning 2.0.0]. + + + + +## [0.1.0] · 2019-08-13 +[0.1.0]: https://github.com/instrumentisto/medea/releases/tag/medea-0.1.0 + [Milestone](https://github.com/instrumentisto/medea/milestone/1) | [Roadmap](https://github.com/instrumentisto/medea/issues/8) -Initial release. +### Added + +- Structured logging [#12](https://github.com/instrumentisto/medea/pull/12). +- Application configuration [#15](https://github.com/instrumentisto/medea/pull/15). +- [WebRTC signalling] [#16](https://github.com/instrumentisto/medea/pull/16). +- [Coturn] integration [#20](https://github.com/instrumentisto/medea/pull/20), + [#42](https://github.com/instrumentisto/medea/pull/42). +- Dockerized medea [#35](https://github.com/instrumentisto/medea/pull/35). +- Graceful shutdown [#30](https://github.com/instrumentisto/medea/pull/30). -### Implemented -- P2P video calls -- Structured logging ([#12]) -- Application configuration ([#15]) -- [WebRTC signalling] ([#16]) -- [Coturn] integration ([#20], [#42]) -- Dockerized medea ([#35]) -- Graceful shutdown ([#30]) -[0.1.0]: https://github.com/instrumentisto/medea/releases/tag/medea-0.1.0 [Coturn]: https://github.com/coturn/coturn -[WebRTC signalling]: https://webrtcglossary.com/signaling/ -[#12]: https://github.com/instrumentisto/medea/pull/12 -[#15]: https://github.com/instrumentisto/medea/pull/15 -[#16]: https://github.com/instrumentisto/medea/pull/16 -[#20]: https://github.com/instrumentisto/medea/pull/20 -[#42]: https://github.com/instrumentisto/medea/pull/42 -[#35]: https://github.com/instrumentisto/medea/pull/35 -[#30]: https://github.com/instrumentisto/medea/pull/30 +[Semantic Versioning 2.0.0]: https://semver.org diff --git a/jason/CHANGELOG.md b/jason/CHANGELOG.md index 409c36949..6554c30e6 100644 --- a/jason/CHANGELOG.md +++ b/jason/CHANGELOG.md @@ -1,30 +1,47 @@ -## [0.1.0] - 2019-08-09 +Change Log +========== + +All user visible changes to this project will be documented in this file. This project uses to [Semantic Versioning 2.0.0]. + + + + +## [0.1.0] · 2019-08-13 +[0.1.0]: https://github.com/instrumentisto/medea/releases/tag/medea-jason-0.1.0 + [Milestone](https://github.com/instrumentisto/medea/milestone/1) | [Roadmap](https://github.com/instrumentisto/medea/issues/8) -Initial release. +### Added -### Implemented +- Setup transport and messaging [#18](https://github.com/instrumentisto/medea/pull/18): + - External Jason API: + - `new Jason()` + - `Jason.join_room()` + - `Jason.dispose()` +- Use provided ICE servers [#20](https://github.com/instrumentisto/medea/pull/20). +- Signalling [#22](https://github.com/instrumentisto/medea/pull/22): + - External Jason API: + - `RoomHandle.on_new_connection` callback + - Handle RPC events: + - `PeerCreated` + - `SdpAnswerMade` + - `IceCandidateDiscovered` + - `PeersRemoved` + - Emit RPC commands: + - `MakeSdpOffer` + - `MakeSdpAnswer` + - `SetIceCandidate` +- Media management [#22](https://github.com/instrumentisto/medea/pull/22): + - External Jason API: + - `MediaStreamHandle.get_media_stream()` + - `ConnectionHandle.on_remote_stream` callback + - `Jason.on_local_stream` callback +- Demo application [#38](https://github.com/instrumentisto/medea/pull/38). +- Demo application [Helm] integration [41](https://github.com/instrumentisto/medea/pull/41). -- Setup toolchain ([#17]) -- Setup transport and messaging ([#18]) -- Signalling ([#22]): - - handle RPC events: - - `PeerCreated` - - `SdpAnswerMade` - - `IceCandidateDiscovered` - - `PeersRemoved` - - emit RPC commands: - - `MakeSdpOffer` - - `MakeSdpAnswer` - - `SetIceCandidate` -- Media management ([#22]): - - `MediaStream` management - - `RTCPeerConnection` management -- P2P video calls ([#22]) -[0.1.0]: https://github.com/instrumentisto/medea/releases/tag/medea-jason-0.1.0 -[#17]: https://github.com/instrumentisto/medea/pull/17 -[#18]: https://github.com/instrumentisto/medea/pull/18 -[#22]: https://github.com/instrumentisto/medea/pull/22 + +[Semantic Versioning 2.0.0]: https://semver.org +[Helm]: https://helm.sh \ No newline at end of file diff --git a/proto/client-api/CHANGELOG.md b/proto/client-api/CHANGELOG.md index 818a1da3d..894cce451 100644 --- a/proto/client-api/CHANGELOG.md +++ b/proto/client-api/CHANGELOG.md @@ -1,25 +1,37 @@ -## [0.1.0] - 2019-08-09 +Change Log +========== + +All user visible changes to this project will be documented in this file. This project uses to [Semantic Versioning 2.0.0]. + + + + +## [0.1.0] · 2019-08-13 +[0.1.0]: https://github.com/instrumentisto/medea/releases/tag/medea-client-api-proto-0.1.0 + [Milestone](https://github.com/instrumentisto/medea/milestone/1) | [Roadmap](https://github.com/instrumentisto/medea/issues/8) -Initial release. - -### Implemented - -- Server messages: - - `Pong` - - `Event` -- Client messages: - - `Ping` - - `Command` -- Client commands: - - `MakeSdpOffer` - - `MakeSdpAnswer` - - `SetIceCandidate` -- Server events: - - `PeerCreated` - - `SdpAnswerMade` - - `IceCandidateDiscovered` - - `PeersRemoved` +### Added -[0.1.0]: https://github.com/instrumentisto/medea/releases/tag/medea-client-api-proto-0.1.0 +- Client API RPC messages [#16](https://github.com/instrumentisto/medea/pull/16): + - Server messages: + - `Pong` + - `Event` + - Client messages: + - `Ping` + - `Command` + - Client commands: + - `MakeSdpOffer` + - `MakeSdpAnswer` + - `SetIceCandidate` + - Server events: + - `PeerCreated` + - `SdpAnswerMade` + - `IceCandidateDiscovered` + - `PeersRemoved` + + + + +[Semantic Versioning 2.0.0]: https://semver.org \ No newline at end of file From e34a9cc0b470892f6b7f7cc1247c180174218390 Mon Sep 17 00:00:00 2001 From: alexlapa Date: Tue, 13 Aug 2019 00:43:18 +0300 Subject: [PATCH 470/735] fix bad refs [skip ci] --- jason/src/api/connection.rs | 2 +- jason/src/api/room.rs | 8 ++++---- jason/src/media/stream.rs | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/jason/src/api/connection.rs b/jason/src/api/connection.rs index db134ab53..e54f8aa72 100644 --- a/jason/src/api/connection.rs +++ b/jason/src/api/connection.rs @@ -23,7 +23,7 @@ struct InnerConnection { /// Connection with a specific remote `Member`, that is used on JS side. /// -/// Actually, represents a [`Weak`]-based handle to [`InnerConnection`]. +/// Actually, represents a [`Weak`]-based handle to `InnerConnection`. #[allow(clippy::module_name_repetitions)] #[wasm_bindgen] pub struct ConnectionHandle(Weak>); diff --git a/jason/src/api/room.rs b/jason/src/api/room.rs index 89ecfa3fd..b6fb1bbfa 100644 --- a/jason/src/api/room.rs +++ b/jason/src/api/room.rs @@ -27,18 +27,18 @@ use crate::{ use super::{connection::Connection, ConnectionHandle}; -/// JS side handle to [`Room`] where all the media happens. +/// JS side handle to `Room` where all the media happens. /// -/// Actually, represents a [`Weak`]-based handle to [`InnerRoom`]. +/// Actually, represents a [`Weak`]-based handle to `InnerRoom`. /// -/// For using [`RoomHandle`] on Rust side, consider the [`Room`]. +/// For using [`RoomHandle`] on Rust side, consider the `Room`. #[allow(clippy::module_name_repetitions)] #[wasm_bindgen] pub struct RoomHandle(Weak>); #[wasm_bindgen] impl RoomHandle { - /// Sets callback, which will be invoked on new [`Connection`] establishing. + /// Sets callback, which will be invoked on new `Connection` establishing. pub fn on_new_connection( &mut self, f: js_sys::Function, diff --git a/jason/src/media/stream.rs b/jason/src/media/stream.rs index f480a71aa..335d3c1d3 100644 --- a/jason/src/media/stream.rs +++ b/jason/src/media/stream.rs @@ -105,7 +105,7 @@ impl MediaStream { /// JS side handle to [`MediaStream`]. /// -/// Actually, represents a [`Weak`]-based handle to [`InnerStream`]. +/// Actually, represents a [`Weak`]-based handle to `InnerStream`. /// /// For using [`MediaStreamHandle`] on Rust side, consider the [`MediaStream`]. #[wasm_bindgen] From a4c5f83102cbc6a8456b4ae7d58f0d380f658099 Mon Sep 17 00:00:00 2001 From: alexlapa Date: Tue, 13 Aug 2019 14:32:13 +0300 Subject: [PATCH 471/735] minor refactor, stop using nightly clippy --- Makefile | 2 +- crates/medea-macro/src/dispatchable.rs | 4 ++-- src/api/control/endpoint.rs | 15 ++++++--------- src/api/control/pipeline.rs | 14 +------------- src/conf/mod.rs | 4 ++-- 5 files changed, 12 insertions(+), 27 deletions(-) diff --git a/Makefile b/Makefile index 6a69e3eee..aaa18e1fe 100644 --- a/Makefile +++ b/Makefile @@ -186,7 +186,7 @@ cargo.fmt: # make cargo.lint cargo.lint: - cargo +nightly-2019-08-03 clippy --all -- -D clippy::pedantic -D warnings + cargo clippy --all -- -D clippy::pedantic -D warnings diff --git a/crates/medea-macro/src/dispatchable.rs b/crates/medea-macro/src/dispatchable.rs index bf1ec6126..6c7e92265 100644 --- a/crates/medea-macro/src/dispatchable.rs +++ b/crates/medea-macro/src/dispatchable.rs @@ -149,7 +149,7 @@ mod to_handler_fn_name_spec { #[test] fn converts_name_from_camel_case_to_snake_case() { - for (name, expected) in vec![ + for (name, expected) in &[ ("SomeTestTrait", "on_some_test_trait"), ("RPCConnection", "on_rpc_connection"), ("RConnection", "on_r_connection"), @@ -161,7 +161,7 @@ mod to_handler_fn_name_spec { ("s", "on_s"), ("ASDF", "on_asdf"), ] { - assert_eq!(to_handler_fn_name(name), expected); + assert_eq!(to_handler_fn_name(name), *expected); } } } diff --git a/src/api/control/endpoint.rs b/src/api/control/endpoint.rs index 326c3fb30..9dc88ee6b 100644 --- a/src/api/control/endpoint.rs +++ b/src/api/control/endpoint.rs @@ -186,27 +186,24 @@ mod src_uri_deserialization_tests { fn return_error_when_uri_not_local() { let invalid_json_uri = r#"{ "src": "not_local://room_id/member_id/endpoint_id" }"#; - match serde_json::from_str::(invalid_json_uri) { - Ok(_) => assert!(false), - Err(_) => assert!(true), + if serde_json::from_str::(invalid_json_uri).is_ok() { + unreachable!() } } #[test] fn return_error_when_uri_is_not_full() { let invalid_json_uri = r#"{ "src": "local://room_id/member_id" }"#; - match serde_json::from_str::(invalid_json_uri) { - Ok(_) => assert!(false), - Err(_) => assert!(true), + if serde_json::from_str::(invalid_json_uri).is_ok() { + unreachable!() } } #[test] fn return_error_when_uri_have_empty_part() { let invalid_json_uri = r#"{ "src": "local://room_id//endpoint_id" }"#; - match serde_json::from_str::(invalid_json_uri) { - Ok(_) => assert!(false), - Err(_) => assert!(true), + if serde_json::from_str::(invalid_json_uri).is_ok() { + unreachable!() } } } diff --git a/src/api/control/pipeline.rs b/src/api/control/pipeline.rs index 96fbad5ec..59e41dba3 100644 --- a/src/api/control/pipeline.rs +++ b/src/api/control/pipeline.rs @@ -1,10 +1,7 @@ //! Control API specification Pipeline definition. use std::{ - collections::{ - hash_map::{IntoIter, Iter}, - HashMap, - }, + collections::{hash_map::Iter, HashMap}, iter::IntoIterator, }; @@ -26,15 +23,6 @@ impl Pipeline { } } -impl IntoIterator for Pipeline { - type IntoIter = IntoIter; - type Item = (String, T); - - fn into_iter(self) -> Self::IntoIter { - self.pipeline.into_iter() - } -} - impl<'a, T> IntoIterator for &'a Pipeline { type IntoIter = Iter<'a, String, T>; type Item = (&'a String, &'a T); diff --git a/src/conf/mod.rs b/src/conf/mod.rs index dc10a2b83..44e59bc0d 100644 --- a/src/conf/mod.rs +++ b/src/conf/mod.rs @@ -153,7 +153,7 @@ mod tests { let defaults = Conf::default(); let test_config_file_path = "test_config.toml"; - let data = format!("[rpc]\nidle_timeout = \"45s\""); + let data = "[rpc]\nidle_timeout = \"45s\"".to_owned(); fs::write(test_config_file_path, data).unwrap(); env::set_var(APP_CONF_PATH_ENV_VAR_NAME, test_config_file_path); @@ -184,7 +184,7 @@ mod tests { fn conf_parse_spec_env_overrides_file() { let test_config_file_path = "test_config.toml"; - let data = format!("[rpc]\nidle_timeout = \"47s\""); + let data = "[rpc]\nidle_timeout = \"47s\"".to_owned(); fs::write(test_config_file_path, data).unwrap(); env::set_var(APP_CONF_PATH_ENV_VAR_NAME, test_config_file_path); From f755fb8cb742a13734446d346329b73e2f32c9cf Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 13 Aug 2019 17:35:05 +0300 Subject: [PATCH 472/735] Try to fix jason build --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f16b53cc2..d2dcfcc80 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,7 +29,6 @@ jobs: name: "Build jason (Rust stable)" before_script: - rm -f /home/travis/.cargo/bin/wasm-pack - - make yarn dockerized=no - curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh script: - wasm-pack build -t web jason From 3c7bcb3c6fb3dee10d91b170d0f5a5b1ee9eafde Mon Sep 17 00:00:00 2001 From: alexlapa Date: Tue, 13 Aug 2019 18:13:15 +0300 Subject: [PATCH 473/735] add todos, delete signalling_test cause we dont need it anymore --- signaling_test.html | 204 ---------------------------------------- src/signalling/peers.rs | 2 + src/signalling/room.rs | 2 + 3 files changed, 4 insertions(+), 204 deletions(-) delete mode 100644 signaling_test.html diff --git a/signaling_test.html b/signaling_test.html deleted file mode 100644 index 1dd643d61..000000000 --- a/signaling_test.html +++ /dev/null @@ -1,204 +0,0 @@ - - - - Chat - - - - - - - -
-
- - You -
-
- - Partner -
-
-
- - -
- - diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index b69e289c9..a0f8bf690 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -181,6 +181,8 @@ impl PeerRepository { } } + // TODO: -> HashMap>, and remove context from args + /// Close all related to disconnected [`Member`] [`Peer`]s and partner /// [`Peer`]s. /// diff --git a/src/signalling/room.rs b/src/signalling/room.rs index c18d0f9d8..3f1a203e0 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -521,6 +521,8 @@ pub struct PeersRemoved { impl Handler for Room { type Result = ActFuture<(), ()>; + //TODO: notify only about peers taht are owned by this member + /// Send [`Event::PeersRemoved`] to remote [`Member`]. /// /// Delete all removed [`PeerId`]s from all [`Member`]'s From 38c24a83cc52bd6757de5de16ad993818575b6d4 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 13 Aug 2019 18:32:06 +0300 Subject: [PATCH 474/735] Notify only abour peers that are owned by this member --- src/signalling/peers.rs | 5 ----- src/signalling/room.rs | 2 -- 2 files changed, 7 deletions(-) diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index a0f8bf690..a4dde5c02 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -207,11 +207,6 @@ impl PeerRepository { .push(partner_peer.id()); }); - peers_to_remove - .entry(peer.partner_member_id()) - .or_insert_with(Vec::new) - .push(peer.id()); - peers_to_remove .entry(peer.member_id()) .or_insert_with(Vec::new) diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 3f1a203e0..c18d0f9d8 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -521,8 +521,6 @@ pub struct PeersRemoved { impl Handler for Room { type Result = ActFuture<(), ()>; - //TODO: notify only about peers taht are owned by this member - /// Send [`Event::PeersRemoved`] to remote [`Member`]. /// /// Delete all removed [`PeerId`]s from all [`Member`]'s From abfb6dd6ebbf69610bde51da07f3d9e8b44f2423 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 13 Aug 2019 18:57:16 +0300 Subject: [PATCH 475/735] Remove context from peer's connection_closed args --- src/signalling/peers.rs | 36 +++++++++++++++--------------------- src/signalling/room.rs | 16 +++++++++++++++- 2 files changed, 30 insertions(+), 22 deletions(-) diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index a4dde5c02..b28c91bdd 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -9,17 +9,13 @@ use std::{ fmt, }; -use actix::{AsyncContext as _, Context}; use medea_client_api_proto::{Incrementable, PeerId, TrackId}; use crate::{ api::control::MemberId, log::prelude::*, media::{New, Peer, PeerStateMachine}, - signalling::{ - elements::Member, - room::{PeersRemoved, Room, RoomError}, - }, + signalling::{elements::Member, room::RoomError}, }; #[derive(Debug)] @@ -181,17 +177,16 @@ impl PeerRepository { } } - // TODO: -> HashMap>, and remove context from args - - /// Close all related to disconnected [`Member`] [`Peer`]s and partner - /// [`Peer`]s. + /// Remove all related to [`Member`] [`Peer`]s. + /// Note that this function will also remove all partners [`Peer`]s. /// - /// Send [`Event::PeersRemoved`] to all affected [`Member`]s. - pub fn connection_closed( + /// Returns `HashMap` with all remove [`Peer`]s. + /// Key - [`Peer`]'s owner [`MemberId`], + /// value - removed [`Peer`]'s [`PeerId`]. + pub fn remove_peers_related_to_member( &mut self, member_id: &MemberId, - ctx: &mut Context, - ) { + ) -> HashMap> { let mut peers_to_remove: HashMap> = HashMap::new(); @@ -213,15 +208,14 @@ impl PeerRepository { .push(peer.id()); }); - for (peer_member_id, peers_id) in peers_to_remove { - for peer_id in &peers_id { + peers_to_remove + .values() + .flat_map(|peer_ids| peer_ids.iter()) + .for_each(|peer_id| { self.peers.remove(peer_id); - } - ctx.notify(PeersRemoved { - member_id: peer_member_id, - peers_id, - }) - } + }); + + peers_to_remove } } diff --git a/src/signalling/room.rs b/src/signalling/room.rs index c18d0f9d8..f29634e0d 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -669,7 +669,13 @@ impl Handler for Room { type Result = (); /// Passes message to [`ParticipantService`] to cleanup stored connections. + /// /// Remove all related for disconnected [`Member`] [`Peer`]s. + /// + /// Send [`PeersRemoved`] message to [`Member`]. + /// + /// Delete all removed [`PeerId`]s from all [`Member`]'s + /// endpoints. fn handle(&mut self, msg: RpcConnectionClosed, ctx: &mut Self::Context) { info!( "RpcConnectionClosed for member {}, reason {:?}", @@ -677,7 +683,15 @@ impl Handler for Room { ); if let ClosedReason::Closed = msg.reason { - self.peers.connection_closed(&msg.member_id, ctx); + let removed_peers = + self.peers.remove_peers_related_to_member(&msg.member_id); + + for (peer_member_id, peers_ids) in removed_peers { + ctx.notify(PeersRemoved { + member_id: peer_member_id, + peers_id: peers_ids, + }) + } } self.members From 05d051d835089afe526e29d567d148b6a64e3785 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 13 Aug 2019 19:03:58 +0300 Subject: [PATCH 476/735] Fix Makefile test.unit --- Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Makefile b/Makefile index ec1f49720..ec4fe6fcd 100644 --- a/Makefile +++ b/Makefile @@ -261,9 +261,13 @@ ifeq ($(test-unit-crate),@all) @make test.unit crate=medea-client-api-proto @make test.unit crate=medea-macro @make test.unit crate=medea +else +ifeq ($(test-unit-crate),medea) + cargo test --lib --bin medea else cargo test -p $(test-unit-crate) endif +endif # Run Rust e2e tests of project. From 1497199c8cc3a8c20189946c16e57d45a2004bfa Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 13 Aug 2019 19:52:56 +0300 Subject: [PATCH 477/735] Fix e2e test --- tests/e2e/signalling/three_pubs.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/e2e/signalling/three_pubs.rs b/tests/e2e/signalling/three_pubs.rs index be5112478..b32d781d7 100644 --- a/tests/e2e/signalling/three_pubs.rs +++ b/tests/e2e/signalling/three_pubs.rs @@ -108,8 +108,7 @@ fn three_members_p2p_video_call() { }) .collect(); assert_eq!(peers_removed.len(), 1); - assert_eq!(peers_removed[0].len(), 2); - assert_ne!(peers_removed[0][0], peers_removed[0][1]); + assert_eq!(peers_removed[0].len(), 1); members_peers_removed.set(members_peers_removed.get() + 1); // Stop when all members receive Event::PeerRemoved From 38526222eb3adbbf7c07f88bd908ae3ee45ad20a Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 13 Aug 2019 20:28:53 +0300 Subject: [PATCH 478/735] Fix returning error code when test failed --- Makefile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Makefile b/Makefile index ec4fe6fcd..bda874761 100644 --- a/Makefile +++ b/Makefile @@ -292,9 +292,7 @@ ifeq ($(dockerized),no) env $(medea-env) $(if $(call eq,$(logs),yes),,RUST_LOG=warn) cargo run $(if $(call eq,$(release),yes),--release) & sleep 1 - - cargo test --test e2e - - @make down.medea + cargo test --test e2e && make down.medea dockerized=no || make down.medea dockerized=no && exit 1 ifneq ($(coturn),no) @make down.coturn endif From 0df52c6aaa9163cb976dccc53387b94f29cf3697 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 14 Aug 2019 12:17:32 +0300 Subject: [PATCH 479/735] Fix test results returning for CI --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index bda874761..0c29a6a66 100644 --- a/Makefile +++ b/Makefile @@ -292,7 +292,8 @@ ifeq ($(dockerized),no) env $(medea-env) $(if $(call eq,$(logs),yes),,RUST_LOG=warn) cargo run $(if $(call eq,$(release),yes),--release) & sleep 1 - cargo test --test e2e && make down.medea dockerized=no || make down.medea dockerized=no && exit 1 + cargo test --test e2e + - killall medea ifneq ($(coturn),no) @make down.coturn endif From 087d5e89539003462b6dbf2dd28d2b1a3463811c Mon Sep 17 00:00:00 2001 From: alexlapa Date: Wed, 14 Aug 2019 15:15:54 +0300 Subject: [PATCH 480/735] add todos --- CHANGELOG.md | 2 ++ src/signalling/room.rs | 2 ++ 2 files changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 12168679d..a9b6d714a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ Change Log All user visible changes to this project will be documented in this file. This project uses to [Semantic Versioning 2.0.0]. +# TODO: do not forget to add changes + ## [0.1.0] · 2019-08-13 diff --git a/src/signalling/room.rs b/src/signalling/room.rs index f29634e0d..fbc798418 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -518,6 +518,8 @@ pub struct PeersRemoved { pub member_id: MemberId, } + +// TODO: do we really need this message atm? move this logic to send_peers_removed? impl Handler for Room { type Result = ActFuture<(), ()>; From 184e1aa86ddb5b9cfb5ddc9bfcffc6b9fa9379d7 Mon Sep 17 00:00:00 2001 From: alexlapa Date: Wed, 14 Aug 2019 15:47:36 +0300 Subject: [PATCH 481/735] add todos --- src/conf/mod.rs | 6 ++++++ src/conf/server.rs | 2 ++ src/signalling/room_service.rs | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/src/conf/mod.rs b/src/conf/mod.rs index 79d7d11fa..55d23b50c 100644 --- a/src/conf/mod.rs +++ b/src/conf/mod.rs @@ -40,6 +40,9 @@ pub struct Conf { pub server: Server, /// TURN server settings. pub turn: Turn, + + // TODO: move it to server section, so we will have server.http && + // server.grpc /// gRPC server settings. pub grpc: Grpc, /// Logging settings. @@ -67,6 +70,9 @@ impl Conf { Ok(cfg.try_into()?) } + // TODO: any reason why this func is here and not in impl Server? + // dont hardcode scheme, just store it in 'host' field + // and dont forget to update helm configs pub fn get_base_rpc_url(&self) -> String { format!("wss://{}", self.server.host) } diff --git a/src/conf/server.rs b/src/conf/server.rs index 3e1167221..80dcbb56c 100644 --- a/src/conf/server.rs +++ b/src/conf/server.rs @@ -9,6 +9,8 @@ use smart_default::SmartDefault; #[derive(Clone, Debug, Deserialize, Serialize, SmartDefault)] #[serde(default)] pub struct Server { + // TODO: change to public_url, move to RPC, improve docs, since this param + // is quite important /// Server host. #[default("localhost:8080".to_string())] pub host: String, diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index 9cf05ef42..2d1136c60 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -171,6 +171,8 @@ impl Handler for RoomService { let room = Room::new(&room, self.app.clone())?; let room_addr = room.start(); + // TODO: lets add some static method in shutdown module to encapsulate + // this boilerplate self.graceful_shutdown.do_send(shutdown::Subscribe( shutdown::Subscriber { priority: shutdown::Priority(2), @@ -199,6 +201,8 @@ impl Handler for RoomService { ctx: &mut Self::Context, ) -> Self::Result { if let Some(room) = self.room_repo.get(&msg.0) { + // TODO: lets add some static method in shutdown module to + // encapsulate this boilerplate self.graceful_shutdown.do_send(shutdown::Unsubscribe( shutdown::Subscriber { priority: shutdown::Priority(2), From 9d21b78bc83380a5e1f005248d597fbc361f732c Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 14 Aug 2019 15:52:20 +0300 Subject: [PATCH 482/735] Update CHANGELOG [skip ci] --- CHANGELOG.md | 19 ++++++++++++++++++- proto/client-api/CHANGELOG.md | 16 +++++++++++++++- src/signalling/room.rs | 4 ++-- 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a9b6d714a..28238b9f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,24 @@ Change Log All user visible changes to this project will be documented in this file. This project uses to [Semantic Versioning 2.0.0]. -# TODO: do not forget to add changes + + +## [0.2.0] · 2019-?-? +[0.2.0]: https://github.com/instrumentisto/medea/releases/tag/medea-0.2.0 + +[Milestone](https://github.com/instrumentisto/medea/milestone/2) | +[Roadmap](https://github.com/instrumentisto/medea/issues/27) + +### Added + +- Static control API spec [#28](https://github.com/instrumentisto/medea/pull/28) + - parse static control api specs + - created interior entities for control API specs + - dynamically `Peer`s creation when client connects + - auto removing `Peer`s when `Member` disconnects + - E2E tests for signalling + + diff --git a/proto/client-api/CHANGELOG.md b/proto/client-api/CHANGELOG.md index 894cce451..19632f5a6 100644 --- a/proto/client-api/CHANGELOG.md +++ b/proto/client-api/CHANGELOG.md @@ -6,6 +6,20 @@ All user visible changes to this project will be documented in this file. This p +## [0.2.0] · 2019-?-? +[0.2.0]: https://github.com/instrumentisto/medea/releases/tag/medea-client-api-proto-0.2.0 + +[Milestone](https://github.com/instrumentisto/medea/milestone/2) | +[Roadmap](https://github.com/instrumentisto/medea/issues/27) + +### Added + +- `PeerId` and `TrackId` +- `Incrementable` trait for IDs + + + + ## [0.1.0] · 2019-08-13 [0.1.0]: https://github.com/instrumentisto/medea/releases/tag/medea-client-api-proto-0.1.0 @@ -34,4 +48,4 @@ All user visible changes to this project will be documented in this file. This p -[Semantic Versioning 2.0.0]: https://semver.org \ No newline at end of file +[Semantic Versioning 2.0.0]: https://semver.org diff --git a/src/signalling/room.rs b/src/signalling/room.rs index fbc798418..a4d702bd4 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -518,8 +518,8 @@ pub struct PeersRemoved { pub member_id: MemberId, } - -// TODO: do we really need this message atm? move this logic to send_peers_removed? +// TODO: do we really need this message atm? move this logic to +// send_peers_removed? impl Handler for Room { type Result = ActFuture<(), ()>; From 7ccd5fa677fa2c72be5feb588f79dd68c2b3ba7d Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 14 Aug 2019 16:42:10 +0300 Subject: [PATCH 483/735] Create static function for subscribe and unsubscribe GracefulShutdown --- src/main.rs | 22 +++++++++----------- src/shutdown.rs | 30 ++++++++++++++++++++++++--- src/signalling/room_service.rs | 37 ++++++++++++++-------------------- 3 files changed, 52 insertions(+), 37 deletions(-) diff --git a/src/main.rs b/src/main.rs index c2acb51b3..0eb916b04 100644 --- a/src/main.rs +++ b/src/main.rs @@ -58,20 +58,18 @@ fn main() -> Result<(), Error> { .map(move |_| { let grpc_addr = grpc::server::run(room_service, app_context); - graceful_shutdown.do_send(shutdown::Subscribe( - shutdown::Subscriber { - priority: shutdown::Priority(1), - addr: grpc_addr.clone().recipient(), - }, - )); + shutdown::subscribe( + &graceful_shutdown, + grpc_addr.clone().recipient(), + shutdown::Priority(1), + ); let server = Server::run(room_repo, config).unwrap(); - graceful_shutdown.do_send(shutdown::Subscribe( - shutdown::Subscriber { - priority: shutdown::Priority(1), - addr: server.recipient(), - }, - )); + shutdown::subscribe( + &graceful_shutdown, + server.recipient(), + shutdown::Priority(1), + ); }) }) }) diff --git a/src/shutdown.rs b/src/shutdown.rs index 4b5f54208..fb62b9ac4 100644 --- a/src/shutdown.rs +++ b/src/shutdown.rs @@ -7,7 +7,7 @@ use std::{ use actix::{ prelude::{Actor, Context}, - AsyncContext, Handler, Message, Recipient, ResponseActFuture, System, + Addr, AsyncContext, Handler, Message, Recipient, ResponseActFuture, System, WrapFuture as _, }; use failure::Fail; @@ -181,7 +181,7 @@ pub struct Subscriber { /// Message that [`Subscriber`] subscribes to shutdown messages with. #[derive(Message)] #[rtype(result = "Result<(), ShuttingDownError>")] -pub struct Subscribe(pub Subscriber); +struct Subscribe(pub Subscriber); impl Handler for GracefulShutdown { type Result = Result<(), ShuttingDownError>; @@ -208,7 +208,7 @@ pub struct ShuttingDownError; /// notifications with. #[derive(Message)] #[rtype(result = "()")] -pub struct Unsubscribe(pub Subscriber); +struct Unsubscribe(pub Subscriber); impl Handler for GracefulShutdown { type Result = (); @@ -227,3 +227,27 @@ impl Handler for GracefulShutdown { } } } + +/// Subscribe recipient to [`GracefulShutdown`]. +pub fn subscribe( + shutdown_addr: &Addr, + subscriber: Recipient, + priority: Priority, +) { + shutdown_addr.do_send(Subscribe(Subscriber { + priority, + addr: subscriber, + })); +} + +/// Unsubscribe recipient from [`GracefulShutdown`]. +pub fn unsubscribe( + shutdown_addr: &Addr, + subscriber: Recipient, + priority: Priority, +) { + shutdown_addr.do_send(Unsubscribe(Subscriber { + priority, + addr: subscriber, + })); +} diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index 2d1136c60..f82592cec 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -132,12 +132,11 @@ impl Handler for RoomService { let room_id = spec.id().clone(); let room = Room::new(&spec, self.app.clone())?.start(); - self.graceful_shutdown.do_send(shutdown::Subscribe( - shutdown::Subscriber { - priority: shutdown::Priority(2), - addr: room.clone().recipient(), - }, - )); + shutdown::subscribe( + &self.graceful_shutdown, + room.clone().recipient(), + shutdown::Priority(2), + ); self.room_repo.add(room_id, room); } @@ -171,14 +170,11 @@ impl Handler for RoomService { let room = Room::new(&room, self.app.clone())?; let room_addr = room.start(); - // TODO: lets add some static method in shutdown module to encapsulate - // this boilerplate - self.graceful_shutdown.do_send(shutdown::Subscribe( - shutdown::Subscriber { - priority: shutdown::Priority(2), - addr: room_addr.clone().recipient(), - }, - )); + shutdown::subscribe( + &self.graceful_shutdown, + room_addr.clone().recipient(), + shutdown::Priority(2), + ); debug!("New Room [id = {}] started.", room_id); self.room_repo.add(room_id, room_addr); @@ -201,14 +197,11 @@ impl Handler for RoomService { ctx: &mut Self::Context, ) -> Self::Result { if let Some(room) = self.room_repo.get(&msg.0) { - // TODO: lets add some static method in shutdown module to - // encapsulate this boilerplate - self.graceful_shutdown.do_send(shutdown::Unsubscribe( - shutdown::Subscriber { - priority: shutdown::Priority(2), - addr: room.clone().recipient(), - }, - )); + shutdown::unsubscribe( + &self.graceful_shutdown, + room.clone().recipient(), + shutdown::Priority(2), + ); let rooms = self.room_repo.clone(); ctx.spawn(wrap_future( room.send(Close) From 75c018dee61205a9d4f17915ab91e7b2fb155add Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 14 Aug 2019 17:20:55 +0300 Subject: [PATCH 484/735] Move grpc and http to server module of config --- .travis.yml | 1 - Makefile | 13 +++--- config.toml | 40 ++++++++--------- src/api/client/server.rs | 2 +- src/api/control/grpc/server.rs | 6 +-- src/conf/http_server.rs | 81 ++++++++++++++++++++++++++++++++++ src/conf/mod.rs | 13 +++--- src/conf/server.rs | 77 ++++---------------------------- src/signalling/room_service.rs | 2 +- 9 files changed, 130 insertions(+), 105 deletions(-) create mode 100644 src/conf/http_server.rs diff --git a/.travis.yml b/.travis.yml index 74086cac9..84b0c4803 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,7 +38,6 @@ jobs: name: "Build jason (Rust stable)" before_script: - rm -f /home/travis/.cargo/bin/wasm-pack - - make yarn dockerized=no - curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh script: - wasm-pack build -t web jason diff --git a/Makefile b/Makefile index 247a42fea..bcfa81244 100644 --- a/Makefile +++ b/Makefile @@ -264,9 +264,13 @@ ifeq ($(test-unit-crate),@all) @make test.unit crate=medea-client-api-proto @make test.unit crate=medea-macro @make test.unit crate=medea +else +ifeq ($(test-unit-crate),medea) + cargo test --lib --bin medea else cargo test -p $(test-unit-crate) endif +endif # Run Rust e2e tests of project. @@ -276,9 +280,9 @@ endif # make test.e2e [dockerized=(YES|no)] [logs=(yes|NO)] [coturn=(YES|no)] medea-env = RUST_BACKTRACE=1 \ - MEDEA_SERVER.BIND_PORT=8081 \ + MEDEA_SERVER.HTTP.BIND_PORT=8081 \ $(if $(call eq,$(logs),yes),,RUST_LOG=warn) \ - MEDEA_SERVER.STATIC_SPECS_PATH=tests/specs + MEDEA_SERVER.HTTP.STATIC_SPECS_PATH=tests/specs test.e2e: ifneq ($(coturn),no) @@ -291,9 +295,8 @@ ifeq ($(dockerized),no) env $(medea-env) $(if $(call eq,$(logs),yes),,RUST_LOG=warn) cargo run --bin medea $(if $(call eq,$(release),yes),--release) & sleep 1 - - cargo test --test e2e - - @make down.medea + cargo test --test e2e + - killall medea ifneq ($(coturn),no) @make down.coturn endif diff --git a/config.toml b/config.toml index 876ece40d..39ee9e5c7 100644 --- a/config.toml +++ b/config.toml @@ -1,4 +1,4 @@ -[server] +[server.http] # Server host # # Default: @@ -23,6 +23,25 @@ static_specs_path = "dev/specs" +[server.grpc] +# IP address to bind gRPC server to. +# +# Default: +# bind_ip = "0.0.0.0" + +# Port to bind gRPC server to. +# +# Default: +# bind_port = 50051 + +# Completion queue count of gRPC server. +# +# Default: +# completion_queue_count = 2 + + + + [rpc] # Duration, after which remote RPC client will be considered idle if no # heartbeat messages received. @@ -89,25 +108,6 @@ static_specs_path = "dev/specs" -[grpc] -# IP address to bind gRPC server to. -# -# Default: -# bind_ip = "0.0.0.0" - -# Port to bind gRPC server to. -# -# Default: -# bind_port = 50051 - -# Completion queue count of gRPC server. -# -# Default: -# completion_queue_count = 2 - - - - [log] # Maximum allowed level of application log entries. # diff --git a/src/api/client/server.rs b/src/api/client/server.rs index a9ce3cf4a..60a7e4a93 100644 --- a/src/api/client/server.rs +++ b/src/api/client/server.rs @@ -97,7 +97,7 @@ pub struct Server(ActixServer); impl Server { /// Starts Client API HTTP server. pub fn run(rooms: RoomRepository, config: Conf) -> io::Result> { - let server_addr = config.server.bind_addr(); + let server_addr = config.server.http.bind_addr(); let server = HttpServer::new(move || { App::new() diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index 15cc80958..a4916d07a 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -607,9 +607,9 @@ impl Handler for GrpcServer { /// Run gRPC server in actix actor. pub fn run(room_repo: Addr, app: AppContext) -> Addr { - let bind_ip = app.config.grpc.bind_ip.to_string(); - let bind_port = app.config.grpc.bind_port; - let cq_count = app.config.grpc.completion_queue_count; + let bind_ip = app.config.server.grpc.bind_ip.to_string(); + let bind_port = app.config.server.grpc.bind_port; + let cq_count = app.config.server.grpc.completion_queue_count; let service = create_control_api(ControlApiService { app, diff --git a/src/conf/http_server.rs b/src/conf/http_server.rs new file mode 100644 index 000000000..2edbe5b0a --- /dev/null +++ b/src/conf/http_server.rs @@ -0,0 +1,81 @@ +//! HTTP server settings. + +use std::net::{IpAddr, Ipv4Addr, SocketAddr, ToSocketAddrs as _}; + +use serde::{Deserialize, Serialize}; +use smart_default::SmartDefault; + +/// HTTP server settings. +#[derive(Clone, Debug, Deserialize, Serialize, SmartDefault)] +#[serde(default)] +pub struct HttpServer { + // TODO: change to public_url, move to RPC, improve docs, since this param + // is quite important + /// Server host. + #[default("localhost:8080".to_string())] + pub host: String, + + /// IP address to bind HTTP server to. Defaults to `0.0.0.0`. + #[default(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)))] + pub bind_ip: IpAddr, + + /// Port to bind HTTP server to. Defaults to `8080`. + #[default(8080)] + pub bind_port: u16, + + /// Path to directory with static control API specs. + pub static_specs_path: Option, +} + +impl HttpServer { + /// Builds [`SocketAddr`] from `bind_ip` and `bind_port`. + #[inline] + pub fn bind_addr(&self) -> SocketAddr { + (self.bind_ip, self.bind_port) + .to_socket_addrs() + .unwrap() + .next() + .unwrap() + } +} + +#[cfg(test)] +mod server_spec { + use std::env; + + use serial_test_derive::serial; + + use crate::conf::Conf; + + use super::*; + + #[test] + #[serial] + fn overrides_defaults_and_gets_bind_addr() { + let default_conf = Conf::default(); + + env::set_var("MEDEA_SERVER.HTTP.BIND_IP", "5.5.5.5"); + env::set_var("MEDEA_SERVER.HTTP.BIND_PORT", "1234"); + + let env_conf = Conf::parse().unwrap(); + + env::remove_var("MEDEA_SERVER.HTTP.BIND_IP"); + env::remove_var("MEDEA_SERVER.HTTP.BIND_PORT"); + + assert_ne!( + default_conf.server.http.bind_ip, + env_conf.server.http.bind_ip + ); + assert_ne!( + default_conf.server.http.bind_port, + env_conf.server.http.bind_port + ); + + assert_eq!(env_conf.server.http.bind_ip, Ipv4Addr::new(5, 5, 5, 5)); + assert_eq!(env_conf.server.http.bind_port, 1234); + assert_eq!( + env_conf.server.http.bind_addr(), + "5.5.5.5:1234".parse().unwrap(), + ); + } +} diff --git a/src/conf/mod.rs b/src/conf/mod.rs index 55d23b50c..73a3c1232 100644 --- a/src/conf/mod.rs +++ b/src/conf/mod.rs @@ -1,6 +1,7 @@ //! Provides application configuration options. pub mod grpc; +pub mod http_server; pub mod log; pub mod rpc; pub mod server; @@ -16,6 +17,7 @@ use serde::{Deserialize, Serialize}; #[doc(inline)] pub use self::{ grpc::Grpc, + http_server::HttpServer, log::Log, rpc::Rpc, server::Server, @@ -36,17 +38,16 @@ static APP_CONF_PATH_ENV_VAR_NAME: &str = "MEDEA_CONF"; pub struct Conf { /// HTTP server settings. pub rpc: Rpc, - /// RPC connection settings. + + /// Servers related settings. pub server: Server, + /// TURN server settings. pub turn: Turn, - // TODO: move it to server section, so we will have server.http && - // server.grpc - /// gRPC server settings. - pub grpc: Grpc, /// Logging settings. pub log: Log, + /// Application shutdown settings. pub shutdown: Shutdown, } @@ -74,7 +75,7 @@ impl Conf { // dont hardcode scheme, just store it in 'host' field // and dont forget to update helm configs pub fn get_base_rpc_url(&self) -> String { - format!("wss://{}", self.server.host) + format!("wss://{}", self.server.http.host) } } diff --git a/src/conf/server.rs b/src/conf/server.rs index 80dcbb56c..776830059 100644 --- a/src/conf/server.rs +++ b/src/conf/server.rs @@ -1,75 +1,16 @@ -//! HTTP server settings. - -use std::net::{IpAddr, Ipv4Addr, SocketAddr, ToSocketAddrs as _}; +//! Servers related settings. use serde::{Deserialize, Serialize}; -use smart_default::SmartDefault; -/// HTTP server settings. -#[derive(Clone, Debug, Deserialize, Serialize, SmartDefault)] +use super::{grpc::Grpc, http_server::HttpServer}; + +/// Servers related settings. +#[derive(Clone, Debug, Deserialize, Serialize, Default)] #[serde(default)] pub struct Server { - // TODO: change to public_url, move to RPC, improve docs, since this param - // is quite important - /// Server host. - #[default("localhost:8080".to_string())] - pub host: String, - - /// IP address to bind HTTP server to. Defaults to `0.0.0.0`. - #[default(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)))] - pub bind_ip: IpAddr, - - /// Port to bind HTTP server to. Defaults to `8080`. - #[default(8080)] - pub bind_port: u16, - - /// Path to directory with static control API specs. - pub static_specs_path: Option, -} - -impl Server { - /// Builds [`SocketAddr`] from `bind_ip` and `bind_port`. - #[inline] - pub fn bind_addr(&self) -> SocketAddr { - (self.bind_ip, self.bind_port) - .to_socket_addrs() - .unwrap() - .next() - .unwrap() - } -} - -#[cfg(test)] -mod server_spec { - use std::env; - - use serial_test_derive::serial; - - use crate::conf::Conf; - - use super::*; - - #[test] - #[serial] - fn overrides_defaults_and_gets_bind_addr() { - let default_conf = Conf::default(); - - env::set_var("MEDEA_SERVER.BIND_IP", "5.5.5.5"); - env::set_var("MEDEA_SERVER.BIND_PORT", "1234"); - - let env_conf = Conf::parse().unwrap(); - - env::remove_var("MEDEA_SERVER.BIND_IP"); - env::remove_var("MEDEA_SERVER.BIND_PORT"); - - assert_ne!(default_conf.server.bind_ip, env_conf.server.bind_ip); - assert_ne!(default_conf.server.bind_port, env_conf.server.bind_port); + /// RPC connection settings. + pub http: HttpServer, - assert_eq!(env_conf.server.bind_ip, Ipv4Addr::new(5, 5, 5, 5)); - assert_eq!(env_conf.server.bind_port, 1234); - assert_eq!( - env_conf.server.bind_addr(), - "5.5.5.5:1234".parse().unwrap(), - ); - } + /// gRPC server settings. + pub grpc: Grpc, } diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index f82592cec..3ac41fda5 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -112,7 +112,7 @@ impl Handler for RoomService { _: &mut Self::Context, ) -> Self::Result { if let Some(static_specs_path) = - self.app.config.server.static_specs_path.clone() + self.app.config.server.http.static_specs_path.clone() { let room_specs = match load_static_specs_from_dir(static_specs_path) { From b92d6a6b1f248822d87e6c4fc104ece4c4e2a596 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 14 Aug 2019 17:53:55 +0300 Subject: [PATCH 485/735] Update helm configs --- docker-compose.medea.yml | 4 ++-- .../chart/medea-demo/templates/deployment.server.yaml | 8 +++++--- jason/demo/chart/medea-demo/values.yaml | 4 +++- jason/demo/staging.vals.yaml | 4 +++- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/docker-compose.medea.yml b/docker-compose.medea.yml index d44552280..134bb34a8 100644 --- a/docker-compose.medea.yml +++ b/docker-compose.medea.yml @@ -14,5 +14,5 @@ services: environment: RUST_LOG: ${RUST_LOG} MEDEA_CONF: "config.toml" - MEDEA_SERVER.BIND_PORT: ${MEDEA_SERVER_BIND_PORT} - MEDEA_SERVER.STATIC_SPECS_PATH: ${MEDEA_SERVER_STATIC_SPECS_PATH} + MEDEA_SERVER.HTTP.BIND_PORT: ${MEDEA_SERVER_BIND_PORT} + MEDEA_SERVER.HTTP.STATIC_SPECS_PATH: ${MEDEA_SERVER_STATIC_SPECS_PATH} diff --git a/jason/demo/chart/medea-demo/templates/deployment.server.yaml b/jason/demo/chart/medea-demo/templates/deployment.server.yaml index 651f97923..b91cd6415 100644 --- a/jason/demo/chart/medea-demo/templates/deployment.server.yaml +++ b/jason/demo/chart/medea-demo/templates/deployment.server.yaml @@ -64,12 +64,14 @@ spec: value: {{ $coturn.conf.listening_port | quote }} - name: MEDEA_TURN.DB.REDIS.PORT value: {{ $coturnDb.conf.port | quote }} + - name: MEDEA_SERVER.HTTP.HOST + value: {{ .Values.server.conf.server.http.host }} envFrom: - secretRef: name: {{ template "medea-demo.fullname" . }}.server.cred ports: - name: http - containerPort: {{ .Values.server.conf.server.bind_port }} + containerPort: {{ .Values.server.conf.server.http.bind_port }} volumeMounts: - name: conf subPath: medea.toml @@ -80,11 +82,11 @@ spec: {{- end }} livenessProbe: tcpSocket: - port: {{ .Values.server.conf.server.bind_port }} + port: {{ .Values.server.conf.server.http.bind_port }} initialDelaySeconds: 3 readinessProbe: tcpSocket: - port: {{ .Values.server.conf.server.bind_port }} + port: {{ .Values.server.conf.server.http.bind_port }} initialDelaySeconds: 5 - name: coturn image: "{{ $coturn.image.repository }}:{{ $coturn.image.tag }}" diff --git a/jason/demo/chart/medea-demo/values.yaml b/jason/demo/chart/medea-demo/values.yaml index ce1628bc2..8cfec77a0 100644 --- a/jason/demo/chart/medea-demo/values.yaml +++ b/jason/demo/chart/medea-demo/values.yaml @@ -16,7 +16,9 @@ server: # configuration will have no effect. conf: server: - bind_port: 8080 + http: + bind_port: 8080 + host: "" turn: user: USER pass: PASS diff --git a/jason/demo/staging.vals.yaml b/jason/demo/staging.vals.yaml index 3589ac3f3..247be275c 100644 --- a/jason/demo/staging.vals.yaml +++ b/jason/demo/staging.vals.yaml @@ -9,7 +9,9 @@ server: pullPolicy: Always conf: server: - bind_port: 9980 + http: + host: "wss://demo.medea.stg.t11913.org" + bind_port: 9980 turn: host: demo.medea.stg.t11913.org pass: changeme From 964a3fa451c00fe53a91431f3e60739d976e8615 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 14 Aug 2019 18:32:06 +0300 Subject: [PATCH 486/735] HTTP client API host config refactor --- config.toml | 4 +- .../templates/deployment.server.yaml | 2 +- jason/demo/chart/medea-demo/values.yaml | 2 +- jason/demo/minikube.vals.yaml | 3 ++ jason/demo/staging.vals.yaml | 2 +- src/api/control/grpc/server.rs | 39 ++++++++++--------- src/conf/http_server.rs | 16 +++++--- src/conf/mod.rs | 7 ---- tests/e2e/signalling/pub_sub_signallng.rs | 2 +- tests/e2e/signalling/three_pubs.rs | 2 +- 10 files changed, 41 insertions(+), 38 deletions(-) diff --git a/config.toml b/config.toml index 39ee9e5c7..f8a9dea1c 100644 --- a/config.toml +++ b/config.toml @@ -2,7 +2,7 @@ # Server host # # Default: -# host = "localhost:8080" +# host = "ws://0.0.0.0:8080" # IP address to bind HTTP server to. # @@ -21,8 +21,6 @@ static_specs_path = "dev/specs" - - [server.grpc] # IP address to bind gRPC server to. # diff --git a/jason/demo/chart/medea-demo/templates/deployment.server.yaml b/jason/demo/chart/medea-demo/templates/deployment.server.yaml index b91cd6415..4ff97f634 100644 --- a/jason/demo/chart/medea-demo/templates/deployment.server.yaml +++ b/jason/demo/chart/medea-demo/templates/deployment.server.yaml @@ -65,7 +65,7 @@ spec: - name: MEDEA_TURN.DB.REDIS.PORT value: {{ $coturnDb.conf.port | quote }} - name: MEDEA_SERVER.HTTP.HOST - value: {{ .Values.server.conf.server.http.host }} + value: {{ .Values.server.conf.server.http.public_url }} envFrom: - secretRef: name: {{ template "medea-demo.fullname" . }}.server.cred diff --git a/jason/demo/chart/medea-demo/values.yaml b/jason/demo/chart/medea-demo/values.yaml index 8cfec77a0..99e6bf3f2 100644 --- a/jason/demo/chart/medea-demo/values.yaml +++ b/jason/demo/chart/medea-demo/values.yaml @@ -18,7 +18,7 @@ server: server: http: bind_port: 8080 - host: "" + public_url: "" turn: user: USER pass: PASS diff --git a/jason/demo/minikube.vals.yaml b/jason/demo/minikube.vals.yaml index 2db89efdf..31c8958b1 100644 --- a/jason/demo/minikube.vals.yaml +++ b/jason/demo/minikube.vals.yaml @@ -8,6 +8,9 @@ server: tag: dev pullPolicy: IfNotPresent conf: + server: + http: + public_url: "wss://medea-demo.test" turn: host: medea-demo.test diff --git a/jason/demo/staging.vals.yaml b/jason/demo/staging.vals.yaml index 247be275c..e0ca7c99d 100644 --- a/jason/demo/staging.vals.yaml +++ b/jason/demo/staging.vals.yaml @@ -10,7 +10,7 @@ server: conf: server: http: - host: "wss://demo.medea.stg.t11913.org" + public_url: "wss://demo.medea.stg.t11913.org" bind_port: 9980 turn: host: demo.medea.stg.t11913.org diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index a4916d07a..7bd284cc0 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -43,7 +43,10 @@ use crate::{ AppContext, }; -use crate::shutdown::ShutdownGracefully; +use crate::{ + api::control::{MemberId, RoomId}, + shutdown::ShutdownGracefully, +}; #[derive(Debug, Fail)] pub enum ControlApiError { @@ -154,6 +157,21 @@ struct ControlApiService { } impl ControlApiService { + fn get_sid( + &self, + room_id: &RoomId, + member_id: &MemberId, + credentials: &str, + ) -> String { + format!( + "{}/{}/{}/{}", + self.app.config.server.http.public_url, + room_id, + member_id, + credentials + ) + } + /// Implementation of `Create` method for `Room` element. pub fn create_room( &mut self, @@ -170,15 +188,7 @@ impl ControlApiService { let sid: HashMap = fut_try!(room.members()) .iter() .map(|(id, member)| { - let base_url = self.app.config.get_base_rpc_url(); - - let uri = format!( - "{}/{}/{}/{}", - base_url, - &room_id, - id, - member.credentials() - ); + let uri = self.get_sid(&room_id, &id, member.credentials()); (id.clone().to_string(), uri) }) @@ -203,14 +213,7 @@ impl ControlApiService { let (member_id, room_uri) = local_uri.take_member_id(); let room_id = room_uri.take_room_id(); - let base_url = self.app.config.get_base_rpc_url(); - let sid = format!( - "{}/{}/{}/{}", - base_url, - room_id, - member_id, - spec.credentials() - ); + let sid = self.get_sid(&room_id, &member_id, spec.credentials()); let mut sids = HashMap::new(); sids.insert(member_id.to_string(), sid); diff --git a/src/conf/http_server.rs b/src/conf/http_server.rs index 2edbe5b0a..4cea00fd6 100644 --- a/src/conf/http_server.rs +++ b/src/conf/http_server.rs @@ -9,11 +9,17 @@ use smart_default::SmartDefault; #[derive(Clone, Debug, Deserialize, Serialize, SmartDefault)] #[serde(default)] pub struct HttpServer { - // TODO: change to public_url, move to RPC, improve docs, since this param - // is quite important - /// Server host. - #[default("localhost:8080".to_string())] - pub host: String, + /// Public URI of server. Address for exposed [Client API]. + /// + /// This address will be returned from [Control API] in `sids` and to + /// this address will connect [Jason] for start session. + /// + /// Defaults to `ws://0.0.0.0:8080`. + /// + /// [Client API]: http://tiny.cc/c80uaz + /// [Jason]: https://github.com/instrumentisto/medea/tree/master/jason + #[default("ws://0.0.0.0:8080".to_string())] + pub public_url: String, /// IP address to bind HTTP server to. Defaults to `0.0.0.0`. #[default(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)))] diff --git a/src/conf/mod.rs b/src/conf/mod.rs index 73a3c1232..a1222de4f 100644 --- a/src/conf/mod.rs +++ b/src/conf/mod.rs @@ -70,13 +70,6 @@ impl Conf { Ok(cfg.try_into()?) } - - // TODO: any reason why this func is here and not in impl Server? - // dont hardcode scheme, just store it in 'host' field - // and dont forget to update helm configs - pub fn get_base_rpc_url(&self) -> String { - format!("wss://{}", self.server.http.host) - } } /// Returns the path to the configuration file, if it's set via CLI `args` diff --git a/tests/e2e/signalling/pub_sub_signallng.rs b/tests/e2e/signalling/pub_sub_signallng.rs index 90cfa968d..48598d8b9 100644 --- a/tests/e2e/signalling/pub_sub_signallng.rs +++ b/tests/e2e/signalling/pub_sub_signallng.rs @@ -6,7 +6,7 @@ use crate::signalling::TestMember; #[test] fn pub_sub_video_call() { System::run(|| { - let base_url = "ws://localhost:8081/ws/pub-sub-video-call"; + let base_url = "ws://0.0.0.0:8081/ws/pub-sub-video-call"; // Note that events is separated by members. // Every member will have different instance of this. diff --git a/tests/e2e/signalling/three_pubs.rs b/tests/e2e/signalling/three_pubs.rs index be5112478..4186e8c6c 100644 --- a/tests/e2e/signalling/three_pubs.rs +++ b/tests/e2e/signalling/three_pubs.rs @@ -8,7 +8,7 @@ use crate::signalling::{CloseSocket, TestMember}; #[test] fn three_members_p2p_video_call() { System::run(|| { - let base_url = "ws://localhost:8081/ws/three-members-conference"; + let base_url = "ws://0.0.0.0:8081/ws/three-members-conference"; // Note that events, peer_created_count, ice_candidates // is separated by members. From d3e3356fb44e55b576f2292fbbedcfb9c5cdbe34 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 15 Aug 2019 13:33:27 +0300 Subject: [PATCH 487/735] Refactor peers_removed --- src/api/client/session.rs | 2 +- src/signalling/participants.rs | 1 + src/signalling/room.rs | 111 ++++++++++++++------------------- 3 files changed, 50 insertions(+), 64 deletions(-) diff --git a/src/api/client/session.rs b/src/api/client/session.rs index 91c5b2b61..faca856d5 100644 --- a/src/api/client/session.rs +++ b/src/api/client/session.rs @@ -166,7 +166,7 @@ impl RpcConnection for Addr { ) -> Box> { let fut = self .send(msg) - .map_err(|err| error!("Failed send event {:?} ", err)); + .map_err(|err| warn!("Failed send event {:?} ", err)); Box::new(fut) } } diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 11a8cb075..d5d1cd443 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -237,6 +237,7 @@ impl ParticipantService { let closed_at = Instant::now(); match reason { ClosedReason::Closed => { + debug!("Connection for member [id = {}] removed.", member_id); self.connections.remove(&member_id); ctx.spawn(wrap_future( diff --git a/src/signalling/room.rs b/src/signalling/room.rs index a4d702bd4..f514c533d 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -7,7 +7,7 @@ use std::{collections::HashMap, sync::Arc, time::Duration}; use actix::{ fut::wrap_future, Actor, ActorFuture, AsyncContext, Context, Handler, - Message, ResponseActFuture, WrapFuture as _, + ResponseActFuture, WrapFuture as _, }; use failure::Fail; use futures::future; @@ -487,79 +487,39 @@ impl Room { }), ) } -} - -/// [`Actor`] implementation that provides an ergonomic way -/// to interact with [`Room`]. -impl Actor for Room { - type Context = Context; -} - -impl Handler for Room { - type Result = Result<(), AuthorizationError>; - /// Responses with `Ok` if `RpcConnection` is authorized, otherwise `Err`s. - fn handle( + /// Signal of removing [`Member`]'s [`Peer`]s. + fn member_peers_removed( &mut self, - msg: Authorize, - _ctx: &mut Self::Context, - ) -> Self::Result { - self.members - .get_member_by_id_and_credentials(&msg.member_id, &msg.credentials) - .map(|_| ()) - } -} - -/// Signal of removing [`Member`]'s [`Peer`]s. -#[derive(Debug, Message)] -#[rtype(result = "Result<(), ()>")] -pub struct PeersRemoved { - pub peers_id: Vec, - pub member_id: MemberId, -} - -// TODO: do we really need this message atm? move this logic to -// send_peers_removed? -impl Handler for Room { - type Result = ActFuture<(), ()>; - - /// Send [`Event::PeersRemoved`] to remote [`Member`]. - /// - /// Delete all removed [`PeerId`]s from all [`Member`]'s - /// endpoints. - #[allow(clippy::single_match_else)] - fn handle( - &mut self, - msg: PeersRemoved, - ctx: &mut Self::Context, - ) -> Self::Result { - info!( - "Peers {:?} removed for member '{}'.", - msg.peers_id, msg.member_id - ); - if let Some(member) = self.members.get_member_by_id(&msg.member_id) { - member.peers_removed(&msg.peers_id); + peers_id: Vec, + member_id: MemberId, + ctx: &mut Context, + ) -> ActFuture<(), ()> { + info!("Peers {:?} removed for member '{}'.", peers_id, member_id); + if let Some(member) = self.members.get_member_by_id(&member_id) { + member.peers_removed(&peers_id); } else { error!( "Participant with id {} for which received \ Event::PeersRemoved not found. Closing room.", - msg.member_id + member_id ); return Box::new(self.close_gracefully(ctx)); } - Box::new(self.send_peers_removed(msg.member_id, msg.peers_id).then( + Box::new(self.send_peers_removed(member_id, peers_id).then( |err, room, ctx: &mut Context| { if let Err(e) = err { match e { - RoomError::ConnectionNotExists(_) => { + RoomError::ConnectionNotExists(_) + | RoomError::UnableToSendEvent(_) => { Box::new(future::ok(()).into_actor(room)) } _ => { error!( - "Failed PeersEvent command, because {}. Room \ - will be stopped.", + "Unexpected failed PeersEvent command, \ + because {}. Room will be stopped.", e ); room.close_gracefully(ctx) @@ -573,6 +533,27 @@ impl Handler for Room { } } +/// [`Actor`] implementation that provides an ergonomic way +/// to interact with [`Room`]. +impl Actor for Room { + type Context = Context; +} + +impl Handler for Room { + type Result = Result<(), AuthorizationError>; + + /// Responses with `Ok` if `RpcConnection` is authorized, otherwise `Err`s. + fn handle( + &mut self, + msg: Authorize, + _ctx: &mut Self::Context, + ) -> Self::Result { + self.members + .get_member_by_id_and_credentials(&msg.member_id, &msg.credentials) + .map(|_| ()) + } +} + impl Handler for Room { type Result = ActFuture<(), ()>; @@ -684,19 +665,23 @@ impl Handler for Room { msg.member_id, msg.reason ); + self.members + .connection_closed(msg.member_id.clone(), &msg.reason, ctx); + if let ClosedReason::Closed = msg.reason { let removed_peers = self.peers.remove_peers_related_to_member(&msg.member_id); for (peer_member_id, peers_ids) in removed_peers { - ctx.notify(PeersRemoved { - member_id: peer_member_id, - peers_id: peers_ids, - }) + // Here we may have some problems. If two participants + // disconnect at one moment then sending event + // to another participant fail, + // because connection already closed but we don't know about it + // because message in event loop. + let fut = + self.member_peers_removed(peers_ids, peer_member_id, ctx); + ctx.spawn(fut); } } - - self.members - .connection_closed(msg.member_id, &msg.reason, ctx); } } From 2ce6f52011be25a0b07cdcc434ed1e35d86fd3c3 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 15 Aug 2019 15:46:50 +0300 Subject: [PATCH 488/735] Reduce boilerplate --- src/signalling/room.rs | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 16a6c54ea..ad2c24122 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -547,6 +547,24 @@ impl Room { }, )) } + + /// Remove [`Peer`]s and call [`Room::member_peers_removed`] for every + /// [`Member`]. + /// + /// This will delete [`Peer`]s from [`PeerRepository`] and send + /// [`Event::PeersRemoved`] event to [`Member`]. + fn remove_peers( + &mut self, + member_id: &MemberId, + peer_ids_to_remove: HashSet, + ctx: &mut Context, + ) { + let removed_peers = + self.peers.remove_peers(&member_id, peer_ids_to_remove); + for (member_id, peers_id) in removed_peers { + self.member_peers_removed(peers_id, member_id, ctx); + } + } } /// [`Actor`] implementation that provides an ergonomic way @@ -828,11 +846,7 @@ impl Handler for Room { let member_id = id.clone(); - let removed_peers = - self.peers.remove_peers(&member_id, peer_ids_to_remove); - for (member_id, peers_id) in removed_peers { - self.member_peers_removed(peers_id, member_id, ctx); - } + self.remove_peers(&member_id, peer_ids_to_remove, ctx); self.members.delete_member(&member_id, ctx); } } @@ -869,10 +883,7 @@ impl Handler for Room { } } - let removed_peers = self.peers.remove_peers(&member.id(), peers); - for (member_id, peers_id) in removed_peers { - self.member_peers_removed(peers_id, member_id, ctx); - } + self.remove_peers(&member.id(), peers, ctx); } self.members.delete_member(&msg.0, ctx); @@ -920,12 +931,7 @@ impl Handler for Room { let publish_id = WebRtcPublishId(play_id.0); if let Some(endpoint) = member.take_src(&publish_id) { let peer_ids = endpoint.peer_ids(); - // TODO: reduce boilerplate - let removed_peers = - self.peers.remove_peers(&member_id, peer_ids); - for (member_id, peers_id) in removed_peers { - self.member_peers_removed(peers_id, member_id, ctx); - } + self.remove_peers(&member_id, peer_ids, ctx); } publish_id.0 From 71c18e90fd7b5087bed52a5a98a3a4ece66ed8c1 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 15 Aug 2019 19:08:03 +0300 Subject: [PATCH 489/735] Use stable cargo clippy --- .travis.yml | 2 +- Makefile | 2 +- jason/src/lib.rs | 3 --- proto/client-api/src/lib.rs | 3 --- src/lib.rs | 3 --- src/signalling/room.rs | 2 +- 6 files changed, 3 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index d2dcfcc80..23ce8b619 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,7 @@ jobs: include: - stage: lints - rust: nightly + rust: stable name: "Clippy" before_script: rustup component add clippy script: make lint diff --git a/Makefile b/Makefile index 0c29a6a66..ca4bd37de 100644 --- a/Makefile +++ b/Makefile @@ -186,7 +186,7 @@ cargo.fmt: # make cargo.lint cargo.lint: - cargo +nightly clippy --all -- -D clippy::pedantic -D warnings + cargo clippy --all -- -D clippy::pedantic -D warnings diff --git a/jason/src/lib.rs b/jason/src/lib.rs index 5b46cb81a..846efad6c 100644 --- a/jason/src/lib.rs +++ b/jason/src/lib.rs @@ -1,6 +1,3 @@ -// TODO: when using enum's Self will be in stable, remove it. -#![allow(clippy::use_self)] - pub mod api; pub mod media; pub mod peer; diff --git a/proto/client-api/src/lib.rs b/proto/client-api/src/lib.rs index 6deb9d036..963672365 100644 --- a/proto/client-api/src/lib.rs +++ b/proto/client-api/src/lib.rs @@ -1,8 +1,5 @@ //! Client API protocol implementation for Medea media server. -// TODO: when using enum's Self will be in stable, remove it. -#![allow(clippy::use_self)] - use std::collections::HashMap; use macro_attr::*; diff --git a/src/lib.rs b/src/lib.rs index 19fbb35bb..302f13b61 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,8 +1,5 @@ //! Medea media server application. -// TODO: when using enum's Self will be in stable, remove it. -#![allow(clippy::use_self)] - #[macro_use] pub mod utils; pub mod api; diff --git a/src/signalling/room.rs b/src/signalling/room.rs index f514c533d..df5794987 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -493,7 +493,7 @@ impl Room { &mut self, peers_id: Vec, member_id: MemberId, - ctx: &mut Context, + ctx: &mut Context, ) -> ActFuture<(), ()> { info!("Peers {:?} removed for member '{}'.", peers_id, member_id); if let Some(member) = self.members.get_member_by_id(&member_id) { From 3ce239bb77a40718f905199f0bc0afdbfdac8bac Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 15 Aug 2019 20:20:15 +0300 Subject: [PATCH 490/735] Use Self for enums --- jason/src/peer/conn.rs | 8 ++++---- jason/src/rpc/websocket.rs | 14 +++++++------- jason/src/utils/errors.rs | 16 ++++++++-------- proto/client-api/src/lib.rs | 16 ++++++++-------- src/api/control/endpoint.rs | 4 ++-- src/lib.rs | 4 ++-- src/signalling/elements/member.rs | 2 +- src/signalling/participants.rs | 4 ++-- src/signalling/room.rs | 12 +++--------- src/turn/repo.rs | 2 +- src/turn/service.rs | 8 ++++---- 11 files changed, 42 insertions(+), 48 deletions(-) diff --git a/jason/src/peer/conn.rs b/jason/src/peer/conn.rs index 16a5ae731..a1ac9deb3 100644 --- a/jason/src/peer/conn.rs +++ b/jason/src/peer/conn.rs @@ -38,8 +38,8 @@ impl TransceiverKind { /// Returns string representation of a [`TransceiverKind`]. pub fn as_str(self) -> &'static str { match self { - TransceiverKind::Audio => "audio", - TransceiverKind::Video => "video", + Self::Audio => "audio", + Self::Video => "video", } } } @@ -58,8 +58,8 @@ impl From for RtcRtpTransceiverDirection { fn from(direction: TransceiverDirection) -> Self { use TransceiverDirection::*; match direction { - Sendonly => RtcRtpTransceiverDirection::Sendonly, - Recvonly => RtcRtpTransceiverDirection::Recvonly, + Sendonly => Self::Sendonly, + Recvonly => Self::Recvonly, } } } diff --git a/jason/src/rpc/websocket.rs b/jason/src/rpc/websocket.rs index ff0a68982..1e05f3bd4 100644 --- a/jason/src/rpc/websocket.rs +++ b/jason/src/rpc/websocket.rs @@ -28,7 +28,7 @@ impl State { /// Returns `true` if socket can be closed. pub fn can_close(&self) -> bool { match self { - State::CONNECTING | State::OPEN => true, + Self::CONNECTING | Self::OPEN => true, _ => false, } } @@ -39,10 +39,10 @@ impl TryFrom for State { fn try_from(value: u16) -> Result { match value { - 0 => Ok(State::CONNECTING), - 1 => Ok(State::OPEN), - 2 => Ok(State::CLOSING), - 3 => Ok(State::CLOSED), + 0 => Ok(Self::CONNECTING), + 1 => Ok(Self::OPEN), + 2 => Ok(Self::CLOSING), + 3 => Ok(Self::CLOSED), _ => Err(WasmErr::Custom( format!("Could not cast {} to State variant", value).into(), )), @@ -212,8 +212,8 @@ impl From<&CloseEvent> for CloseMsg { let code: u16 = event.code(); let body = format!("{}:{}", code, event.reason()); match code { - 1000 => CloseMsg::Normal(body), - _ => CloseMsg::Disconnect(body), + 1000 => Self::Normal(body), + _ => Self::Disconnect(body), } } } diff --git a/jason/src/utils/errors.rs b/jason/src/utils/errors.rs index 19fa5334f..8f17d753a 100644 --- a/jason/src/utils/errors.rs +++ b/jason/src/utils/errors.rs @@ -24,21 +24,21 @@ impl WasmErr { impl From<&'static str> for WasmErr { fn from(msg: &'static str) -> Self { - WasmErr::Custom(Cow::Borrowed(msg)) + Self::Custom(Cow::Borrowed(msg)) } } impl From for WasmErr { fn from(msg: String) -> Self { - WasmErr::Custom(Cow::Owned(msg)) + Self::Custom(Cow::Owned(msg)) } } impl From for WasmErr { fn from(val: JsValue) -> Self { match val.dyn_into::() { - Ok(err) => WasmErr::JsError(err), - Err(val) => WasmErr::Untyped(val), + Ok(err) => Self::JsError(err), + Err(val) => Self::Untyped(val), } } } @@ -56,11 +56,11 @@ impl From for JsValue { impl fmt::Display for WasmErr { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { - WasmErr::JsError(err) => { + Self::JsError(err) => { write!(f, "{}", String::from(err.to_string())) } - WasmErr::Custom(reason) => write!(f, "{}", reason), - WasmErr::Untyped(val) => match val.as_string() { + Self::Custom(reason) => write!(f, "{}", reason), + Self::Untyped(val) => match val.as_string() { Some(reason) => write!(f, "{}", reason), None => write!(f, "no str representation for JsError"), }, @@ -72,7 +72,7 @@ macro_rules! impl_from_error { ($error:ty) => { impl From<$error> for WasmErr { fn from(error: $error) -> Self { - WasmErr::Custom(format!("{}", error).into()) + Self::Custom(format!("{}", error).into()) } } }; diff --git a/proto/client-api/src/lib.rs b/proto/client-api/src/lib.rs index 963672365..642bc6cb4 100644 --- a/proto/client-api/src/lib.rs +++ b/proto/client-api/src/lib.rs @@ -212,12 +212,12 @@ impl Serialize for ClientMsg { use serde::ser::SerializeStruct; match self { - ClientMsg::Ping(n) => { + Self::Ping(n) => { let mut ping = serializer.serialize_struct("ping", 1)?; ping.serialize_field("ping", n)?; ping.end() } - ClientMsg::Command(command) => command.serialize(serializer), + Self::Command(command) => command.serialize(serializer), } } } @@ -243,7 +243,7 @@ impl<'de> Deserialize<'de> for ClientMsg { )) })?; - Ok(ClientMsg::Ping(n)) + Ok(Self::Ping(n)) } else { let command = serde_json::from_value::(ev).map_err(|e| { @@ -252,7 +252,7 @@ impl<'de> Deserialize<'de> for ClientMsg { e )) })?; - Ok(ClientMsg::Command(command)) + Ok(Self::Command(command)) } } } @@ -266,12 +266,12 @@ impl Serialize for ServerMsg { use serde::ser::SerializeStruct; match self { - ServerMsg::Pong(n) => { + Self::Pong(n) => { let mut ping = serializer.serialize_struct("pong", 1)?; ping.serialize_field("pong", n)?; ping.end() } - ServerMsg::Event(command) => command.serialize(serializer), + Self::Event(command) => command.serialize(serializer), } } } @@ -297,7 +297,7 @@ impl<'de> Deserialize<'de> for ServerMsg { )) })?; - Ok(ServerMsg::Pong(n)) + Ok(Self::Pong(n)) } else { let event = serde_json::from_value::(ev).map_err(|e| { Error::custom(format!( @@ -305,7 +305,7 @@ impl<'de> Deserialize<'de> for ServerMsg { e )) })?; - Ok(ServerMsg::Event(event)) + Ok(Self::Event(event)) } } } diff --git a/src/api/control/endpoint.rs b/src/api/control/endpoint.rs index 9dc88ee6b..4f4fa88b6 100644 --- a/src/api/control/endpoint.rs +++ b/src/api/control/endpoint.rs @@ -25,10 +25,10 @@ impl TryFrom<&MemberElement> for Endpoint { fn try_from(from: &MemberElement) -> Result { match from { MemberElement::WebRtcPlayEndpoint { spec } => { - Ok(Endpoint::WebRtcPlay(spec.clone())) + Ok(Self::WebRtcPlay(spec.clone())) } MemberElement::WebRtcPublishEndpoint { spec } => { - Ok(Endpoint::WebRtcPublish(spec.clone())) + Ok(Self::WebRtcPublish(spec.clone())) } } } diff --git a/src/lib.rs b/src/lib.rs index 302f13b61..582722b37 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -48,8 +48,8 @@ pub enum ServerStartError { impl From for ServerStartError { fn from(err: RoomError) -> Self { match err { - RoomError::BadRoomSpec(m) => ServerStartError::BadRoomSpec(m), - _ => ServerStartError::UnknownRoomError, + RoomError::BadRoomSpec(m) => Self::BadRoomSpec(m), + _ => Self::UnknownRoomError, } } } diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index e9b3e76f5..631560255 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -38,7 +38,7 @@ pub enum MembersLoadError { impl From for MembersLoadError { fn from(err: TryFromElementError) -> Self { - MembersLoadError::TryFromError(err) + Self::TryFromError(err) } } diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index d5d1cd443..a649c122f 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -58,13 +58,13 @@ pub enum ParticipantServiceErr { impl From for ParticipantServiceErr { fn from(err: TurnServiceErr) -> Self { - ParticipantServiceErr::TurnServiceErr(err) + Self::TurnServiceErr(err) } } impl From for ParticipantServiceErr { fn from(err: MailboxError) -> Self { - ParticipantServiceErr::MailBoxErr(err) + Self::MailBoxErr(err) } } diff --git a/src/signalling/room.rs b/src/signalling/room.rs index df5794987..6b10b08aa 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -67,25 +67,19 @@ pub enum RoomError { impl From for RoomError { fn from(err: PeerError) -> Self { - RoomError::PeerError(err) + Self::PeerError(err) } } impl From for RoomError { fn from(err: TryFromElementError) -> Self { - RoomError::BadRoomSpec(format!( - "Element located in wrong place. {}", - err - )) + Self::BadRoomSpec(format!("Element located in wrong place. {}", err)) } } impl From for RoomError { fn from(err: MembersLoadError) -> Self { - RoomError::BadRoomSpec(format!( - "Error while loading room spec. {}", - err - )) + Self::BadRoomSpec(format!("Error while loading room spec. {}", err)) } } diff --git a/src/turn/repo.rs b/src/turn/repo.rs index 4daa2eb05..69558318d 100644 --- a/src/turn/repo.rs +++ b/src/turn/repo.rs @@ -20,7 +20,7 @@ pub enum TurnDatabaseErr { impl From for TurnDatabaseErr { fn from(err: RedisError) -> Self { - TurnDatabaseErr::RedisError(err) + Self::RedisError(err) } } diff --git a/src/turn/service.rs b/src/turn/service.rs index 96c0712a7..6710ae7a9 100644 --- a/src/turn/service.rs +++ b/src/turn/service.rs @@ -112,22 +112,22 @@ pub enum TurnServiceErr { impl From for TurnServiceErr { fn from(err: TurnDatabaseErr) -> Self { - TurnServiceErr::TurnAuthRepoErr(err) + Self::TurnAuthRepoErr(err) } } impl From> for TurnServiceErr { fn from(err: bb8::RunError) -> Self { match err { - RunError::User(error) => TurnServiceErr::TurnAuthRepoErr(error), - RunError::TimedOut => TurnServiceErr::TimedOut, + RunError::User(error) => Self::TurnAuthRepoErr(error), + RunError::TimedOut => Self::TimedOut, } } } impl From for TurnServiceErr { fn from(err: MailboxError) -> Self { - TurnServiceErr::MailboxErr(err) + Self::MailboxErr(err) } } From 88d8fb83401585266ee65fd930b06930d84e5fc9 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 16 Aug 2019 12:42:11 +0300 Subject: [PATCH 491/735] Try to speedup travis caching and update stable --- .travis.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 23ce8b619..88dbe675e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,8 +3,15 @@ language: rust services: - docker +# Need to cache the whole `.cargo` directory to keep .crates.toml for +# cargo-update to work cache: - cargo: true + directories: + - /home/travis/.cargo + +# But don't cache the cargo registry +before_cache: + - rm -rf /home/travis/.cargo/registry jobs: allow_failures: @@ -62,6 +69,7 @@ jobs: install: - rustc -vV - cargo -vV + - rustup update stable before_deploy: - echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc From 1ab4f9a3c42942a6383914b6a6da02bf0699185e Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 16 Aug 2019 13:09:56 +0300 Subject: [PATCH 492/735] Fix caching permissions for docker --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 88dbe675e..a82391e50 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,6 +12,8 @@ cache: # But don't cache the cargo registry before_cache: - rm -rf /home/travis/.cargo/registry + - sudo chown -R travis:travis $HOME/.cargo + - sudo chown -R travis:travis $TRAVIS_BUILD_DIR/target jobs: allow_failures: From 6864d2eeb0fb22c1e95ecbd3ec38516ae5b75ffd Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 16 Aug 2019 13:38:19 +0300 Subject: [PATCH 493/735] Fix cache --- .travis.yml | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index a82391e50..b11cf4f6e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,17 +3,8 @@ language: rust services: - docker -# Need to cache the whole `.cargo` directory to keep .crates.toml for -# cargo-update to work cache: - directories: - - /home/travis/.cargo - -# But don't cache the cargo registry -before_cache: - - rm -rf /home/travis/.cargo/registry - - sudo chown -R travis:travis $HOME/.cargo - - sudo chown -R travis:travis $TRAVIS_BUILD_DIR/target + cargo: true jobs: allow_failures: From 625904f2659fe532b3bde4c5ff9e2bf090e3afce Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 16 Aug 2019 15:41:26 +0300 Subject: [PATCH 494/735] Try to fix with rustup --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index ca4bd37de..8f880c565 100644 --- a/Makefile +++ b/Makefile @@ -288,6 +288,7 @@ endif ifeq ($(dockerized),no) @make down.medea dockerized=no + rustup update stable # TODO: remove it when docker will have rust 1.37 cargo build $(if $(call eq,$(release),yes),--release) env $(medea-env) $(if $(call eq,$(logs),yes),,RUST_LOG=warn) cargo run $(if $(call eq,$(release),yes),--release) & From c9e250b02378fbab2ac6e777fa0307d69ee006b6 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 16 Aug 2019 19:19:03 +0300 Subject: [PATCH 495/735] Add conditional run ci --- .travis.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.travis.yml b/.travis.yml index b11cf4f6e..33d999031 100644 --- a/.travis.yml +++ b/.travis.yml @@ -103,6 +103,16 @@ deploy: tags: true branch: master +stages: + - name: lints + if: branch = master OR commit_message =~ ^*.\[run ci] + - name: formatting + if: branch = master OR commit_message =~ ^*.\[run ci] + - name: build + if: branch = master OR commit_message =~ ^*.\[run ci] + - name: tests + if: branch = master OR commit_message =~ ^*.\[run ci] + notifications: email: on_success: never From d6fd6b45ca7d1c6d9843fb29b26eec8e05dc0d08 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 16 Aug 2019 19:20:46 +0300 Subject: [PATCH 496/735] This commit should run ci [run ci] --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 33d999031..8dfd099d4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,7 @@ language: rust +# Comment for testing conditional CI + services: - docker From ed6e45d5296133f9fc999ffd39d31ad6e5230ffd Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 16 Aug 2019 19:22:57 +0300 Subject: [PATCH 497/735] Fix regex [run ci] --- .travis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8dfd099d4..bd3251a0e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -107,13 +107,13 @@ deploy: stages: - name: lints - if: branch = master OR commit_message =~ ^*.\[run ci] + if: branch = master OR commit_message =~ ^.*\[run ci\] - name: formatting - if: branch = master OR commit_message =~ ^*.\[run ci] + if: branch = master OR commit_message =~ ^.*\[run ci\] - name: build - if: branch = master OR commit_message =~ ^*.\[run ci] + if: branch = master OR commit_message =~ ^.*\[run ci\] - name: tests - if: branch = master OR commit_message =~ ^*.\[run ci] + if: branch = master OR commit_message =~ ^.*\[run ci\] notifications: email: From 19ff908b7660410d4478e317e188d52777485d38 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 16 Aug 2019 19:24:59 +0300 Subject: [PATCH 498/735] Try another /*/ for regex [run ci] --- .travis.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index bd3251a0e..a1f54bff9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,5 @@ language: rust -# Comment for testing conditional CI - services: - docker @@ -107,13 +105,13 @@ deploy: stages: - name: lints - if: branch = master OR commit_message =~ ^.*\[run ci\] + if: branch = master OR commit_message =~ /.*\[run ci\]/ - name: formatting - if: branch = master OR commit_message =~ ^.*\[run ci\] + if: branch = master OR commit_message =~ /.*\[run ci\]/ - name: build - if: branch = master OR commit_message =~ ^.*\[run ci\] + if: branch = master OR commit_message =~ /.*\[run ci\]/ - name: tests - if: branch = master OR commit_message =~ ^.*\[run ci\] + if: branch = master OR commit_message =~ /.*\[run ci\]/ notifications: email: From 9d002979c758e235c782c5f57267cd8f44b8dbb2 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 16 Aug 2019 19:33:29 +0300 Subject: [PATCH 499/735] Optimize caching for Travis CI [run ci] --- .travis.yml | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index a1f54bff9..c8b3bc13e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,6 +15,7 @@ jobs: - stage: lints rust: stable name: "Clippy" + env: CACHE_NAME=clippy_cache before_script: rustup component add clippy script: make lint @@ -22,11 +23,13 @@ jobs: rust: nightly name: "Rustfmt" before_script: rustup component add rustfmt + env: CACHE_NAME=formatting_cache script: make fmt check=yes - stage: build rust: stable name: "Build jason (Rust stable)" + env: CACHE_NAME=jason_cache before_script: - rm -f /home/travis/.cargo/bin/wasm-pack - curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh @@ -58,6 +61,15 @@ jobs: name: "E2E tests (Rust stable)" script: make test.e2e +stages: + - name: lints + if: branch = master OR commit_message =~ /.*\[run ci\]/ + - name: formatting + if: branch = master OR commit_message =~ /.*\[run ci\]/ + - name: build + if: branch = master OR commit_message =~ /.*\[run ci\]/ + - name: tests + if: branch = master OR commit_message =~ /.*\[run ci\]/ install: - rustc -vV @@ -103,16 +115,6 @@ deploy: tags: true branch: master -stages: - - name: lints - if: branch = master OR commit_message =~ /.*\[run ci\]/ - - name: formatting - if: branch = master OR commit_message =~ /.*\[run ci\]/ - - name: build - if: branch = master OR commit_message =~ /.*\[run ci\]/ - - name: tests - if: branch = master OR commit_message =~ /.*\[run ci\]/ - notifications: email: on_success: never From 6572962b5d38f4bb90c709f7af31a7c31dcae245 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 16 Aug 2019 20:14:16 +0300 Subject: [PATCH 500/735] Down services when e2e test fail --- Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 8f880c565..1be85c9de 100644 --- a/Makefile +++ b/Makefile @@ -293,11 +293,12 @@ ifeq ($(dockerized),no) env $(medea-env) $(if $(call eq,$(logs),yes),,RUST_LOG=warn) cargo run $(if $(call eq,$(release),yes),--release) & sleep 1 - cargo test --test e2e - - killall medea + $(shell cargo test --test e2e) + @make down ifneq ($(coturn),no) @make down.coturn endif + @exit $(.SHELLSTATUS) else @make down.medea dockerized=yes @make down.medea dockerized=no From 5d1dc1000f0b24ab4e5d58631b00e84bff47ef84 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 16 Aug 2019 20:19:03 +0300 Subject: [PATCH 501/735] Fix Travis if --- .travis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index c8b3bc13e..101ff3d7b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -63,13 +63,13 @@ jobs: stages: - name: lints - if: branch = master OR commit_message =~ /.*\[run ci\]/ + if: (branch = master AND type != pull_request) OR commit_message =~ /.*\[run ci\]/ - name: formatting - if: branch = master OR commit_message =~ /.*\[run ci\]/ + if: (branch = master AND type != pull_request) OR commit_message =~ /.*\[run ci\]/ - name: build - if: branch = master OR commit_message =~ /.*\[run ci\]/ + if: (branch = master AND type != pull_request) OR commit_message =~ /.*\[run ci\]/ - name: tests - if: branch = master OR commit_message =~ /.*\[run ci\]/ + if: (branch = master AND type != pull_request) OR commit_message =~ /.*\[run ci\]/ install: - rustc -vV From e3386af493134332e4bb52c3a39602c1395f3a37 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 20 Aug 2019 17:57:06 +0300 Subject: [PATCH 502/735] Add contributing guide --- CONTRIBUTING.md | 118 ++++++++++++++++++++++++++++++++++++++++++++++++ Makefile | 25 +++++++++- 2 files changed, 142 insertions(+), 1 deletion(-) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 000000000..07c3ee866 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,118 @@ +Contribution Guide +=== + +## Prerequisites + +In addition to default stable [Rust] toolchain you will need `rustfmt` and `clippy` +components, and also a nightly [Rust] toolchain (for better tooling). +```bash +rustup toolchain install nightly +rustup component add rustfmt +rustup component add clippy +``` + +Also you need install [wasm-pack] for [jason] building and testing: +```bash +$ curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sudo sh +``` + + + + +## Operations + +Take a look at [`Makefile`] for commands usage details. + + +### Development environment + +Boot up dockerized environment for [medea] with [jason]: +```bash +$ make up.dev +``` + +In some cases you may wish boot up only [medea] without [jason]: +```bash +$ make up.medea +``` + + +### Building + +To build/rebuild project and its Docker image use docker-wrapped command from [`Makefile`]: +```bash +$ make build +``` + +To build only [medea]: +```bash +$ make build.medea +``` + +To build only [jason]: +```bash +$ make build.jason +``` + + +### Formatting + +To auto-format Rust sources use command from [`Makefile`]: +```bash +$ make fmt +``` + + +### Linting + +To lint Rust sources use command from [`Makefile`]: +```bash +$ make lint +``` + + +### Testing + +To run unit tests command from [`Makefile`]: +```bash +$ make test.unit + +# or for concrete crate only +$ make test.unit crate=medea +$ make test.unit crate=jason +``` + +To run E2E tests use docker-wrapped commands from [`Makefile`]: +```bash +$ make test.e2e +``` + + +### Documentation + +To generate Rust sources project documentation use command from [`Makefile`]: +```bash +$ make docs.rust + +# if you don't wish to automatically open docs in browser +$ make docs.rust open=no + +# or for concrete crate only +$ make docs.rust crate=jason +``` + + + + +## Running CI + +Add `[run ci]` to your commit message. + + + + +[`Makefile`]: https://github.com/instrumentisto/medea/blob/master/Makefile +[jason]: https://github.com/instrumentisto/medea/tree/master/jason +[medea]: https://github.com/instrumentisto/medea +[Rust]: https://www.rust-lang.org/ +[wasm-pack]: https://github.com/rustwasm/wasm-pack diff --git a/Makefile b/Makefile index 1be85c9de..e75532029 100644 --- a/Makefile +++ b/Makefile @@ -30,7 +30,7 @@ CURRENT_BRANCH := $(strip $(shell git branch | grep \* | cut -d ' ' -f2)) # Aliases # ########### -build: docker.build.medea +build: docker.build.medea build.medea build.jason # Resolve all project dependencies. @@ -658,6 +658,29 @@ endef +############ +# Building # +############ + +# Build medea. +# +# Usage: +# make build.medea + +build.medea: + cargo build -p medea + + +# Build jason. +# +# Usage: +# make build.jason +build.jason: + wasm-pack build -t web jason + + + + ################## # .PHONY section # ################## From 4fe5b90b12970b32cb9944bfb121371cf331e40c Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 21 Aug 2019 19:45:53 +0300 Subject: [PATCH 503/735] Commit for check that CI works [run ci] --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 28238b9f4..77a2ba70f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ All user visible changes to this project will be documented in this file. This p -## [0.2.0] · 2019-?-? +## TBD [0.2.0] · 2019-?-? [0.2.0]: https://github.com/instrumentisto/medea/releases/tag/medea-0.2.0 [Milestone](https://github.com/instrumentisto/medea/milestone/2) | From b97dc211bb5d76a280ea74ccca6c9e9959e51e03 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 22 Aug 2019 13:19:30 +0300 Subject: [PATCH 504/735] Fix e2e tests, remove $(shell) --- Makefile | 4 ++-- tests/e2e/signalling/pub_sub_signallng.rs | 2 +- tests/e2e/signalling/three_pubs.rs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index e75532029..fe519285f 100644 --- a/Makefile +++ b/Makefile @@ -288,12 +288,12 @@ endif ifeq ($(dockerized),no) @make down.medea dockerized=no - rustup update stable # TODO: remove it when docker will have rust 1.37 cargo build $(if $(call eq,$(release),yes),--release) env $(medea-env) $(if $(call eq,$(logs),yes),,RUST_LOG=warn) cargo run $(if $(call eq,$(release),yes),--release) & sleep 1 - $(shell cargo test --test e2e) + cargo test --test e2e + @make down ifneq ($(coturn),no) @make down.coturn diff --git a/tests/e2e/signalling/pub_sub_signallng.rs b/tests/e2e/signalling/pub_sub_signallng.rs index 90cfa968d..48598d8b9 100644 --- a/tests/e2e/signalling/pub_sub_signallng.rs +++ b/tests/e2e/signalling/pub_sub_signallng.rs @@ -6,7 +6,7 @@ use crate::signalling::TestMember; #[test] fn pub_sub_video_call() { System::run(|| { - let base_url = "ws://localhost:8081/ws/pub-sub-video-call"; + let base_url = "ws://0.0.0.0:8081/ws/pub-sub-video-call"; // Note that events is separated by members. // Every member will have different instance of this. diff --git a/tests/e2e/signalling/three_pubs.rs b/tests/e2e/signalling/three_pubs.rs index b32d781d7..cdaab2639 100644 --- a/tests/e2e/signalling/three_pubs.rs +++ b/tests/e2e/signalling/three_pubs.rs @@ -8,7 +8,7 @@ use crate::signalling::{CloseSocket, TestMember}; #[test] fn three_members_p2p_video_call() { System::run(|| { - let base_url = "ws://localhost:8081/ws/three-members-conference"; + let base_url = "ws://0.0.0.0:8081/ws/three-members-conference"; // Note that events, peer_created_count, ice_candidates // is separated by members. From 7574f1f438291ec31b1e238023b37e1334b21eac Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 22 Aug 2019 14:19:50 +0300 Subject: [PATCH 505/735] Fix docs refs --- src/api/client/rpc_connection.rs | 16 ++++++++-------- src/api/control/endpoint.rs | 2 ++ src/api/control/member.rs | 8 +++++++- src/api/control/mod.rs | 4 +++- src/api/control/room.rs | 4 +++- src/media/peer.rs | 6 +++--- .../elements/endpoints/webrtc/play_endpoint.rs | 2 ++ src/signalling/elements/member.rs | 16 +++++++++++++--- src/signalling/participants.rs | 8 +++++--- src/signalling/peers.rs | 9 +++++++-- src/signalling/room.rs | 6 ++++-- 11 files changed, 57 insertions(+), 24 deletions(-) diff --git a/src/api/client/rpc_connection.rs b/src/api/client/rpc_connection.rs index 1275c7d68..841f7a0a2 100644 --- a/src/api/client/rpc_connection.rs +++ b/src/api/client/rpc_connection.rs @@ -26,7 +26,7 @@ macro_attr! { /// Abstraction over RPC connection with some remote [`Member`]. /// -/// [`Member`]: crate::api::control::member::Member +/// [`Member`]: crate::signalling::elements::member::Member pub trait RpcConnection: fmt::Debug + Send { /// Closes [`RpcConnection`]. /// No [`RpcConnectionClosed`] signals should be emitted. @@ -35,7 +35,7 @@ pub trait RpcConnection: fmt::Debug + Send { /// Sends [`Event`] to remote [`Member`]. /// - /// [`Member`]: crate::api::control::member::Member + /// [`Member`]: crate::signalling::elements::member::Member fn send_event( &self, msg: EventMessage, @@ -48,7 +48,7 @@ pub trait RpcConnection: fmt::Debug + Send { pub struct Authorize { /// ID of [`Member`] to authorize [`RpcConnection`] for. /// - /// [`Member`]: crate::api::control::member::Member + /// [`Member`]: crate::signalling::elements::member::Member pub member_id: MemberId, /// Credentials to authorize [`RpcConnection`] with. pub credentials: String, // TODO: &str when futures will allow references @@ -61,7 +61,7 @@ pub struct Authorize { pub enum AuthorizationError { /// Authorizing [`Member`] does not exists in the [`Room`]. /// - /// [`Member`]: crate::api::control::member::Member + /// [`Member`]: crate::signalling::elements::member::Member /// [`Room`]: crate::signalling::Room MemberNotExists, /// Provided credentials are invalid. @@ -71,27 +71,27 @@ pub enum AuthorizationError { /// Signal of new [`RpcConnection`] being established with specified [`Member`]. /// Transport should consider dropping connection if message result is err. /// -/// [`Member`]: crate::api::control::member::Member +/// [`Member`]: crate::signalling::elements::member::Member #[derive(Debug, Message)] #[rtype(result = "Result<(), ()>")] #[allow(clippy::module_name_repetitions)] pub struct RpcConnectionEstablished { /// ID of [`Member`] that establishes [`RpcConnection`]. /// - /// [`Member`]: crate::api::control::member::Member + /// [`Member`]: crate::signalling::elements::member::Member pub member_id: MemberId, /// Established [`RpcConnection`]. pub connection: Box, } /// Signal of existing [`RpcConnection`] of specified [`Member`] being closed. /// -/// [`Member`]: crate::api::control::member::Member +/// [`Member`]: crate::signalling::elements::member::Member #[derive(Debug, Message)] #[allow(clippy::module_name_repetitions)] pub struct RpcConnectionClosed { /// ID of [`Member`] which [`RpcConnection`] is closed. /// - /// [`Member`]: crate::api::control::member::Member + /// [`Member`]: crate::signalling::elements::member::Member pub member_id: MemberId, /// Reason of why [`RpcConnection`] is closed. pub reason: ClosedReason, diff --git a/src/api/control/endpoint.rs b/src/api/control/endpoint.rs index 4f4fa88b6..a9b7f1190 100644 --- a/src/api/control/endpoint.rs +++ b/src/api/control/endpoint.rs @@ -62,6 +62,8 @@ pub struct WebRtcPlayEndpoint { #[derive(Clone, Debug)] pub struct SrcUri { /// ID of [`Room`] + /// + /// [`Room`]: crate::signalling::room::Room pub room_id: String, /// ID of `Member` pub member_id: MemberId, diff --git a/src/api/control/member.rs b/src/api/control/member.rs index 7d5052d5c..fcbcc465f 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -29,20 +29,26 @@ macro_attr! { } /// Element of [`Member`]'s [`Pipeline`]. +/// +/// [`Member`]: crate::signalling::elements::member::Member #[allow(clippy::module_name_repetitions)] #[derive(Clone, Deserialize, Debug)] #[serde(tag = "kind")] pub enum MemberElement { /// Represent [`WebRtcPublishEndpoint`]. /// Can transform into [`Endpoint`] enum by `Endpoint::try_from`. + /// + /// [`Endpoint`]: crate::api::control::endpoint::Endpoint WebRtcPublishEndpoint { spec: WebRtcPublishEndpoint }, /// Represent [`WebRtcPlayEndpoint`]. /// Can transform into [`Endpoint`] enum by `Endpoint::try_from`. + /// + /// [`Endpoint`]: crate::api::control::endpoint::Endpoint WebRtcPlayEndpoint { spec: WebRtcPlayEndpoint }, } -/// Newtype for [`Element::Member`] variant. +/// Newtype for [`RoomElement::Member`] variant. #[allow(clippy::module_name_repetitions)] #[derive(Clone, Debug)] pub struct MemberSpec { diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index 3090910ec..dc0bc2192 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -31,8 +31,10 @@ pub enum RootElement { }, } -/// Errors that can occur when we try transform some spec from [`Element`]. +/// Errors that can occur when we try transform some spec from `Element`. /// This error used in all [`TryFrom`] of Control API. +/// +/// [`TryFrom`]: std::convert::TryFrom #[allow(clippy::pub_enum_variant_names)] #[derive(Debug, Fail)] pub enum TryFromElementError { diff --git a/src/api/control/room.rs b/src/api/control/room.rs index ccc914697..33c3d8d2d 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -28,6 +28,8 @@ macro_attr! { } /// Element of [`Room`]'s [`Pipeline`]. +/// +/// [`Room`]: crate::signalling::room::Room #[allow(clippy::module_name_repetitions)] #[derive(Clone, Deserialize, Debug)] #[serde(tag = "kind")] @@ -41,7 +43,7 @@ pub enum RoomElement { } /// [`crate::signalling::room::Room`] specification. -/// Newtype for [`Element::Room`] +/// Newtype for [`RootElement::Room`] #[allow(clippy::module_name_repetitions)] #[derive(Clone, Debug)] pub struct RoomSpec { diff --git a/src/media/peer.rs b/src/media/peer.rs index 1cc83c8f7..19141c0b7 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -164,7 +164,7 @@ pub struct Peer { impl Peer { /// Returns ID of [`Member`] associated with this [`Peer`]. /// - /// [`Member`]: crate::api::control::member::Member + /// [`Member`]: crate::signalling::elements::member::Member pub fn member_id(&self) -> MemberId { self.context.member_id.clone() } @@ -181,7 +181,7 @@ impl Peer { /// Returns ID of interconnected [`Member`]. /// - /// [`Member`]: crate::api::control::member::Member + /// [`Member`]: crate::signalling::elements::member::Member pub fn partner_member_id(&self) -> MemberId { self.context.partner_member.clone() } @@ -227,7 +227,7 @@ impl Peer { impl Peer { /// Creates new [`Peer`] for [`Member`]. /// - /// [`Member`]: crate::api::control::member::Member + /// [`Member`]: crate::signalling::elements::member::Member pub fn new( id: Id, member_id: MemberId, diff --git a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs index ca6978ae1..b89358d8d 100644 --- a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs @@ -144,6 +144,8 @@ impl WebRtcPlayEndpoint { } /// Return [`PeerId`] of [`Peer`] of this [`WebRtcPlayEndpoint`]. + /// + /// [`Peer`]: crate::media::peer::Peer pub fn peer_id(&self) -> Option { self.0.borrow().peer_id() } diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index 631560255..522c0e4fb 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -1,4 +1,7 @@ //! [`Member`] is member of [`Room`] with [`RpcConnection`]. +//! +//! [`Room`]: crate::signalling::room::Room +//! [`RpcConnection`]: crate::api::client::rpc_connection::RpcConnection use std::{ cell::RefCell, @@ -23,7 +26,7 @@ use super::endpoints::webrtc::{ /// Errors which may occur while loading [`Member`]s from [`RoomSpec`]. #[derive(Debug, Fail)] pub enum MembersLoadError { - /// Errors that can occur when we try transform some spec from [`Element`]. + /// Errors that can occur when we try transform some spec from `Element`. #[fail(display = "TryFromElementError: {}", _0)] TryFromError(TryFromElementError), @@ -32,6 +35,8 @@ pub enum MembersLoadError { MemberNotFound(MemberId), /// [`Endpoint`] not found. + /// + /// [`Endpoint`]: crate::api::control::endpoint::Endpoint #[fail(display = "Endpoint with id '{}' not found.", _0)] EndpointNotFound(String), } @@ -43,6 +48,9 @@ impl From for MembersLoadError { } /// [`Member`] is member of [`Room`] with [`RpcConnection`]. +/// +/// [`Room`]: crate::signalling::room::Room +/// [`RpcConnection`]: crate::api::client::rpc_connection::RpcConnection #[derive(Clone, Debug)] pub struct Member(Rc>); @@ -190,6 +198,8 @@ impl Member { /// Notify [`Member`] that some [`Peer`]s removed. /// /// All [`PeerId`]s related to this [`Member`] will be removed. + /// + /// [`Peer`]: crate::media::peer::Peer pub fn peers_removed(&self, peer_ids: &[PeerId]) { self.srcs() .into_iter() @@ -247,7 +257,7 @@ impl Member { self.0.borrow_mut().srcs.insert(endpoint.id(), endpoint); } - /// Lookup [`WebRtcPublishEndpoint`] source endpoint by [`EndpointId`]. + /// Lookup [`WebRtcPublishEndpoint`] source endpoint by [`WebRtcPublishId`]. pub fn get_src_by_id( &self, id: &WebRtcPublishId, @@ -255,7 +265,7 @@ impl Member { self.0.borrow().srcs.get(id).cloned() } - /// Lookup [`WebRtcPlayEndpoint`] sink endpoint by [`EndpointId`]. + /// Lookup [`WebRtcPlayEndpoint`] sink endpoint by [`WebRtcPlayId`]. pub fn get_sink_by_id( &self, id: &WebRtcPlayId, diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index a649c122f..1f5100510 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -3,7 +3,7 @@ //! [`RpcConnection`] authorization, establishment, message sending, Turn //! credentials management. //! -//! [`Member`]: crate::api::control::member::Member +//! [`Member`]: crate::signalling::elements::member::Member //! [`RpcConnection`]: crate::api::client::rpc_connection::RpcConnection //! [`ParticipantService`]: crate::signalling::participants::ParticipantService @@ -82,7 +82,9 @@ pub struct ParticipantService { /// Service for managing authorization on Turn server. turn: Arc, - /// Established [`RpcConnection`]s of [`Members`]s in this [`Room`]. + /// Established [`RpcConnection`]s of [`Member`]s in this [`Room`]. + /// + /// [`Member`]: crate::signalling::elements::member::Member // TODO: Replace Box> with enum, // as the set of all possible RpcConnection types is not closed. connections: HashMap>, @@ -141,7 +143,7 @@ impl ParticipantService { } } - /// Checks if [`Member`] has **active** [`RcpConnection`]. + /// Checks if [`Member`] has **active** [`RpcConnection`]. pub fn member_has_connection(&self, member_id: &MemberId) -> bool { self.connections.contains_key(member_id) && !self.drop_connection_tasks.contains_key(member_id) diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index b28c91bdd..e9bd33a8f 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -22,14 +22,19 @@ use crate::{ pub struct PeerRepository { /// [`Peer`]s of [`Member`]s in this [`Room`]. /// - /// [`Member`]: crate::api::control::member::Member + /// [`Member`]: crate::signalling::elements::member::Member /// [`Room`]: crate::signalling::Room peers: HashMap, /// Count of [`Peer`]s in this [`Room`]. + /// + /// [`Room`]: crate::signalling::room::Room peers_count: Counter, /// Count of [`MediaTrack`]s in this [`Room`]. + /// + /// [`MediaTrack`]: crate::media::track::MediaTrack + /// [`Room`]: crate::signalling::room::Room tracks_count: Counter, } @@ -148,7 +153,7 @@ impl PeerRepository { /// Returns all [`Peer`]s of specified [`Member`]. /// - /// [`Member`]: crate::api::control::member::Member + /// [`Member`]: crate::signalling::elements::member::Member pub fn get_peers_by_member_id<'a>( &'a self, member_id: &'a MemberId, diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 6b10b08aa..a146aa004 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -1,7 +1,7 @@ //! Room definitions and implementations. Room is responsible for media //! connection establishment between concrete [`Member`]s. //! -//! [`Member`]: crate::api::control::member::Member +//! [`Member`]: crate::signalling::elements::member::Member use std::{collections::HashMap, sync::Arc, time::Duration}; @@ -114,7 +114,7 @@ pub struct Room { impl Room { /// Create new instance of [`Room`]. /// - /// Returns [`RoomError::BadRoomSpec`] when error while [`Element`] + /// Returns [`RoomError::BadRoomSpec`] when error while `Element` /// transformation happens. pub fn new( room_spec: &RoomSpec, @@ -653,6 +653,8 @@ impl Handler for Room { /// /// Delete all removed [`PeerId`]s from all [`Member`]'s /// endpoints. + /// + /// [`PeersRemoved`]: medea-client-api-proto::Event::PeersRemoved fn handle(&mut self, msg: RpcConnectionClosed, ctx: &mut Self::Context) { info!( "RpcConnectionClosed for member {}, reason {:?}", From d2a5eba75f113f05f8d2e7b57ff01517b8f5dcab Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 22 Aug 2019 14:46:53 +0300 Subject: [PATCH 506/735] Update CHANGELOG [run ci] --- CHANGELOG.md | 18 +++++++++++++++++- jason/CHANGELOG.md | 12 ++++++++++++ proto/client-api/CHANGELOG.md | 13 +++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5755c7fce..182179eea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,23 @@ All user visible changes to this project will be documented in this file. This p +## TBD [0.2.0] · 2019-??-?? +[0.2.0]: /../../tree/medea-0.2.0 + +[Milestone](../../milestone/2) | [Roadmap](/../../issues/27) + +### Added + +- Static control API spec [#28](https://github.com/instrumentisto/medea/pull/28) + - parse static control api specs + - created interior entities for control API specs + - dynamically `Peer`s creation when client connects + - auto removing `Peer`s when `Member` disconnects + - E2E tests for signalling + + + + ## [0.1.0] · 2019-08-22 [0.1.0]: /../../tree/medea-0.1.0 @@ -27,6 +44,5 @@ All user visible changes to this project will be documented in this file. This p - [Coturn]: https://github.com/coturn/coturn [Semantic Versioning 2.0.0]: https://semver.org diff --git a/jason/CHANGELOG.md b/jason/CHANGELOG.md index 2e9e5a89a..378c59e87 100644 --- a/jason/CHANGELOG.md +++ b/jason/CHANGELOG.md @@ -6,6 +6,18 @@ All user visible changes to this project will be documented in this file. This p +## TBD [0.2.0] · 2019-??-?? +[0.2.0]: /../../tree/medea-jason-0.2.0 + +[Milestone](../../milestone/2) | [Roadmap](/../../issues/27) + +### Changed + +- Use newtypes for track ID and peer ID ([#28](https://github.com/instrumentisto/medea/pull/28)) + + + + ## [0.1.0] · 2019-08-21 [0.1.0]: /../../tree/medea-jason-0.1.0/jason diff --git a/proto/client-api/CHANGELOG.md b/proto/client-api/CHANGELOG.md index b95b7bf90..810d57955 100644 --- a/proto/client-api/CHANGELOG.md +++ b/proto/client-api/CHANGELOG.md @@ -6,6 +6,19 @@ All user visible changes to this project will be documented in this file. This p +## TBD [0.2.0] · 2019-??-?? +[0.2.0]: /../../tree/medea-client-api-proto-0.2.0 + +[Milestone](../../milestone/2) | [Roadmap](/../../issues/27) + +### Added + +- `TrackId` and `PeerId` +- `Incrementable` trait + + + + ## [0.1.0] · 2019-08-21 [0.1.0]: /../../tree/medea-client-api-proto-0.1.0/proto/client-api From e510d43df428b1d881507f994c0633766945c927 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 22 Aug 2019 15:13:40 +0300 Subject: [PATCH 507/735] Remove allow clippy::use_self from jason, use stable clippy in CI [run ci] --- .travis.yml | 2 +- jason/src/lib.rs | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index e88667eae..500b905a0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,7 @@ jobs: include: - name: Clippy stage: check - rust: nightly + rust: stable before_script: rustup component add clippy script: make lint diff --git a/jason/src/lib.rs b/jason/src/lib.rs index 5b46cb81a..846efad6c 100644 --- a/jason/src/lib.rs +++ b/jason/src/lib.rs @@ -1,6 +1,3 @@ -// TODO: when using enum's Self will be in stable, remove it. -#![allow(clippy::use_self)] - pub mod api; pub mod media; pub mod peer; From d824aa217ec28fa3ca03e79d958a432b3e8ca827 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 22 Aug 2019 15:43:48 +0300 Subject: [PATCH 508/735] Add dockerized building, upd contributing guide [run ci] --- .travis.yml | 6 +++--- CONTRIBUTING.md | 11 ++++++++--- Makefile | 30 +++++++++++++++++++++++++++--- proto/client-api/Cargo.toml | 2 -- 4 files changed, 38 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index 500b905a0..af03856f8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -36,17 +36,17 @@ jobs: - name: medea (stable) stage: build rust: stable - script: cargo build --bin medea + script: make build.medea - name: medea (beta) stage: build rust: beta - script: cargo build --bin medea + script: make build.medea - name: medea (nightly) stage: build rust: nightly - script: cargo build --bin medea + script: make build.medea - name: unit (stable) stage: test diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 07c3ee866..15e4e9213 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -31,7 +31,7 @@ Boot up dockerized environment for [medea] with [jason]: $ make up.dev ``` -In some cases you may wish boot up only [medea] without [jason]: +Boot up only [medea] without [jason]: ```bash $ make up.medea ``` @@ -41,7 +41,7 @@ $ make up.medea To build/rebuild project and its Docker image use docker-wrapped command from [`Makefile`]: ```bash -$ make build +$ make build dockerized=yes ``` To build only [medea]: @@ -54,6 +54,11 @@ To build only [jason]: $ make build.jason ``` +To build [medea] in docker (it works with [jason] too): +```bash +$ make build.medea dockerized=yes +``` + ### Formatting @@ -75,7 +80,7 @@ $ make lint To run unit tests command from [`Makefile`]: ```bash -$ make test.unit +$ make test.unit crate=@all # or for concrete crate only $ make test.unit crate=medea diff --git a/Makefile b/Makefile index 6e32a20d6..cbc46991b 100644 --- a/Makefile +++ b/Makefile @@ -648,18 +648,41 @@ endef # Build medea. # # Usage: -# make build.medea +# make build.medea [dockerized=(no|yes)] build.medea: - cargo build -p medea +ifneq ($(dockerized),yes) + cargo build --bin medea +else + docker run --rm \ + -v "$(PWD)":/app -w /app \ + -u $(shell id -u):$(shell id -g) \ + -v "$(HOME)/.cargo/registry":/usr/local/cargo/registry \ + -v "$(PWD)/target":/app/target \ + rust:latest \ + make build.medea +endif # Build jason. # # Usage: -# make build.jason +# make build.jason [dockerized=(no|yes)] + build.jason: +ifneq ($(dockerized),yes) wasm-pack build -t web jason +else + docker run --rm --network=host \ + -v "$(PWD)":/app -w /app \ + -u $(shell id -u):$(shell id -g) \ + -v "$(HOME)/.cargo/registry":/usr/local/cargo/registry \ + -v "$(PWD)/target":/app/target \ + --env XDG_CACHE_HOME=$(HOME) \ + -v "$(HOME):$(HOME)" \ + rust:latest \ + sh -c "curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh && make build.jason" +endif @@ -680,4 +703,5 @@ build.jason: release release.crates release.helm release.npm \ test test.unit test.e2e \ up up.coturn up.demo up.dev up.jason up.medea \ + build build.medea build.jason \ yarn diff --git a/proto/client-api/Cargo.toml b/proto/client-api/Cargo.toml index 4139fc685..ec5d7a9ec 100644 --- a/proto/client-api/Cargo.toml +++ b/proto/client-api/Cargo.toml @@ -21,7 +21,5 @@ medea = [] medea-macro = "0.1" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" - -# TODO: move it into features newtype_derive = "0.1" macro-attr = "0.2" From 9b83a5bc848a24696d9b132a5d0c3eeee24a4651 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 22 Aug 2019 16:42:58 +0300 Subject: [PATCH 509/735] Fix Makefile [run ci] --- Makefile | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index cbc46991b..e0fa54fe4 100644 --- a/Makefile +++ b/Makefile @@ -308,7 +308,7 @@ ifneq ($(coturn),no) @make up.coturn endif ifeq ($(dockerized),no) - @make down.medea dockerized=no + -@make down.medea dockerized=no cargo build $(if $(call eq,$(release),yes),--release) env $(medea-env) $(if $(call eq,$(logs),yes),,RUST_LOG=warn) cargo run $(if $(call eq,$(release),yes),--release) & @@ -316,14 +316,15 @@ ifeq ($(dockerized),no) sleep 1 cargo test --test e2e - @make down + -@make down ifneq ($(coturn),no) - @make down.coturn + -@make down.coturn endif - @exit $(.SHELLSTATUS) + -@exit $(.SHELLSTATUS) else - @make down.medea dockerized=yes - @make down.medea dockerized=no + -@make down.medea dockerized=yes + -@make down.medea dockerized=no + @make up.coturn docker run --rm --network=host -v "$(PWD)":/app -w /app \ @@ -333,7 +334,7 @@ else rust:latest \ make test.e2e dockerized=no coturn=no release=yes - @make down.coturn + -@make down.coturn endif From ee8d67284dc786b2adb7313275eab593a142b28e Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 22 Aug 2019 18:49:24 +0300 Subject: [PATCH 510/735] Upd CHANGELOG, add license, CHANGELOG and README for medea-grpc-proto --- CHANGELOG.md | 16 +-- Cargo.lock | 4 +- proto/grpc/CHANGELOG.md | 32 ++++++ proto/grpc/Cargo.toml | 12 ++- proto/grpc/LICENSE-APACHE.md | 194 +++++++++++++++++++++++++++++++++++ proto/grpc/LICENSE-MIT.md | 25 +++++ proto/grpc/README.md | 44 ++++++++ 7 files changed, 314 insertions(+), 13 deletions(-) create mode 100644 proto/grpc/CHANGELOG.md create mode 100644 proto/grpc/LICENSE-APACHE.md create mode 100644 proto/grpc/LICENSE-MIT.md create mode 100644 proto/grpc/README.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 182179eea..824549f59 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,12 +13,16 @@ All user visible changes to this project will be documented in this file. This p ### Added -- Static control API spec [#28](https://github.com/instrumentisto/medea/pull/28) - - parse static control api specs - - created interior entities for control API specs - - dynamically `Peer`s creation when client connects - - auto removing `Peer`s when `Member` disconnects - - E2E tests for signalling +- Dynamic control API exposed via gRPC ([#33](/../../pull/33)): + - `Create` method for `Room`, `Member`, `Endpoint`; + - `Get` method for `Room`, `Member`, `Endpoint`; + - `Delete` method for `Room`, `Member`, `Endpoint`. +- Static control API spec ([#28](/../../pull/28)) + - parse static control api specs + - created interior entities for control API specs + - dynamically `Peer`s creation when client connects + - auto removing `Peer`s when `Member` disconnects + - E2E tests for signalling diff --git a/Cargo.lock b/Cargo.lock index fd5201f6d..588705f61 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1163,7 +1163,7 @@ dependencies = [ "humantime-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "macro-attr 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "medea-client-api-proto 0.2.0-dev.1", - "medea-grpc-proto 0.1.0-dev", + "medea-grpc-proto 0.1.0-dev.1", "medea-macro 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "newtype_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.8.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1200,7 +1200,7 @@ dependencies = [ [[package]] name = "medea-grpc-proto" -version = "0.1.0-dev" +version = "0.1.0-dev.1" dependencies = [ "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "grpcio 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/proto/grpc/CHANGELOG.md b/proto/grpc/CHANGELOG.md new file mode 100644 index 000000000..53cccff17 --- /dev/null +++ b/proto/grpc/CHANGELOG.md @@ -0,0 +1,32 @@ +`medea-grpc-proto` changelog +================================== + +All user visible changes to this project will be documented in this file. This project uses [Semantic Versioning 2.0.0]. + + + + +## TBD [0.1.0] · 2019-??-?? +[0.1.0]: /../../tree/medea-grpc-proto-0.1.0/proto/grpc + +[Milestone](/../../milestone/2) | [Roadmap](/../../issues/27) + +### Added + +- Methods ([#33](/../../pull/33)): + - `Create`, + - `Get`, + - `Delete`. +- Elements ([#33](/../../pull/33)): + - `Room`, + - `Member`, + - `WebRtcPlayEndpoint`, + - `WebRtcPublishEndpoint` + - `Hub`, + - `FileRecorder`, + - `Relay`. + + + + +[Semantic Versioning 2.0.0]: https://semver.org diff --git a/proto/grpc/Cargo.toml b/proto/grpc/Cargo.toml index d981a5cf3..6e3342704 100644 --- a/proto/grpc/Cargo.toml +++ b/proto/grpc/Cargo.toml @@ -1,13 +1,15 @@ [package] name = "medea-grpc-proto" -version = "0.1.0-dev" +version = "0.1.0-dev.1" edition = "2018" -description = "Client API protocol implementation for Medea media server" +description = "Compiled gRPC specs for Medea media server control API." authors = ["Instrumentisto Team "] -homepage = "https://github.com/instrumentisto/medea" +license = "MIT/Apache-2.0" +homepage = "https://github.com/instrumentisto/medea/tree/master/proto/grpc" +repository = "https://github.com/instrumentisto/medea/tree/master/proto/grpc" readme = "README.md" -repository = "https://github.com/instrumentisto/medea" -build = "build.rs" +keywords = ["medea", "grpc", "control-api"] +categories = ["api-bindings", "web-programming"] [dependencies] grpcio = "0.4" diff --git a/proto/grpc/LICENSE-APACHE.md b/proto/grpc/LICENSE-APACHE.md new file mode 100644 index 000000000..24e951b55 --- /dev/null +++ b/proto/grpc/LICENSE-APACHE.md @@ -0,0 +1,194 @@ +Apache License +============== + +_Version 2.0, January 2004_ +_<>_ + +### Terms and Conditions for use, reproduction, and distribution + +#### 1. Definitions + +“License” shall mean the terms and conditions for use, reproduction, and +distribution as defined by Sections 1 through 9 of this document. + +“Licensor” shall mean the copyright owner or entity authorized by the copyright +owner that is granting the License. + +“Legal Entity” shall mean the union of the acting entity and all other entities +that control, are controlled by, or are under common control with that entity. +For the purposes of this definition, “control” means **(i)** the power, direct or +indirect, to cause the direction or management of such entity, whether by +contract or otherwise, or **(ii)** ownership of fifty percent (50%) or more of the +outstanding shares, or **(iii)** beneficial ownership of such entity. + +“You” (or “Your”) shall mean an individual or Legal Entity exercising +permissions granted by this License. + +“Source” form shall mean the preferred form for making modifications, including +but not limited to software source code, documentation source, and configuration +files. + +“Object” form shall mean any form resulting from mechanical transformation or +translation of a Source form, including but not limited to compiled object code, +generated documentation, and conversions to other media types. + +“Work” shall mean the work of authorship, whether in Source or Object form, made +available under the License, as indicated by a copyright notice that is included +in or attached to the work (an example is provided in the Appendix below). + +“Derivative Works” shall mean any work, whether in Source or Object form, that +is based on (or derived from) the Work and for which the editorial revisions, +annotations, elaborations, or other modifications represent, as a whole, an +original work of authorship. For the purposes of this License, Derivative Works +shall not include works that remain separable from, or merely link (or bind by +name) to the interfaces of, the Work and Derivative Works thereof. + +“Contribution” shall mean any work of authorship, including the original version +of the Work and any modifications or additions to that Work or Derivative Works +thereof, that is intentionally submitted to Licensor for inclusion in the Work +by the copyright owner or by an individual or Legal Entity authorized to submit +on behalf of the copyright owner. For the purposes of this definition, +“submitted” means any form of electronic, verbal, or written communication sent +to the Licensor or its representatives, including but not limited to +communication on electronic mailing lists, source code control systems, and +issue tracking systems that are managed by, or on behalf of, the Licensor for +the purpose of discussing and improving the Work, but excluding communication +that is conspicuously marked or otherwise designated in writing by the copyright +owner as “Not a Contribution.” + +“Contributor” shall mean Licensor and any individual or Legal Entity on behalf +of whom a Contribution has been received by Licensor and subsequently +incorporated within the Work. + +#### 2. Grant of Copyright License + +Subject to the terms and conditions of this License, each Contributor hereby +grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, +irrevocable copyright license to reproduce, prepare Derivative Works of, +publicly display, publicly perform, sublicense, and distribute the Work and such +Derivative Works in Source or Object form. + +#### 3. Grant of Patent License + +Subject to the terms and conditions of this License, each Contributor hereby +grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, +irrevocable (except as stated in this section) patent license to make, have +made, use, offer to sell, sell, import, and otherwise transfer the Work, where +such license applies only to those patent claims licensable by such Contributor +that are necessarily infringed by their Contribution(s) alone or by combination +of their Contribution(s) with the Work to which such Contribution(s) was +submitted. If You institute patent litigation against any entity (including a +cross-claim or counterclaim in a lawsuit) alleging that the Work or a +Contribution incorporated within the Work constitutes direct or contributory +patent infringement, then any patent licenses granted to You under this License +for that Work shall terminate as of the date such litigation is filed. + +#### 4. Redistribution + +You may reproduce and distribute copies of the Work or Derivative Works thereof +in any medium, with or without modifications, and in Source or Object form, +provided that You meet the following conditions: + +* **(a)** You must give any other recipients of the Work or Derivative Works a copy of +this License; and +* **(b)** You must cause any modified files to carry prominent notices stating that You +changed the files; and +* **(c)** You must retain, in the Source form of any Derivative Works that You distribute, +all copyright, patent, trademark, and attribution notices from the Source form +of the Work, excluding those notices that do not pertain to any part of the +Derivative Works; and +* **(d)** If the Work includes a “NOTICE” text file as part of its distribution, then any +Derivative Works that You distribute must include a readable copy of the +attribution notices contained within such NOTICE file, excluding those notices +that do not pertain to any part of the Derivative Works, in at least one of the +following places: within a NOTICE text file distributed as part of the +Derivative Works; within the Source form or documentation, if provided along +with the Derivative Works; or, within a display generated by the Derivative +Works, if and wherever such third-party notices normally appear. The contents of +the NOTICE file are for informational purposes only and do not modify the +License. You may add Your own attribution notices within Derivative Works that +You distribute, alongside or as an addendum to the NOTICE text from the Work, +provided that such additional attribution notices cannot be construed as +modifying the License. + +You may add Your own copyright statement to Your modifications and may provide +additional or different license terms and conditions for use, reproduction, or +distribution of Your modifications, or for any such Derivative Works as a whole, +provided Your use, reproduction, and distribution of the Work otherwise complies +with the conditions stated in this License. + +#### 5. Submission of Contributions + +Unless You explicitly state otherwise, any Contribution intentionally submitted +for inclusion in the Work by You to the Licensor shall be under the terms and +conditions of this License, without any additional terms or conditions. +Notwithstanding the above, nothing herein shall supersede or modify the terms of +any separate license agreement you may have executed with Licensor regarding +such Contributions. + +#### 6. Trademarks + +This License does not grant permission to use the trade names, trademarks, +service marks, or product names of the Licensor, except as required for +reasonable and customary use in describing the origin of the Work and +reproducing the content of the NOTICE file. + +#### 7. Disclaimer of Warranty + +Unless required by applicable law or agreed to in writing, Licensor provides the +Work (and each Contributor provides its Contributions) on an “AS IS” BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, +including, without limitation, any warranties or conditions of TITLE, +NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are +solely responsible for determining the appropriateness of using or +redistributing the Work and assume any risks associated with Your exercise of +permissions under this License. + +#### 8. Limitation of Liability + +In no event and under no legal theory, whether in tort (including negligence), +contract, or otherwise, unless required by applicable law (such as deliberate +and grossly negligent acts) or agreed to in writing, shall any Contributor be +liable to You for damages, including any direct, indirect, special, incidental, +or consequential damages of any character arising as a result of this License or +out of the use or inability to use the Work (including but not limited to +damages for loss of goodwill, work stoppage, computer failure or malfunction, or +any and all other commercial damages or losses), even if such Contributor has +been advised of the possibility of such damages. + +#### 9. Accepting Warranty or Additional Liability + +While redistributing the Work or Derivative Works thereof, You may choose to +offer, and charge a fee for, acceptance of support, warranty, indemnity, or +other liability obligations and/or rights consistent with this License. However, +in accepting such obligations, You may act only on Your own behalf and on Your +sole responsibility, not on behalf of any other Contributor, and only if You +agree to indemnify, defend, and hold each Contributor harmless for any liability +incurred by, or claims asserted against, such Contributor by reason of your +accepting any such warranty or additional liability. + +_END OF TERMS AND CONDITIONS_ + +### APPENDIX: How to apply the Apache License to your work + +To apply the Apache License to your work, attach the following boilerplate +notice, with the fields enclosed by brackets `[]` replaced with your own +identifying information. (Don't include the brackets!) The text should be +enclosed in the appropriate comment syntax for the file format. We also +recommend that a file or class name and description of purpose be included on +the same “printed page” as the copyright notice for easier identification within +third-party archives. + + Copyright © 2019 Instrumentisto Team, https://github.com/instrumentisto + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/proto/grpc/LICENSE-MIT.md b/proto/grpc/LICENSE-MIT.md new file mode 100644 index 000000000..8852bcc25 --- /dev/null +++ b/proto/grpc/LICENSE-MIT.md @@ -0,0 +1,25 @@ +The MIT License (MIT) +===================== + +Copyright © 2019 Instrumentisto Team, https://github.com/instrumentisto + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the “Software”), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. diff --git a/proto/grpc/README.md b/proto/grpc/README.md new file mode 100644 index 000000000..a8f05477a --- /dev/null +++ b/proto/grpc/README.md @@ -0,0 +1,44 @@ +Medea Control API gRPC specs +========================= + +[![Crates.io](https://img.shields.io/crates/v/medea-grpc-proto)](https://crates.io/crates/medea-grpc-proto) +![Crates.io license](https://img.shields.io/crates/l/medea-grpc-proto) + +[Changelog](https://github.com/instrumentisto/medea/blob/master/proto/grpc/CHANGELOG.md) + +Compiled gRPC specs for [Medea] media server control API. + +__Currently, in early development phase.__ + + + + +## Prerequisites +- CMake >= 3.8.0 +- Rust >= 1.19.0 +- binutils >= 2.22 +- LLVM and Clang >= 3.9 if you need to generate bindings at compile time. +- [protoc](https://github.com/protocolbuffers/protobuf) + + + + +## License + +This project is licensed under either of + +- Apache License, Version 2.0, ([LICENSE-APACHE](https://github.com/instrumentisto/medea/blob/master/proto/client-api/LICENSE-APACHE.md) or http://www.apache.org/licenses/LICENSE-2.0) +- MIT license ([LICENSE-MIT](https://github.com/instrumentisto/medea/blob/master/proto/client-api/LICENSE-MIT.md) or http://opensource.org/licenses/MIT) + +at your option. + + +### Contribution + +Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. + + + + + +[Medea]: https://github.com/instrumentisto/medea From e9c7dca52f0539afc2d94265b9fc2d7f5689840c Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 23 Aug 2019 12:49:24 +0300 Subject: [PATCH 511/735] Generate gRPC to OUT_DIR for publishing to crates.io [run ci] --- .gitignore | 3 --- proto/grpc/build.rs | 24 +++++++++++++++++------- proto/grpc/{ => proto}/control.proto | 0 proto/grpc/src/lib.rs | 7 ++----- 4 files changed, 19 insertions(+), 15 deletions(-) rename proto/grpc/{ => proto}/control.proto (100%) diff --git a/.gitignore b/.gitignore index 68aaff180..8f622b075 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,3 @@ /target/ **/*.rs.bk - -/proto/grpc/src -!/proto/grpc/src/lib.rs diff --git a/proto/grpc/build.rs b/proto/grpc/build.rs index 13799655d..e965c45cb 100644 --- a/proto/grpc/build.rs +++ b/proto/grpc/build.rs @@ -1,12 +1,22 @@ -fn main() { - let proto_root = "."; - let proto_output = "./src"; - println!("cargo:rerun-if-changed={}", proto_root); +use std::{env, fs::File, io::Write as _}; + +static CONTROL_API_MOD_RS: &[u8] = b" +/// Generated from protobuf. +pub mod control; +/// Generated from protobuf. +pub mod control_grpc; +"; + +fn main() -> Result<(), Box> { + let out_dir = env::var("OUT_DIR")?; + protoc_grpcio::compile_grpc_protos( - &["control.proto"], - &[proto_root], - &proto_output, + &["proto/control.proto"], + &["proto"], + &out_dir, None, ) .expect("Failed to compile gRPC definitions!"); + File::create(out_dir + "/mod.rs")?.write_all(CONTROL_API_MOD_RS)?; + Ok(()) } diff --git a/proto/grpc/control.proto b/proto/grpc/proto/control.proto similarity index 100% rename from proto/grpc/control.proto rename to proto/grpc/proto/control.proto diff --git a/proto/grpc/src/lib.rs b/proto/grpc/src/lib.rs index 56a1f42cd..a828042da 100644 --- a/proto/grpc/src/lib.rs +++ b/proto/grpc/src/lib.rs @@ -1,11 +1,8 @@ //! gRPC generated specs. -//! Don't edit `*.rs` files (except `lib.rs`) in this crate because it -//! automatically generated by `protoc` in `build.rs` file. #![allow(bare_trait_objects)] #![allow(clippy::pedantic)] #![allow(clippy::cargo)] #![allow(clippy::nursery)] - -pub mod control; -pub mod control_grpc; +#![allow(bare_trait_objects)] +include!(concat!(env!("OUT_DIR"), "/mod.rs")); From ea447073f5b88d582516c493aa9a4ca3713372cc Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 23 Aug 2019 18:55:18 +0300 Subject: [PATCH 512/735] Fix CHANGELOGs --- CHANGELOG.md | 16 ++++++++++------ jason/CHANGELOG.md | 2 +- proto/client-api/CHANGELOG.md | 6 ++++-- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 182179eea..203f983ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,12 +13,16 @@ All user visible changes to this project will be documented in this file. This p ### Added -- Static control API spec [#28](https://github.com/instrumentisto/medea/pull/28) - - parse static control api specs - - created interior entities for control API specs - - dynamically `Peer`s creation when client connects - - auto removing `Peer`s when `Member` disconnects - - E2E tests for signalling +- Control API: + - Parse static control api specs ([#28]); + - Created interior entities for control API specs ([#28]). +- Signalling: + - Dynamic `Peer`s creation when client connect ([#28]); + - Auto removing `Peer`s when `Member` disconnect ([#28]). +- Testing: + - E2E tests for signalling ([#28]). + +[#28]: /../../pull/28 diff --git a/jason/CHANGELOG.md b/jason/CHANGELOG.md index 378c59e87..157d3116a 100644 --- a/jason/CHANGELOG.md +++ b/jason/CHANGELOG.md @@ -13,7 +13,7 @@ All user visible changes to this project will be documented in this file. This p ### Changed -- Use newtypes for track ID and peer ID ([#28](https://github.com/instrumentisto/medea/pull/28)) +- Use track ID and peer ID from `medea-client-api-proto` ([#28](/../../pull/28)) diff --git a/proto/client-api/CHANGELOG.md b/proto/client-api/CHANGELOG.md index 810d57955..a6c571591 100644 --- a/proto/client-api/CHANGELOG.md +++ b/proto/client-api/CHANGELOG.md @@ -13,8 +13,10 @@ All user visible changes to this project will be documented in this file. This p ### Added -- `TrackId` and `PeerId` -- `Incrementable` trait +- `TrackId` and `PeerId` ([#28]) +- `Incrementable` trait ([#28]) + +[#28]: ../../pull/28 From 52095700324bf475f537f7aaae74d35dede863a3 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 23 Aug 2019 19:01:22 +0300 Subject: [PATCH 513/735] Fix MD links --- CHANGELOG.md | 2 +- CONTRIBUTING.md | 4 ++-- jason/CHANGELOG.md | 4 ++-- proto/client-api/CHANGELOG.md | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 203f983ac..23236a692 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ All user visible changes to this project will be documented in this file. This p ## TBD [0.2.0] · 2019-??-?? [0.2.0]: /../../tree/medea-0.2.0 -[Milestone](../../milestone/2) | [Roadmap](/../../issues/27) +[Milestone](/../../milestone/2) | [Roadmap](/../../issues/27) ### Added diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 15e4e9213..530d4aa05 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -116,8 +116,8 @@ Add `[run ci]` to your commit message. -[`Makefile`]: https://github.com/instrumentisto/medea/blob/master/Makefile -[jason]: https://github.com/instrumentisto/medea/tree/master/jason +[`Makefile`]: /Makefile +[jason]: /jason [medea]: https://github.com/instrumentisto/medea [Rust]: https://www.rust-lang.org/ [wasm-pack]: https://github.com/rustwasm/wasm-pack diff --git a/jason/CHANGELOG.md b/jason/CHANGELOG.md index 157d3116a..214174a47 100644 --- a/jason/CHANGELOG.md +++ b/jason/CHANGELOG.md @@ -7,9 +7,9 @@ All user visible changes to this project will be documented in this file. This p ## TBD [0.2.0] · 2019-??-?? -[0.2.0]: /../../tree/medea-jason-0.2.0 +[0.2.0]: /../../tree/medea-jason-0.2.0/jason -[Milestone](../../milestone/2) | [Roadmap](/../../issues/27) +[Milestone](/../../milestone/2) | [Roadmap](/../../issues/27) ### Changed diff --git a/proto/client-api/CHANGELOG.md b/proto/client-api/CHANGELOG.md index a6c571591..d66ccaa80 100644 --- a/proto/client-api/CHANGELOG.md +++ b/proto/client-api/CHANGELOG.md @@ -7,16 +7,16 @@ All user visible changes to this project will be documented in this file. This p ## TBD [0.2.0] · 2019-??-?? -[0.2.0]: /../../tree/medea-client-api-proto-0.2.0 +[0.2.0]: /../../tree/medea-client-api-proto-0.2.0/proto/client-api -[Milestone](../../milestone/2) | [Roadmap](/../../issues/27) +[Milestone](/../../milestone/2) | [Roadmap](/../../issues/27) ### Added - `TrackId` and `PeerId` ([#28]) - `Incrementable` trait ([#28]) -[#28]: ../../pull/28 +[#28]: /../../pull/28 From f1709c3f9bce7371337a2b7f30f3de2f1b99f450 Mon Sep 17 00:00:00 2001 From: alexlapa Date: Wed, 28 Aug 2019 13:25:09 +0300 Subject: [PATCH 514/735] refactor [run ci] --- .env | 3 - .travis.yml | 2 +- Cargo.lock | 148 +++++++++++----------- Cargo.toml | 4 +- Makefile | 52 +++----- docker-compose.medea.yml | 7 +- jason/Cargo.toml | 2 +- jason/e2e-demo/js/index.js | 5 - jason/src/api/connection.rs | 13 +- jason/src/api/room.rs | 10 +- proto/client-api/Cargo.toml | 2 +- proto/client-api/src/lib.rs | 2 - tests/e2e/signalling/mod.rs | 44 ++++--- tests/e2e/signalling/pub_sub_signallng.rs | 5 +- tests/e2e/signalling/three_pubs.rs | 6 +- 15 files changed, 142 insertions(+), 163 deletions(-) diff --git a/.env b/.env index 4c79c4691..96d451168 100644 --- a/.env +++ b/.env @@ -4,6 +4,3 @@ MEDEA_CONF=config.toml COMPOSE_PROJECT_NAME=medea COMPOSE_IMAGE_NAME=instrumentisto/medea COMPOSE_IMAGE_VER=0.0.1-dev - -MEDEA_SERVER_BIND_PORT=8080 -MEDEA_SERVER_STATIC_SPECS_PATH=./dev/specs diff --git a/.travis.yml b/.travis.yml index af03856f8..d1b95047f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -56,7 +56,7 @@ jobs: - name: e2e signalling (stable) stage: test rust: stable - script: make test.e2e + script: make test.e2e release=yes - name: crates.io stage: release diff --git a/Cargo.lock b/Cargo.lock index 3c6eb1bd2..d44cf9976 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5,7 +5,7 @@ name = "Inflector" version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -23,7 +23,7 @@ dependencies = [ "derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "hashbrown 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", @@ -53,7 +53,7 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-service 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-service 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "actix-utils 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", "either 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -73,7 +73,7 @@ dependencies = [ "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "actix-connect 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "actix-server-config 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-service 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-service 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "actix-threadpool 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "actix-utils 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -94,7 +94,7 @@ dependencies = [ "httparse 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "mime 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", "percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -120,7 +120,7 @@ dependencies = [ "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "actix-rt 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "actix-server 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-service 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-service 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "actix-utils 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "awc 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -174,7 +174,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "actix-rt 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "actix-server-config 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-service 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-service 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", @@ -200,7 +200,7 @@ dependencies = [ [[package]] name = "actix-service" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", @@ -213,7 +213,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -226,7 +226,7 @@ version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-service 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-service 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "either 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", @@ -246,7 +246,7 @@ dependencies = [ "actix-rt 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "actix-server 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "actix-server-config 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-service 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-service 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "actix-threadpool 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "actix-utils 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "actix-web-codegen 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -338,7 +338,7 @@ dependencies = [ [[package]] name = "ascii" -version = "0.9.2" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -347,7 +347,7 @@ version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -362,7 +362,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "actix-http 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-service 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-service 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -393,7 +393,7 @@ name = "backtrace-sys" version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -446,7 +446,7 @@ name = "brotli-sys" version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -483,13 +483,13 @@ name = "c2-chacha" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "ppv-lite86 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cc" -version = "1.0.40" +version = "1.0.41" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -521,7 +521,7 @@ name = "combine" version = "3.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "ascii 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", + "ascii 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "either 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -533,7 +533,7 @@ name = "config" version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "nom 4.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "rust-ini 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)", @@ -608,7 +608,7 @@ dependencies = [ "arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "memoffset 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -627,7 +627,7 @@ version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -646,7 +646,7 @@ name = "derive_more" version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -661,7 +661,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", "redox_users 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -670,7 +670,7 @@ version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -838,7 +838,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "getrandom" -version = "0.1.10" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -963,7 +963,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "socket2 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)", "widestring 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "winreg 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1001,7 +1001,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "lazy_static" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1076,7 +1076,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "medea" -version = "0.2.0-dev.1" +version = "0.1.0" dependencies = [ "actix 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)", "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1095,7 +1095,7 @@ dependencies = [ "humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "humantime-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "macro-attr 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "medea-client-api-proto 0.2.0-dev.1", + "medea-client-api-proto 0.1.0", "medea-macro 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "newtype_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1120,7 +1120,7 @@ dependencies = [ [[package]] name = "medea-client-api-proto" -version = "0.2.0-dev.1" +version = "0.1.0" dependencies = [ "macro-attr 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "medea-macro 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1131,13 +1131,13 @@ dependencies = [ [[package]] name = "medea-jason" -version = "0.2.0-dev.1" +version = "0.1.0" dependencies = [ "console_error_panic_hook 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "js-sys 0.3.27 (registry+https://github.com/rust-lang/crates.io-index)", "macro-attr 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "medea-client-api-proto 0.2.0-dev.1", + "medea-client-api-proto 0.1.0", "medea-macro 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "newtype_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1156,7 +1156,7 @@ dependencies = [ "Inflector 0.11.4 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1201,7 +1201,7 @@ name = "miniz-sys" version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1258,7 +1258,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1362,7 +1362,7 @@ dependencies = [ "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1377,7 +1377,7 @@ dependencies = [ "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1391,7 +1391,7 @@ dependencies = [ "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1464,7 +1464,7 @@ dependencies = [ "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1482,7 +1482,7 @@ dependencies = [ "rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1490,7 +1490,7 @@ name = "rand" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "getrandom 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "getrandom 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1533,7 +1533,7 @@ name = "rand_core" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "getrandom 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "getrandom 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1567,7 +1567,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1580,7 +1580,7 @@ dependencies = [ "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1792,7 +1792,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1851,7 +1851,7 @@ name = "serial_test" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1937,7 +1937,7 @@ version = "4.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arc-swap 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1987,7 +1987,7 @@ dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2020,7 +2020,7 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.3" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2051,7 +2051,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "dirs 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2067,7 +2067,7 @@ name = "thread_local" version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2085,7 +2085,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2166,7 +2166,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2190,7 +2190,7 @@ dependencies = [ "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2299,7 +2299,7 @@ dependencies = [ "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2322,7 +2322,7 @@ dependencies = [ "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "ipconfig 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "lru-cache 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "resolv-conf 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2431,11 +2431,11 @@ version = "0.2.50" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bumpalo 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-shared 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2467,7 +2467,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-backend 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-shared 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2510,7 +2510,7 @@ dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-backend 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "weedle 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2535,7 +2535,7 @@ dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", "memory_units 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2558,7 +2558,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "winapi" -version = "0.3.7" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2580,7 +2580,7 @@ name = "winapi-util" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2593,7 +2593,7 @@ name = "wincolor" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2602,7 +2602,7 @@ name = "winreg" version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2610,7 +2610,7 @@ name = "winutil" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2641,7 +2641,7 @@ dependencies = [ "checksum actix-rt 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "18d9054b1cfacfa441846b9b99001010cb8fbb02130e6cfdb25cea36d3e98e87" "checksum actix-server 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fb3038e9e457e0a498ea682723e0f4e6cc2c4f362a1868d749808355275ad959" "checksum actix-server-config 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "483a34989c682d93142bacad6300375bb6ad8002d2e0bb249dbad86128b9ff30" -"checksum actix-service 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "aaecc01bbc595ebd7a563a7d4f8a607d0b964bb55273c6f362b0b02c26508cf2" +"checksum actix-service 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bca5b48e928841ff7e7dce1fdb5b0d4582f6b1b976e08f4bac3f640643e0773f" "checksum actix-threadpool 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6b5ae85d13da7e6fb86b1b7bc83185e0e3bd4cc5f421c887e1803796c034d35d" "checksum actix-utils 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6ea501068a0173533704be321f149853f702d9e3c3ce9d57e7a96d94b1ab5aca" "checksum actix-web 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0147b2fd52ced64145c8370af627f12f098222a1c6ba67d021e21cd0d806f574" @@ -2654,7 +2654,7 @@ dependencies = [ "checksum arc-swap 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "854ede29f7a0ce90519fb2439d030320c6201119b87dab0ee96044603e1130b9" "checksum arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0d382e583f07208808f6b1249e60848879ba3543f57c32277bf52d69c2f0f0ee" "checksum arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)" = "b8d73f9beda665eaa98ab9e4f7442bd4e7de6652587de55b2525e52e29c1b0ba" -"checksum ascii 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "91e320562a8fa3286a481b7189f89578ace6b20df99e123c87f2f509c957c5d6" +"checksum ascii 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "eab1c04a571841102f5345a8fc0f6bb3d31c315dec879b5c6e42e40ce7ffa34e" "checksum atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1803c647a3ec87095e7ae7acfca019e98de5ec9a7d01343f611cf3152ed71a90" "checksum autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "b671c8fb71b457dd4ae18c4ba1e59aa81793daacc361d82fcd410cef0d491875" "checksum awc 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "96ff50f02103155c49ced9711b00198f6dacefceb234ece4fcaa4f7ad270e1d5" @@ -2671,7 +2671,7 @@ dependencies = [ "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" "checksum bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" "checksum c2-chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7d64d04786e0f528460fc884753cf8dddcc466be308f6026f8e355c41a0e4101" -"checksum cc 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)" = "b548a4ee81fccb95919d4e22cfea83c7693ebfd78f0495493178db20b3139da7" +"checksum cc 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)" = "8dae9c4b8fedcae85592ba623c4fd08cfdab3e3b72d6df780c6ead964a69bfff" "checksum cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b486ce3ccf7ffd79fdeb678eac06a9e6c09fc88d33836340becb8fffe87c5e33" "checksum chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "77d81f58b7301084de3b958691458a53c3f7e0b1d702f77e550b6a88e3a88abe" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" @@ -2712,7 +2712,7 @@ dependencies = [ "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" "checksum futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "45dc39533a6cae6da2b56da48edae506bb767ec07370f86f70fc062e9d435869" "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" -"checksum getrandom 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "6171a6cc63fbabbe27c2b5ee268e8b7fe5dc1eb0dd2dfad537c1dfed6f69117e" +"checksum getrandom 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "fc344b02d3868feb131e8b5fe2b9b0a1cc42942679af493061fc13b853243872" "checksum h2 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)" = "a5b34c246847f938a410a03c5458c7fee2274436675e76d8b903c08efc29c462" "checksum hashbrown 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "29fba9abe4742d586dfd0c06ae4f7e73a1c2d86b856933509b269d82cdf06e18" "checksum hashbrown 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e1de41fb8dba9714efd92241565cdff73f78508c95697dd56787d3cba27e2353" @@ -2732,7 +2732,7 @@ dependencies = [ "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a91d884b6667cd606bb5a69aa0c99ba811a115fc68915e7056ec08a46e93199a" "checksum lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "76f033c7ad61445c5b347c7382dd1237847eb1bce590fe50365dcb33d546be73" -"checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" +"checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" "checksum libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)" = "34fcd2c08d2f832f376f4173a231990fa5aef4e99fb569867318a227ef4c06ba" "checksum linked-hash-map 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6d262045c5b87c0861b3f004610afd0e2c851e2908d08b6c870cbb9d5f494ecd" "checksum linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ae91b68aebc4ddb91978b11a1b02ddd8602a05ec19002801c5666000e05e0f83" @@ -2842,7 +2842,7 @@ dependencies = [ "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" "checksum string 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d24114bfcceb867ca7f71a0d3fe45d45619ec47a6fbfa98cb14e14250bfa5d6d" "checksum syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)" = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" -"checksum syn 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "158521e6f544e7e3dcfc370ac180794aa38cb34a1b1e07609376d4adcf429b93" +"checksum syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "66850e97125af79138385e9b88339cbcd037e3f28ceab8c5ad98e64f0f1f80bf" "checksum synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f" "checksum take_mut 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f764005d11ee5f36500a149ace24e00e3da98b0158b3e2d53a7495660d3f4d60" "checksum term 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "edd106a334b7657c10b7c540a0106114feadeb4dc314513e97df481d5d966f42" @@ -2894,7 +2894,7 @@ dependencies = [ "checksum weedle 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3bb43f70885151e629e2a19ce9e50bd730fd436cfd4b666894c9ce4de9141164" "checksum widestring 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "effc0e4ff8085673ea7b9b2e3c73f6bd4d118810c9009ed8f1e16bd96c331db6" "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" -"checksum winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f10e386af2b13e47c89e7236a7a14a086791a2b88ebad6df9bf42040195cf770" +"checksum winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" "checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" "checksum winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7168bab6e1daee33b4557efd0e95d5ca70a03706d39fa5f3fe7a236f584b03c9" diff --git a/Cargo.toml b/Cargo.toml index c8fed33c5..12db5d9ed 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "medea" -version = "0.2.0-dev.1" +version = "0.1.0" edition = "2018" description = "Medea media server" authors = ["Instrumentisto Team "] @@ -27,7 +27,6 @@ lto = "thin" actix = "0.8" actix-web = "1.0" actix-web-actors = "1.0" -awc = "0.2" bb8 = "0.3" bb8-redis = "0.3" chrono = "0.4" @@ -64,3 +63,4 @@ actix-http-test = "0.2" serial_test = "0.2" serial_test_derive = "0.2" actix-codec = "0.1.2" +awc = "0.2" diff --git a/Makefile b/Makefile index 87f91cec0..c3630757c 100644 --- a/Makefile +++ b/Makefile @@ -41,7 +41,7 @@ endif # Aliases # ########### -build: docker.build.medea build.medea build.jason +build: build.medea docker.build.medea build.jason # Resolve all project dependencies. @@ -84,17 +84,11 @@ down.demo: docker.down.demo # Run Coturn STUN/TURN server. # -# Defaults: -# logs=no -# # Usage: -# make up.coturn [logs=(yes|no)] +# make up.coturn -up.coturn: +up.coturn: down.coturn docker-compose -f docker-compose.coturn.yml up -d -ifeq ($(logs),yes) - docker-compose -f docker-compose.coturn.yml logs & -endif up.demo: docker.up.demo @@ -105,8 +99,8 @@ up.demo: docker.up.demo # Usage: # make up.dev -up.dev: - $(MAKE) -j3 up.coturn up.jason up.medea +up.dev: up.coturn + $(MAKE) -j2 up.jason up.medea # Run Jason E2E demo in development mode. @@ -118,20 +112,14 @@ up.jason: npm run start --prefix=jason/e2e-demo - # Run Medea media server in development mode. # -# Defaults: -# dockerized=no -# # Usage: -# make up.medea [dockerized=(yes|no)] +# make up.medea 1[dockerized=(NO|yes)] -up.medea: up.coturn +up.medea: down.medea ifeq ($(dockerized),yes) - @make down.medea docker-compose -f docker-compose.medea.yml up - @make down.coturn else cargo run --bin medea endif @@ -153,11 +141,8 @@ down: # Stop Medea media server. # -# Defaults: -# dockerized=no -# # Usage: -# make down.medea [dockerized=(yes|no)] +# make down.medea [dockerized=(NO|yes)] down.medea: ifeq ($(dockerized),yes) @@ -296,10 +281,9 @@ endif # If logs set to "yes" then medea print all logs to stdout. # # Usage: -# make test.e2e [dockerized=(YES|no)] [logs=(yes|NO)] [coturn=(YES|no)] +# make test.e2e [dockerized=(YES|no)] [logs=(yes|NO)] [coturn=(YES|no)] [release=(NO|yes)] medea-env = RUST_BACKTRACE=1 \ - MEDEA_SERVER.BIND_PORT=8081 \ $(if $(call eq,$(logs),yes),,RUST_LOG=warn) \ MEDEA_SERVER.STATIC_SPECS_PATH=tests/specs @@ -310,10 +294,10 @@ endif ifeq ($(dockerized),no) -@make down.medea dockerized=no - cargo build $(if $(call eq,$(release),yes),--release) + make build.medea dockerized=no release=$(release) env $(medea-env) $(if $(call eq,$(logs),yes),,RUST_LOG=warn) cargo run $(if $(call eq,$(release),yes),--release) & - sleep 1 + sleep 5 cargo test --test e2e -@make down @@ -331,8 +315,8 @@ else -u $(shell id -u):$(shell id -g) \ -v "$(HOME)/.cargo/registry":/usr/local/cargo/registry \ -v "$(PWD)/target":/app/target \ - rust:latest \ - make test.e2e dockerized=no coturn=no release=yes + rust:$(RUST_VER) \ + make test.e2e dockerized=no coturn=no release=$(release) -@make down.coturn endif @@ -649,19 +633,19 @@ endef # Build medea. # # Usage: -# make build.medea [dockerized=(no|yes)] +# make build.medea [dockerized=(NO|yes)] [release=(NO|yes)] build.medea: ifneq ($(dockerized),yes) - cargo build --bin medea + cargo build --bin medea $(if $(call eq,$(release),yes),--release) else docker run --rm \ -v "$(PWD)":/app -w /app \ -u $(shell id -u):$(shell id -g) \ -v "$(HOME)/.cargo/registry":/usr/local/cargo/registry \ -v "$(PWD)/target":/app/target \ - rust:latest \ - make build.medea + rust:$(RUST_VER) \ + make build.medea release=$(release) endif @@ -681,7 +665,7 @@ else -v "$(PWD)/target":/app/target \ --env XDG_CACHE_HOME=$(HOME) \ -v "$(HOME):$(HOME)" \ - rust:latest \ + rust:$(RUST_VER) \ sh -c "curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh && make build.jason" endif diff --git a/docker-compose.medea.yml b/docker-compose.medea.yml index 435387df6..07c33bf82 100644 --- a/docker-compose.medea.yml +++ b/docker-compose.medea.yml @@ -6,13 +6,12 @@ services: image: ${COMPOSE_IMAGE_NAME}:${COMPOSE_IMAGE_VER} build: . ports: - - "${MEDEA_SERVER_BIND_PORT}:${MEDEA_SERVER_BIND_PORT}" + - "8080:8080" volumes: - - ./${MEDEA_SERVER_STATIC_SPECS_PATH}:/${MEDEA_SERVER_STATIC_SPECS_PATH} + - ./dev/specs:/specs - ./config.toml:/config.toml network_mode: "host" environment: RUST_LOG: ${RUST_LOG} MEDEA_CONF: "config.toml" - MEDEA_SERVER.BIND_PORT: ${MEDEA_SERVER_BIND_PORT} - MEDEA_SERVER.STATIC_SPECS_PATH: ${MEDEA_SERVER_STATIC_SPECS_PATH} + MEDEA_SERVER.STATIC_SPECS_PATH: /specs diff --git a/jason/Cargo.toml b/jason/Cargo.toml index 2fcdbb0c8..999de5572 100644 --- a/jason/Cargo.toml +++ b/jason/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "medea-jason" -version = "0.2.0-dev.1" +version = "0.1.0" edition = "2018" description = "Client library for Medea media server" authors = ["Instrumentisto Team "] diff --git a/jason/e2e-demo/js/index.js b/jason/e2e-demo/js/index.js index d245aba5d..087a2c81a 100644 --- a/jason/e2e-demo/js/index.js +++ b/jason/e2e-demo/js/index.js @@ -8,10 +8,7 @@ async function f() { let responder_room = await responder.join_room("ws://localhost:8080/ws/pub-pub-video-call/responder/test"); caller_room.on_new_connection(function (connection) { - console.log("caller got new connection with member " + connection.member_id()); connection.on_remote_stream(function (stream) { - console.log("got video from remote member " + connection.member_id()); - var video = document.createElement("video"); video.srcObject = stream.get_media_stream(); @@ -43,9 +40,7 @@ async function f() { } }); responder_room.on_new_connection(function (connection) { - console.log("responder got new connection with member " + connection.member_id()); connection.on_remote_stream(function (stream) { - console.log("got video from remote member " + connection.member_id()); var video = document.createElement("video"); diff --git a/jason/src/api/connection.rs b/jason/src/api/connection.rs index f8c26f79c..44e4d3ec6 100644 --- a/jason/src/api/connection.rs +++ b/jason/src/api/connection.rs @@ -5,7 +5,6 @@ use std::{ rc::{Rc, Weak}, }; -use medea_client_api_proto::PeerId; use wasm_bindgen::prelude::*; use crate::{ @@ -18,7 +17,6 @@ use crate::{ /// Shared between JS side ([`ConnectionHandle`]) and /// Rust side ([`Connection`]). struct InnerConnection { - remote_member: PeerId, on_remote_stream: Callback, } @@ -44,14 +42,6 @@ impl ConnectionHandle { }) .ok_or_else(|| WasmErr::from("Detached state").into()) } - - /// Returns ID of the remote `Member`. - pub fn member_id(&self) -> Result { - self.0 - .upgrade() - .map(|conn| conn.borrow().remote_member.0) - .ok_or_else(|| WasmErr::from("Detached state").into()) - } } /// Connection with a specific remote [`Member`], that is used on Rust side. @@ -62,9 +52,8 @@ pub(crate) struct Connection(Rc>); impl Connection { /// Instantiates new [`Connection`] for a given [`Member`]. #[inline] - pub(crate) fn new(member_id: PeerId) -> Self { + pub(crate) fn new() -> Self { Self(Rc::new(RefCell::new(InnerConnection { - remote_member: member_id, on_remote_stream: Callback::default(), }))) } diff --git a/jason/src/api/room.rs b/jason/src/api/room.rs index 8e3aa6573..9775cc298 100644 --- a/jason/src/api/room.rs +++ b/jason/src/api/room.rs @@ -145,12 +145,14 @@ impl InnerRoom { /// Creates new [`Connection`]s basing on senders and receivers of provided /// [`Track`]s. + // TODO: creates connections based on remote peer_ids atm, should create + // connections based on remote member_ids fn create_connections_from_tracks(&mut self, tracks: &[Track]) { - let create_connection = |room: &mut Self, member_id: &PeerId| { - if !room.connections.contains_key(member_id) { - let con = Connection::new(*member_id); + let create_connection = |room: &mut Self, peer_id: &PeerId| { + if !room.connections.contains_key(peer_id) { + let con = Connection::new(); room.on_new_connection.call1(con.new_handle()); - room.connections.insert(*member_id, con); + room.connections.insert(*peer_id, con); } }; diff --git a/proto/client-api/Cargo.toml b/proto/client-api/Cargo.toml index ec5d7a9ec..96478304d 100644 --- a/proto/client-api/Cargo.toml +++ b/proto/client-api/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "medea-client-api-proto" -version = "0.2.0-dev.1" +version = "0.1.0" edition = "2018" description = "Client API protocol implementation for Medea media server" authors = ["Instrumentisto Team "] diff --git a/proto/client-api/src/lib.rs b/proto/client-api/src/lib.rs index 642bc6cb4..c9029a3e6 100644 --- a/proto/client-api/src/lib.rs +++ b/proto/client-api/src/lib.rs @@ -33,8 +33,6 @@ macro_attr! { #[cfg(feature = "medea")] pub trait Incrementable: Sized + Clone { /// Returns current value + 1. - /// - /// This function don't mutate `self`. fn increment(&self) -> Self; } diff --git a/tests/e2e/signalling/mod.rs b/tests/e2e/signalling/mod.rs index b0d735de2..514b79dab 100644 --- a/tests/e2e/signalling/mod.rs +++ b/tests/e2e/signalling/mod.rs @@ -30,9 +30,12 @@ pub struct TestMember { /// and display all events of this [`TestMember`]). events: Vec, + /// Max test lifetime, will panic when it will be exceeded. + deadline: Option, + /// Function which will be called at every received by this [`TestMember`] /// [`Event`]. - test_fn: Box)>, + on_message: Box)>, } impl TestMember { @@ -40,13 +43,12 @@ impl TestMember { /// Most likely, this ping will never be sent, /// because it has been established that it is sent once per 3 seconds, /// and there are simply no tests that last so much. - fn heartbeat(&self, ctx: &mut Context) { - ctx.run_later(Duration::from_secs(3), |act, ctx| { + fn start_heartbeat(&self, ctx: &mut Context) { + ctx.run_interval(Duration::from_secs(3), |act, _| { act.writer .start_send(WsMessage::Text(r#"{"ping": 1}"#.to_string())) .unwrap(); act.writer.poll_complete().unwrap(); - act.heartbeat(ctx); }); } @@ -58,25 +60,27 @@ impl TestMember { } /// Start test member in new [`Arbiter`] by given URI. - /// `test_fn` - is function which will be called at every [`Event`] + /// `on_message` - is function which will be called at every [`Event`] /// received from server. pub fn start( uri: &str, - test_fn: Box)>, + on_message: Box)>, + deadline: Option, ) { Arbiter::spawn( awc::Client::new() .ws(uri) .connect() .map_err(|e| panic!("Error: {}", e)) - .map(|(_, framed)| { + .map(move |(_, framed)| { let (sink, stream) = framed.split(); - TestMember::create(|ctx| { + TestMember::create(move |ctx| { TestMember::add_stream(stream, ctx); TestMember { writer: sink, events: Vec::new(), - test_fn, + deadline, + on_message, } }); }), @@ -91,14 +95,18 @@ impl Actor for TestMember { /// The timer is needed because some tests may just stuck /// and listen socket forever. fn started(&mut self, ctx: &mut Self::Context) { - self.heartbeat(ctx); - ctx.run_later(Duration::from_secs(5), |act, _ctx| { - panic!( - "This test lasts more than 5 seconds. Most likely, this is \ + self.start_heartbeat(ctx); + + if let Some(deadline) = self.deadline { + ctx.run_later(deadline, |act, _ctx| { + panic!( + "This test lasts more than 5 seconds. Most likely, this is \ not normal. Here is all events of member: {:?}", - act.events - ); - }); + act.events + ); + }); + } + } } @@ -124,7 +132,7 @@ impl Handler for TestMember { impl StreamHandler for TestMember { /// Basic signalling implementation. - /// A `TestMember::test_fn` [`FnMut`] function will be called for each + /// A `TestMember::on_message` [`FnMut`] function will be called for each /// [`Event`] received from test server. fn handle(&mut self, msg: Frame, ctx: &mut Context) { if let Frame::Text(txt) = msg { @@ -133,7 +141,7 @@ impl StreamHandler for TestMember { if let Ok(event) = event { self.events.push(event.clone()); // Test function call - (self.test_fn)(&event, ctx); + (self.on_message)(&event, ctx); if let Event::PeerCreated { peer_id, diff --git a/tests/e2e/signalling/pub_sub_signallng.rs b/tests/e2e/signalling/pub_sub_signallng.rs index 48598d8b9..a473db28d 100644 --- a/tests/e2e/signalling/pub_sub_signallng.rs +++ b/tests/e2e/signalling/pub_sub_signallng.rs @@ -6,7 +6,7 @@ use crate::signalling::TestMember; #[test] fn pub_sub_video_call() { System::run(|| { - let base_url = "ws://0.0.0.0:8081/ws/pub-sub-video-call"; + let base_url = "ws://0.0.0.0:8080/ws/pub-sub-video-call"; // Note that events is separated by members. // Every member will have different instance of this. @@ -91,13 +91,16 @@ fn pub_sub_video_call() { } }; + let deadline = Some(std::time::Duration::from_secs(5)); TestMember::start( &format!("{}/caller/test", base_url), Box::new(test_fn.clone()), + deadline ); TestMember::start( &format!("{}/responder/test", base_url), Box::new(test_fn), + deadline ); }) .unwrap(); diff --git a/tests/e2e/signalling/three_pubs.rs b/tests/e2e/signalling/three_pubs.rs index cdaab2639..303b54dc9 100644 --- a/tests/e2e/signalling/three_pubs.rs +++ b/tests/e2e/signalling/three_pubs.rs @@ -8,7 +8,7 @@ use crate::signalling::{CloseSocket, TestMember}; #[test] fn three_members_p2p_video_call() { System::run(|| { - let base_url = "ws://0.0.0.0:8081/ws/three-members-conference"; + let base_url = "ws://0.0.0.0:8080/ws/three-members-conference"; // Note that events, peer_created_count, ice_candidates // is separated by members. @@ -120,17 +120,21 @@ fn three_members_p2p_video_call() { } }; + let deadline = Some(std::time::Duration::from_secs(5)); TestMember::start( &format!("{}/member-1/test", base_url), Box::new(test_fn.clone()), + deadline ); TestMember::start( &format!("{}/member-2/test", base_url), Box::new(test_fn.clone()), + deadline ); TestMember::start( &format!("{}/member-3/test", base_url), Box::new(test_fn), + deadline ); }) .unwrap(); From fdd16ee4526acc683e4c83c6578726a01bd22ff6 Mon Sep 17 00:00:00 2001 From: alexlapa Date: Wed, 28 Aug 2019 13:36:26 +0300 Subject: [PATCH 515/735] fmt, changelog [run ci] --- jason/CHANGELOG.md | 4 +--- tests/e2e/signalling/mod.rs | 5 ++--- tests/e2e/signalling/pub_sub_signallng.rs | 4 ++-- tests/e2e/signalling/three_pubs.rs | 6 +++--- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/jason/CHANGELOG.md b/jason/CHANGELOG.md index 214174a47..72f2c717b 100644 --- a/jason/CHANGELOG.md +++ b/jason/CHANGELOG.md @@ -1,4 +1,4 @@ -`medea-jason` changelog +1 ======================= All user visible changes to this project will be documented in this file. This project uses [Semantic Versioning 2.0.0]. @@ -13,8 +13,6 @@ All user visible changes to this project will be documented in this file. This p ### Changed -- Use track ID and peer ID from `medea-client-api-proto` ([#28](/../../pull/28)) - diff --git a/tests/e2e/signalling/mod.rs b/tests/e2e/signalling/mod.rs index 514b79dab..22eda9b4d 100644 --- a/tests/e2e/signalling/mod.rs +++ b/tests/e2e/signalling/mod.rs @@ -100,13 +100,12 @@ impl Actor for TestMember { if let Some(deadline) = self.deadline { ctx.run_later(deadline, |act, _ctx| { panic!( - "This test lasts more than 5 seconds. Most likely, this is \ - not normal. Here is all events of member: {:?}", + "This test lasts more than 5 seconds. Most likely, this \ + is not normal. Here is all events of member: {:?}", act.events ); }); } - } } diff --git a/tests/e2e/signalling/pub_sub_signallng.rs b/tests/e2e/signalling/pub_sub_signallng.rs index a473db28d..1b3f430f7 100644 --- a/tests/e2e/signalling/pub_sub_signallng.rs +++ b/tests/e2e/signalling/pub_sub_signallng.rs @@ -95,12 +95,12 @@ fn pub_sub_video_call() { TestMember::start( &format!("{}/caller/test", base_url), Box::new(test_fn.clone()), - deadline + deadline, ); TestMember::start( &format!("{}/responder/test", base_url), Box::new(test_fn), - deadline + deadline, ); }) .unwrap(); diff --git a/tests/e2e/signalling/three_pubs.rs b/tests/e2e/signalling/three_pubs.rs index 303b54dc9..3e6e845bd 100644 --- a/tests/e2e/signalling/three_pubs.rs +++ b/tests/e2e/signalling/three_pubs.rs @@ -124,17 +124,17 @@ fn three_members_p2p_video_call() { TestMember::start( &format!("{}/member-1/test", base_url), Box::new(test_fn.clone()), - deadline + deadline, ); TestMember::start( &format!("{}/member-2/test", base_url), Box::new(test_fn.clone()), - deadline + deadline, ); TestMember::start( &format!("{}/member-3/test", base_url), Box::new(test_fn), - deadline + deadline, ); }) .unwrap(); From deefbdcb9ef15aadb7af5cd66ea8598e1086870d Mon Sep 17 00:00:00 2001 From: alexlapa Date: Wed, 28 Aug 2019 13:54:37 +0300 Subject: [PATCH 516/735] asd --- .env | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env b/.env index 96d451168..29364142b 100644 --- a/.env +++ b/.env @@ -3,4 +3,4 @@ MEDEA_CONF=config.toml COMPOSE_PROJECT_NAME=medea COMPOSE_IMAGE_NAME=instrumentisto/medea -COMPOSE_IMAGE_VER=0.0.1-dev +COMPOSE_IMAGE_VER=dev From bc5049bb7580965971ea6923cdd2a7dcae6e2349 Mon Sep 17 00:00:00 2001 From: alexlapa Date: Thu, 29 Aug 2019 12:18:18 +0300 Subject: [PATCH 517/735] refactor [run ci] --- .env | 2 ++ .travis.yml | 4 +-- Makefile | 56 ++++++++++++++++++---------------------- docker-compose.medea.yml | 2 +- 4 files changed, 30 insertions(+), 34 deletions(-) diff --git a/.env b/.env index 29364142b..0a394414f 100644 --- a/.env +++ b/.env @@ -4,3 +4,5 @@ MEDEA_CONF=config.toml COMPOSE_PROJECT_NAME=medea COMPOSE_IMAGE_NAME=instrumentisto/medea COMPOSE_IMAGE_VER=dev + +MEDEA_SERVER_STATIC_SPECS_PATH=./dev/specs diff --git a/.travis.yml b/.travis.yml index d1b95047f..71c96bc75 100644 --- a/.travis.yml +++ b/.travis.yml @@ -36,7 +36,7 @@ jobs: - name: medea (stable) stage: build rust: stable - script: make build.medea + script: make docker.build.medea debug=no TAG=${TRAVIS_JOB_ID} - name: medea (beta) stage: build @@ -56,7 +56,7 @@ jobs: - name: e2e signalling (stable) stage: test rust: stable - script: make test.e2e release=yes + script: make test.e2e dockerized=yes TAG=${TRAVIS_JOB_ID} - name: crates.io stage: release diff --git a/Makefile b/Makefile index c3630757c..1a26d2d1c 100644 --- a/Makefile +++ b/Makefile @@ -112,15 +112,28 @@ up.jason: npm run start --prefix=jason/e2e-demo -# Run Medea media server in development mode. +# Run Medea media server. # # Usage: -# make up.medea 1[dockerized=(NO|yes)] +# make up.medea [dockerized=(NO|yes)] [background=(NO|yes) +# [log=(NO|yes)]] [TAG=(dev|)] -up.medea: down.medea +docker-up-tag = $(if $(call eq,$(TAG),),dev,$(TAG)) + +up.medea: ifeq ($(dockerized),yes) - docker-compose -f docker-compose.medea.yml up + @make down.medea dockerized=yes + COMPOSE_IMAGE_NAME=$(MEDEA_IMAGE_NAME) \ + COMPOSE_IMAGE_VER=$(docker-up-tag) \ + docker-compose -f docker-compose.medea.yml up \ + $(if $(call eq,$(background),yes),-d,--abort-on-container-exit) +ifeq ($(background),yes) +ifeq ($(log),yes) + docker-compose -f docker-compose.medea.yml logs -f +endif +endif else + @make down.medea dockerized=no cargo run --bin medea endif @@ -281,45 +294,26 @@ endif # If logs set to "yes" then medea print all logs to stdout. # # Usage: -# make test.e2e [dockerized=(YES|no)] [logs=(yes|NO)] [coturn=(YES|no)] [release=(NO|yes)] +# make test.e2e [dockerized=(YES|no)] [logs=(yes|NO)] +# [release=(NO|yes)] [TAG=(dev|)] medea-env = RUST_BACKTRACE=1 \ $(if $(call eq,$(logs),yes),,RUST_LOG=warn) \ - MEDEA_SERVER.STATIC_SPECS_PATH=tests/specs + MEDEA_SERVER_STATIC_SPECS_PATH=./tests/specs test.e2e: + -@make down ifneq ($(coturn),no) @make up.coturn endif ifeq ($(dockerized),no) - -@make down.medea dockerized=no - - make build.medea dockerized=no release=$(release) env $(medea-env) $(if $(call eq,$(logs),yes),,RUST_LOG=warn) cargo run $(if $(call eq,$(release),yes),--release) & - - sleep 5 - cargo test --test e2e - - -@make down -ifneq ($(coturn),no) - -@make down.coturn -endif - -@exit $(.SHELLSTATUS) else - -@make down.medea dockerized=yes - -@make down.medea dockerized=no - - @make up.coturn - - docker run --rm --network=host -v "$(PWD)":/app -w /app \ - -u $(shell id -u):$(shell id -g) \ - -v "$(HOME)/.cargo/registry":/usr/local/cargo/registry \ - -v "$(PWD)/target":/app/target \ - rust:$(RUST_VER) \ - make test.e2e dockerized=no coturn=no release=$(release) - - -@make down.coturn + $(medea-env) make up.medea dockerized=yes background=yes logs=$(logs) TAG=$(TAG) endif + sleep 15 + RUST_BACKTRACE=1 cargo test --test e2e + -@make down diff --git a/docker-compose.medea.yml b/docker-compose.medea.yml index 07c33bf82..72d2dbac2 100644 --- a/docker-compose.medea.yml +++ b/docker-compose.medea.yml @@ -8,7 +8,7 @@ services: ports: - "8080:8080" volumes: - - ./dev/specs:/specs + - ${MEDEA_SERVER_STATIC_SPECS_PATH}:/specs - ./config.toml:/config.toml network_mode: "host" environment: From 17629c0f46ae4170d5727e3ee648e233006d63f7 Mon Sep 17 00:00:00 2001 From: alexlapa Date: Fri, 30 Aug 2019 10:44:53 +0300 Subject: [PATCH 518/735] refactor [run ci] --- .travis.yml | 4 +- Cargo.lock | 96 ++++----------------- Cargo.toml | 1 + Makefile | 9 +- src/api/control/endpoint.rs | 135 ++++++++++++++++------------- src/api/control/member.rs | 2 +- src/lib.rs | 139 +++++++++++++++++++----------- src/main.rs | 58 +------------ src/media/track.rs | 4 +- src/signalling/elements/member.rs | 8 +- src/signalling/participants.rs | 23 +++-- src/signalling/peers.rs | 4 +- src/signalling/room.rs | 8 +- src/turn/mod.rs | 3 +- src/turn/service.rs | 18 ++-- 15 files changed, 218 insertions(+), 294 deletions(-) diff --git a/.travis.yml b/.travis.yml index 71c96bc75..cb21c38da 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,7 +33,7 @@ jobs: script: - make release.npm crate=medea-jason publish=no - - name: medea (stable) + - name: medea docker (stable) stage: build rust: stable script: make docker.build.medea debug=no TAG=${TRAVIS_JOB_ID} @@ -56,7 +56,7 @@ jobs: - name: e2e signalling (stable) stage: test rust: stable - script: make test.e2e dockerized=yes TAG=${TRAVIS_JOB_ID} + script: make test.e2e dockerized=yes logs=yes TAG=${TRAVIS_JOB_ID} - name: crates.io stage: release diff --git a/Cargo.lock b/Cargo.lock index d44cf9976..9630ff150 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -237,7 +237,7 @@ dependencies = [ [[package]] name = "actix-web" -version = "1.0.5" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -263,9 +263,9 @@ dependencies = [ "regex 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_urlencoded 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_urlencoded 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", - "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "url 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -276,7 +276,7 @@ dependencies = [ "actix 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)", "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "actix-http 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-web 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-web 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -684,63 +684,6 @@ name = "either" version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "encoding" -version = "0.2.33" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "encoding-index-japanese 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)", - "encoding-index-korean 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)", - "encoding-index-simpchinese 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)", - "encoding-index-singlebyte 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)", - "encoding-index-tradchinese 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "encoding-index-japanese" -version = "1.20141219.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "encoding_index_tests 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "encoding-index-korean" -version = "1.20141219.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "encoding_index_tests 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "encoding-index-simpchinese" -version = "1.20141219.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "encoding_index_tests 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "encoding-index-singlebyte" -version = "1.20141219.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "encoding_index_tests 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "encoding-index-tradchinese" -version = "1.20141219.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "encoding_index_tests 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "encoding_index_tests" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "encoding_rs" version = "0.8.17" @@ -1082,7 +1025,7 @@ dependencies = [ "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "actix-http 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", "actix-http-test 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-web 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-web 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", "actix-web-actors 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "awc 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "bb8 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1116,6 +1059,7 @@ dependencies = [ "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-signal 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", + "url 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1493,7 +1437,7 @@ dependencies = [ "getrandom 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1512,7 +1456,7 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "c2-chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1530,7 +1474,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "rand_core" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "getrandom 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1549,7 +1493,7 @@ name = "rand_hc" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2107,7 +2051,7 @@ dependencies = [ "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-threadpool 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-udp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-udp 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-uds 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2244,7 +2188,7 @@ dependencies = [ [[package]] name = "tokio-udp" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2309,7 +2253,7 @@ dependencies = [ "tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-udp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-udp 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2383,7 +2327,6 @@ name = "url" version = "1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "encoding 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2644,7 +2587,7 @@ dependencies = [ "checksum actix-service 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bca5b48e928841ff7e7dce1fdb5b0d4582f6b1b976e08f4bac3f640643e0773f" "checksum actix-threadpool 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6b5ae85d13da7e6fb86b1b7bc83185e0e3bd4cc5f421c887e1803796c034d35d" "checksum actix-utils 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6ea501068a0173533704be321f149853f702d9e3c3ce9d57e7a96d94b1ab5aca" -"checksum actix-web 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0147b2fd52ced64145c8370af627f12f098222a1c6ba67d021e21cd0d806f574" +"checksum actix-web 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "8ced216f53d465f9d6478454b2b994d1fe91ec203ac9d056837cbe07e823cb83" "checksum actix-web-actors 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "008c1b686048a16fef4ef2fc6b6e5fcf5f29829891ad87fc0848ade26b285627" "checksum actix-web-codegen 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3fe9e3cdec1e645b675f354766e0688c5705021c85ab3cf739be1c8999b91c76" "checksum actix_derive 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0bf5f6d7bf2d220ae8b4a7ae02a572bb35b7c4806b24049af905ab8110de156c" @@ -2693,13 +2636,6 @@ dependencies = [ "checksum dotenv 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4424bad868b0ffe6ae351ee463526ba625bbca817978293bbe6bb7dc1804a175" "checksum dtoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "ea57b42383d091c85abcc2706240b94ab2a8fa1fc81c10ff23c4de06e2a90b5e" "checksum either 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5527cfe0d098f36e3f8839852688e63c8fff1c90b2b405aef730615f9a7bcf7b" -"checksum encoding 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "6b0d943856b990d12d3b55b359144ff341533e516d94098b1d3fc1ac666d36ec" -"checksum encoding-index-japanese 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)" = "04e8b2ff42e9a05335dbf8b5c6f7567e5591d0d916ccef4e0b1710d32a0d0c91" -"checksum encoding-index-korean 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)" = "4dc33fb8e6bcba213fe2f14275f0963fd16f0a02c878e3095ecfdf5bee529d81" -"checksum encoding-index-simpchinese 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d87a7194909b9118fc707194baa434a4e3b0fb6a5a757c73c3adb07aa25031f7" -"checksum encoding-index-singlebyte 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3351d5acffb224af9ca265f435b859c7c01537c0849754d3db3fdf2bfe2ae84a" -"checksum encoding-index-tradchinese 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fd0e20d5688ce3cab59eb3ef3a2083a5c77bf496cb798dc6fcdb75f323890c18" -"checksum encoding_index_tests 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "a246d82be1c9d791c5dfde9a2bd045fc3cbba3fa2b11ad558f27d01712f00569" "checksum encoding_rs 0.8.17 (registry+https://github.com/rust-lang/crates.io-index)" = "4155785c79f2f6701f185eb2e6b4caf0555ec03477cb4c70db67b465311620ed" "checksum enum-as-inner 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3d58266c97445680766be408285e798d3401c6d4c378ec5552e78737e681e37d" "checksum env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "aafcde04e90a5226a6443b7aabdb016ba2f8307c847d524724bd9b346dd1a2d3" @@ -2784,7 +2720,7 @@ dependencies = [ "checksum rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "03a2a90da8c7523f554344f921aa97283eadf6ac484a6d2a7d0212fa7f8d6853" "checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" "checksum rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" -"checksum rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "615e683324e75af5d43d8f7a39ffe3ee4a9dc42c5c701167a71dc59c3a493aca" +"checksum rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" "checksum rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" "checksum rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" "checksum rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" @@ -2862,7 +2798,7 @@ dependencies = [ "checksum tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1d14b10654be682ac43efee27401d792507e30fd8d26389e1da3b185de2e4119" "checksum tokio-threadpool 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "90ca01319dea1e376a001e8dc192d42ebde6dd532532a5bad988ac37db365b19" "checksum tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "f2106812d500ed25a4f38235b9cae8f78a09edf43203e16e59c3b769a342a60e" -"checksum tokio-udp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "66268575b80f4a4a710ef83d087fdfeeabdce9b74c797535fbac18a2cb906e92" +"checksum tokio-udp 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "56775b287cda0fd8ca0c5d2f5b1d0646afbd360101e2eef91cd89365fcfc2f5f" "checksum tokio-uds 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "037ffc3ba0e12a0ab4aca92e5234e0dedeb48fddf6ccd260f1f150a36a9f2445" "checksum toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "758664fc71a3a69038656bee8b6be6477d2a6c315a6b81f7081f591bffa4111f" "checksum toml 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c7aabe75941d914b72bf3e5d3932ed92ce0664d49d8432305a8b547c37227724" diff --git a/Cargo.toml b/Cargo.toml index 12db5d9ed..233b8c9dd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -56,6 +56,7 @@ smart-default = "0.5" tokio = "0.1" tokio-signal = "0.2" toml = "0.5" +url = "2.1" [dev-dependencies] actix-http = "0.2" diff --git a/Makefile b/Makefile index 1a26d2d1c..882baa940 100644 --- a/Makefile +++ b/Makefile @@ -116,7 +116,7 @@ up.jason: # # Usage: # make up.medea [dockerized=(NO|yes)] [background=(NO|yes) -# [log=(NO|yes)]] [TAG=(dev|)] +# [logs=(NO|yes)]] [TAG=(dev|)] docker-up-tag = $(if $(call eq,$(TAG),),dev,$(TAG)) @@ -128,7 +128,7 @@ ifeq ($(dockerized),yes) docker-compose -f docker-compose.medea.yml up \ $(if $(call eq,$(background),yes),-d,--abort-on-container-exit) ifeq ($(background),yes) -ifeq ($(log),yes) +ifeq ($(logs),yes) docker-compose -f docker-compose.medea.yml logs -f endif endif @@ -299,6 +299,7 @@ endif medea-env = RUST_BACKTRACE=1 \ $(if $(call eq,$(logs),yes),,RUST_LOG=warn) \ + MEDEA_SERVER.STATIC_SPECS_PATH=./tests/specs \ MEDEA_SERVER_STATIC_SPECS_PATH=./tests/specs test.e2e: @@ -309,9 +310,9 @@ endif ifeq ($(dockerized),no) env $(medea-env) $(if $(call eq,$(logs),yes),,RUST_LOG=warn) cargo run $(if $(call eq,$(release),yes),--release) & else - $(medea-env) make up.medea dockerized=yes background=yes logs=$(logs) TAG=$(TAG) + env $(medea-env) make up.medea dockerized=yes background=yes logs=$(logs) TAG=$(TAG) & endif - sleep 15 + sleep 5 RUST_BACKTRACE=1 cargo test --test e2e -@make down diff --git a/src/api/control/endpoint.rs b/src/api/control/endpoint.rs index a9b7f1190..2cc718769 100644 --- a/src/api/control/endpoint.rs +++ b/src/api/control/endpoint.rs @@ -1,11 +1,12 @@ //! Control API specification Endpoint definitions. -use std::{convert::TryFrom, fmt}; +use std::{convert::TryFrom, fmt, str::FromStr}; use serde::{ - de::{self, Deserializer, Error, Unexpected, Visitor}, + de::{self, Deserializer, Error, Visitor}, Deserialize, }; +use url::Url; use crate::api::control::MemberId; @@ -19,6 +20,22 @@ pub enum Endpoint { WebRtcPlay(WebRtcPlayEndpoint), } +#[derive(Clone, Debug)] +pub enum Scheme { + Local, +} + +impl FromStr for Scheme { + type Err = String; + + fn from_str(s: &str) -> Result { + match s { + "local" => Ok(Scheme::Local), + _ => Err(format!("cannot parse \"{}\" to Scheme", s)), + } + } +} + impl TryFrom<&MemberElement> for Endpoint { type Error = TryFromElementError; @@ -61,6 +78,7 @@ pub struct WebRtcPlayEndpoint { /// Special uri with pattern `local://{room_id}/{member_id}/{endpoint_id}`. #[derive(Clone, Debug)] pub struct SrcUri { + pub scheme: Scheme, /// ID of [`Room`] /// /// [`Room`]: crate::signalling::room::Room @@ -93,62 +111,63 @@ impl<'de> Deserialize<'de> for SrcUri { where E: de::Error, { - let protocol_name: String = value.chars().take(8).collect(); - if protocol_name != "local://" { - return Err(Error::invalid_value( - Unexpected::Str(&format!( - "{} in {}", - protocol_name, value - )), - &self, - )); - } - - let uri_body = value.chars().skip(8).collect::(); - let mut uri_body_splitted: Vec<&str> = - uri_body.rsplit('/').collect(); - let uri_body_splitted_len = uri_body_splitted.len(); - if uri_body_splitted_len != 3 { - let error_msg = if uri_body_splitted_len == 0 { - "room_id, member_id, endpoint_id" - } else if uri_body_splitted_len == 1 { - "member_id, endpoint_id" - } else if uri_body_splitted_len == 2 { - "endpoint_id" - } else { + let uri = Url::parse(value).map_err(|_| { + Error::custom(format!("'{}' is not URL", value)) + })?; + + let scheme = match FromStr::from_str(uri.scheme()) { + Ok(scheme) => scheme, + Err(_) => { + return Err(Error::custom(format!( + "cannot parse uri scheme \"{}\"", + value + ))) + } + }; + let room_id = match uri.host() { + Some(host) => host.to_string(), + None => { return Err(Error::custom(format!( - "Too many fields: {}. Expecting 3 fields, found \ - {}.", - uri_body, uri_body_splitted_len - ))); - }; - return Err(Error::missing_field(error_msg)); - } - let room_id = uri_body_splitted.pop().unwrap().to_string(); - if room_id.is_empty() { - return Err(Error::custom(format!( - "room_id in {} is empty!", - value - ))); - } - let member_id = uri_body_splitted.pop().unwrap().to_string(); - if member_id.is_empty() { - return Err(Error::custom(format!( - "member_id in {} is empty!", - value - ))); - } - let endpoint_id = uri_body_splitted.pop().unwrap().to_string(); - if endpoint_id.is_empty() { - return Err(Error::custom(format!( - "endpoint_id in {} is empty!", - value - ))); - } + "cannot parse uri scheme \"{}\"", + value + ))) + } + }; + + let mut path = match uri.path_segments() { + Some(path) => path, + None => { + return Err(Error::custom(format!( + "cannot parse uri segments \"{}\"", + value + ))) + } + }; + + let member_id = match path.next() { + Some(member_id) => MemberId(member_id.to_owned()), + None => { + return Err(Error::custom(format!( + "cannot parse member_id \"{}\"", + value + ))) + } + }; + + let endpoint_id = match path.next() { + Some(endpoint_id) => endpoint_id.to_owned(), + None => { + return Err(Error::custom(format!( + "cannot parse endpoint_id \"{}\"", + value + ))) + } + }; Ok(SrcUri { + scheme, room_id, - member_id: MemberId(member_id), + member_id, endpoint_id, }) } @@ -200,12 +219,4 @@ mod src_uri_deserialization_tests { unreachable!() } } - - #[test] - fn return_error_when_uri_have_empty_part() { - let invalid_json_uri = r#"{ "src": "local://room_id//endpoint_id" }"#; - if serde_json::from_str::(invalid_json_uri).is_ok() { - unreachable!() - } - } } diff --git a/src/api/control/member.rs b/src/api/control/member.rs index fcbcc465f..d66c31c55 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -70,7 +70,7 @@ impl MemberSpec { }) } - pub fn get_publish_endpoint( + pub fn get_publish_endpoint_by_id( &self, id: &str, ) -> Option<&WebRtcPublishEndpoint> { diff --git a/src/lib.rs b/src/lib.rs index 582722b37..df3360a8e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -13,17 +13,21 @@ pub mod turn; use std::sync::Arc; use actix::prelude::*; -use failure::Fail; +use failure::{Error, Fail}; +use futures::future::{Either, Future, IntoFuture as _}; use std::collections::HashMap; use crate::{ - api::control::{load_static_specs_from_dir, RoomId}, + api::{ + client::server::Server, + control::{load_static_specs_from_dir, RoomId}, + }, conf::Conf, + log::prelude::*, shutdown::GracefulShutdown, - signalling::{room::RoomError, Room}, + signalling::{room::RoomError, room_repo::RoomsRepository, Room}, turn::{service, TurnServiceErr}, }; -use futures::future::Either; /// Errors which can happen while server starting. #[derive(Debug, Fail)] @@ -54,6 +58,53 @@ impl From for ServerStartError { } } +pub fn run() -> Result<(), Error> { + dotenv::dotenv().ok(); + let logger = log::new_dual_logger(std::io::stdout(), std::io::stderr()); + let _scope_guard = slog_scope::set_global_logger(logger); + slog_stdlog::init()?; + + let config = Conf::parse()?; + info!("{:?}", config); + + actix::run(|| { + start_static_rooms(&config) + .map_err(|e| error!("Turn: {:?}", e)) + .map(Result::unwrap) + .map(move |(res, graceful_shutdown)| { + (res, graceful_shutdown, config) + }) + .map(|(res, graceful_shutdown, config)| { + let rooms = res; + info!( + "Loaded rooms: {:?}", + rooms.iter().map(|(id, _)| &id.0).collect::>() + ); + let room_repo = RoomsRepository::new(rooms); + + (room_repo, graceful_shutdown, config) + }) + .and_then(|(room_repo, graceful_shutdown, config)| { + Server::run(room_repo, config) + .map_err(|e| error!("Error starting server: {:?}", e)) + .map(|server| { + graceful_shutdown + .send(shutdown::Subscribe(shutdown::Subscriber { + addr: server.recipient(), + priority: shutdown::Priority(1), + })) + .map_err(|e| error!("Shutdown sub: {}", e)) + .map(|_| ()) + }) + .into_future() + .flatten() + }) + }) + .unwrap(); + + Ok(()) +} + /// Parses static [`Room`]s from config and starts them in separate arbiters. /// /// Returns [`ServerStartError::DuplicateRoomId`] if find duplicated room ID. @@ -63,9 +114,7 @@ impl From for ServerStartError { /// /// Returns [`ServerStartError::BadRoomSpec`] /// if some error happened while creating room from spec. -// This is not the most beautiful solution, but at the moment let it be. In the -// 32-grpc-dynamic-control-api branch, this logic is changed and everything will -// look better. +// TODO: temporary solution, changed in 32-grpc-dynamic-control-api branch pub fn start_static_rooms( conf: &Conf, ) -> impl Future< @@ -79,52 +128,42 @@ pub fn start_static_rooms( GracefulShutdown::new(conf.shutdown.timeout).start(); let config = conf.clone(); if let Some(static_specs_path) = config.server.static_specs_path.clone() { - Either::A( - service::new_turn_auth_service(&config.turn) - .map(Arc::new) - .map(move |turn_auth_service| { - let room_specs = - match load_static_specs_from_dir(static_specs_path) { - Ok(r) => r, - Err(e) => { - return Err(ServerStartError::LoadSpec(e)) - } - }; - let mut rooms = HashMap::new(); - let arbiter = Arbiter::new(); - - for spec in room_specs { - if rooms.contains_key(spec.id()) { - return Err(ServerStartError::DuplicateRoomId( - spec.id().clone(), - )); - } - - let room_id = spec.id().clone(); - let rpc_reconnect_timeout = - config.rpc.reconnect_timeout; - let turn_cloned = Arc::clone(&turn_auth_service); - let room = - Room::start_in_arbiter(&arbiter, move |_| { - Room::new( - &spec, - rpc_reconnect_timeout, - turn_cloned, - ) - .unwrap() - }); - graceful_shutdown.do_send(shutdown::Subscribe( - shutdown::Subscriber { - addr: room.clone().recipient(), - priority: shutdown::Priority(2), - }, + Either::A(service::new_turn_auth_service(&config.turn).map( + move |turn_auth_service| { + let room_specs = + match load_static_specs_from_dir(static_specs_path) { + Ok(r) => r, + Err(e) => return Err(ServerStartError::LoadSpec(e)), + }; + let mut rooms = HashMap::new(); + let arbiter = Arbiter::new(); + + for spec in room_specs { + if rooms.contains_key(spec.id()) { + return Err(ServerStartError::DuplicateRoomId( + spec.id().clone(), )); - rooms.insert(room_id, room); } - Ok((rooms, graceful_shutdown)) - }), - ) + let room_id = spec.id().clone(); + let rpc_reconnect_timeout = config.rpc.reconnect_timeout; + let turn_cloned = Arc::clone(&turn_auth_service); + let room = Room::start_in_arbiter(&arbiter, move |_| { + Room::new(&spec, rpc_reconnect_timeout, turn_cloned) + .unwrap() + }); + graceful_shutdown.do_send(shutdown::Subscribe( + shutdown::Subscriber { + addr: room.clone().recipient(), + priority: shutdown::Priority(2), + }, + )); + rooms.insert(room_id, room); + } + + Ok((rooms, graceful_shutdown)) + }, + )) } else { Either::B(futures::future::ok(Ok((HashMap::new(), graceful_shutdown)))) } diff --git a/src/main.rs b/src/main.rs index b48d6a812..54e22b3d4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,57 +1,3 @@ -use failure::Error; -use futures::future::{Future, IntoFuture as _}; -use medea::{ - api::client::server::Server, - conf::Conf, - log::{self, prelude::*}, - shutdown, - signalling::room_repo::RoomsRepository, - start_static_rooms, -}; - -fn main() -> Result<(), Error> { - dotenv::dotenv().ok(); - let logger = log::new_dual_logger(std::io::stdout(), std::io::stderr()); - let _scope_guard = slog_scope::set_global_logger(logger); - slog_stdlog::init()?; - - let config = Conf::parse()?; - info!("{:?}", config); - - actix::run(|| { - start_static_rooms(&config) - .map_err(|e| error!("Turn: {:?}", e)) - .map(Result::unwrap) - .map(move |(res, graceful_shutdown)| { - (res, graceful_shutdown, config) - }) - .map(|(res, graceful_shutdown, config)| { - let rooms = res; - info!( - "Loaded rooms: {:?}", - rooms.iter().map(|(id, _)| &id.0).collect::>() - ); - let room_repo = RoomsRepository::new(rooms); - - (room_repo, graceful_shutdown, config) - }) - .and_then(|(room_repo, graceful_shutdown, config)| { - Server::run(room_repo, config) - .map_err(|e| error!("Error starting server: {:?}", e)) - .map(|server| { - graceful_shutdown - .send(shutdown::Subscribe(shutdown::Subscriber { - addr: server.recipient(), - priority: shutdown::Priority(1), - })) - .map_err(|e| error!("Shutdown sub: {}", e)) - .map(|_| ()) - }) - .into_future() - .flatten() - }) - }) - .unwrap(); - - Ok(()) +fn main() -> Result<(), failure::Error> { + medea::run() } diff --git a/src/media/track.rs b/src/media/track.rs index 30f990192..41c26181b 100644 --- a/src/media/track.rs +++ b/src/media/track.rs @@ -4,9 +4,7 @@ use std::cell::RefCell; -use medea_client_api_proto::MediaType; - -use medea_client_api_proto::TrackId as Id; +use medea_client_api_proto::{MediaType, TrackId as Id}; /// Representation of [MediaStreamTrack][1] object. /// diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index 522c0e4fb..89ef33c9b 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -1,7 +1,6 @@ -//! [`Member`] is member of [`Room`] with [`RpcConnection`]. +//! [`Member`] is member of [`Room`]. //! //! [`Room`]: crate::signalling::room::Room -//! [`RpcConnection`]: crate::api::client::rpc_connection::RpcConnection use std::{ cell::RefCell, @@ -47,10 +46,9 @@ impl From for MembersLoadError { } } -/// [`Member`] is member of [`Room`] with [`RpcConnection`]. +/// [`Member`] is member of [`Room`]. /// /// [`Room`]: crate::signalling::room::Room -/// [`RpcConnection`]: crate::api::client::rpc_connection::RpcConnection #[derive(Clone, Debug)] pub struct Member(Rc>); @@ -126,7 +124,7 @@ impl Member { )?; let publisher_endpoint = publisher_spec - .get_publish_endpoint(&spec_play_endpoint.src.endpoint_id) + .get_publish_endpoint_by_id(&spec_play_endpoint.src.endpoint_id) .map_or( Err(MembersLoadError::EndpointNotFound( spec_play_endpoint.src.endpoint_id.clone(), diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index bc845a721..43501a459 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -40,7 +40,7 @@ use crate::{ room::{ActFuture, RoomError}, Room, }, - turn::{BoxedTurnAuthService, TurnServiceErr, UnreachablePolicy}, + turn::{TurnAuthService, TurnServiceErr, UnreachablePolicy}, }; #[derive(Fail, Debug)] @@ -81,7 +81,7 @@ pub struct ParticipantService { members: HashMap, /// Service for managing authorization on Turn server. - turn: Arc, + turn: Arc, /// Established [`RpcConnection`]s of [`Member`]s in this [`Room`]. /// @@ -105,7 +105,7 @@ impl ParticipantService { pub fn new( room_spec: &RoomSpec, reconnect_timeout: Duration, - turn: Arc, + turn: Arc, ) -> Result { Ok(Self { room_id: room_spec.id().clone(), @@ -118,8 +118,8 @@ impl ParticipantService { } /// Lookup [`Member`] by provided id. - pub fn get_member_by_id(&self, id: &MemberId) -> Option { - self.members.get(id).cloned() + pub fn get_member_by_id(&self, id: &MemberId) -> Option<&Member> { + self.members.get(id) } /// Lookup [`Member`] by provided id and credentials. Returns @@ -131,11 +131,11 @@ impl ParticipantService { &self, member_id: &MemberId, credentials: &str, - ) -> Result { + ) -> Result<&Member, AuthorizationError> { match self.get_member_by_id(member_id) { Some(member) => { if member.credentials().eq(credentials) { - Ok(member.clone()) + Ok(member) } else { Err(AuthorizationError::InvalidCredentials) } @@ -182,12 +182,12 @@ impl ParticipantService { ParticipantServiceErr::ParticipantNotFound(member_id), ))); } - Some(member) => member, + Some(member) => member.clone(), }; // lookup previous member connection if let Some(mut connection) = self.connections.remove(&member_id) { - debug!("Closing old RpcConnection for participant {}", member_id); + debug!("Closing old RpcConnection for participant {}", &member_id); // cancel RpcConnection close task, since connection is // reestablished @@ -208,7 +208,7 @@ impl ParticipantService { }) .and_then( move |ice: IceUser, room: &mut Room, _| { - room.members.insert_connection(member_id.clone(), con); + room.members.insert_connection(member_id, con); member.replace_ice_user(ice); wrap_future(future::ok(member)) @@ -242,7 +242,6 @@ impl ParticipantService { ClosedReason::Closed => { debug!("Connection for member [id = {}] removed.", member_id); self.connections.remove(&member_id); - ctx.spawn(wrap_future( self.delete_ice_user(&member_id).map_err(|err| { error!("Error deleting IceUser {:?}", err) @@ -308,7 +307,7 @@ impl ParticipantService { let remove_ice_users = Box::new({ let mut room_users = Vec::with_capacity(self.members.len()); - self.members.iter().for_each(|(_, data)| { + self.members.values().for_each(|data| { if let Some(ice_user) = data.take_ice_user() { room_users.push(ice_user); } diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index e9bd33a8f..7c27151e8 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -70,7 +70,7 @@ impl PeerRepository { } /// Returns borrowed [`PeerStateMachine`] by its ID. - pub fn get_peer( + pub fn get_peer_by_id( &self, peer_id: PeerId, ) -> Result<&PeerStateMachine, RoomError> { @@ -137,7 +137,7 @@ impl PeerRepository { } /// Returns borrowed [`Peer`] by its ID. - pub fn get_inner_peer<'a, S>( + pub fn get_inner_peer_by_id<'a, S>( &'a self, peer_id: PeerId, ) -> Result<&'a Peer, RoomError> diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 17f0cc46e..2835278af 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -36,7 +36,7 @@ use crate::{ participants::ParticipantService, peers::PeerRepository, }, - turn::BoxedTurnAuthService, + turn::TurnAuthService, }; /// Ergonomic type alias for using [`ActorFuture`] for [`Room`]. @@ -120,7 +120,7 @@ impl Room { pub fn new( room_spec: &RoomSpec, reconnect_timeout: Duration, - turn: Arc, + turn: Arc, ) -> Result { Ok(Self { id: room_spec.id().clone(), @@ -285,7 +285,7 @@ impl Room { from_peer_id: PeerId, candidate: IceCandidate, ) -> Result, RoomError> { - let from_peer = self.peers.get_peer(from_peer_id)?; + let from_peer = self.peers.get_peer_by_id(from_peer_id)?; if let PeerStateMachine::New(_) = from_peer { return Err(PeerError::WrongState( from_peer_id, @@ -296,7 +296,7 @@ impl Room { } let to_peer_id = from_peer.partner_peer_id(); - let to_peer = self.peers.get_peer(to_peer_id)?; + let to_peer = self.peers.get_peer_by_id(to_peer_id)?; if let PeerStateMachine::New(_) = to_peer { return Err(PeerError::WrongState( to_peer_id, diff --git a/src/turn/mod.rs b/src/turn/mod.rs index 37a586107..2200d2a6e 100644 --- a/src/turn/mod.rs +++ b/src/turn/mod.rs @@ -7,8 +7,7 @@ pub mod service; #[doc(inline)] pub use self::service::{ - new_turn_auth_service, BoxedTurnAuthService, TurnAuthService, - TurnServiceErr, UnreachablePolicy, + new_turn_auth_service, TurnAuthService, TurnServiceErr, UnreachablePolicy, }; #[cfg(test)] diff --git a/src/turn/service.rs b/src/turn/service.rs index 6710ae7a9..41ee1e091 100644 --- a/src/turn/service.rs +++ b/src/turn/service.rs @@ -3,7 +3,7 @@ //! [coturn]: https://github.com/coturn/coturn //! [TURN]: https://webrtcglossary.com/turn/ -use std::fmt; +use std::{fmt, sync::Arc}; use actix::{ fut::wrap_future, Actor, ActorFuture, Addr, Context, Handler, MailboxError, @@ -22,15 +22,11 @@ use crate::{ turn::repo::{TurnDatabase, TurnDatabaseErr}, }; -/// Boxed [`TurnAuthService`] which can be [`Sync`] and [`Send`]. -#[allow(clippy::module_name_repetitions)] -pub type BoxedTurnAuthService = Box; - static TURN_PASS_LEN: usize = 16; #[allow(clippy::module_name_repetitions)] /// Manages Turn server credentials. -pub trait TurnAuthService: fmt::Debug + Send { +pub trait TurnAuthService: fmt::Debug + Send + Sync { /// Generates and registers Turn credentials. fn create( &self, @@ -161,9 +157,9 @@ struct Service { /// Create new instance [`TurnAuthService`]. #[allow(clippy::module_name_repetitions)] -pub fn new_turn_auth_service( +pub fn new_turn_auth_service<'a>( cf: &conf::Turn, -) -> impl Future { +) -> impl Future, Error = TurnServiceErr> { let db_pass = cf.db.redis.pass.clone(); let turn_address = cf.addr(); let turn_username = cf.user.clone(); @@ -191,7 +187,7 @@ pub fn new_turn_auth_service( turn_password, static_user: None, }) - .map::<_, BoxedTurnAuthService>(|service| Box::new(service.start())) + .map::<_, Arc>(|service| Arc::new(service.start())) .map_err(TurnServiceErr::from) } @@ -325,7 +321,7 @@ pub mod test { } #[allow(clippy::module_name_repetitions)] - pub fn new_turn_auth_service_mock() -> Arc { - Arc::new(Box::new(TurnAuthServiceMock {})) + pub fn new_turn_auth_service_mock() -> Arc { + Arc::new(TurnAuthServiceMock {}) } } From 4ea9fc8776b347ddd40709987cf8b657ef443f31 Mon Sep 17 00:00:00 2001 From: alexlapa Date: Fri, 30 Aug 2019 12:17:09 +0300 Subject: [PATCH 519/735] meh, so i should docker save && load? [run ci] --- docker-compose.medea.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/docker-compose.medea.yml b/docker-compose.medea.yml index 72d2dbac2..cd9c501d3 100644 --- a/docker-compose.medea.yml +++ b/docker-compose.medea.yml @@ -4,7 +4,6 @@ services: medea: container_name: ${COMPOSE_PROJECT_NAME}-backend image: ${COMPOSE_IMAGE_NAME}:${COMPOSE_IMAGE_VER} - build: . ports: - "8080:8080" volumes: From c107c62ec3c45bff0a1a7ec94c99437b38a505c8 Mon Sep 17 00:00:00 2001 From: alexlapa Date: Fri, 30 Aug 2019 12:24:43 +0300 Subject: [PATCH 520/735] meh, so i should docker save && load? [run ci] --- .travis.yml | 76 ++++++++++++++++++++++++++--------------------------- Makefile | 33 +++++++++++++++++++++++ 2 files changed, 71 insertions(+), 38 deletions(-) diff --git a/.travis.yml b/.travis.yml index cb21c38da..4536452df 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,47 +11,47 @@ jobs: stage: build include: - - name: Clippy - stage: check - rust: stable - before_script: rustup component add clippy - script: make lint - - - name: rustfmt - stage: check - rust: nightly - cache: false - before_script: rustup component add rustfmt - script: make fmt check=yes - - - name: medea-jason (stable) - stage: build - rust: stable - before_script: - - rm -f /home/travis/.cargo/bin/wasm-pack - - curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh - script: - - make release.npm crate=medea-jason publish=no - - - name: medea docker (stable) - stage: build - rust: stable - script: make docker.build.medea debug=no TAG=${TRAVIS_JOB_ID} +# - name: Clippy +# stage: check +# rust: stable +# before_script: rustup component add clippy +# script: make lint - - name: medea (beta) - stage: build - rust: beta - script: make build.medea +# - name: rustfmt +# stage: check +# rust: nightly +# cache: false +# before_script: rustup component add rustfmt +# script: make fmt check=yes - - name: medea (nightly) - stage: build - rust: nightly - script: make build.medea +# - name: medea-jason (stable) +# stage: build +# rust: stable +# before_script: +# - rm -f /home/travis/.cargo/bin/wasm-pack +# - curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh +# script: +# - make release.npm crate=medea-jason publish=no - - name: unit (stable) - stage: test - rust: stable - script: make test.unit crate=@all +# - name: medea docker (stable) +# stage: build +# rust: stable +# script: make docker.build.medea debug=no TAG=${TRAVIS_JOB_ID} +# +# - name: medea (beta) +# stage: build +# rust: beta +# script: make build.medea +# +# - name: medea (nightly) +# stage: build +# rust: nightly +# script: make build.medea +# +# - name: unit (stable) +# stage: test +# rust: stable +# script: make test.unit crate=@all - name: e2e signalling (stable) stage: test diff --git a/Makefile b/Makefile index 882baa940..8649350c6 100644 --- a/Makefile +++ b/Makefile @@ -443,6 +443,39 @@ docker.up.demo: docker.down.demo docker-compose -f jason/demo/docker-compose.yml up +# Save project Docker images in a tarball file. +# +# Usage: +# make docker.tar [IMAGE=(|)] +# [TAGS=(dev|[,...])] + +docker-tar-image-name = $(IMAGE_NAME)$(if $(call eq,$(IMAGE),),,/$(IMAGE)) +docker-tar-dir = .cache/docker/$(docker-tar-image-name) +docker-tar-tags = $(if $(call eq,$(TAGS),),dev,$(TAGS)) + +docker.tar: + @mkdir -p $(docker-tar-dir)/ + docker save \ + -o $(docker-tar-dir)/$(subst $(comma),_,$(docker-tar-tags)).tar \ + $(foreach tag,$(subst $(comma), ,$(docker-tar-tags)),\ + $(docker-tar-image-name):$(tag)) + + +# Load project Docker images from a tarball file. +# +# Usage: +# make docker.untar [IMAGE=(|)] +# [TAGS=(dev|[,...])] + +docker-untar-image-name = $(IMAGE_NAME)$(if $(call eq,$(IMAGE),),,/$(IMAGE)) +docker-untar-dir = .cache/docker/$(docker-untar-image-name) +docker-untar-tags = $(if $(call eq,$(TAGS),),dev,$(TAGS)) + +docker.untar: + docker load \ + -i $(docker-untar-dir)/$(subst $(comma),_,$(docker-untar-tags)).tar + + ############################## From b47bbeac1012f10c7aa00f223ab35c531bba1b0a Mon Sep 17 00:00:00 2001 From: alexlapa Date: Fri, 30 Aug 2019 12:25:56 +0300 Subject: [PATCH 521/735] oops [run ci] --- .travis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4536452df..4c8043097 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,10 +33,10 @@ jobs: # script: # - make release.npm crate=medea-jason publish=no -# - name: medea docker (stable) -# stage: build -# rust: stable -# script: make docker.build.medea debug=no TAG=${TRAVIS_JOB_ID} + - name: medea docker (stable) + stage: build + rust: stable + script: make docker.build.medea debug=no TAG=${TRAVIS_JOB_ID} # # - name: medea (beta) # stage: build From a42403df418a857b96bc122668d67b71951f0a71 Mon Sep 17 00:00:00 2001 From: alexlapa Date: Fri, 30 Aug 2019 13:03:45 +0300 Subject: [PATCH 522/735] add docker save and docker load [run ci] --- .travis.yml | 7 ++++++- Makefile | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4c8043097..5de4649bd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,8 @@ language: rust -cache: cargo +cache: + cargo: true + directories: + - .cache/docker/ install: - rustc -vV @@ -37,6 +40,7 @@ jobs: stage: build rust: stable script: make docker.build.medea debug=no TAG=${TRAVIS_JOB_ID} + after_script: make docker.tar TAGS=${TRAVIS_JOB_ID} # # - name: medea (beta) # stage: build @@ -56,6 +60,7 @@ jobs: - name: e2e signalling (stable) stage: test rust: stable + before_script: make docker.untar TAGS=${TRAVIS_JOB_ID} script: make test.e2e dockerized=yes logs=yes TAG=${TRAVIS_JOB_ID} - name: crates.io diff --git a/Makefile b/Makefile index 8649350c6..0cf777a92 100644 --- a/Makefile +++ b/Makefile @@ -449,7 +449,7 @@ docker.up.demo: docker.down.demo # make docker.tar [IMAGE=(|)] # [TAGS=(dev|[,...])] -docker-tar-image-name = $(IMAGE_NAME)$(if $(call eq,$(IMAGE),),,/$(IMAGE)) +docker-tar-image-name = $(MEDEA_IMAGE_NAME)$(if $(call eq,$(IMAGE),),,/$(IMAGE)) docker-tar-dir = .cache/docker/$(docker-tar-image-name) docker-tar-tags = $(if $(call eq,$(TAGS),),dev,$(TAGS)) @@ -467,7 +467,7 @@ docker.tar: # make docker.untar [IMAGE=(|)] # [TAGS=(dev|[,...])] -docker-untar-image-name = $(IMAGE_NAME)$(if $(call eq,$(IMAGE),),,/$(IMAGE)) +docker-untar-image-name = $(MEDEA_IMAGE_NAME)$(if $(call eq,$(IMAGE),),,/$(IMAGE)) docker-untar-dir = .cache/docker/$(docker-untar-image-name) docker-untar-tags = $(if $(call eq,$(TAGS),),dev,$(TAGS)) From 8bb9acfb918c6bde6cf94dc518e0c5500c2e74a2 Mon Sep 17 00:00:00 2001 From: alexlapa Date: Fri, 30 Aug 2019 13:36:03 +0300 Subject: [PATCH 523/735] add docker save and docker load [run ci] --- .travis.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5de4649bd..b06ebc643 100644 --- a/.travis.yml +++ b/.travis.yml @@ -39,8 +39,10 @@ jobs: - name: medea docker (stable) stage: build rust: stable - script: make docker.build.medea debug=no TAG=${TRAVIS_JOB_ID} - after_script: make docker.tar TAGS=${TRAVIS_JOB_ID} + script: + - make docker.build.medea debug=no TAG=${TRAVIS_JOB_ID} + - make docker.tar TAGS=${TRAVIS_JOB_ID} + - ls .cache # # - name: medea (beta) # stage: build From 892a27ec11f412f4dfd85ce75972cc26007f0c0a Mon Sep 17 00:00:00 2001 From: alexlapa Date: Fri, 30 Aug 2019 13:43:06 +0300 Subject: [PATCH 524/735] use build id [run ci] --- .travis.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index b06ebc643..a78d1daf3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -39,10 +39,8 @@ jobs: - name: medea docker (stable) stage: build rust: stable - script: - - make docker.build.medea debug=no TAG=${TRAVIS_JOB_ID} - - make docker.tar TAGS=${TRAVIS_JOB_ID} - - ls .cache + script: make docker.build.medea debug=no TAG=${TRAVIS_BUILD_ID} + after_script: make docker.tar TAGS=${TRAVIS_BUILD_ID} # # - name: medea (beta) # stage: build @@ -62,8 +60,8 @@ jobs: - name: e2e signalling (stable) stage: test rust: stable - before_script: make docker.untar TAGS=${TRAVIS_JOB_ID} - script: make test.e2e dockerized=yes logs=yes TAG=${TRAVIS_JOB_ID} + before_script: make docker.untar TAGS=${TRAVIS_BUILD_ID} + script: make test.e2e dockerized=yes logs=yes TAG=${TRAVIS_BUILD_ID} - name: crates.io stage: release From b4b81ab97e8d92169933ede9eb9ff0ed76cae858 Mon Sep 17 00:00:00 2001 From: alexlapa Date: Fri, 30 Aug 2019 14:40:27 +0300 Subject: [PATCH 525/735] debug ci [run ci] --- .travis.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index a78d1daf3..57e9d47b4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -39,8 +39,10 @@ jobs: - name: medea docker (stable) stage: build rust: stable - script: make docker.build.medea debug=no TAG=${TRAVIS_BUILD_ID} - after_script: make docker.tar TAGS=${TRAVIS_BUILD_ID} + script: + - make docker.build.medea debug=no TAG=${TRAVIS_BUILD_ID} + - make docker.tar TAGS=${TRAVIS_BUILD_ID} + - ls .cache/docker/ # # - name: medea (beta) # stage: build @@ -60,8 +62,10 @@ jobs: - name: e2e signalling (stable) stage: test rust: stable - before_script: make docker.untar TAGS=${TRAVIS_BUILD_ID} - script: make test.e2e dockerized=yes logs=yes TAG=${TRAVIS_BUILD_ID} + script: + - ls .cache/ + - make docker.untar TAGS=${TRAVIS_BUILD_ID} + - make test.e2e dockerized=yes logs=yes TAG=${TRAVIS_BUILD_ID} - name: crates.io stage: release From 6f65dcc061059c7ffbbeed8a9359fdda72adb043 Mon Sep 17 00:00:00 2001 From: alexlapa Date: Fri, 30 Aug 2019 15:17:16 +0300 Subject: [PATCH 526/735] travis [run ci] --- .travis.yml | 70 ++++++++++++++++++++++++++--------------------------- 1 file changed, 34 insertions(+), 36 deletions(-) diff --git a/.travis.yml b/.travis.yml index 57e9d47b4..e598b0063 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,27 +14,27 @@ jobs: stage: build include: -# - name: Clippy -# stage: check -# rust: stable -# before_script: rustup component add clippy -# script: make lint + - name: Clippy + stage: check + rust: stable + before_script: rustup component add clippy + script: make lint -# - name: rustfmt -# stage: check -# rust: nightly -# cache: false -# before_script: rustup component add rustfmt -# script: make fmt check=yes + - name: rustfmt + stage: check + rust: nightly + cache: false + before_script: rustup component add rustfmt + script: make fmt check=yes -# - name: medea-jason (stable) -# stage: build -# rust: stable -# before_script: -# - rm -f /home/travis/.cargo/bin/wasm-pack -# - curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh -# script: -# - make release.npm crate=medea-jason publish=no + - name: medea-jason (stable) + stage: build + rust: stable + before_script: + - rm -f /home/travis/.cargo/bin/wasm-pack + - curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh + script: + - make release.npm crate=medea-jason publish=no - name: medea docker (stable) stage: build @@ -42,28 +42,26 @@ jobs: script: - make docker.build.medea debug=no TAG=${TRAVIS_BUILD_ID} - make docker.tar TAGS=${TRAVIS_BUILD_ID} - - ls .cache/docker/ -# -# - name: medea (beta) -# stage: build -# rust: beta -# script: make build.medea -# -# - name: medea (nightly) -# stage: build -# rust: nightly -# script: make build.medea -# -# - name: unit (stable) -# stage: test -# rust: stable -# script: make test.unit crate=@all + + - name: medea (beta) + stage: build + rust: beta + script: make build.medea + + - name: medea (nightly) + stage: build + rust: nightly + script: make build.medea + + - name: unit (stable) + stage: test + rust: stable + script: make test.unit crate=@all - name: e2e signalling (stable) stage: test rust: stable script: - - ls .cache/ - make docker.untar TAGS=${TRAVIS_BUILD_ID} - make test.e2e dockerized=yes logs=yes TAG=${TRAVIS_BUILD_ID} From 7e44c1db6118c3687b788a2eab757829c1e149cc Mon Sep 17 00:00:00 2001 From: alexlapa Date: Fri, 30 Aug 2019 16:24:17 +0300 Subject: [PATCH 527/735] you kidding me [run ci] --- .travis.yml | 72 +++++++++++++++++++++++++++-------------------------- 1 file changed, 37 insertions(+), 35 deletions(-) diff --git a/.travis.yml b/.travis.yml index e598b0063..f62b36c04 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,27 +14,27 @@ jobs: stage: build include: - - name: Clippy - stage: check - rust: stable - before_script: rustup component add clippy - script: make lint - - - name: rustfmt - stage: check - rust: nightly - cache: false - before_script: rustup component add rustfmt - script: make fmt check=yes - - - name: medea-jason (stable) - stage: build - rust: stable - before_script: - - rm -f /home/travis/.cargo/bin/wasm-pack - - curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh - script: - - make release.npm crate=medea-jason publish=no +# - name: Clippy +# stage: check +# rust: stable +# before_script: rustup component add clippy +# script: make lint +# +# - name: rustfmt +# stage: check +# rust: nightly +# cache: false +# before_script: rustup component add rustfmt +# script: make fmt check=yes +# +# - name: medea-jason (stable) +# stage: build +# rust: stable +# before_script: +# - rm -f /home/travis/.cargo/bin/wasm-pack +# - curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh +# script: +# - make release.npm crate=medea-jason publish=no - name: medea docker (stable) stage: build @@ -42,26 +42,28 @@ jobs: script: - make docker.build.medea debug=no TAG=${TRAVIS_BUILD_ID} - make docker.tar TAGS=${TRAVIS_BUILD_ID} + - ls .cache/docker/ - - name: medea (beta) - stage: build - rust: beta - script: make build.medea - - - name: medea (nightly) - stage: build - rust: nightly - script: make build.medea - - - name: unit (stable) - stage: test - rust: stable - script: make test.unit crate=@all +# - name: medea (beta) +# stage: build +# rust: beta +# script: make build.medea +# +# - name: medea (nightly) +# stage: build +# rust: nightly +# script: make build.medea +# +# - name: unit (stable) +# stage: test +# rust: stable +# script: make test.unit crate=@all - name: e2e signalling (stable) stage: test rust: stable script: + - ls .cache/ - make docker.untar TAGS=${TRAVIS_BUILD_ID} - make test.e2e dockerized=yes logs=yes TAG=${TRAVIS_BUILD_ID} From cf5383bd1a9cda9dcb857d9d4d195942432bdaeb Mon Sep 17 00:00:00 2001 From: alexlapa Date: Fri, 30 Aug 2019 17:19:01 +0300 Subject: [PATCH 528/735] you kidding me [run ci] --- .travis.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index f62b36c04..d00a8c436 100644 --- a/.travis.yml +++ b/.travis.yml @@ -44,15 +44,15 @@ jobs: - make docker.tar TAGS=${TRAVIS_BUILD_ID} - ls .cache/docker/ -# - name: medea (beta) -# stage: build -# rust: beta -# script: make build.medea -# -# - name: medea (nightly) -# stage: build -# rust: nightly -# script: make build.medea + - name: medea (beta) + stage: build + rust: beta + script: make build.medea + + - name: medea (nightly) + stage: build + rust: nightly + script: make build.medea # # - name: unit (stable) # stage: test From bae48500e5234a19a22a6a37269e70a53d1688ea Mon Sep 17 00:00:00 2001 From: alexlapa Date: Fri, 30 Aug 2019 17:58:13 +0300 Subject: [PATCH 529/735] you kidding me [run ci] --- .travis.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index d00a8c436..bffd13589 100644 --- a/.travis.yml +++ b/.travis.yml @@ -53,11 +53,11 @@ jobs: stage: build rust: nightly script: make build.medea -# -# - name: unit (stable) -# stage: test -# rust: stable -# script: make test.unit crate=@all + + - name: unit (stable) + stage: test + rust: stable + script: make test.unit crate=@all - name: e2e signalling (stable) stage: test From b604d4d749ed6d6d3fe15949d3edb6d057a99ada Mon Sep 17 00:00:00 2001 From: alexlapa Date: Fri, 30 Aug 2019 20:19:47 +0300 Subject: [PATCH 530/735] try login [run ci] --- .travis.yml | 57 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 25 deletions(-) diff --git a/.travis.yml b/.travis.yml index bffd13589..ea3e40768 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,10 @@ language: rust + +env: + global: + - secure: MLoB6bB/z1Ff6SWldgnS+o8iI7+ShuYlcPlcOrErdIc4dirRVLOhZNc+oDP4auhF5IsjTLMjRzre98I6kI2EYCHqx1HPEhiFPnA+d+tLl3l3Hgwqi2jTd1LcSnn62X9qazQNGUyhwB/itMQyswUBE7XEegNpFWYFOyvvI6JwoADwBMEA6Um9FnW2/NdkKTZvAqTjJ8o6axHLo58LGLekmUj2Fc+z5cbzbK/9CrXGvXihLs0ZGRQnKRtxknfFPKVam/aTPR5sFaAjJ5El9VjnCLJnX/uwt9rNjdK3DRwHf7Qeo3Gj867HhLi2ba4KRvhoZJcq4BEoXBZzOJWchqasPc2veOoiZOg5AUQNnjWPQ2dun3o9OaLySp3qhzQ8yxIS+9U1JLsd3pLhb2gBQNAwK92pzUS+WhwhwAv6QkODvROVJeG55N23u2a8Enk7SHR9KFFCaDqzor7vcmAtk8q7JkVwxXX6/yS43hNk9teF1Cox8kG26lYbQLA1/XXu8Z1+F0aXv5WpC9cHjWEPef87lHedB4gCs9erNJEF2gUCOpWWt/J9DCE6U9OizHuosDrqFfZQH+A3Y6c8Mh2TcLnc7BadqFUMvRwAV8bOzaBjfAVH+aGARyDbWfK8NtFtkw/lfoVLZ2nx4rPfo2oVOholRpProoj09vJe1QdruX+Sdew= + - secure: tXgsViat9MxuqPcPqjbnQPAVw5iQGFi5M64IvYQqDSYCc3EbBaQe+I1NMcNcHM6XZ4VzINa5xnaeh8AJC2BOcmDnNt4Af+YyCZDuz7lQsE7kvKqGSCaKnNGr23P/FTVz64wLFIFbhnClL8Q+VHLkpzsxY6utjdhGfQfsIK0kdAQ2lHuXDbqQC0GA7fiz7hD41GblsnNQLaSPoMtpFYMN8ta5pyLIlTzrZ/QjOWFV7VC46A/AlPnkzRWuGYrayep622oFFQ365uiDoSzZBFu0+nHkdVuJxN05HYfSw/m1/XLoK8Ytu0Qm12D7I9H71lkX7IEjZwr/L+WIuJQCPU8mzB+Qh3TUE2mOMVA0DMwIJ572aJQqAFi1shXsyFn5MfMptOwILUHDBYFj9RJVA/pJUeND4DlQMLjldzYbEGv8Y2jL3hW7jrb9PRlXIhlYS0UR8rwAGdWRbNKezq3Ve2Z0tyIvOYgIDAs47Yj9VHLgthLiRJ5e/ptKt7rM4grqpiQnKo01Ss60XVA6Vab2h2gvIX2GK0N4TR6Kjy0cfHbBGrsO9J7dCKXosU6/rc61AfFj+Lb/CayZ0+FKRznNNJU+Sb2uylQHksgvvCHdsg8a60rfLPLm93G01CHIEMS1Sqw9xAE5wxbMSCZeV4ZCj5A8j45R09ISrt0UodbYhQPrPfY= + cache: cargo: true directories: @@ -40,32 +46,33 @@ jobs: stage: build rust: stable script: - - make docker.build.medea debug=no TAG=${TRAVIS_BUILD_ID} - - make docker.tar TAGS=${TRAVIS_BUILD_ID} - - ls .cache/docker/ - - - name: medea (beta) - stage: build - rust: beta - script: make build.medea - - - name: medea (nightly) - stage: build - rust: nightly - script: make build.medea - - - name: unit (stable) - stage: test - rust: stable - script: make test.unit crate=@all +# - make docker.build.medea debug=no TAG=${TRAVIS_BUILD_ID} + - docker login -u="$QUAIO_PASS" -p="$QUAIO_USER" +# - make docker.tar TAGS=${TRAVIS_BUILD_ID} +# - ls .cache/docker/ - - name: e2e signalling (stable) - stage: test - rust: stable - script: - - ls .cache/ - - make docker.untar TAGS=${TRAVIS_BUILD_ID} - - make test.e2e dockerized=yes logs=yes TAG=${TRAVIS_BUILD_ID} +# - name: medea (beta) +# stage: build +# rust: beta +# script: make build.medea +# +# - name: medea (nightly) +# stage: build +# rust: nightly +# script: make build.medea +# +# - name: unit (stable) +# stage: test +# rust: stable +# script: make test.unit crate=@all +# +# - name: e2e signalling (stable) +# stage: test +# rust: stable +# script: +# - ls .cache/ +# - make docker.untar TAGS=${TRAVIS_BUILD_ID} +# - make test.e2e dockerized=yes logs=yes TAG=${TRAVIS_BUILD_ID} - name: crates.io stage: release From 7de14d661f208ab849dffdb216ed2db609d22fdd Mon Sep 17 00:00:00 2001 From: alexlapa Date: Fri, 30 Aug 2019 20:41:53 +0300 Subject: [PATCH 531/735] try login [run ci] --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ea3e40768..c8213dd6f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -47,7 +47,7 @@ jobs: rust: stable script: # - make docker.build.medea debug=no TAG=${TRAVIS_BUILD_ID} - - docker login -u="$QUAIO_PASS" -p="$QUAIO_USER" + - docker login -u="$QUAYIO_USER" -p="$QUAYIO_PASS" # - make docker.tar TAGS=${TRAVIS_BUILD_ID} # - ls .cache/docker/ From 1d438874f3b463395d09063cface8f52d0b5696a Mon Sep 17 00:00:00 2001 From: alexlapa Date: Fri, 30 Aug 2019 21:08:48 +0300 Subject: [PATCH 532/735] try login [run ci] --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index c8213dd6f..26e0153e7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,8 +2,8 @@ language: rust env: global: - - secure: MLoB6bB/z1Ff6SWldgnS+o8iI7+ShuYlcPlcOrErdIc4dirRVLOhZNc+oDP4auhF5IsjTLMjRzre98I6kI2EYCHqx1HPEhiFPnA+d+tLl3l3Hgwqi2jTd1LcSnn62X9qazQNGUyhwB/itMQyswUBE7XEegNpFWYFOyvvI6JwoADwBMEA6Um9FnW2/NdkKTZvAqTjJ8o6axHLo58LGLekmUj2Fc+z5cbzbK/9CrXGvXihLs0ZGRQnKRtxknfFPKVam/aTPR5sFaAjJ5El9VjnCLJnX/uwt9rNjdK3DRwHf7Qeo3Gj867HhLi2ba4KRvhoZJcq4BEoXBZzOJWchqasPc2veOoiZOg5AUQNnjWPQ2dun3o9OaLySp3qhzQ8yxIS+9U1JLsd3pLhb2gBQNAwK92pzUS+WhwhwAv6QkODvROVJeG55N23u2a8Enk7SHR9KFFCaDqzor7vcmAtk8q7JkVwxXX6/yS43hNk9teF1Cox8kG26lYbQLA1/XXu8Z1+F0aXv5WpC9cHjWEPef87lHedB4gCs9erNJEF2gUCOpWWt/J9DCE6U9OizHuosDrqFfZQH+A3Y6c8Mh2TcLnc7BadqFUMvRwAV8bOzaBjfAVH+aGARyDbWfK8NtFtkw/lfoVLZ2nx4rPfo2oVOholRpProoj09vJe1QdruX+Sdew= - - secure: tXgsViat9MxuqPcPqjbnQPAVw5iQGFi5M64IvYQqDSYCc3EbBaQe+I1NMcNcHM6XZ4VzINa5xnaeh8AJC2BOcmDnNt4Af+YyCZDuz7lQsE7kvKqGSCaKnNGr23P/FTVz64wLFIFbhnClL8Q+VHLkpzsxY6utjdhGfQfsIK0kdAQ2lHuXDbqQC0GA7fiz7hD41GblsnNQLaSPoMtpFYMN8ta5pyLIlTzrZ/QjOWFV7VC46A/AlPnkzRWuGYrayep622oFFQ365uiDoSzZBFu0+nHkdVuJxN05HYfSw/m1/XLoK8Ytu0Qm12D7I9H71lkX7IEjZwr/L+WIuJQCPU8mzB+Qh3TUE2mOMVA0DMwIJ572aJQqAFi1shXsyFn5MfMptOwILUHDBYFj9RJVA/pJUeND4DlQMLjldzYbEGv8Y2jL3hW7jrb9PRlXIhlYS0UR8rwAGdWRbNKezq3Ve2Z0tyIvOYgIDAs47Yj9VHLgthLiRJ5e/ptKt7rM4grqpiQnKo01Ss60XVA6Vab2h2gvIX2GK0N4TR6Kjy0cfHbBGrsO9J7dCKXosU6/rc61AfFj+Lb/CayZ0+FKRznNNJU+Sb2uylQHksgvvCHdsg8a60rfLPLm93G01CHIEMS1Sqw9xAE5wxbMSCZeV4ZCj5A8j45R09ISrt0UodbYhQPrPfY= + - secure: O14lnD45q3oyuMtKU7Jfy1e+LSs91UZPnNuTPT9IZNoHPgJM77mdK1bwu5SqSXpmDEaq3uQBBhIKEKxiOgogiRAGcALnjSLIe02qrw8kR4hhB7IsuCsfJA3rgnH5NrSxV2ja5wHUkTtYORIB30GX/SU4qNw8C+HeAcXDaxPRNJYuIkE41jW121PDgheS7Ti49ui5JOKss/FdpI8Ii5xXvNf9Z60MSJKPsM8yaj+RiqDccXrFuyppVE/Ezn95gdJh1Sr7BUaP521FOhOYl4bvMEV0pHHMwaPD0b2Ku0yJ+GrZiZ2YqTmsNiaa4hN2AAv38w46KfhQuvJg173cEGf6hCrrF+IOQvmGG977xSO7tci2l5idjIZ1xtXsLQ9Yp49DBxd1s2I20j+fHmCImH1cV4+hEnMTQLITzemS3MkHIxbEgcMyssjZD7FASNU1C3fbeeHEG3JPM/hHj0mlGlhv7T54gL5Q7Qggnj+xsE44yU18bP0K/G48QBLeXDSfZzeaCbrif9bALAVnUMhRMSuW9EfOHcu7juaBAj5mPxWfN4CoQgqBFPh+V+q6+WViV0/5djoKlrOy323hNTg+CXIqWn9RYIbxbyRMGXIU6Z78Sr6Yls+8tK1cpdXOzQ6CMeUJh2H264hFMM1ZGvlQ+VYqRYMCViuVW4Aofuqr1zfsnz0= + - secure: xm+WIGYVoYvjAlWOaoli0YZ4LMFBKd7pG0qno4zrDMGrz1AwLRK6dce0+ROvIdEcuOror2j4wryYgDRMLYgxzhXeMMVFkxZuB1MmeC8VHirf0jNHNNihWwnEyTDGtj5VXijD/ipo4jiskBZEsg/oW97iFUudjl/rNT2R0Gy420QgGV4p3m9jTjBBL6giIQUNK0g+5aIkCfb4U/4gcpFA5nZJgyfQtnKKmVnEPl26vbU+Ui7F/wqTK0a7AJT3RCaEddtu7E5DKNnk4/45e4//LKNEE8I2KGqWlqWXqFYs+Cno1trDOcKm0yiTIquvbZsrOuH7wN1il4qVcsdgQLps2kFahpJyQJbJJViBkbqnlwRJDnxtszbrxSGW6HiVMSSd8AOthwJd3n7lMkBDwrwG9Dx7MiNY/NIdRxufEuoOw/6tj31oBJhM1s+/Fhjzlz0j5R5spTtcaNg6Q0Gi+F283jjwvobIzvUUKKSt4I1UZLTQNSzxrWTJZ4kJBG1JiTxH7BwHMtxhiaZn5ajk5HfVXScmBknZIovsylj5UXp1d5IhXUNq4jTXTdybOurhQ1XLVz/hw64oOIQkuftaNHuQMe3oB69aWLWpS6+r3k1ZCT/WODbS3xlhp/MXO3WLD4WY1OWJ522t/YOUQX3j72bZADlQOcU/OWQ5LWNC3XGibrk= cache: cargo: true @@ -47,7 +47,7 @@ jobs: rust: stable script: # - make docker.build.medea debug=no TAG=${TRAVIS_BUILD_ID} - - docker login -u="$QUAYIO_USER" -p="$QUAYIO_PASS" + - echo "$QUAYIO_PASS" | docker login -u "$QUAYIO_USER" --password-stdin # - make docker.tar TAGS=${TRAVIS_BUILD_ID} # - ls .cache/docker/ From 8b8bfce114f3b9093a3d5890f78a885fba0d22ab Mon Sep 17 00:00:00 2001 From: alexlapa Date: Fri, 30 Aug 2019 21:17:41 +0300 Subject: [PATCH 533/735] try login [run ci] --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 26e0153e7..00323c590 100644 --- a/.travis.yml +++ b/.travis.yml @@ -47,7 +47,7 @@ jobs: rust: stable script: # - make docker.build.medea debug=no TAG=${TRAVIS_BUILD_ID} - - echo "$QUAYIO_PASS" | docker login -u "$QUAYIO_USER" --password-stdin + - echo "$QUAYIO_PASS" | docker login quay.io -u "$QUAYIO_USER" --password-stdin # - make docker.tar TAGS=${TRAVIS_BUILD_ID} # - ls .cache/docker/ From e5f6772f106ab25250de9f265505177099f90a2d Mon Sep 17 00:00:00 2001 From: alexlapa Date: Mon, 2 Sep 2019 13:35:37 +0300 Subject: [PATCH 534/735] try pass docker credentials store [run ci] --- .travis.yml | 5 +++++ ci/docker-pass.sh | 24 ++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 ci/docker-pass.sh diff --git a/.travis.yml b/.travis.yml index 00323c590..ea097409b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -45,8 +45,13 @@ jobs: - name: medea docker (stable) stage: build rust: stable + addons: + apt: + packages: + - pass script: # - make docker.build.medea debug=no TAG=${TRAVIS_BUILD_ID} + - ./ci/docker-pass.sh - echo "$QUAYIO_PASS" | docker login quay.io -u "$QUAYIO_USER" --password-stdin # - make docker.tar TAGS=${TRAVIS_BUILD_ID} # - ls .cache/docker/ diff --git a/ci/docker-pass.sh b/ci/docker-pass.sh new file mode 100644 index 000000000..f5b0575ea --- /dev/null +++ b/ci/docker-pass.sh @@ -0,0 +1,24 @@ +#!/bin/sh + +# see https://github.com/docker/docker-credential-helpers/blob/master/ci/before_script_linux.sh + +set -e + +# init key for pass +# dont forget to change email +gpg --batch --gen-key <<-EOF +%echo Generating a standard key +Key-Type: DSA +Key-Length: 1024 +Subkey-Type: ELG-E +Subkey-Length: 1024 +Name-Real: Instrumentisto Team +Name-Email: lapa.alex@ex.ua +Expire-Date: 0 +# Do a commit here, so that we can later print "done" :-) +%commit +%echo done +EOF + +key=$(gpg --no-auto-check-trustdb --list-secret-keys | grep ^sec | cut -d/ -f2 | cut -d" " -f1) +pass init $key \ No newline at end of file From a6ef1ee19fb8b33a23f366bcbc94cf56c1f4f430 Mon Sep 17 00:00:00 2001 From: alexlapa Date: Mon, 2 Sep 2019 13:48:47 +0300 Subject: [PATCH 535/735] travis cache --- .travis.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index ea097409b..f720d7644 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,10 +5,7 @@ env: - secure: O14lnD45q3oyuMtKU7Jfy1e+LSs91UZPnNuTPT9IZNoHPgJM77mdK1bwu5SqSXpmDEaq3uQBBhIKEKxiOgogiRAGcALnjSLIe02qrw8kR4hhB7IsuCsfJA3rgnH5NrSxV2ja5wHUkTtYORIB30GX/SU4qNw8C+HeAcXDaxPRNJYuIkE41jW121PDgheS7Ti49ui5JOKss/FdpI8Ii5xXvNf9Z60MSJKPsM8yaj+RiqDccXrFuyppVE/Ezn95gdJh1Sr7BUaP521FOhOYl4bvMEV0pHHMwaPD0b2Ku0yJ+GrZiZ2YqTmsNiaa4hN2AAv38w46KfhQuvJg173cEGf6hCrrF+IOQvmGG977xSO7tci2l5idjIZ1xtXsLQ9Yp49DBxd1s2I20j+fHmCImH1cV4+hEnMTQLITzemS3MkHIxbEgcMyssjZD7FASNU1C3fbeeHEG3JPM/hHj0mlGlhv7T54gL5Q7Qggnj+xsE44yU18bP0K/G48QBLeXDSfZzeaCbrif9bALAVnUMhRMSuW9EfOHcu7juaBAj5mPxWfN4CoQgqBFPh+V+q6+WViV0/5djoKlrOy323hNTg+CXIqWn9RYIbxbyRMGXIU6Z78Sr6Yls+8tK1cpdXOzQ6CMeUJh2H264hFMM1ZGvlQ+VYqRYMCViuVW4Aofuqr1zfsnz0= - secure: xm+WIGYVoYvjAlWOaoli0YZ4LMFBKd7pG0qno4zrDMGrz1AwLRK6dce0+ROvIdEcuOror2j4wryYgDRMLYgxzhXeMMVFkxZuB1MmeC8VHirf0jNHNNihWwnEyTDGtj5VXijD/ipo4jiskBZEsg/oW97iFUudjl/rNT2R0Gy420QgGV4p3m9jTjBBL6giIQUNK0g+5aIkCfb4U/4gcpFA5nZJgyfQtnKKmVnEPl26vbU+Ui7F/wqTK0a7AJT3RCaEddtu7E5DKNnk4/45e4//LKNEE8I2KGqWlqWXqFYs+Cno1trDOcKm0yiTIquvbZsrOuH7wN1il4qVcsdgQLps2kFahpJyQJbJJViBkbqnlwRJDnxtszbrxSGW6HiVMSSd8AOthwJd3n7lMkBDwrwG9Dx7MiNY/NIdRxufEuoOw/6tj31oBJhM1s+/Fhjzlz0j5R5spTtcaNg6Q0Gi+F283jjwvobIzvUUKKSt4I1UZLTQNSzxrWTJZ4kJBG1JiTxH7BwHMtxhiaZn5ajk5HfVXScmBknZIovsylj5UXp1d5IhXUNq4jTXTdybOurhQ1XLVz/hw64oOIQkuftaNHuQMe3oB69aWLWpS6+r3k1ZCT/WODbS3xlhp/MXO3WLD4WY1OWJ522t/YOUQX3j72bZADlQOcU/OWQ5LWNC3XGibrk= -cache: - cargo: true - directories: - - .cache/docker/ +cache: cargo install: - rustc -vV From 77289a463c843cfb4b90cdacba6f52b0f55f0e3a Mon Sep 17 00:00:00 2001 From: alexlapa Date: Mon, 2 Sep 2019 13:49:15 +0300 Subject: [PATCH 536/735] Make docker-pass.sh executable [run ci] --- ci/docker-pass.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 ci/docker-pass.sh diff --git a/ci/docker-pass.sh b/ci/docker-pass.sh old mode 100644 new mode 100755 From 9c2a1c9ddc9151f9ebe6a3e1efa2e14c599ef5ca Mon Sep 17 00:00:00 2001 From: alexlapa Date: Mon, 2 Sep 2019 14:18:33 +0300 Subject: [PATCH 537/735] docker secure login [run ci] --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f720d7644..1f6955a8e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -46,9 +46,10 @@ jobs: apt: packages: - pass + - docker-ce script: # - make docker.build.medea debug=no TAG=${TRAVIS_BUILD_ID} - - ./ci/docker-pass.sh +# - ./ci/docker-pass.sh - echo "$QUAYIO_PASS" | docker login quay.io -u "$QUAYIO_USER" --password-stdin # - make docker.tar TAGS=${TRAVIS_BUILD_ID} # - ls .cache/docker/ From 1590b4014135b809283c56713d9431880702876e Mon Sep 17 00:00:00 2001 From: alexlapa Date: Mon, 2 Sep 2019 14:40:39 +0300 Subject: [PATCH 538/735] debug travis [run ci] --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 1f6955a8e..c8f544570 100644 --- a/.travis.yml +++ b/.travis.yml @@ -50,7 +50,8 @@ jobs: script: # - make docker.build.medea debug=no TAG=${TRAVIS_BUILD_ID} # - ./ci/docker-pass.sh - - echo "$QUAYIO_PASS" | docker login quay.io -u "$QUAYIO_USER" --password-stdin + - cat /home/travis/.docker/config.json +# - echo "$QUAYIO_PASS" | docker login quay.io -u "$QUAYIO_USER" --password-stdin # - make docker.tar TAGS=${TRAVIS_BUILD_ID} # - ls .cache/docker/ From abb384ce94ffd644c9edaa327a54470a0abef811 Mon Sep 17 00:00:00 2001 From: alexlapa Date: Mon, 2 Sep 2019 15:55:56 +0300 Subject: [PATCH 539/735] secure login [run ci] --- .travis.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index c8f544570..0eea7a612 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,9 +7,13 @@ env: cache: cargo +services: + - docker + install: - rustc -vV - cargo -vV + - docker -v jobs: allow_failures: @@ -46,12 +50,12 @@ jobs: apt: packages: - pass - - docker-ce +# - docker-ce script: # - make docker.build.medea debug=no TAG=${TRAVIS_BUILD_ID} -# - ./ci/docker-pass.sh - - cat /home/travis/.docker/config.json -# - echo "$QUAYIO_PASS" | docker login quay.io -u "$QUAYIO_USER" --password-stdin + - ./ci/docker-pass.sh + - echo "$QUAYIO_PASS" | docker login quay.io -u "$QUAYIO_USER" --password-stdin + - sed -i '0,/{/s/{/{\n\t"credsStore": "pass",/' ~/.docker/config.json # - make docker.tar TAGS=${TRAVIS_BUILD_ID} # - ls .cache/docker/ From 167f3b0429e4d1feda0ec281b3b29db3b7388a05 Mon Sep 17 00:00:00 2001 From: alexlapa Date: Mon, 2 Sep 2019 16:14:47 +0300 Subject: [PATCH 540/735] secure login [run ci] --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 0eea7a612..d90dcf4a2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -55,7 +55,7 @@ jobs: # - make docker.build.medea debug=no TAG=${TRAVIS_BUILD_ID} - ./ci/docker-pass.sh - echo "$QUAYIO_PASS" | docker login quay.io -u "$QUAYIO_USER" --password-stdin - - sed -i '0,/{/s/{/{\n\t"credsStore": "pass",/' ~/.docker/config.json +# - "sed -i '0,/{/s/{/{\n\t"credsStore": \"pass\",/' ~/.docker/config.json" # - make docker.tar TAGS=${TRAVIS_BUILD_ID} # - ls .cache/docker/ From c15c023a7c5aa2cfcbd6f9844f1accedc3eae0a8 Mon Sep 17 00:00:00 2001 From: alexlapa Date: Mon, 2 Sep 2019 17:00:09 +0300 Subject: [PATCH 541/735] try build and push [run ci] --- .travis.yml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index d90dcf4a2..4de703075 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,6 @@ services: install: - rustc -vV - cargo -vV - - docker -v jobs: allow_failures: @@ -50,14 +49,12 @@ jobs: apt: packages: - pass -# - docker-ce script: -# - make docker.build.medea debug=no TAG=${TRAVIS_BUILD_ID} + - make docker.build.medea debug=no TAG=${TRAVIS_BUILD_ID} - ./ci/docker-pass.sh - echo "$QUAYIO_PASS" | docker login quay.io -u "$QUAYIO_USER" --password-stdin -# - "sed -i '0,/{/s/{/{\n\t"credsStore": \"pass\",/' ~/.docker/config.json" -# - make docker.tar TAGS=${TRAVIS_BUILD_ID} -# - ls .cache/docker/ + - docker tag instrumentisto/medea:${TRAVIS_BUILD_ID} quay.io/alexlapa/medea:${TRAVIS_BUILD_ID} + - docker push quay.io/alexlapa/medea:${TRAVIS_BUILD_ID} # - name: medea (beta) # stage: build From 97035dc1c7bb4c073135201a3e42abe8db040604 Mon Sep 17 00:00:00 2001 From: alexlapa Date: Mon, 2 Sep 2019 18:29:19 +0300 Subject: [PATCH 542/735] try build and push and pull for tests [run ci] --- .env | 2 +- .travis.yml | 17 +++++++---------- Makefile | 48 +++++++++--------------------------------------- 3 files changed, 17 insertions(+), 50 deletions(-) diff --git a/.env b/.env index 0a394414f..fcc5bf5cb 100644 --- a/.env +++ b/.env @@ -2,7 +2,7 @@ RUST_LOG=debug MEDEA_CONF=config.toml COMPOSE_PROJECT_NAME=medea -COMPOSE_IMAGE_NAME=instrumentisto/medea +COMPOSE_IMAGE_NAME=alexlapa/medea COMPOSE_IMAGE_VER=dev MEDEA_SERVER_STATIC_SPECS_PATH=./dev/specs diff --git a/.travis.yml b/.travis.yml index 4de703075..6601379a8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -49,11 +49,10 @@ jobs: apt: packages: - pass - script: - - make docker.build.medea debug=no TAG=${TRAVIS_BUILD_ID} + script: make docker.build.medea debug=no TAG=${TRAVIS_BUILD_ID} registry=quay.io + after_script: - ./ci/docker-pass.sh - echo "$QUAYIO_PASS" | docker login quay.io -u "$QUAYIO_USER" --password-stdin - - docker tag instrumentisto/medea:${TRAVIS_BUILD_ID} quay.io/alexlapa/medea:${TRAVIS_BUILD_ID} - docker push quay.io/alexlapa/medea:${TRAVIS_BUILD_ID} # - name: medea (beta) @@ -71,13 +70,11 @@ jobs: # rust: stable # script: make test.unit crate=@all # -# - name: e2e signalling (stable) -# stage: test -# rust: stable -# script: -# - ls .cache/ -# - make docker.untar TAGS=${TRAVIS_BUILD_ID} -# - make test.e2e dockerized=yes logs=yes TAG=${TRAVIS_BUILD_ID} + - name: e2e signalling (stable) + stage: test + rust: stable + script: + - make test.e2e dockerized=yes logs=yes TAG=${TRAVIS_BUILD_ID} registry=quay.io - name: crates.io stage: release diff --git a/Makefile b/Makefile index 0cf777a92..e7ab3f035 100644 --- a/Makefile +++ b/Makefile @@ -116,14 +116,16 @@ up.jason: # # Usage: # make up.medea [dockerized=(NO|yes)] [background=(NO|yes) -# [logs=(NO|yes)]] [TAG=(dev|)] +# [logs=(NO|yes)]] [TAG=(dev|)] +# [registry=(dockerhub|)] +docker-image-name = $(if $(call eq,$(registry),),,$(registry)/)$(MEDEA_IMAGE_NAME) docker-up-tag = $(if $(call eq,$(TAG),),dev,$(TAG)) up.medea: ifeq ($(dockerized),yes) @make down.medea dockerized=yes - COMPOSE_IMAGE_NAME=$(MEDEA_IMAGE_NAME) \ + COMPOSE_IMAGE_NAME=$(docker-image-name) \ COMPOSE_IMAGE_VER=$(docker-up-tag) \ docker-compose -f docker-compose.medea.yml up \ $(if $(call eq,$(background),yes),-d,--abort-on-container-exit) @@ -296,6 +298,7 @@ endif # Usage: # make test.e2e [dockerized=(YES|no)] [logs=(yes|NO)] # [release=(NO|yes)] [TAG=(dev|)] +# [registry=(dockerhub|)] medea-env = RUST_BACKTRACE=1 \ $(if $(call eq,$(logs),yes),,RUST_LOG=warn) \ @@ -310,7 +313,7 @@ endif ifeq ($(dockerized),no) env $(medea-env) $(if $(call eq,$(logs),yes),,RUST_LOG=warn) cargo run $(if $(call eq,$(release),yes),--release) & else - env $(medea-env) make up.medea dockerized=yes background=yes logs=$(logs) TAG=$(TAG) & + env $(medea-env) make up.medea dockerized=yes background=yes logs=$(logs) TAG=$(TAG) registry=$(registry) & endif sleep 5 RUST_BACKTRACE=1 cargo test --test e2e @@ -389,10 +392,10 @@ docker.build.demo: # # Usage: # make docker.build.medea [TAG=(dev|)] [debug=(yes|no)] -# [no-cache=(no|yes)] -# [minikube=(no|yes)] +# [no-cache=(no|yes)] [minikube=(no|yes)] +# [registry=(dockerhub|)] -docker-build-medea-image-name = $(MEDEA_IMAGE_NAME) +docker-build-medea-image-name = $(if $(call eq,$(registry),),,$(registry)/)$(MEDEA_IMAGE_NAME) docker.build.medea: ifneq ($(no-cache),yes) @@ -443,39 +446,6 @@ docker.up.demo: docker.down.demo docker-compose -f jason/demo/docker-compose.yml up -# Save project Docker images in a tarball file. -# -# Usage: -# make docker.tar [IMAGE=(|)] -# [TAGS=(dev|[,...])] - -docker-tar-image-name = $(MEDEA_IMAGE_NAME)$(if $(call eq,$(IMAGE),),,/$(IMAGE)) -docker-tar-dir = .cache/docker/$(docker-tar-image-name) -docker-tar-tags = $(if $(call eq,$(TAGS),),dev,$(TAGS)) - -docker.tar: - @mkdir -p $(docker-tar-dir)/ - docker save \ - -o $(docker-tar-dir)/$(subst $(comma),_,$(docker-tar-tags)).tar \ - $(foreach tag,$(subst $(comma), ,$(docker-tar-tags)),\ - $(docker-tar-image-name):$(tag)) - - -# Load project Docker images from a tarball file. -# -# Usage: -# make docker.untar [IMAGE=(|)] -# [TAGS=(dev|[,...])] - -docker-untar-image-name = $(MEDEA_IMAGE_NAME)$(if $(call eq,$(IMAGE),),,/$(IMAGE)) -docker-untar-dir = .cache/docker/$(docker-untar-image-name) -docker-untar-tags = $(if $(call eq,$(TAGS),),dev,$(TAGS)) - -docker.untar: - docker load \ - -i $(docker-untar-dir)/$(subst $(comma),_,$(docker-untar-tags)).tar - - ############################## From bbf356f420905c5175a3f57907368e4f5f07373a Mon Sep 17 00:00:00 2001 From: alexlapa Date: Mon, 2 Sep 2019 19:06:04 +0300 Subject: [PATCH 543/735] try run everything on CI [run ci] --- .env | 2 +- .travis.yml | 75 +++++++++++++++++++++++----------------------- jason/CHANGELOG.md | 2 +- 3 files changed, 40 insertions(+), 39 deletions(-) diff --git a/.env b/.env index fcc5bf5cb..0a394414f 100644 --- a/.env +++ b/.env @@ -2,7 +2,7 @@ RUST_LOG=debug MEDEA_CONF=config.toml COMPOSE_PROJECT_NAME=medea -COMPOSE_IMAGE_NAME=alexlapa/medea +COMPOSE_IMAGE_NAME=instrumentisto/medea COMPOSE_IMAGE_VER=dev MEDEA_SERVER_STATIC_SPECS_PATH=./dev/specs diff --git a/.travis.yml b/.travis.yml index 6601379a8..a55539681 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,30 +17,29 @@ install: jobs: allow_failures: - rust: nightly - stage: build include: -# - name: Clippy -# stage: check -# rust: stable -# before_script: rustup component add clippy -# script: make lint -# -# - name: rustfmt -# stage: check -# rust: nightly -# cache: false -# before_script: rustup component add rustfmt -# script: make fmt check=yes -# -# - name: medea-jason (stable) -# stage: build -# rust: stable -# before_script: -# - rm -f /home/travis/.cargo/bin/wasm-pack -# - curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh -# script: -# - make release.npm crate=medea-jason publish=no + - name: Clippy + stage: check + rust: stable + before_script: rustup component add clippy + script: make lint + + - name: rustfmt + stage: check + rust: nightly + cache: false + before_script: rustup component add rustfmt + script: make fmt check=yes + + - name: medea-jason (stable) + stage: build + rust: stable + before_script: + - rm -f /home/travis/.cargo/bin/wasm-pack + - curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh + script: + - make release.npm crate=medea-jason publish=no - name: medea docker (stable) stage: build @@ -55,21 +54,21 @@ jobs: - echo "$QUAYIO_PASS" | docker login quay.io -u "$QUAYIO_USER" --password-stdin - docker push quay.io/alexlapa/medea:${TRAVIS_BUILD_ID} -# - name: medea (beta) -# stage: build -# rust: beta -# script: make build.medea -# -# - name: medea (nightly) -# stage: build -# rust: nightly -# script: make build.medea -# -# - name: unit (stable) -# stage: test -# rust: stable -# script: make test.unit crate=@all -# + - name: medea (beta) + stage: build_beta + rust: beta + script: make build.medea + + - name: medea (nightly) + stage: build_beta + rust: nightly + script: make build.medea + + - name: unit (stable) + stage: test + rust: stable + script: make test.unit crate=@all + - name: e2e signalling (stable) stage: test rust: stable @@ -133,6 +132,8 @@ stages: if: (branch = master AND type != pull_request) OR commit_message =~ /.*\[run ci\]/ - name: build if: (branch = master AND type != pull_request) OR commit_message =~ /.*\[run ci\]/ + - name: build_beta + if: branch = master - name: test if: (branch = master AND type != pull_request) OR commit_message =~ /.*\[run ci\]/ - name: tests diff --git a/jason/CHANGELOG.md b/jason/CHANGELOG.md index 72f2c717b..bb1a9a9ba 100644 --- a/jason/CHANGELOG.md +++ b/jason/CHANGELOG.md @@ -1,4 +1,4 @@ -1 +`medea-jason` changelog ======================= All user visible changes to this project will be documented in this file. This project uses [Semantic Versioning 2.0.0]. From 8fcc52c9f24baac41c3e1e6f9ba9be6d4dd1fa40 Mon Sep 17 00:00:00 2001 From: alexlapa Date: Tue, 3 Sep 2019 02:15:04 +0300 Subject: [PATCH 544/735] try run everything on CI [run ci] --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a55539681..378aee2ca 100644 --- a/.travis.yml +++ b/.travis.yml @@ -52,7 +52,7 @@ jobs: after_script: - ./ci/docker-pass.sh - echo "$QUAYIO_PASS" | docker login quay.io -u "$QUAYIO_USER" --password-stdin - - docker push quay.io/alexlapa/medea:${TRAVIS_BUILD_ID} + - docker push quay.io/instrumentisto/medea:${TRAVIS_BUILD_ID} - name: medea (beta) stage: build_beta From 5888aa5811baddf0add3bd3bd9fdee4921a8209c Mon Sep 17 00:00:00 2001 From: alexlapa Date: Mon, 2 Sep 2019 19:15:12 +0300 Subject: [PATCH 545/735] perhaps, we dont need this script anymore [run ci] --- .travis.yml | 5 ----- ci/docker-pass.sh | 24 ------------------------ 2 files changed, 29 deletions(-) delete mode 100755 ci/docker-pass.sh diff --git a/.travis.yml b/.travis.yml index 378aee2ca..1c0dd9ffd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -44,13 +44,8 @@ jobs: - name: medea docker (stable) stage: build rust: stable - addons: - apt: - packages: - - pass script: make docker.build.medea debug=no TAG=${TRAVIS_BUILD_ID} registry=quay.io after_script: - - ./ci/docker-pass.sh - echo "$QUAYIO_PASS" | docker login quay.io -u "$QUAYIO_USER" --password-stdin - docker push quay.io/instrumentisto/medea:${TRAVIS_BUILD_ID} diff --git a/ci/docker-pass.sh b/ci/docker-pass.sh deleted file mode 100755 index f5b0575ea..000000000 --- a/ci/docker-pass.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh - -# see https://github.com/docker/docker-credential-helpers/blob/master/ci/before_script_linux.sh - -set -e - -# init key for pass -# dont forget to change email -gpg --batch --gen-key <<-EOF -%echo Generating a standard key -Key-Type: DSA -Key-Length: 1024 -Subkey-Type: ELG-E -Subkey-Length: 1024 -Name-Real: Instrumentisto Team -Name-Email: lapa.alex@ex.ua -Expire-Date: 0 -# Do a commit here, so that we can later print "done" :-) -%commit -%echo done -EOF - -key=$(gpg --no-auto-check-trustdb --list-secret-keys | grep ^sec | cut -d/ -f2 | cut -d" " -f1) -pass init $key \ No newline at end of file From 271bf0b390a66aa4f0587769c5fa42568cda07c1 Mon Sep 17 00:00:00 2001 From: alexlapa Date: Tue, 3 Sep 2019 04:05:11 +0300 Subject: [PATCH 546/735] update deps [run ci] --- Cargo.lock | 59 ++--- Cargo.toml | 2 +- jason/Cargo.lock | 582 ----------------------------------------------- 3 files changed, 32 insertions(+), 611 deletions(-) delete mode 100644 jason/Cargo.lock diff --git a/Cargo.lock b/Cargo.lock index 9630ff150..6578fe2da 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -15,7 +15,7 @@ version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "actix-http 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-rt 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-rt 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "actix_derive 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -49,10 +49,11 @@ dependencies = [ [[package]] name = "actix-connect" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-rt 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "actix-service 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "actix-utils 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -71,7 +72,7 @@ version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-connect 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-connect 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "actix-server-config 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "actix-service 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "actix-threadpool 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -80,7 +81,7 @@ dependencies = [ "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "brotli2 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "chrono 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "copyless 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", "either 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -118,7 +119,7 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-rt 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-rt 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "actix-server 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "actix-service 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "actix-utils 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -155,7 +156,7 @@ dependencies = [ [[package]] name = "actix-rt" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "actix-threadpool 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -172,7 +173,7 @@ name = "actix-server" version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "actix-rt 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-rt 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "actix-server-config 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "actix-service 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", @@ -243,7 +244,7 @@ dependencies = [ "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "actix-http 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", "actix-router 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-rt 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-rt 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "actix-server 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "actix-server-config 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "actix-service 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -499,13 +500,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "chrono" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ + "js-sys 0.3.27 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", "num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1030,7 +1033,7 @@ dependencies = [ "awc 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "bb8 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "bb8-redis 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "chrono 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "config 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", "dotenv 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1098,7 +1101,7 @@ name = "medea-macro" version = "0.1.0" dependencies = [ "Inflector 0.11.4 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1363,7 +1366,7 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1387,7 +1390,7 @@ name = "quote" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1734,7 +1737,7 @@ name = "serde_derive" version = "1.0.99" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1869,7 +1872,7 @@ name = "slog-json" version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "chrono 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1902,7 +1905,7 @@ version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", - "chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "chrono 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "term 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1967,7 +1970,7 @@ name = "syn" version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2051,7 +2054,7 @@ dependencies = [ "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-threadpool 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-udp 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-udp 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-uds 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2188,7 +2191,7 @@ dependencies = [ [[package]] name = "tokio-udp" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2253,7 +2256,7 @@ dependencies = [ "tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-udp 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-udp 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2376,7 +2379,7 @@ dependencies = [ "bumpalo 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-shared 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2408,7 +2411,7 @@ name = "wasm-bindgen-macro-support" version = "0.2.50" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-backend 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2451,7 +2454,7 @@ dependencies = [ "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-backend 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2577,11 +2580,11 @@ dependencies = [ "checksum Inflector 0.11.4 (registry+https://github.com/rust-lang/crates.io-index)" = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" "checksum actix 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)" = "671ce3d27313f236827a5dd153a1073ad03ef31fc77f562020263e7830cf1ef7" "checksum actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9f2c11af4b06dc935d8e1b1491dad56bfb32febc49096a91e773f8535c176453" -"checksum actix-connect 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "646be02316c497d1cb8b1ed82eb723b052d6b3e2462c94bd52d0ac2d4a29a165" +"checksum actix-connect 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "a0ff50d0ec73f6db267ca8ad28ccf325846e691c6bc15d8b6c0f4ea43b238e90" "checksum actix-http 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)" = "de5aaeef8b9eef653b910f957a02bea9c1b375f7fa49b411fb75dad8f41462eb" "checksum actix-http-test 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "beafa31d71c8fa8204ede1602a3dd221e5cf30ff354180f8ee87274ab81cf607" "checksum actix-router 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "23224bb527e204261d0291102cb9b52713084def67d94f7874923baefe04ccf7" -"checksum actix-rt 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "18d9054b1cfacfa441846b9b99001010cb8fbb02130e6cfdb25cea36d3e98e87" +"checksum actix-rt 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "168620aaf00fcd2a16e621790abaf180ef7377c2f8355b4ca5775d6afc778ed8" "checksum actix-server 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fb3038e9e457e0a498ea682723e0f4e6cc2c4f362a1868d749808355275ad959" "checksum actix-server-config 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "483a34989c682d93142bacad6300375bb6ad8002d2e0bb249dbad86128b9ff30" "checksum actix-service 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bca5b48e928841ff7e7dce1fdb5b0d4582f6b1b976e08f4bac3f640643e0773f" @@ -2616,7 +2619,7 @@ dependencies = [ "checksum c2-chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7d64d04786e0f528460fc884753cf8dddcc466be308f6026f8e355c41a0e4101" "checksum cc 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)" = "8dae9c4b8fedcae85592ba623c4fd08cfdab3e3b72d6df780c6ead964a69bfff" "checksum cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b486ce3ccf7ffd79fdeb678eac06a9e6c09fc88d33836340becb8fffe87c5e33" -"checksum chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "77d81f58b7301084de3b958691458a53c3f7e0b1d702f77e550b6a88e3a88abe" +"checksum chrono 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "27429a03ca54100bf6bdc726c09adc46a74187ac93f9ce96dc7aaa9594ebf707" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" "checksum combine 3.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "da3da6baa321ec19e1cc41d31bf599f00c783d0517095cdaf0332e3fe8d20680" "checksum config 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "f9107d78ed62b3fa5a86e7d18e647abed48cfd8f8fab6c72f4cdb982d196f7e6" @@ -2708,7 +2711,7 @@ dependencies = [ "checksum percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" "checksum ppv-lite86 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e3cbf9f658cdb5000fcf6f362b8ea2ba154b9f146a61c7a20d647034c6b6561b" "checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" -"checksum proc-macro2 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4c5c2380ae88876faae57698be9e9775e3544decad214599c3a6266cca6ac802" +"checksum proc-macro2 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "175a40b9cf564ce9bf050654633dbf339978706b8ead1a907bb970b63185dd95" "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" "checksum quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" "checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" @@ -2798,7 +2801,7 @@ dependencies = [ "checksum tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1d14b10654be682ac43efee27401d792507e30fd8d26389e1da3b185de2e4119" "checksum tokio-threadpool 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "90ca01319dea1e376a001e8dc192d42ebde6dd532532a5bad988ac37db365b19" "checksum tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "f2106812d500ed25a4f38235b9cae8f78a09edf43203e16e59c3b769a342a60e" -"checksum tokio-udp 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "56775b287cda0fd8ca0c5d2f5b1d0646afbd360101e2eef91cd89365fcfc2f5f" +"checksum tokio-udp 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f02298505547f73e60f568359ef0d016d5acd6e830ab9bc7c4a5b3403440121b" "checksum tokio-uds 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "037ffc3ba0e12a0ab4aca92e5234e0dedeb48fddf6ccd260f1f150a36a9f2445" "checksum toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "758664fc71a3a69038656bee8b6be6477d2a6c315a6b81f7081f591bffa4111f" "checksum toml 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c7aabe75941d914b72bf3e5d3932ed92ce0664d49d8432305a8b547c37227724" diff --git a/Cargo.toml b/Cargo.toml index 233b8c9dd..ce3f7e997 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -48,7 +48,7 @@ serde_json = "1.0" serde_yaml = "0.8" slog = "2.5" slog-async = "2.3" -slog-envlogger = "2.1" +slog-envlogger = "2.2" slog-json = "2.3" slog-scope = "4.1" slog-stdlog = "4.0" diff --git a/jason/Cargo.lock b/jason/Cargo.lock deleted file mode 100644 index cffc142a0..000000000 --- a/jason/Cargo.lock +++ /dev/null @@ -1,582 +0,0 @@ -[[package]] -name = "aho-corasick" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "atty" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", - "termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "autocfg" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "backtrace" -version = "0.3.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "backtrace-sys" -version = "0.1.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cc 1.0.34 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "bumpalo" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "cc" -version = "1.0.34" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "cfg-if" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "console_error_panic_hook" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "discard" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "env_logger" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "failure" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "backtrace 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", - "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "failure_derive" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.30 (registry+https://github.com/rust-lang/crates.io-index)", - "synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "futures" -version = "0.1.26" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "heck" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "unicode-segmentation 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "humantime" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "itoa" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "jason" -version = "0.1.0-dev" -dependencies = [ - "console_error_panic_hook 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "discard 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", - "js-sys 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-futures 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-test 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", - "web-sys 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "js-sys" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "wasm-bindgen 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "lazy_static" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "libc" -version = "0.2.51" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "log" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "memchr" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "nom" -version = "4.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "proc-macro2" -version = "0.4.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "quick-error" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "quote" -version = "0.6.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "redox_syscall" -version = "0.1.52" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "redox_termios" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "redox_syscall 0.1.52 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "regex" -version = "1.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "aho-corasick 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", - "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", - "utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "regex-syntax" -version = "0.6.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rustc-demangle" -version = "0.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "ryu" -version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "scoped-tls" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "serde" -version = "1.0.90" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "serde_derive 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "serde_derive" -version = "1.0.90" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.30 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "serde_json" -version = "1.0.39" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "sourcefile" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "syn" -version = "0.15.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "synstructure" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.30 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "termcolor" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "wincolor 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "termion" -version = "1.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.52 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "thread_local" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "ucd-util" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "unicode-segmentation" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "unicode-xid" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "utf8-ranges" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "version_check" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "wasm-bindgen" -version = "0.2.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-macro 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bumpalo 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.30 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-shared 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "wasm-bindgen-futures" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", - "js-sys 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-macro-support 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.30 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-backend 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-shared 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.40" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "wasm-bindgen-test" -version = "0.2.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "console_error_panic_hook 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", - "js-sys 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)", - "scoped-tls 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-futures 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-test-macro 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "wasm-bindgen-test-macro" -version = "0.2.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "wasm-bindgen-webidl" -version = "0.2.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.30 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-backend 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", - "weedle 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "web-sys" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "js-sys 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)", - "sourcefile 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-webidl 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "weedle" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "nom 4.2.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "winapi" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "winapi-util" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "wincolor" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[metadata] -"checksum aho-corasick 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e6f484ae0c99fec2e858eb6134949117399f222608d84cadb3f58c1f97c2364c" -"checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" -"checksum autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a6d640bee2da49f60a4068a7fae53acde8982514ab7bae8b8cea9e88cbcfd799" -"checksum backtrace 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "cd5a90e2b463010cd0e0ce9a11d4a9d5d58d9f41d4a6ba3dcaf9e68b466e88b4" -"checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6" -"checksum bumpalo 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f6a6bc2ba935b1e2f810787ceba8dfe86cbc164cee55925cae715541186673c4" -"checksum cc 1.0.34 (registry+https://github.com/rust-lang/crates.io-index)" = "30f813bf45048a18eda9190fd3c6b78644146056740c43172a5a3699118588fd" -"checksum cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "11d43355396e872eefb45ce6342e4374ed7bc2b3a502d1b28e36d6e23c05d1f4" -"checksum console_error_panic_hook 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "b8d976903543e0c48546a91908f21588a680a8c8f984df9a5d69feccb2b2a211" -"checksum discard 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0" -"checksum env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b61fa891024a945da30a9581546e8cfaf5602c7b3f4c137a2805cf388f92075a" -"checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" -"checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" -"checksum futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)" = "62941eff9507c8177d448bd83a44d9b9760856e184081d8cd79ba9f03dd24981" -"checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" -"checksum humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ca7e5f2e110db35f93b837c81797f3714500b81d517bf20c431b16d3ca4f114" -"checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b" -"checksum js-sys 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)" = "d4bda84b98977341bb6ba1086ecbd9eab8bc929de0f2923c118baf76c21dd0c8" -"checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" -"checksum libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)" = "bedcc7a809076656486ffe045abeeac163da1b558e963a31e29fbfbeba916917" -"checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6" -"checksum memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2efc7bc57c883d4a4d6e3246905283d8dae951bb3bd32f49d6ef297f546e1c39" -"checksum nom 4.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2ad2a91a8e869eeb30b9cb3119ae87773a8f4ae617f41b1eb9c154b2905f7bd6" -"checksum proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)" = "4d317f9caece796be1980837fd5cb3dfec5613ebdb04ad0956deea83ce168915" -"checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" -"checksum quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)" = "cdd8e04bd9c52e0342b406469d494fcb033be4bdbe5c606016defbb1681411e1" -"checksum redox_syscall 0.1.52 (registry+https://github.com/rust-lang/crates.io-index)" = "d32b3053e5ced86e4bc0411fec997389532bf56b000e66cb4884eeeb41413d69" -"checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" -"checksum regex 1.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "559008764a17de49a3146b234641644ed37d118d1ef641a0bb573d146edc6ce0" -"checksum regex-syntax 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "dcfd8681eebe297b81d98498869d4aae052137651ad7b96822f09ceb690d0a96" -"checksum rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "adacaae16d02b6ec37fdc7acfcddf365978de76d1983d3ee22afc260e1ca9619" -"checksum ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "eb9e9b8cde282a9fe6a42dd4681319bfb63f121b8a8ee9439c6f4107e58a46f7" -"checksum scoped-tls 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2" -"checksum serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)" = "aa5f7c20820475babd2c077c3ab5f8c77a31c15e16ea38687b4c02d3e48680f4" -"checksum serde_derive 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)" = "58fc82bec244f168b23d1963b45c8bf5726e9a15a9d146a067f9081aeed2de79" -"checksum serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)" = "5a23aa71d4a4d43fdbfaac00eff68ba8a06a51759a89ac3304323e800c4dd40d" -"checksum sourcefile 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4bf77cb82ba8453b42b6ae1d692e4cdc92f9a47beaf89a847c8be83f4e328ad3" -"checksum syn 0.15.30 (registry+https://github.com/rust-lang/crates.io-index)" = "66c8865bf5a7cbb662d8b011950060b3c8743dca141b054bf7195b20d314d8e2" -"checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015" -"checksum termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4096add70612622289f2fdcdbd5086dc81c1e2675e6ae58d6c4f62a16c6d7f2f" -"checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096" -"checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" -"checksum ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "535c204ee4d8434478593480b8f86ab45ec9aae0e83c568ca81abf0fd0e88f86" -"checksum unicode-segmentation 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "aa6024fc12ddfd1c6dbc14a80fa2324d4568849869b779f6bd37e5e4c03344d1" -"checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" -"checksum utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "796f7e48bef87609f7ade7e06495a87d5cd06c7866e6a5cbfceffc558a243737" -"checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" -"checksum wasm-bindgen 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)" = "9742fc4860f47bede1090a5e4b0cfc33afcd70cfdf45dd28f2cfb02d4662b0dd" -"checksum wasm-bindgen-backend 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)" = "c6d7f35ecbb4180513cdb9b298543321bcb278670730415cbb3205ff2c66a477" -"checksum wasm-bindgen-futures 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)" = "67bfbec85e48e8915b6acfa1c4d90b770ce033c96dc2067688f3bccd00d3b9e1" -"checksum wasm-bindgen-macro 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)" = "e3c86b06bcd28e92e87d2c2ad208889b2f69ea33f79810b91ef660cc3de65a4c" -"checksum wasm-bindgen-macro-support 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)" = "81d7338dd8c67e193d8ef18e5802dc03d8710456baa792c1c2e66847e57fd389" -"checksum wasm-bindgen-shared 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)" = "0d57c3b66f2f3e4d96b50f49b7b7e2f4cfcddc88b15744433c98c5c105b26672" -"checksum wasm-bindgen-test 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)" = "85bbc3ad78a8d59a63a02d59345e8da9a3e0c1617f79e77fd1c3da6e047db63e" -"checksum wasm-bindgen-test-macro 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)" = "114dfdf01bd3659dd79db05480fbd2751759d1c79cd9edc22f2fe611c866e932" -"checksum wasm-bindgen-webidl 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)" = "fc7052a577eefce17a439edfce5c2eedc8432fe7457bbe949624cdf946233fa7" -"checksum web-sys 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)" = "72d02003924c77af871ad74216f828b6e32af776cbb3f5dab3dcde2f2713c012" -"checksum weedle 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "26a4c67f132386d965390b8a734d5d10adbcd30eb5cc74bd9229af8b83f10044" -"checksum winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f10e386af2b13e47c89e7236a7a14a086791a2b88ebad6df9bf42040195cf770" -"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" -"checksum winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7168bab6e1daee33b4557efd0e95d5ca70a03706d39fa5f3fe7a236f584b03c9" -"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -"checksum wincolor 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "561ed901ae465d6185fa7864d63fbd5720d0ef718366c9a4dc83cf6170d7e9ba" From b163c8ee319d2fdfb445519bf6b16283b6073ed3 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 3 Sep 2019 14:14:03 +0300 Subject: [PATCH 547/735] Fix gRPC error for parsing SrcUri [run ci] --- src/api/control/local_uri.rs | 18 ++++++++++-------- src/api/error_codes.rs | 4 ++-- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/api/control/local_uri.rs b/src/api/control/local_uri.rs index b8d3b812e..7519f3fe8 100644 --- a/src/api/control/local_uri.rs +++ b/src/api/control/local_uri.rs @@ -27,19 +27,13 @@ pub enum LocalUriParseError { MissingFields(String), #[fail(display = "Error while parsing URL. {:?}", _0)] - UrlParseErr(url::ParseError), + UrlParseErr(String, url::ParseError), /// Provided empty `&str`. #[fail(display = "You provided empty local uri.")] Empty, } -impl From for LocalUriParseError { - fn from(from: url::ParseError) -> Self { - Self::UrlParseErr(from) - } -} - /// State of [`LocalUri`] which points to `Room`. #[derive(Debug)] pub struct IsRoomId(RoomId); @@ -210,7 +204,15 @@ impl LocalUriInner { return Err(LocalUriParseError::Empty); } - let url = Url::parse(value)?; + let url = match Url::parse(value) { + Ok(url) => url, + Err(e) => { + return Err(LocalUriParseError::UrlParseErr( + value.to_string(), + e, + )) + } + }; if url.scheme() != "local" { return Err(LocalUriParseError::NotLocal(value.to_string())); } diff --git a/src/api/error_codes.rs b/src/api/error_codes.rs index c8c8f529d..4412c8ca0 100644 --- a/src/api/error_codes.rs +++ b/src/api/error_codes.rs @@ -273,8 +273,8 @@ impl From for ErrorResponse { LocalUriParseError::MissingFields(text) => { Self::new(ErrorCode::MissingFieldsInSrcUri, &text) } - LocalUriParseError::UrlParseErr(_) => { - Self::new(ErrorCode::InvalidSrcUri, &err.to_string()) + LocalUriParseError::UrlParseErr(id, _) => { + Self::new(ErrorCode::InvalidSrcUri, &id) } } } From 04a51bc9572ed959dae7162d5d89a7591657e18f Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 3 Sep 2019 14:17:26 +0300 Subject: [PATCH 548/735] Remote TODO [run ci] --- src/signalling/participants.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 3ad77fe9d..ce852140d 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -134,7 +134,6 @@ impl ParticipantService { }) } - // TODO: try return ref /// Lookup [`Member`] by provided id. pub fn get_member_by_id(&self, id: &MemberId) -> Option { self.members.get(id).cloned() From 1e28f6efc361658e01d7f06583c96651fd6781a0 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 3 Sep 2019 14:29:29 +0300 Subject: [PATCH 549/735] Remote outdated commented code --- src/signalling/peers.rs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index fa0df01f4..63eaacaf0 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -209,12 +209,6 @@ impl PeerRepository { } } - // for (member_id, removed_peers_ids) in removed_peers { - // ctx.notify(PeersRemoved { - // member_id, - // peers_id: removed_peers_ids, - // }) - // } removed_peers } From 724027cda3b308a5c2a746343a92ec6f804fca20 Mon Sep 17 00:00:00 2001 From: tyranron Date: Tue, 3 Sep 2019 18:35:59 +0300 Subject: [PATCH 550/735] Corrections [skip ci] --- .clippy.toml | 3 +-- .env | 4 ++-- CHANGELOG.md | 1 + CONTRIBUTING.md | 5 ++++- Cargo.toml | 4 ++-- .../{pub_pub_video_call.yml => pub-pub-video-call.yml} | 6 ++++-- .../{pub_sub_video_call.yml => pub-sub-video-call.yml} | 4 ++-- ...members_conference.yml => three-members-conference.yml} | 7 ++++--- dev/specs/{video_call_1.yml => video-call-1.yml} | 6 ++++-- jason/e2e-demo/js/index.js | 3 --- proto/client-api/Cargo.toml | 4 ++-- .../{pub_sub_video_call.yml => pub-sub-video-call.yml} | 0 ...members_conference.yml => three-members-conference.yml} | 1 - 13 files changed, 26 insertions(+), 22 deletions(-) rename dev/specs/{pub_pub_video_call.yml => pub-pub-video-call.yml} (93%) rename dev/specs/{pub_sub_video_call.yml => pub-sub-video-call.yml} (86%) rename dev/specs/{three_members_conference.yml => three-members-conference.yml} (96%) rename dev/specs/{video_call_1.yml => video-call-1.yml} (93%) rename tests/specs/{pub_sub_video_call.yml => pub-sub-video-call.yml} (100%) rename tests/specs/{three_members_conference.yml => three-members-conference.yml} (99%) diff --git a/.clippy.toml b/.clippy.toml index 4de1a2733..0bac1693a 100644 --- a/.clippy.toml +++ b/.clippy.toml @@ -13,6 +13,5 @@ doc-valid-idents = [ "RTCConfiguration", "RTCIceCandidate", "RTCIceServer", "RTCPeerConnection", "RTCPeerConnectionIceEvent", "RTCRtpTransceiver", "RTCRtpTransceiverDirection", - "RTCSdpType", "RTCIceCandidateInit", - "WebRTC", "RtcPeerConnection", + "RTCSdpType", "RTCIceCandidateInit" ] diff --git a/.env b/.env index 0a394414f..5175d17bd 100644 --- a/.env +++ b/.env @@ -1,8 +1,8 @@ RUST_LOG=debug + MEDEA_CONF=config.toml +MEDEA_SERVER_STATIC_SPECS_PATH=./dev/specs COMPOSE_PROJECT_NAME=medea COMPOSE_IMAGE_NAME=instrumentisto/medea COMPOSE_IMAGE_VER=dev - -MEDEA_SERVER_STATIC_SPECS_PATH=./dev/specs diff --git a/CHANGELOG.md b/CHANGELOG.md index 23236a692..a8d573d93 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,5 +48,6 @@ All user visible changes to this project will be documented in this file. This p + [Coturn]: https://github.com/coturn/coturn [Semantic Versioning 2.0.0]: https://semver.org diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 530d4aa05..861379d07 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,5 +1,8 @@ Contribution Guide -=== +================== + + + ## Prerequisites diff --git a/Cargo.toml b/Cargo.toml index ce3f7e997..578763d6f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -59,9 +59,9 @@ toml = "0.5" url = "2.1" [dev-dependencies] +actix-codec = "0.1" actix-http = "0.2" actix-http-test = "0.2" +awc = "0.2" serial_test = "0.2" serial_test_derive = "0.2" -actix-codec = "0.1.2" -awc = "0.2" diff --git a/dev/specs/pub_pub_video_call.yml b/dev/specs/pub-pub-video-call.yml similarity index 93% rename from dev/specs/pub_pub_video_call.yml rename to dev/specs/pub-pub-video-call.yml index 560cf0ecb..728ac94cc 100644 --- a/dev/specs/pub_pub_video_call.yml +++ b/dev/specs/pub-pub-video-call.yml @@ -8,13 +8,15 @@ spec: credentials: test spec: pipeline: - # Media element which is able to receive media data from client via WebRTC. + # Media element which is able to receive media data from client + # via WebRTC. publish: kind: WebRtcPublishEndpoint spec: # Actually, it receives not media data, but ICE candidates only. p2p: Always - # Media element which is able to play media data for client via WebRTC. + # Media element which is able to play media data for client + # via WebRTC. play: kind: WebRtcPlayEndpoint spec: diff --git a/dev/specs/pub_sub_video_call.yml b/dev/specs/pub-sub-video-call.yml similarity index 86% rename from dev/specs/pub_sub_video_call.yml rename to dev/specs/pub-sub-video-call.yml index bf8af54e4..cc51077a2 100644 --- a/dev/specs/pub_sub_video_call.yml +++ b/dev/specs/pub-sub-video-call.yml @@ -8,13 +8,13 @@ spec: credentials: test spec: pipeline: - # Media element which is able to receive media data from client via WebRTC. + # Media element which is able to receive media data from client + # via WebRTC. publish: kind: WebRtcPublishEndpoint spec: # Actually, it receives not media data, but ICE candidates only. p2p: Always - # Media element which is able to play media data for client via WebRTC. responder: kind: Member credentials: test diff --git a/dev/specs/three_members_conference.yml b/dev/specs/three-members-conference.yml similarity index 96% rename from dev/specs/three_members_conference.yml rename to dev/specs/three-members-conference.yml index 34ea7e8f5..ec774bb1c 100644 --- a/dev/specs/three_members_conference.yml +++ b/dev/specs/three-members-conference.yml @@ -8,13 +8,15 @@ spec: credentials: test spec: pipeline: - # Media element which is able to receive media data from client via WebRTC. + # Media element which is able to receive media data from client + # via WebRTC. publish: kind: WebRtcPublishEndpoint spec: # Actually, it receives not media data, but ICE candidates only. p2p: Always - # Media element which is able to play media data for client via WebRTC. + # Media element which is able to play media data for client + # via WebRTC. play: kind: WebRtcPlayEndpoint spec: @@ -40,7 +42,6 @@ spec: kind: WebRtcPlayEndpoint spec: src: "local://three-members-conference/responder2/publish" - responder2: kind: Member credentials: test diff --git a/dev/specs/video_call_1.yml b/dev/specs/video-call-1.yml similarity index 93% rename from dev/specs/video_call_1.yml rename to dev/specs/video-call-1.yml index 936c8d69f..31f413836 100644 --- a/dev/specs/video_call_1.yml +++ b/dev/specs/video-call-1.yml @@ -8,13 +8,15 @@ spec: credentials: test spec: pipeline: - # Media element which is able to receive media data from client via WebRTC. + # Media element which is able to receive media data from client + # via WebRTC. publish: kind: WebRtcPublishEndpoint spec: # Actually, it receives not media data, but ICE candidates only. p2p: Always - # Media element which is able to play media data for client via WebRTC. + # Media element which is able to play media data for client + # via WebRTC. play: kind: WebRtcPlayEndpoint spec: diff --git a/jason/e2e-demo/js/index.js b/jason/e2e-demo/js/index.js index 087a2c81a..d7699954e 100644 --- a/jason/e2e-demo/js/index.js +++ b/jason/e2e-demo/js/index.js @@ -10,7 +10,6 @@ async function f() { caller_room.on_new_connection(function (connection) { connection.on_remote_stream(function (stream) { var video = document.createElement("video"); - video.srcObject = stream.get_media_stream(); document.body.appendChild(video); video.play(); @@ -41,9 +40,7 @@ async function f() { }); responder_room.on_new_connection(function (connection) { connection.on_remote_stream(function (stream) { - var video = document.createElement("video"); - video.srcObject = stream.get_media_stream(); document.body.appendChild(video); video.play(); diff --git a/proto/client-api/Cargo.toml b/proto/client-api/Cargo.toml index 96478304d..ab14aa137 100644 --- a/proto/client-api/Cargo.toml +++ b/proto/client-api/Cargo.toml @@ -18,8 +18,8 @@ jason = [] medea = [] [dependencies] +macro-attr = "0.2" medea-macro = "0.1" +newtype_derive = "0.1" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" -newtype_derive = "0.1" -macro-attr = "0.2" diff --git a/tests/specs/pub_sub_video_call.yml b/tests/specs/pub-sub-video-call.yml similarity index 100% rename from tests/specs/pub_sub_video_call.yml rename to tests/specs/pub-sub-video-call.yml diff --git a/tests/specs/three_members_conference.yml b/tests/specs/three-members-conference.yml similarity index 99% rename from tests/specs/three_members_conference.yml rename to tests/specs/three-members-conference.yml index 8a638c5d0..432d9d92d 100644 --- a/tests/specs/three_members_conference.yml +++ b/tests/specs/three-members-conference.yml @@ -36,7 +36,6 @@ spec: kind: WebRtcPlayEndpoint spec: src: "local://three-members-conference/member-3/publish" - member-3: kind: Member credentials: test From 069bd98522c9b071d16853db6e1e4487d85295bd Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 3 Sep 2019 19:44:46 +0300 Subject: [PATCH 551/735] Create control config section, load static specs path by default --- config.toml | 7 +++++-- src/api/control/mod.rs | 9 +++++---- src/conf/control.rs | 11 +++++++++++ src/conf/mod.rs | 4 ++++ src/conf/server.rs | 3 --- src/lib.rs | 9 +++++++-- 6 files changed, 32 insertions(+), 11 deletions(-) create mode 100644 src/conf/control.rs diff --git a/config.toml b/config.toml index cb83ee233..b49052200 100644 --- a/config.toml +++ b/config.toml @@ -9,11 +9,14 @@ # Default: # bind_port = 8080 + + + +[control] # Path to directory with static control API specs. # # Default: -# static_specs_path = None -static_specs_path = "dev/specs" +# static_specs_path = "./specs/" diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index dc0bc2192..6ae6b08fb 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -19,6 +19,7 @@ pub use self::{ member::{Id as MemberId, MemberSpec}, room::{Id as RoomId, RoomElement, RoomSpec}, }; +use std::fs::ReadDir; #[derive(Clone, Deserialize, Debug)] #[serde(tag = "kind")] @@ -55,12 +56,12 @@ pub fn load_from_yaml_file>(path: P) -> Result { Ok(room) } -/// Load all [`RoomSpec`] from YAML files from provided path. -pub fn load_static_specs_from_dir>( - path: P, +/// Load all [`RoomSpec`] from YAML files from provided [`ReadDir`]. +pub fn load_static_specs_from_dir( + dir: ReadDir, ) -> Result, Error> { let mut specs = Vec::new(); - for entry in std::fs::read_dir(path)? { + for entry in dir { let entry = entry?; let spec = load_from_yaml_file(entry.path())?; specs.push(spec) diff --git a/src/conf/control.rs b/src/conf/control.rs new file mode 100644 index 000000000..2e83f6f99 --- /dev/null +++ b/src/conf/control.rs @@ -0,0 +1,11 @@ +use serde::{Deserialize, Serialize}; +use smart_default::SmartDefault; + +/// Control API settings. +#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, SmartDefault)] +#[serde(default)] +pub struct Control { + /// Path to directory with static control API specs. + #[default(String::from("./specs/"))] + pub static_specs_dir: String, +} diff --git a/src/conf/mod.rs b/src/conf/mod.rs index 4a40cbdf2..73cab1dcd 100644 --- a/src/conf/mod.rs +++ b/src/conf/mod.rs @@ -1,5 +1,6 @@ //! Provides application configuration options. +pub mod control; pub mod log; pub mod rpc; pub mod server; @@ -14,6 +15,7 @@ use serde::{Deserialize, Serialize}; #[doc(inline)] pub use self::{ + control::Control, log::Log, rpc::Rpc, server::Server, @@ -42,6 +44,8 @@ pub struct Conf { pub log: Log, /// Application shutdown settings. pub shutdown: Shutdown, + /// Control API settings. + pub control: Control, } impl Conf { diff --git a/src/conf/server.rs b/src/conf/server.rs index e7e53a99e..fc221cf58 100644 --- a/src/conf/server.rs +++ b/src/conf/server.rs @@ -16,9 +16,6 @@ pub struct Server { /// Port to bind HTTP server to. Defaults to `8080`. #[default(8080)] pub bind_port: u16, - - /// Path to directory with static control API specs. - pub static_specs_path: Option, } impl Server { diff --git a/src/lib.rs b/src/lib.rs index df3360a8e..e37ced2d6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -127,11 +127,12 @@ pub fn start_static_rooms( let graceful_shutdown = GracefulShutdown::new(conf.shutdown.timeout).start(); let config = conf.clone(); - if let Some(static_specs_path) = config.server.static_specs_path.clone() { + let static_specs_path = config.control.static_specs_dir.clone(); + if let Ok(static_specs_dir) = std::fs::read_dir(static_specs_path) { Either::A(service::new_turn_auth_service(&config.turn).map( move |turn_auth_service| { let room_specs = - match load_static_specs_from_dir(static_specs_path) { + match load_static_specs_from_dir(static_specs_dir) { Ok(r) => r, Err(e) => return Err(ServerStartError::LoadSpec(e)), }; @@ -165,6 +166,10 @@ pub fn start_static_rooms( }, )) } else { + warn!( + "'./spec/' dir not found. Static control API specs will not be \ + loaded." + ); Either::B(futures::future::ok(Ok((HashMap::new(), graceful_shutdown)))) } } From 9f2b53f435bed1d85bd8b636a50a1c6ced39d1d9 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 3 Sep 2019 19:48:09 +0300 Subject: [PATCH 552/735] Use dev/config.toml for development --- .env | 2 +- config.toml | 2 +- dev/config.toml | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 dev/config.toml diff --git a/.env b/.env index 5175d17bd..d580fe2b9 100644 --- a/.env +++ b/.env @@ -1,6 +1,6 @@ RUST_LOG=debug -MEDEA_CONF=config.toml +MEDEA_CONF=./dev/config.toml MEDEA_SERVER_STATIC_SPECS_PATH=./dev/specs COMPOSE_PROJECT_NAME=medea diff --git a/config.toml b/config.toml index b49052200..9ab6bdb2f 100644 --- a/config.toml +++ b/config.toml @@ -16,7 +16,7 @@ # Path to directory with static control API specs. # # Default: -# static_specs_path = "./specs/" +# static_specs_dir = "./specs/" diff --git a/dev/config.toml b/dev/config.toml new file mode 100644 index 000000000..cf32cc3dc --- /dev/null +++ b/dev/config.toml @@ -0,0 +1,2 @@ +[control] +static_specs_dir = "dev/specs/" \ No newline at end of file From 7af21d1824b71501a31af122dfbeed34cc324978 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 3 Sep 2019 19:53:15 +0300 Subject: [PATCH 553/735] Refactor travis.yml --- .travis.yml | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1c0dd9ffd..39ac9782c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,13 +7,22 @@ env: cache: cargo -services: - - docker - install: - rustc -vV - cargo -vV +stages: + - name: check + if: (branch = master AND type != pull_request) OR commit_message =~ /.*\[run ci\]/ + - name: build + if: (branch = master AND type != pull_request) OR commit_message =~ /.*\[run ci\]/ + - name: build_beta + if: branch = master + - name: test + if: (branch = master AND type != pull_request) OR commit_message =~ /.*\[run ci\]/ + - name: tests + if: (branch = master AND type != pull_request) OR commit_message =~ /.*\[run ci\]/ + jobs: allow_failures: - rust: nightly @@ -44,10 +53,12 @@ jobs: - name: medea docker (stable) stage: build rust: stable - script: make docker.build.medea debug=no TAG=${TRAVIS_BUILD_ID} registry=quay.io + script: make docker.build.medea debug=no TAG=build-${TRAVIS_BUILD_ID} registry=quay.io + services: + - docker after_script: - echo "$QUAYIO_PASS" | docker login quay.io -u "$QUAYIO_USER" --password-stdin - - docker push quay.io/instrumentisto/medea:${TRAVIS_BUILD_ID} + - docker push quay.io/instrumentisto/medea:build-${TRAVIS_BUILD_ID} - name: medea (beta) stage: build_beta @@ -67,8 +78,10 @@ jobs: - name: e2e signalling (stable) stage: test rust: stable + services: + - docker script: - - make test.e2e dockerized=yes logs=yes TAG=${TRAVIS_BUILD_ID} registry=quay.io + - make test.e2e dockerized=yes logs=yes TAG=build-${TRAVIS_BUILD_ID} registry=quay.io - name: crates.io stage: release @@ -122,18 +135,6 @@ jobs: on: tags: true -stages: - - name: check - if: (branch = master AND type != pull_request) OR commit_message =~ /.*\[run ci\]/ - - name: build - if: (branch = master AND type != pull_request) OR commit_message =~ /.*\[run ci\]/ - - name: build_beta - if: branch = master - - name: test - if: (branch = master AND type != pull_request) OR commit_message =~ /.*\[run ci\]/ - - name: tests - if: (branch = master AND type != pull_request) OR commit_message =~ /.*\[run ci\]/ - notifications: email: on_success: never From 32b8a4779df2f1fbcfde3bd9195b4f532daf802f Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 3 Sep 2019 20:01:51 +0300 Subject: [PATCH 554/735] Fix docker-compose --- .env | 2 +- docker-compose.medea.yml | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.env b/.env index d580fe2b9..06b3fee18 100644 --- a/.env +++ b/.env @@ -1,7 +1,7 @@ RUST_LOG=debug MEDEA_CONF=./dev/config.toml -MEDEA_SERVER_STATIC_SPECS_PATH=./dev/specs +MEDEA_CONTROL_STATIC_SPECS_DIR=./dev/specs COMPOSE_PROJECT_NAME=medea COMPOSE_IMAGE_NAME=instrumentisto/medea diff --git a/docker-compose.medea.yml b/docker-compose.medea.yml index cd9c501d3..c1ab030b4 100644 --- a/docker-compose.medea.yml +++ b/docker-compose.medea.yml @@ -7,10 +7,10 @@ services: ports: - "8080:8080" volumes: - - ${MEDEA_SERVER_STATIC_SPECS_PATH}:/specs - - ./config.toml:/config.toml + - ${MEDEA_CONTROL_STATIC_SPECS_DIR}:/specs:ro + - ./dev/config.toml:/dev/config.toml:ro network_mode: "host" environment: RUST_LOG: ${RUST_LOG} - MEDEA_CONF: "config.toml" - MEDEA_SERVER.STATIC_SPECS_PATH: /specs + MEDEA_CONF: "./dev/config.toml" + MEDEA_CONTROL.STATIC_SPECS_DIR: /specs From 1fd1d9357ec7c39843caa3bc68f82e8f1fbf0b63 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 3 Sep 2019 20:03:56 +0300 Subject: [PATCH 555/735] Fix Incrementable trait --- proto/client-api/src/lib.rs | 4 ++-- src/signalling/peers.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/proto/client-api/src/lib.rs b/proto/client-api/src/lib.rs index c9029a3e6..a8faf35b5 100644 --- a/proto/client-api/src/lib.rs +++ b/proto/client-api/src/lib.rs @@ -33,14 +33,14 @@ macro_attr! { #[cfg(feature = "medea")] pub trait Incrementable: Sized + Clone { /// Returns current value + 1. - fn increment(&self) -> Self; + fn incr(&self) -> Self; } /// Implement [`Incrementable`] trait for newtype with any numeric type. macro_rules! impl_incrementable { ($name:ty) => { impl Incrementable for $name { - fn increment(&self) -> Self { + fn incr(&self) -> Self { Self(self.0 + 1) } } diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index 7c27151e8..efe58b24f 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -48,7 +48,7 @@ impl Counter { /// Returns id and increase counter. pub fn next_id(&mut self) -> T { let id = self.count; - self.count = self.count.increment(); + self.count = self.count.incr(); id } From 77f8cdd7f80e095cf07e377dca6b4b8b5bdc32c2 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 3 Sep 2019 20:16:18 +0300 Subject: [PATCH 556/735] Refactor Makefile [run ci] --- .travis.yml | 4 ++-- Makefile | 42 +++++++++++++++++++++++++++++------------- 2 files changed, 31 insertions(+), 15 deletions(-) diff --git a/.travis.yml b/.travis.yml index 39ac9782c..2871ba330 100644 --- a/.travis.yml +++ b/.travis.yml @@ -63,12 +63,12 @@ jobs: - name: medea (beta) stage: build_beta rust: beta - script: make build.medea + script: make cargo.build crate=medea - name: medea (nightly) stage: build_beta rust: nightly - script: make build.medea + script: make cargo.build crate=medea - name: unit (stable) stage: test diff --git a/Makefile b/Makefile index e7ab3f035..34f0a2d61 100644 --- a/Makefile +++ b/Makefile @@ -628,12 +628,16 @@ endef # Building # ############ -# Build medea. +# Build medea's related crates. # # Usage: -# make build.medea [dockerized=(NO|yes)] [release=(NO|yes)] - -build.medea: +# make build crate=(medea|medea-jason|@all) [dockerized=(yes|no) +cargo.build: +ifeq ($(crate),@all) + @make build crate=medea + @make build crate=medea-jason +endif +ifeq ($(crate),medea) ifneq ($(dockerized),yes) cargo build --bin medea $(if $(call eq,$(release),yes),--release) else @@ -645,14 +649,8 @@ else rust:$(RUST_VER) \ make build.medea release=$(release) endif - - -# Build jason. -# -# Usage: -# make build.jason [dockerized=(no|yes)] - -build.jason: +endif +ifeq ($(crate),medea-jason) ifneq ($(dockerized),yes) wasm-pack build -t web jason else @@ -666,8 +664,26 @@ else rust:$(RUST_VER) \ sh -c "curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh && make build.jason" endif +endif +# Build medea. +# +# Usage: +# make build.medea [dockerized=(NO|yes)] [release=(NO|yes)] + +build.medea: + make cargo.build crate=medea + + +# Build jason. +# +# Usage: +# make build.jason [dockerized=(no|yes)] + +build.jason: + make cargo.build crate=medea-jason + ################## @@ -686,5 +702,5 @@ endif release release.crates release.helm release.npm \ test test.unit test.e2e \ up up.coturn up.demo up.dev up.jason up.medea \ - build build.medea build.jason \ + cargo.build build.medea build.jason \ yarn From cf41984e45cddad484599f817dc69d62de79598c Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 4 Sep 2019 01:17:21 +0300 Subject: [PATCH 557/735] Fix tests [run ci] --- Makefile | 4 ++-- src/api/client/server.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 34f0a2d61..8ab5ece11 100644 --- a/Makefile +++ b/Makefile @@ -302,8 +302,8 @@ endif medea-env = RUST_BACKTRACE=1 \ $(if $(call eq,$(logs),yes),,RUST_LOG=warn) \ - MEDEA_SERVER.STATIC_SPECS_PATH=./tests/specs \ - MEDEA_SERVER_STATIC_SPECS_PATH=./tests/specs + MEDEA_CONTROL.STATIC_SPECS_DIR=./tests/specs \ + MEDEA_CONTROL_STATIC_SPECS_DIR=./tests/specs test.e2e: -@make down diff --git a/src/api/client/server.rs b/src/api/client/server.rs index 5f9be91da..48c25c37b 100644 --- a/src/api/client/server.rs +++ b/src/api/client/server.rs @@ -156,7 +156,7 @@ mod test { /// Creates [`RoomsRepository`] for tests filled with a single [`Room`]. fn room(conf: Rpc) -> RoomsRepository { let room_spec = - control::load_from_yaml_file("tests/specs/pub_sub_video_call.yml") + control::load_from_yaml_file("tests/specs/pub-sub-video-call.yml") .unwrap(); let room_id = room_spec.id.clone(); From 9353d5d4d873246c387310efd16eb82d52a99c99 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 4 Sep 2019 01:25:15 +0300 Subject: [PATCH 558/735] Use derive_more Display in medea-client-api-proto [run ci] --- Cargo.lock | 3 +-- proto/client-api/Cargo.toml | 3 +-- proto/client-api/src/lib.rs | 41 ++++++++++++++++--------------------- 3 files changed, 20 insertions(+), 27 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6578fe2da..a518ccf43 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1069,9 +1069,8 @@ dependencies = [ name = "medea-client-api-proto" version = "0.1.0" dependencies = [ - "macro-attr 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", "medea-macro 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "newtype_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", ] diff --git a/proto/client-api/Cargo.toml b/proto/client-api/Cargo.toml index ab14aa137..4be54b21c 100644 --- a/proto/client-api/Cargo.toml +++ b/proto/client-api/Cargo.toml @@ -18,8 +18,7 @@ jason = [] medea = [] [dependencies] -macro-attr = "0.2" +derive_more = "0.15" medea-macro = "0.1" -newtype_derive = "0.1" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" diff --git a/proto/client-api/src/lib.rs b/proto/client-api/src/lib.rs index a8faf35b5..08f5d4962 100644 --- a/proto/client-api/src/lib.rs +++ b/proto/client-api/src/lib.rs @@ -2,32 +2,27 @@ use std::collections::HashMap; -use macro_attr::*; +use derive_more::Display; use medea_macro::dispatchable; -use newtype_derive::*; use serde::{de::Deserializer, ser::Serializer, Deserialize, Serialize}; -macro_attr! { - /// ID of [`Peer`]. - #[cfg_attr( - feature = "medea", - derive(Deserialize, Debug, Hash, Eq, Default, PartialEq) - )] - #[cfg_attr(feature = "jason", derive(Serialize))] - #[derive(Clone, Copy, NewtypeDisplay!)] - pub struct PeerId(pub u64); -} - -macro_attr! { - /// ID of [`MediaTrack`]. - #[cfg_attr( - feature = "medea", - derive(Deserialize, Debug, Hash, Eq, Default, PartialEq) - )] - #[cfg_attr(feature = "jason", derive(Serialize))] - #[derive(Clone, Copy, NewtypeDisplay!)] - pub struct TrackId(pub u64); -} +/// ID of [`Peer`]. +#[cfg_attr( + feature = "medea", + derive(Deserialize, Debug, Hash, Eq, Default, PartialEq) +)] +#[cfg_attr(feature = "jason", derive(Serialize))] +#[derive(Clone, Copy, Display)] +pub struct PeerId(pub u64); + +/// ID of [`MediaTrack`]. +#[cfg_attr( + feature = "medea", + derive(Deserialize, Debug, Hash, Eq, Default, PartialEq) +)] +#[cfg_attr(feature = "jason", derive(Serialize))] +#[derive(Clone, Copy, Display)] +pub struct TrackId(pub u64); /// Trait for providing function `increment()` which return current value + 1. #[cfg(feature = "medea")] From 7936eeaceaf4ce3a4d6803123a37719bceca5a51 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 4 Sep 2019 12:46:40 +0300 Subject: [PATCH 559/735] Remove old hardcoded environment vars from .travis-ci [run ci] --- .travis.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2871ba330..5a3df1528 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,5 @@ language: rust -env: - global: - - secure: O14lnD45q3oyuMtKU7Jfy1e+LSs91UZPnNuTPT9IZNoHPgJM77mdK1bwu5SqSXpmDEaq3uQBBhIKEKxiOgogiRAGcALnjSLIe02qrw8kR4hhB7IsuCsfJA3rgnH5NrSxV2ja5wHUkTtYORIB30GX/SU4qNw8C+HeAcXDaxPRNJYuIkE41jW121PDgheS7Ti49ui5JOKss/FdpI8Ii5xXvNf9Z60MSJKPsM8yaj+RiqDccXrFuyppVE/Ezn95gdJh1Sr7BUaP521FOhOYl4bvMEV0pHHMwaPD0b2Ku0yJ+GrZiZ2YqTmsNiaa4hN2AAv38w46KfhQuvJg173cEGf6hCrrF+IOQvmGG977xSO7tci2l5idjIZ1xtXsLQ9Yp49DBxd1s2I20j+fHmCImH1cV4+hEnMTQLITzemS3MkHIxbEgcMyssjZD7FASNU1C3fbeeHEG3JPM/hHj0mlGlhv7T54gL5Q7Qggnj+xsE44yU18bP0K/G48QBLeXDSfZzeaCbrif9bALAVnUMhRMSuW9EfOHcu7juaBAj5mPxWfN4CoQgqBFPh+V+q6+WViV0/5djoKlrOy323hNTg+CXIqWn9RYIbxbyRMGXIU6Z78Sr6Yls+8tK1cpdXOzQ6CMeUJh2H264hFMM1ZGvlQ+VYqRYMCViuVW4Aofuqr1zfsnz0= - - secure: xm+WIGYVoYvjAlWOaoli0YZ4LMFBKd7pG0qno4zrDMGrz1AwLRK6dce0+ROvIdEcuOror2j4wryYgDRMLYgxzhXeMMVFkxZuB1MmeC8VHirf0jNHNNihWwnEyTDGtj5VXijD/ipo4jiskBZEsg/oW97iFUudjl/rNT2R0Gy420QgGV4p3m9jTjBBL6giIQUNK0g+5aIkCfb4U/4gcpFA5nZJgyfQtnKKmVnEPl26vbU+Ui7F/wqTK0a7AJT3RCaEddtu7E5DKNnk4/45e4//LKNEE8I2KGqWlqWXqFYs+Cno1trDOcKm0yiTIquvbZsrOuH7wN1il4qVcsdgQLps2kFahpJyQJbJJViBkbqnlwRJDnxtszbrxSGW6HiVMSSd8AOthwJd3n7lMkBDwrwG9Dx7MiNY/NIdRxufEuoOw/6tj31oBJhM1s+/Fhjzlz0j5R5spTtcaNg6Q0Gi+F283jjwvobIzvUUKKSt4I1UZLTQNSzxrWTJZ4kJBG1JiTxH7BwHMtxhiaZn5ajk5HfVXScmBknZIovsylj5UXp1d5IhXUNq4jTXTdybOurhQ1XLVz/hw64oOIQkuftaNHuQMe3oB69aWLWpS6+r3k1ZCT/WODbS3xlhp/MXO3WLD4WY1OWJ522t/YOUQX3j72bZADlQOcU/OWQ5LWNC3XGibrk= - cache: cargo install: From 709b0be5cfe7f786d79f3cfbdbb981188f672d66 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 4 Sep 2019 15:00:47 +0300 Subject: [PATCH 560/735] Fix demo app --- jason/demo/docker-compose.yml | 4 +++- jason/demo/index.html | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/jason/demo/docker-compose.yml b/jason/demo/docker-compose.yml index b35e87d11..0e75ce46f 100644 --- a/jason/demo/docker-compose.yml +++ b/jason/demo/docker-compose.yml @@ -15,7 +15,9 @@ services: image: instrumentisto/medea:dev depends_on: ["coturn-db"] environment: - MEDEA_LOG.LEVEL: "DEBUG" + RUST_LOG: "DEBUG" + volumes: + - ../../dev/specs:/specs:ro network_mode: service:web-client coturn: container_name: demo-coturn diff --git a/jason/demo/index.html b/jason/demo/index.html index d3ea3da5e..f509b01b4 100644 --- a/jason/demo/index.html +++ b/jason/demo/index.html @@ -63,10 +63,10 @@ var bindJoinButtons = function (roomId) { joinCallerButton.onclick = function () { - window.connect_room(baseUrl + roomId + '/1/caller_credentials') + window.connect_room(baseUrl + roomId + '/caller/test') }; joinResponderButton.onclick = function () { - window.connect_room(baseUrl + roomId + '/2/responder_credentials') + window.connect_room(baseUrl + roomId + '/responder/test') }; }; From 2b0432819bb891d90eaacaddf6393a22026c1d02 Mon Sep 17 00:00:00 2001 From: tyranron Date: Thu, 5 Sep 2019 12:08:50 +0300 Subject: [PATCH 561/735] Corrections to Docker Compose env --- .env | 3 +-- Makefile | 10 ++++------ config.toml | 4 ++-- dev/config.toml | 2 -- docker-compose.medea.yml | 10 ++++------ proto/client-api/src/lib.rs | 4 ++-- tests/e2e/signalling/mod.rs | 2 +- 7 files changed, 14 insertions(+), 21 deletions(-) diff --git a/.env b/.env index 06b3fee18..81835986d 100644 --- a/.env +++ b/.env @@ -1,7 +1,6 @@ RUST_LOG=debug -MEDEA_CONF=./dev/config.toml -MEDEA_CONTROL_STATIC_SPECS_DIR=./dev/specs +MEDEA_CONF=config.toml COMPOSE_PROJECT_NAME=medea COMPOSE_IMAGE_NAME=instrumentisto/medea diff --git a/Makefile b/Makefile index 8ab5ece11..bccf59691 100644 --- a/Makefile +++ b/Makefile @@ -690,17 +690,15 @@ build.jason: # .PHONY section # ################## -.PHONY: build \ - cargo cargo.fmt cargo.lint \ +.PHONY: build build.jason build.medea \ + cargo cargo.build cargo.fmt cargo.lint \ docker.build.demo docker.build.medea docker.down.demo docker.up.demo \ docs docs.rust \ - down.demo \ + down down.demo down.coturn down.medea \ helm helm.down helm.init helm.lint helm.list \ helm.package helm.package.release helm.up \ minikube.boot \ - down down.medea down.coturn \ release release.crates release.helm release.npm \ - test test.unit test.e2e \ + test test.e2e test.unit \ up up.coturn up.demo up.dev up.jason up.medea \ - cargo.build build.medea build.jason \ yarn diff --git a/config.toml b/config.toml index 9ab6bdb2f..977635414 100644 --- a/config.toml +++ b/config.toml @@ -13,10 +13,10 @@ [control] -# Path to directory with static control API specs. +# Path to directory with static Сontrol API specs. # # Default: -# static_specs_dir = "./specs/" +# static_specs_dir = "specs/" diff --git a/dev/config.toml b/dev/config.toml index cf32cc3dc..e69de29bb 100644 --- a/dev/config.toml +++ b/dev/config.toml @@ -1,2 +0,0 @@ -[control] -static_specs_dir = "dev/specs/" \ No newline at end of file diff --git a/docker-compose.medea.yml b/docker-compose.medea.yml index c1ab030b4..9d134f8b0 100644 --- a/docker-compose.medea.yml +++ b/docker-compose.medea.yml @@ -6,11 +6,9 @@ services: image: ${COMPOSE_IMAGE_NAME}:${COMPOSE_IMAGE_VER} ports: - "8080:8080" - volumes: - - ${MEDEA_CONTROL_STATIC_SPECS_DIR}:/specs:ro - - ./dev/config.toml:/dev/config.toml:ro - network_mode: "host" environment: RUST_LOG: ${RUST_LOG} - MEDEA_CONF: "./dev/config.toml" - MEDEA_CONTROL.STATIC_SPECS_DIR: /specs + volumes: + - ./dev/config.toml:/config.toml:ro + - ./dev/specs:/specs:ro + network_mode: host diff --git a/proto/client-api/src/lib.rs b/proto/client-api/src/lib.rs index 08f5d4962..5253644c6 100644 --- a/proto/client-api/src/lib.rs +++ b/proto/client-api/src/lib.rs @@ -24,14 +24,14 @@ pub struct PeerId(pub u64); #[derive(Clone, Copy, Display)] pub struct TrackId(pub u64); -/// Trait for providing function `increment()` which return current value + 1. +/// Value that is able to be incremented by `1`. #[cfg(feature = "medea")] pub trait Incrementable: Sized + Clone { /// Returns current value + 1. fn incr(&self) -> Self; } -/// Implement [`Incrementable`] trait for newtype with any numeric type. +/// Implements [`Incrementable`] trait for newtype with any numeric type. macro_rules! impl_incrementable { ($name:ty) => { impl Incrementable for $name { diff --git a/tests/e2e/signalling/mod.rs b/tests/e2e/signalling/mod.rs index 22eda9b4d..eadeaf8eb 100644 --- a/tests/e2e/signalling/mod.rs +++ b/tests/e2e/signalling/mod.rs @@ -1,4 +1,4 @@ -//! Signalling API e2e tests. +//! Signalling API E2E tests. mod pub_sub_signallng; mod three_pubs; From d5b02f272b364980e33da00769f371287c6d72ba Mon Sep 17 00:00:00 2001 From: tyranron Date: Thu, 5 Sep 2019 12:35:36 +0300 Subject: [PATCH 562/735] Corrections to code style --- Cargo.lock | 8 ++++---- jason/CHANGELOG.md | 6 ++---- jason/Cargo.toml | 2 +- jason/src/media/track.rs | 4 +--- proto/client-api/CHANGELOG.md | 10 ++++------ proto/client-api/Cargo.toml | 2 +- src/conf/control.rs | 2 +- src/signalling/peers.rs | 1 - 8 files changed, 14 insertions(+), 21 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a518ccf43..50f8574c9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1041,7 +1041,7 @@ dependencies = [ "humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "humantime-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "macro-attr 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "medea-client-api-proto 0.1.0", + "medea-client-api-proto 0.1.1-dev", "medea-macro 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "newtype_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1067,7 +1067,7 @@ dependencies = [ [[package]] name = "medea-client-api-proto" -version = "0.1.0" +version = "0.1.1-dev" dependencies = [ "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", "medea-macro 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1077,13 +1077,13 @@ dependencies = [ [[package]] name = "medea-jason" -version = "0.1.0" +version = "0.1.1-dev" dependencies = [ "console_error_panic_hook 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "js-sys 0.3.27 (registry+https://github.com/rust-lang/crates.io-index)", "macro-attr 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "medea-client-api-proto 0.1.0", + "medea-client-api-proto 0.1.1-dev", "medea-macro 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "newtype_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/jason/CHANGELOG.md b/jason/CHANGELOG.md index bb1a9a9ba..cc7a01ff4 100644 --- a/jason/CHANGELOG.md +++ b/jason/CHANGELOG.md @@ -6,10 +6,8 @@ All user visible changes to this project will be documented in this file. This p -## TBD [0.2.0] · 2019-??-?? -[0.2.0]: /../../tree/medea-jason-0.2.0/jason - -[Milestone](/../../milestone/2) | [Roadmap](/../../issues/27) +## TBD [0.1.1] · 2019-??-?? +[0.1.1]: /../../tree/medea-jason-0.1.1/jason ### Changed diff --git a/jason/Cargo.toml b/jason/Cargo.toml index 999de5572..2a7308ef4 100644 --- a/jason/Cargo.toml +++ b/jason/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "medea-jason" -version = "0.1.0" +version = "0.1.1-dev" edition = "2018" description = "Client library for Medea media server" authors = ["Instrumentisto Team "] diff --git a/jason/src/media/track.rs b/jason/src/media/track.rs index 9ea8bf1c8..32e5463f3 100644 --- a/jason/src/media/track.rs +++ b/jason/src/media/track.rs @@ -4,11 +4,9 @@ use std::rc::Rc; -use medea_client_api_proto::MediaType; +use medea_client_api_proto::{MediaType, TrackId as Id}; use web_sys::MediaStreamTrack; -use medea_client_api_proto::TrackId as Id; - /// Representation of [MediaStreamTrack][1]. /// /// [1]: https://www.w3.org/TR/mediacapture-streams/#mediastreamtrack diff --git a/proto/client-api/CHANGELOG.md b/proto/client-api/CHANGELOG.md index d66ccaa80..32c8174e6 100644 --- a/proto/client-api/CHANGELOG.md +++ b/proto/client-api/CHANGELOG.md @@ -6,15 +6,13 @@ All user visible changes to this project will be documented in this file. This p -## TBD [0.2.0] · 2019-??-?? -[0.2.0]: /../../tree/medea-client-api-proto-0.2.0/proto/client-api - -[Milestone](/../../milestone/2) | [Roadmap](/../../issues/27) +## TBD [0.1.1] · 2019-??-?? +[0.1.1]: /../../tree/medea-client-api-proto-0.1.1/proto/client-api ### Added -- `TrackId` and `PeerId` ([#28]) -- `Incrementable` trait ([#28]) +- `TrackId` and `PeerId` types ([#28]); +- `Incrementable` trait ([#28]). [#28]: /../../pull/28 diff --git a/proto/client-api/Cargo.toml b/proto/client-api/Cargo.toml index 4be54b21c..63a028a7a 100644 --- a/proto/client-api/Cargo.toml +++ b/proto/client-api/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "medea-client-api-proto" -version = "0.1.0" +version = "0.1.1-dev" edition = "2018" description = "Client API protocol implementation for Medea media server" authors = ["Instrumentisto Team "] diff --git a/src/conf/control.rs b/src/conf/control.rs index 2e83f6f99..8bceecdcb 100644 --- a/src/conf/control.rs +++ b/src/conf/control.rs @@ -5,7 +5,7 @@ use smart_default::SmartDefault; #[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, SmartDefault)] #[serde(default)] pub struct Control { - /// Path to directory with static control API specs. + /// Path to directory with static Сontrol API specs. #[default(String::from("./specs/"))] pub static_specs_dir: String, } diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index efe58b24f..32ac935a1 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -49,7 +49,6 @@ impl Counter { pub fn next_id(&mut self) -> T { let id = self.count; self.count = self.count.incr(); - id } } From 301a26e5d45a3f69c9a02634b32a5ec289fa5d0e Mon Sep 17 00:00:00 2001 From: tyranron Date: Thu, 5 Sep 2019 12:45:13 +0300 Subject: [PATCH 563/735] Revert Docker Compose env changes and correct medea crate version --- .env | 2 +- .travis.yml | 1 - CHANGELOG.md | 7 +++---- Cargo.lock | 2 +- Cargo.toml | 2 +- dev/config.toml | 2 ++ docker-compose.medea.yml | 9 +++++---- 7 files changed, 13 insertions(+), 12 deletions(-) diff --git a/.env b/.env index 81835986d..62d565cb0 100644 --- a/.env +++ b/.env @@ -1,6 +1,6 @@ RUST_LOG=debug -MEDEA_CONF=config.toml +MEDEA_CONF=dev/config.toml COMPOSE_PROJECT_NAME=medea COMPOSE_IMAGE_NAME=instrumentisto/medea diff --git a/.travis.yml b/.travis.yml index 5a3df1528..c6c412f8a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,4 @@ language: rust - cache: cargo install: diff --git a/CHANGELOG.md b/CHANGELOG.md index a8d573d93..210e0728b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,11 +14,10 @@ All user visible changes to this project will be documented in this file. This p ### Added - Control API: - - Parse static control api specs ([#28]); - - Created interior entities for control API specs ([#28]). + - Support for static Сontrol API specs ([#28]). - Signalling: - - Dynamic `Peer`s creation when client connect ([#28]); - - Auto removing `Peer`s when `Member` disconnect ([#28]). + - Dynamic `Peer`s creation when client connects ([#28]); + - Auto-removing `Peer`s when `Member` disconnects ([#28]). - Testing: - E2E tests for signalling ([#28]). diff --git a/Cargo.lock b/Cargo.lock index 50f8574c9..6b3a9525c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1022,7 +1022,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "medea" -version = "0.1.0" +version = "0.2.0-dev" dependencies = [ "actix 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)", "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index 578763d6f..defa6dcea 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "medea" -version = "0.1.0" +version = "0.2.0-dev" edition = "2018" description = "Medea media server" authors = ["Instrumentisto Team "] diff --git a/dev/config.toml b/dev/config.toml index e69de29bb..c69db4582 100644 --- a/dev/config.toml +++ b/dev/config.toml @@ -0,0 +1,2 @@ +[control] +static_specs_dir = "dev/specs/" diff --git a/docker-compose.medea.yml b/docker-compose.medea.yml index 9d134f8b0..570851008 100644 --- a/docker-compose.medea.yml +++ b/docker-compose.medea.yml @@ -4,11 +4,12 @@ services: medea: container_name: ${COMPOSE_PROJECT_NAME}-backend image: ${COMPOSE_IMAGE_NAME}:${COMPOSE_IMAGE_VER} - ports: - - "8080:8080" environment: RUST_LOG: ${RUST_LOG} + MEDEA_CONF: ${MEDEA_CONF} + ports: + - "8080:8080" volumes: - - ./dev/config.toml:/config.toml:ro - - ./dev/specs:/specs:ro + - ./dev/config.toml:/dev/config.toml:ro + - ./dev/specs:/dev/specs:ro network_mode: host From 5f46c5f817687dbfc6f43a6acab3dc770cdba868 Mon Sep 17 00:00:00 2001 From: tyranron Date: Thu, 5 Sep 2019 13:52:44 +0300 Subject: [PATCH 564/735] Some code style corrections --- src/api/control/endpoint.rs | 140 ++++++++++++++++-------------------- src/api/control/mod.rs | 10 +-- src/api/control/pipeline.rs | 5 +- src/lib.rs | 4 +- src/signalling/room.rs | 5 +- 5 files changed, 77 insertions(+), 87 deletions(-) diff --git a/src/api/control/endpoint.rs b/src/api/control/endpoint.rs index 2cc718769..2a78e8544 100644 --- a/src/api/control/endpoint.rs +++ b/src/api/control/endpoint.rs @@ -12,16 +12,17 @@ use crate::api::control::MemberId; use super::{member::MemberElement, TryFromElementError}; -/// [`Endpoint`] represents a media element that one or more media data streams -/// flow through. +/// Media element that one or more media data streams flow through. #[derive(Debug)] pub enum Endpoint { WebRtcPublish(WebRtcPublishEndpoint), WebRtcPlay(WebRtcPlayEndpoint), } +/// Possible schemes of media elements URIs. #[derive(Clone, Debug)] pub enum Scheme { + /// `local://` scheme which refers to a local in-memory media element. Local, } @@ -89,8 +90,8 @@ pub struct SrcUri { pub endpoint_id: String, } -/// Serde deserializer for [`SrcUri`]. -/// Deserialize URIs with pattern `local://{room_id}/{member_id}/{endpoint_id}`. +/// Deserialization for [`SrcUri`] with pattern +/// `local://{room_id}/{member_id}/{endpoint_id}`. impl<'de> Deserialize<'de> for SrcUri { fn deserialize(deserializer: D) -> Result where @@ -103,7 +104,7 @@ impl<'de> Deserialize<'de> for SrcUri { fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { formatter.write_str( - "Uri in format local://room_id/member_id/endpoint_id", + "URI in format local://room_id/member_id/endpoint_id", ) } @@ -112,58 +113,45 @@ impl<'de> Deserialize<'de> for SrcUri { E: de::Error, { let uri = Url::parse(value).map_err(|_| { - Error::custom(format!("'{}' is not URL", value)) + Error::custom(format!("'{}' is not URI", value)) })?; - - let scheme = match FromStr::from_str(uri.scheme()) { - Ok(scheme) => scheme, - Err(_) => { - return Err(Error::custom(format!( - "cannot parse uri scheme \"{}\"", - value - ))) - } - }; - let room_id = match uri.host() { - Some(host) => host.to_string(), - None => { - return Err(Error::custom(format!( - "cannot parse uri scheme \"{}\"", - value - ))) - } - }; - - let mut path = match uri.path_segments() { - Some(path) => path, - None => { - return Err(Error::custom(format!( - "cannot parse uri segments \"{}\"", - value - ))) - } - }; - - let member_id = match path.next() { - Some(member_id) => MemberId(member_id.to_owned()), - None => { - return Err(Error::custom(format!( - "cannot parse member_id \"{}\"", + let scheme = FromStr::from_str(uri.scheme()).map_err(|_| { + Error::custom(format!( + "cannot parse URI scheme '{}'", + value + )) + })?; + let room_id = uri + .host() + .ok_or_else(|| { + Error::custom(format!( + "cannot parse room ID from URI '{}'", value - ))) - } - }; - - let endpoint_id = match path.next() { - Some(endpoint_id) => endpoint_id.to_owned(), - None => { - return Err(Error::custom(format!( - "cannot parse endpoint_id \"{}\"", + )) + })? + .to_string(); + let mut path = uri.path_segments().ok_or_else(|| { + Error::custom(format!( + "cannot parse member and endpoint IDs from URI '{}'", + value + )) + })?; + let member_id = path + .next() + .map(|id| MemberId(id.to_owned())) + .ok_or_else(|| { + Error::custom(format!( + "cannot parse member ID from URI '{}'", + value + )) + })?; + let endpoint_id = + path.next().map(ToOwned::to_owned).ok_or_else(|| { + Error::custom(format!( + "cannot parse endpoint ID from URI '{}'", value - ))) - } - }; - + )) + })?; Ok(SrcUri { scheme, room_id, @@ -189,34 +177,32 @@ mod src_uri_deserialization_tests { } #[test] - fn deserialize() { - let valid_json_uri = - r#"{ "src": "local://room_id/member_id/endpoint_id" }"#; - let local_uri: SrcUriTest = - serde_json::from_str(valid_json_uri).unwrap(); - - assert_eq!( - local_uri.src.member_id, - MemberId(String::from("member_id")) - ); - assert_eq!(local_uri.src.room_id, String::from("room_id")); - assert_eq!(local_uri.src.endpoint_id, String::from("endpoint_id")); + fn deserializes() { + let uri: SrcUriTest = serde_json::from_str( + r#"{ "src": "local://room_id/member_id/endpoint_id" }"#, + ) + .unwrap(); + + assert_eq!(uri.src.member_id, MemberId("member_id".into())); + assert_eq!(uri.src.room_id, "room_id".to_string()); + assert_eq!(uri.src.endpoint_id, "endpoint_id".to_string()); } #[test] - fn return_error_when_uri_not_local() { - let invalid_json_uri = - r#"{ "src": "not_local://room_id/member_id/endpoint_id" }"#; - if serde_json::from_str::(invalid_json_uri).is_ok() { - unreachable!() - } + fn errors_on_incorrect_scheme() { + let res = serde_json::from_str::( + r#"{ "src": "not_local://room_id/member_id/endpoint_id" }"#, + ); + + assert!(res.is_err()) } #[test] - fn return_error_when_uri_is_not_full() { - let invalid_json_uri = r#"{ "src": "local://room_id/member_id" }"#; - if serde_json::from_str::(invalid_json_uri).is_ok() { - unreachable!() - } + fn errors_when_endpoint_is_absent() { + let res = serde_json::from_str::( + r#"{ "src": "local://room_id/member_id" }"#, + ); + + assert!(res.is_err()) } } diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index 6ae6b08fb..d706654f0 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -7,7 +7,12 @@ pub mod member; pub mod pipeline; pub mod room; -use std::{convert::TryFrom as _, fs::File, io::Read as _, path::Path}; +use std::{ + convert::TryFrom as _, + fs::{File, ReadDir}, + io::Read as _, + path::Path, +}; use failure::{Error, Fail}; use serde::Deserialize; @@ -19,7 +24,6 @@ pub use self::{ member::{Id as MemberId, MemberSpec}, room::{Id as RoomId, RoomElement, RoomSpec}, }; -use std::fs::ReadDir; #[derive(Clone, Deserialize, Debug)] #[serde(tag = "kind")] @@ -52,7 +56,6 @@ pub fn load_from_yaml_file>(path: P) -> Result { file.read_to_string(&mut buf)?; let parsed: RootElement = serde_yaml::from_str(&buf)?; let room = RoomSpec::try_from(&parsed)?; - Ok(room) } @@ -66,6 +69,5 @@ pub fn load_static_specs_from_dir( let spec = load_from_yaml_file(entry.path())?; specs.push(spec) } - Ok(specs) } diff --git a/src/api/control/pipeline.rs b/src/api/control/pipeline.rs index 59e41dba3..66d773235 100644 --- a/src/api/control/pipeline.rs +++ b/src/api/control/pipeline.rs @@ -14,19 +14,22 @@ pub struct Pipeline { } impl Pipeline { + #[inline] pub fn iter(&self) -> impl Iterator { self.into_iter() } + #[inline] pub fn get(&self, id: &str) -> Option<&T> { self.pipeline.get(id) } } impl<'a, T> IntoIterator for &'a Pipeline { - type IntoIter = Iter<'a, String, T>; type Item = (&'a String, &'a T); + type IntoIter = Iter<'a, String, T>; + #[inline] fn into_iter(self) -> Self::IntoIter { self.pipeline.iter() } diff --git a/src/lib.rs b/src/lib.rs index e37ced2d6..36b210d04 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -167,8 +167,8 @@ pub fn start_static_rooms( )) } else { warn!( - "'./spec/' dir not found. Static control API specs will not be \ - loaded." + "'{}' dir not found. Static Control API specs will not be loaded.", + static_specs_path ); Either::B(futures::future::ok(Ok((HashMap::new(), graceful_shutdown)))) } diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 2835278af..fc04e1d3d 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -11,7 +11,6 @@ use actix::{ }; use failure::Fail; use futures::future; - use medea_client_api_proto::{Command, Event, IceCandidate, PeerId, TrackId}; use crate::{ @@ -74,13 +73,13 @@ impl From for RoomError { impl From for RoomError { fn from(err: TryFromElementError) -> Self { - Self::BadRoomSpec(format!("Element located in wrong place. {}", err)) + Self::BadRoomSpec(format!("Element located in wrong place: {}", err)) } } impl From for RoomError { fn from(err: MembersLoadError) -> Self { - Self::BadRoomSpec(format!("Error while loading room spec. {}", err)) + Self::BadRoomSpec(format!("Error while loading room spec: {}", err)) } } From 564eb1536c1cb996a68bd199fa39bcc1717ac9a5 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 5 Sep 2019 15:20:16 +0300 Subject: [PATCH 565/735] Use derive_more, remove macro_attr and newtype_derive crates --- Cargo.lock | 3 +-- Cargo.toml | 3 +-- src/api/client/rpc_connection.rs | 22 ++++++++----------- src/api/control/member.rs | 20 ++++------------- src/api/control/pipeline.rs | 2 +- src/api/control/room.rs | 20 ++++------------- src/lib.rs | 2 +- .../endpoints/webrtc/play_endpoint.rs | 11 ++++------ .../endpoints/webrtc/publish_endpoint.rs | 11 ++++------ 9 files changed, 29 insertions(+), 65 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6b3a9525c..19f367d20 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1035,15 +1035,14 @@ dependencies = [ "bb8-redis 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "chrono 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "config 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", "dotenv 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "humantime-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "macro-attr 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "medea-client-api-proto 0.1.1-dev", "medea-macro 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "newtype_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "redis 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index defa6dcea..b3f5c21b4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,14 +32,13 @@ bb8-redis = "0.3" chrono = "0.4" config = "0.9" dotenv = "0.14" +derive_more = "0.15" failure = "0.1" futures = "0.1" humantime = "1.2" humantime-serde = "0.1" -macro-attr = "0.2" medea-client-api-proto = { path = "proto/client-api", features = ["medea"] } medea-macro = "0.1" -newtype_derive = "0.1" rand = "0.7" redis = "0.11" rust-crypto = "0.2" diff --git a/src/api/client/rpc_connection.rs b/src/api/client/rpc_connection.rs index 841f7a0a2..2c4f5002a 100644 --- a/src/api/client/rpc_connection.rs +++ b/src/api/client/rpc_connection.rs @@ -5,24 +5,20 @@ use std::fmt; use actix::Message; +use derive_more::{From, Into}; use futures::Future; -use macro_attr::*; use medea_client_api_proto::{Command, Event}; -use newtype_derive::NewtypeFrom; use crate::api::control::MemberId; -macro_attr! { - /// Wrapper [`Command`] for implements actix [`Message`]. - #[derive(Message, NewtypeFrom!)] - #[rtype(result = "Result<(), ()>")] - pub struct CommandMessage(Command); -} -macro_attr! { - /// Wrapper [`Event`] for implements actix [`Message`]. - #[derive(Message, NewtypeFrom!)] - pub struct EventMessage(Event); -} +/// Wrapper [`Command`] for implements actix [`Message`]. +#[derive(Message, Into, From)] +#[rtype(result = "Result<(), ()>")] +pub struct CommandMessage(Command); + +/// Wrapper [`Event`] for implements actix [`Message`]. +#[derive(Message, Into, From)] +pub struct EventMessage(Event); /// Abstraction over RPC connection with some remote [`Member`]. /// diff --git a/src/api/control/member.rs b/src/api/control/member.rs index d66c31c55..9f25798e7 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -2,8 +2,7 @@ use std::convert::TryFrom; -use macro_attr::*; -use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; +use derive_more::{Display, From}; use serde::Deserialize; use super::{ @@ -13,20 +12,9 @@ use super::{ TryFromElementError, }; -macro_attr! { - /// ID of `Member`. - #[derive( - Clone, - Debug, - Deserialize, - Eq, - Hash, - PartialEq, - NewtypeFrom!, - NewtypeDisplay! - )] - pub struct Id(pub String); -} +/// ID of `Member`. +#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, From, Display)] +pub struct Id(pub String); /// Element of [`Member`]'s [`Pipeline`]. /// diff --git a/src/api/control/pipeline.rs b/src/api/control/pipeline.rs index 66d773235..4b57cd843 100644 --- a/src/api/control/pipeline.rs +++ b/src/api/control/pipeline.rs @@ -26,8 +26,8 @@ impl Pipeline { } impl<'a, T> IntoIterator for &'a Pipeline { - type Item = (&'a String, &'a T); type IntoIter = Iter<'a, String, T>; + type Item = (&'a String, &'a T); #[inline] fn into_iter(self) -> Self::IntoIter { diff --git a/src/api/control/room.rs b/src/api/control/room.rs index 33c3d8d2d..a2033f2f1 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -2,8 +2,7 @@ use std::{collections::HashMap, convert::TryFrom}; -use macro_attr::*; -use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; +use derive_more::{Display, From}; use serde::Deserialize; use super::{ @@ -12,20 +11,9 @@ use super::{ MemberId, RootElement, TryFromElementError, }; -macro_attr! { - /// ID of [`Room`]. - #[derive( - Clone, - Debug, - Deserialize, - Eq, - Hash, - PartialEq, - NewtypeFrom!, - NewtypeDisplay!, - )] - pub struct Id(pub String); -} +/// ID of [`Room`]. +#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, From, Display)] +pub struct Id(pub String); /// Element of [`Room`]'s [`Pipeline`]. /// diff --git a/src/lib.rs b/src/lib.rs index 36b210d04..35d4429ad 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -128,7 +128,7 @@ pub fn start_static_rooms( GracefulShutdown::new(conf.shutdown.timeout).start(); let config = conf.clone(); let static_specs_path = config.control.static_specs_dir.clone(); - if let Ok(static_specs_dir) = std::fs::read_dir(static_specs_path) { + if let Ok(static_specs_dir) = std::fs::read_dir(&static_specs_path) { Either::A(service::new_turn_auth_service(&config.turn).map( move |turn_auth_service| { let room_specs = diff --git a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs index b89358d8d..cc59e1f09 100644 --- a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs @@ -5,9 +5,8 @@ use std::{ rc::{Rc, Weak}, }; -use macro_attr::*; +use derive_more::{Display, From}; use medea_client_api_proto::PeerId; -use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; use crate::{ api::control::endpoint::SrcUri, @@ -21,11 +20,9 @@ use super::publish_endpoint::WebRtcPublishEndpoint; pub use Id as WebRtcPlayId; -macro_attr! { - /// ID of endpoint. - #[derive(Clone, Debug, Eq, Hash, PartialEq, NewtypeFrom!, NewtypeDisplay!)] - pub struct Id(pub String); -} +/// ID of endpoint. +#[derive(Clone, Debug, Eq, Hash, PartialEq, From, Display)] +pub struct Id(pub String); #[derive(Debug, Clone)] struct WebRtcPlayEndpointInner { diff --git a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs index 59b834f39..4999549e1 100644 --- a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs @@ -6,9 +6,8 @@ use std::{ rc::{Rc, Weak}, }; -use macro_attr::*; +use derive_more::{Display, From}; use medea_client_api_proto::PeerId; -use newtype_derive::{newtype_fmt, NewtypeDisplay, NewtypeFrom}; use crate::{ api::control::endpoint::P2pMode, @@ -22,11 +21,9 @@ use super::play_endpoint::WebRtcPlayEndpoint; pub use Id as WebRtcPublishId; -macro_attr! { - /// ID of endpoint. - #[derive(Clone, Debug, Eq, Hash, PartialEq, NewtypeFrom!, NewtypeDisplay!)] - pub struct Id(pub String); -} +/// ID of endpoint. +#[derive(Clone, Debug, Eq, Hash, PartialEq, From, Display)] +pub struct Id(pub String); #[derive(Debug, Clone)] struct WebRtcPublishEndpointInner { From d8e27db65308527367af3f0479487723b40c57fa Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 5 Sep 2019 15:32:11 +0300 Subject: [PATCH 566/735] Fix Counter bounds --- src/signalling/peers.rs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index 32ac935a1..6d05b4635 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -6,10 +6,10 @@ use std::{ collections::HashMap, convert::{TryFrom, TryInto}, - fmt, }; use medea_client_api_proto::{Incrementable, PeerId, TrackId}; +use derive_more::Display; use crate::{ api::control::MemberId, @@ -39,8 +39,8 @@ pub struct PeerRepository { } /// Simple ID counter. -#[derive(Default, Debug)] -pub struct Counter { +#[derive(Default, Debug, Clone, Copy, Display)] +pub struct Counter { count: T, } @@ -53,12 +53,6 @@ impl Counter { } } -impl fmt::Display for Counter { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "{}", self.count) - } -} - impl PeerRepository { /// Store [`Peer`] in [`Room`]. /// From f530a0fa5268340ffb6c972e5c839057be81052e Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 5 Sep 2019 15:37:24 +0300 Subject: [PATCH 567/735] Fix docs --- src/api/control/pipeline.rs | 2 ++ src/signalling/elements/member.rs | 2 +- src/signalling/peers.rs | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/api/control/pipeline.rs b/src/api/control/pipeline.rs index 4b57cd843..b307e4cc5 100644 --- a/src/api/control/pipeline.rs +++ b/src/api/control/pipeline.rs @@ -14,11 +14,13 @@ pub struct Pipeline { } impl Pipeline { + /// Iterate over pipeline by reference. #[inline] pub fn iter(&self) -> impl Iterator { self.into_iter() } + /// Lookup element of [`Pipeline`] by ID. #[inline] pub fn get(&self, id: &str) -> Option<&T> { self.pipeline.get(id) diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index 89ef33c9b..86c76cbb1 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -162,7 +162,7 @@ impl Member { let new_self_play_id = WebRtcPlayId(spec_play_name.to_string()); let new_self_play = WebRtcPlayEndpoint::new( - new_self_play_id.clone(), + new_self_play_id, spec_play_endpoint.src.clone(), new_publish.downgrade(), this_member.downgrade(), diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index 6d05b4635..dbd0a43b1 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -110,9 +110,9 @@ impl PeerRepository { /// Lookup [`Peer`] of [`Member`] with ID `member_id` which /// connected with `partner_member_id`. /// - /// Return Some(peer_id, partner_peer_id) if that [`Peer`] found. + /// Return `Some(peer_id, partner_peer_id)` if that [`Peer`] found. /// - /// Return None if that [`Peer`] not found. + /// Return `None` if that [`Peer`] not found. pub fn get_peer_by_members_ids( &self, member_id: &MemberId, From 0cfae60c3c6e32ce9a8393101c6a6779f86b36b2 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 5 Sep 2019 16:43:03 +0300 Subject: [PATCH 568/735] Use #[display] instead of #[fail] --- src/api/control/mod.rs | 7 ++++--- src/lib.rs | 11 ++++++----- src/media/peer.rs | 17 ++++++++++------- src/shutdown.rs | 5 +++-- src/signalling/elements/member.rs | 9 +++++---- src/signalling/participants.rs | 12 +++++------- src/signalling/peers.rs | 2 +- src/signalling/room.rs | 21 +++++++++++---------- src/turn/repo.rs | 5 +++-- src/turn/service.rs | 9 +++++---- 10 files changed, 53 insertions(+), 45 deletions(-) diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index d706654f0..1ebc9fc99 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -14,6 +14,7 @@ use std::{ path::Path, }; +use derive_more::Display; use failure::{Error, Fail}; use serde::Deserialize; @@ -41,11 +42,11 @@ pub enum RootElement { /// /// [`TryFrom`]: std::convert::TryFrom #[allow(clippy::pub_enum_variant_names)] -#[derive(Debug, Fail)] +#[derive(Debug, Fail, Display)] pub enum TryFromElementError { - #[fail(display = "Element is not Room")] + #[display(fmt = "Element is not Room")] NotRoom, - #[fail(display = "Element is not Member")] + #[display(fmt = "Element is not Room")] NotMember, } diff --git a/src/lib.rs b/src/lib.rs index 35d4429ad..3ace04836 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -13,6 +13,7 @@ pub mod turn; use std::sync::Arc; use actix::prelude::*; +use derive_more::Display; use failure::{Error, Fail}; use futures::future::{Either, Future, IntoFuture as _}; use std::collections::HashMap; @@ -30,22 +31,22 @@ use crate::{ }; /// Errors which can happen while server starting. -#[derive(Debug, Fail)] +#[derive(Debug, Fail, Display)] pub enum ServerStartError { /// Duplicate [`RoomId`] founded. - #[fail(display = "Duplicate of room ID '{:?}'", _0)] + #[display(fmt = "Duplicate of room ID '{:?}'", _0)] DuplicateRoomId(RoomId), /// Some error happened while loading spec. - #[fail(display = "Failed to load specs. {}", _0)] + #[display(fmt = "Failed to load specs. {}", _0)] LoadSpec(failure::Error), /// Some error happened while creating new room from spec. - #[fail(display = "Bad room spec. {}", _0)] + #[display(fmt = "Bad room spec. {}", _0)] BadRoomSpec(String), /// Unexpected error returned from room. - #[fail(display = "Unknown room error.")] + #[display(fmt = "Unknown room error.")] UnknownRoomError, } diff --git a/src/media/peer.rs b/src/media/peer.rs index 19141c0b7..11aed31de 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -6,6 +6,7 @@ use std::{collections::HashMap, convert::TryFrom, fmt, rc::Rc}; +use derive_more::Display; use failure::Fail; use medea_client_api_proto::{ AudioSettings, Direction, MediaType, PeerId as Id, Track, TrackId, @@ -38,17 +39,19 @@ pub struct WaitRemoteSdp {} pub struct Stable {} /// Produced when unwrapping [`PeerStateMachine`] to [`Peer`] with wrong state. -#[derive(Fail, Debug)] +#[derive(Fail, Debug, Display)] #[allow(clippy::module_name_repetitions)] pub enum PeerError { - #[fail( - display = "Cannot unwrap Peer from PeerStateMachine [id = {}]. \ - Expected state {} was {}", - _0, _1, _2 + #[display( + fmt = "Cannot unwrap Peer from PeerStateMachine [id = {}]. Expected \ + state {} was {}", + _0, + _1, + _2 )] WrongState(Id, &'static str, String), - #[fail( - display = "Peer is sending Track [{}] without providing its mid", + #[display( + fmt = "Peer is sending Track [{}] without providing its mid", _0 )] MidsMismatch(TrackId), diff --git a/src/shutdown.rs b/src/shutdown.rs index 11d2192ac..d5115ac5d 100644 --- a/src/shutdown.rs +++ b/src/shutdown.rs @@ -10,6 +10,7 @@ use actix::{ AsyncContext, Handler, Message, Recipient, ResponseActFuture, System, WrapFuture as _, }; +use derive_more::Display; use failure::Fail; use futures::{future, stream::iter_ok, Future, Stream}; use tokio::util::FutureExt as _; @@ -200,8 +201,8 @@ impl Handler for GracefulShutdown { } /// Error which indicates that process is shutting down at this moment. -#[derive(Clone, Copy, Debug, Fail)] -#[fail(display = "Process is shutting down at the moment")] +#[derive(Clone, Copy, Debug, Fail, Display)] +#[display(fmt = "Process is shutting down at the moment")] pub struct ShuttingDownError; /// Message that [`Subscriber`] unsubscribes from receiving shutdown diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index 86c76cbb1..210d1be37 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -9,6 +9,7 @@ use std::{ rc::{Rc, Weak}, }; +use derive_more::Display; use failure::Fail; use medea_client_api_proto::{IceServer, PeerId}; @@ -23,20 +24,20 @@ use super::endpoints::webrtc::{ }; /// Errors which may occur while loading [`Member`]s from [`RoomSpec`]. -#[derive(Debug, Fail)] +#[derive(Debug, Fail, Display)] pub enum MembersLoadError { /// Errors that can occur when we try transform some spec from `Element`. - #[fail(display = "TryFromElementError: {}", _0)] + #[display(fmt = "TryFromElementError: {}", _0)] TryFromError(TryFromElementError), /// [`Member`] not found. - #[fail(display = "Member with id '{}' not found.", _0)] + #[display(fmt = "Member with id '{}' not found.", _0)] MemberNotFound(MemberId), /// [`Endpoint`] not found. /// /// [`Endpoint`]: crate::api::control::endpoint::Endpoint - #[fail(display = "Endpoint with id '{}' not found.", _0)] + #[display(fmt = "Endpoint with id '{}' not found.", _0)] EndpointNotFound(String), } diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 43501a459..e7266de89 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -17,6 +17,7 @@ use actix::{ fut::wrap_future, ActorFuture, AsyncContext, Context, MailboxError, SpawnHandle, }; +use derive_more::Display; use failure::Fail; use futures::{ future::{self, join_all, Either}, @@ -43,17 +44,14 @@ use crate::{ turn::{TurnAuthService, TurnServiceErr, UnreachablePolicy}, }; -#[derive(Fail, Debug)] +#[derive(Fail, Debug, Display)] #[allow(clippy::module_name_repetitions)] pub enum ParticipantServiceErr { - #[fail(display = "TurnService Error in ParticipantService: {}", _0)] + #[display(fmt = "TurnService Error in ParticipantService: {}", _0)] TurnServiceErr(TurnServiceErr), - #[fail( - display = "Mailbox error when accessing ParticipantService: {}", - _0 - )] + #[display(fmt = "Mailbox error when accessing ParticipantService: {}", _0)] MailBoxErr(MailboxError), - #[fail(display = "Participant with Id [{}] was not found", _0)] + #[display(fmt = "Participant with Id [{}] was not found", _0)] ParticipantNotFound(MemberId), } diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index dbd0a43b1..a5ef56894 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -8,8 +8,8 @@ use std::{ convert::{TryFrom, TryInto}, }; -use medea_client_api_proto::{Incrementable, PeerId, TrackId}; use derive_more::Display; +use medea_client_api_proto::{Incrementable, PeerId, TrackId}; use crate::{ api::control::MemberId, diff --git a/src/signalling/room.rs b/src/signalling/room.rs index fc04e1d3d..b10ef7903 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -9,6 +9,7 @@ use actix::{ fut::wrap_future, Actor, ActorFuture, AsyncContext, Context, Handler, ResponseActFuture, WrapFuture as _, }; +use derive_more::Display; use failure::Fail; use futures::future; use medea_client_api_proto::{Command, Event, IceCandidate, PeerId, TrackId}; @@ -43,25 +44,25 @@ pub type ActFuture = Box>; #[allow(clippy::module_name_repetitions)] -#[derive(Debug, Fail)] +#[derive(Debug, Fail, Display)] pub enum RoomError { - #[fail(display = "Couldn't find Peer with [id = {}]", _0)] + #[display(fmt = "Couldn't find Peer with [id = {}]", _0)] PeerNotFound(PeerId), - #[fail(display = "Couldn't find Member with [id = {}]", _0)] + #[display(fmt = "Couldn't find Member with [id = {}]", _0)] MemberNotFound(MemberId), - #[fail(display = "Member [id = {}] does not have Turn credentials", _0)] + #[display(fmt = "Member [id = {}] does not have Turn credentials", _0)] NoTurnCredentials(MemberId), - #[fail(display = "Couldn't find RpcConnection with Member [id = {}]", _0)] + #[display(fmt = "Couldn't find RpcConnection with Member [id = {}]", _0)] ConnectionNotExists(MemberId), - #[fail(display = "Unable to send event to Member [id = {}]", _0)] + #[display(fmt = "Unable to send event to Member [id = {}]", _0)] UnableToSendEvent(MemberId), - #[fail(display = "PeerError: {}", _0)] + #[display(fmt = "PeerError: {}", _0)] PeerError(PeerError), - #[fail(display = "Generic room error {}", _0)] + #[display(fmt = "Generic room error {}", _0)] BadRoomSpec(String), - #[fail(display = "Turn service error: {}", _0)] + #[display(fmt = "Turn service error: {}", _0)] TurnServiceError(String), - #[fail(display = "Client error:{}", _0)] + #[display(fmt = "Client error:{}", _0)] ClientError(String), } diff --git a/src/turn/repo.rs b/src/turn/repo.rs index 69558318d..4a91d773a 100644 --- a/src/turn/repo.rs +++ b/src/turn/repo.rs @@ -5,6 +5,7 @@ use std::time::Duration; use bb8::{Pool, RunError}; use bb8_redis::{RedisConnectionManager, RedisPool}; use crypto::{digest::Digest, md5::Md5}; +use derive_more::Display; use failure::Fail; use futures::future::Future; use redis::{ConnectionInfo, RedisError}; @@ -12,9 +13,9 @@ use tokio::prelude::*; use crate::{log::prelude::*, media::IceUser}; -#[derive(Fail, Debug)] +#[derive(Fail, Debug, Display)] pub enum TurnDatabaseErr { - #[fail(display = "Redis returned error: {}", _0)] + #[display(fmt = "Redis returned error: {}", _0)] RedisError(RedisError), } diff --git a/src/turn/service.rs b/src/turn/service.rs index 41ee1e091..c6ec2978f 100644 --- a/src/turn/service.rs +++ b/src/turn/service.rs @@ -10,6 +10,7 @@ use actix::{ Message, WrapFuture, }; use bb8::RunError; +use derive_more::Display; use failure::Fail; use futures::future::{err, ok, Future}; use rand::{distributions::Alphanumeric, Rng}; @@ -96,13 +97,13 @@ type ActFuture = Box>; /// Error which can happen in [`TurnAuthService`]. -#[derive(Debug, Fail)] +#[derive(Debug, Fail, Display)] pub enum TurnServiceErr { - #[fail(display = "Error accessing TurnAuthRepo: {}", _0)] + #[display(fmt = "Error accessing TurnAuthRepo: {}", _0)] TurnAuthRepoErr(TurnDatabaseErr), - #[fail(display = "Mailbox error when accessing TurnAuthRepo: {}", _0)] + #[display(fmt = "Mailbox error when accessing TurnAuthRepo: {}", _0)] MailboxErr(MailboxError), - #[fail(display = "Timeout exceeded while trying to insert/delete IceUser")] + #[display(fmt = "Timeout exceeded while trying to insert/delete IceUser")] TimedOut, } From d24bed2c0c9aebbe0377dc6d7ea7f2225844a887 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 5 Sep 2019 17:11:06 +0300 Subject: [PATCH 569/735] Fix docker-compose [run ci] --- dev/config.toml | 2 -- docker-compose.medea.yml | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/dev/config.toml b/dev/config.toml index c69db4582..e69de29bb 100644 --- a/dev/config.toml +++ b/dev/config.toml @@ -1,2 +0,0 @@ -[control] -static_specs_dir = "dev/specs/" diff --git a/docker-compose.medea.yml b/docker-compose.medea.yml index 570851008..84367eef8 100644 --- a/docker-compose.medea.yml +++ b/docker-compose.medea.yml @@ -10,6 +10,6 @@ services: ports: - "8080:8080" volumes: - - ./dev/config.toml:/dev/config.toml:ro - - ./dev/specs:/dev/specs:ro + - ./${MEDEA_CONF}:/${MEDEA_CONF}:ro + - ${MEDEA_CONTROL_STATIC_SPECS_DIR}:/specs:ro network_mode: host From cf29a44f78ffb94b1246d23ca7ef572d2e4454fe Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 5 Sep 2019 17:27:25 +0300 Subject: [PATCH 570/735] Refactor control API specs --- dev/specs/pub-pub-video-call.yml | 4 ++-- dev/specs/pub-sub-video-call.yml | 8 ++++---- dev/specs/three-members-conference.yml | 24 ++++++++++++------------ dev/specs/video-call-1.yml | 4 ++-- tests/specs/three-members-conference.yml | 12 ++++++------ 5 files changed, 26 insertions(+), 26 deletions(-) diff --git a/dev/specs/pub-pub-video-call.yml b/dev/specs/pub-pub-video-call.yml index 728ac94cc..abf670e8f 100644 --- a/dev/specs/pub-pub-video-call.yml +++ b/dev/specs/pub-pub-video-call.yml @@ -17,7 +17,7 @@ spec: p2p: Always # Media element which is able to play media data for client # via WebRTC. - play: + play-responder: kind: WebRtcPlayEndpoint spec: src: "local://pub-pub-video-call/responder/publish" @@ -30,7 +30,7 @@ spec: kind: WebRtcPublishEndpoint spec: p2p: Always - play: + play-caller: kind: WebRtcPlayEndpoint spec: src: "local://pub-pub-video-call/caller/publish" diff --git a/dev/specs/pub-sub-video-call.yml b/dev/specs/pub-sub-video-call.yml index cc51077a2..ff4fef12f 100644 --- a/dev/specs/pub-sub-video-call.yml +++ b/dev/specs/pub-sub-video-call.yml @@ -3,7 +3,7 @@ id: pub-sub-video-call spec: pipeline: # Here we're defining a member who initiates video call. - caller: + publisher: kind: Member credentials: test spec: @@ -15,12 +15,12 @@ spec: spec: # Actually, it receives not media data, but ICE candidates only. p2p: Always - responder: + subcriber: kind: Member credentials: test spec: pipeline: - play: + play-publisher: kind: WebRtcPlayEndpoint spec: - src: "local://pub-sub-video-call/caller/publish" + src: "local://pub-sub-video-call/publisher/publish" diff --git a/dev/specs/three-members-conference.yml b/dev/specs/three-members-conference.yml index ec774bb1c..3ed460b21 100644 --- a/dev/specs/three-members-conference.yml +++ b/dev/specs/three-members-conference.yml @@ -17,15 +17,15 @@ spec: p2p: Always # Media element which is able to play media data for client # via WebRTC. - play: + play-responder-1: kind: WebRtcPlayEndpoint spec: - src: "local://three-members-conference/responder/publish" - play2: + src: "local://three-members-conference/responder-1/publish" + play-responder-2: kind: WebRtcPlayEndpoint spec: - src: "local://three-members-conference/responder2/publish" - responder: + src: "local://three-members-conference/responder-2/publish" + responder-1: kind: Member credentials: test spec: @@ -34,15 +34,15 @@ spec: kind: WebRtcPublishEndpoint spec: p2p: Always - play1: + play-caller: kind: WebRtcPlayEndpoint spec: src: "local://three-members-conference/caller/publish" - play2: + play-responder-2: kind: WebRtcPlayEndpoint spec: - src: "local://three-members-conference/responder2/publish" - responder2: + src: "local://three-members-conference/responder-2/publish" + responder-2: kind: Member credentials: test spec: @@ -51,11 +51,11 @@ spec: kind: WebRtcPublishEndpoint spec: p2p: Always - play1: + play-caller: kind: WebRtcPlayEndpoint spec: src: "local://three-members-conference/caller/publish" - play2: + play-responder-1: kind: WebRtcPlayEndpoint spec: - src: "local://three-members-conference/responder/publish" + src: "local://three-members-conference/responder-1/publish" diff --git a/dev/specs/video-call-1.yml b/dev/specs/video-call-1.yml index 31f413836..82304e3e9 100644 --- a/dev/specs/video-call-1.yml +++ b/dev/specs/video-call-1.yml @@ -17,7 +17,7 @@ spec: p2p: Always # Media element which is able to play media data for client # via WebRTC. - play: + play-responder: kind: WebRtcPlayEndpoint spec: src: "local://video-call-1/responder/publish" @@ -30,7 +30,7 @@ spec: kind: WebRtcPublishEndpoint spec: p2p: Always - play: + play-caller: kind: WebRtcPlayEndpoint spec: src: "local://video-call-1/caller/publish" diff --git a/tests/specs/three-members-conference.yml b/tests/specs/three-members-conference.yml index 432d9d92d..0583c08a4 100644 --- a/tests/specs/three-members-conference.yml +++ b/tests/specs/three-members-conference.yml @@ -11,11 +11,11 @@ spec: kind: WebRtcPublishEndpoint spec: p2p: Always - play: + play-member-2: kind: WebRtcPlayEndpoint spec: src: "local://three-members-conference/member-2/publish" - play2: + play-member-3: kind: WebRtcPlayEndpoint spec: src: "local://three-members-conference/member-3/publish" @@ -28,11 +28,11 @@ spec: kind: WebRtcPublishEndpoint spec: p2p: Always - play1: + play-member-1: kind: WebRtcPlayEndpoint spec: src: "local://three-members-conference/member-1/publish" - play2: + play-member-3: kind: WebRtcPlayEndpoint spec: src: "local://three-members-conference/member-3/publish" @@ -45,11 +45,11 @@ spec: kind: WebRtcPublishEndpoint spec: p2p: Always - play1: + play-member-2: kind: WebRtcPlayEndpoint spec: src: "local://three-members-conference/member-2/publish" - play2: + play-member-1: kind: WebRtcPlayEndpoint spec: src: "local://three-members-conference/member-1/publish" From eb3beec4b5aa604105efeb026823bfa3dca64fb6 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 5 Sep 2019 17:40:27 +0300 Subject: [PATCH 571/735] Rename dev to _dev dir --- .env | 2 +- _dev/config.toml | 2 ++ {dev => _dev}/coturn/redis.conf | 0 {dev => _dev}/coturn/turnserver.conf | 0 {dev => _dev}/specs/pub-pub-video-call.yml | 0 {dev => _dev}/specs/pub-sub-video-call.yml | 0 {dev => _dev}/specs/three-members-conference.yml | 0 {dev => _dev}/specs/video-call-1.yml | 0 dev/config.toml | 0 docker-compose.coturn.yml | 4 ++-- docker-compose.medea.yml | 1 + jason/demo/docker-compose.yml | 6 +++--- 12 files changed, 9 insertions(+), 6 deletions(-) create mode 100644 _dev/config.toml rename {dev => _dev}/coturn/redis.conf (100%) rename {dev => _dev}/coturn/turnserver.conf (100%) rename {dev => _dev}/specs/pub-pub-video-call.yml (100%) rename {dev => _dev}/specs/pub-sub-video-call.yml (100%) rename {dev => _dev}/specs/three-members-conference.yml (100%) rename {dev => _dev}/specs/video-call-1.yml (100%) delete mode 100644 dev/config.toml diff --git a/.env b/.env index 62d565cb0..9f5229f9f 100644 --- a/.env +++ b/.env @@ -1,6 +1,6 @@ RUST_LOG=debug -MEDEA_CONF=dev/config.toml +MEDEA_CONF=_dev/config.toml COMPOSE_PROJECT_NAME=medea COMPOSE_IMAGE_NAME=instrumentisto/medea diff --git a/_dev/config.toml b/_dev/config.toml new file mode 100644 index 000000000..b1ecba523 --- /dev/null +++ b/_dev/config.toml @@ -0,0 +1,2 @@ +[control] +static_specs_dir = "_dev/specs" \ No newline at end of file diff --git a/dev/coturn/redis.conf b/_dev/coturn/redis.conf similarity index 100% rename from dev/coturn/redis.conf rename to _dev/coturn/redis.conf diff --git a/dev/coturn/turnserver.conf b/_dev/coturn/turnserver.conf similarity index 100% rename from dev/coturn/turnserver.conf rename to _dev/coturn/turnserver.conf diff --git a/dev/specs/pub-pub-video-call.yml b/_dev/specs/pub-pub-video-call.yml similarity index 100% rename from dev/specs/pub-pub-video-call.yml rename to _dev/specs/pub-pub-video-call.yml diff --git a/dev/specs/pub-sub-video-call.yml b/_dev/specs/pub-sub-video-call.yml similarity index 100% rename from dev/specs/pub-sub-video-call.yml rename to _dev/specs/pub-sub-video-call.yml diff --git a/dev/specs/three-members-conference.yml b/_dev/specs/three-members-conference.yml similarity index 100% rename from dev/specs/three-members-conference.yml rename to _dev/specs/three-members-conference.yml diff --git a/dev/specs/video-call-1.yml b/_dev/specs/video-call-1.yml similarity index 100% rename from dev/specs/video-call-1.yml rename to _dev/specs/video-call-1.yml diff --git a/dev/config.toml b/dev/config.toml deleted file mode 100644 index e69de29bb..000000000 diff --git a/docker-compose.coturn.yml b/docker-compose.coturn.yml index 88e1a7473..bdfd32d7a 100644 --- a/docker-compose.coturn.yml +++ b/docker-compose.coturn.yml @@ -9,7 +9,7 @@ services: - --log-file=stdout #- --Verbose volumes: - - ./dev/coturn/turnserver.conf:/etc/coturn/turnserver.conf:ro + - ./_dev/coturn/turnserver.conf:/etc/coturn/turnserver.conf:ro - ./.cache/coturn/data:/var/lib/coturn network_mode: host coturn-db: @@ -19,4 +19,4 @@ services: ports: - "6379:6379" # coturn redis volumes: - - ./dev/coturn/redis.conf:/etc/redis.conf:ro + - ./_dev/coturn/redis.conf:/etc/redis.conf:ro diff --git a/docker-compose.medea.yml b/docker-compose.medea.yml index 84367eef8..bf680426a 100644 --- a/docker-compose.medea.yml +++ b/docker-compose.medea.yml @@ -7,6 +7,7 @@ services: environment: RUST_LOG: ${RUST_LOG} MEDEA_CONF: ${MEDEA_CONF} + MEDEA_CONTROL.STATIC_SPECS_DIR: /specs ports: - "8080:8080" volumes: diff --git a/jason/demo/docker-compose.yml b/jason/demo/docker-compose.yml index 0e75ce46f..747dcd22f 100644 --- a/jason/demo/docker-compose.yml +++ b/jason/demo/docker-compose.yml @@ -17,7 +17,7 @@ services: environment: RUST_LOG: "DEBUG" volumes: - - ../../dev/specs:/specs:ro + - ../../_dev/specs:/specs:ro network_mode: service:web-client coturn: container_name: demo-coturn @@ -27,7 +27,7 @@ services: - --log-file=stdout #- --verbose volumes: - - ../../dev/coturn/turnserver.conf:/etc/coturn/turnserver.conf:ro + - ../../_dev/coturn/turnserver.conf:/etc/coturn/turnserver.conf:ro - ../../.cache/coturn/data:/var/lib/coturn network_mode: host coturn-db: @@ -35,5 +35,5 @@ services: image: redis:alpine command: ["redis-server", "/etc/redis.conf"] volumes: - - ../../dev/coturn/redis.conf:/etc/redis.conf:ro + - ../../_dev/coturn/redis.conf:/etc/redis.conf:ro network_mode: service:web-client From 0d7b4c24087a411a5e45fc37aa1b9c5d7e1cf1e9 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 5 Sep 2019 17:56:26 +0300 Subject: [PATCH 572/735] Fix some docs, reduce clones in ws_index --- src/api/client/rpc_connection.rs | 4 ++-- src/api/client/server.rs | 27 ++++++++++++++------------- src/lib.rs | 4 ++-- src/signalling/room_repo.rs | 4 ++-- 4 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/api/client/rpc_connection.rs b/src/api/client/rpc_connection.rs index 2c4f5002a..770f81393 100644 --- a/src/api/client/rpc_connection.rs +++ b/src/api/client/rpc_connection.rs @@ -11,12 +11,12 @@ use medea_client_api_proto::{Command, Event}; use crate::api::control::MemberId; -/// Wrapper [`Command`] for implements actix [`Message`]. +/// Newtype for [`Command`] with actix [`Message`] implementation. #[derive(Message, Into, From)] #[rtype(result = "Result<(), ()>")] pub struct CommandMessage(Command); -/// Wrapper [`Event`] for implements actix [`Message`]. +/// Newtype for [`Event`] with actix [`Message`] implementation. #[derive(Message, Into, From)] pub struct EventMessage(Event); diff --git a/src/api/client/server.rs b/src/api/client/server.rs index 48c25c37b..3e89becac 100644 --- a/src/api/client/server.rs +++ b/src/api/client/server.rs @@ -27,7 +27,7 @@ use crate::{ conf::{Conf, Rpc}, log::prelude::*, shutdown::ShutdownGracefully, - signalling::room_repo::RoomsRepository, + signalling::room_repo::RoomRepository, }; /// Parameters of new WebSocket connection creation HTTP request. @@ -50,21 +50,22 @@ fn ws_index( payload: Payload, ) -> impl Future { debug!("Request params: {:?}", info); + let RequestParams { + room_id, + member_id, + credentials, + } = info.into_inner(); - match state.rooms.get(&info.room_id) { + match state.rooms.get(&room_id) { Some(room) => Either::A( room.send(Authorize { - member_id: info.member_id.clone(), - credentials: info.credentials.clone(), + member_id: member_id.clone(), + credentials, }) .from_err() .and_then(move |res| match res { Ok(_) => ws::start( - WsSession::new( - info.member_id.clone(), - room, - state.config.idle_timeout, - ), + WsSession::new(member_id, room, state.config.idle_timeout), &request, payload, ), @@ -85,7 +86,7 @@ pub struct Context { /// Repository of all currently existing [`Room`]s in application. /// /// [`Room`]: crate::signalling::Room - pub rooms: RoomsRepository, + pub rooms: RoomRepository, /// Settings of application. pub config: Rpc, @@ -96,7 +97,7 @@ pub struct Server(ActixServer); impl Server { /// Starts Client API HTTP server. - pub fn run(rooms: RoomsRepository, config: Conf) -> io::Result> { + pub fn run(rooms: RoomRepository, config: Conf) -> io::Result> { let server_addr = config.server.bind_addr(); let server = HttpServer::new(move || { @@ -154,7 +155,7 @@ mod test { use super::*; /// Creates [`RoomsRepository`] for tests filled with a single [`Room`]. - fn room(conf: Rpc) -> RoomsRepository { + fn room(conf: Rpc) -> RoomRepository { let room_spec = control::load_from_yaml_file("tests/specs/pub-sub-video-call.yml") .unwrap(); @@ -171,7 +172,7 @@ mod test { room_id => client_room, }; - RoomsRepository::new(rooms) + RoomRepository::new(rooms) } /// Creates test WebSocket server of Client API which can handle requests. diff --git a/src/lib.rs b/src/lib.rs index 3ace04836..b590f4863 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -26,7 +26,7 @@ use crate::{ conf::Conf, log::prelude::*, shutdown::GracefulShutdown, - signalling::{room::RoomError, room_repo::RoomsRepository, Room}, + signalling::{room::RoomError, room_repo::RoomRepository, Room}, turn::{service, TurnServiceErr}, }; @@ -81,7 +81,7 @@ pub fn run() -> Result<(), Error> { "Loaded rooms: {:?}", rooms.iter().map(|(id, _)| &id.0).collect::>() ); - let room_repo = RoomsRepository::new(rooms); + let room_repo = RoomRepository::new(rooms); (room_repo, graceful_shutdown, config) }) diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs index 67dca91b4..4ba52d31a 100644 --- a/src/signalling/room_repo.rs +++ b/src/signalling/room_repo.rs @@ -11,13 +11,13 @@ use crate::{api::control::RoomId, signalling::Room}; /// Repository that stores [`Room`]s addresses. #[derive(Clone, Default)] -pub struct RoomsRepository { +pub struct RoomRepository { // TODO: Use crossbeam's concurrent hashmap when its done. // [Tracking](https://github.com/crossbeam-rs/rfcs/issues/32). rooms: Arc>>>, } -impl RoomsRepository { +impl RoomRepository { /// Creates new [`Room`]s repository with passed-in [`Room`]s. pub fn new(rooms: HashMap>) -> Self { Self { From 883fbc57dc3164faa329c84004ef276fbc6824c1 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 5 Sep 2019 18:52:27 +0300 Subject: [PATCH 573/735] Fix docs and some code [run ci] --- src/api/control/endpoint.rs | 8 +++++- src/api/control/member.rs | 6 ++++- src/api/control/mod.rs | 2 +- src/api/control/pipeline.rs | 4 ++- src/api/control/room.rs | 9 +++++-- src/conf/control.rs | 10 ++++--- src/conf/mod.rs | 9 ++++++- src/lib.rs | 3 +-- src/media/peer.rs | 2 +- .../endpoints/webrtc/play_endpoint.rs | 20 +++++++------- .../endpoints/webrtc/publish_endpoint.rs | 27 ++++++++++--------- src/signalling/elements/member.rs | 8 +++--- src/signalling/participants.rs | 14 +++++----- src/signalling/peers.rs | 10 +++---- 14 files changed, 83 insertions(+), 49 deletions(-) diff --git a/src/api/control/endpoint.rs b/src/api/control/endpoint.rs index 2a78e8544..58ca04dd5 100644 --- a/src/api/control/endpoint.rs +++ b/src/api/control/endpoint.rs @@ -1,4 +1,6 @@ -//! Control API specification Endpoint definitions. +//! Definitions and implementations of [Control API]'s `Endpoint`s elements. +//! +//! [Control API]: http://tiny.cc/380uaz use std::{convert::TryFrom, fmt, str::FromStr}; @@ -79,13 +81,17 @@ pub struct WebRtcPlayEndpoint { /// Special uri with pattern `local://{room_id}/{member_id}/{endpoint_id}`. #[derive(Clone, Debug)] pub struct SrcUri { + /// Scheme of media element URI. pub scheme: Scheme, + /// ID of [`Room`] /// /// [`Room`]: crate::signalling::room::Room pub room_id: String, + /// ID of `Member` pub member_id: MemberId, + /// Control ID of [`Endpoint`] pub endpoint_id: String, } diff --git a/src/api/control/member.rs b/src/api/control/member.rs index 9f25798e7..0e71a2f1f 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -1,4 +1,6 @@ -//! Member definitions and implementations. +//! Definitions and implementations of [Control API]'s `Member` element. +//! +//! [Control API]: http://tiny.cc/380uaz use std::convert::TryFrom; @@ -58,6 +60,7 @@ impl MemberSpec { }) } + /// Lookup [`WebRtcPublishEndpoint`] by ID. pub fn get_publish_endpoint_by_id( &self, id: &str, @@ -80,6 +83,7 @@ impl MemberSpec { }) } + /// Returns credentials of this [`Member`]. pub fn credentials(&self) -> &str { &self.credentials } diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index 1ebc9fc99..d87771abc 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -1,4 +1,4 @@ -//! Implementation of [Control API]. +//! Implementation and definitions of [Control API] specs. //! //! [Control API]: http://tiny.cc/380uaz diff --git a/src/api/control/pipeline.rs b/src/api/control/pipeline.rs index b307e4cc5..ebb7f3c1d 100644 --- a/src/api/control/pipeline.rs +++ b/src/api/control/pipeline.rs @@ -1,4 +1,6 @@ -//! Control API specification Pipeline definition. +//! Definitions and implementations of [Control API]'s `Pipeline`. +//! +//! [Control API]: http://tiny.cc/380uaz use std::{ collections::{hash_map::Iter, HashMap}, diff --git a/src/api/control/room.rs b/src/api/control/room.rs index a2033f2f1..880f3e30e 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -1,4 +1,6 @@ -//! Room definitions and implementations. +//! Definitions and implementations of [Control API]'s `Room` element. +//! +//! [Control API]: http://tiny.cc/380uaz use std::{collections::HashMap, convert::TryFrom}; @@ -30,8 +32,11 @@ pub enum RoomElement { }, } -/// [`crate::signalling::room::Room`] specification. +/// [Control API]'s `Room` element specification +/// /// Newtype for [`RootElement::Room`] +/// +/// [Control API]: http://tiny.cc/380uaz #[allow(clippy::module_name_repetitions)] #[derive(Clone, Debug)] pub struct RoomSpec { diff --git a/src/conf/control.rs b/src/conf/control.rs index 8bceecdcb..ae7f049d4 100644 --- a/src/conf/control.rs +++ b/src/conf/control.rs @@ -1,11 +1,15 @@ use serde::{Deserialize, Serialize}; use smart_default::SmartDefault; -/// Control API settings. +/// [Control API] settings. +/// +/// [Control API]: http://tiny.cc/380uaz #[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, SmartDefault)] #[serde(default)] pub struct Control { - /// Path to directory with static Сontrol API specs. - #[default(String::from("./specs/"))] + /// Path to directory with static [Сontrol API] specs. + /// + /// [Control API]: http://tiny.cc/380uaz + #[default(String::from("specs/"))] pub static_specs_dir: String, } diff --git a/src/conf/mod.rs b/src/conf/mod.rs index 73cab1dcd..a5cb1cac1 100644 --- a/src/conf/mod.rs +++ b/src/conf/mod.rs @@ -36,15 +36,22 @@ static APP_CONF_PATH_ENV_VAR_NAME: &str = "MEDEA_CONF"; pub struct Conf { /// HTTP server settings. pub rpc: Rpc, + /// RPC connection settings. pub server: Server, + /// TURN server settings. pub turn: Turn, + /// Logging settings. pub log: Log, + /// Application shutdown settings. pub shutdown: Shutdown, - /// Control API settings. + + /// [Control API] settings. + /// + /// [Control API]: http://tiny.cc/380uaz pub control: Control, } diff --git a/src/lib.rs b/src/lib.rs index b590f4863..f71206970 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -10,13 +10,12 @@ pub mod shutdown; pub mod signalling; pub mod turn; -use std::sync::Arc; +use std::{collections::HashMap, sync::Arc}; use actix::prelude::*; use derive_more::Display; use failure::{Error, Fail}; use futures::future::{Either, Future, IntoFuture as _}; -use std::collections::HashMap; use crate::{ api::{ diff --git a/src/media/peer.rs b/src/media/peer.rs index 11aed31de..f7738fc08 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -253,7 +253,7 @@ impl Peer { } } - /// Add `send` tracks to self and add `recv` for this `send` + /// Add `send` tracks to `self` and add `recv` for this `send` /// to `partner_peer`. pub fn add_publisher( &mut self, diff --git a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs index cc59e1f09..496be86a0 100644 --- a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs @@ -117,7 +117,7 @@ impl WebRtcPlayEndpoint { /// Returns owner [`Member`] of this [`WebRtcPlayEndpoint`]. /// - /// __This function will panic if pointer is empty.__ + /// __This function will panic if pointer to [`Member`] was dropped.__ pub fn owner(&self) -> Member { self.0.borrow().owner() } @@ -140,7 +140,7 @@ impl WebRtcPlayEndpoint { self.0.borrow_mut().set_peer_id(peer_id); } - /// Return [`PeerId`] of [`Peer`] of this [`WebRtcPlayEndpoint`]. + /// Returns [`PeerId`] of this [`WebRtcPlayEndpoint`]'s [`Peer`]. /// /// [`Peer`]: crate::media::peer::Peer pub fn peer_id(&self) -> Option { @@ -149,24 +149,24 @@ impl WebRtcPlayEndpoint { /// Reset state of this [`WebRtcPlayEndpoint`]. /// - /// Atm this only reset peer_id. + /// _Atm this only reset peer_id._ pub fn reset(&self) { self.0.borrow_mut().reset() } - /// Returns ID of this [`WebRtcPlayEndpoint`]. + /// Returns [`Id`] of this [`WebRtcPlayEndpoint`]. pub fn id(&self) -> Id { self.0.borrow().id.clone() } - /// Downgrade [`WeakWebRtcPlayEndpoint`] to weak pointer - /// [`WeakWebRtcPlayEndpoint`]. + /// Downgrade [`WebRtcPlayEndpoint`] to [`WeakWebRtcPlayEndpoint`] weak + /// pointer. pub fn downgrade(&self) -> WeakWebRtcPlayEndpoint { WeakWebRtcPlayEndpoint(Rc::downgrade(&self.0)) } - /// Compares pointers. If both pointers point to the same address, then - /// returns true. + /// Compares [`WebRtcPlayEndpoint`]'s inner pointers. If both pointers + /// points to the same address, then returns `true`. #[cfg(test)] pub fn ptr_eq(&self, another_play: &Self) -> bool { Rc::ptr_eq(&self.0, &another_play.0) @@ -181,12 +181,14 @@ pub struct WeakWebRtcPlayEndpoint(Weak>); impl WeakWebRtcPlayEndpoint { /// Upgrade weak pointer to strong pointer. /// - /// This function will __panic__ if weak pointer is `None`. + /// This function will __panic__ if weak pointer was dropped. pub fn upgrade(&self) -> WebRtcPlayEndpoint { WebRtcPlayEndpoint(self.0.upgrade().unwrap()) } /// Safe upgrade to [`WebRtcPlayEndpoint`]. + /// + /// Returns `None` if weak pointer was dropped. pub fn safe_upgrade(&self) -> Option { self.0.upgrade().map(WebRtcPlayEndpoint) } diff --git a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs index 4999549e1..3f5c4861e 100644 --- a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs @@ -123,12 +123,13 @@ impl WebRtcPublishEndpoint { }))) } - /// Add sink for this [`WebRtcPublishEndpoint`]. + /// Add [`WebRtcPlayEndpoint`] (sink) to this [`WebRtcPublishEndpoint`]. pub fn add_sink(&self, sink: WeakWebRtcPlayEndpoint) { self.0.borrow_mut().add_sinks(sink) } - /// Returns all sinks of this [`WebRtcPublishEndpoint`]. + /// Returns all [`WebRtcPlayEndpoint`]s (sinks) of this + /// [`WebRtcPublishEndpoint`]. /// /// __This function will panic if meet empty pointer.__ pub fn sinks(&self) -> Vec { @@ -137,7 +138,7 @@ impl WebRtcPublishEndpoint { /// Returns owner [`Member`] of this [`WebRtcPublishEndpoint`]. /// - /// __This function will panic if pointer is empty.__ + /// __This function will panic if pointer to [`Member`] was dropped.__ pub fn owner(&self) -> Member { self.0.borrow().owner() } @@ -147,19 +148,19 @@ impl WebRtcPublishEndpoint { self.0.borrow_mut().add_peer_id(peer_id) } - /// Returns all [`PeerId`] of this [`WebRtcPublishEndpoint`]. + /// Returns all [`PeerId`]s of this [`WebRtcPublishEndpoint`]. pub fn peer_ids(&self) -> HashSet { self.0.borrow().peer_ids() } /// Reset state of this [`WebRtcPublishEndpoint`]. /// - /// Atm this only reset peer_ids. + /// _Atm this only reset `peer_ids`._ pub fn reset(&self) { self.0.borrow_mut().reset() } - /// Remove [`PeerId`] from peer_ids. + /// Remove [`PeerId`] from `peer_ids`. #[allow(clippy::trivially_copy_pass_by_ref)] pub fn remove_peer_id(&self, peer_id: &PeerId) { self.0.borrow_mut().remove_peer_id(peer_id) @@ -170,12 +171,12 @@ impl WebRtcPublishEndpoint { self.0.borrow_mut().remove_peer_ids(peer_ids) } - /// Returns ID of this [`WebRtcPublishEndpoint`]. + /// Returns [`Id`] of this [`WebRtcPublishEndpoint`]. pub fn id(&self) -> Id { self.0.borrow().id.clone() } - /// Remove all empty Weak pointers from sinks of this + /// Remove all dropped [`Weak`] pointers from sinks of this /// [`WebRtcPublishEndpoint`]. pub fn remove_empty_weaks_from_sinks(&self) { self.0 @@ -184,14 +185,14 @@ impl WebRtcPublishEndpoint { .retain(|e| e.safe_upgrade().is_some()); } - /// Downgrade [`WeakWebRtcPublishEndpoint`] to weak pointer + /// Downgrade [`WebRtcPublishEndpoint`] to weak pointer /// [`WeakWebRtcPublishEndpoint`]. pub fn downgrade(&self) -> WeakWebRtcPublishEndpoint { WeakWebRtcPublishEndpoint(Rc::downgrade(&self.0)) } - /// Compares pointers. If both pointers point to the same address, then - /// returns true. + /// Compares [`WebRtcPublishEndpoint`]'s inner pointers. If both pointers + /// points to the same address, then returns `true`. #[cfg(test)] pub fn ptr_eq(&self, another_publish: &Self) -> bool { Rc::ptr_eq(&self.0, &another_publish.0) @@ -206,12 +207,14 @@ pub struct WeakWebRtcPublishEndpoint(Weak>); impl WeakWebRtcPublishEndpoint { /// Upgrade weak pointer to strong pointer. /// - /// This function will __panic__ if weak pointer is `None`. + /// This function will __panic__ if weak pointer was dropped. pub fn upgrade(&self) -> WebRtcPublishEndpoint { WebRtcPublishEndpoint(self.0.upgrade().unwrap()) } /// Safe upgrade to [`WebRtcPlayEndpoint`]. + /// + /// Returns `None` if weak pointer was dropped. pub fn safe_upgrade(&self) -> Option { self.0.upgrade().map(WebRtcPublishEndpoint) } diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index 210d1be37..dde263285 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -74,7 +74,7 @@ struct MemberInner { impl Member { /// Create new empty [`Member`]. /// - /// To fill this [`Member`], you need to call the [`Member::load`] + /// To fill this [`Member`], you need to call [`Member::load`] /// function. fn new(id: MemberId, credentials: String) -> Self { Self(Rc::new(RefCell::new(MemberInner { @@ -236,7 +236,7 @@ impl Member { self.0.borrow().credentials.clone() } - /// Returns all publishers of this [`Member`]. + /// Returns all srcs of this [`Member`]. pub fn srcs(&self) -> HashMap { self.0.borrow().srcs.clone() } @@ -303,7 +303,7 @@ pub struct WeakMember(Weak>); impl WeakMember { /// Upgrade weak pointer to strong pointer. /// - /// This function will __panic__ if weak pointer is `None`. + /// This function will __panic__ if weak pointer was dropped. pub fn upgrade(&self) -> Member { Member(Weak::upgrade(&self.0).unwrap()) } @@ -314,7 +314,7 @@ impl WeakMember { } } -/// Creates all empty [`Member`] from [`RoomSpec`] and then +/// Creates all empty [`Member`]s from [`RoomSpec`] and then /// load all related to this [`Member`]s srcs and sinks endpoints. /// /// Returns store of all [`Member`]s loaded from [`RoomSpec`]. diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index e7266de89..bf82718c2 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -115,15 +115,17 @@ impl ParticipantService { }) } - /// Lookup [`Member`] by provided id. + /// Lookup [`Member`] by provided [`MemberId`]. pub fn get_member_by_id(&self, id: &MemberId) -> Option<&Member> { self.members.get(id) } - /// Lookup [`Member`] by provided id and credentials. Returns - /// [`Err(AuthorizationError::MemberNotExists)`] if lookup by - /// [`MemberId`] failed. Returns - /// [`Err(AuthorizationError::InvalidCredentials)`] if [`Member`] + /// Lookup [`Member`] by provided [`MemberId`] and credentials. + /// + /// Returns [`Err(AuthorizationError::MemberNotExists)`] if lookup by + /// [`MemberId`] failed. + /// + /// Returns [`Err(AuthorizationError::InvalidCredentials)`] if [`Member`] /// was found, but incorrect credentials was provided. pub fn get_member_by_id_and_credentials( &self, @@ -142,7 +144,7 @@ impl ParticipantService { } } - /// Checks if [`Member`] has **active** [`RpcConnection`]. + /// Checks if [`Member`] has __active__ [`RpcConnection`]. pub fn member_has_connection(&self, member_id: &MemberId) -> bool { self.connections.contains_key(member_id) && !self.drop_connection_tasks.contains_key(member_id) diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index a5ef56894..e5baf2d4a 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -88,15 +88,15 @@ impl PeerRepository { let first_peer = Peer::new( first_peer_id, - first_member.id().clone(), + first_member.id(), second_peer_id, - second_member.id().clone(), + second_member.id(), ); let second_peer = Peer::new( second_peer_id, - second_member.id().clone(), + second_member.id(), first_peer_id, - first_member.id().clone(), + first_member.id(), ); (first_peer, second_peer) @@ -178,7 +178,7 @@ impl PeerRepository { /// Remove all related to [`Member`] [`Peer`]s. /// Note that this function will also remove all partners [`Peer`]s. /// - /// Returns `HashMap` with all remove [`Peer`]s. + /// Returns `HashMap` with all removed [`Peer`]s. /// Key - [`Peer`]'s owner [`MemberId`], /// value - removed [`Peer`]'s [`PeerId`]. pub fn remove_peers_related_to_member( From 38ffdd8efac63cf8825ec8812e85b2f957ddd308 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 5 Sep 2019 20:09:04 +0300 Subject: [PATCH 574/735] Final reread [run ci] --- proto/client-api/src/lib.rs | 6 +-- src/api/control/member.rs | 2 +- src/api/control/mod.rs | 3 ++ src/api/control/room.rs | 2 + .../endpoints/webrtc/play_endpoint.rs | 1 + .../endpoints/webrtc/publish_endpoint.rs | 1 + src/signalling/elements/member.rs | 44 +++++++++---------- src/signalling/participants.rs | 1 + src/signalling/peers.rs | 10 ++--- src/signalling/room.rs | 4 +- src/utils/mod.rs | 2 +- 11 files changed, 39 insertions(+), 37 deletions(-) diff --git a/proto/client-api/src/lib.rs b/proto/client-api/src/lib.rs index 5253644c6..243387697 100644 --- a/proto/client-api/src/lib.rs +++ b/proto/client-api/src/lib.rs @@ -6,7 +6,7 @@ use derive_more::Display; use medea_macro::dispatchable; use serde::{de::Deserializer, ser::Serializer, Deserialize, Serialize}; -/// ID of [`Peer`]. +/// ID of `Peer`. #[cfg_attr( feature = "medea", derive(Deserialize, Debug, Hash, Eq, Default, PartialEq) @@ -15,7 +15,7 @@ use serde::{de::Deserializer, ser::Serializer, Deserialize, Serialize}; #[derive(Clone, Copy, Display)] pub struct PeerId(pub u64); -/// ID of [`MediaTrack`]. +/// ID of `MediaTrack`. #[cfg_attr( feature = "medea", derive(Deserialize, Debug, Hash, Eq, Default, PartialEq) @@ -140,7 +140,7 @@ pub struct IceCandidate { pub sdp_mid: Option, } -/// [`Track] with specified direction. +/// [`Track`] with specified direction. #[cfg_attr(feature = "medea", derive(Serialize, Debug, Clone, PartialEq))] #[cfg_attr(feature = "jason", derive(Deserialize))] pub struct Track { diff --git a/src/api/control/member.rs b/src/api/control/member.rs index 0e71a2f1f..c0e56884e 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -83,7 +83,7 @@ impl MemberSpec { }) } - /// Returns credentials of this [`Member`]. + /// Returns credentials from this [`MemberSpec`]. pub fn credentials(&self) -> &str { &self.credentials } diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index d87771abc..bb4103456 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -26,6 +26,9 @@ pub use self::{ room::{Id as RoomId, RoomElement, RoomSpec}, }; +/// Root elements of [Control API] spec. +/// +/// [Control API]: http://tiny.cc/380uaz #[derive(Clone, Deserialize, Debug)] #[serde(tag = "kind")] pub enum RootElement { diff --git a/src/api/control/room.rs b/src/api/control/room.rs index 880f3e30e..5997ba559 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -14,6 +14,8 @@ use super::{ }; /// ID of [`Room`]. +/// +/// [`Room`]: crate::signalling::room::Room #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, From, Display)] pub struct Id(pub String); diff --git a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs index 496be86a0..c44d87ded 100644 --- a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs @@ -18,6 +18,7 @@ use crate::{ use super::publish_endpoint::WebRtcPublishEndpoint; +#[doc(inline)] pub use Id as WebRtcPlayId; /// ID of endpoint. diff --git a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs index 3f5c4861e..158237d1b 100644 --- a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs @@ -19,6 +19,7 @@ use crate::{ use super::play_endpoint::WebRtcPlayEndpoint; +#[doc(inline)] pub use Id as WebRtcPublishId; /// ID of endpoint. diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index dde263285..70d78dcf1 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -96,42 +96,39 @@ impl Member { room_spec .pipeline .get(&self.id().0) - .map_or(Err(MembersLoadError::MemberNotFound(self.id())), Ok)?, + .ok_or_else(|| MembersLoadError::MemberNotFound(self.id()))?, )?; let this_member = store .get(&self.id()) - .map_or(Err(MembersLoadError::MemberNotFound(self.id())), Ok)?; + .ok_or_else(|| MembersLoadError::MemberNotFound(self.id()))?; for (spec_play_name, spec_play_endpoint) in this_member_spec.play_endpoints() { let publisher_id = MemberId(spec_play_endpoint.src.member_id.to_string()); - let publisher_member = store.get(&publisher_id).map_or( - Err(MembersLoadError::MemberNotFound(publisher_id)), - Ok, - )?; + let publisher_member = store + .get(&publisher_id) + .ok_or(MembersLoadError::MemberNotFound(publisher_id))?; let publisher_spec = MemberSpec::try_from( room_spec .pipeline .get(&spec_play_endpoint.src.member_id.to_string()) - .map_or( - Err(MembersLoadError::MemberNotFound( + .ok_or_else(|| { + MembersLoadError::MemberNotFound( spec_play_endpoint.src.member_id.clone(), - )), - Ok, - )?, + ) + })?, )?; let publisher_endpoint = publisher_spec .get_publish_endpoint_by_id(&spec_play_endpoint.src.endpoint_id) - .map_or( - Err(MembersLoadError::EndpointNotFound( + .ok_or_else(|| { + MembersLoadError::EndpointNotFound( spec_play_endpoint.src.endpoint_id.clone(), - )), - Ok, - )?; + ) + })?; if let Some(publisher) = publisher_member.get_src_by_id(&WebRtcPublishId( @@ -322,14 +319,15 @@ pub fn parse_members( room_spec: &RoomSpec, ) -> Result, MembersLoadError> { let members_spec = room_spec.members()?; - let mut members = HashMap::new(); - for (id, member) in &members_spec { - members.insert( - id.clone(), - Member::new(id.clone(), member.credentials().to_string()), - ); - } + let members: HashMap = members_spec + .iter() + .map(|(id, member)| { + let new_member = + Member::new(id.clone(), member.credentials().to_string()); + (id.clone(), new_member) + }) + .collect(); for member in members.values() { member.load(room_spec, &members)?; diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index bf82718c2..b5d29fd56 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -274,6 +274,7 @@ impl ParticipantService { &mut self, member_id: &MemberId, ) -> Box> { + // TODO: rewrite using `Option::flatten` when it will be in stable rust. match self.get_member_by_id(&member_id) { Some(member) => match member.take_ice_user() { Some(ice_user) => self.turn.delete(vec![ice_user]), diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index e5baf2d4a..f06e29f4a 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -151,13 +151,9 @@ impl PeerRepository { &'a self, member_id: &'a MemberId, ) -> impl Iterator { - self.peers.iter().filter_map(move |(_, peer)| { - if &peer.member_id() == member_id { - Some(peer) - } else { - None - } - }) + self.peers + .values() + .filter(move |peer| &peer.member_id() == member_id) } /// Returns owned [`Peer`] by its ID. diff --git a/src/signalling/room.rs b/src/signalling/room.rs index b10ef7903..f2e2a7cc2 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -391,7 +391,7 @@ impl Room { let mut created_peers: Vec<(PeerId, PeerId)> = Vec::new(); // Create all connected publish endpoints. - for (_, publisher) in member.srcs() { + for publisher in member.srcs().values() { for receiver in publisher.sinks() { let receiver_owner = receiver.owner(); @@ -408,7 +408,7 @@ impl Room { } // Create all connected play's receivers peers. - for (_, receiver) in member.sinks() { + for receiver in member.sinks().values() { let publisher = receiver.src(); if receiver.peer_id().is_none() diff --git a/src/utils/mod.rs b/src/utils/mod.rs index ec14c04d8..e47aa50a8 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -15,7 +15,7 @@ /// assert_eq!(map.get("c"), None); /// ``` /// -/// [`HashMap`]: std::hashmap::HashMap +/// [`HashMap`]: std::collections::HashMap #[macro_export] macro_rules! hashmap { (@single $($x:tt)*) => (()); From bccc4f838992e358385f6258b280f15c8ff9d37d Mon Sep 17 00:00:00 2001 From: alexlapa Date: Thu, 5 Sep 2019 21:32:52 +0300 Subject: [PATCH 575/735] refactor, add todos --- proto/grpc/proto/control.proto | 5 +- src/api/client/server.rs | 6 +- .../control/endpoints/webrtc_play_endpoint.rs | 16 +- src/api/control/grpc/server.rs | 314 ++++++++---------- src/api/control/local_uri.rs | 30 +- src/shutdown.rs | 17 +- src/signalling/room_service.rs | 154 +++++---- 7 files changed, 251 insertions(+), 291 deletions(-) diff --git a/proto/grpc/proto/control.proto b/proto/grpc/proto/control.proto index d05be273a..a52434715 100644 --- a/proto/grpc/proto/control.proto +++ b/proto/grpc/proto/control.proto @@ -3,7 +3,7 @@ syntax = "proto3"; package medea; service ControlApi { - rpc Create (CreateRequest) returns (Response); + rpc Create (CreateRequest) returns (CreateResponse); rpc Apply (ApplyRequest) returns (Response); rpc Delete (IdRequest) returns (Response); rpc Get (IdRequest) returns (GetResponse); @@ -42,6 +42,9 @@ message IdRequest { repeated string id = 1; } message Response { + Error error = 1; +} +message CreateResponse { map sid = 1; Error error = 2; } diff --git a/src/api/client/server.rs b/src/api/client/server.rs index 60a7e4a93..6fa1e3253 100644 --- a/src/api/client/server.rs +++ b/src/api/client/server.rs @@ -2,7 +2,7 @@ use std::io; -use actix::{Actor, Addr, Handler, ResponseActFuture, WrapFuture as _}; +use actix::{Actor, Addr, Handler, ResponseFuture, WrapFuture as _}; use actix_web::{ dev::Server as ActixServer, middleware, @@ -126,7 +126,7 @@ impl Actor for Server { } impl Handler for Server { - type Result = ResponseActFuture; + type Result = ResponseFuture<(), ()>; fn handle( &mut self, @@ -134,7 +134,7 @@ impl Handler for Server { _: &mut Self::Context, ) -> Self::Result { info!("Server received ShutdownGracefully message so shutting down"); - Box::new(self.0.stop(true).into_actor(self)) + Box::new(self.0.stop(true)) } } diff --git a/src/api/control/endpoints/webrtc_play_endpoint.rs b/src/api/control/endpoints/webrtc_play_endpoint.rs index f0e278780..c3c6055f2 100644 --- a/src/api/control/endpoints/webrtc_play_endpoint.rs +++ b/src/api/control/endpoints/webrtc_play_endpoint.rs @@ -45,7 +45,7 @@ impl TryFrom<&WebRtcPlayEndpointProto> for WebRtcPlayEndpoint { fn try_from(value: &WebRtcPlayEndpointProto) -> Result { Ok(Self { - src: SrcUri::parse(value.get_src())?, + src: SrcUri::try_from(value.get_src())?, }) } } @@ -70,13 +70,11 @@ pub struct SrcUri { pub endpoint_id: WebRtcPublishId, } -impl SrcUri { - /// Parse [`SrcUri`] from str. - /// - /// Returns [`SrcParseError::LocalUriParseError`] when some error happened - /// while parsing URI. - pub fn parse(value: &str) -> Result { - let local_uri = LocalUriType::parse(value).map_err(|e| { +impl TryFrom<&str> for SrcUri { + type Error = SrcParseError; + + fn try_from(value: &str) -> Result { + let local_uri = LocalUriType::try_from(value).map_err(|e| { SrcParseError::LocalUriParseError(value.to_string(), e) })?; @@ -124,7 +122,7 @@ impl<'de> Deserialize<'de> for SrcUri { where E: de::Error, { - match SrcUri::parse(value) { + match SrcUri::try_from(value) { Ok(src_uri) => Ok(src_uri), Err(e) => Err(Error::custom(e)), } diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index 7bd284cc0..ec2c61c5d 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -6,15 +6,19 @@ use std::{collections::HashMap, convert::TryFrom, sync::Arc}; use actix::{ - Actor, Addr, Arbiter, Context, Handler, MailboxError, ResponseActFuture, + Actor, Addr, Arbiter, Context, Handler, MailboxError, ResponseFuture, WrapFuture as _, }; use failure::Fail; -use futures::future::{self, Either, Future}; -use grpcio::{Environment, RpcContext, Server, ServerBuilder, UnarySink}; +use futures::future::{Either, Future}; +use grpcio::{ + Environment, RpcContext, RpcStatus, RpcStatusCode, Server, ServerBuilder, + UnarySink, UnarySinkResult, +}; use medea_grpc_proto::{ control::{ - ApplyRequest, CreateRequest, Error, GetResponse, IdRequest, Response, + ApplyRequest, CreateRequest, CreateResponse, Error, GetResponse, + IdRequest, Response, }, control_grpc::{create_control_api, ControlApi}, }; @@ -35,9 +39,9 @@ use crate::{ signalling::{ room::RoomError, room_service::{ - CreateEndpointInRoom, CreateMemberInRoom, DeleteEndpointFromMember, - DeleteMemberFromRoom, DeleteRoom, GetEndpoint, GetMember, GetRoom, - RoomService, RoomServiceError, StartRoom, + CreateEndpointInRoom, CreateMemberInRoom, DeleteElements, + GetEndpoint, GetMember, GetRoom, RoomService, RoomServiceError, + StartRoom, }, }, AppContext, @@ -115,7 +119,7 @@ macro_rules! fut_try { /// See `send_error_response` doc for details about arguments for this macro. macro_rules! parse_local_uri { ($uri:expr, $ctx:expr, $sink:expr, $response:ty) => { - match LocalUriType::parse($uri) { + match LocalUriType::try_from($uri.as_ref()) { Ok(o) => o, Err(e) => { let error: ErrorResponse = e.into(); @@ -258,12 +262,12 @@ impl ControlApiService { /// Generate [`Response`] for `Create` method of all elements. fn get_response_for_create( result: Result, -) -> Response { +) -> CreateResponse { let error: ErrorResponse = match result { Ok(r) => match r { Ok(r) => match r { Ok(sid) => { - let mut response = Response::new(); + let mut response = CreateResponse::new(); response.set_sid(sid); return response; } @@ -274,97 +278,99 @@ fn get_response_for_create( Err(e) => e.into(), }; - let mut error_response = Response::new(); + let mut error_response = CreateResponse::new(); error_response.set_error(error.into()); error_response } impl ControlApi for ControlApiService { + // TODO: just send Vec, see fn delete() /// Implementation for `Create` method of gRPC control API. fn create( &mut self, ctx: RpcContext, req: CreateRequest, - sink: UnarySink, + sink: UnarySink, ) { - let local_uri = parse_local_uri!(req.get_id(), ctx, sink, Response); - - match local_uri { - LocalUriType::Room(local_uri) => { - if req.has_room() { - ctx.spawn(self.create_room(&req, local_uri).then( - move |r| { - sink.success(get_response_for_create(r)) - .map_err(|_| ()) - }, - )); - } else { - send_error_response!( - ctx, - sink, - ErrorResponse::new( - ErrorCode::ElementIdForRoomButElementIsNot, - &req.get_id(), - ), - Response - ); - } - } - LocalUriType::Member(local_uri) => { - if req.has_member() { - ctx.spawn(self.create_member(&req, local_uri).then( - move |r| { - sink.success(get_response_for_create(r)).map_err( - |e| { - warn!( - "Error while sending Create response \ - by gRPC. {:?}", - e - ) - }, - ) - }, - )); - } else { - send_error_response!( - ctx, - sink, - ErrorResponse::new( - ErrorCode::ElementIdForMemberButElementIsNot, - &req.get_id(), - ), - Response - ); - } - } - LocalUriType::Endpoint(local_uri) => { - if req.has_webrtc_pub() || req.has_webrtc_play() { - ctx.spawn(self.create_endpoint(&req, local_uri).then( - move |r| { - sink.success(get_response_for_create(r)).map_err( - |e| { - warn!( - "Error while sending Create response \ - by gRPC. {:?}", - e - ) - }, - ) - }, - )); - } else { - send_error_response!( - ctx, - sink, - ErrorResponse::new( - ErrorCode::ElementIdForEndpointButElementIsNot, - &req.get_id(), - ), - Response - ); - } - } - } + // let local_uri = parse_local_uri!(req.get_id(), ctx, sink, + // Response); + // + // match local_uri { + // LocalUriType::Room(local_uri) => { + // if req.has_room() { + // ctx.spawn(self.create_room(&req, local_uri).then( + // move |r| { + // sink.success(get_response_for_create(r)) + // .map_err(|_| ()) + // }, + // )); + // } else { + // send_error_response!( + // ctx, + // sink, + // ErrorResponse::new( + // + // ErrorCode::ElementIdForRoomButElementIsNot, + // &req.get_id(), ), + // Response + // ); + // } + // } + // LocalUriType::Member(local_uri) => { + // if req.has_member() { + // ctx.spawn(self.create_member(&req, + // local_uri).then( move |r| { + // + // sink.success(get_response_for_create(r)).map_err( + // |e| { warn!( + // "Error while sending Create + // response \ by gRPC. + // {:?}", e + // ) + // }, + // ) + // }, + // )); + // } else { + // send_error_response!( + // ctx, + // sink, + // ErrorResponse::new( + // + // ErrorCode::ElementIdForMemberButElementIsNot, + // &req.get_id(), ), + // Response + // ); + // } + // } + // LocalUriType::Endpoint(local_uri) => { + // if req.has_webrtc_pub() || req.has_webrtc_play() { + // ctx.spawn(self.create_endpoint(&req, + // local_uri).then( move |r| { + // + // sink.success(get_response_for_create(r)).map_err( + // |e| { warn!( + // "Error while sending Create + // response \ by gRPC. + // {:?}", e + // ) + // }, + // ) + // }, + // )); + // } else { + // send_error_response!( + // ctx, + // sink, + // ErrorResponse::new( + // + // ErrorCode::ElementIdForEndpointButElementIsNot, + // &req.get_id(), ), + // Response + // ); + // } + // } + // } } /// Implementation for `Apply` method of gRPC control API. @@ -372,105 +378,62 @@ impl ControlApi for ControlApiService { &mut self, _ctx: RpcContext, _req: ApplyRequest, - _sink: UnarySink, + sink: UnarySink, ) { - unimplemented!() + // TODO: poll UnarySinkResult's, log err if any + sink.fail(RpcStatus::new(RpcStatusCode::Unimplemented, None)); } /// Implementation for `Delete` method of gRPC control API. fn delete( &mut self, ctx: RpcContext, - req: IdRequest, + mut req: IdRequest, sink: UnarySink, ) { - let mut delete_room_futs = Vec::new(); - let mut delete_member_futs = Vec::new(); - let mut delete_endpoints_futs = Vec::new(); + let mut delete_elements = DeleteElements::new(); for id in req.get_id() { - let uri = parse_local_uri!(id, ctx, sink, Response); + let uri: LocalUriType = parse_local_uri!(id, ctx, sink, Response); + delete_elements.add_uri(uri); + } - match uri { - LocalUriType::Room(uri) => { - delete_room_futs.push( - self.room_service.send(DeleteRoom(uri.take_room_id())), - ); - } - LocalUriType::Member(uri) => { - let (member_id, room_uri) = uri.take_member_id(); - let room_id = room_uri.take_room_id(); - delete_member_futs.push( - self.room_service - .send(DeleteMemberFromRoom { room_id, member_id }), - ); - } - LocalUriType::Endpoint(uri) => { - let (endpoint_id, member_uri) = uri.take_endpoint_id(); - let (member_id, room_uri) = member_uri.take_member_id(); - let room_id = room_uri.take_room_id(); - delete_endpoints_futs.push(self.room_service.send( - DeleteEndpointFromMember { - room_id, - member_id, - endpoint_id, - }, - )); - } + let delete_elements = match delete_elements.validate() { + Ok(validated) => validated, + Err(err) => { + send_error_response!( + ctx, + sink, + ErrorResponse::from(err), + Response + ); } - } + }; - ctx.spawn( - future::join_all(delete_room_futs) - .join3( - future::join_all(delete_member_futs), - future::join_all(delete_endpoints_futs), - ) - .then(move |result| { - let map_err_closure = |e| { - warn!( - "Error while sending Delete response by gRPC. {:?}", - e - ) - }; - match result { - Ok((member, endpoint, room)) => { - let results = member - .into_iter() - .chain(endpoint.into_iter()) - .chain(room.into_iter()); - for result in results { - if let Err(e) = result { - let mut response = Response::new(); - let error: ErrorResponse = e.into(); - response.set_error(error.into()); - return sink - .success(response) - .map_err(map_err_closure); - } - } + ctx.spawn(self.room_service.send(delete_elements).then( + move |result| { + match result { + Ok(result) => { + sink.success(Response::new()); + } + Err(e) => { + let mut response = Response::new(); - let mut response = Response::new(); - response.set_sid(HashMap::new()); - sink.success(response).map_err(map_err_closure) - } - Err(e) => { - warn!( - "Control API Delete method mailbox error. {:?}", - e - ); - let mut response = Response::new(); - let error: Error = - ErrorResponse::unknown(&format!("{:?}", e)) - .into(); - response.set_error(error); - sink.success(response).map_err(map_err_closure) - } + // TODO: dont use unknown, add some special err for all + // mailbox errs, Unavailable("ActorName") or something + let error: Error = + ErrorResponse::unknown(&format!("{:?}", e)).into(); + response.set_error(error); + + let a: UnarySinkResult = sink.success(response); } - }), - ); + } + Ok(()) + }, + )); } + /// TODO: just send Vec, see fn delete() /// Implementation for `Get` method of gRPC control API. fn get( &mut self, @@ -589,7 +552,7 @@ impl Actor for GrpcServer { } impl Handler for GrpcServer { - type Result = ResponseActFuture; + type Result = ResponseFuture<(), ()>; fn handle( &mut self, @@ -599,12 +562,7 @@ impl Handler for GrpcServer { info!( "gRPC server received ShutdownGracefully message so shutting down.", ); - Box::new( - self.server - .shutdown() - .map_err(|e| warn!("{:?}", e)) - .into_actor(self), - ) + Box::new(self.server.shutdown().map_err(|e| warn!("{:?}", e))) } } diff --git a/src/api/control/local_uri.rs b/src/api/control/local_uri.rs index 7519f3fe8..22b6dd2c0 100644 --- a/src/api/control/local_uri.rs +++ b/src/api/control/local_uri.rs @@ -3,7 +3,7 @@ // Fix bug in clippy. #![allow(clippy::use_self)] -use std::fmt; +use std::{convert::TryFrom, fmt}; use failure::Fail; use url::Url; @@ -194,12 +194,10 @@ struct LocalUriInner { endpoint_id: Option, } -impl LocalUriInner { - /// Parse [`LocalUri`] from str. - /// - /// Returns [`LocalUriParse::NotLocal`] when uri is not "local://" - /// Returns [`LocalUriParse::TooManyFields`] when uri have too many paths. - fn parse(value: &str) -> Result { +impl TryFrom<&str> for LocalUriInner { + type Error = LocalUriParseError; + + fn try_from(value: &str) -> Result { if value.is_empty() { return Err(LocalUriParseError::Empty); } @@ -251,7 +249,9 @@ impl LocalUriInner { endpoint_id, }) } +} +impl LocalUriInner { /// Return true if this [`LocalUri`] pointing to `Room` element. fn is_room_uri(&self) -> bool { self.room_id.is_some() @@ -302,8 +302,20 @@ pub enum LocalUriType { } impl LocalUriType { - pub fn parse(value: &str) -> Result { - let inner = LocalUriInner::parse(value)?; + pub fn room_id(&self) -> &RoomId { + match self { + LocalUriType::Room(uri) => uri.room_id(), + LocalUriType::Member(uri) => uri.room_id(), + LocalUriType::Endpoint(uri) => uri.room_id(), + } + } +} + +impl TryFrom<&str> for LocalUriType { + type Error = LocalUriParseError; + + fn try_from(value: &str) -> Result { + let inner = LocalUriInner::try_from(value)?; if inner.is_room_uri() { Ok(LocalUriType::Room(LocalUri::::new( inner.room_id.unwrap(), diff --git a/src/shutdown.rs b/src/shutdown.rs index fb62b9ac4..d741df920 100644 --- a/src/shutdown.rs +++ b/src/shutdown.rs @@ -7,7 +7,7 @@ use std::{ use actix::{ prelude::{Actor, Context}, - Addr, AsyncContext, Handler, Message, Recipient, ResponseActFuture, System, + Addr, AsyncContext, Handler, Message, Recipient, ResponseFuture, System, WrapFuture as _, }; use failure::Fail; @@ -104,18 +104,14 @@ struct OsSignal(i32); #[cfg(unix)] impl Handler for GracefulShutdown { - type Result = ResponseActFuture; + type Result = ResponseFuture<(), ()>; - fn handle( - &mut self, - sig: OsSignal, - _: &mut Context, - ) -> ResponseActFuture { + fn handle(&mut self, sig: OsSignal, _: &mut Context) -> Self::Result { info!("OS signal '{}' received", sig.0); match self.state { State::InProgress => { - return Box::new(future::ok(()).into_actor(self)); + return Box::new(future::ok(())); } State::Listening => { self.state = State::InProgress; @@ -126,7 +122,7 @@ impl Handler for GracefulShutdown { if self.subs.is_empty() { System::current().stop(); - return Box::new(future::ok(()).into_actor(self)); + return Box::new(future::ok(())); } let by_priority: Vec<_> = self @@ -158,8 +154,7 @@ impl Handler for GracefulShutdown { .map(|_| { info!("Graceful shutdown succeeded, stopping system"); System::current().stop() - }) - .into_actor(self), + }), ) } } diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index 3ac41fda5..92c610db2 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -1,18 +1,20 @@ //! Service which control [`Room`]. use actix::{ - fut::wrap_future, Actor, ActorFuture, Addr, AsyncContext as _, Context, - Handler, MailboxError, Message, + fut::wrap_future, Actor, ActorFuture, Addr, Context, Handler, MailboxError, + Message, ResponseFuture, WrapFuture as _, }; use failure::Fail; -use futures::future::{Either, Future}; +use futures::future::{self, Either, Future}; use medea_grpc_proto::control::Element as ElementProto; use crate::{ api::control::{ endpoints::Endpoint as EndpointSpec, load_static_specs_from_dir, - local_uri::{IsEndpointId, IsMemberId, IsRoomId, LocalUri}, + local_uri::{ + IsEndpointId, IsMemberId, IsRoomId, LocalUri, LocalUriType, + }, MemberId, MemberSpec, RoomId, RoomSpec, }, log::prelude::*, @@ -28,6 +30,7 @@ use crate::{ }, AppContext, }; +use serde::export::PhantomData; type ActFuture = Box>; @@ -46,7 +49,7 @@ pub enum RoomServiceError { #[fail(display = "Failed to load static specs. {:?}", _0)] FailedToLoadStaticSpecs(failure::Error), #[fail(display = "Unknow error.")] - Unknow, + Unknown, } impl From for RoomServiceError { @@ -84,6 +87,28 @@ impl RoomService { graceful_shutdown, } } + + fn close_room( + &self, + id: RoomId, + ) -> impl ActorFuture { + if let Some(room) = self.room_repo.get(&id) { + shutdown::unsubscribe( + &self.graceful_shutdown, + room.clone().recipient(), + shutdown::Priority(2), + ); + + actix::fut::Either::A(room.send(Close).into_actor(self).map( + move |_, act, _| { + debug!("Room [id = {}] removed.", id); + act.room_repo.remove(&id); + }, + )) + } else { + actix::fut::Either::B(actix::fut::ok(())) + } + } } impl Actor for RoomService { @@ -165,9 +190,7 @@ impl Handler for RoomService { )); } - let room = msg.1; - - let room = Room::new(&room, self.app.clone())?; + let room = Room::new(&msg.1, self.app.clone())?; let room_addr = room.start(); shutdown::subscribe( @@ -186,90 +209,61 @@ impl Handler for RoomService { /// Signal for delete [`Room`]. #[derive(Message)] #[rtype(result = "Result<(), RoomServiceError>")] -pub struct DeleteRoom(pub RoomId); +pub struct DeleteElements { + uris: Vec, + _marker: PhantomData, +} -impl Handler for RoomService { - type Result = Result<(), RoomServiceError>; +pub struct NotValidated; +pub struct Valid; - fn handle( - &mut self, - msg: DeleteRoom, - ctx: &mut Self::Context, - ) -> Self::Result { - if let Some(room) = self.room_repo.get(&msg.0) { - shutdown::unsubscribe( - &self.graceful_shutdown, - room.clone().recipient(), - shutdown::Priority(2), - ); - let rooms = self.room_repo.clone(); - ctx.spawn(wrap_future( - room.send(Close) - .map(move |_| { - rooms.remove(&msg.0); - debug!("Room [id = {}] removed.", msg.0); - }) - .map_err(|e| warn!("Close room mailbox error {:?}.", e)), - )); +impl DeleteElements { + pub fn new() -> DeleteElements { + Self { + uris: vec![], + _marker: PhantomData, } + } - Ok(()) + pub fn add_uri(&mut self, uri: LocalUriType) { + self.uris.push(uri); } } -/// Signal for delete [`Member`] from [`Room`]. -#[derive(Message)] -#[rtype(result = "Result<(), RoomServiceError>")] -pub struct DeleteMemberFromRoom { - pub member_id: MemberId, - pub room_id: RoomId, -} +impl DeleteElements { + pub fn validate(self) -> Result, RoomServiceError> { + // TODO: correct errors + if self.uris.is_empty() { + return Err(RoomServiceError::Unknown); + } -impl Handler for RoomService { - type Result = Result<(), RoomServiceError>; + let first_room = self.uris[0].room_id(); + let is_same_room = + self.uris.iter().all(|item| item.room_id() == first_room); - fn handle( - &mut self, - msg: DeleteMemberFromRoom, - _ctx: &mut Self::Context, - ) -> Self::Result { - if let Some(room) = self.room_repo.get(&msg.room_id) { - room.do_send(DeleteMember(msg.member_id)); - } else { - return Err(RoomServiceError::RoomNotFound(get_local_uri_to_room( - msg.room_id, - ))); + if !is_same_room { + return Err(RoomServiceError::Unknown); } - Ok(()) + Ok(DeleteElements { + uris: self.uris, + _marker: PhantomData, + }) } } -/// Signal for delete [`Endpoint`] from [`Member`]. -#[derive(Message)] -#[rtype(result = "Result<(), RoomServiceError>")] -pub struct DeleteEndpointFromMember { - pub room_id: RoomId, - pub member_id: MemberId, - pub endpoint_id: String, -} - -impl Handler for RoomService { +impl Handler> for RoomService { type Result = Result<(), RoomServiceError>; fn handle( &mut self, - msg: DeleteEndpointFromMember, - _ctx: &mut Self::Context, + mut msg: DeleteElements, + _: &mut Self::Context, ) -> Self::Result { - if let Some(room) = self.room_repo.get(&msg.room_id) { - room.do_send(DeleteEndpoint { - endpoint_id: msg.endpoint_id, - member_id: msg.member_id, - }); - } + // TODO: handle room delete here, send batch to room, handle it atomically + // just discard other messages if room delete present - Ok(()) + unimplemented!() } } @@ -305,7 +299,7 @@ impl Handler for RoomService { }), ) } else { - return Box::new(wrap_future(futures::future::err( + return Box::new(wrap_future(future::err( RoomServiceError::RoomNotFound(get_local_uri_to_room( room_id, )), @@ -313,7 +307,7 @@ impl Handler for RoomService { } } - Box::new(wrap_future(futures::future::join_all(futs))) + Box::new(wrap_future(future::join_all(futs))) } } @@ -348,7 +342,7 @@ impl Handler for RoomService { }), ) } else { - return Box::new(wrap_future(futures::future::err( + return Box::new(wrap_future(future::err( RoomServiceError::RoomNotFound(get_local_uri_to_room( room_id, )), @@ -356,7 +350,7 @@ impl Handler for RoomService { } } - Box::new(wrap_future(futures::future::join_all(futs))) + Box::new(wrap_future(future::join_all(futs))) } } @@ -395,7 +389,7 @@ impl Handler for RoomService { }), ); } else { - return Box::new(wrap_future(futures::future::err( + return Box::new(wrap_future(future::err( RoomServiceError::RoomNotFound(get_local_uri_to_room( room_id, )), @@ -403,7 +397,7 @@ impl Handler for RoomService { } } - Box::new(wrap_future(futures::future::join_all(futs))) + Box::new(wrap_future(future::join_all(futs))) } } @@ -430,7 +424,7 @@ impl Handler for RoomService { .map_err(RoomServiceError::from), ) } else { - Either::B(futures::future::err(RoomServiceError::RoomNotFound( + Either::B(future::err(RoomServiceError::RoomNotFound( get_local_uri_to_room(msg.room_id), ))) }; @@ -467,7 +461,7 @@ impl Handler for RoomService { .map_err(RoomServiceError::from), ) } else { - Either::B(futures::future::err(RoomServiceError::RoomNotFound( + Either::B(future::err(RoomServiceError::RoomNotFound( get_local_uri_to_room(msg.room_id), ))) }; From 495c4e374f97830dcb47a3e81dac856885b10a03 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 6 Sep 2019 02:18:41 +0300 Subject: [PATCH 576/735] Reread --- src/lib.rs | 6 +++--- src/media/peer.rs | 4 ++-- .../elements/endpoints/webrtc/play_endpoint.rs | 10 ++++++---- .../endpoints/webrtc/publish_endpoint.rs | 9 ++++++--- src/signalling/elements/member.rs | 8 ++++---- src/signalling/participants.rs | 6 +++--- src/signalling/peers.rs | 18 ++++++++++-------- src/signalling/room.rs | 11 +++++++---- tests/e2e/signalling/mod.rs | 10 +++++----- tests/e2e/signalling/three_pubs.rs | 1 + 10 files changed, 47 insertions(+), 36 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index f71206970..ea4c8de16 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -36,15 +36,15 @@ pub enum ServerStartError { #[display(fmt = "Duplicate of room ID '{:?}'", _0)] DuplicateRoomId(RoomId), - /// Some error happened while loading spec. + /// Some error happened while loading Control API spec. #[display(fmt = "Failed to load specs. {}", _0)] LoadSpec(failure::Error), - /// Some error happened while creating new room from spec. + /// Some error happened while creating new [`Room`] from Control API spec. #[display(fmt = "Bad room spec. {}", _0)] BadRoomSpec(String), - /// Unexpected error returned from room. + /// Unexpected error returned from [`Room`]. #[display(fmt = "Unknown room error.")] UnknownRoomError, } diff --git a/src/media/peer.rs b/src/media/peer.rs index f7738fc08..4b7827986 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -269,8 +269,8 @@ impl Peer { MediaType::Video(VideoSettings {}), )); - self.add_sender(track_video.clone()); - self.add_sender(track_audio.clone()); + self.add_sender(Rc::clone(&track_video)); + self.add_sender(Rc::clone(&track_audio)); partner_peer.add_receiver(track_video); partner_peer.add_receiver(track_audio); diff --git a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs index c44d87ded..84052b94e 100644 --- a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs @@ -89,7 +89,9 @@ impl Drop for WebRtcPlayEndpointInner { } } -/// Signalling representation of `WebRtcPlayEndpoint`. +/// Signalling representation of Control API's [`WebRtcPlayEndpoint`]. +/// +/// [`WebRtcPlayEndpoint`]: crate::api::control::endpoint::WebRtcPlayEndpoint #[allow(clippy::module_name_repetitions)] #[derive(Debug, Clone)] pub struct WebRtcPlayEndpoint(Rc>); @@ -123,15 +125,15 @@ impl WebRtcPlayEndpoint { self.0.borrow().owner() } - /// Returns `Weak` pointer to owner [`Member`] of this + /// Returns weak pointer to owner [`Member`] of this /// [`WebRtcPlayEndpoint`]. pub fn weak_owner(&self) -> WeakMember { self.0.borrow().weak_owner() } - /// Returns source's [`WebRtcPublishEndpoint`]. + /// Returns srcs's [`WebRtcPublishEndpoint`]. /// - /// __This function will panic if pointer is empty.__ + /// __This function will panic if weak pointer was dropped.__ pub fn src(&self) -> WebRtcPublishEndpoint { self.0.borrow().src() } diff --git a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs index 158237d1b..7bf36a17e 100644 --- a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs @@ -22,7 +22,7 @@ use super::play_endpoint::WebRtcPlayEndpoint; #[doc(inline)] pub use Id as WebRtcPublishId; -/// ID of endpoint. +/// ID of [`WebRtcPublishEndpoint`]. #[derive(Clone, Debug, Eq, Hash, PartialEq, From, Display)] pub struct Id(pub String); @@ -102,7 +102,10 @@ impl WebRtcPublishEndpointInner { } } -/// Signalling representation of `WebRtcPublishEndpoint`. +/// Signalling representation of [`WebRtcPublishEndpoint`]. +/// +/// [`WebRtcPublishEndpoint`]: +/// crate::api::control::endpoint::WebRtcPublishEndpoint #[allow(clippy::module_name_repetitions)] #[derive(Debug, Clone)] pub struct WebRtcPublishEndpoint(Rc>); @@ -161,7 +164,7 @@ impl WebRtcPublishEndpoint { self.0.borrow_mut().reset() } - /// Remove [`PeerId`] from `peer_ids`. + /// Remove [`PeerId`] from this [`WebRtcPublishEndpoint`]'s `peer_ids`. #[allow(clippy::trivially_copy_pass_by_ref)] pub fn remove_peer_id(&self, peer_id: &PeerId) { self.0.borrow_mut().remove_peer_id(peer_id) diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index 70d78dcf1..a310b318b 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -198,12 +198,12 @@ impl Member { /// [`Peer`]: crate::media::peer::Peer pub fn peers_removed(&self, peer_ids: &[PeerId]) { self.srcs() - .into_iter() - .for_each(|(_, p)| p.remove_peer_ids(peer_ids)); + .values() + .for_each(|p| p.remove_peer_ids(peer_ids)); self.sinks() - .into_iter() - .filter_map(|(_, p)| p.peer_id().map(|id| (id, p))) + .values() + .filter_map(|p| p.peer_id().map(|id| (id, p))) .filter(|(id, _)| peer_ids.contains(&id)) .for_each(|(_, p)| p.reset()); } diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index b5d29fd56..fcec73f93 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -174,7 +174,7 @@ impl ParticipantService { &mut self, ctx: &mut Context, member_id: MemberId, - con: Box, + conn: Box, ) -> ActFuture { let member = match self.get_member_by_id(&member_id) { None => { @@ -208,7 +208,7 @@ impl ParticipantService { }) .and_then( move |ice: IceUser, room: &mut Room, _| { - room.members.insert_connection(member_id, con); + room.members.insert_connection(member_id, conn); member.replace_ice_user(ice); wrap_future(future::ok(member)) @@ -257,7 +257,7 @@ impl ParticipantService { info!( "Member {} connection lost at {:?}. Room will be \ stopped.", - &member_id, closed_at + member_id, closed_at ); ctx.notify(RpcConnectionClosed { member_id, diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index f06e29f4a..3c7923459 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -78,25 +78,27 @@ impl PeerRepository { first_member: &Member, second_member: &Member, ) -> (Peer, Peer) { + let first_member_id = first_member.id(); + let second_member_id = second_member.id(); + debug!( "Created peer between {} and {}.", - first_member.id(), - second_member.id() + first_member_id, second_member_id ); let first_peer_id = self.peers_count.next_id(); let second_peer_id = self.peers_count.next_id(); let first_peer = Peer::new( first_peer_id, - first_member.id(), + first_member_id.clone(), second_peer_id, - second_member.id(), + second_member_id.clone(), ); let second_peer = Peer::new( second_peer_id, - second_member.id(), + second_member_id, first_peer_id, - first_member.id(), + first_member_id, ); (first_peer, second_peer) @@ -214,9 +216,9 @@ impl PeerRepository { } impl From> for PeerRepository { - fn from(map: HashMap) -> Self { + fn from(peers: HashMap) -> Self { Self { - peers: map, + peers, peers_count: Counter::default(), tracks_count: Counter::default(), } diff --git a/src/signalling/room.rs b/src/signalling/room.rs index f2e2a7cc2..0b528f403 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -100,7 +100,8 @@ enum State { pub struct Room { id: RoomId, - /// [`RpcConnection`]s of [`Member`]s in this [`Room`]. + /// [`Member`]s and associated [`RpcConnection`]s of this [`Room`], handles + /// [`RpcConnection`] authorization, establishment, message sending. /// /// [`RpcConnection`]: crate::api::client::rpc_connection::RpcConnection pub members: ParticipantService, @@ -192,11 +193,13 @@ impl Room { fn send_peers_removed( &mut self, member_id: MemberId, - peers: Vec, + removed_peers_ids: Vec, ) -> ActFuture<(), RoomError> { Box::new(wrap_future(self.members.send_event_to_member( member_id, - Event::PeersRemoved { peer_ids: peers }, + Event::PeersRemoved { + peer_ids: removed_peers_ids, + }, ))) } @@ -612,7 +615,7 @@ impl Handler for Room { msg: RpcConnectionEstablished, ctx: &mut Self::Context, ) -> Self::Result { - info!("RpcConnectionEstablished for member {}", &msg.member_id); + info!("RpcConnectionEstablished for member {}", msg.member_id); let fut = self .members diff --git a/tests/e2e/signalling/mod.rs b/tests/e2e/signalling/mod.rs index eadeaf8eb..61ee899c6 100644 --- a/tests/e2e/signalling/mod.rs +++ b/tests/e2e/signalling/mod.rs @@ -138,7 +138,6 @@ impl StreamHandler for TestMember { let txt = String::from_utf8(txt.unwrap().to_vec()).unwrap(); let event: Result = serde_json::from_str(&txt); if let Ok(event) = event { - self.events.push(event.clone()); // Test function call (self.on_message)(&event, ctx); @@ -147,15 +146,15 @@ impl StreamHandler for TestMember { sdp_offer, tracks, .. - } = event + } = &event { match sdp_offer { Some(_) => self.send_command(Command::MakeSdpAnswer { - peer_id, + peer_id: *peer_id, sdp_answer: "responder_answer".into(), }), None => self.send_command(Command::MakeSdpOffer { - peer_id, + peer_id: *peer_id, sdp_offer: "caller_offer".into(), mids: tracks .into_iter() @@ -167,7 +166,7 @@ impl StreamHandler for TestMember { } self.send_command(Command::SetIceCandidate { - peer_id, + peer_id: *peer_id, candidate: IceCandidate { candidate: "ice_candidate".to_string(), sdp_m_line_index: None, @@ -175,6 +174,7 @@ impl StreamHandler for TestMember { }, }); } + self.events.push(event); } } } diff --git a/tests/e2e/signalling/three_pubs.rs b/tests/e2e/signalling/three_pubs.rs index 3e6e845bd..21180d2e7 100644 --- a/tests/e2e/signalling/three_pubs.rs +++ b/tests/e2e/signalling/three_pubs.rs @@ -22,6 +22,7 @@ fn three_members_p2p_video_call() { let members_peers_removed = Rc::new(Cell::new(0)); let test_fn = move |event: &Event, ctx: &mut Context| { + // TODO: this is unnecessary clone, try use events from TestMember events.push(event.clone()); match event { Event::PeerCreated { ice_servers, .. } => { From 891baa41cf7aecbb15976d82dbe9e26d61dde85c Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 6 Sep 2019 10:21:37 +0300 Subject: [PATCH 577/735] Remove events cloning in e2e tests [run ci] --- tests/e2e/signalling/mod.rs | 10 +++++++--- tests/e2e/signalling/pub_sub_signallng.rs | 7 +++---- tests/e2e/signalling/three_pubs.rs | 7 +++---- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/tests/e2e/signalling/mod.rs b/tests/e2e/signalling/mod.rs index 61ee899c6..d2778238f 100644 --- a/tests/e2e/signalling/mod.rs +++ b/tests/e2e/signalling/mod.rs @@ -35,7 +35,7 @@ pub struct TestMember { /// Function which will be called at every received by this [`TestMember`] /// [`Event`]. - on_message: Box)>, + on_message: Box, Vec<&Event>)>, } impl TestMember { @@ -64,7 +64,9 @@ impl TestMember { /// received from server. pub fn start( uri: &str, - on_message: Box)>, + on_message: Box< + dyn FnMut(&Event, &mut Context, Vec<&Event>), + >, deadline: Option, ) { Arbiter::spawn( @@ -138,8 +140,10 @@ impl StreamHandler for TestMember { let txt = String::from_utf8(txt.unwrap().to_vec()).unwrap(); let event: Result = serde_json::from_str(&txt); if let Ok(event) = event { + let mut events: Vec<&Event> = self.events.iter().collect(); + events.push(&event); // Test function call - (self.on_message)(&event, ctx); + (self.on_message)(&event, ctx, events); if let Event::PeerCreated { peer_id, diff --git a/tests/e2e/signalling/pub_sub_signallng.rs b/tests/e2e/signalling/pub_sub_signallng.rs index 1b3f430f7..23c2ff90b 100644 --- a/tests/e2e/signalling/pub_sub_signallng.rs +++ b/tests/e2e/signalling/pub_sub_signallng.rs @@ -10,10 +10,9 @@ fn pub_sub_video_call() { // Note that events is separated by members. // Every member will have different instance of this. - let mut events = Vec::new(); - let test_fn = move |event: &Event, _: &mut Context| { - events.push(event.clone()); - + let test_fn = move |event: &Event, + _: &mut Context, + events: Vec<&Event>| { // Start checking result of test. if let Event::IceCandidateDiscovered { .. } = event { let peers_count = events diff --git a/tests/e2e/signalling/three_pubs.rs b/tests/e2e/signalling/three_pubs.rs index 21180d2e7..dc6265a27 100644 --- a/tests/e2e/signalling/three_pubs.rs +++ b/tests/e2e/signalling/three_pubs.rs @@ -13,7 +13,6 @@ fn three_members_p2p_video_call() { // Note that events, peer_created_count, ice_candidates // is separated by members. // Every member will have different instance of this. - let mut events = Vec::new(); let mut peer_created_count = 0; let mut ice_candidates = 0; @@ -21,9 +20,9 @@ fn three_members_p2p_video_call() { let members_tested = Rc::new(Cell::new(0)); let members_peers_removed = Rc::new(Cell::new(0)); - let test_fn = move |event: &Event, ctx: &mut Context| { - // TODO: this is unnecessary clone, try use events from TestMember - events.push(event.clone()); + let test_fn = move |event: &Event, + ctx: &mut Context, + events: Vec<&Event>| { match event { Event::PeerCreated { ice_servers, .. } => { assert_eq!(ice_servers.len(), 2); From 45417ab4a3e8fd19f579c519226f9a886bbb0d6e Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 6 Sep 2019 12:45:44 +0300 Subject: [PATCH 578/735] Reread [run ci] --- proto/client-api/src/lib.rs | 2 +- src/api/client/server.rs | 3 +-- src/api/control/endpoint.rs | 2 +- src/api/control/mod.rs | 2 +- src/api/control/room.rs | 2 +- src/media/peer.rs | 2 +- .../elements/endpoints/webrtc/publish_endpoint.rs | 4 ++-- src/signalling/elements/member.rs | 14 ++++++++------ src/signalling/participants.rs | 2 +- src/signalling/room.rs | 4 ++-- src/turn/repo.rs | 2 +- src/turn/service.rs | 2 +- 12 files changed, 21 insertions(+), 20 deletions(-) diff --git a/proto/client-api/src/lib.rs b/proto/client-api/src/lib.rs index 243387697..64cd50237 100644 --- a/proto/client-api/src/lib.rs +++ b/proto/client-api/src/lib.rs @@ -26,7 +26,7 @@ pub struct TrackId(pub u64); /// Value that is able to be incremented by `1`. #[cfg(feature = "medea")] -pub trait Incrementable: Sized + Clone { +pub trait Incrementable { /// Returns current value + 1. fn incr(&self) -> Self; } diff --git a/src/api/client/server.rs b/src/api/client/server.rs index 3e89becac..d9cd8df00 100644 --- a/src/api/client/server.rs +++ b/src/api/client/server.rs @@ -160,7 +160,6 @@ mod test { control::load_from_yaml_file("tests/specs/pub-sub-video-call.yml") .unwrap(); - let room_id = room_spec.id.clone(); let client_room = Room::new( &room_spec, conf.reconnect_timeout, @@ -169,7 +168,7 @@ mod test { .unwrap() .start(); let rooms = hashmap! { - room_id => client_room, + room_spec.id => client_room, }; RoomRepository::new(rooms) diff --git a/src/api/control/endpoint.rs b/src/api/control/endpoint.rs index 58ca04dd5..cad17adb1 100644 --- a/src/api/control/endpoint.rs +++ b/src/api/control/endpoint.rs @@ -92,7 +92,7 @@ pub struct SrcUri { /// ID of `Member` pub member_id: MemberId, - /// Control ID of [`Endpoint`] + /// Control API ID of [`Endpoint`] pub endpoint_id: String, } diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index bb4103456..1b4eb25a0 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -45,7 +45,7 @@ pub enum RootElement { /// /// [`TryFrom`]: std::convert::TryFrom #[allow(clippy::pub_enum_variant_names)] -#[derive(Debug, Fail, Display)] +#[derive(Debug, Display, Fail)] pub enum TryFromElementError { #[display(fmt = "Element is not Room")] NotRoom, diff --git a/src/api/control/room.rs b/src/api/control/room.rs index 5997ba559..f303e6585 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -16,7 +16,7 @@ use super::{ /// ID of [`Room`]. /// /// [`Room`]: crate::signalling::room::Room -#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, From, Display)] +#[derive(Clone, Debug, Deserialize, Display, Eq, Hash, PartialEq, From)] pub struct Id(pub String); /// Element of [`Room`]'s [`Pipeline`]. diff --git a/src/media/peer.rs b/src/media/peer.rs index 4b7827986..7c1b952ab 100644 --- a/src/media/peer.rs +++ b/src/media/peer.rs @@ -39,7 +39,7 @@ pub struct WaitRemoteSdp {} pub struct Stable {} /// Produced when unwrapping [`PeerStateMachine`] to [`Peer`] with wrong state. -#[derive(Fail, Debug, Display)] +#[derive(Debug, Display, Fail)] #[allow(clippy::module_name_repetitions)] pub enum PeerError { #[display( diff --git a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs index 7bf36a17e..6f7421e24 100644 --- a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs @@ -26,7 +26,7 @@ pub use Id as WebRtcPublishId; #[derive(Clone, Debug, Eq, Hash, PartialEq, From, Display)] pub struct Id(pub String); -#[derive(Debug, Clone)] +#[derive(Clone, Debug)] struct WebRtcPublishEndpointInner { /// ID of this [`WebRtcPublishEndpoint`]. id: Id, @@ -205,7 +205,7 @@ impl WebRtcPublishEndpoint { /// Weak pointer to [`WebRtcPublishEndpoint`]. #[allow(clippy::module_name_repetitions)] -#[derive(Debug, Clone)] +#[derive(Clone, Debug)] pub struct WeakWebRtcPublishEndpoint(Weak>); impl WeakWebRtcPublishEndpoint { diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index a310b318b..82e807483 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -24,7 +24,7 @@ use super::endpoints::webrtc::{ }; /// Errors which may occur while loading [`Member`]s from [`RoomSpec`]. -#[derive(Debug, Fail, Display)] +#[derive(Debug, Display, Fail)] pub enum MembersLoadError { /// Errors that can occur when we try transform some spec from `Element`. #[display(fmt = "TryFromElementError: {}", _0)] @@ -56,6 +56,7 @@ pub struct Member(Rc>); #[allow(clippy::module_name_repetitions)] #[derive(Debug)] struct MemberInner { + /// ID of this [`Member`]. id: MemberId, /// All [`WebRtcPublishEndpoint`]s of this [`Member`]. @@ -108,9 +109,10 @@ impl Member { { let publisher_id = MemberId(spec_play_endpoint.src.member_id.to_string()); - let publisher_member = store - .get(&publisher_id) - .ok_or(MembersLoadError::MemberNotFound(publisher_id))?; + let publisher_member = + store.get(&publisher_id).ok_or_else(|| { + MembersLoadError::MemberNotFound(publisher_id) + })?; let publisher_spec = MemberSpec::try_from( room_spec .pipeline @@ -138,7 +140,7 @@ impl Member { let new_play_endpoint_id = WebRtcPlayId(spec_play_name.to_string()); let new_play_endpoint = WebRtcPlayEndpoint::new( - new_play_endpoint_id.clone(), + new_play_endpoint_id, spec_play_endpoint.src.clone(), publisher.downgrade(), this_member.downgrade(), @@ -152,7 +154,7 @@ impl Member { spec_play_endpoint.src.endpoint_id.to_string(), ); let new_publish = WebRtcPublishEndpoint::new( - new_publish_id.clone(), + new_publish_id, publisher_endpoint.p2p.clone(), Vec::new(), publisher_member.downgrade(), diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index fcec73f93..fbfd71af3 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -187,7 +187,7 @@ impl ParticipantService { // lookup previous member connection if let Some(mut connection) = self.connections.remove(&member_id) { - debug!("Closing old RpcConnection for participant {}", &member_id); + debug!("Closing old RpcConnection for member [id = {}]", member_id); // cancel RpcConnection close task, since connection is // reestablished diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 0b528f403..0be9295a4 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -477,10 +477,10 @@ impl Room { self.members .drop_connections(ctx) .into_actor(self) - .map(move |_, room: &mut Self, _| { + .map(|_, room: &mut Self, _| { room.state = State::Stopped; }) - .map_err(move |_, room, _| { + .map_err(|_, room, _| { error!("Error closing room {:?}", room.id); }), ) diff --git a/src/turn/repo.rs b/src/turn/repo.rs index 4a91d773a..5965b92af 100644 --- a/src/turn/repo.rs +++ b/src/turn/repo.rs @@ -13,7 +13,7 @@ use tokio::prelude::*; use crate::{log::prelude::*, media::IceUser}; -#[derive(Fail, Debug, Display)] +#[derive(Debug, Display, Fail)] pub enum TurnDatabaseErr { #[display(fmt = "Redis returned error: {}", _0)] RedisError(RedisError), diff --git a/src/turn/service.rs b/src/turn/service.rs index c6ec2978f..ab9c2b80a 100644 --- a/src/turn/service.rs +++ b/src/turn/service.rs @@ -97,7 +97,7 @@ type ActFuture = Box>; /// Error which can happen in [`TurnAuthService`]. -#[derive(Debug, Fail, Display)] +#[derive(Display, Debug, Fail)] pub enum TurnServiceErr { #[display(fmt = "Error accessing TurnAuthRepo: {}", _0)] TurnAuthRepoErr(TurnDatabaseErr), From 3186fbf59bf5dbf61c24b1520f7cd06468581025 Mon Sep 17 00:00:00 2001 From: alexlapa Date: Fri, 6 Sep 2019 16:00:29 +0300 Subject: [PATCH 579/735] minor refactor [run ci] --- tests/e2e/signalling/mod.rs | 10 +++++----- tests/e2e/signalling/pub_sub_signallng.rs | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/e2e/signalling/mod.rs b/tests/e2e/signalling/mod.rs index d2778238f..6e1cf59b7 100644 --- a/tests/e2e/signalling/mod.rs +++ b/tests/e2e/signalling/mod.rs @@ -19,6 +19,8 @@ use futures::{future::Future, sink::Sink, stream::SplitSink, Stream}; use medea_client_api_proto::{Command, Event, IceCandidate}; use serde_json::error::Error as SerdeError; +pub type MessageHandler = Box, Vec<&Event>)>; + /// Medea client for testing purposes. pub struct TestMember { /// Writer to WebSocket. @@ -35,7 +37,7 @@ pub struct TestMember { /// Function which will be called at every received by this [`TestMember`] /// [`Event`]. - on_message: Box, Vec<&Event>)>, + on_message: MessageHandler, } impl TestMember { @@ -64,9 +66,7 @@ impl TestMember { /// received from server. pub fn start( uri: &str, - on_message: Box< - dyn FnMut(&Event, &mut Context, Vec<&Event>), - >, + on_message: MessageHandler, deadline: Option, ) { Arbiter::spawn( @@ -161,7 +161,7 @@ impl StreamHandler for TestMember { peer_id: *peer_id, sdp_offer: "caller_offer".into(), mids: tracks - .into_iter() + .iter() .map(|t| t.id) .enumerate() .map(|(mid, id)| (id, mid.to_string())) diff --git a/tests/e2e/signalling/pub_sub_signallng.rs b/tests/e2e/signalling/pub_sub_signallng.rs index 23c2ff90b..0545b7922 100644 --- a/tests/e2e/signalling/pub_sub_signallng.rs +++ b/tests/e2e/signalling/pub_sub_signallng.rs @@ -93,7 +93,7 @@ fn pub_sub_video_call() { let deadline = Some(std::time::Duration::from_secs(5)); TestMember::start( &format!("{}/caller/test", base_url), - Box::new(test_fn.clone()), + Box::new(test_fn), deadline, ); TestMember::start( From 913d8b9f4bbcb909a8bd49a81371ef7fa1c46bef Mon Sep 17 00:00:00 2001 From: alexlapa Date: Fri, 6 Sep 2019 16:41:27 +0300 Subject: [PATCH 580/735] stable rustfmt [run ci] --- .travis.yml | 2 +- Makefile | 2 +- tests/e2e/signalling/mod.rs | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index c6c412f8a..bb44dbe43 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,7 +30,7 @@ jobs: - name: rustfmt stage: check - rust: nightly + rust: stable cache: false before_script: rustup component add rustfmt script: make fmt check=yes diff --git a/Makefile b/Makefile index bccf59691..2e9d302a7 100644 --- a/Makefile +++ b/Makefile @@ -197,7 +197,7 @@ cargo: # make cargo.fmt [check=(no|yes)] cargo.fmt: - cargo +nightly fmt --all $(if $(call eq,$(check),yes),-- --check,) + cargo fmt --all $(if $(call eq,$(check),yes),-- --check,) # Lint Rust sources with clippy. diff --git a/tests/e2e/signalling/mod.rs b/tests/e2e/signalling/mod.rs index 6e1cf59b7..8146e2078 100644 --- a/tests/e2e/signalling/mod.rs +++ b/tests/e2e/signalling/mod.rs @@ -19,7 +19,8 @@ use futures::{future::Future, sink::Sink, stream::SplitSink, Stream}; use medea_client_api_proto::{Command, Event, IceCandidate}; use serde_json::error::Error as SerdeError; -pub type MessageHandler = Box, Vec<&Event>)>; +pub type MessageHandler = + Box, Vec<&Event>)>; /// Medea client for testing purposes. pub struct TestMember { From 2c4e830af812f16f456817da787ef7286fb01076 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 6 Sep 2019 17:03:21 +0300 Subject: [PATCH 581/735] Implement batch delete --- src/api/control/grpc/server.rs | 24 ++--- src/bin/client.rs | 10 +- src/signalling/room.rs | 176 ++++++++++++++++++--------------- src/signalling/room_service.rs | 68 +++++++++---- 4 files changed, 161 insertions(+), 117 deletions(-) diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index ec2c61c5d..a3f241f4d 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -50,6 +50,7 @@ use crate::{ use crate::{ api::control::{MemberId, RoomId}, shutdown::ShutdownGracefully, + signalling::room_service::NotValidated, }; #[derive(Debug, Fail)] @@ -309,8 +310,8 @@ impl ControlApi for ControlApiService { // ctx, // sink, // ErrorResponse::new( - // - // ErrorCode::ElementIdForRoomButElementIsNot, + // + // ErrorCode::ElementIdForRoomButElementIsNot, // &req.get_id(), ), // Response // ); @@ -320,8 +321,8 @@ impl ControlApi for ControlApiService { // if req.has_member() { // ctx.spawn(self.create_member(&req, // local_uri).then( move |r| { - // - // sink.success(get_response_for_create(r)).map_err( + // + // sink.success(get_response_for_create(r)).map_err( // |e| { warn!( // "Error while sending Create // response \ by gRPC. @@ -336,8 +337,8 @@ impl ControlApi for ControlApiService { // ctx, // sink, // ErrorResponse::new( - // - // ErrorCode::ElementIdForMemberButElementIsNot, + // + // ErrorCode::ElementIdForMemberButElementIsNot, // &req.get_id(), ), // Response // ); @@ -347,8 +348,8 @@ impl ControlApi for ControlApiService { // if req.has_webrtc_pub() || req.has_webrtc_play() { // ctx.spawn(self.create_endpoint(&req, // local_uri).then( move |r| { - // - // sink.success(get_response_for_create(r)).map_err( + // + // sink.success(get_response_for_create(r)).map_err( // |e| { warn!( // "Error while sending Create // response \ by gRPC. @@ -363,8 +364,8 @@ impl ControlApi for ControlApiService { // ctx, // sink, // ErrorResponse::new( - // - // ErrorCode::ElementIdForEndpointButElementIsNot, + // + // ErrorCode::ElementIdForEndpointButElementIsNot, // &req.get_id(), ), // Response // ); @@ -420,7 +421,8 @@ impl ControlApi for ControlApiService { let mut response = Response::new(); // TODO: dont use unknown, add some special err for all - // mailbox errs, Unavailable("ActorName") or something + // mailbox errs, Unavailable("ActorName") or + // something let error: Error = ErrorResponse::unknown(&format!("{:?}", e)).into(); response.set_error(error); diff --git a/src/bin/client.rs b/src/bin/client.rs index 81d483b4b..2fac580e9 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -17,13 +17,13 @@ fn main() { let ch = ChannelBuilder::new(env).connect("localhost:50051"); let client = ControlApiClient::new(ch); - create_room(&client); - delete_room(&client); + // create_room(&client); + // delete_room(&client); delete_endpoint(&client); delete_member(&client); - create_member(&client); - create_endpoint(&client); - get_room(&client); + // create_member(&client); + // create_endpoint(&client); + // get_room(&client); } fn create_room(client: &ControlApiClient) { diff --git a/src/signalling/room.rs b/src/signalling/room.rs index e8393e821..17916cde4 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -24,7 +24,7 @@ use crate::{ RpcConnectionClosed, RpcConnectionEstablished, }, control::{ - local_uri::{IsMemberId, LocalUri}, + local_uri::{IsMemberId, LocalUri, LocalUriType}, room::RoomSpec, Endpoint as EndpointSpec, MemberId, MemberSpec, RoomId, TryFromElementError, WebRtcPlayId, WebRtcPublishId, @@ -566,6 +566,76 @@ impl Room { self.member_peers_removed(peers_id, member_id, ctx); } } + + /// Signal for delete [`Member`] from this [`Room`] + fn delete_member(&mut self, member_id: MemberId, ctx: &mut Context) { + debug!( + "Delete Member [id = {}] in room [id = {}].", + member_id, self.id + ); + if let Some(member) = self.members.get_member_by_id(&member_id) { + let mut peers = HashSet::new(); + for (_, sink) in member.sinks() { + if let Some(peer_id) = sink.peer_id() { + peers.insert(peer_id); + } + } + + for (_, src) in member.srcs() { + for peer_id in src.peer_ids() { + peers.insert(peer_id); + } + } + + self.remove_peers(&member.id(), peers, ctx); + } + + self.members.delete_member(&member_id, ctx); + + debug!( + "Member [id = {}] removed from Room [id = {}].", + member_id, self.id + ); + } + + /// Signal for delete endpoint from this [`Room`] + fn delete_endpoint( + &mut self, + member_id: MemberId, + endpoint_id: String, + ctx: &mut Context, + ) { + let endpoint_id = if let Some(member) = + self.members.get_member_by_id(&member_id) + { + let play_id = WebRtcPlayId(endpoint_id); + if let Some(endpoint) = member.take_sink(&play_id) { + if let Some(peer_id) = endpoint.peer_id() { + let removed_peers = + self.peers.remove_peer(&member_id, peer_id); + for (member_id, peers_ids) in removed_peers { + self.member_peers_removed(peers_ids, member_id, ctx); + } + } + } + + let publish_id = WebRtcPublishId(play_id.0); + if let Some(endpoint) = member.take_src(&publish_id) { + let peer_ids = endpoint.peer_ids(); + self.remove_peers(&member_id, peer_ids, ctx); + } + + publish_id.0 + } else { + endpoint_id + }; + + debug!( + "Endpoint [id = {}] removed in Member [id = {}] from Room [id = \ + {}].", + endpoint_id, member_id, self.id + ); + } } /// [`Actor`] implementation that provides an ergonomic way @@ -858,95 +928,37 @@ impl Handler for Room { } } -/// Signal for delete [`Member`] from this [`Room`] -#[derive(Debug, Message, Clone)] +#[derive(Message, Debug)] #[rtype(result = "()")] -pub struct DeleteMember(pub MemberId); +pub struct Delete(pub Vec); -impl Handler for Room { +impl Handler for Room { type Result = (); - fn handle( - &mut self, - msg: DeleteMember, - ctx: &mut Self::Context, - ) -> Self::Result { - debug!("Delete Member [id = {}] in room [id = {}].", msg.0, self.id); - if let Some(member) = self.members.get_member_by_id(&msg.0) { - let mut peers = HashSet::new(); - for (_, sink) in member.sinks() { - if let Some(peer_id) = sink.peer_id() { - peers.insert(peer_id); + fn handle(&mut self, msg: Delete, ctx: &mut Self::Context) { + let mut member_ids = Vec::new(); + let mut endpoint_ids = Vec::new(); + for id in msg.0 { + match id { + LocalUriType::Member(member_uri) => { + member_ids.push(member_uri); } - } - - for (_, src) in member.srcs() { - for peer_id in src.peer_ids() { - peers.insert(peer_id); + LocalUriType::Endpoint(endpoint_uri) => { + endpoint_ids.push(endpoint_uri); } + // TODO (evdokimovs): better message + _ => warn!("Delete method in Room found LocalUri."), } - - self.remove_peers(&member.id(), peers, ctx); } - - self.members.delete_member(&msg.0, ctx); - - debug!( - "Member [id = {}] removed from Room [id = {}].", - msg.0, self.id - ); - } -} - -/// Signal for delete endpoint from this [`Room`] -#[derive(Debug, Message, Clone)] -#[rtype(result = "()")] -pub struct DeleteEndpoint { - pub member_id: MemberId, - pub endpoint_id: String, -} - -impl Handler for Room { - type Result = (); - - fn handle( - &mut self, - msg: DeleteEndpoint, - ctx: &mut Self::Context, - ) -> Self::Result { - let member_id = msg.member_id; - let endpoint_id = msg.endpoint_id; - - let endpoint_id = if let Some(member) = - self.members.get_member_by_id(&member_id) - { - let play_id = WebRtcPlayId(endpoint_id); - if let Some(endpoint) = member.take_sink(&play_id) { - if let Some(peer_id) = endpoint.peer_id() { - let removed_peers = - self.peers.remove_peer(&member_id, peer_id); - for (member_id, peers_ids) in removed_peers { - self.member_peers_removed(peers_ids, member_id, ctx); - } - } - } - - let publish_id = WebRtcPublishId(play_id.0); - if let Some(endpoint) = member.take_src(&publish_id) { - let peer_ids = endpoint.peer_ids(); - self.remove_peers(&member_id, peer_ids, ctx); - } - - publish_id.0 - } else { - endpoint_id - }; - - debug!( - "Endpoint [id = {}] removed in Member [id = {}] from Room [id = \ - {}].", - endpoint_id, member_id, self.id - ); + member_ids.into_iter().for_each(|uri| { + let (member_id, _) = uri.take_member_id(); + self.delete_member(member_id, ctx); + }); + endpoint_ids.into_iter().for_each(|uri| { + let (endpoint_id, member_uri) = uri.take_endpoint_id(); + let (member_id, _) = member_uri.take_member_id(); + self.delete_endpoint(member_id, endpoint_id, ctx); + }); } } diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index 92c610db2..660d11752 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -21,8 +21,8 @@ use crate::{ shutdown::{self, GracefulShutdown}, signalling::{ room::{ - Close, CreateEndpoint, CreateMember, DeleteEndpoint, DeleteMember, - RoomError, SerializeProtobufEndpoint, SerializeProtobufMember, + Close, CreateEndpoint, CreateMember, Delete, RoomError, + SerializeProtobufEndpoint, SerializeProtobufMember, SerializeProtobufRoom, }, room_repo::RoomRepository, @@ -88,10 +88,7 @@ impl RoomService { } } - fn close_room( - &self, - id: RoomId, - ) -> impl ActorFuture { + fn close_room(&self, id: RoomId) -> ActFuture<(), MailboxError> { if let Some(room) = self.room_repo.get(&id) { shutdown::unsubscribe( &self.graceful_shutdown, @@ -99,14 +96,12 @@ impl RoomService { shutdown::Priority(2), ); - actix::fut::Either::A(room.send(Close).into_actor(self).map( - move |_, act, _| { - debug!("Room [id = {}] removed.", id); - act.room_repo.remove(&id); - }, - )) + Box::new(room.send(Close).into_actor(self).map(move |_, act, _| { + debug!("Room [id = {}] removed.", id); + act.room_repo.remove(&id); + })) } else { - actix::fut::Either::B(actix::fut::ok(())) + Box::new(actix::fut::ok(())) } } } @@ -228,9 +223,7 @@ impl DeleteElements { pub fn add_uri(&mut self, uri: LocalUriType) { self.uris.push(uri); } -} -impl DeleteElements { pub fn validate(self) -> Result, RoomServiceError> { // TODO: correct errors if self.uris.is_empty() { @@ -258,12 +251,49 @@ impl Handler> for RoomService { fn handle( &mut self, mut msg: DeleteElements, - _: &mut Self::Context, + ctx: &mut Context, ) -> Self::Result { - // TODO: handle room delete here, send batch to room, handle it atomically - // just discard other messages if room delete present + use actix::AsyncContext as _; + // TODO: handle room delete here, send batch to room, handle it + // atomically just discard other messages if room delete + // present + let mut deletes_from_room: Vec = Vec::new(); + let is_room_message = msg + .uris + .into_iter() + .filter_map(|l| { + if let LocalUriType::Room(room_id) = l { + Some(room_id) + } else { + deletes_from_room.push(l); + None + } + }) + .map(|room_id| { + // TODO (evdokimovs): Error handling + ctx.spawn( + self.close_room(room_id.take_room_id()) + .map_err(|_, _, _| ()), + ); + }) + .count() + > 0; + + if !is_room_message && !deletes_from_room.is_empty() { + let room_id = deletes_from_room[0].room_id().clone(); + // TODO (evdokimovs): print warns on URIs which not deleted. + let deletes_from_room: Vec = deletes_from_room + .into_iter() + .filter(|uri| uri.room_id() == &room_id) + .collect(); + // TODO (evdokimovs): handle None. + if let Some(room) = self.room_repo.get(&room_id) { + // TODO (evdokimovs): handle errors. + room.do_send(Delete(deletes_from_room)); + } + } - unimplemented!() + Ok(()) } } From 847ab3cec6c6a5c6808b60a99c2bfcb88316351b Mon Sep 17 00:00:00 2001 From: alexlapa Date: Fri, 6 Sep 2019 17:30:53 +0300 Subject: [PATCH 582/735] whatever [run ci] --- .travis.yml | 2 +- Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index bb44dbe43..c6c412f8a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,7 +30,7 @@ jobs: - name: rustfmt stage: check - rust: stable + rust: nightly cache: false before_script: rustup component add rustfmt script: make fmt check=yes diff --git a/Makefile b/Makefile index 2e9d302a7..bccf59691 100644 --- a/Makefile +++ b/Makefile @@ -197,7 +197,7 @@ cargo: # make cargo.fmt [check=(no|yes)] cargo.fmt: - cargo fmt --all $(if $(call eq,$(check),yes),-- --check,) + cargo +nightly fmt --all $(if $(call eq,$(check),yes),-- --check,) # Lint Rust sources with clippy. From 83ff84075ba6edf08ad237bbfb7c64a70fd094c4 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 6 Sep 2019 18:29:42 +0300 Subject: [PATCH 583/735] Dirty implementation of batch get --- src/api/control/grpc/server.rs | 102 +++++------------------------ src/api/control/local_uri.rs | 12 ++-- src/bin/client.rs | 18 ++--- src/signalling/room.rs | 116 +++++++++++++++++++++++++-------- src/signalling/room_service.rs | 52 ++++++++++++++- 5 files changed, 171 insertions(+), 129 deletions(-) diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index a3f241f4d..cd0869291 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -50,7 +50,7 @@ use crate::{ use crate::{ api::control::{MemberId, RoomId}, shutdown::ShutdownGracefully, - signalling::room_service::NotValidated, + signalling::room_service::{Get, NotValidated}, }; #[derive(Debug, Fail)] @@ -443,96 +443,28 @@ impl ControlApi for ControlApiService { req: IdRequest, sink: UnarySink, ) { - let mut room_ids = Vec::new(); - let mut member_ids = Vec::new(); - let mut endpoint_ids = Vec::new(); - + let mut uris = Vec::new(); for id in req.get_id() { let local_uri = parse_local_uri!(id, ctx, sink, GetResponse); - - match local_uri { - LocalUriType::Room(room_uri) => { - room_ids.push(room_uri.take_room_id()); - } - LocalUriType::Member(member_uri) => { - let (member_id, room_uri) = member_uri.take_member_id(); - let room_id = room_uri.take_room_id(); - member_ids.push((room_id, member_id)); - } - LocalUriType::Endpoint(endpoint_uri) => { - let (endpoint_id, member_uri) = - endpoint_uri.take_endpoint_id(); - let (member_id, room_uri) = member_uri.take_member_id(); - let room_id = room_uri.take_room_id(); - endpoint_ids.push((room_id, member_id, endpoint_id)); - } - } + uris.push(local_uri); } - - let room_fut = self.room_service.send(GetRoom(room_ids)); - let member_fut = self.room_service.send(GetMember(member_ids)); - let endpoint_fut = self.room_service.send(GetEndpoint(endpoint_ids)); - - ctx.spawn(room_fut.join3(member_fut, endpoint_fut).then(|result| { - let grpc_err_closure = - |e| warn!("Error while sending Get response. {:?}", e); - + ctx.spawn(self.room_service.send(Get(uris)).then(|result| { match result { - Ok((room, member, endpoint)) => { - let mut elements = HashMap::new(); - let mut elements_results = Vec::new(); - - let results = vec![room, member, endpoint]; - - for result in results { - match result { - Ok(o) => { - elements_results.push(o); - } - Err(e) => { - let mut response = GetResponse::new(); - let error: ErrorResponse = e.into(); - response.set_error(error.into()); - return sink - .success(response) - .map_err(grpc_err_closure); - } - } - } - - let elements_results = elements_results - .into_iter() - .flat_map(std::iter::IntoIterator::into_iter); - - for element in elements_results { - match element { - Ok((id, o)) => { - elements.insert(id, o); - } - Err(e) => { - let mut response = GetResponse::new(); - let error: ErrorResponse = e.into(); - response.set_error(error.into()); - return sink - .success(response) - .map_err(grpc_err_closure); - } - } - } - - let mut response = GetResponse::new(); - response.set_elements(elements); - - sink.success(response).map_err(grpc_err_closure) - } - Err(e) => { - warn!("Control API Get method mailbox error. {:?}", e); + Ok(resp) => { let mut response = GetResponse::new(); - let error: Error = - ErrorResponse::unknown(&format!("{:?}", e)).into(); - response.set_error(error); - sink.success(response).map_err(grpc_err_closure) + let resp = response.set_elements( + resp.unwrap() + .into_iter() + .map(|(id, value)| (id.to_string(), value)) + .collect(), + ); + // TODO (evdokimovs): remove this unwrap. + sink.success(response).map_err(|e| { + error!("Error while get.") // TODO (evdokimovs): better + // response + }) } + _ => unimplemented!() } })); } diff --git a/src/api/control/local_uri.rs b/src/api/control/local_uri.rs index 22b6dd2c0..525473dce 100644 --- a/src/api/control/local_uri.rs +++ b/src/api/control/local_uri.rs @@ -35,15 +35,15 @@ pub enum LocalUriParseError { } /// State of [`LocalUri`] which points to `Room`. -#[derive(Debug)] +#[derive(Debug, PartialEq, Hash, Eq)] pub struct IsRoomId(RoomId); /// State of [`LocalUri`] which points to `Member`. -#[derive(Debug)] +#[derive(Debug, PartialEq, Hash, Eq)] pub struct IsMemberId(LocalUri, MemberId); /// State of [`LocalUri`] which points to `Endpoint`. -#[derive(Debug)] +#[derive(Debug, PartialEq, Hash, Eq)] pub struct IsEndpointId(LocalUri, String); #[allow(clippy::doc_markdown)] @@ -89,7 +89,7 @@ pub struct IsEndpointId(LocalUri, String); /// /// This is necessary so that it is not possible to get the address in the /// wrong state ("local://room_id//endpoint_id" for example). -#[derive(Debug)] +#[derive(Debug, PartialEq, Hash, Eq)] pub struct LocalUri { state: T, } @@ -184,7 +184,7 @@ impl From for LocalUri { } #[allow(clippy::doc_markdown)] -#[derive(Debug, Clone)] +#[derive(Debug, Clone, PartialEq, Hash, Eq)] struct LocalUriInner { /// ID of [`Room`] room_id: Option, @@ -294,7 +294,7 @@ impl fmt::Display for LocalUri { /// Enum for store all kinds of [`LocalUri`]s. #[allow(clippy::module_name_repetitions)] -#[derive(Debug)] +#[derive(Debug, Hash, PartialEq, Eq)] pub enum LocalUriType { Room(LocalUri), Member(LocalUri), diff --git a/src/bin/client.rs b/src/bin/client.rs index 2fac580e9..b8242e909 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -17,13 +17,13 @@ fn main() { let ch = ChannelBuilder::new(env).connect("localhost:50051"); let client = ControlApiClient::new(ch); - // create_room(&client); - // delete_room(&client); - delete_endpoint(&client); - delete_member(&client); - // create_member(&client); - // create_endpoint(&client); - // get_room(&client); +// create_room(&client); +// delete_room(&client); +// delete_endpoint(&client); +// delete_member(&client); +// create_member(&client); +// create_endpoint(&client); + get_room(&client); } fn create_room(client: &ControlApiClient) { @@ -134,9 +134,9 @@ fn delete_member(client: &ControlApiClient) { fn get_room(client: &ControlApiClient) { let mut get_room_request = IdRequest::new(); let mut room = RepeatedField::new(); - room.push("local://grpc-test".to_string()); +// room.push("local://grpc-test".to_string()); room.push("local://video-call-1/responder".to_string()); - room.push("local://grpc-test/publisher/publish".to_string()); +// room.push("local://grpc-test/publisher/publish".to_string()); // room.push("local://pub-pub-video-call".to_string()); get_room_request.set_id(room); diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 17916cde4..87e18b3b6 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -636,6 +636,47 @@ impl Room { endpoint_id, member_id, self.id ); } + + fn serialize_member_to_protobuf( + &self, + member_id: &MemberId, + ) -> Result { + let member = self.members.get_member(member_id)?; + + let mut member_element: Room_Element = member.into(); + let member = member_element.take_member(); + + let mut element = ElementProto::new(); + element.set_member(member); + + Ok(element) + } + + fn serialize_endpoint_to_proto( + &self, + member_id: &MemberId, + endpoint_id: String, + ) -> Result { + let member = self.members.get_member(member_id)?; + + let publish_endpoint_id = WebRtcPublishId(endpoint_id); + let mut element = ElementProto::new(); + + if let Some(endpoint) = member.get_src_by_id(&publish_endpoint_id) { + let mut member_element: Member_Element = endpoint.into(); + let endpoint = member_element.take_webrtc_pub(); + element.set_webrtc_pub(endpoint); + } else { + let play_endpoint_id = WebRtcPlayId(publish_endpoint_id.0); + + let endpoint = member.get_sink(&play_endpoint_id)?; + let mut member_element: Member_Element = endpoint.into(); + let endpoint = member_element.take_webrtc_play(); + element.set_webrtc_play(endpoint); + } + + Ok(element) + } } /// [`Actor`] implementation that provides an ergonomic way @@ -663,6 +704,51 @@ impl Into for &mut Room { } } +#[derive(Message)] +#[rtype(result = "Result, RoomError>")] +pub struct SerializeProto { + pub uris: Vec, +} + +impl Handler for Room { + type Result = Result, RoomError>; + + fn handle( + &mut self, + msg: SerializeProto, + ctx: &mut Self::Context, + ) -> Self::Result { + let mut serialized = HashMap::new(); + for uri in msg.uris { + match &uri { + LocalUriType::Room(room_uri) => { + if room_uri.room_id() == &self.id { + let current_room: ElementProto = self.into(); + serialized.insert(uri, current_room); + } else { + // TODO (evdokimovs): return err + } + } + LocalUriType::Member(member_uri) => { + let member_id = member_uri.member_id(); + let member_proto = + self.serialize_member_to_protobuf(member_id)?; + serialized.insert(uri, member_proto); + } + LocalUriType::Endpoint(endpoint_uri) => { + let endpoint_id = endpoint_uri.endpoint_id().to_string(); + let member_id = endpoint_uri.member_id(); + let endpoint_proto = self + .serialize_endpoint_to_proto(member_id, endpoint_id)?; + serialized.insert(uri, endpoint_proto); + } + } + } + + Ok(serialized) + } +} + /// Serialize this [`Room`] to protobuf object. #[allow(clippy::module_name_repetitions)] #[derive(Message)] @@ -696,15 +782,7 @@ impl Handler for Room { msg: SerializeProtobufMember, _ctx: &mut Self::Context, ) -> Self::Result { - let member = self.members.get_member(&msg.0)?; - - let mut member_element: Room_Element = member.into(); - let member = member_element.take_member(); - - let mut element = ElementProto::new(); - element.set_member(member); - - Ok(element) + self.serialize_member_to_protobuf(&msg.0) } } @@ -723,25 +801,7 @@ impl Handler for Room { msg: SerializeProtobufEndpoint, _ctx: &mut Self::Context, ) -> Self::Result { - let member = self.members.get_member(&msg.0)?; - - let endpoint_id = WebRtcPublishId(msg.1); - let mut element = ElementProto::new(); - - if let Some(endpoint) = member.get_src_by_id(&endpoint_id) { - let mut member_element: Member_Element = endpoint.into(); - let endpoint = member_element.take_webrtc_pub(); - element.set_webrtc_pub(endpoint); - } else { - let endpoint_id = WebRtcPlayId(endpoint_id.0); - - let endpoint = member.get_sink(&endpoint_id)?; - let mut member_element: Member_Element = endpoint.into(); - let endpoint = member_element.take_webrtc_play(); - element.set_webrtc_play(endpoint); - } - - Ok(element) + self.serialize_endpoint_to_proto(&msg.0, msg.1) } } diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index 660d11752..eaebd13c8 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -22,7 +22,7 @@ use crate::{ signalling::{ room::{ Close, CreateEndpoint, CreateMember, Delete, RoomError, - SerializeProtobufEndpoint, SerializeProtobufMember, + SerializeProto, SerializeProtobufEndpoint, SerializeProtobufMember, SerializeProtobufRoom, }, room_repo::RoomRepository, @@ -31,6 +31,7 @@ use crate::{ AppContext, }; use serde::export::PhantomData; +use std::collections::HashMap; type ActFuture = Box>; @@ -300,6 +301,55 @@ impl Handler> for RoomService { /// Type alias for result of Get request. type GetResults = Vec>; +#[derive(Message)] +#[rtype( + result = "Result, RoomServiceError>" +)] +pub struct Get(pub Vec); + +impl Handler for RoomService { + type Result = + ActFuture, RoomServiceError>; + + fn handle(&mut self, msg: Get, ctx: &mut Self::Context) -> Self::Result { + let mut rooms_elements = HashMap::new(); + for uri in msg.0 { + if self.room_repo.is_contains_room_with_id(uri.room_id()) { + rooms_elements + .entry(uri.room_id().clone()) + .or_insert_with(|| Vec::new()) + .push(uri); + } else { + // TODO: error here + } + } + + let mut futs = Vec::new(); + for (room_id, elements) in rooms_elements { + if let Some(room) = self.room_repo.get(&room_id) { + // TODO (evdokimovs): error handling + futs.push(room.send(SerializeProto { uris: elements })); + } else { + unimplemented!() + // TODO (evdokimovs): error + } + } + + Box::new(wrap_future( + futures::future::join_all(futs) + .map_err(|e| RoomServiceError::from(e)) + .map(|results| { + let mut all = HashMap::new(); + for result in results { + let result = result.unwrap(); + all.extend(result) + } + all + }), + )) + } +} + /// Signal for get serialized to protobuf object [`Room`]. #[derive(Message)] #[rtype(result = "Result")] From ad26b60886d6a7614a69383effa9f2652f55eedf Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 6 Sep 2019 18:34:58 +0300 Subject: [PATCH 584/735] Some cleanup --- src/api/client/server.rs | 2 +- src/api/control/grpc/server.rs | 16 ++-- src/bin/client.rs | 18 ++--- src/shutdown.rs | 1 - src/signalling/room.rs | 58 +------------ src/signalling/room_service.rs | 143 +-------------------------------- 6 files changed, 21 insertions(+), 217 deletions(-) diff --git a/src/api/client/server.rs b/src/api/client/server.rs index 6fa1e3253..421af617b 100644 --- a/src/api/client/server.rs +++ b/src/api/client/server.rs @@ -2,7 +2,7 @@ use std::io; -use actix::{Actor, Addr, Handler, ResponseFuture, WrapFuture as _}; +use actix::{Actor, Addr, Handler, ResponseFuture}; use actix_web::{ dev::Server as ActixServer, middleware, diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index cd0869291..e39fc18bd 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -7,7 +7,6 @@ use std::{collections::HashMap, convert::TryFrom, sync::Arc}; use actix::{ Actor, Addr, Arbiter, Context, Handler, MailboxError, ResponseFuture, - WrapFuture as _, }; use failure::Fail; use futures::future::{Either, Future}; @@ -33,15 +32,14 @@ use crate::{ Endpoint, MemberSpec, RoomSpec, TryFromElementError, TryFromProtobufError, }, - error_codes::{ErrorCode, ErrorResponse}, + error_codes::ErrorResponse, }, log::prelude::*, signalling::{ room::RoomError, room_service::{ CreateEndpointInRoom, CreateMemberInRoom, DeleteElements, - GetEndpoint, GetMember, GetRoom, RoomService, RoomServiceError, - StartRoom, + RoomService, RoomServiceError, StartRoom, }, }, AppContext, @@ -50,7 +48,7 @@ use crate::{ use crate::{ api::control::{MemberId, RoomId}, shutdown::ShutdownGracefully, - signalling::room_service::{Get, NotValidated}, + signalling::room_service::Get, }; #[derive(Debug, Fail)] @@ -289,9 +287,9 @@ impl ControlApi for ControlApiService { /// Implementation for `Create` method of gRPC control API. fn create( &mut self, - ctx: RpcContext, - req: CreateRequest, - sink: UnarySink, + _ctx: RpcContext, + _req: CreateRequest, + _sink: UnarySink, ) { // let local_uri = parse_local_uri!(req.get_id(), ctx, sink, // Response); @@ -464,7 +462,7 @@ impl ControlApi for ControlApiService { // response }) } - _ => unimplemented!() + _ => unimplemented!(), } })); } diff --git a/src/bin/client.rs b/src/bin/client.rs index b8242e909..7e9abe5e8 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -17,13 +17,13 @@ fn main() { let ch = ChannelBuilder::new(env).connect("localhost:50051"); let client = ControlApiClient::new(ch); -// create_room(&client); -// delete_room(&client); -// delete_endpoint(&client); -// delete_member(&client); -// create_member(&client); -// create_endpoint(&client); - get_room(&client); + // create_room(&client); + // delete_room(&client); + // delete_endpoint(&client); + // delete_member(&client); + // create_member(&client); + // create_endpoint(&client); + get_room(&client); } fn create_room(client: &ControlApiClient) { @@ -134,9 +134,9 @@ fn delete_member(client: &ControlApiClient) { fn get_room(client: &ControlApiClient) { let mut get_room_request = IdRequest::new(); let mut room = RepeatedField::new(); -// room.push("local://grpc-test".to_string()); + // room.push("local://grpc-test".to_string()); room.push("local://video-call-1/responder".to_string()); -// room.push("local://grpc-test/publisher/publish".to_string()); + // room.push("local://grpc-test/publisher/publish".to_string()); // room.push("local://pub-pub-video-call".to_string()); get_room_request.set_id(room); diff --git a/src/shutdown.rs b/src/shutdown.rs index d741df920..18a8155a2 100644 --- a/src/shutdown.rs +++ b/src/shutdown.rs @@ -8,7 +8,6 @@ use std::{ use actix::{ prelude::{Actor, Context}, Addr, AsyncContext, Handler, Message, Recipient, ResponseFuture, System, - WrapFuture as _, }; use failure::Fail; use futures::{future, stream::iter_ok, Future, Stream}; diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 87e18b3b6..ea5b05364 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -716,7 +716,7 @@ impl Handler for Room { fn handle( &mut self, msg: SerializeProto, - ctx: &mut Self::Context, + _: &mut Self::Context, ) -> Self::Result { let mut serialized = HashMap::new(); for uri in msg.uris { @@ -749,62 +749,6 @@ impl Handler for Room { } } -/// Serialize this [`Room`] to protobuf object. -#[allow(clippy::module_name_repetitions)] -#[derive(Message)] -#[rtype(result = "Result")] -pub struct SerializeProtobufRoom; - -impl Handler for Room { - type Result = Result; - - /// Serialize this [`Room`] to protobuf object. - fn handle( - &mut self, - _msg: SerializeProtobufRoom, - _ctx: &mut Self::Context, - ) -> Self::Result { - Ok(self.into()) - } -} - -/// Serialize [`Member`] from this [`Room`] to protobuf object. -#[derive(Message)] -#[rtype(result = "Result")] -pub struct SerializeProtobufMember(pub MemberId); - -impl Handler for Room { - type Result = Result; - - /// Serialize [`Member`] to protobuf object. - fn handle( - &mut self, - msg: SerializeProtobufMember, - _ctx: &mut Self::Context, - ) -> Self::Result { - self.serialize_member_to_protobuf(&msg.0) - } -} - -/// Serialize endpoint from this [`Room`] to protobuf object. -#[derive(Message)] -#[rtype(result = "Result")] -pub struct SerializeProtobufEndpoint(pub MemberId, pub String); - -impl Handler for Room { - type Result = Result; - - /// Serialize [`WebRtcPlayEndpoint`] or [`WebRtcPublishEndpoint`] to - /// protobuf object. - fn handle( - &mut self, - msg: SerializeProtobufEndpoint, - _ctx: &mut Self::Context, - ) -> Self::Result { - self.serialize_endpoint_to_proto(&msg.0, msg.1) - } -} - impl Handler for Room { type Result = Result<(), AuthorizationError>; diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index eaebd13c8..3472435e0 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -2,7 +2,7 @@ use actix::{ fut::wrap_future, Actor, ActorFuture, Addr, Context, Handler, MailboxError, - Message, ResponseFuture, WrapFuture as _, + Message, WrapFuture as _, }; use failure::Fail; use futures::future::{self, Either, Future}; @@ -12,9 +12,7 @@ use crate::{ api::control::{ endpoints::Endpoint as EndpointSpec, load_static_specs_from_dir, - local_uri::{ - IsEndpointId, IsMemberId, IsRoomId, LocalUri, LocalUriType, - }, + local_uri::{IsRoomId, LocalUri, LocalUriType}, MemberId, MemberSpec, RoomId, RoomSpec, }, log::prelude::*, @@ -22,8 +20,7 @@ use crate::{ signalling::{ room::{ Close, CreateEndpoint, CreateMember, Delete, RoomError, - SerializeProto, SerializeProtobufEndpoint, SerializeProtobufMember, - SerializeProtobufRoom, + SerializeProto, }, room_repo::RoomRepository, Room, @@ -298,9 +295,6 @@ impl Handler> for RoomService { } } -/// Type alias for result of Get request. -type GetResults = Vec>; - #[derive(Message)] #[rtype( result = "Result, RoomServiceError>" @@ -350,137 +344,6 @@ impl Handler for RoomService { } } -/// Signal for get serialized to protobuf object [`Room`]. -#[derive(Message)] -#[rtype(result = "Result")] -pub struct GetRoom(pub Vec); - -impl Handler for RoomService { - type Result = ActFuture; - - fn handle( - &mut self, - msg: GetRoom, - _ctx: &mut Self::Context, - ) -> Self::Result { - let mut futs = Vec::new(); - - for room_id in msg.0 { - if let Some(room) = self.room_repo.get(&room_id) { - futs.push( - room.send(SerializeProtobufRoom) - .map_err(RoomServiceError::from) - .map(move |result| { - result.map(|r| { - let local_uri = - LocalUri::::new(room_id); - (local_uri.to_string(), r) - }) - }), - ) - } else { - return Box::new(wrap_future(future::err( - RoomServiceError::RoomNotFound(get_local_uri_to_room( - room_id, - )), - ))); - } - } - - Box::new(wrap_future(future::join_all(futs))) - } -} - -/// Signal for get serialized to protobuf object [`Member`]. -#[derive(Message)] -#[rtype(result = "Result")] -pub struct GetMember(pub Vec<(RoomId, MemberId)>); - -impl Handler for RoomService { - type Result = ActFuture; - - fn handle( - &mut self, - msg: GetMember, - _ctx: &mut Self::Context, - ) -> Self::Result { - let mut futs = Vec::new(); - - for (room_id, member_id) in msg.0 { - if let Some(room) = self.room_repo.get(&room_id) { - futs.push( - room.send(SerializeProtobufMember(member_id.clone())) - .map_err(RoomServiceError::from) - .map(|result| { - result.map(|r| { - let local_uri = LocalUri::::new( - room_id, member_id, - ); - - (local_uri.to_string(), r) - }) - }), - ) - } else { - return Box::new(wrap_future(future::err( - RoomServiceError::RoomNotFound(get_local_uri_to_room( - room_id, - )), - ))); - } - } - - Box::new(wrap_future(future::join_all(futs))) - } -} - -/// Signal for get serialized to protobuf object `Endpoint`. -#[derive(Message)] -#[rtype(result = "Result")] -pub struct GetEndpoint(pub Vec<(RoomId, MemberId, String)>); - -impl Handler for RoomService { - type Result = ActFuture; - - fn handle( - &mut self, - msg: GetEndpoint, - _ctx: &mut Self::Context, - ) -> Self::Result { - let mut futs = Vec::new(); - - for (room_id, member_id, endpoint_id) in msg.0 { - if let Some(room) = self.room_repo.get(&room_id) { - futs.push( - room.send(SerializeProtobufEndpoint( - member_id.clone(), - endpoint_id.clone(), - )) - .map_err(RoomServiceError::from) - .map(|result| { - result.map(|r| { - let local_uri = LocalUri::::new( - room_id, - member_id, - endpoint_id, - ); - (local_uri.to_string(), r) - }) - }), - ); - } else { - return Box::new(wrap_future(future::err( - RoomServiceError::RoomNotFound(get_local_uri_to_room( - room_id, - )), - ))); - } - } - - Box::new(wrap_future(future::join_all(futs))) - } -} - /// Signal for create new [`Member`] in [`Room`] #[derive(Message)] #[rtype(result = "Result, RoomServiceError>")] From 486ef4c68ddb846c77bece01df824013d0bd655c Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 6 Sep 2019 19:03:48 +0300 Subject: [PATCH 585/735] Error handling for get --- src/api/control/grpc/server.rs | 124 ++++++++------------------------- src/api/control/local_uri.rs | 10 +-- src/bin/client.rs | 4 +- src/signalling/room_service.rs | 28 +++++--- 4 files changed, 56 insertions(+), 110 deletions(-) diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index e39fc18bd..034079d82 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -291,85 +291,7 @@ impl ControlApi for ControlApiService { _req: CreateRequest, _sink: UnarySink, ) { - // let local_uri = parse_local_uri!(req.get_id(), ctx, sink, - // Response); - // - // match local_uri { - // LocalUriType::Room(local_uri) => { - // if req.has_room() { - // ctx.spawn(self.create_room(&req, local_uri).then( - // move |r| { - // sink.success(get_response_for_create(r)) - // .map_err(|_| ()) - // }, - // )); - // } else { - // send_error_response!( - // ctx, - // sink, - // ErrorResponse::new( - // - // ErrorCode::ElementIdForRoomButElementIsNot, - // &req.get_id(), ), - // Response - // ); - // } - // } - // LocalUriType::Member(local_uri) => { - // if req.has_member() { - // ctx.spawn(self.create_member(&req, - // local_uri).then( move |r| { - // - // sink.success(get_response_for_create(r)).map_err( - // |e| { warn!( - // "Error while sending Create - // response \ by gRPC. - // {:?}", e - // ) - // }, - // ) - // }, - // )); - // } else { - // send_error_response!( - // ctx, - // sink, - // ErrorResponse::new( - // - // ErrorCode::ElementIdForMemberButElementIsNot, - // &req.get_id(), ), - // Response - // ); - // } - // } - // LocalUriType::Endpoint(local_uri) => { - // if req.has_webrtc_pub() || req.has_webrtc_play() { - // ctx.spawn(self.create_endpoint(&req, - // local_uri).then( move |r| { - // - // sink.success(get_response_for_create(r)).map_err( - // |e| { warn!( - // "Error while sending Create - // response \ by gRPC. - // {:?}", e - // ) - // }, - // ) - // }, - // )); - // } else { - // send_error_response!( - // ctx, - // sink, - // ErrorResponse::new( - // - // ErrorCode::ElementIdForEndpointButElementIsNot, - // &req.get_id(), ), - // Response - // ); - // } - // } - // } + unimplemented!() } /// Implementation for `Apply` method of gRPC control API. @@ -433,7 +355,6 @@ impl ControlApi for ControlApiService { )); } - /// TODO: just send Vec, see fn delete() /// Implementation for `Get` method of gRPC control API. fn get( &mut self, @@ -446,23 +367,36 @@ impl ControlApi for ControlApiService { let local_uri = parse_local_uri!(id, ctx, sink, GetResponse); uris.push(local_uri); } - ctx.spawn(self.room_service.send(Get(uris)).then(|result| { - match result { - Ok(resp) => { + ctx.spawn(self.room_service.send(Get(uris)).then(|mailbox_result| { + let err = |e| { + warn!( + "Error while sending response on Get request by gRPC. {:?}", + e + ); + }; + match mailbox_result { + Ok(room_service_result) => match room_service_result { + Ok(elements) => { + let mut response = GetResponse::new(); + let resp = response.set_elements( + elements + .into_iter() + .map(|(id, value)| (id.to_string(), value)) + .collect(), + ); + sink.success(response).map_err(err) + } + Err(e) => { + let mut response = GetResponse::new(); + response.set_error(ErrorResponse::from(e).into()); + sink.success(response).map_err(err) + } + }, + Err(e) => { let mut response = GetResponse::new(); - let resp = response.set_elements( - resp.unwrap() - .into_iter() - .map(|(id, value)| (id.to_string(), value)) - .collect(), - ); - // TODO (evdokimovs): remove this unwrap. - sink.success(response).map_err(|e| { - error!("Error while get.") // TODO (evdokimovs): better - // response - }) + response.set_error(ErrorResponse::unknown(&e).into()); + sink.success(response).map_err(err) } - _ => unimplemented!(), } })); } diff --git a/src/api/control/local_uri.rs b/src/api/control/local_uri.rs index 525473dce..c859f6331 100644 --- a/src/api/control/local_uri.rs +++ b/src/api/control/local_uri.rs @@ -35,15 +35,15 @@ pub enum LocalUriParseError { } /// State of [`LocalUri`] which points to `Room`. -#[derive(Debug, PartialEq, Hash, Eq)] +#[derive(Debug, PartialEq, Hash, Eq, Clone)] pub struct IsRoomId(RoomId); /// State of [`LocalUri`] which points to `Member`. -#[derive(Debug, PartialEq, Hash, Eq)] +#[derive(Debug, PartialEq, Hash, Eq, Clone)] pub struct IsMemberId(LocalUri, MemberId); /// State of [`LocalUri`] which points to `Endpoint`. -#[derive(Debug, PartialEq, Hash, Eq)] +#[derive(Debug, PartialEq, Hash, Eq, Clone)] pub struct IsEndpointId(LocalUri, String); #[allow(clippy::doc_markdown)] @@ -89,7 +89,7 @@ pub struct IsEndpointId(LocalUri, String); /// /// This is necessary so that it is not possible to get the address in the /// wrong state ("local://room_id//endpoint_id" for example). -#[derive(Debug, PartialEq, Hash, Eq)] +#[derive(Debug, PartialEq, Hash, Eq, Clone)] pub struct LocalUri { state: T, } @@ -294,7 +294,7 @@ impl fmt::Display for LocalUri { /// Enum for store all kinds of [`LocalUri`]s. #[allow(clippy::module_name_repetitions)] -#[derive(Debug, Hash, PartialEq, Eq)] +#[derive(Debug, Hash, PartialEq, Eq, Clone)] pub enum LocalUriType { Room(LocalUri), Member(LocalUri), diff --git a/src/bin/client.rs b/src/bin/client.rs index 7e9abe5e8..0940fe322 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -134,8 +134,8 @@ fn delete_member(client: &ControlApiClient) { fn get_room(client: &ControlApiClient) { let mut get_room_request = IdRequest::new(); let mut room = RepeatedField::new(); - // room.push("local://grpc-test".to_string()); - room.push("local://video-call-1/responder".to_string()); + room.push("local://grpc-test".to_string()); + // room.push("local://video-call-1/responder".to_string()); // room.push("local://grpc-test/publisher/publish".to_string()); // room.push("local://pub-pub-video-call".to_string()); get_room_request.set_id(room); diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index 3472435e0..23a08d663 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -314,31 +314,43 @@ impl Handler for RoomService { .or_insert_with(|| Vec::new()) .push(uri); } else { - // TODO: error here + if let LocalUriType::Room(room_uri) = uri { + return Box::new(actix::fut::err( + RoomServiceError::RoomNotFound(room_uri), + )); + } else { + return Box::new(actix::fut::err( + RoomServiceError::Unknown, + )); + } } } let mut futs = Vec::new(); for (room_id, elements) in rooms_elements { if let Some(room) = self.room_repo.get(&room_id) { - // TODO (evdokimovs): error handling futs.push(room.send(SerializeProto { uris: elements })); } else { - unimplemented!() - // TODO (evdokimovs): error + return Box::new(actix::fut::err( + RoomServiceError::RoomNotFound(get_local_uri_to_room( + room_id, + )), + )); } } Box::new(wrap_future( futures::future::join_all(futs) .map_err(|e| RoomServiceError::from(e)) - .map(|results| { + .and_then(|results| { let mut all = HashMap::new(); for result in results { - let result = result.unwrap(); - all.extend(result) + match result { + Ok(res) => all.extend(res), + Err(e) => return Err(RoomServiceError::from(e)), + } } - all + Ok(all) }), )) } From 7e3ed6bd1258945284ecfa96f02ad1bb0dd26150 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 6 Sep 2019 19:28:07 +0300 Subject: [PATCH 586/735] Error handling for Delete --- src/signalling/room_service.rs | 80 +++++++++++++++++++++------------- 1 file changed, 50 insertions(+), 30 deletions(-) diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index 23a08d663..e2997e24b 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -1,8 +1,8 @@ //! Service which control [`Room`]. use actix::{ - fut::wrap_future, Actor, ActorFuture, Addr, Context, Handler, MailboxError, - Message, WrapFuture as _, + fut::wrap_future, Actor, ActorFuture, Addr, AsyncContext as _, Context, + Handler, MailboxError, Message, WrapFuture as _, }; use failure::Fail; use futures::future::{self, Either, Future}; @@ -86,7 +86,10 @@ impl RoomService { } } - fn close_room(&self, id: RoomId) -> ActFuture<(), MailboxError> { + fn close_room( + &self, + id: RoomId, + ) -> Box> { if let Some(room) = self.room_repo.get(&id) { shutdown::unsubscribe( &self.graceful_shutdown, @@ -94,12 +97,14 @@ impl RoomService { shutdown::Priority(2), ); - Box::new(room.send(Close).into_actor(self).map(move |_, act, _| { + let room_repo = self.room_repo.clone(); + + Box::new(room.send(Close).map(move |_| { debug!("Room [id = {}] removed.", id); - act.room_repo.remove(&id); + room_repo.remove(&id); })) } else { - Box::new(actix::fut::ok(())) + Box::new(futures::future::ok(())) } } } @@ -244,19 +249,17 @@ impl DeleteElements { } impl Handler> for RoomService { - type Result = Result<(), RoomServiceError>; + type Result = ActFuture<(), RoomServiceError>; fn handle( &mut self, mut msg: DeleteElements, ctx: &mut Context, ) -> Self::Result { - use actix::AsyncContext as _; - // TODO: handle room delete here, send batch to room, handle it - // atomically just discard other messages if room delete - // present let mut deletes_from_room: Vec = Vec::new(); - let is_room_message = msg + let room_messages_futs: Vec< + Box>, + > = msg .uris .into_iter() .filter_map(|l| { @@ -267,31 +270,48 @@ impl Handler> for RoomService { None } }) - .map(|room_id| { - // TODO (evdokimovs): Error handling - ctx.spawn( - self.close_room(room_id.take_room_id()) - .map_err(|_, _, _| ()), - ); - }) - .count() - > 0; - - if !is_room_message && !deletes_from_room.is_empty() { + .map(|room_id| self.close_room(room_id.take_room_id())) + .collect(); + + if !room_messages_futs.is_empty() { + Box::new(wrap_future( + futures::future::join_all(room_messages_futs) + .map(|_| ()) + .map_err(|e| RoomServiceError::from(e)), + )) + } else if !deletes_from_room.is_empty() { let room_id = deletes_from_room[0].room_id().clone(); - // TODO (evdokimovs): print warns on URIs which not deleted. + let mut ignored_ids = Vec::new(); let deletes_from_room: Vec = deletes_from_room .into_iter() - .filter(|uri| uri.room_id() == &room_id) + .filter_map(|uri| { + if uri.room_id() == &room_id { + Some(uri) + } else { + ignored_ids.push(uri); + None + } + }) .collect(); - // TODO (evdokimovs): handle None. + if !ignored_ids.is_empty() { + warn!( + "Some ids from Get request was ignored: {:?}", + ignored_ids + ); + } if let Some(room) = self.room_repo.get(&room_id) { - // TODO (evdokimovs): handle errors. - room.do_send(Delete(deletes_from_room)); + Box::new(wrap_future( + room.send(Delete(deletes_from_room)) + .map_err(|e| RoomServiceError::from(e)), + )) + } else { + Box::new(actix::fut::err(RoomServiceError::RoomNotFound( + get_local_uri_to_room(room_id), + ))) } + } else { + Box::new(actix::fut::ok(())) } - - Ok(()) } } From b6e2f28fad402d43953ad93880fbedaae34670a2 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 6 Sep 2019 19:40:50 +0300 Subject: [PATCH 587/735] Return Create method --- src/api/control/grpc/server.rs | 88 ++++++++++++++++++++++++++++++++-- src/bin/client.rs | 18 +++---- 2 files changed, 92 insertions(+), 14 deletions(-) diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index 034079d82..a90114c1d 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -32,7 +32,7 @@ use crate::{ Endpoint, MemberSpec, RoomSpec, TryFromElementError, TryFromProtobufError, }, - error_codes::ErrorResponse, + error_codes::{ErrorCode, ErrorResponse}, }, log::prelude::*, signalling::{ @@ -287,11 +287,89 @@ impl ControlApi for ControlApiService { /// Implementation for `Create` method of gRPC control API. fn create( &mut self, - _ctx: RpcContext, - _req: CreateRequest, - _sink: UnarySink, + ctx: RpcContext, + req: CreateRequest, + sink: UnarySink, ) { - unimplemented!() + let local_uri = + parse_local_uri!(req.get_id(), ctx, sink, CreateResponse); + + match local_uri { + LocalUriType::Room(local_uri) => { + if req.has_room() { + ctx.spawn(self.create_room(&req, local_uri).then( + move |r| { + sink.success(get_response_for_create(r)) + .map_err(|_| ()) + }, + )); + } else { + send_error_response!( + ctx, + sink, + ErrorResponse::new( + ErrorCode::ElementIdForRoomButElementIsNot, + &req.get_id(), + ), + CreateResponse + ); + } + } + LocalUriType::Member(local_uri) => { + if req.has_member() { + ctx.spawn(self.create_member(&req, local_uri).then( + move |r| { + sink.success(get_response_for_create(r)).map_err( + |e| { + warn!( + "Error while sending Create response \ + by gRPC. {:?}", + e + ) + }, + ) + }, + )); + } else { + send_error_response!( + ctx, + sink, + ErrorResponse::new( + ErrorCode::ElementIdForMemberButElementIsNot, + &req.get_id(), + ), + CreateResponse + ); + } + } + LocalUriType::Endpoint(local_uri) => { + if req.has_webrtc_pub() || req.has_webrtc_play() { + ctx.spawn(self.create_endpoint(&req, local_uri).then( + move |r| { + sink.success(get_response_for_create(r)).map_err( + |e| { + warn!( + "Error while sending Create response \ + by gRPC. {:?}", + e + ) + }, + ) + }, + )); + } else { + send_error_response!( + ctx, + sink, + ErrorResponse::new( + ErrorCode::ElementIdForEndpointButElementIsNot, + &req.get_id(), + ), + CreateResponse + ); + } + } + } } /// Implementation for `Apply` method of gRPC control API. diff --git a/src/bin/client.rs b/src/bin/client.rs index 0940fe322..13e7ae168 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -17,12 +17,12 @@ fn main() { let ch = ChannelBuilder::new(env).connect("localhost:50051"); let client = ControlApiClient::new(ch); - // create_room(&client); - // delete_room(&client); - // delete_endpoint(&client); - // delete_member(&client); - // create_member(&client); - // create_endpoint(&client); + create_room(&client); + delete_room(&client); + delete_endpoint(&client); + delete_member(&client); + create_member(&client); + create_endpoint(&client); get_room(&client); } @@ -135,9 +135,9 @@ fn get_room(client: &ControlApiClient) { let mut get_room_request = IdRequest::new(); let mut room = RepeatedField::new(); room.push("local://grpc-test".to_string()); - // room.push("local://video-call-1/responder".to_string()); - // room.push("local://grpc-test/publisher/publish".to_string()); - // room.push("local://pub-pub-video-call".to_string()); + room.push("local://video-call-1/responder".to_string()); + room.push("local://grpc-test/publisher/publish".to_string()); + room.push("local://pub-pub-video-call".to_string()); get_room_request.set_id(room); let reply = client.get(&get_room_request).expect("get room"); From 74f2e69b5cecfa64cd4c37d90bfb076507d5e5d2 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 6 Sep 2019 19:49:29 +0300 Subject: [PATCH 588/735] Refactor --- src/api/control/grpc/server.rs | 123 +++++++++++++++++++-------------- src/signalling/room_service.rs | 10 +-- 2 files changed, 76 insertions(+), 57 deletions(-) diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index a90114c1d..05f07206a 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -12,7 +12,7 @@ use failure::Fail; use futures::future::{Either, Future}; use grpcio::{ Environment, RpcContext, RpcStatus, RpcStatusCode, Server, ServerBuilder, - UnarySink, UnarySinkResult, + UnarySink, }; use medea_grpc_proto::{ control::{ @@ -387,7 +387,7 @@ impl ControlApi for ControlApiService { fn delete( &mut self, ctx: RpcContext, - mut req: IdRequest, + req: IdRequest, sink: UnarySink, ) { let mut delete_elements = DeleteElements::new(); @@ -409,28 +409,44 @@ impl ControlApi for ControlApiService { } }; - ctx.spawn(self.room_service.send(delete_elements).then( - move |result| { - match result { - Ok(result) => { - sink.success(Response::new()); - } - Err(e) => { - let mut response = Response::new(); - - // TODO: dont use unknown, add some special err for all - // mailbox errs, Unavailable("ActorName") or - // something - let error: Error = - ErrorResponse::unknown(&format!("{:?}", e)).into(); - response.set_error(error); - - let a: UnarySinkResult = sink.success(response); + ctx.spawn( + self.room_service + .send(delete_elements) + .then(move |result| { + match result { + Ok(result) => match result { + Ok(_) => sink.success(Response::new()), + Err(e) => { + let mut response = Response::new(); + response + .set_error(ErrorResponse::from(e).into()); + sink.success(response) + } + }, + Err(e) => { + let mut response = Response::new(); + + // TODO: dont use unknown, add some special err for + // all mailbox + // errs, Unavailable("ActorName") or + // something + let error: Error = + ErrorResponse::unknown(&format!("{:?}", e)) + .into(); + response.set_error(error); + + sink.success(response) + } } - } - Ok(()) - }, - )); + }) + .map_err(|e| { + warn!( + "Error while sending response on Delete request by \ + gRPC: {:?}", + e + ) + }), + ); } /// Implementation for `Get` method of gRPC control API. @@ -445,38 +461,41 @@ impl ControlApi for ControlApiService { let local_uri = parse_local_uri!(id, ctx, sink, GetResponse); uris.push(local_uri); } - ctx.spawn(self.room_service.send(Get(uris)).then(|mailbox_result| { - let err = |e| { - warn!( - "Error while sending response on Get request by gRPC. {:?}", - e - ); - }; - match mailbox_result { - Ok(room_service_result) => match room_service_result { - Ok(elements) => { - let mut response = GetResponse::new(); - let resp = response.set_elements( - elements - .into_iter() - .map(|(id, value)| (id.to_string(), value)) - .collect(), - ); - sink.success(response).map_err(err) - } + ctx.spawn( + self.room_service + .send(Get(uris)) + .then(|mailbox_result| match mailbox_result { + Ok(room_service_result) => match room_service_result { + Ok(elements) => { + let mut response = GetResponse::new(); + response.set_elements( + elements + .into_iter() + .map(|(id, value)| (id.to_string(), value)) + .collect(), + ); + sink.success(response) + } + Err(e) => { + let mut response = GetResponse::new(); + response.set_error(ErrorResponse::from(e).into()); + sink.success(response) + } + }, Err(e) => { let mut response = GetResponse::new(); - response.set_error(ErrorResponse::from(e).into()); - sink.success(response).map_err(err) + response.set_error(ErrorResponse::unknown(&e).into()); + sink.success(response) } - }, - Err(e) => { - let mut response = GetResponse::new(); - response.set_error(ErrorResponse::unknown(&e).into()); - sink.success(response).map_err(err) - } - } - })); + }) + .map_err(|e| { + warn!( + "Error while sending response on Get request by gRPC: \ + {:?}", + e + ) + }), + ); } } diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index e2997e24b..55c6a49c7 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -1,8 +1,8 @@ //! Service which control [`Room`]. use actix::{ - fut::wrap_future, Actor, ActorFuture, Addr, AsyncContext as _, Context, - Handler, MailboxError, Message, WrapFuture as _, + fut::wrap_future, Actor, ActorFuture, Addr, Context, Handler, MailboxError, + Message, }; use failure::Fail; use futures::future::{self, Either, Future}; @@ -253,8 +253,8 @@ impl Handler> for RoomService { fn handle( &mut self, - mut msg: DeleteElements, - ctx: &mut Context, + msg: DeleteElements, + _: &mut Context, ) -> Self::Result { let mut deletes_from_room: Vec = Vec::new(); let room_messages_futs: Vec< @@ -325,7 +325,7 @@ impl Handler for RoomService { type Result = ActFuture, RoomServiceError>; - fn handle(&mut self, msg: Get, ctx: &mut Self::Context) -> Self::Result { + fn handle(&mut self, msg: Get, _: &mut Self::Context) -> Self::Result { let mut rooms_elements = HashMap::new(); for uri in msg.0 { if self.room_repo.is_contains_room_with_id(uri.room_id()) { From 7bd0c20c3c62cb238b1c073e5bd956435d8c4aa6 Mon Sep 17 00:00:00 2001 From: alexlapa Date: Fri, 6 Sep 2019 19:50:50 +0300 Subject: [PATCH 589/735] travis spec fix [run ci] --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index c6c412f8a..7edad2bd3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,8 +14,6 @@ stages: if: branch = master - name: test if: (branch = master AND type != pull_request) OR commit_message =~ /.*\[run ci\]/ - - name: tests - if: (branch = master AND type != pull_request) OR commit_message =~ /.*\[run ci\]/ jobs: allow_failures: From dec921719c0fe8531454024be937ca6ca46f0cb2 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 6 Sep 2019 20:24:20 +0300 Subject: [PATCH 590/735] Some errors returning --- src/api/error_codes.rs | 14 ++++++++++++++ src/signalling/room.rs | 16 +++++++++++----- src/signalling/room_service.rs | 4 ++-- 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/src/api/error_codes.rs b/src/api/error_codes.rs index 4412c8ca0..6fd6beaad 100644 --- a/src/api/error_codes.rs +++ b/src/api/error_codes.rs @@ -227,6 +227,17 @@ pub enum ErrorCode { /// Code: __1302__. #[display(fmt = "Room already exists.")] RoomAlreadyExists = 1302, + + /////////////////////////////////////////// + // Internal server errors (1400 - 1499) // + ///////////////////////////////////////// + // TODO: Maybe print errors to log for this kind of errors?? + /// [`LocalUriType`] with some [`RoomId`] provided + /// to [`Room`] with not this [`Room`]'s [`RoomId`]. + #[display( + fmt = "Local URI provided to 'Room' which have different RoomId." + )] + UriProvidedToWrongRoom = 1400, } impl From for ErrorResponse { @@ -286,6 +297,9 @@ impl From for ErrorResponse { RoomError::MemberError(e) => e.into(), RoomError::MembersLoadError(e) => e.into(), RoomError::ParticipantServiceErr(e) => e.into(), + RoomError::WrongRoomId(uri, _) => { + Self::new(ErrorCode::UriProvidedToWrongRoom, &uri) + } _ => Self::unknown(&err), } } diff --git a/src/signalling/room.rs b/src/signalling/room.rs index ea5b05364..70be4f372 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -79,6 +79,11 @@ pub enum RoomError { ParticipantServiceErr(ParticipantServiceErr), #[fail(display = "Client error:{}", _0)] ClientError(String), + #[fail( + display = "Given LocalUri [uri = {}] to wrong room [id = {}]", + _0, _1 + )] + WrongRoomId(LocalUriType, RoomId), } impl From for RoomError { @@ -706,9 +711,7 @@ impl Into for &mut Room { #[derive(Message)] #[rtype(result = "Result, RoomError>")] -pub struct SerializeProto { - pub uris: Vec, -} +pub struct SerializeProto(pub Vec); impl Handler for Room { type Result = Result, RoomError>; @@ -719,14 +722,17 @@ impl Handler for Room { _: &mut Self::Context, ) -> Self::Result { let mut serialized = HashMap::new(); - for uri in msg.uris { + for uri in msg.0 { match &uri { LocalUriType::Room(room_uri) => { if room_uri.room_id() == &self.id { let current_room: ElementProto = self.into(); serialized.insert(uri, current_room); } else { - // TODO (evdokimovs): return err + return Err(RoomError::WrongRoomId( + uri, + self.id.clone(), + )); } } LocalUriType::Member(member_uri) => { diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index 55c6a49c7..512bfeae2 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -349,7 +349,7 @@ impl Handler for RoomService { let mut futs = Vec::new(); for (room_id, elements) in rooms_elements { if let Some(room) = self.room_repo.get(&room_id) { - futs.push(room.send(SerializeProto { uris: elements })); + futs.push(room.send(SerializeProto(elements))); } else { return Box::new(actix::fut::err( RoomServiceError::RoomNotFound(get_local_uri_to_room( @@ -391,7 +391,7 @@ impl Handler for RoomService { fn handle( &mut self, msg: CreateMemberInRoom, - _ctx: &mut Self::Context, + _: &mut Self::Context, ) -> Self::Result { let fut = if let Some(room) = self.room_repo.get(&msg.room_id) { Either::A( From 1f74867ce762feef75baed5ed0477dc9cff95149 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 9 Sep 2019 12:20:52 +0300 Subject: [PATCH 591/735] Return err on unimplemented Apply method call --- src/api/control/grpc/server.rs | 19 ++++++++++++++++--- src/bin/client.rs | 13 +++++++++++-- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index 05f07206a..76aba4682 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -375,12 +375,25 @@ impl ControlApi for ControlApiService { /// Implementation for `Apply` method of gRPC control API. fn apply( &mut self, - _ctx: RpcContext, + ctx: RpcContext, _req: ApplyRequest, sink: UnarySink, ) { - // TODO: poll UnarySinkResult's, log err if any - sink.fail(RpcStatus::new(RpcStatusCode::Unimplemented, None)); + ctx.spawn( + sink.fail(RpcStatus::new( + RpcStatusCode::Unimplemented, + Some("Apply method currently is unimplemented.".to_string()), + )) + .map(|_| { + info!( + "An unimplemented gRPC Control API method 'Apply' was \ + called." + ); + }) + .map_err(|e| { + warn!("Unimplemented method Apply error: {:?}", e); + }), + ); } /// Implementation for `Delete` method of gRPC control API. diff --git a/src/bin/client.rs b/src/bin/client.rs index 13e7ae168..2214306da 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -5,8 +5,9 @@ use std::{collections::HashMap, sync::Arc}; use grpcio::{ChannelBuilder, EnvBuilder}; use medea_grpc_proto::{ control::{ - CreateRequest, IdRequest, Member, Member_Element, Room, Room_Element, - WebRtcPlayEndpoint, WebRtcPublishEndpoint, WebRtcPublishEndpoint_P2P, + ApplyRequest, CreateRequest, IdRequest, Member, Member_Element, Room, + Room_Element, WebRtcPlayEndpoint, WebRtcPublishEndpoint, + WebRtcPublishEndpoint_P2P, }, control_grpc::ControlApiClient, }; @@ -17,6 +18,8 @@ fn main() { let ch = ChannelBuilder::new(env).connect("localhost:50051"); let client = ControlApiClient::new(ch); + unimplemented_apply(&client); + return; create_room(&client); delete_room(&client); delete_endpoint(&client); @@ -26,6 +29,12 @@ fn main() { get_room(&client); } +fn unimplemented_apply(client: &ControlApiClient) { + let mut req = ApplyRequest::new(); + let reply = client.apply(&req).expect("Apply error"); + println!("{:?}", reply); +} + fn create_room(client: &ControlApiClient) { let mut req = CreateRequest::new(); let mut room = Room::new(); From 2a7a5174f402cd7efacdb55123990af46fec7f6b Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 9 Sep 2019 13:06:42 +0300 Subject: [PATCH 592/735] Rewrite Endpoint serialization to proto with Into trait --- src/api/error_codes.rs | 3 + src/bin/client.rs | 19 +++--- src/signalling/elements/endpoints/mod.rs | 17 +++++ .../endpoints/webrtc/play_endpoint.rs | 13 +++- .../endpoints/webrtc/publish_endpoint.rs | 13 +++- src/signalling/elements/member.rs | 41 +++++++++++- src/signalling/participants.rs | 2 +- src/signalling/room.rs | 62 ++++--------------- 8 files changed, 104 insertions(+), 66 deletions(-) diff --git a/src/api/error_codes.rs b/src/api/error_codes.rs index 6fd6beaad..13292320d 100644 --- a/src/api/error_codes.rs +++ b/src/api/error_codes.rs @@ -338,6 +338,9 @@ impl From for ErrorResponse { MemberError::PublishEndpointNotFound(id) => { Self::new(ErrorCode::PublishEndpointNotFound, &id) } + MemberError::EndpointNotFound(id) => { + Self::new(ErrorCode::EndpointNotFound, &id) + } } } } diff --git a/src/bin/client.rs b/src/bin/client.rs index 2214306da..f84e6e5f2 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -18,14 +18,13 @@ fn main() { let ch = ChannelBuilder::new(env).connect("localhost:50051"); let client = ControlApiClient::new(ch); - unimplemented_apply(&client); - return; + // unimplemented_apply(&client); create_room(&client); - delete_room(&client); - delete_endpoint(&client); - delete_member(&client); - create_member(&client); - create_endpoint(&client); + // delete_room(&client); + // delete_endpoint(&client); + // delete_member(&client); + // create_member(&client); + // create_endpoint(&client); get_room(&client); } @@ -143,10 +142,10 @@ fn delete_member(client: &ControlApiClient) { fn get_room(client: &ControlApiClient) { let mut get_room_request = IdRequest::new(); let mut room = RepeatedField::new(); - room.push("local://grpc-test".to_string()); - room.push("local://video-call-1/responder".to_string()); + // room.push("local://grpc-test".to_string()); + // room.push("local://video-call-1/responder".to_string()); room.push("local://grpc-test/publisher/publish".to_string()); - room.push("local://pub-pub-video-call".to_string()); + // room.push("local://pub-pub-video-call".to_string()); get_room_request.set_id(room); let reply = client.get(&get_room_request).expect("get room"); diff --git a/src/signalling/elements/endpoints/mod.rs b/src/signalling/elements/endpoints/mod.rs index cadc86a3c..98056d0aa 100644 --- a/src/signalling/elements/endpoints/mod.rs +++ b/src/signalling/elements/endpoints/mod.rs @@ -1,3 +1,20 @@ //! Medea endpoints implementations. pub mod webrtc; + +use medea_grpc_proto::control::Element as RootElementProto; + +pub enum Endpoint { + WebRtcPublishEndpoint(webrtc::WebRtcPublishEndpoint), + WebRtcPlayEndpoint(webrtc::WebRtcPlayEndpoint), +} + +// TODO: maybe better? +impl Into for Endpoint { + fn into(self) -> RootElementProto { + match self { + Self::WebRtcPublishEndpoint(play) => play.into(), + Self::WebRtcPlayEndpoint(publish) => publish.into(), + } + } +} diff --git a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs index 76a723e28..785b0f9ca 100644 --- a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs @@ -7,7 +7,7 @@ use std::{ use medea_client_api_proto::PeerId; use medea_grpc_proto::control::{ - Member_Element as ElementProto, + Element as RootElementProto, Member_Element as ElementProto, WebRtcPlayEndpoint as WebRtcPlayEndpointProto, }; @@ -22,6 +22,7 @@ use crate::{ }; use super::publish_endpoint::WebRtcPublishEndpoint; +use crate::api::control::RootElement; #[derive(Debug, Clone)] struct WebRtcPlayEndpointInner { @@ -201,3 +202,13 @@ impl Into for WebRtcPlayEndpoint { element } } + +impl Into for WebRtcPlayEndpoint { + fn into(self) -> RootElementProto { + let mut element = RootElementProto::new(); + let mut member_element: ElementProto = self.into(); + let endpoint = member_element.take_webrtc_play(); + element.set_webrtc_play(endpoint); + element + } +} diff --git a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs index a69969bde..69225c03b 100644 --- a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs @@ -8,7 +8,7 @@ use std::{ use medea_client_api_proto::PeerId; use medea_grpc_proto::control::{ - Member_Element as ElementProto, + Element as RootElementProto, Member_Element as ElementProto, WebRtcPublishEndpoint as WebRtcPublishEndpointProto, }; @@ -23,6 +23,7 @@ use crate::{ }; use super::play_endpoint::WebRtcPlayEndpoint; +use crate::api::control::RootElement; #[derive(Debug, Clone)] struct WebRtcPublishEndpointInner { @@ -225,3 +226,13 @@ impl Into for WebRtcPublishEndpoint { element } } + +impl Into for WebRtcPublishEndpoint { + fn into(self) -> RootElementProto { + let mut element = RootElementProto::new(); + let mut member_element: ElementProto = self.into(); + let endpoint = member_element.take_webrtc_pub(); + element.set_webrtc_pub(endpoint); + element + } +} diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index 2777b3a1c..3ca1cd72c 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -12,7 +12,8 @@ use std::{ use failure::Fail; use medea_client_api_proto::{IceServer, PeerId}; use medea_grpc_proto::control::{ - Member as MemberProto, Room_Element as ElementProto, + Element as RootElementProto, Member as MemberProto, + Room_Element as ElementProto, }; use crate::{ @@ -28,7 +29,10 @@ use crate::{ media::IceUser, }; -use super::endpoints::webrtc::{WebRtcPlayEndpoint, WebRtcPublishEndpoint}; +use super::endpoints::{ + webrtc::{WebRtcPlayEndpoint, WebRtcPublishEndpoint}, + Endpoint, +}; /// Errors which may occur while loading [`Member`]s from [`RoomSpec`]. #[derive(Debug, Fail)] @@ -64,6 +68,9 @@ pub enum MemberError { #[fail(display = "Play endpoint [id = {}] not found.", _0)] PlayEndpointNotFound(LocalUri), + + #[fail(display = "Endpoint [id = {}] not found.", _0)] + EndpointNotFound(LocalUri), } /// [`Member`] is member of [`Room`]. @@ -417,6 +424,24 @@ impl Member { member.insert_sink(sink); } + pub fn get_endpoint_by_id( + &self, + id: String, + ) -> Result { + let webrtc_publish_id = WebRtcPublishId(id); + if let Some(publish_endpoint) = self.get_src_by_id(&webrtc_publish_id) { + return Ok(Endpoint::WebRtcPublishEndpoint(publish_endpoint)); + } + let webrtc_play_id = WebRtcPlayId(webrtc_publish_id.0); + if let Some(play_endpoint) = self.get_sink_by_id(&webrtc_play_id) { + return Ok(Endpoint::WebRtcPlayEndpoint(play_endpoint)); + } + + Err(MemberError::EndpointNotFound( + self.get_local_uri_to_endpoint(webrtc_play_id.to_string()), + )) + } + /// Downgrade strong [`Member`]'s pointer to weak [`WeakMember`] pointer. pub fn downgrade(&self) -> WeakMember { WeakMember(Rc::downgrade(&self.0)) @@ -533,6 +558,18 @@ impl Into for Member { } } +impl Into for Member { + fn into(self) -> RootElementProto { + let mut member_element: ElementProto = self.into(); + let member = member_element.take_member(); + + let mut element = RootElementProto::new(); + element.set_member(member); + + element + } +} + #[cfg(test)] mod tests { use crate::api::control::{MemberId, RootElement}; diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index ce852140d..26860692d 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -33,7 +33,7 @@ use crate::{ WebRtcPublishEndpoint as WebRtcPublishEndpointSpec, }, local_uri::{IsEndpointId, IsMemberId, LocalUri}, - MemberId, MemberSpec, RoomId, RoomSpec, WebRtcPlayId, + Endpoint, MemberId, MemberSpec, RoomId, RoomSpec, WebRtcPlayId, WebRtcPublishId, }, }, diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 70be4f372..0b3b0ce40 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -641,47 +641,6 @@ impl Room { endpoint_id, member_id, self.id ); } - - fn serialize_member_to_protobuf( - &self, - member_id: &MemberId, - ) -> Result { - let member = self.members.get_member(member_id)?; - - let mut member_element: Room_Element = member.into(); - let member = member_element.take_member(); - - let mut element = ElementProto::new(); - element.set_member(member); - - Ok(element) - } - - fn serialize_endpoint_to_proto( - &self, - member_id: &MemberId, - endpoint_id: String, - ) -> Result { - let member = self.members.get_member(member_id)?; - - let publish_endpoint_id = WebRtcPublishId(endpoint_id); - let mut element = ElementProto::new(); - - if let Some(endpoint) = member.get_src_by_id(&publish_endpoint_id) { - let mut member_element: Member_Element = endpoint.into(); - let endpoint = member_element.take_webrtc_pub(); - element.set_webrtc_pub(endpoint); - } else { - let play_endpoint_id = WebRtcPlayId(publish_endpoint_id.0); - - let endpoint = member.get_sink(&play_endpoint_id)?; - let mut member_element: Member_Element = endpoint.into(); - let endpoint = member_element.take_webrtc_play(); - element.set_webrtc_play(endpoint); - } - - Ok(element) - } } /// [`Actor`] implementation that provides an ergonomic way @@ -721,7 +680,8 @@ impl Handler for Room { msg: SerializeProto, _: &mut Self::Context, ) -> Self::Result { - let mut serialized = HashMap::new(); + let mut serialized: HashMap = + HashMap::new(); for uri in msg.0 { match &uri { LocalUriType::Room(room_uri) => { @@ -736,17 +696,17 @@ impl Handler for Room { } } LocalUriType::Member(member_uri) => { - let member_id = member_uri.member_id(); - let member_proto = - self.serialize_member_to_protobuf(member_id)?; - serialized.insert(uri, member_proto); + let member = + self.members.get_member(member_uri.member_id())?; + serialized.insert(uri, member.into()); } LocalUriType::Endpoint(endpoint_uri) => { - let endpoint_id = endpoint_uri.endpoint_id().to_string(); - let member_id = endpoint_uri.member_id(); - let endpoint_proto = self - .serialize_endpoint_to_proto(member_id, endpoint_id)?; - serialized.insert(uri, endpoint_proto); + let member = + self.members.get_member(endpoint_uri.member_id())?; + let endpoint = member.get_endpoint_by_id( + endpoint_uri.endpoint_id().to_string(), + )?; + serialized.insert(uri, endpoint.into()); } } } From 61c27f7065c6465368e238ed1fd96f8b1ddda2c7 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 9 Sep 2019 14:12:44 +0300 Subject: [PATCH 593/735] Better error gRPC errors --- src/api/control/grpc/server.rs | 44 ++++++++----------- src/api/error_codes.rs | 61 ++++++++++++++++++-------- src/signalling/participants.rs | 11 ----- src/signalling/room_service.rs | 79 ++++++++++------------------------ 4 files changed, 82 insertions(+), 113 deletions(-) diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index 76aba4682..296c988d2 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -67,9 +67,18 @@ pub enum ControlApiError { #[fail(display = "{:?}", _0)] TryFromElement(TryFromElementError), - /// Wrapped [`MailboxError`]. - #[fail(display = "{:?}", _0)] - MailboxError(MailboxError), + /// [`MailboxError`] for [`RoomService`]. + #[fail(display = "Room service mailbox error: {:?}", _0)] + RoomServiceMailboxError(MailboxError), + + /// [`MailboxError`] which never can happen. This error needed + /// for `fut_try!` macro because they use `From` trait. + /// With this error we cover [`MailboxError`] in places where + /// it cannot happen. + /// + /// __Never use this error.__ + #[fail(display = "Mailbox error which never can happen.")] + UnknownMailboxErr(MailboxError), } impl From for ControlApiError { @@ -90,12 +99,6 @@ impl From for ControlApiError { } } -impl From for ControlApiError { - fn from(from: MailboxError) -> Self { - ControlApiError::MailboxError(from) - } -} - /// Try to unwrap some [`Result`] and if it `Err` then return err future with /// [`ControlApiError`]. /// @@ -200,7 +203,7 @@ impl ControlApiService { Either::A( self.room_service .send(StartRoom(room_id, room)) - .map_err(ControlApiError::from) + .map_err(ControlApiError::RoomServiceMailboxError) .map(move |r| r.map(|_| Ok(sid))), ) } @@ -227,7 +230,7 @@ impl ControlApiService { member_id, spec, }) - .map_err(ControlApiError::from) + .map_err(ControlApiError::RoomServiceMailboxError) .map(|r| r.map(|r| r.map(|_| sids))), ) } @@ -252,7 +255,7 @@ impl ControlApiService { endpoint_id, spec: endpoint, }) - .map_err(ControlApiError::from) + .map_err(ControlApiError::RoomServiceMailboxError) .map(|r| r.map(|r| r.map(|_| HashMap::new()))), ) } @@ -403,24 +406,13 @@ impl ControlApi for ControlApiService { req: IdRequest, sink: UnarySink, ) { - let mut delete_elements = DeleteElements::new(); + let mut uris = Vec::new(); for id in req.get_id() { let uri: LocalUriType = parse_local_uri!(id, ctx, sink, Response); - delete_elements.add_uri(uri); + uris.push(uri); } - - let delete_elements = match delete_elements.validate() { - Ok(validated) => validated, - Err(err) => { - send_error_response!( - ctx, - sink, - ErrorResponse::from(err), - Response - ); - } - }; + let delete_elements = DeleteElements { uris }; ctx.spawn( self.room_service diff --git a/src/api/error_codes.rs b/src/api/error_codes.rs index 13292320d..2a8bc620b 100644 --- a/src/api/error_codes.rs +++ b/src/api/error_codes.rs @@ -133,6 +133,11 @@ pub enum ErrorCode { /// Code: __1005__. #[display(fmt = "Endpoint not found.")] EndpointNotFound = 1005, + /// Room not found for provided element. + /// + /// Code: __1006__. + #[display(fmt = "Room not found for provided element.")] + RoomNotFoundForProvidedElement = 1006, ////////////////////////////////////// // Spec errors (1100 - 1199 codes) // @@ -208,6 +213,11 @@ pub enum ErrorCode { /// Code: __1203__. #[display(fmt = "Provided empty element ID.")] EmptyElementId = 1203, + /// Provided empty elements IDs list. + /// + /// Code: __1204__. + #[display(fmt = "Privded empty elements IDs list.")] + EmptyElementsList = 1204, ///////////////////////////// // Conflict (1300 - 1399) // @@ -227,17 +237,6 @@ pub enum ErrorCode { /// Code: __1302__. #[display(fmt = "Room already exists.")] RoomAlreadyExists = 1302, - - /////////////////////////////////////////// - // Internal server errors (1400 - 1499) // - ///////////////////////////////////////// - // TODO: Maybe print errors to log for this kind of errors?? - /// [`LocalUriType`] with some [`RoomId`] provided - /// to [`Room`] with not this [`Room`]'s [`RoomId`]. - #[display( - fmt = "Local URI provided to 'Room' which have different RoomId." - )] - UriProvidedToWrongRoom = 1400, } impl From for ErrorResponse { @@ -255,7 +254,8 @@ impl From for ErrorResponse { ParticipantServiceErr::EndpointAlreadyExists(id) => { Self::new(ErrorCode::EndpointAlreadyExists, &id) } - _ => Self::unknown(&err), + ParticipantServiceErr::TurnServiceErr(_) + | ParticipantServiceErr::MemberError(_) => Self::unknown(&err), } } } @@ -264,7 +264,13 @@ impl From for ErrorResponse { fn from(err: TryFromProtobufError) -> Self { match err { TryFromProtobufError::SrcUriError(e) => e.into(), - _ => Self::unknown(&err), + TryFromProtobufError::SrcUriNotFound + | TryFromProtobufError::RoomElementNotFound + | TryFromProtobufError::MemberElementNotFound + | TryFromProtobufError::P2pModeNotFound + | TryFromProtobufError::MemberCredentialsNotFound => { + Self::unknown(&err) + } } } } @@ -297,10 +303,16 @@ impl From for ErrorResponse { RoomError::MemberError(e) => e.into(), RoomError::MembersLoadError(e) => e.into(), RoomError::ParticipantServiceErr(e) => e.into(), - RoomError::WrongRoomId(uri, _) => { - Self::new(ErrorCode::UriProvidedToWrongRoom, &uri) - } - _ => Self::unknown(&err), + RoomError::WrongRoomId(_, _) + | RoomError::PeerNotFound(_) + | RoomError::NoTurnCredentials(_) + | RoomError::ConnectionNotExists(_) + | RoomError::UnableToSendEvent(_) + | RoomError::PeerError(_) + | RoomError::TryFromElementError(_) + | RoomError::BadRoomSpec(_) + | RoomError::TurnServiceError(_) + | RoomError::ClientError(_) => Self::unknown(&err), } } } @@ -366,7 +378,16 @@ impl From for ErrorResponse { Self::new(ErrorCode::RoomAlreadyExists, &id) } RoomServiceError::RoomError(e) => e.into(), - _ => Self::unknown(&err), + RoomServiceError::EmptyUrisList => { + Self::new_empty(ErrorCode::EmptyElementsList) + } + RoomServiceError::RoomNotFoundForElement(id) => { + Self::new(ErrorCode::RoomNotFoundForProvidedElement, &id) + } + RoomServiceError::RoomMailboxErr(_) + | RoomServiceError::FailedToLoadStaticSpecs(_) => { + Self::unknown(&err) + } } } } @@ -376,7 +397,9 @@ impl From for ErrorResponse { match err { ControlApiError::LocalUri(e) => e.into(), ControlApiError::TryFromProtobuf(e) => e.into(), - _ => Self::unknown(&err), + ControlApiError::RoomServiceMailboxError(_) + | ControlApiError::TryFromElement(_) + | ControlApiError::UnknownMailboxErr(_) => Self::unknown(&err), } } } diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 26860692d..6f9c04bbe 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -57,11 +57,6 @@ use crate::{ pub enum ParticipantServiceErr { #[fail(display = "TurnService Error in ParticipantService: {}", _0)] TurnServiceErr(TurnServiceErr), - #[fail( - display = "Mailbox error when accessing ParticipantService: {}", - _0 - )] - MailBoxErr(MailboxError), #[fail(display = "Participant [id = {}] not found", _0)] ParticipantNotFound(LocalUri), #[fail(display = "Endpoint [id = {}] not found.", _0)] @@ -80,12 +75,6 @@ impl From for ParticipantServiceErr { } } -impl From for ParticipantServiceErr { - fn from(err: MailboxError) -> Self { - Self::MailBoxErr(err) - } -} - impl From for ParticipantServiceErr { fn from(err: MemberError) -> Self { ParticipantServiceErr::MemberError(err) diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index 512bfeae2..4e579415e 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -38,16 +38,18 @@ type ActFuture = pub enum RoomServiceError { #[fail(display = "Room [id = {}] not found.", _0)] RoomNotFound(LocalUri), - #[fail(display = "Mailbox error: {:?}", _0)] - MailboxError(MailboxError), + #[fail(display = "Room mailbox error: {:?}", _0)] + RoomMailboxErr(MailboxError), #[fail(display = "Room [id = {}] already exists.", _0)] RoomAlreadyExists(LocalUri), #[fail(display = "{}", _0)] RoomError(RoomError), #[fail(display = "Failed to load static specs. {:?}", _0)] FailedToLoadStaticSpecs(failure::Error), - #[fail(display = "Unknow error.")] - Unknown, + #[fail(display = "Empty URIs list.")] + EmptyUrisList, + #[fail(display = "Room not found for element [id = {}]", _0)] + RoomNotFoundForElement(LocalUriType), } impl From for RoomServiceError { @@ -56,12 +58,6 @@ impl From for RoomServiceError { } } -impl From for RoomServiceError { - fn from(e: MailboxError) -> Self { - RoomServiceError::MailboxError(e) - } -} - /// Service for controlling [`Room`]s. pub struct RoomService { /// Repository that stores [`Room`]s addresses. @@ -205,57 +201,25 @@ impl Handler for RoomService { } /// Signal for delete [`Room`]. +// TODO: maybe use state machine? #[derive(Message)] #[rtype(result = "Result<(), RoomServiceError>")] -pub struct DeleteElements { - uris: Vec, - _marker: PhantomData, -} - -pub struct NotValidated; -pub struct Valid; - -impl DeleteElements { - pub fn new() -> DeleteElements { - Self { - uris: vec![], - _marker: PhantomData, - } - } - - pub fn add_uri(&mut self, uri: LocalUriType) { - self.uris.push(uri); - } - - pub fn validate(self) -> Result, RoomServiceError> { - // TODO: correct errors - if self.uris.is_empty() { - return Err(RoomServiceError::Unknown); - } - - let first_room = self.uris[0].room_id(); - let is_same_room = - self.uris.iter().all(|item| item.room_id() == first_room); - - if !is_same_room { - return Err(RoomServiceError::Unknown); - } - - Ok(DeleteElements { - uris: self.uris, - _marker: PhantomData, - }) - } +pub struct DeleteElements { + pub uris: Vec, } -impl Handler> for RoomService { +impl Handler for RoomService { type Result = ActFuture<(), RoomServiceError>; fn handle( &mut self, - msg: DeleteElements, + msg: DeleteElements, _: &mut Context, ) -> Self::Result { + if msg.uris.is_empty() { + return Box::new(actix::fut::err(RoomServiceError::EmptyUrisList)); + } + let mut deletes_from_room: Vec = Vec::new(); let room_messages_futs: Vec< Box>, @@ -277,7 +241,7 @@ impl Handler> for RoomService { Box::new(wrap_future( futures::future::join_all(room_messages_futs) .map(|_| ()) - .map_err(|e| RoomServiceError::from(e)), + .map_err(|e| RoomServiceError::RoomMailboxErr(e)), )) } else if !deletes_from_room.is_empty() { let room_id = deletes_from_room[0].room_id().clone(); @@ -302,7 +266,7 @@ impl Handler> for RoomService { if let Some(room) = self.room_repo.get(&room_id) { Box::new(wrap_future( room.send(Delete(deletes_from_room)) - .map_err(|e| RoomServiceError::from(e)), + .map_err(|e| RoomServiceError::RoomMailboxErr(e)), )) } else { Box::new(actix::fut::err(RoomServiceError::RoomNotFound( @@ -340,7 +304,7 @@ impl Handler for RoomService { )); } else { return Box::new(actix::fut::err( - RoomServiceError::Unknown, + RoomServiceError::RoomNotFoundForElement(uri), )); } } @@ -352,6 +316,7 @@ impl Handler for RoomService { futs.push(room.send(SerializeProto(elements))); } else { return Box::new(actix::fut::err( + // TODO: better return RoomNotFoundForElement err RoomServiceError::RoomNotFound(get_local_uri_to_room( room_id, )), @@ -361,7 +326,7 @@ impl Handler for RoomService { Box::new(wrap_future( futures::future::join_all(futs) - .map_err(|e| RoomServiceError::from(e)) + .map_err(|e| RoomServiceError::RoomMailboxErr(e)) .and_then(|results| { let mut all = HashMap::new(); for result in results { @@ -396,7 +361,7 @@ impl Handler for RoomService { let fut = if let Some(room) = self.room_repo.get(&msg.room_id) { Either::A( room.send(CreateMember(msg.member_id, msg.spec)) - .map_err(RoomServiceError::from), + .map_err(RoomServiceError::RoomMailboxErr), ) } else { Either::B(future::err(RoomServiceError::RoomNotFound( @@ -433,7 +398,7 @@ impl Handler for RoomService { endpoint_id: msg.endpoint_id, spec: msg.spec, }) - .map_err(RoomServiceError::from), + .map_err(RoomServiceError::RoomMailboxErr), ) } else { Either::B(future::err(RoomServiceError::RoomNotFound( From 4c18b5719e6ddc6f453f2a7de16d00683452350e Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 9 Sep 2019 14:37:20 +0300 Subject: [PATCH 594/735] Fix lints --- src/api/control/endpoint.rs | 222 ------------------ src/bin/client.rs | 8 +- .../endpoints/webrtc/play_endpoint.rs | 1 - .../endpoints/webrtc/publish_endpoint.rs | 1 - src/signalling/elements/member.rs | 2 +- src/signalling/participants.rs | 5 +- src/signalling/room.rs | 22 +- src/signalling/room_service.rs | 43 ++-- 8 files changed, 40 insertions(+), 264 deletions(-) delete mode 100644 src/api/control/endpoint.rs diff --git a/src/api/control/endpoint.rs b/src/api/control/endpoint.rs deleted file mode 100644 index 2cc718769..000000000 --- a/src/api/control/endpoint.rs +++ /dev/null @@ -1,222 +0,0 @@ -//! Control API specification Endpoint definitions. - -use std::{convert::TryFrom, fmt, str::FromStr}; - -use serde::{ - de::{self, Deserializer, Error, Visitor}, - Deserialize, -}; -use url::Url; - -use crate::api::control::MemberId; - -use super::{member::MemberElement, TryFromElementError}; - -/// [`Endpoint`] represents a media element that one or more media data streams -/// flow through. -#[derive(Debug)] -pub enum Endpoint { - WebRtcPublish(WebRtcPublishEndpoint), - WebRtcPlay(WebRtcPlayEndpoint), -} - -#[derive(Clone, Debug)] -pub enum Scheme { - Local, -} - -impl FromStr for Scheme { - type Err = String; - - fn from_str(s: &str) -> Result { - match s { - "local" => Ok(Scheme::Local), - _ => Err(format!("cannot parse \"{}\" to Scheme", s)), - } - } -} - -impl TryFrom<&MemberElement> for Endpoint { - type Error = TryFromElementError; - - fn try_from(from: &MemberElement) -> Result { - match from { - MemberElement::WebRtcPlayEndpoint { spec } => { - Ok(Self::WebRtcPlay(spec.clone())) - } - MemberElement::WebRtcPublishEndpoint { spec } => { - Ok(Self::WebRtcPublish(spec.clone())) - } - } - } -} - -/// Peer-to-peer mode of [`WebRtcPublishEndpoint`]. -#[derive(Clone, Deserialize, Debug)] -pub enum P2pMode { - /// Always connect peer-to-peer. - Always, -} - -/// Media element which is able to publish media data for another client via -/// WebRTC. -#[allow(clippy::module_name_repetitions)] -#[derive(Clone, Deserialize, Debug)] -pub struct WebRtcPublishEndpoint { - /// Peer-to-peer mode. - pub p2p: P2pMode, -} - -/// Media element which is able to play media data for client via WebRTC. -#[allow(clippy::module_name_repetitions)] -#[derive(Clone, Deserialize, Debug)] -pub struct WebRtcPlayEndpoint { - /// Source URI in format `local://{room_id}/{member_id}/{endpoint_id}`. - pub src: SrcUri, -} - -/// Special uri with pattern `local://{room_id}/{member_id}/{endpoint_id}`. -#[derive(Clone, Debug)] -pub struct SrcUri { - pub scheme: Scheme, - /// ID of [`Room`] - /// - /// [`Room`]: crate::signalling::room::Room - pub room_id: String, - /// ID of `Member` - pub member_id: MemberId, - /// Control ID of [`Endpoint`] - pub endpoint_id: String, -} - -/// Serde deserializer for [`SrcUri`]. -/// Deserialize URIs with pattern `local://{room_id}/{member_id}/{endpoint_id}`. -impl<'de> Deserialize<'de> for SrcUri { - fn deserialize(deserializer: D) -> Result - where - D: Deserializer<'de>, - { - struct SrcUriVisitor; - - impl<'de> Visitor<'de> for SrcUriVisitor { - type Value = SrcUri; - - fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str( - "Uri in format local://room_id/member_id/endpoint_id", - ) - } - - fn visit_str(self, value: &str) -> Result - where - E: de::Error, - { - let uri = Url::parse(value).map_err(|_| { - Error::custom(format!("'{}' is not URL", value)) - })?; - - let scheme = match FromStr::from_str(uri.scheme()) { - Ok(scheme) => scheme, - Err(_) => { - return Err(Error::custom(format!( - "cannot parse uri scheme \"{}\"", - value - ))) - } - }; - let room_id = match uri.host() { - Some(host) => host.to_string(), - None => { - return Err(Error::custom(format!( - "cannot parse uri scheme \"{}\"", - value - ))) - } - }; - - let mut path = match uri.path_segments() { - Some(path) => path, - None => { - return Err(Error::custom(format!( - "cannot parse uri segments \"{}\"", - value - ))) - } - }; - - let member_id = match path.next() { - Some(member_id) => MemberId(member_id.to_owned()), - None => { - return Err(Error::custom(format!( - "cannot parse member_id \"{}\"", - value - ))) - } - }; - - let endpoint_id = match path.next() { - Some(endpoint_id) => endpoint_id.to_owned(), - None => { - return Err(Error::custom(format!( - "cannot parse endpoint_id \"{}\"", - value - ))) - } - }; - - Ok(SrcUri { - scheme, - room_id, - member_id, - endpoint_id, - }) - } - } - - deserializer.deserialize_identifier(SrcUriVisitor) - } -} - -#[cfg(test)] -mod src_uri_deserialization_tests { - use serde::Deserialize; - - use super::*; - - #[derive(Deserialize)] - struct SrcUriTest { - src: SrcUri, - } - - #[test] - fn deserialize() { - let valid_json_uri = - r#"{ "src": "local://room_id/member_id/endpoint_id" }"#; - let local_uri: SrcUriTest = - serde_json::from_str(valid_json_uri).unwrap(); - - assert_eq!( - local_uri.src.member_id, - MemberId(String::from("member_id")) - ); - assert_eq!(local_uri.src.room_id, String::from("room_id")); - assert_eq!(local_uri.src.endpoint_id, String::from("endpoint_id")); - } - - #[test] - fn return_error_when_uri_not_local() { - let invalid_json_uri = - r#"{ "src": "not_local://room_id/member_id/endpoint_id" }"#; - if serde_json::from_str::(invalid_json_uri).is_ok() { - unreachable!() - } - } - - #[test] - fn return_error_when_uri_is_not_full() { - let invalid_json_uri = r#"{ "src": "local://room_id/member_id" }"#; - if serde_json::from_str::(invalid_json_uri).is_ok() { - unreachable!() - } - } -} diff --git a/src/bin/client.rs b/src/bin/client.rs index f84e6e5f2..6c6f6befd 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -29,7 +29,7 @@ fn main() { } fn unimplemented_apply(client: &ControlApiClient) { - let mut req = ApplyRequest::new(); + let req = ApplyRequest::new(); let reply = client.apply(&req).expect("Apply error"); println!("{:?}", reply); } @@ -142,10 +142,10 @@ fn delete_member(client: &ControlApiClient) { fn get_room(client: &ControlApiClient) { let mut get_room_request = IdRequest::new(); let mut room = RepeatedField::new(); - // room.push("local://grpc-test".to_string()); - // room.push("local://video-call-1/responder".to_string()); + room.push("local://grpc-test".to_string()); + room.push("local://video-call-1/responder".to_string()); room.push("local://grpc-test/publisher/publish".to_string()); - // room.push("local://pub-pub-video-call".to_string()); + room.push("local://pub-pub-video-call".to_string()); get_room_request.set_id(room); let reply = client.get(&get_room_request).expect("get room"); diff --git a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs index 785b0f9ca..fd177831b 100644 --- a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs @@ -22,7 +22,6 @@ use crate::{ }; use super::publish_endpoint::WebRtcPublishEndpoint; -use crate::api::control::RootElement; #[derive(Debug, Clone)] struct WebRtcPlayEndpointInner { diff --git a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs index 69225c03b..cb474c465 100644 --- a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs @@ -23,7 +23,6 @@ use crate::{ }; use super::play_endpoint::WebRtcPlayEndpoint; -use crate::api::control::RootElement; #[derive(Debug, Clone)] struct WebRtcPublishEndpointInner { diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index 3ca1cd72c..4dcb0b9c1 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -60,7 +60,7 @@ pub enum MembersLoadError { PublishEndpointNotFound(LocalUri), } -#[allow(clippy::module_name_repetitions)] +#[allow(clippy::module_name_repetitions, clippy::pub_enum_variant_names)] #[derive(Debug, Fail)] pub enum MemberError { #[fail(display = "Publish endpoint [id = {}] not found.", _0)] diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 6f9c04bbe..ab67c02ca 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -10,8 +10,7 @@ use std::{collections::HashMap, time::Instant}; use actix::{ - fut::wrap_future, ActorFuture, AsyncContext, Context, MailboxError, - SpawnHandle, + fut::wrap_future, ActorFuture, AsyncContext, Context, SpawnHandle, }; use failure::Fail; use futures::{ @@ -33,7 +32,7 @@ use crate::{ WebRtcPublishEndpoint as WebRtcPublishEndpointSpec, }, local_uri::{IsEndpointId, IsMemberId, LocalUri}, - Endpoint, MemberId, MemberSpec, RoomId, RoomSpec, WebRtcPlayId, + MemberId, MemberSpec, RoomId, RoomSpec, WebRtcPlayId, WebRtcPublishId, }, }, diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 0b3b0ce40..54ddaaa3f 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -13,9 +13,7 @@ use failure::Fail; use futures::future; use medea_client_api_proto::{Command, Event, IceCandidate, PeerId, TrackId}; -use medea_grpc_proto::control::{ - Element as ElementProto, Member_Element, Room as RoomProto, Room_Element, -}; +use medea_grpc_proto::control::{Element as ElementProto, Room as RoomProto}; use crate::{ api::{ @@ -573,12 +571,12 @@ impl Room { } /// Signal for delete [`Member`] from this [`Room`] - fn delete_member(&mut self, member_id: MemberId, ctx: &mut Context) { + fn delete_member(&mut self, member_id: &MemberId, ctx: &mut Context) { debug!( "Delete Member [id = {}] in room [id = {}].", member_id, self.id ); - if let Some(member) = self.members.get_member_by_id(&member_id) { + if let Some(member) = self.members.get_member_by_id(member_id) { let mut peers = HashSet::new(); for (_, sink) in member.sinks() { if let Some(peer_id) = sink.peer_id() { @@ -595,7 +593,7 @@ impl Room { self.remove_peers(&member.id(), peers, ctx); } - self.members.delete_member(&member_id, ctx); + self.members.delete_member(member_id, ctx); debug!( "Member [id = {}] removed from Room [id = {}].", @@ -606,18 +604,18 @@ impl Room { /// Signal for delete endpoint from this [`Room`] fn delete_endpoint( &mut self, - member_id: MemberId, + member_id: &MemberId, endpoint_id: String, ctx: &mut Context, ) { let endpoint_id = if let Some(member) = - self.members.get_member_by_id(&member_id) + self.members.get_member_by_id(member_id) { let play_id = WebRtcPlayId(endpoint_id); if let Some(endpoint) = member.take_sink(&play_id) { if let Some(peer_id) = endpoint.peer_id() { let removed_peers = - self.peers.remove_peer(&member_id, peer_id); + self.peers.remove_peer(member_id, peer_id); for (member_id, peers_ids) in removed_peers { self.member_peers_removed(peers_ids, member_id, ctx); } @@ -627,7 +625,7 @@ impl Room { let publish_id = WebRtcPublishId(play_id.0); if let Some(endpoint) = member.take_src(&publish_id) { let peer_ids = endpoint.peer_ids(); - self.remove_peers(&member_id, peer_ids, ctx); + self.remove_peers(member_id, peer_ids, ctx); } publish_id.0 @@ -922,12 +920,12 @@ impl Handler for Room { } member_ids.into_iter().for_each(|uri| { let (member_id, _) = uri.take_member_id(); - self.delete_member(member_id, ctx); + self.delete_member(&member_id, ctx); }); endpoint_ids.into_iter().for_each(|uri| { let (endpoint_id, member_uri) = uri.take_endpoint_id(); let (member_id, _) = member_uri.take_member_id(); - self.delete_endpoint(member_id, endpoint_id, ctx); + self.delete_endpoint(&member_id, endpoint_id, ctx); }); } } diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index 4e579415e..4ed558877 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -27,7 +27,6 @@ use crate::{ }, AppContext, }; -use serde::export::PhantomData; use std::collections::HashMap; type ActFuture = @@ -211,10 +210,12 @@ pub struct DeleteElements { impl Handler for RoomService { type Result = ActFuture<(), RoomServiceError>; + // TODO: delete this allow when drain_filter TODO will be resolved. + #[allow(clippy::unnecessary_filter_map)] fn handle( &mut self, msg: DeleteElements, - _: &mut Context, + _: &mut Self::Context, ) -> Self::Result { if msg.uris.is_empty() { return Box::new(actix::fut::err(RoomServiceError::EmptyUrisList)); @@ -228,23 +229,27 @@ impl Handler for RoomService { .into_iter() .filter_map(|l| { if let LocalUriType::Room(room_id) = l { - Some(room_id) + Some(self.close_room(room_id.take_room_id())) } else { deletes_from_room.push(l); None } }) - .map(|room_id| self.close_room(room_id.take_room_id())) .collect(); if !room_messages_futs.is_empty() { Box::new(wrap_future( futures::future::join_all(room_messages_futs) .map(|_| ()) - .map_err(|e| RoomServiceError::RoomMailboxErr(e)), + .map_err(RoomServiceError::RoomMailboxErr), )) - } else if !deletes_from_room.is_empty() { + } else if deletes_from_room.is_empty() { + Box::new(actix::fut::ok(())) + } else { let room_id = deletes_from_room[0].room_id().clone(); + + // TODO: rewrite using drain_filter when this will be in stable + // http://tiny.cc/2osfcz (Vec::drain_filter docs) let mut ignored_ids = Vec::new(); let deletes_from_room: Vec = deletes_from_room .into_iter() @@ -257,24 +262,24 @@ impl Handler for RoomService { } }) .collect(); + if !ignored_ids.is_empty() { warn!( "Some ids from Get request was ignored: {:?}", ignored_ids ); } + if let Some(room) = self.room_repo.get(&room_id) { Box::new(wrap_future( room.send(Delete(deletes_from_room)) - .map_err(|e| RoomServiceError::RoomMailboxErr(e)), + .map_err(RoomServiceError::RoomMailboxErr), )) } else { Box::new(actix::fut::err(RoomServiceError::RoomNotFound( get_local_uri_to_room(room_id), ))) } - } else { - Box::new(actix::fut::ok(())) } } } @@ -295,18 +300,16 @@ impl Handler for RoomService { if self.room_repo.is_contains_room_with_id(uri.room_id()) { rooms_elements .entry(uri.room_id().clone()) - .or_insert_with(|| Vec::new()) + .or_insert_with(Vec::new) .push(uri); + } else if let LocalUriType::Room(room_uri) = uri { + return Box::new(actix::fut::err( + RoomServiceError::RoomNotFound(room_uri), + )); } else { - if let LocalUriType::Room(room_uri) = uri { - return Box::new(actix::fut::err( - RoomServiceError::RoomNotFound(room_uri), - )); - } else { - return Box::new(actix::fut::err( - RoomServiceError::RoomNotFoundForElement(uri), - )); - } + return Box::new(actix::fut::err( + RoomServiceError::RoomNotFoundForElement(uri), + )); } } @@ -326,7 +329,7 @@ impl Handler for RoomService { Box::new(wrap_future( futures::future::join_all(futs) - .map_err(|e| RoomServiceError::RoomMailboxErr(e)) + .map_err(RoomServiceError::RoomMailboxErr) .and_then(|results| { let mut all = HashMap::new(); for result in results { From 255b188ab2cfa21124b826c746d74f2ddf61c0a6 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 9 Sep 2019 15:28:31 +0300 Subject: [PATCH 595/735] Additional error text --- src/api/error_codes.rs | 84 +++++++++++++++++++++++++--------- src/bin/client.rs | 7 +-- src/signalling/room_service.rs | 21 +++++++-- 3 files changed, 84 insertions(+), 28 deletions(-) diff --git a/src/api/error_codes.rs b/src/api/error_codes.rs index 2a8bc620b..1ca0c4fa3 100644 --- a/src/api/error_codes.rs +++ b/src/api/error_codes.rs @@ -35,13 +35,16 @@ pub struct ErrorResponse { error_code: ErrorCode, /// Element ID where some error happened. May be empty. - element_id: String, + element_id: Option, - /// If some unexpected error will be throwed then this field will - /// store this error converted to [`String`]. + /// All [`ErrorCode`]s have [`Display`] implementation. And this + /// implementation will be used if this field is [`None`]. But + /// some time we want to use custom text. Then we set this field + /// to [`Some`] and this custom text will be added to + /// [`Display`] implementation's text. /// - /// Normally this field should be [`None`]. - unknown_error: Option, + /// By default this field should be [`None`]. + additional_text: Option, } impl ErrorResponse { @@ -49,17 +52,17 @@ impl ErrorResponse { pub fn new(error_code: ErrorCode, element_id: &T) -> Self { Self { error_code, - element_id: element_id.to_string(), - unknown_error: None, + element_id: Some(element_id.to_string()), + additional_text: None, } } /// New [`ErrorResponse`] only with [`ErrorCode`]. - pub fn new_empty(error_code: ErrorCode) -> Self { + pub fn empty(error_code: ErrorCode) -> Self { Self { error_code, - element_id: String::new(), - unknown_error: None, + element_id: None, + additional_text: None, } } @@ -69,8 +72,20 @@ impl ErrorResponse { pub fn unknown(unknown_error: &B) -> Self { Self { error_code: ErrorCode::UnknownError, - unknown_error: Some(unknown_error.to_string()), - element_id: String::new(), + additional_text: Some(unknown_error.to_string()), + element_id: None, + } + } + + pub fn custom_text( + error_code: ErrorCode, + text: String, + id: Option>, + ) -> Self { + Self { + error_code, + additional_text: Some(text), + element_id: id.map(|s| s.to_string()), } } } @@ -79,17 +94,19 @@ impl Into for ErrorResponse { fn into(self) -> ErrorProto { let mut error = ErrorProto::new(); - if let Some(unknown_error) = &self.unknown_error { + if let Some(additional_text) = &self.additional_text { error.set_text(format!( - "{} Here is error: '{}'", + "{} {}", self.error_code.to_string(), - unknown_error + additional_text )); } else { error.set_text(self.error_code.to_string()); } - error.set_element(self.element_id.to_string()); + if let Some(id) = self.element_id { + error.set_element(id); + } error.set_code(self.error_code as u32); error @@ -216,8 +233,18 @@ pub enum ErrorCode { /// Provided empty elements IDs list. /// /// Code: __1204__. - #[display(fmt = "Privded empty elements IDs list.")] + #[display(fmt = "Provided empty elements IDs list.")] EmptyElementsList = 1204, + /// Provided not the same [`RoomId`]s in elements IDs. + /// + /// Code: __1205__. + #[display(fmt = "Provided not the same Room IDs in elements IDs.")] + ProvidedNotSameRoomIds = 1205, + /// Provided ID for [`Room`] and for [`Room`]'s elements. + /// + /// Code: __1206__. + #[display(fmt = "Provided ID for Room and for Room's elements.")] + DeleteRoomAndFromRoom = 1206, ///////////////////////////// // Conflict (1300 - 1399) // @@ -284,9 +311,7 @@ impl From for ErrorResponse { LocalUriParseError::TooManyFields(text) => { Self::new(ErrorCode::ElementIdIsTooLong, &text) } - LocalUriParseError::Empty => { - Self::new_empty(ErrorCode::EmptyElementId) - } + LocalUriParseError::Empty => Self::empty(ErrorCode::EmptyElementId), LocalUriParseError::MissingFields(text) => { Self::new(ErrorCode::MissingFieldsInSrcUri, &text) } @@ -379,11 +404,28 @@ impl From for ErrorResponse { } RoomServiceError::RoomError(e) => e.into(), RoomServiceError::EmptyUrisList => { - Self::new_empty(ErrorCode::EmptyElementsList) + Self::empty(ErrorCode::EmptyElementsList) } RoomServiceError::RoomNotFoundForElement(id) => { Self::new(ErrorCode::RoomNotFoundForProvidedElement, &id) } + RoomServiceError::NotSameRoomIds(ids, expected_room_id) => { + Self::custom_text( + ErrorCode::ProvidedNotSameRoomIds, + format!( + "Expected Room ID: '{}'. IDs with different Room ID: \ + {:?}", + expected_room_id, + ids.into_iter() + .map(|id| id.to_string()) + .collect::>() + ), + None, + ) + } + RoomServiceError::DeleteRoomAndFromRoom => { + Self::empty(ErrorCode::DeleteRoomAndFromRoom) + } RoomServiceError::RoomMailboxErr(_) | RoomServiceError::FailedToLoadStaticSpecs(_) => { Self::unknown(&err) diff --git a/src/bin/client.rs b/src/bin/client.rs index 6c6f6befd..117a73c60 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -20,12 +20,12 @@ fn main() { // unimplemented_apply(&client); create_room(&client); - // delete_room(&client); + delete_room(&client); // delete_endpoint(&client); // delete_member(&client); // create_member(&client); // create_endpoint(&client); - get_room(&client); + // get_room(&client); } fn unimplemented_apply(client: &ControlApiClient) { @@ -112,7 +112,8 @@ fn create_endpoint(client: &ControlApiClient) { fn delete_room(client: &ControlApiClient) { let mut delete_request = IdRequest::new(); let mut rooms = RepeatedField::new(); - rooms.push("local://pub-pub-video-call".to_string()); + rooms.push("local://video-call-1/caller".to_string()); + rooms.push("local://pub-pub-video-call/caller".to_string()); delete_request.set_id(rooms); let reply = client.delete(&delete_request).expect("delete room"); diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index 4ed558877..9a5384909 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -49,6 +49,14 @@ pub enum RoomServiceError { EmptyUrisList, #[fail(display = "Room not found for element [id = {}]", _0)] RoomNotFoundForElement(LocalUriType), + #[fail( + display = "Provided not the same Room IDs in elements IDs [ids = \ + {:?}].", + _0 + )] + NotSameRoomIds(Vec, RoomId), + #[fail(display = "Provided Room IDs with Room elements IDs.")] + DeleteRoomAndFromRoom, } impl From for RoomServiceError { @@ -237,6 +245,12 @@ impl Handler for RoomService { }) .collect(); + if !room_messages_futs.is_empty() && !deletes_from_room.is_empty() { + return Box::new(actix::fut::err( + RoomServiceError::DeleteRoomAndFromRoom, + )); + } + if !room_messages_futs.is_empty() { Box::new(wrap_future( futures::future::join_all(room_messages_futs) @@ -264,10 +278,9 @@ impl Handler for RoomService { .collect(); if !ignored_ids.is_empty() { - warn!( - "Some ids from Get request was ignored: {:?}", - ignored_ids - ); + return Box::new(actix::fut::err( + RoomServiceError::NotSameRoomIds(ignored_ids, room_id), + )); } if let Some(room) = self.room_repo.get(&room_id) { From b4eec93f94a9958dfb562be7369d67f0837f0458 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 9 Sep 2019 15:49:23 +0300 Subject: [PATCH 596/735] Fix gRPC error --- src/api/control/grpc/server.rs | 36 +++++++++++++--------------------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index 296c988d2..9cc69d75d 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -286,7 +286,6 @@ fn get_response_for_create( } impl ControlApi for ControlApiService { - // TODO: just send Vec, see fn delete() /// Implementation for `Create` method of gRPC control API. fn create( &mut self, @@ -417,31 +416,24 @@ impl ControlApi for ControlApiService { ctx.spawn( self.room_service .send(delete_elements) - .then(move |result| { - match result { - Ok(result) => match result { - Ok(_) => sink.success(Response::new()), - Err(e) => { - let mut response = Response::new(); - response - .set_error(ErrorResponse::from(e).into()); - sink.success(response) - } - }, + .then(move |result| match result { + Ok(result) => match result { + Ok(_) => sink.success(Response::new()), Err(e) => { let mut response = Response::new(); - - // TODO: dont use unknown, add some special err for - // all mailbox - // errs, Unavailable("ActorName") or - // something - let error: Error = - ErrorResponse::unknown(&format!("{:?}", e)) - .into(); - response.set_error(error); - + response.set_error(ErrorResponse::from(e).into()); sink.success(response) } + }, + Err(e) => { + let mut response = Response::new(); + response.set_error( + ErrorResponse::from( + ControlApiError::RoomServiceMailboxError(e), + ) + .into(), + ); + sink.success(response) } }) .map_err(|e| { From 5691e1410a6477665a6fe605978ef8862006df36 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 9 Sep 2019 17:44:56 +0300 Subject: [PATCH 597/735] Refactor --- _dev/config.toml | 2 +- src/api/client/server.rs | 2 +- src/api/control/grpc/server.rs | 11 ++--- src/api/control/local_uri.rs | 21 +++++----- src/api/control/mod.rs | 9 +--- src/conf/control.rs | 5 ++- src/conf/http_server.rs | 28 +++++-------- src/conf/mod.rs | 10 ++--- src/conf/server.rs | 16 -------- src/main.rs | 75 ++++++++++++++++++---------------- 10 files changed, 79 insertions(+), 100 deletions(-) delete mode 100644 src/conf/server.rs diff --git a/_dev/config.toml b/_dev/config.toml index f3a3bc147..b1ecba523 100644 --- a/_dev/config.toml +++ b/_dev/config.toml @@ -1,2 +1,2 @@ [control] -static_specs_dir = "_dev/spec" \ No newline at end of file +static_specs_dir = "_dev/specs" \ No newline at end of file diff --git a/src/api/client/server.rs b/src/api/client/server.rs index 1a991e5ba..caa078e44 100644 --- a/src/api/client/server.rs +++ b/src/api/client/server.rs @@ -98,7 +98,7 @@ pub struct Server(ActixServer); impl Server { /// Starts Client API HTTP server. pub fn run(rooms: RoomRepository, config: Conf) -> io::Result> { - let server_addr = config.server.http.bind_addr(); + let server_addr = config.client.bind_addr(); let server = HttpServer::new(move || { App::new() diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index 9cc69d75d..fd6f7375d 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -171,10 +171,7 @@ impl ControlApiService { ) -> String { format!( "{}/{}/{}/{}", - self.app.config.server.http.public_url, - room_id, - member_id, - credentials + self.app.config.client.public_url, room_id, member_id, credentials ) } @@ -528,9 +525,9 @@ impl Handler for GrpcServer { /// Run gRPC server in actix actor. pub fn run(room_repo: Addr, app: AppContext) -> Addr { - let bind_ip = app.config.server.grpc.bind_ip.to_string(); - let bind_port = app.config.server.grpc.bind_port; - let cq_count = app.config.server.grpc.completion_queue_count; + let bind_ip = app.config.control.grpc.bind_ip.to_string(); + let bind_port = app.config.control.grpc.bind_port; + let cq_count = app.config.control.grpc.completion_queue_count; let service = create_control_api(ControlApiService { app, diff --git a/src/api/control/local_uri.rs b/src/api/control/local_uri.rs index c859f6331..62426b76e 100644 --- a/src/api/control/local_uri.rs +++ b/src/api/control/local_uri.rs @@ -353,7 +353,7 @@ mod tests { #[test] fn parse_local_uri_to_room_element() { - let local_uri = LocalUriType::parse("local://room_id").unwrap(); + let local_uri = LocalUriType::try_from("local://room_id").unwrap(); if let LocalUriType::Room(room) = local_uri { assert_eq!(room.take_room_id(), RoomId("room_id".to_string())); } else { @@ -364,7 +364,7 @@ mod tests { #[test] fn parse_local_uri_to_element_of_room() { let local_uri = - LocalUriType::parse("local://room_id/room_element_id").unwrap(); + LocalUriType::try_from("local://room_id/room_element_id").unwrap(); if let LocalUriType::Member(member) = local_uri { let (element_id, room_uri) = member.take_member_id(); assert_eq!(element_id, MemberId("room_element_id".to_string())); @@ -377,9 +377,10 @@ mod tests { #[test] fn parse_local_uri_to_endpoint() { - let local_uri = - LocalUriType::parse("local://room_id/room_element_id/endpoint_id") - .unwrap(); + let local_uri = LocalUriType::try_from( + "local://room_id/room_element_id/endpoint_id", + ) + .unwrap(); if let LocalUriType::Endpoint(endpoint) = local_uri { let (endpoint_id, member_uri) = endpoint.take_endpoint_id(); assert_eq!(endpoint_id, "endpoint_id".to_string()); @@ -394,7 +395,7 @@ mod tests { #[test] fn returns_parse_error_if_local_uri_not_local() { - match LocalUriType::parse("not-local://room_id") { + match LocalUriType::try_from("not-local://room_id") { Ok(_) => unreachable!(), Err(e) => match e { LocalUriParseError::NotLocal(_) => (), @@ -405,7 +406,7 @@ mod tests { #[test] fn returns_parse_error_if_local_uri_empty() { - match LocalUriType::parse("") { + match LocalUriType::try_from("") { Ok(_) => unreachable!(), Err(e) => match e { LocalUriParseError::Empty => (), @@ -416,7 +417,7 @@ mod tests { #[test] fn returns_error_if_local_uri_have_too_many_paths() { - match LocalUriType::parse("local://room/member/endpoint/too_many") { + match LocalUriType::try_from("local://room/member/endpoint/too_many") { Ok(_) => unreachable!(), Err(e) => match e { LocalUriParseError::TooManyFields(_) => (), @@ -432,7 +433,7 @@ mod tests { "local://room_id/member_id", "local://room_id/member_id/endpoint_id", ] { - let local_uri = LocalUriType::parse(&local_uri_str).unwrap(); + let local_uri = LocalUriType::try_from(local_uri_str).unwrap(); assert_eq!(local_uri_str.to_string(), local_uri.to_string()); } } @@ -444,7 +445,7 @@ mod tests { "local:////endpoint_id", "local:///member_id/endpoint_id", ] { - match LocalUriType::parse(local_uri_str) { + match LocalUriType::try_from(local_uri_str) { Ok(_) => unreachable!(local_uri_str), Err(e) => match e { LocalUriParseError::MissingFields(_) => (), diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index 078416709..0073ef67a 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -9,15 +9,10 @@ pub mod member; pub mod pipeline; pub mod room; -use std::{ - convert::TryFrom as _, - fs::{File, ReadDir}, - io::Read as _, - path::Path, -}; +use std::{convert::TryFrom as _, fs::File, io::Read as _, path::Path}; use derive_more::{Display, From}; -use failure::{Error, Fail}; +use failure::Fail; use serde::Deserialize; use self::{ diff --git a/src/conf/control.rs b/src/conf/control.rs index ae7f049d4..08eafa0e4 100644 --- a/src/conf/control.rs +++ b/src/conf/control.rs @@ -1,10 +1,11 @@ +use crate::conf::Grpc; use serde::{Deserialize, Serialize}; use smart_default::SmartDefault; /// [Control API] settings. /// /// [Control API]: http://tiny.cc/380uaz -#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, SmartDefault)] +#[derive(Clone, Debug, Deserialize, Serialize, SmartDefault)] #[serde(default)] pub struct Control { /// Path to directory with static [Сontrol API] specs. @@ -12,4 +13,6 @@ pub struct Control { /// [Control API]: http://tiny.cc/380uaz #[default(String::from("specs/"))] pub static_specs_dir: String, + + pub grpc: Grpc, } diff --git a/src/conf/http_server.rs b/src/conf/http_server.rs index 4cea00fd6..67eff61c5 100644 --- a/src/conf/http_server.rs +++ b/src/conf/http_server.rs @@ -8,7 +8,7 @@ use smart_default::SmartDefault; /// HTTP server settings. #[derive(Clone, Debug, Deserialize, Serialize, SmartDefault)] #[serde(default)] -pub struct HttpServer { +pub struct Client { /// Public URI of server. Address for exposed [Client API]. /// /// This address will be returned from [Control API] in `sids` and to @@ -33,7 +33,7 @@ pub struct HttpServer { pub static_specs_path: Option, } -impl HttpServer { +impl Client { /// Builds [`SocketAddr`] from `bind_ip` and `bind_port`. #[inline] pub fn bind_addr(&self) -> SocketAddr { @@ -60,27 +60,21 @@ mod server_spec { fn overrides_defaults_and_gets_bind_addr() { let default_conf = Conf::default(); - env::set_var("MEDEA_SERVER.HTTP.BIND_IP", "5.5.5.5"); - env::set_var("MEDEA_SERVER.HTTP.BIND_PORT", "1234"); + env::set_var("MEDEA_CLIENT.BIND_IP", "5.5.5.5"); + env::set_var("MEDEA_CLIENT.BIND_PORT", "1234"); let env_conf = Conf::parse().unwrap(); - env::remove_var("MEDEA_SERVER.HTTP.BIND_IP"); - env::remove_var("MEDEA_SERVER.HTTP.BIND_PORT"); + env::remove_var("MEDEA_CLIENT.BIND_IP"); + env::remove_var("MEDEA_CLIENT.BIND_PORT"); - assert_ne!( - default_conf.server.http.bind_ip, - env_conf.server.http.bind_ip - ); - assert_ne!( - default_conf.server.http.bind_port, - env_conf.server.http.bind_port - ); + assert_ne!(default_conf.client.bind_ip, env_conf.client.bind_ip); + assert_ne!(default_conf.client.bind_port, env_conf.client.bind_port); - assert_eq!(env_conf.server.http.bind_ip, Ipv4Addr::new(5, 5, 5, 5)); - assert_eq!(env_conf.server.http.bind_port, 1234); + assert_eq!(env_conf.client.bind_ip, Ipv4Addr::new(5, 5, 5, 5)); + assert_eq!(env_conf.client.bind_port, 1234); assert_eq!( - env_conf.server.http.bind_addr(), + env_conf.client.bind_addr(), "5.5.5.5:1234".parse().unwrap(), ); } diff --git a/src/conf/mod.rs b/src/conf/mod.rs index a27c8b631..582c40c35 100644 --- a/src/conf/mod.rs +++ b/src/conf/mod.rs @@ -5,7 +5,6 @@ pub mod grpc; pub mod http_server; pub mod log; pub mod rpc; -pub mod server; pub mod shutdown; pub mod turn; @@ -19,10 +18,9 @@ use serde::{Deserialize, Serialize}; pub use self::{ control::Control, grpc::Grpc, - http_server::HttpServer, + http_server::Client, log::Log, rpc::Rpc, - server::Server, shutdown::Shutdown, turn::{Redis, Turn}, }; @@ -41,8 +39,10 @@ pub struct Conf { /// HTTP server settings. pub rpc: Rpc, - /// RPC connection settings. - pub server: Server, + /// [Client API] connection settings. + /// + /// [Client API]: http://tiny.cc/c80uaz + pub client: Client, /// TURN server settings. pub turn: Turn, diff --git a/src/conf/server.rs b/src/conf/server.rs deleted file mode 100644 index 776830059..000000000 --- a/src/conf/server.rs +++ /dev/null @@ -1,16 +0,0 @@ -//! Servers related settings. - -use serde::{Deserialize, Serialize}; - -use super::{grpc::Grpc, http_server::HttpServer}; - -/// Servers related settings. -#[derive(Clone, Debug, Deserialize, Serialize, Default)] -#[serde(default)] -pub struct Server { - /// RPC connection settings. - pub http: HttpServer, - - /// gRPC server settings. - pub grpc: Grpc, -} diff --git a/src/main.rs b/src/main.rs index aa4fce030..da3fce371 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; -use actix::Actor; +use actix::{Actor, Addr}; use failure::Error; use futures::future::Future; use medea::{ @@ -19,6 +19,30 @@ use medea::{ AppContext, }; +fn start_static_rooms( + room_service: &Addr, +) -> impl Future { + room_service + .send(StartStaticRooms) + .map_err(|e| error!("StartStaticRooms mailbox error: {:?}", e)) + .map(|result| { + if let Err(e) = result { + match e { + RoomServiceError::FailedToLoadStaticSpecs(e) => match e { + LoadStaticControlSpecsError::SpecDirNotFound => { + warn!( + "Specs dir not exists. Control API specs not \ + loaded." + ); + } + _ => panic!("{}", e), + }, + _ => panic!("{}", e), + } + } + }) +} + fn main() -> Result<(), Error> { dotenv::dotenv().ok(); let logger = log::new_dual_logger(std::io::stdout(), std::io::stderr()); @@ -47,41 +71,22 @@ fn main() -> Result<(), Error> { ) .start(); - room_service - .clone() - .send(StartStaticRooms) - .map_err(|e| { - error!("StartStaticRooms mailbox error: {:?}", e) - }) - .map(|result| { - if let Err(e) = result { - match e { - RoomServiceError::FailedToLoadStaticSpecs(e) => match e { - LoadStaticControlSpecsError::SpecDirNotFound => { - warn!("Specs dir not exists. Control API specs not loaded."); - } - _ => panic!("{}", e) - } - _ => panic!("{}", e) - } - } - }) - .map(move |_| { - let grpc_addr = - grpc::server::run(room_service, app_context); - shutdown::subscribe( - &graceful_shutdown, - grpc_addr.clone().recipient(), - shutdown::Priority(1), - ); + start_static_rooms(&room_service).map(move |_| { + let grpc_addr = + grpc::server::run(room_service, app_context); + shutdown::subscribe( + &graceful_shutdown, + grpc_addr.clone().recipient(), + shutdown::Priority(1), + ); - let server = Server::run(room_repo, config).unwrap(); - shutdown::subscribe( - &graceful_shutdown, - server.recipient(), - shutdown::Priority(1), - ); - }) + let server = Server::run(room_repo, config).unwrap(); + shutdown::subscribe( + &graceful_shutdown, + server.recipient(), + shutdown::Priority(1), + ); + }) }) }) .unwrap(); From e8972f8ce385e22db95833d43a04b37f1cde4b59 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 9 Sep 2019 17:59:34 +0300 Subject: [PATCH 598/735] Refactor to #[display] from #[fail] [run ci] --- _ci/protoc_install.sh | 2 ++ .../control/endpoints/webrtc_play_endpoint.rs | 6 ++--- src/api/control/grpc/server.rs | 13 +++++----- src/api/control/local_uri.rs | 13 +++++----- src/api/control/mod.rs | 14 +++++------ src/signalling/elements/member.rs | 8 +++---- src/signalling/room_service.rs | 24 +++++++++---------- 7 files changed, 42 insertions(+), 38 deletions(-) diff --git a/_ci/protoc_install.sh b/_ci/protoc_install.sh index 3765255b4..ae0e35ffc 100644 --- a/_ci/protoc_install.sh +++ b/_ci/protoc_install.sh @@ -1,3 +1,5 @@ +#!/usr/bin/env bash + if [[ ! $DONT_INSTALL_PROTOC ]] ; then echo "Installing protoc" PROTOBUF_VERSION=3.3.0 diff --git a/src/api/control/endpoints/webrtc_play_endpoint.rs b/src/api/control/endpoints/webrtc_play_endpoint.rs index 57478049a..d9e2b019d 100644 --- a/src/api/control/endpoints/webrtc_play_endpoint.rs +++ b/src/api/control/endpoints/webrtc_play_endpoint.rs @@ -38,11 +38,11 @@ impl TryFrom<&WebRtcPlayEndpointProto> for WebRtcPlayEndpoint { } } -#[derive(Debug, Fail)] +#[derive(Debug, Fail, Display)] pub enum SrcParseError { - #[fail(display = "Provided not src uri {}", _0)] + #[display(fmt = "Provided not src uri {}", _0)] NotSrcUri(String), - #[fail(display = "Local URI '{}' parse error: {:?}", _0, _1)] + #[display(fmt = "Local URI '{}' parse error: {:?}", _0, _1)] LocalUriParseError(String, LocalUriParseError), } diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index fd6f7375d..f66ee0202 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -8,6 +8,7 @@ use std::{collections::HashMap, convert::TryFrom, sync::Arc}; use actix::{ Actor, Addr, Arbiter, Context, Handler, MailboxError, ResponseFuture, }; +use derive_more::Display; use failure::Fail; use futures::future::{Either, Future}; use grpcio::{ @@ -51,24 +52,24 @@ use crate::{ signalling::room_service::Get, }; -#[derive(Debug, Fail)] +#[derive(Debug, Fail, Display)] pub enum ControlApiError { /// Error when parsing ID of element. - #[fail(display = "{:?}", _0)] + #[display(fmt = "{:?}", _0)] LocalUri(LocalUriParseError), /// This error is rather abnormal, since what it catches must be caught at /// the level of the gRPC. - #[fail(display = "{:?}", _0)] + #[display(fmt = "{:?}", _0)] TryFromProtobuf(TryFromProtobufError), /// This error is rather abnormal, since what it catches must be caught at /// the level of the gRPC. - #[fail(display = "{:?}", _0)] + #[display(fmt = "{:?}", _0)] TryFromElement(TryFromElementError), /// [`MailboxError`] for [`RoomService`]. - #[fail(display = "Room service mailbox error: {:?}", _0)] + #[display(fmt = "Room service mailbox error: {:?}", _0)] RoomServiceMailboxError(MailboxError), /// [`MailboxError`] which never can happen. This error needed @@ -77,7 +78,7 @@ pub enum ControlApiError { /// it cannot happen. /// /// __Never use this error.__ - #[fail(display = "Mailbox error which never can happen.")] + #[display(fmt = "Mailbox error which never can happen.")] UnknownMailboxErr(MailboxError), } diff --git a/src/api/control/local_uri.rs b/src/api/control/local_uri.rs index 62426b76e..179a64e82 100644 --- a/src/api/control/local_uri.rs +++ b/src/api/control/local_uri.rs @@ -5,6 +5,7 @@ use std::{convert::TryFrom, fmt}; +use derive_more::Display; use failure::Fail; use url::Url; @@ -13,24 +14,24 @@ use crate::api::control::endpoints::webrtc_play_endpoint::SrcUri; use super::{MemberId, RoomId}; #[allow(clippy::module_name_repetitions)] -#[derive(Debug, Fail)] +#[derive(Debug, Fail, Display)] pub enum LocalUriParseError { /// Protocol of provided URI is not "local://". - #[fail(display = "Provided URIs protocol is not 'local://'.")] + #[display(fmt = "Provided URIs protocol is not 'local://'.")] NotLocal(String), /// Too many paths in provided URI. - #[fail(display = "Too many paths in provided URI ({}).", _0)] + #[display(fmt = "Too many paths in provided URI ({}).", _0)] TooManyFields(String), - #[fail(display = "Missing fields. {}", _0)] + #[display(fmt = "Missing fields. {}", _0)] MissingFields(String), - #[fail(display = "Error while parsing URL. {:?}", _0)] + #[display(fmt = "Error while parsing URL. {:?}", _0)] UrlParseErr(String, url::ParseError), /// Provided empty `&str`. - #[fail(display = "You provided empty local uri.")] + #[display(fmt = "You provided empty local uri.")] Empty, } diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index 0073ef67a..8101d4dbc 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -30,30 +30,30 @@ pub use self::{ }; /// Errors which may occur while deserialize protobuf spec. -#[derive(Debug, Fail)] +#[derive(Debug, Fail, Display)] pub enum TryFromProtobufError { /// Error while parsing src uri of [`WebRtcPlayEndpoint`]. - #[fail(display = "Src uri parse error: {:?}", _0)] + #[display(fmt = "Src uri parse error: {:?}", _0)] SrcUriError(SrcParseError), /// Src URI not provided for [`WebRtcPlayEndpoint`]. - #[fail(display = "Src uri for publish endpoint not provided.")] + #[display(fmt = "Src uri for publish endpoint not provided.")] SrcUriNotFound, /// Room element not provided. - #[fail(display = "Room element not provided.")] + #[display(fmt = "Room element not provided.")] RoomElementNotFound, /// Member element not provided. - #[fail(display = "Member element not provided.")] + #[display(fmt = "Member element not provided.")] MemberElementNotFound, /// [`P2pMode`] not found. - #[fail(display = "P2p mode for play endpoint not provided.")] + #[display(fmt = "P2p mode for play endpoint not provided.")] P2pModeNotFound, /// Member credentials not found. - #[fail(display = "Credentials for member not provided.")] + #[display(fmt = "Credentials for member not provided.")] MemberCredentialsNotFound, } diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index 0e890d611..8b1d909bc 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -62,15 +62,15 @@ pub enum MembersLoadError { } #[allow(clippy::module_name_repetitions, clippy::pub_enum_variant_names)] -#[derive(Debug, Fail)] +#[derive(Debug, Fail, Display)] pub enum MemberError { - #[fail(display = "Publish endpoint [id = {}] not found.", _0)] + #[display(fmt = "Publish endpoint [id = {}] not found.", _0)] PublishEndpointNotFound(LocalUri), - #[fail(display = "Play endpoint [id = {}] not found.", _0)] + #[display(fmt = "Play endpoint [id = {}] not found.", _0)] PlayEndpointNotFound(LocalUri), - #[fail(display = "Endpoint [id = {}] not found.", _0)] + #[display(fmt = "Endpoint [id = {}] not found.", _0)] EndpointNotFound(LocalUri), } diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index 39adae0df..4e9325984 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -4,6 +4,7 @@ use actix::{ fut::wrap_future, Actor, ActorFuture, Addr, Context, Handler, MailboxError, Message, }; +use derive_more::Display; use failure::Fail; use futures::future::{self, Either, Future}; use medea_grpc_proto::control::Element as ElementProto; @@ -33,29 +34,28 @@ type ActFuture = Box>; #[allow(clippy::module_name_repetitions)] -#[derive(Debug, Fail)] +#[derive(Debug, Fail, Display)] pub enum RoomServiceError { - #[fail(display = "Room [id = {}] not found.", _0)] + #[display(fmt = "Room [id = {}] not found.", _0)] RoomNotFound(LocalUri), - #[fail(display = "Room mailbox error: {:?}", _0)] + #[display(fmt = "Room mailbox error: {:?}", _0)] RoomMailboxErr(MailboxError), - #[fail(display = "Room [id = {}] already exists.", _0)] + #[display(fmt = "Room [id = {}] already exists.", _0)] RoomAlreadyExists(LocalUri), - #[fail(display = "{}", _0)] + #[display(fmt = "{}", _0)] RoomError(RoomError), - #[fail(display = "Failed to load static specs. {:?}", _0)] + #[display(fmt = "Failed to load static specs. {:?}", _0)] FailedToLoadStaticSpecs(LoadStaticControlSpecsError), - #[fail(display = "Empty URIs list.")] + #[display(fmt = "Empty URIs list.")] EmptyUrisList, - #[fail(display = "Room not found for element [id = {}]", _0)] + #[display(fmt = "Room not found for element [id = {}]", _0)] RoomNotFoundForElement(LocalUriType), - #[fail( - display = "Provided not the same Room IDs in elements IDs [ids = \ - {:?}].", + #[display( + fmt = "Provided not the same Room IDs in elements IDs [ids = {:?}].", _0 )] NotSameRoomIds(Vec, RoomId), - #[fail(display = "Provided Room IDs with Room elements IDs.")] + #[display(fmt = "Provided Room IDs with Room elements IDs.")] DeleteRoomAndFromRoom, } From 06fe0bcf8a896a3b3308ba03e4fda70b5ba461e9 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 9 Sep 2019 20:31:02 +0300 Subject: [PATCH 599/735] Add config tests --- src/api/control/grpc/server.rs | 17 ++++- src/bin/client.rs | 3 +- src/conf/{http_server.rs => client.rs} | 0 src/conf/control.rs | 24 +++++++ src/conf/grpc.rs | 36 ++++++++++ src/conf/log.rs | 21 ++++++ src/conf/mod.rs | 4 +- src/conf/rpc.rs | 27 +++++++ src/conf/shutdown.rs | 21 ++++++ src/conf/turn.rs | 57 +++++++++++++++ src/signalling/room_service.rs | 99 ++++++++++++++++---------- 11 files changed, 267 insertions(+), 42 deletions(-) rename src/conf/{http_server.rs => client.rs} (100%) diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index f66ee0202..06ac9b228 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -403,13 +403,24 @@ impl ControlApi for ControlApiService { req: IdRequest, sink: UnarySink, ) { - let mut uris = Vec::new(); + let mut delete_elements = DeleteElements::new(); for id in req.get_id() { let uri: LocalUriType = parse_local_uri!(id, ctx, sink, Response); - uris.push(uri); + delete_elements.add_uri(uri); } - let delete_elements = DeleteElements { uris }; + + let delete_elements = match delete_elements.validate() { + Ok(d) => d, + Err(e) => { + send_error_response!( + ctx, + sink, + ErrorResponse::from(e), + Response + ); + } + }; ctx.spawn( self.room_service diff --git a/src/bin/client.rs b/src/bin/client.rs index 117a73c60..03c3a62ef 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -19,7 +19,7 @@ fn main() { let client = ControlApiClient::new(ch); // unimplemented_apply(&client); - create_room(&client); + // create_room(&client); delete_room(&client); // delete_endpoint(&client); // delete_member(&client); @@ -113,6 +113,7 @@ fn delete_room(client: &ControlApiClient) { let mut delete_request = IdRequest::new(); let mut rooms = RepeatedField::new(); rooms.push("local://video-call-1/caller".to_string()); + rooms.push("local://video-call-1".to_string()); rooms.push("local://pub-pub-video-call/caller".to_string()); delete_request.set_id(rooms); diff --git a/src/conf/http_server.rs b/src/conf/client.rs similarity index 100% rename from src/conf/http_server.rs rename to src/conf/client.rs diff --git a/src/conf/control.rs b/src/conf/control.rs index 08eafa0e4..06cdbe688 100644 --- a/src/conf/control.rs +++ b/src/conf/control.rs @@ -16,3 +16,27 @@ pub struct Control { pub grpc: Grpc, } + +#[cfg(test)] +mod control_conf_specs { + use std::env; + + use serial_test_derive::serial; + + use crate::conf::Conf; + + #[test] + #[serial] + fn overrides_defaults() { + let default_conf = Conf::default(); + + env::set_var("MEDEA_CONTROL.STATIC_SPECS_DIR", "test/"); + let env_conf = Conf::parse().unwrap(); + env::remove_var("MEDEA_CONTROL.STATIC_SPECS_DIR"); + + assert_ne!( + default_conf.control.static_specs_dir, + env_conf.control.static_specs_dir + ); + } +} diff --git a/src/conf/grpc.rs b/src/conf/grpc.rs index 5cce340be..b02154bd3 100644 --- a/src/conf/grpc.rs +++ b/src/conf/grpc.rs @@ -21,3 +21,39 @@ pub struct Grpc { #[default(2)] pub completion_queue_count: usize, } + +#[cfg(test)] +mod control_grpc_conf_specs { + use std::env; + + use serial_test_derive::serial; + + use crate::conf::Conf; + + #[test] + #[serial] + fn overrides_defaults() { + let default_conf = Conf::default(); + + env::set_var("MEDEA_CONTROL.GRPC.BIND_IP", "127.0.0.1"); + env::set_var("MEDEA_CONTROL.GRPC.BIND_PORT", "44444"); + env::set_var("MEDEA_CONTROL.GRPC.COMPLETION_QUEUE_COUNT", "10"); + let env_conf = Conf::parse().unwrap(); + env::remove_var("MEDEA_CONTROL.GRPC.BIND_IP"); + env::remove_var("MEDEA_CONTROL.GRPC.BIND_PORT"); + env::remove_var("MEDEA_CONTROL.GRPC.COMPLETION_QUEUE_COUNT"); + + assert_ne!( + default_conf.control.grpc.bind_ip, + env_conf.control.grpc.bind_ip + ); + assert_ne!( + default_conf.control.grpc.bind_port, + env_conf.control.grpc.bind_port + ); + assert_ne!( + default_conf.control.grpc.completion_queue_count, + env_conf.control.grpc.completion_queue_count + ); + } +} diff --git a/src/conf/log.rs b/src/conf/log.rs index 086603d08..2600d2840 100644 --- a/src/conf/log.rs +++ b/src/conf/log.rs @@ -21,3 +21,24 @@ impl Log { slog::Level::from_str(&self.level).ok() } } + +#[cfg(test)] +mod log_conf_specs { + use std::env; + + use serial_test_derive::serial; + + use crate::conf::Conf; + + #[test] + #[serial] + fn overrides_defaults() { + let default_conf = Conf::default(); + + env::set_var("MEDEA_LOG.LEVEL", "DEBUG"); + let env_conf = Conf::parse().unwrap(); + env::remove_var("MEDEA_LOG.LEVEL"); + + assert_ne!(default_conf.log.level, env_conf.log.level); + } +} diff --git a/src/conf/mod.rs b/src/conf/mod.rs index 582c40c35..8acf4c4a2 100644 --- a/src/conf/mod.rs +++ b/src/conf/mod.rs @@ -1,8 +1,8 @@ //! Provides application configuration options. +pub mod client; pub mod control; pub mod grpc; -pub mod http_server; pub mod log; pub mod rpc; pub mod shutdown; @@ -16,9 +16,9 @@ use serde::{Deserialize, Serialize}; #[doc(inline)] pub use self::{ + client::Client, control::Control, grpc::Grpc, - http_server::Client, log::Log, rpc::Rpc, shutdown::Shutdown, diff --git a/src/conf/rpc.rs b/src/conf/rpc.rs index dbd3bb565..4744dde1b 100644 --- a/src/conf/rpc.rs +++ b/src/conf/rpc.rs @@ -21,3 +21,30 @@ pub struct Rpc { #[serde(with = "humantime_serde")] pub reconnect_timeout: Duration, } + +#[cfg(test)] +mod log_conf_specs { + use std::env; + + use serial_test_derive::serial; + + use crate::conf::Conf; + + #[test] + #[serial] + fn overrides_defaults() { + let default_conf = Conf::default(); + + env::set_var("MEDEA_RPC.IDLE_TIMEOUT", "20s"); + env::set_var("MEDEA_RPC.RECONNECT_TIMEOUT", "30s"); + let env_conf = Conf::parse().unwrap(); + env::remove_var("MEDEA_RPC.IDLE_TIMEOUT"); + env::remove_var("MEDEA_RPC.RECONNECT_TIMEOUT"); + + assert_ne!(default_conf.rpc.idle_timeout, env_conf.rpc.idle_timeout); + assert_ne!( + default_conf.rpc.reconnect_timeout, + env_conf.rpc.reconnect_timeout + ); + } +} diff --git a/src/conf/shutdown.rs b/src/conf/shutdown.rs index b0e824d7e..f43e814a6 100644 --- a/src/conf/shutdown.rs +++ b/src/conf/shutdown.rs @@ -14,3 +14,24 @@ pub struct Shutdown { #[serde(with = "humantime_serde")] pub timeout: Duration, } + +#[cfg(test)] +mod shutdown_conf_specs { + use std::env; + + use serial_test_derive::serial; + + use crate::conf::Conf; + + #[test] + #[serial] + fn overrides_defaults() { + let default_conf = Conf::default(); + + env::set_var("MEDEA_SHUTDOWN.TIMEOUT", "20s"); + let env_conf = Conf::parse().unwrap(); + env::remove_var("MEDEA_SHUTDOWN.TIMEOUT"); + + assert_ne!(default_conf.shutdown.timeout, env_conf.shutdown.timeout); + } +} diff --git a/src/conf/turn.rs b/src/conf/turn.rs index 762f90819..45481915d 100644 --- a/src/conf/turn.rs +++ b/src/conf/turn.rs @@ -68,3 +68,60 @@ pub struct Redis { #[serde(with = "humantime_serde")] pub connection_timeout: Duration, } + +#[cfg(test)] +mod turn_conf_specs { + use std::env; + + use serial_test_derive::serial; + + use crate::conf::Conf; + + #[test] + #[serial] + fn overrides_defaults() { + let default_conf = Conf::default(); + + env::set_var("MEDEA_TURN.DB.REDIS.IP", "0.0.0.0"); + env::set_var("MEDEA_TURN.DB.REDIS.PORT", "4444"); + env::set_var("MEDEA_TURN.DB.REDIS.PASS", "hellofellow"); + env::set_var("MEDEA_TURN.DB.REDIS.DB_NUMBER", "10"); + env::set_var("MEDEA_TURN.DB.REDIS.CONNECTION_TIMEOUT", "10s"); + env::set_var("MEDEA_TURN.HOST", "example.com"); + env::set_var("MEDEA_TURN.PORT", "4444"); + env::set_var("MEDEA_TURN.USER", "ferris"); + env::set_var("MEDEA_TURN.PASS", "qwerty"); + let env_conf = Conf::parse().unwrap(); + env::remove_var("MEDEA_TURN.DB.REDIS.IP"); + env::remove_var("MEDEA_TURN.DB.REDIS.PORT"); + env::remove_var("MEDEA_TURN.DB.REDIS.PASS"); + env::remove_var("MEDEA_TURN.DB.REDIS.DB_NUMBER"); + env::remove_var("MEDEA_TURN.DB.REDIS.CONNECTION_TIMEOUT"); + env::remove_var("MEDEA_TURN.HOST"); + env::remove_var("MEDEA_TURN.PORT"); + env::remove_var("MEDEA_TURN.USER"); + env::remove_var("MEDEA_TURN.PASS"); + + assert_ne!(default_conf.turn.db.redis.ip, env_conf.turn.db.redis.ip); + assert_ne!( + default_conf.turn.db.redis.port, + env_conf.turn.db.redis.port + ); + assert_ne!( + default_conf.turn.db.redis.pass, + env_conf.turn.db.redis.pass + ); + assert_ne!( + default_conf.turn.db.redis.db_number, + env_conf.turn.db.redis.db_number + ); + assert_ne!( + default_conf.turn.db.redis.connection_timeout, + env_conf.turn.db.redis.connection_timeout + ); + assert_ne!(default_conf.turn.host, env_conf.turn.host); + assert_ne!(default_conf.turn.port, env_conf.turn.port); + assert_ne!(default_conf.turn.user, env_conf.turn.user); + assert_ne!(default_conf.turn.pass, env_conf.turn.pass); + } +} diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index 4e9325984..047b2e1c6 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -1,5 +1,7 @@ //! Service which control [`Room`]. +use std::collections::HashMap; + use actix::{ fut::wrap_future, Actor, ActorFuture, Addr, Context, Handler, MailboxError, Message, @@ -28,7 +30,7 @@ use crate::{ }, AppContext, }; -use std::collections::HashMap; +use failure::_core::marker::PhantomData; type ActFuture = Box>; @@ -205,22 +207,74 @@ impl Handler for RoomService { } } +pub struct Validated; +pub struct Unvalidated; + +impl DeleteElements { + pub fn new() -> DeleteElements { + Self { + uris: Vec::new(), + _state: PhantomData, + } + } + + pub fn add_uri(&mut self, uri: LocalUriType) { + self.uris.push(uri) + } + + pub fn validate( + self, + ) -> Result, RoomServiceError> { + if self.uris.is_empty() { + return Err(RoomServiceError::EmptyUrisList); + } + + let mut ignored_uris = Vec::new(); + + let first_room = self.uris[0].room_id().clone(); + let uris: Vec = self + .uris + .into_iter() + .filter_map(|uri| { + if uri.room_id() == &first_room { + Some(uri) + } else { + ignored_uris.push(uri); + None + } + }) + .collect(); + + if ignored_uris.len() > 0 { + return Err(RoomServiceError::NotSameRoomIds( + ignored_uris, + first_room, + )); + } + + Ok(DeleteElements { + uris, + _state: PhantomData, + }) + } +} + /// Signal for delete [`Room`]. -// TODO: maybe use state machine? #[derive(Message)] #[rtype(result = "Result<(), RoomServiceError>")] -pub struct DeleteElements { - pub uris: Vec, +pub struct DeleteElements { + uris: Vec, + _state: PhantomData, } -impl Handler for RoomService { +impl Handler> for RoomService { type Result = ActFuture<(), RoomServiceError>; // TODO: delete this allow when drain_filter TODO will be resolved. #[allow(clippy::unnecessary_filter_map)] fn handle( &mut self, - msg: DeleteElements, + msg: DeleteElements, _: &mut Self::Context, ) -> Self::Result { if msg.uris.is_empty() { @@ -243,44 +297,15 @@ impl Handler for RoomService { }) .collect(); - if !room_messages_futs.is_empty() && !deletes_from_room.is_empty() { - return Box::new(actix::fut::err( - RoomServiceError::DeleteRoomAndFromRoom, - )); - } - if !room_messages_futs.is_empty() { Box::new(wrap_future( futures::future::join_all(room_messages_futs) .map(|_| ()) .map_err(RoomServiceError::RoomMailboxErr), )) - } else if deletes_from_room.is_empty() { - Box::new(actix::fut::ok(())) - } else { + } else if !deletes_from_room.is_empty() { let room_id = deletes_from_room[0].room_id().clone(); - // TODO: rewrite using drain_filter when this will be in stable - // http://tiny.cc/2osfcz (Vec::drain_filter docs) - let mut ignored_ids = Vec::new(); - let deletes_from_room: Vec = deletes_from_room - .into_iter() - .filter_map(|uri| { - if uri.room_id() == &room_id { - Some(uri) - } else { - ignored_ids.push(uri); - None - } - }) - .collect(); - - if !ignored_ids.is_empty() { - return Box::new(actix::fut::err( - RoomServiceError::NotSameRoomIds(ignored_ids, room_id), - )); - } - if let Some(room) = self.room_repo.get(&room_id) { Box::new(wrap_future( room.send(Delete(deletes_from_room)) @@ -291,6 +316,8 @@ impl Handler for RoomService { get_local_uri_to_room(room_id), ))) } + } else { + Box::new(actix::fut::err(RoomServiceError::EmptyUrisList)) } } } From bb832cf32b553dca50100cfb858dece4a4ff12e8 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 10 Sep 2019 12:16:01 +0300 Subject: [PATCH 600/735] Use _ci/install_protoc.sh in Dockerfile --- .dockerignore | 2 ++ _ci/protoc_install.sh | 5 +++-- build/medea/Dockerfile | 3 ++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.dockerignore b/.dockerignore index 856595443..746486524 100644 --- a/.dockerignore +++ b/.dockerignore @@ -18,4 +18,6 @@ # Medea dependencies cache. !.cache/cargo/ +!_ci + # !target/{mode} is added and removed dynamically to reduce image build times. diff --git a/_ci/protoc_install.sh b/_ci/protoc_install.sh index ae0e35ffc..c7b82c7ed 100644 --- a/_ci/protoc_install.sh +++ b/_ci/protoc_install.sh @@ -4,9 +4,10 @@ if [[ ! $DONT_INSTALL_PROTOC ]] ; then echo "Installing protoc" PROTOBUF_VERSION=3.3.0 PROTOC_FILENAME=protoc-${PROTOBUF_VERSION}-linux-x86_64.zip - pushd /home/travis || exit + pushd "${HOME}" || exit wget https://github.com/google/protobuf/releases/download/v${PROTOBUF_VERSION}/${PROTOC_FILENAME} unzip ${PROTOC_FILENAME} - bin/protoc --version + cp bin/protoc /usr/bin + protoc --version popd || exit fi diff --git a/build/medea/Dockerfile b/build/medea/Dockerfile index 19e9444c8..5aeabd608 100644 --- a/build/medea/Dockerfile +++ b/build/medea/Dockerfile @@ -16,8 +16,9 @@ RUN mkdir -p /out/etc/ \ && echo 'nobody:x:65534:' > /out/etc/group RUN apt-get update -RUN apt-get install -y cmake protobuf-compiler golang +RUN apt-get install -y cmake golang ENV GOPATH /usr/lib/go COPY / /app/ +RUN bash /app/_ci/protoc_install.sh WORKDIR "/app" From d953be05b3af49e033eb6887602c1c92852947e6 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 10 Sep 2019 12:29:06 +0300 Subject: [PATCH 601/735] Add environment variables to example config, fix example config --- config.toml | 44 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/config.toml b/config.toml index affe41f6f..4d486098d 100644 --- a/config.toml +++ b/config.toml @@ -1,16 +1,22 @@ [server.http] -# Server host +# Server host. +# +# Environment variable: MEDEA_SERVER.HTTP.HOST # # Default: # host = "ws://0.0.0.0:8080" # IP address to bind HTTP server to. # +# Environment variable: MEDEA_SERVER.HTTP.BIND_IP +# # Default: # bind_ip = "0.0.0.0" # Port to bind HTTP server to. # +# Environment variable: MEDEA_SERVER.HTTP.BIND_PORT +# # Default: # bind_port = 8080 @@ -20,6 +26,8 @@ [control] # Path to directory with static Сontrol API specs. # +# Environment variable: MEDEA_CONTROL.STATIC_SPECS_DIR +# # Default: # static_specs_dir = "specs/" @@ -27,16 +35,22 @@ [server.grpc] # IP address to bind gRPC server to. # +# Environment variable: MEDEA_SERVER.GRPC.BIND_IP +# # Default: # bind_ip = "0.0.0.0" # Port to bind gRPC server to. # +# Environment variable: MEDEA_SERVER.GRPC.BIND_PORT +# # Default: # bind_port = 50051 # Completion queue count of gRPC server. # +# Environment variable: MEDEA_SERVER.GRPC.COMPLETION_QUEUE_COUNT +# # Default: # completion_queue_count = 2 @@ -47,12 +61,16 @@ # Duration, after which remote RPC client will be considered idle if no # heartbeat messages received. # +# Environment variable: MEDEA_RPC.IDLE_TIMEOUT +# # Default: # idle_timeout = "10s" # Duration, after which the server deletes the client session if # the remote RPC client does not reconnect after it is idle. # +# Environment variable: MEDEA_RPC.RECONNECT_TIMEOUT +# # Default: # reconnect_timeout = "10s" @@ -62,47 +80,65 @@ [turn] # Turn server host. # +# Environment variable: MEDEA_TURN.HOST +# # Default: # host = "localhost" # Turn server port. # +# Environment variable: MEDEA_TURN.PORT +# # Default: # port = 3478 # Static user on Turn server. # +# Environment variable: MEDEA_TURN.USER +# # Default: # user = "USER" # Static user password on Turn server. # +# Environment variable: MEDEA_TURN.PASS +# # Default: # pass = "PASS" [turn.db.redis] # Host of Coturn's Redis database. # +# Environment variable: MEDEA_TURN.DB.REDIS.IP +# # Default: -# host = "127.0.0.1" +# ip = "127.0.0.1" # Port of Coturn's Redis database for client connections. # +# Environment variable: MEDEA_TURN.DB.REDIS.PORT +# # Default: # port = 6379 # Password to connect to Coturn's Redis database with. # +# Environment variable: MEDEA_TURN.DB.REDIS.PASS +# # Default: # pass = "turn" # Number of Coturn's database in Redis. # +# Environment variable: MEDEA_TURN.DB.REDIS.DB_NUMBER +# # Default: # db_number = 0 # Timeout for establishing connection with Coturn's Redis database. # +# Environment variable: MEDEA_TURN.DB.REDIS.CONNECTION_TIMEOUT +# # Default: # connection_timeout = "5s" @@ -112,6 +148,8 @@ [log] # Maximum allowed level of application log entries. # +# Environment variable: MEDEA_LOG.LEVEL +# # Possible values: # "OFF", "CRITICAL", "ERROR", "WARN", "INFO", "DEBUG", "TRACE" # @@ -124,5 +162,7 @@ [shutdown] # Maximum duration given to shutdown the whole application gracefully. # +# Environment variable: MEDEA_SHUTDOWN.TIMEOUT +# # Default: # timeout = "5s" From 002f8130f5a56c2a9c1001f7598de2a5462ab49e Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 10 Sep 2019 14:05:22 +0300 Subject: [PATCH 602/735] Reread --- Cargo.lock | 4 +- .../templates/deployment.server.yaml | 10 +- jason/demo/chart/medea-demo/values.yaml | 7 +- jason/demo/minikube.vals.yaml | 3 +- jason/demo/staging.vals.yaml | 3 +- proto/grpc/Cargo.toml | 2 +- proto/grpc/README.md | 2 +- proto/grpc/build.rs | 4 +- src/api/control/endpoints/mod.rs | 68 ++---- .../endpoints/webrtc_publish_endpoint.rs | 6 +- src/api/control/grpc/server.rs | 227 ++++++++---------- src/api/control/mod.rs | 27 +-- src/api/control/room.rs | 6 +- src/api/error_codes.rs | 64 +++-- src/bin/client.rs | 4 +- 15 files changed, 201 insertions(+), 236 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ab5c55252..8f06e5110 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1093,7 +1093,7 @@ dependencies = [ "humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "humantime-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "medea-client-api-proto 0.1.1-dev", - "medea-grpc-proto 0.1.0-dev.1", + "medea-grpc-proto 0.1.0-dev", "medea-macro 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1129,7 +1129,7 @@ dependencies = [ [[package]] name = "medea-grpc-proto" -version = "0.1.0-dev.1" +version = "0.1.0-dev" dependencies = [ "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "grpcio 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/jason/demo/chart/medea-demo/templates/deployment.server.yaml b/jason/demo/chart/medea-demo/templates/deployment.server.yaml index 4ff97f634..fa58b70b1 100644 --- a/jason/demo/chart/medea-demo/templates/deployment.server.yaml +++ b/jason/demo/chart/medea-demo/templates/deployment.server.yaml @@ -64,14 +64,14 @@ spec: value: {{ $coturn.conf.listening_port | quote }} - name: MEDEA_TURN.DB.REDIS.PORT value: {{ $coturnDb.conf.port | quote }} - - name: MEDEA_SERVER.HTTP.HOST - value: {{ .Values.server.conf.server.http.public_url }} + - name: MEDEA_CLIENT.HOST + value: {{ .Values.server.conf.client.public_url }} envFrom: - secretRef: name: {{ template "medea-demo.fullname" . }}.server.cred ports: - name: http - containerPort: {{ .Values.server.conf.server.http.bind_port }} + containerPort: {{ .Values.server.conf.client.bind_port }} volumeMounts: - name: conf subPath: medea.toml @@ -82,11 +82,11 @@ spec: {{- end }} livenessProbe: tcpSocket: - port: {{ .Values.server.conf.server.http.bind_port }} + port: {{ .Values.server.conf.client.bind_port }} initialDelaySeconds: 3 readinessProbe: tcpSocket: - port: {{ .Values.server.conf.server.http.bind_port }} + port: {{ .Values.server.conf.client.bind_port }} initialDelaySeconds: 5 - name: coturn image: "{{ $coturn.image.repository }}:{{ $coturn.image.tag }}" diff --git a/jason/demo/chart/medea-demo/values.yaml b/jason/demo/chart/medea-demo/values.yaml index 99e6bf3f2..10a9f895b 100644 --- a/jason/demo/chart/medea-demo/values.yaml +++ b/jason/demo/chart/medea-demo/values.yaml @@ -15,10 +15,9 @@ server: # ports and passwords) are auto-wired and specifying them in this # configuration will have no effect. conf: - server: - http: - bind_port: 8080 - public_url: "" + client: + bind_port: 8080 + public_url: "" turn: user: USER pass: PASS diff --git a/jason/demo/minikube.vals.yaml b/jason/demo/minikube.vals.yaml index 31c8958b1..a11ead5c4 100644 --- a/jason/demo/minikube.vals.yaml +++ b/jason/demo/minikube.vals.yaml @@ -8,8 +8,7 @@ server: tag: dev pullPolicy: IfNotPresent conf: - server: - http: + client: public_url: "wss://medea-demo.test" turn: host: medea-demo.test diff --git a/jason/demo/staging.vals.yaml b/jason/demo/staging.vals.yaml index e0ca7c99d..735341f6e 100644 --- a/jason/demo/staging.vals.yaml +++ b/jason/demo/staging.vals.yaml @@ -8,8 +8,7 @@ server: tag: edge pullPolicy: Always conf: - server: - http: + client: public_url: "wss://demo.medea.stg.t11913.org" bind_port: 9980 turn: diff --git a/proto/grpc/Cargo.toml b/proto/grpc/Cargo.toml index 6e3342704..db0b99334 100644 --- a/proto/grpc/Cargo.toml +++ b/proto/grpc/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "medea-grpc-proto" -version = "0.1.0-dev.1" +version = "0.1.0-dev" edition = "2018" description = "Compiled gRPC specs for Medea media server control API." authors = ["Instrumentisto Team "] diff --git a/proto/grpc/README.md b/proto/grpc/README.md index a8f05477a..922618ac7 100644 --- a/proto/grpc/README.md +++ b/proto/grpc/README.md @@ -17,7 +17,7 @@ __Currently, in early development phase.__ - CMake >= 3.8.0 - Rust >= 1.19.0 - binutils >= 2.22 -- LLVM and Clang >= 3.9 if you need to generate bindings at compile time. +- LLVM and Clang >= 3.9 - [protoc](https://github.com/protocolbuffers/protobuf) diff --git a/proto/grpc/build.rs b/proto/grpc/build.rs index e965c45cb..12a2919b5 100644 --- a/proto/grpc/build.rs +++ b/proto/grpc/build.rs @@ -1,4 +1,4 @@ -use std::{env, fs::File, io::Write as _}; +use std::{env, error::Error, fs::File, io::Write as _}; static CONTROL_API_MOD_RS: &[u8] = b" /// Generated from protobuf. @@ -7,7 +7,7 @@ pub mod control; pub mod control_grpc; "; -fn main() -> Result<(), Box> { +fn main() -> Result<(), Box> { let out_dir = env::var("OUT_DIR")?; protoc_grpcio::compile_grpc_protos( diff --git a/src/api/control/endpoints/mod.rs b/src/api/control/endpoints/mod.rs index d8f404c58..df50f182a 100644 --- a/src/api/control/endpoints/mod.rs +++ b/src/api/control/endpoints/mod.rs @@ -9,7 +9,7 @@ use medea_grpc_proto::control::{ CreateRequest, Member_Element as MemberElementProto, }; -use super::{member::MemberElement, TryFromElementError, TryFromProtobufError}; +use super::{member::MemberElement, TryFromProtobufError}; #[doc(inline)] pub use webrtc_play_endpoint::WebRtcPlayEndpoint; @@ -37,51 +37,29 @@ impl Into for Endpoint { } } -impl TryFrom<&MemberElementProto> for Endpoint { - type Error = TryFromProtobufError; +macro_rules! impl_try_from_proto_for_endpoint { + ($proto:ty) => { + impl TryFrom<$proto> for Endpoint { + type Error = TryFromProtobufError; - fn try_from(value: &MemberElementProto) -> Result { - if value.has_webrtc_play() { - let play = WebRtcPlayEndpoint::try_from(value.get_webrtc_play())?; - Ok(Endpoint::WebRtcPlay(play)) - } else if value.has_webrtc_pub() { - let publish = WebRtcPublishEndpoint::from(value.get_webrtc_pub()); - Ok(Endpoint::WebRtcPublish(publish)) - } else { - // TODO implement another endpoints when they will be implemented - unimplemented!() - } - } -} - -impl TryFrom<&CreateRequest> for Endpoint { - type Error = TryFromProtobufError; - - fn try_from(value: &CreateRequest) -> Result { - if value.has_webrtc_play() { - let play = WebRtcPlayEndpoint::try_from(value.get_webrtc_play())?; - Ok(Endpoint::WebRtcPlay(play)) - } else if value.has_webrtc_pub() { - let publish = WebRtcPublishEndpoint::from(value.get_webrtc_pub()); - Ok(Endpoint::WebRtcPublish(publish)) - } else { - // TODO implement another endpoints when they will be implemented - unimplemented!() - } - } -} - -impl TryFrom<&MemberElement> for Endpoint { - type Error = TryFromElementError; - - fn try_from(from: &MemberElement) -> Result { - match from { - MemberElement::WebRtcPlayEndpoint { spec } => { - Ok(Endpoint::WebRtcPlay(spec.clone())) - } - MemberElement::WebRtcPublishEndpoint { spec } => { - Ok(Endpoint::WebRtcPublish(spec.clone())) + fn try_from(proto: $proto) -> Result { + if proto.has_webrtc_play() { + let play = + WebRtcPlayEndpoint::try_from(proto.get_webrtc_play())?; + Ok(Endpoint::WebRtcPlay(play)) + } else if proto.has_webrtc_pub() { + let publish = + WebRtcPublishEndpoint::from(proto.get_webrtc_pub()); + Ok(Endpoint::WebRtcPublish(publish)) + } else { + // TODO implement another endpoints when they will be + // implemented + unimplemented!() + } } } - } + }; } + +impl_try_from_proto_for_endpoint!(&MemberElementProto); +impl_try_from_proto_for_endpoint!(&CreateRequest); diff --git a/src/api/control/endpoints/webrtc_publish_endpoint.rs b/src/api/control/endpoints/webrtc_publish_endpoint.rs index 0c5b7198d..62e435881 100644 --- a/src/api/control/endpoints/webrtc_publish_endpoint.rs +++ b/src/api/control/endpoints/webrtc_publish_endpoint.rs @@ -17,7 +17,11 @@ pub struct WebRtcPublishId(pub String); pub enum P2pMode { /// Always connect peer-to-peer. Always, + + /// Never connect peer-to-peer. Never, + + /// Connect peer-to-peer if it possible. IfPossible, } @@ -46,7 +50,7 @@ impl Into for P2pMode { #[allow(clippy::module_name_repetitions)] #[derive(Clone, Deserialize, Debug)] pub struct WebRtcPublishEndpoint { - /// Peer-to-peer mode. + /// Peer-to-peer mode of this [`WebRtcPublishEndpoint`]. pub p2p: P2pMode, } diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index 06ac9b228..f55b9b1df 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -30,42 +30,34 @@ use crate::{ IsEndpointId, IsMemberId, IsRoomId, LocalUri, LocalUriParseError, LocalUriType, }, - Endpoint, MemberSpec, RoomSpec, TryFromElementError, - TryFromProtobufError, + Endpoint, MemberId, MemberSpec, RoomId, RoomSpec, + TryFromElementError, TryFromProtobufError, }, error_codes::{ErrorCode, ErrorResponse}, }, log::prelude::*, + shutdown::ShutdownGracefully, signalling::{ room::RoomError, room_service::{ - CreateEndpointInRoom, CreateMemberInRoom, DeleteElements, + CreateEndpointInRoom, CreateMemberInRoom, DeleteElements, Get, RoomService, RoomServiceError, StartRoom, }, }, AppContext, }; -use crate::{ - api::control::{MemberId, RoomId}, - shutdown::ShutdownGracefully, - signalling::room_service::Get, -}; - #[derive(Debug, Fail, Display)] pub enum ControlApiError { - /// Error when parsing ID of element. - #[display(fmt = "{:?}", _0)] + /// Error while parsing local URI of element. LocalUri(LocalUriParseError), /// This error is rather abnormal, since what it catches must be caught at /// the level of the gRPC. - #[display(fmt = "{:?}", _0)] TryFromProtobuf(TryFromProtobufError), /// This error is rather abnormal, since what it catches must be caught at /// the level of the gRPC. - #[display(fmt = "{:?}", _0)] TryFromElement(TryFromElementError), /// [`MailboxError`] for [`RoomService`]. @@ -78,8 +70,12 @@ pub enum ControlApiError { /// it cannot happen. /// /// __Never use this error.__ - #[display(fmt = "Mailbox error which never can happen.")] + #[display(fmt = "Mailbox error which never can happen. {:?}", _0)] UnknownMailboxErr(MailboxError), + + RoomError(RoomError), + + RoomServiceError(RoomServiceError), } impl From for ControlApiError { @@ -88,6 +84,18 @@ impl From for ControlApiError { } } +impl From for ControlApiError { + fn from(from: RoomError) -> Self { + ControlApiError::RoomError(from) + } +} + +impl From for ControlApiError { + fn from(from: RoomServiceError) -> Self { + Self::RoomServiceError(from) + } +} + impl From for ControlApiError { fn from(from: TryFromProtobufError) -> Self { ControlApiError::TryFromProtobuf(from) @@ -139,6 +147,10 @@ macro_rules! parse_local_uri { /// /// `$response` - is type of response ([`GetResponse`], [`Response`] /// etc). +/// +/// `$ctx` - context where `Future` for send gRPC response will be spawned. +/// +/// `$sink` - `grpcio` sink for response. macro_rules! send_error_response { ($ctx:tt, $sink:tt, $error_code:expr, $response:ty) => { let mut response = <$response>::new(); @@ -153,13 +165,15 @@ macro_rules! send_error_response { }; } -/// Type alias for result of Create request. -type CreateResult = - Result, RoomError>, RoomServiceError>; +/// Type alias for success [`CreateResponse`]'s sids. +type Sids = HashMap; #[derive(Clone)] struct ControlApiService { + /// [`Addr`] of [`RoomService`]. room_service: Addr, + + /// Global app context. app: AppContext, } @@ -181,7 +195,7 @@ impl ControlApiService { &mut self, req: &CreateRequest, local_uri: LocalUri, - ) -> impl Future { + ) -> impl Future { let room_id = local_uri.take_room_id(); let room = fut_try!(RoomSpec::try_from_protobuf( @@ -202,7 +216,9 @@ impl ControlApiService { self.room_service .send(StartRoom(room_id, room)) .map_err(ControlApiError::RoomServiceMailboxError) - .map(move |r| r.map(|_| Ok(sid))), + .and_then(move |r| { + r.map_err(ControlApiError::from).map(|_| sid) + }), ) } @@ -211,7 +227,7 @@ impl ControlApiService { &mut self, req: &CreateRequest, local_uri: LocalUri, - ) -> impl Future { + ) -> impl Future { let spec = fut_try!(MemberSpec::try_from(req.get_member())); let (member_id, room_uri) = local_uri.take_member_id(); @@ -229,7 +245,7 @@ impl ControlApiService { spec, }) .map_err(ControlApiError::RoomServiceMailboxError) - .map(|r| r.map(|r| r.map(|_| sids))), + .and_then(|r| r.map_err(ControlApiError::from).map(|_| sids)), ) } @@ -239,7 +255,7 @@ impl ControlApiService { &mut self, req: &CreateRequest, local_uri: LocalUri, - ) -> impl Future { + ) -> impl Future { let endpoint = fut_try!(Endpoint::try_from(req)); let (endpoint_id, member_uri) = local_uri.take_endpoint_id(); let (member_id, room_uri) = member_uri.take_member_id(); @@ -254,35 +270,13 @@ impl ControlApiService { spec: endpoint, }) .map_err(ControlApiError::RoomServiceMailboxError) - .map(|r| r.map(|r| r.map(|_| HashMap::new()))), + .and_then(|r| { + r.map_err(ControlApiError::from).map(|_| HashMap::new()) + }), ) } } -/// Generate [`Response`] for `Create` method of all elements. -fn get_response_for_create( - result: Result, -) -> CreateResponse { - let error: ErrorResponse = match result { - Ok(r) => match r { - Ok(r) => match r { - Ok(sid) => { - let mut response = CreateResponse::new(); - response.set_sid(sid); - return response; - } - Err(e) => e.into(), - }, - Err(e) => e.into(), - }, - Err(e) => e.into(), - }; - - let mut error_response = CreateResponse::new(); - error_response.set_error(error.into()); - error_response -} - impl ControlApi for ControlApiService { /// Implementation for `Create` method of gRPC control API. fn create( @@ -294,79 +288,70 @@ impl ControlApi for ControlApiService { let local_uri = parse_local_uri!(req.get_id(), ctx, sink, CreateResponse); + let create_grpc_response_err = |e: grpcio::Error| { + warn!("Error while sending Create response by gRPC. {:?}", e) + }; + + fn response(result: Result) -> CreateResponse { + let mut response = CreateResponse::new(); + match result { + Ok(sid) => { + response.set_sid(sid); + } + Err(e) => response.set_error(ErrorResponse::from(e).into()), + } + response + } + + macro_rules! send_element_id_for_room_but_element_is_not_err { + () => { + send_error_response!( + ctx, + sink, + ErrorResponse::new( + ErrorCode::ElementIdForRoomButElementIsNot, + &req.get_id() + ), + CreateResponse + ) + }; + } + match local_uri { LocalUriType::Room(local_uri) => { if req.has_room() { ctx.spawn(self.create_room(&req, local_uri).then( move |r| { - sink.success(get_response_for_create(r)) - .map_err(|_| ()) + sink.success(response(r)) + .map_err(create_grpc_response_err) }, )); } else { - send_error_response!( - ctx, - sink, - ErrorResponse::new( - ErrorCode::ElementIdForRoomButElementIsNot, - &req.get_id(), - ), - CreateResponse - ); + send_element_id_for_room_but_element_is_not_err!(); } } LocalUriType::Member(local_uri) => { if req.has_member() { ctx.spawn(self.create_member(&req, local_uri).then( move |r| { - sink.success(get_response_for_create(r)).map_err( - |e| { - warn!( - "Error while sending Create response \ - by gRPC. {:?}", - e - ) - }, - ) + sink.success(response(r)) + .map_err(create_grpc_response_err) }, )); } else { - send_error_response!( - ctx, - sink, - ErrorResponse::new( - ErrorCode::ElementIdForMemberButElementIsNot, - &req.get_id(), - ), - CreateResponse - ); + send_element_id_for_room_but_element_is_not_err!(); } } LocalUriType::Endpoint(local_uri) => { if req.has_webrtc_pub() || req.has_webrtc_play() { ctx.spawn(self.create_endpoint(&req, local_uri).then( move |r| { - sink.success(get_response_for_create(r)).map_err( - |e| { - warn!( - "Error while sending Create response \ - by gRPC. {:?}", - e - ) - }, - ) + sink.success(response(r)) + .map_err(create_grpc_response_err) }, )); } else { - send_error_response!( - ctx, - sink, - ErrorResponse::new( - ErrorCode::ElementIdForEndpointButElementIsNot, - &req.get_id(), - ), - CreateResponse - ); + send_element_id_for_room_but_element_is_not_err!(); } } } @@ -425,25 +410,14 @@ impl ControlApi for ControlApiService { ctx.spawn( self.room_service .send(delete_elements) - .then(move |result| match result { - Ok(result) => match result { - Ok(_) => sink.success(Response::new()), - Err(e) => { - let mut response = Response::new(); - response.set_error(ErrorResponse::from(e).into()); - sink.success(response) - } - }, - Err(e) => { - let mut response = Response::new(); - response.set_error( - ErrorResponse::from( - ControlApiError::RoomServiceMailboxError(e), - ) - .into(), - ); - sink.success(response) + .map_err(ControlApiError::RoomServiceMailboxError) + .and_then(|r| r.map_err(ControlApiError::from)) + .then(move |result| { + let mut response = Response::new(); + if let Err(e) = result { + response.set_error(ErrorResponse::from(e).into()); } + sink.success(response) }) .map_err(|e| { warn!( @@ -470,29 +444,24 @@ impl ControlApi for ControlApiService { ctx.spawn( self.room_service .send(Get(uris)) - .then(|mailbox_result| match mailbox_result { - Ok(room_service_result) => match room_service_result { + .map_err(ControlApiError::RoomServiceMailboxError) + .and_then(|r| r.map_err(ControlApiError::from)) + .then(|res| { + let mut response = GetResponse::new(); + match res { Ok(elements) => { - let mut response = GetResponse::new(); response.set_elements( elements .into_iter() .map(|(id, value)| (id.to_string(), value)) .collect(), ); - sink.success(response) } Err(e) => { - let mut response = GetResponse::new(); response.set_error(ErrorResponse::from(e).into()); - sink.success(response) } - }, - Err(e) => { - let mut response = GetResponse::new(); - response.set_error(ErrorResponse::unknown(&e).into()); - sink.success(response) } + sink.success(response) }) .map_err(|e| { warn!( @@ -516,7 +485,7 @@ impl Actor for GrpcServer { fn started(&mut self, _ctx: &mut Self::Context) { self.server.start(); - debug!("gRPC server started."); + info!("gRPC Control API server started."); } } @@ -529,9 +498,15 @@ impl Handler for GrpcServer { _: &mut Self::Context, ) -> Self::Result { info!( - "gRPC server received ShutdownGracefully message so shutting down.", + "gRPC Control API server received ShutdownGracefully message so \ + shutting down.", ); - Box::new(self.server.shutdown().map_err(|e| warn!("{:?}", e))) + Box::new(self.server.shutdown().map_err(|e| { + warn!( + "Error while graceful shutdown of gRPC Contro API server: {:?}", + e + ) + })) } } diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index 8101d4dbc..7739dbce0 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -36,25 +36,14 @@ pub enum TryFromProtobufError { #[display(fmt = "Src uri parse error: {:?}", _0)] SrcUriError(SrcParseError), - /// Src URI not provided for [`WebRtcPlayEndpoint`]. - #[display(fmt = "Src uri for publish endpoint not provided.")] - SrcUriNotFound, - - /// Room element not provided. - #[display(fmt = "Room element not provided.")] - RoomElementNotFound, - - /// Member element not provided. - #[display(fmt = "Member element not provided.")] - MemberElementNotFound, - - /// [`P2pMode`] not found. - #[display(fmt = "P2p mode for play endpoint not provided.")] - P2pModeNotFound, - - /// Member credentials not found. - #[display(fmt = "Credentials for member not provided.")] - MemberCredentialsNotFound, + /// Room element doesn't have Member element. Currently this is + /// unimplemented. + #[display( + fmt = "Room element [id = {}]doesn't have Member element. Currently \ + this is unimplemented.", + _0 + )] + NotMemberElementInRoomElement(String), } impl From for TryFromProtobufError { diff --git a/src/api/control/room.rs b/src/api/control/room.rs index f1443db15..ce0e2a825 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -58,7 +58,11 @@ impl RoomSpec { let mut pipeline = HashMap::new(); for (id, room_element) in proto.get_pipeline() { if !room_element.has_member() { - return Err(TryFromProtobufError::MemberElementNotFound); + return Err( + TryFromProtobufError::NotMemberElementInRoomElement( + id.to_string(), + ), + ); } let member = MemberSpec::try_from(room_element.get_member())?; pipeline.insert(id.clone(), member.into()); diff --git a/src/api/error_codes.rs b/src/api/error_codes.rs index 1ca0c4fa3..ffdb50844 100644 --- a/src/api/error_codes.rs +++ b/src/api/error_codes.rs @@ -13,13 +13,10 @@ use derive_more::Display; use medea_grpc_proto::control::Error as ErrorProto; use crate::{ - api::{ - control::{ - endpoints::webrtc_play_endpoint::SrcParseError, - grpc::server::ControlApiError, local_uri::LocalUriParseError, - TryFromElementError, TryFromProtobufError, - }, - error_codes::ErrorCode::ElementIdIsNotLocal, + api::control::{ + endpoints::webrtc_play_endpoint::SrcParseError, + grpc::server::ControlApiError, local_uri::LocalUriParseError, + TryFromElementError, TryFromProtobufError, }, signalling::{ elements::{member::MemberError, MembersLoadError}, @@ -39,12 +36,12 @@ pub struct ErrorResponse { /// All [`ErrorCode`]s have [`Display`] implementation. And this /// implementation will be used if this field is [`None`]. But - /// some time we want to use custom text. Then we set this field - /// to [`Some`] and this custom text will be added to + /// some time we want to add some error explanation. Then we set this field + /// to [`Some`] and this text will be added to /// [`Display`] implementation's text. /// /// By default this field should be [`None`]. - additional_text: Option, + explanation: Option, } impl ErrorResponse { @@ -53,7 +50,7 @@ impl ErrorResponse { Self { error_code, element_id: Some(element_id.to_string()), - additional_text: None, + explanation: None, } } @@ -62,7 +59,7 @@ impl ErrorResponse { Self { error_code, element_id: None, - additional_text: None, + explanation: None, } } @@ -72,7 +69,7 @@ impl ErrorResponse { pub fn unknown(unknown_error: &B) -> Self { Self { error_code: ErrorCode::UnknownError, - additional_text: Some(unknown_error.to_string()), + explanation: Some(unknown_error.to_string()), element_id: None, } } @@ -80,11 +77,11 @@ impl ErrorResponse { pub fn custom_text( error_code: ErrorCode, text: String, - id: Option>, + id: Option, ) -> Self { Self { error_code, - additional_text: Some(text), + explanation: Some(text), element_id: id.map(|s| s.to_string()), } } @@ -94,7 +91,7 @@ impl Into for ErrorResponse { fn into(self) -> ErrorProto { let mut error = ErrorProto::new(); - if let Some(additional_text) = &self.additional_text { + if let Some(additional_text) = &self.explanation { error.set_text(format!( "{} {}", self.error_code.to_string(), @@ -118,6 +115,10 @@ impl Into for ErrorResponse { pub enum ErrorCode { /// Unknown server error. /// + /// Use this [`ErrorCode`] only with [`ErrorResponse::unknown`] function. + /// In error text with this code should be error message which explain what + /// exactly goes wrong ([`ErrorResponse::unknown`] do this). + /// /// Code: __1000__. #[display(fmt = "Unexpected error happened.")] UnknownError = 1000, @@ -264,6 +265,19 @@ pub enum ErrorCode { /// Code: __1302__. #[display(fmt = "Room already exists.")] RoomAlreadyExists = 1302, + + //////////////////////// + // Misc (1400 - 1499)// + ////////////////////// + /// Unimplemented API call. + /// + /// This code should be with additional text which explains what + /// exactly unimplemented (you can do it with [`ErrorResponse::explain`] + /// function). + /// + /// Code: __1400__. + #[display(fmt = "Unimplemented API call.")] + UnimplementedCall = 1400, } impl From for ErrorResponse { @@ -291,12 +305,14 @@ impl From for ErrorResponse { fn from(err: TryFromProtobufError) -> Self { match err { TryFromProtobufError::SrcUriError(e) => e.into(), - TryFromProtobufError::SrcUriNotFound - | TryFromProtobufError::RoomElementNotFound - | TryFromProtobufError::MemberElementNotFound - | TryFromProtobufError::P2pModeNotFound - | TryFromProtobufError::MemberCredentialsNotFound => { - Self::unknown(&err) + TryFromProtobufError::NotMemberElementInRoomElement(id) => { + Self::custom_text( + ErrorCode::UnimplementedCall, + "Not Member elements in Room element currently \ + unimplemented." + .to_string(), + Some(id), + ) } } } @@ -306,7 +322,7 @@ impl From for ErrorResponse { fn from(err: LocalUriParseError) -> Self { match err { LocalUriParseError::NotLocal(text) => { - Self::new(ElementIdIsNotLocal, &text) + Self::new(ErrorCode::ElementIdIsNotLocal, &text) } LocalUriParseError::TooManyFields(text) => { Self::new(ErrorCode::ElementIdIsTooLong, &text) @@ -439,6 +455,8 @@ impl From for ErrorResponse { match err { ControlApiError::LocalUri(e) => e.into(), ControlApiError::TryFromProtobuf(e) => e.into(), + ControlApiError::RoomServiceError(e) => e.into(), + ControlApiError::RoomError(e) => e.into(), ControlApiError::RoomServiceMailboxError(_) | ControlApiError::TryFromElement(_) | ControlApiError::UnknownMailboxErr(_) => Self::unknown(&err), diff --git a/src/bin/client.rs b/src/bin/client.rs index 03c3a62ef..6768789e0 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -19,8 +19,8 @@ fn main() { let client = ControlApiClient::new(ch); // unimplemented_apply(&client); - // create_room(&client); - delete_room(&client); + create_room(&client); + // delete_room(&client); // delete_endpoint(&client); // delete_member(&client); // create_member(&client); From e8d02c4a0a07b1864b7e9dc6035a014c5cd43b0d Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 10 Sep 2019 14:38:37 +0300 Subject: [PATCH 603/735] Reread --- src/api/control/grpc/server.rs | 96 +++++++++++++--------------------- src/api/error_codes.rs | 8 ++- src/bin/client.rs | 4 +- src/signalling/room_service.rs | 14 ++--- 4 files changed, 48 insertions(+), 74 deletions(-) diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index f55b9b1df..550ea3458 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -37,12 +37,9 @@ use crate::{ }, log::prelude::*, shutdown::ShutdownGracefully, - signalling::{ - room::RoomError, - room_service::{ - CreateEndpointInRoom, CreateMemberInRoom, DeleteElements, Get, - RoomService, RoomServiceError, StartRoom, - }, + signalling::room_service::{ + CreateEndpointInRoom, CreateMemberInRoom, DeleteElements, Get, + RoomService, RoomServiceError, StartRoom, }, AppContext, }; @@ -73,8 +70,7 @@ pub enum ControlApiError { #[display(fmt = "Mailbox error which never can happen. {:?}", _0)] UnknownMailboxErr(MailboxError), - RoomError(RoomError), - + /// Wrapper aroung [`RoomServiceError`]. RoomServiceError(RoomServiceError), } @@ -84,12 +80,6 @@ impl From for ControlApiError { } } -impl From for ControlApiError { - fn from(from: RoomError) -> Self { - ControlApiError::RoomError(from) - } -} - impl From for ControlApiError { fn from(from: RoomServiceError) -> Self { Self::RoomServiceError(from) @@ -285,76 +275,60 @@ impl ControlApi for ControlApiService { req: CreateRequest, sink: UnarySink, ) { - let local_uri = - parse_local_uri!(req.get_id(), ctx, sink, CreateResponse); - - let create_grpc_response_err = |e: grpcio::Error| { - warn!("Error while sending Create response by gRPC. {:?}", e) - }; - - fn response(result: Result) -> CreateResponse { - let mut response = CreateResponse::new(); - match result { - Ok(sid) => { - response.set_sid(sid); - } - Err(e) => response.set_error(ErrorResponse::from(e).into()), - } - response - } - - macro_rules! send_element_id_for_room_but_element_is_not_err { - () => { + macro_rules! send_error_response_code { + ($response_code:expr) => { send_error_response!( ctx, sink, - ErrorResponse::new( - ErrorCode::ElementIdForRoomButElementIsNot, - &req.get_id() - ), + ErrorResponse::new($response_code, &req.get_id()), CreateResponse ) }; } - match local_uri { + let response_fut: Box< + dyn Future + Send, + > = match parse_local_uri!(req.get_id(), ctx, sink, CreateResponse) { LocalUriType::Room(local_uri) => { if req.has_room() { - ctx.spawn(self.create_room(&req, local_uri).then( - move |r| { - sink.success(response(r)) - .map_err(create_grpc_response_err) - }, - )); + Box::new(self.create_room(&req, local_uri)) } else { - send_element_id_for_room_but_element_is_not_err!(); + send_error_response_code!( + ErrorCode::ElementIdForRoomButElementIsNot + ); } } LocalUriType::Member(local_uri) => { if req.has_member() { - ctx.spawn(self.create_member(&req, local_uri).then( - move |r| { - sink.success(response(r)) - .map_err(create_grpc_response_err) - }, - )); + Box::new(self.create_member(&req, local_uri)) } else { - send_element_id_for_room_but_element_is_not_err!(); + send_error_response_code!( + ErrorCode::ElementIdForMemberButElementIsNot + ); } } LocalUriType::Endpoint(local_uri) => { if req.has_webrtc_pub() || req.has_webrtc_play() { - ctx.spawn(self.create_endpoint(&req, local_uri).then( - move |r| { - sink.success(response(r)) - .map_err(create_grpc_response_err) - }, - )); + Box::new(self.create_endpoint(&req, local_uri)) } else { - send_element_id_for_room_but_element_is_not_err!(); + send_error_response_code!( + ErrorCode::ElementIdForEndpointButElementIsNot + ); } } - } + }; + ctx.spawn(response_fut.then(move |result| { + let mut response = CreateResponse::new(); + match result { + Ok(sid) => { + response.set_sid(sid); + } + Err(e) => response.set_error(ErrorResponse::from(e).into()), + } + sink.success(response).map_err(|e| { + warn!("Error while sending Create response by gRPC. {:?}", e) + }) + })); } /// Implementation for `Apply` method of gRPC control API. diff --git a/src/api/error_codes.rs b/src/api/error_codes.rs index ffdb50844..10cf6bcc9 100644 --- a/src/api/error_codes.rs +++ b/src/api/error_codes.rs @@ -186,16 +186,15 @@ pub enum ErrorCode { /// Member. /// /// Code: __1104__. - #[display( - fmt = "You provided ID for Member but element's spec is not for Room." - )] + #[display(fmt = "You provided ID for Member but element's spec is not \ + for Member.")] ElementIdForMemberButElementIsNot = 1104, /// Provided element ID to Endpoint element but element spec is not for /// Endpoint. /// /// Code: __1105__. #[display(fmt = "You provided ID for Endpoint but element's spec is not \ - for Room.")] + for Endpoint.")] ElementIdForEndpointButElementIsNot = 1105, /// Invalid ID for element. /// @@ -456,7 +455,6 @@ impl From for ErrorResponse { ControlApiError::LocalUri(e) => e.into(), ControlApiError::TryFromProtobuf(e) => e.into(), ControlApiError::RoomServiceError(e) => e.into(), - ControlApiError::RoomError(e) => e.into(), ControlApiError::RoomServiceMailboxError(_) | ControlApiError::TryFromElement(_) | ControlApiError::UnknownMailboxErr(_) => Self::unknown(&err), diff --git a/src/bin/client.rs b/src/bin/client.rs index 6768789e0..90daaf490 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -23,7 +23,7 @@ fn main() { // delete_room(&client); // delete_endpoint(&client); // delete_member(&client); - // create_member(&client); + create_member(&client); // create_endpoint(&client); // get_room(&client); } @@ -86,7 +86,7 @@ fn create_member(client: &ControlApiClient) { member.set_credentials("test".to_string()); member.set_pipeline(member_pipeline); - create_member_request.set_id("local://grpc-test/player".to_string()); + create_member_request.set_id("local://grpc-test/player/asdsad".to_string()); create_member_request.set_member(member); let reply = client diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index 047b2e1c6..7f30e5ed7 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -384,7 +384,7 @@ impl Handler for RoomService { /// Signal for create new [`Member`] in [`Room`] #[derive(Message)] -#[rtype(result = "Result, RoomServiceError>")] +#[rtype(result = "Result<(), RoomServiceError>")] pub struct CreateMemberInRoom { pub room_id: RoomId, pub member_id: MemberId, @@ -392,7 +392,7 @@ pub struct CreateMemberInRoom { } impl Handler for RoomService { - type Result = ActFuture, RoomServiceError>; + type Result = ActFuture<(), RoomServiceError>; fn handle( &mut self, @@ -402,7 +402,8 @@ impl Handler for RoomService { let fut = if let Some(room) = self.room_repo.get(&msg.room_id) { Either::A( room.send(CreateMember(msg.member_id, msg.spec)) - .map_err(RoomServiceError::RoomMailboxErr), + .map_err(RoomServiceError::RoomMailboxErr) + .and_then(|r| r.map_err(RoomServiceError::from)), ) } else { Either::B(future::err(RoomServiceError::RoomNotFound( @@ -416,7 +417,7 @@ impl Handler for RoomService { /// Signal for create new [`Endpoint`] in [`Room`] #[derive(Message)] -#[rtype(result = "Result, RoomServiceError>")] +#[rtype(result = "Result<(), RoomServiceError>")] pub struct CreateEndpointInRoom { pub room_id: RoomId, pub member_id: MemberId, @@ -425,7 +426,7 @@ pub struct CreateEndpointInRoom { } impl Handler for RoomService { - type Result = ActFuture, RoomServiceError>; + type Result = ActFuture<(), RoomServiceError>; fn handle( &mut self, @@ -439,7 +440,8 @@ impl Handler for RoomService { endpoint_id: msg.endpoint_id, spec: msg.spec, }) - .map_err(RoomServiceError::RoomMailboxErr), + .map_err(RoomServiceError::RoomMailboxErr) + .and_then(|r| r.map_err(RoomServiceError::from)), ) } else { Either::B(future::err(RoomServiceError::RoomNotFound( From 19181ced3791fc5647a172783bf519e232515e1e Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 10 Sep 2019 15:11:34 +0300 Subject: [PATCH 604/735] Reread --- src/api/control/grpc/server.rs | 39 ++++++++++++------------------ src/api/control/local_uri.rs | 29 ++++++++++++++--------- src/signalling/room_service.rs | 43 ++++++++++++++++++++-------------- 3 files changed, 59 insertions(+), 52 deletions(-) diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index 550ea3458..1bed1ceab 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -184,19 +184,18 @@ impl ControlApiService { pub fn create_room( &mut self, req: &CreateRequest, - local_uri: LocalUri, + uri: LocalUri, ) -> impl Future { - let room_id = local_uri.take_room_id(); - let room = fut_try!(RoomSpec::try_from_protobuf( - room_id.clone(), + uri.room_id().clone(), req.get_room() )); let sid: HashMap = fut_try!(room.members()) .iter() .map(|(id, member)| { - let uri = self.get_sid(&room_id, &id, member.credentials()); + let uri = + self.get_sid(uri.room_id(), &id, member.credentials()); (id.clone().to_string(), uri) }) @@ -204,7 +203,10 @@ impl ControlApiService { Either::A( self.room_service - .send(StartRoom(room_id, room)) + .send(StartRoom { + id: uri, + spec: room, + }) .map_err(ControlApiError::RoomServiceMailboxError) .and_then(move |r| { r.map_err(ControlApiError::from).map(|_| sid) @@ -216,24 +218,18 @@ impl ControlApiService { pub fn create_member( &mut self, req: &CreateRequest, - local_uri: LocalUri, + uri: LocalUri, ) -> impl Future { let spec = fut_try!(MemberSpec::try_from(req.get_member())); - let (member_id, room_uri) = local_uri.take_member_id(); - let room_id = room_uri.take_room_id(); - - let sid = self.get_sid(&room_id, &member_id, spec.credentials()); + let sid = + self.get_sid(uri.room_id(), uri.member_id(), spec.credentials()); let mut sids = HashMap::new(); - sids.insert(member_id.to_string(), sid); + sids.insert(uri.member_id().to_string(), sid); Either::A( self.room_service - .send(CreateMemberInRoom { - room_id, - member_id, - spec, - }) + .send(CreateMemberInRoom { uri: uri, spec }) .map_err(ControlApiError::RoomServiceMailboxError) .and_then(|r| r.map_err(ControlApiError::from).map(|_| sids)), ) @@ -244,19 +240,14 @@ impl ControlApiService { pub fn create_endpoint( &mut self, req: &CreateRequest, - local_uri: LocalUri, + uri: LocalUri, ) -> impl Future { let endpoint = fut_try!(Endpoint::try_from(req)); - let (endpoint_id, member_uri) = local_uri.take_endpoint_id(); - let (member_id, room_uri) = member_uri.take_member_id(); - let room_id = room_uri.take_room_id(); Either::A( self.room_service .send(CreateEndpointInRoom { - room_id, - member_id, - endpoint_id, + uri: uri, spec: endpoint, }) .map_err(ControlApiError::RoomServiceMailboxError) diff --git a/src/api/control/local_uri.rs b/src/api/control/local_uri.rs index 179a64e82..71356e485 100644 --- a/src/api/control/local_uri.rs +++ b/src/api/control/local_uri.rs @@ -112,6 +112,12 @@ impl LocalUri { pub fn take_room_id(self) -> RoomId { self.state.0 } + + /// Push [`MemberId`] to the end of URI and returns + /// [`LocalUri`]. + pub fn push_member_id(self, member_id: MemberId) -> LocalUri { + LocalUri::::new(self.state.0, member_id) + } } impl LocalUri { @@ -136,6 +142,17 @@ impl LocalUri { pub fn take_member_id(self) -> (MemberId, LocalUri) { (self.state.1, self.state.0) } + + /// Push endpoint ID to the end of URI and returns + /// [`LocalUri`]. + pub fn push_endpoint_id( + self, + endpoint_id: String, + ) -> LocalUri { + let (member_id, room_uri) = self.take_member_id(); + let room_id = room_uri.take_room_id(); + LocalUri::::new(room_id, member_id, endpoint_id) + } } impl LocalUri { @@ -295,7 +312,7 @@ impl fmt::Display for LocalUri { /// Enum for store all kinds of [`LocalUri`]s. #[allow(clippy::module_name_repetitions)] -#[derive(Debug, Hash, PartialEq, Eq, Clone)] +#[derive(Debug, Hash, PartialEq, Eq, Clone, Display)] pub enum LocalUriType { Room(LocalUri), Member(LocalUri), @@ -338,16 +355,6 @@ impl TryFrom<&str> for LocalUriType { } } -impl fmt::Display for LocalUriType { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self { - LocalUriType::Room(e) => write!(f, "{}", e), - LocalUriType::Member(e) => write!(f, "{}", e), - LocalUriType::Endpoint(e) => write!(f, "{}", e), - } - } -} - #[cfg(test)] mod tests { use super::*; diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index 7f30e5ed7..d2d3cfa2b 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -15,8 +15,10 @@ use crate::{ api::control::{ endpoints::Endpoint as EndpointSpec, load_static_specs_from_dir, - local_uri::{IsRoomId, LocalUri, LocalUriType}, - LoadStaticControlSpecsError, MemberId, MemberSpec, RoomId, RoomSpec, + local_uri::{ + IsEndpointId, IsMemberId, IsRoomId, LocalUri, LocalUriType, + }, + LoadStaticControlSpecsError, MemberSpec, RoomId, RoomSpec, }, log::prelude::*, shutdown::{self, GracefulShutdown}, @@ -173,7 +175,10 @@ impl Handler for RoomService { #[derive(Message)] #[rtype(result = "Result<(), RoomServiceError>")] -pub struct StartRoom(pub RoomId, pub RoomSpec); +pub struct StartRoom { + pub id: LocalUri, + pub spec: RoomSpec, +} impl Handler for RoomService { type Result = Result<(), RoomServiceError>; @@ -183,7 +188,7 @@ impl Handler for RoomService { msg: StartRoom, _ctx: &mut Self::Context, ) -> Self::Result { - let room_id = msg.0; + let room_id = msg.id.take_room_id(); if self.room_repo.get(&room_id).is_some() { return Err(RoomServiceError::RoomAlreadyExists( @@ -191,7 +196,7 @@ impl Handler for RoomService { )); } - let room = Room::new(&msg.1, self.app.clone())?; + let room = Room::new(&msg.spec, self.app.clone())?; let room_addr = room.start(); shutdown::subscribe( @@ -386,8 +391,7 @@ impl Handler for RoomService { #[derive(Message)] #[rtype(result = "Result<(), RoomServiceError>")] pub struct CreateMemberInRoom { - pub room_id: RoomId, - pub member_id: MemberId, + pub uri: LocalUri, pub spec: MemberSpec, } @@ -399,15 +403,18 @@ impl Handler for RoomService { msg: CreateMemberInRoom, _: &mut Self::Context, ) -> Self::Result { - let fut = if let Some(room) = self.room_repo.get(&msg.room_id) { + let (member_id, room_uri) = msg.uri.take_member_id(); + let room_id = room_uri.take_room_id(); + + let fut = if let Some(room) = self.room_repo.get(&room_id) { Either::A( - room.send(CreateMember(msg.member_id, msg.spec)) + room.send(CreateMember(member_id, msg.spec)) .map_err(RoomServiceError::RoomMailboxErr) .and_then(|r| r.map_err(RoomServiceError::from)), ) } else { Either::B(future::err(RoomServiceError::RoomNotFound( - get_local_uri_to_room(msg.room_id), + get_local_uri_to_room(room_id), ))) }; @@ -419,9 +426,7 @@ impl Handler for RoomService { #[derive(Message)] #[rtype(result = "Result<(), RoomServiceError>")] pub struct CreateEndpointInRoom { - pub room_id: RoomId, - pub member_id: MemberId, - pub endpoint_id: String, + pub uri: LocalUri, pub spec: EndpointSpec, } @@ -433,11 +438,15 @@ impl Handler for RoomService { msg: CreateEndpointInRoom, _ctx: &mut Self::Context, ) -> Self::Result { - let fut = if let Some(room) = self.room_repo.get(&msg.room_id) { + let (endpoint_id, member_uri) = msg.uri.take_endpoint_id(); + let (member_id, room_uri) = member_uri.take_member_id(); + let room_id = room_uri.take_room_id(); + + let fut = if let Some(room) = self.room_repo.get(&room_id) { Either::A( room.send(CreateEndpoint { - member_id: msg.member_id, - endpoint_id: msg.endpoint_id, + member_id, + endpoint_id, spec: msg.spec, }) .map_err(RoomServiceError::RoomMailboxErr) @@ -445,7 +454,7 @@ impl Handler for RoomService { ) } else { Either::B(future::err(RoomServiceError::RoomNotFound( - get_local_uri_to_room(msg.room_id), + get_local_uri_to_room(room_id), ))) }; From c7f1acd5c5a8d5b75897fc87807fecdee2c629be Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 10 Sep 2019 15:43:54 +0300 Subject: [PATCH 605/735] Get rid of LocalUriInner, rewrite LocalUri parsing --- src/api/control/local_uri.rs | 111 ++++++++++++----------------------- 1 file changed, 38 insertions(+), 73 deletions(-) diff --git a/src/api/control/local_uri.rs b/src/api/control/local_uri.rs index 71356e485..39dd91279 100644 --- a/src/api/control/local_uri.rs +++ b/src/api/control/local_uri.rs @@ -201,18 +201,7 @@ impl From for LocalUri { } } -#[allow(clippy::doc_markdown)] -#[derive(Debug, Clone, PartialEq, Hash, Eq)] -struct LocalUriInner { - /// ID of [`Room`] - room_id: Option, - /// ID of `Member` - member_id: Option, - /// Control ID of [`Endpoint`] - endpoint_id: Option, -} - -impl TryFrom<&str> for LocalUriInner { +impl TryFrom<&str> for LocalUriType { type Error = LocalUriParseError; fn try_from(value: &str) -> Result { @@ -226,9 +215,10 @@ impl TryFrom<&str> for LocalUriInner { return Err(LocalUriParseError::UrlParseErr( value.to_string(), e, - )) + )); } }; + if url.scheme() != "local" { return Err(LocalUriParseError::NotLocal(value.to_string())); } @@ -237,58 +227,59 @@ impl TryFrom<&str> for LocalUriInner { .host() .map(|id| id.to_string()) .filter(|id| !id.is_empty()) - .map(RoomId); + .map(RoomId) + .ok_or_else(|| { + LocalUriParseError::MissingFields(value.to_string()) + })?; + let mut path = match url.path_segments() { Some(path) => path, None => { - return Ok(Self { + return Ok(LocalUriType::Room(LocalUri::::new( room_id, - member_id: None, - endpoint_id: None, - }) + ))); } }; + let member_id = path .next() .filter(|id| !id.is_empty()) .map(|id| MemberId(id.to_string())); + let endpoint_id = path .next() .filter(|id| !id.is_empty()) - .map(std::string::ToString::to_string); + .map(|id| id.to_string()); if path.next().is_some() { return Err(LocalUriParseError::TooManyFields(value.to_string())); } - Ok(Self { - room_id, - member_id, - endpoint_id, - }) - } -} - -impl LocalUriInner { - /// Return true if this [`LocalUri`] pointing to `Room` element. - fn is_room_uri(&self) -> bool { - self.room_id.is_some() - && self.member_id.is_none() - && self.endpoint_id.is_none() - } - - /// Return true if this [`LocalUri`] pointing to `Member` element. - fn is_member_uri(&self) -> bool { - self.room_id.is_some() - && self.member_id.is_some() - && self.endpoint_id.is_none() - } - - /// Return true if this [`LocalUri`] pointing to `Endpoint` element. - fn is_endpoint_uri(&self) -> bool { - self.room_id.is_some() - && self.member_id.is_some() - && self.endpoint_id.is_some() + if let Some(member_id) = member_id { + if let Some(endpoint_id) = endpoint_id { + return Ok(LocalUriType::Endpoint( + LocalUri::::new( + room_id, + member_id, + endpoint_id, + ), + )); + } else { + return Ok(LocalUriType::Member(LocalUri::::new( + room_id, member_id, + ))); + } + } else { + if endpoint_id.is_some() { + return Err(LocalUriParseError::MissingFields( + value.to_string(), + )); + } else { + return Ok(LocalUriType::Room(LocalUri::::new( + room_id, + ))); + } + } } } @@ -329,32 +320,6 @@ impl LocalUriType { } } -impl TryFrom<&str> for LocalUriType { - type Error = LocalUriParseError; - - fn try_from(value: &str) -> Result { - let inner = LocalUriInner::try_from(value)?; - if inner.is_room_uri() { - Ok(LocalUriType::Room(LocalUri::::new( - inner.room_id.unwrap(), - ))) - } else if inner.is_member_uri() { - Ok(LocalUriType::Member(LocalUri::::new( - inner.room_id.unwrap(), - inner.member_id.unwrap(), - ))) - } else if inner.is_endpoint_uri() { - Ok(LocalUriType::Endpoint(LocalUri::::new( - inner.room_id.unwrap(), - inner.member_id.unwrap(), - inner.endpoint_id.unwrap(), - ))) - } else { - Err(LocalUriParseError::MissingFields(value.to_string())) - } - } -} - #[cfg(test)] mod tests { use super::*; From d7c62d974ac812504b8fdb322b13a00668969118 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 10 Sep 2019 15:55:07 +0300 Subject: [PATCH 606/735] Refactor --- .../control/endpoints/webrtc_play_endpoint.rs | 6 +- src/api/control/grpc/server.rs | 17 ++-- src/api/control/local_uri.rs | 95 +++++++++---------- src/signalling/elements/member.rs | 8 +- src/signalling/room.rs | 24 ++--- src/signalling/room_service.rs | 28 +++--- 6 files changed, 87 insertions(+), 91 deletions(-) diff --git a/src/api/control/endpoints/webrtc_play_endpoint.rs b/src/api/control/endpoints/webrtc_play_endpoint.rs index d9e2b019d..05bdbfd82 100644 --- a/src/api/control/endpoints/webrtc_play_endpoint.rs +++ b/src/api/control/endpoints/webrtc_play_endpoint.rs @@ -12,7 +12,7 @@ use serde::{ use crate::api::control::{ endpoints::webrtc_publish_endpoint::WebRtcPublishId, - local_uri::{IsEndpointId, LocalUri, LocalUriParseError, LocalUriType}, + local_uri::{IsEndpointId, LocalUri, LocalUriParseError, StatefulLocalUri}, MemberId, RoomId, TryFromProtobufError, }; @@ -62,11 +62,11 @@ impl TryFrom<&str> for SrcUri { type Error = SrcParseError; fn try_from(value: &str) -> Result { - let local_uri = LocalUriType::try_from(value).map_err(|e| { + let local_uri = StatefulLocalUri::try_from(value).map_err(|e| { SrcParseError::LocalUriParseError(value.to_string(), e) })?; - if let LocalUriType::Endpoint(endpoint_uri) = local_uri { + if let StatefulLocalUri::Endpoint(endpoint_uri) = local_uri { Ok(endpoint_uri.into()) } else { Err(SrcParseError::NotSrcUri(value.to_string())) diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index 1bed1ceab..6c2d0d428 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -28,7 +28,7 @@ use crate::{ control::{ local_uri::{ IsEndpointId, IsMemberId, IsRoomId, LocalUri, - LocalUriParseError, LocalUriType, + LocalUriParseError, StatefulLocalUri, }, Endpoint, MemberId, MemberSpec, RoomId, RoomSpec, TryFromElementError, TryFromProtobufError, @@ -120,7 +120,7 @@ macro_rules! fut_try { /// See `send_error_response` doc for details about arguments for this macro. macro_rules! parse_local_uri { ($uri:expr, $ctx:expr, $sink:expr, $response:ty) => { - match LocalUriType::try_from($uri.as_ref()) { + match StatefulLocalUri::try_from($uri.as_ref()) { Ok(o) => o, Err(e) => { let error: ErrorResponse = e.into(); @@ -229,7 +229,7 @@ impl ControlApiService { Either::A( self.room_service - .send(CreateMemberInRoom { uri: uri, spec }) + .send(CreateMemberInRoom { uri, spec }) .map_err(ControlApiError::RoomServiceMailboxError) .and_then(|r| r.map_err(ControlApiError::from).map(|_| sids)), ) @@ -247,7 +247,7 @@ impl ControlApiService { Either::A( self.room_service .send(CreateEndpointInRoom { - uri: uri, + uri, spec: endpoint, }) .map_err(ControlApiError::RoomServiceMailboxError) @@ -280,7 +280,7 @@ impl ControlApi for ControlApiService { let response_fut: Box< dyn Future + Send, > = match parse_local_uri!(req.get_id(), ctx, sink, CreateResponse) { - LocalUriType::Room(local_uri) => { + StatefulLocalUri::Room(local_uri) => { if req.has_room() { Box::new(self.create_room(&req, local_uri)) } else { @@ -289,7 +289,7 @@ impl ControlApi for ControlApiService { ); } } - LocalUriType::Member(local_uri) => { + StatefulLocalUri::Member(local_uri) => { if req.has_member() { Box::new(self.create_member(&req, local_uri)) } else { @@ -298,7 +298,7 @@ impl ControlApi for ControlApiService { ); } } - LocalUriType::Endpoint(local_uri) => { + StatefulLocalUri::Endpoint(local_uri) => { if req.has_webrtc_pub() || req.has_webrtc_play() { Box::new(self.create_endpoint(&req, local_uri)) } else { @@ -356,7 +356,8 @@ impl ControlApi for ControlApiService { let mut delete_elements = DeleteElements::new(); for id in req.get_id() { - let uri: LocalUriType = parse_local_uri!(id, ctx, sink, Response); + let uri: StatefulLocalUri = + parse_local_uri!(id, ctx, sink, Response); delete_elements.add_uri(uri); } diff --git a/src/api/control/local_uri.rs b/src/api/control/local_uri.rs index 39dd91279..82c158717 100644 --- a/src/api/control/local_uri.rs +++ b/src/api/control/local_uri.rs @@ -35,6 +35,25 @@ pub enum LocalUriParseError { Empty, } +/// Enum for store all kinds of [`LocalUri`]s. +#[allow(clippy::module_name_repetitions)] +#[derive(Debug, Hash, PartialEq, Eq, Clone, Display)] +pub enum StatefulLocalUri { + Room(LocalUri), + Member(LocalUri), + Endpoint(LocalUri), +} + +impl StatefulLocalUri { + pub fn room_id(&self) -> &RoomId { + match self { + StatefulLocalUri::Room(uri) => uri.room_id(), + StatefulLocalUri::Member(uri) => uri.room_id(), + StatefulLocalUri::Endpoint(uri) => uri.room_id(), + } + } +} + /// State of [`LocalUri`] which points to `Room`. #[derive(Debug, PartialEq, Hash, Eq, Clone)] pub struct IsRoomId(RoomId); @@ -201,7 +220,7 @@ impl From for LocalUri { } } -impl TryFrom<&str> for LocalUriType { +impl TryFrom<&str> for StatefulLocalUri { type Error = LocalUriParseError; fn try_from(value: &str) -> Result { @@ -235,7 +254,7 @@ impl TryFrom<&str> for LocalUriType { let mut path = match url.path_segments() { Some(path) => path, None => { - return Ok(LocalUriType::Room(LocalUri::::new( + return Ok(StatefulLocalUri::Room(LocalUri::::new( room_id, ))); } @@ -257,28 +276,20 @@ impl TryFrom<&str> for LocalUriType { if let Some(member_id) = member_id { if let Some(endpoint_id) = endpoint_id { - return Ok(LocalUriType::Endpoint( - LocalUri::::new( - room_id, - member_id, - endpoint_id, - ), - )); + Ok(StatefulLocalUri::Endpoint(LocalUri::::new( + room_id, + member_id, + endpoint_id, + ))) } else { - return Ok(LocalUriType::Member(LocalUri::::new( + Ok(StatefulLocalUri::Member(LocalUri::::new( room_id, member_id, - ))); + ))) } + } else if endpoint_id.is_some() { + Err(LocalUriParseError::MissingFields(value.to_string())) } else { - if endpoint_id.is_some() { - return Err(LocalUriParseError::MissingFields( - value.to_string(), - )); - } else { - return Ok(LocalUriType::Room(LocalUri::::new( - room_id, - ))); - } + Ok(StatefulLocalUri::Room(LocalUri::::new(room_id))) } } } @@ -301,33 +312,14 @@ impl fmt::Display for LocalUri { } } -/// Enum for store all kinds of [`LocalUri`]s. -#[allow(clippy::module_name_repetitions)] -#[derive(Debug, Hash, PartialEq, Eq, Clone, Display)] -pub enum LocalUriType { - Room(LocalUri), - Member(LocalUri), - Endpoint(LocalUri), -} - -impl LocalUriType { - pub fn room_id(&self) -> &RoomId { - match self { - LocalUriType::Room(uri) => uri.room_id(), - LocalUriType::Member(uri) => uri.room_id(), - LocalUriType::Endpoint(uri) => uri.room_id(), - } - } -} - #[cfg(test)] mod tests { use super::*; #[test] fn parse_local_uri_to_room_element() { - let local_uri = LocalUriType::try_from("local://room_id").unwrap(); - if let LocalUriType::Room(room) = local_uri { + let local_uri = StatefulLocalUri::try_from("local://room_id").unwrap(); + if let StatefulLocalUri::Room(room) = local_uri { assert_eq!(room.take_room_id(), RoomId("room_id".to_string())); } else { unreachable!("{:?}", local_uri); @@ -337,8 +329,9 @@ mod tests { #[test] fn parse_local_uri_to_element_of_room() { let local_uri = - LocalUriType::try_from("local://room_id/room_element_id").unwrap(); - if let LocalUriType::Member(member) = local_uri { + StatefulLocalUri::try_from("local://room_id/room_element_id") + .unwrap(); + if let StatefulLocalUri::Member(member) = local_uri { let (element_id, room_uri) = member.take_member_id(); assert_eq!(element_id, MemberId("room_element_id".to_string())); let room_id = room_uri.take_room_id(); @@ -350,11 +343,11 @@ mod tests { #[test] fn parse_local_uri_to_endpoint() { - let local_uri = LocalUriType::try_from( + let local_uri = StatefulLocalUri::try_from( "local://room_id/room_element_id/endpoint_id", ) .unwrap(); - if let LocalUriType::Endpoint(endpoint) = local_uri { + if let StatefulLocalUri::Endpoint(endpoint) = local_uri { let (endpoint_id, member_uri) = endpoint.take_endpoint_id(); assert_eq!(endpoint_id, "endpoint_id".to_string()); let (member_id, room_uri) = member_uri.take_member_id(); @@ -368,7 +361,7 @@ mod tests { #[test] fn returns_parse_error_if_local_uri_not_local() { - match LocalUriType::try_from("not-local://room_id") { + match StatefulLocalUri::try_from("not-local://room_id") { Ok(_) => unreachable!(), Err(e) => match e { LocalUriParseError::NotLocal(_) => (), @@ -379,7 +372,7 @@ mod tests { #[test] fn returns_parse_error_if_local_uri_empty() { - match LocalUriType::try_from("") { + match StatefulLocalUri::try_from("") { Ok(_) => unreachable!(), Err(e) => match e { LocalUriParseError::Empty => (), @@ -390,7 +383,9 @@ mod tests { #[test] fn returns_error_if_local_uri_have_too_many_paths() { - match LocalUriType::try_from("local://room/member/endpoint/too_many") { + match StatefulLocalUri::try_from( + "local://room/member/endpoint/too_many", + ) { Ok(_) => unreachable!(), Err(e) => match e { LocalUriParseError::TooManyFields(_) => (), @@ -406,7 +401,7 @@ mod tests { "local://room_id/member_id", "local://room_id/member_id/endpoint_id", ] { - let local_uri = LocalUriType::try_from(local_uri_str).unwrap(); + let local_uri = StatefulLocalUri::try_from(local_uri_str).unwrap(); assert_eq!(local_uri_str.to_string(), local_uri.to_string()); } } @@ -418,7 +413,7 @@ mod tests { "local:////endpoint_id", "local:///member_id/endpoint_id", ] { - match LocalUriType::try_from(local_uri_str) { + match StatefulLocalUri::try_from(local_uri_str) { Ok(_) => unreachable!(local_uri_str), Err(e) => match e { LocalUriParseError::MissingFields(_) => (), diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index 8b1d909bc..29dc68e64 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -21,7 +21,7 @@ use crate::{ api::control::{ endpoints::WebRtcPlayEndpoint as WebRtcPlayEndpointSpec, local_uri::{ - IsEndpointId, IsMemberId, IsRoomId, LocalUri, LocalUriType, + IsEndpointId, IsMemberId, IsRoomId, LocalUri, StatefulLocalUri, }, MemberId, MemberSpec, RoomId, RoomSpec, TryFromElementError, WebRtcPlayId, WebRtcPublishId, @@ -40,7 +40,7 @@ use super::endpoints::{ pub enum MembersLoadError { /// Errors that can occur when we try transform some spec from `Element`. #[display(fmt = "TryFromElementError: {}", _0)] - TryFromError(TryFromElementError, LocalUriType), + TryFromError(TryFromElementError, StatefulLocalUri), /// [`Member`] not found. #[display(fmt = "Member [id = {}] not found.", _0)] @@ -138,7 +138,7 @@ impl Member { MemberSpec::try_from(element).map_err(|e| { MembersLoadError::TryFromError( e, - LocalUriType::Member(LocalUri::::new( + StatefulLocalUri::Member(LocalUri::::new( self.room_id(), member_id.clone(), )), @@ -490,7 +490,7 @@ pub fn parse_members( Err(e) => { return Err(MembersLoadError::TryFromError( e, - LocalUriType::Room(LocalUri::::new( + StatefulLocalUri::Room(LocalUri::::new( room_spec.id.clone(), )), )) diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 26fb43772..3971a9158 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -22,7 +22,7 @@ use crate::{ RpcConnectionClosed, RpcConnectionEstablished, }, control::{ - local_uri::{IsMemberId, LocalUri, LocalUriType}, + local_uri::{IsMemberId, LocalUri, StatefulLocalUri}, room::RoomSpec, Endpoint as EndpointSpec, MemberId, MemberSpec, RoomId, TryFromElementError, WebRtcPlayId, WebRtcPublishId, @@ -82,7 +82,7 @@ pub enum RoomError { _0, _1 )] - WrongRoomId(LocalUriType, RoomId), + WrongRoomId(StatefulLocalUri, RoomId), } impl From for RoomError { @@ -671,22 +671,22 @@ impl Into for &mut Room { } #[derive(Message)] -#[rtype(result = "Result, RoomError>")] -pub struct SerializeProto(pub Vec); +#[rtype(result = "Result, RoomError>")] +pub struct SerializeProto(pub Vec); impl Handler for Room { - type Result = Result, RoomError>; + type Result = Result, RoomError>; fn handle( &mut self, msg: SerializeProto, _: &mut Self::Context, ) -> Self::Result { - let mut serialized: HashMap = + let mut serialized: HashMap = HashMap::new(); for uri in msg.0 { match &uri { - LocalUriType::Room(room_uri) => { + StatefulLocalUri::Room(room_uri) => { if room_uri.room_id() == &self.id { let current_room: ElementProto = self.into(); serialized.insert(uri, current_room); @@ -697,12 +697,12 @@ impl Handler for Room { )); } } - LocalUriType::Member(member_uri) => { + StatefulLocalUri::Member(member_uri) => { let member = self.members.get_member(member_uri.member_id())?; serialized.insert(uri, member.into()); } - LocalUriType::Endpoint(endpoint_uri) => { + StatefulLocalUri::Endpoint(endpoint_uri) => { let member = self.members.get_member(endpoint_uri.member_id())?; let endpoint = member.get_endpoint_by_id( @@ -902,7 +902,7 @@ impl Handler for Room { #[derive(Message, Debug)] #[rtype(result = "()")] -pub struct Delete(pub Vec); +pub struct Delete(pub Vec); impl Handler for Room { type Result = (); @@ -912,10 +912,10 @@ impl Handler for Room { let mut endpoint_ids = Vec::new(); for id in msg.0 { match id { - LocalUriType::Member(member_uri) => { + StatefulLocalUri::Member(member_uri) => { member_ids.push(member_uri); } - LocalUriType::Endpoint(endpoint_uri) => { + StatefulLocalUri::Endpoint(endpoint_uri) => { endpoint_ids.push(endpoint_uri); } // TODO (evdokimovs): better message diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index d2d3cfa2b..707f7ae1e 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -16,7 +16,7 @@ use crate::{ endpoints::Endpoint as EndpointSpec, load_static_specs_from_dir, local_uri::{ - IsEndpointId, IsMemberId, IsRoomId, LocalUri, LocalUriType, + IsEndpointId, IsMemberId, IsRoomId, LocalUri, StatefulLocalUri, }, LoadStaticControlSpecsError, MemberSpec, RoomId, RoomSpec, }, @@ -53,12 +53,12 @@ pub enum RoomServiceError { #[display(fmt = "Empty URIs list.")] EmptyUrisList, #[display(fmt = "Room not found for element [id = {}]", _0)] - RoomNotFoundForElement(LocalUriType), + RoomNotFoundForElement(StatefulLocalUri), #[display( fmt = "Provided not the same Room IDs in elements IDs [ids = {:?}].", _0 )] - NotSameRoomIds(Vec, RoomId), + NotSameRoomIds(Vec, RoomId), #[display(fmt = "Provided Room IDs with Room elements IDs.")] DeleteRoomAndFromRoom, } @@ -223,7 +223,7 @@ impl DeleteElements { } } - pub fn add_uri(&mut self, uri: LocalUriType) { + pub fn add_uri(&mut self, uri: StatefulLocalUri) { self.uris.push(uri) } @@ -237,7 +237,7 @@ impl DeleteElements { let mut ignored_uris = Vec::new(); let first_room = self.uris[0].room_id().clone(); - let uris: Vec = self + let uris: Vec = self .uris .into_iter() .filter_map(|uri| { @@ -268,7 +268,7 @@ impl DeleteElements { #[derive(Message)] #[rtype(result = "Result<(), RoomServiceError>")] pub struct DeleteElements { - uris: Vec, + uris: Vec, _state: PhantomData, } @@ -286,14 +286,15 @@ impl Handler> for RoomService { return Box::new(actix::fut::err(RoomServiceError::EmptyUrisList)); } - let mut deletes_from_room: Vec = Vec::new(); + let mut deletes_from_room: Vec = Vec::new(); + // TODO: use Vec::drain_filter when it will be in stable let room_messages_futs: Vec< Box>, > = msg .uris .into_iter() .filter_map(|l| { - if let LocalUriType::Room(room_id) = l { + if let StatefulLocalUri::Room(room_id) = l { Some(self.close_room(room_id.take_room_id())) } else { deletes_from_room.push(l); @@ -328,14 +329,13 @@ impl Handler> for RoomService { } #[derive(Message)] -#[rtype( - result = "Result, RoomServiceError>" -)] -pub struct Get(pub Vec); +#[rtype(result = "Result, \ + RoomServiceError>")] +pub struct Get(pub Vec); impl Handler for RoomService { type Result = - ActFuture, RoomServiceError>; + ActFuture, RoomServiceError>; fn handle(&mut self, msg: Get, _: &mut Self::Context) -> Self::Result { let mut rooms_elements = HashMap::new(); @@ -345,7 +345,7 @@ impl Handler for RoomService { .entry(uri.room_id().clone()) .or_insert_with(Vec::new) .push(uri); - } else if let LocalUriType::Room(room_uri) = uri { + } else if let StatefulLocalUri::Room(room_uri) = uri { return Box::new(actix::fut::err( RoomServiceError::RoomNotFound(room_uri), )); From 44c2be205eb968dd3ef1db9136ac0c3dfb2deb52 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 10 Sep 2019 17:22:48 +0300 Subject: [PATCH 607/735] Refactor, fix doc links --- .../control/endpoints/webrtc_play_endpoint.rs | 17 +- src/api/control/local_uri.rs | 219 ++++++++++-------- src/api/control/member.rs | 4 +- src/api/control/mod.rs | 3 + src/api/error_codes.rs | 23 +- .../endpoints/webrtc/play_endpoint.rs | 2 +- .../endpoints/webrtc/publish_endpoint.rs | 2 +- src/signalling/elements/member.rs | 4 +- src/signalling/participants.rs | 2 + src/signalling/peers.rs | 8 +- src/signalling/room_service.rs | 4 + 11 files changed, 170 insertions(+), 118 deletions(-) diff --git a/src/api/control/endpoints/webrtc_play_endpoint.rs b/src/api/control/endpoints/webrtc_play_endpoint.rs index 05bdbfd82..cffc81136 100644 --- a/src/api/control/endpoints/webrtc_play_endpoint.rs +++ b/src/api/control/endpoints/webrtc_play_endpoint.rs @@ -48,13 +48,24 @@ pub enum SrcParseError { /// Special uri with pattern `local://{room_id}/{member_id}/{endpoint_id}`. /// This uri can pointing only to [`WebRtcPublishEndpoint`]. +/// +/// [`WebRtcPublishEndpoint`]: +/// crate::api::control::endpoints::WebRtcPublishEndpoint #[derive(Clone, Debug)] pub struct SrcUri { - /// ID of [`Room`] + /// ID of [`Room`]. + /// + /// [`Room`]: crate::signalling::room::Room pub room_id: RoomId, - /// ID of `Member` + + /// ID of [`MemberSpec`]. + /// + /// [`MemberSpec`]: crate::api::control::member::MemberSpec pub member_id: MemberId, - /// Control ID of [`Endpoint`] + + /// Control ID of [`Endpoint`]. + /// + /// [`Endpoint`]: crate::api::control::endpoints::Endpoint pub endpoint_id: WebRtcPublishId, } diff --git a/src/api/control/local_uri.rs b/src/api/control/local_uri.rs index 82c158717..bb33c2b0e 100644 --- a/src/api/control/local_uri.rs +++ b/src/api/control/local_uri.rs @@ -1,11 +1,8 @@ //! URI for pointing to some medea element. -// Fix bug in clippy. -#![allow(clippy::use_self)] - use std::{convert::TryFrom, fmt}; -use derive_more::Display; +use derive_more::{Display, From}; use failure::Fail; use url::Url; @@ -13,6 +10,7 @@ use crate::api::control::endpoints::webrtc_play_endpoint::SrcUri; use super::{MemberId, RoomId}; +/// Error which can happen while [`LocalUri`] parsing. #[allow(clippy::module_name_repetitions)] #[derive(Debug, Fail, Display)] pub enum LocalUriParseError { @@ -22,25 +20,34 @@ pub enum LocalUriParseError { /// Too many paths in provided URI. #[display(fmt = "Too many paths in provided URI ({}).", _0)] - TooManyFields(String), + TooManyPaths(String), + /// Some paths is missing in URI. + /// + /// `local://room_id//qwerty` for example. #[display(fmt = "Missing fields. {}", _0)] - MissingFields(String), + MissingPaths(String), + /// Error while parsing URI by [`url::Url`]. #[display(fmt = "Error while parsing URL. {:?}", _0)] UrlParseErr(String, url::ParseError), - /// Provided empty `&str`. + /// Provided empty URI. #[display(fmt = "You provided empty local uri.")] Empty, } /// Enum for store all kinds of [`LocalUri`]s. #[allow(clippy::module_name_repetitions)] -#[derive(Debug, Hash, PartialEq, Eq, Clone, Display)] +#[derive(Debug, Hash, PartialEq, Eq, Clone, Display, From)] pub enum StatefulLocalUri { + /// Stores [`LocalUri`] in [`IsRoomId`] state. Room(LocalUri), + + /// Stores [`LocalUri`] in [`IsMemberId`] state. Member(LocalUri), + + /// Stores [`LocalUri`] in [`IsEndpointId`] state. Endpoint(LocalUri), } @@ -54,22 +61,93 @@ impl StatefulLocalUri { } } -/// State of [`LocalUri`] which points to `Room`. +impl TryFrom<&str> for StatefulLocalUri { + type Error = LocalUriParseError; + + fn try_from(value: &str) -> Result { + if value.is_empty() { + return Err(LocalUriParseError::Empty); + } + + let url = match Url::parse(value) { + Ok(url) => url, + Err(e) => { + return Err(LocalUriParseError::UrlParseErr( + value.to_string(), + e, + )); + } + }; + + if url.scheme() != "local" { + return Err(LocalUriParseError::NotLocal(value.to_string())); + } + + let room_uri = url + .host() + .map(|id| id.to_string()) + .filter(|id| !id.is_empty()) + .map(|id| LocalUri::::new(id.into())) + .ok_or_else(|| { + LocalUriParseError::MissingPaths(value.to_string()) + })?; + + let mut path = match url.path_segments() { + Some(path) => path, + None => return Ok(Self::from(room_uri)), + }; + + let member_id = path + .next() + .filter(|id| !id.is_empty()) + .map(|id| MemberId(id.to_string())); + + let endpoint_id = path + .next() + .filter(|id| !id.is_empty()) + .map(|id| id.to_string()); + + if path.next().is_some() { + return Err(LocalUriParseError::TooManyPaths(value.to_string())); + } + + if let Some(member_id) = member_id { + let member_uri = room_uri.push_member_id(member_id); + if let Some(endpoint_id) = endpoint_id { + Ok(Self::from(member_uri.push_endpoint_id(endpoint_id))) + } else { + Ok(Self::from(member_uri)) + } + } else if endpoint_id.is_some() { + Err(LocalUriParseError::MissingPaths(value.to_string())) + } else { + Ok(Self::from(room_uri)) + } + } +} + +/// State of [`LocalUri`] which points to [`Room`]. +/// +/// [`Room`]: crate::signalling::room::Room #[derive(Debug, PartialEq, Hash, Eq, Clone)] pub struct IsRoomId(RoomId); -/// State of [`LocalUri`] which points to `Member`. +/// State of [`LocalUri`] which points to [`Member`]. +/// +/// [`Member`]: crate::signalling::elements::member::Member #[derive(Debug, PartialEq, Hash, Eq, Clone)] pub struct IsMemberId(LocalUri, MemberId); -/// State of [`LocalUri`] which points to `Endpoint`. +/// State of [`LocalUri`] which points to [`Endpoint`]. +/// +/// [`Endpoint`]: crate::signalling::elements::endpoints::Endpoint #[derive(Debug, PartialEq, Hash, Eq, Clone)] pub struct IsEndpointId(LocalUri, String); -#[allow(clippy::doc_markdown)] -/// Uri in format "local://room_id/member_id/endpoint_id" -/// This kind of uri used for pointing to some element in spec (`Room`, -/// `Member`, `WebRtcPlayEndpoint`, `WebRtcPublishEndpoint`, etc) based on his +/// Uri in format `local://room_id/member_id/endpoint_id`. +/// +/// This kind of uri used for pointing to some element in spec ([`Room`], +/// [`Member`], [`WebRtcPlayEndpoint`], [`WebRtcPublishEndpoint`], etc) based on /// state. /// /// [`LocalUri`] can be in three states: [`IsRoomId`], [`IsMemberId`], @@ -78,8 +156,8 @@ pub struct IsEndpointId(LocalUri, String); /// /// You also can take value from [`LocalUri`] without copy, but you have to do /// it consistently. For example, if you wish to get [`RoomId`], [`MemberId`] -/// and [`EndpointId`] from [`LocalUri`] you should to make this -/// steps: +/// and [`Endpoint`] ID from [`LocalUri`] in [`IsEndpointId`] state you should +/// make this steps: /// /// ``` /// # use crate::api::control::local_uri::{LocalUri, IsEndpointId}; @@ -95,8 +173,11 @@ pub struct IsEndpointId(LocalUri, String); /// orig_endpoint_id.clone() /// ); /// -/// // We can get reference to room_id from this LocalUri but can't take room_id -/// // without this consistency. +/// // We can get reference to room_id from this LocalUri +/// // without taking ownership: +/// assert_eq!(local_uri.room_id(), &orig_member_id); +/// +/// // If you want to take all IDs ownership, you should do this steps: /// let (endpoint_id, member_uri) = local_uri.take_endpoint_id(); /// assert_eq!(endpoint_id, orig_endpoint_id); /// @@ -108,7 +189,17 @@ pub struct IsEndpointId(LocalUri, String); /// ``` /// /// This is necessary so that it is not possible to get the address in the -/// wrong state ("local://room_id//endpoint_id" for example). +/// wrong state (`local://room_id//endpoint_id` for example). +/// +/// [`Member`]: crate::signalling::elements::member::Member +/// [`Room`]: crate::signalling::room::Room +/// [`WebRtcPlayEndpoint`]: +/// crate::signalling::elements::endpoints::webrtc::WebRtcPlayEndpoint +/// +/// [`WebRtcPublishEndpoint`]: +/// crate::signalling::elements::endpoints::webrtc::WebRtcPublishEndpoint +/// +/// [`Endpoint`]: crate::signalling::elements::endpoints::Endpoint #[derive(Debug, PartialEq, Hash, Eq, Clone)] pub struct LocalUri { state: T, @@ -133,7 +224,7 @@ impl LocalUri { } /// Push [`MemberId`] to the end of URI and returns - /// [`LocalUri`]. + /// [`LocalUri`] in [`IsMemberId`]. pub fn push_member_id(self, member_id: MemberId) -> LocalUri { LocalUri::::new(self.state.0, member_id) } @@ -163,7 +254,7 @@ impl LocalUri { } /// Push endpoint ID to the end of URI and returns - /// [`LocalUri`]. + /// [`LocalUri`] in [`IsEndpointId`] state. pub fn push_endpoint_id( self, endpoint_id: String, @@ -199,12 +290,14 @@ impl LocalUri { &self.state.0.member_id() } - /// Returns reference to endpoint ID. + /// Returns reference to [`Endpoint`] ID. + /// + /// [`Endpoint`]: crate::signalling::elements::endpoints::Endpoint pub fn endpoint_id(&self) -> &str { &self.state.1 } - /// Return endpoint id and [`LocalUri`] in state [`IsMemberId`]. + /// Return endpoint id and [`LocalUri`] in [`IsMemberId`] state. pub fn take_endpoint_id(self) -> (String, LocalUri) { (self.state.1, self.state.0) } @@ -220,80 +313,6 @@ impl From for LocalUri { } } -impl TryFrom<&str> for StatefulLocalUri { - type Error = LocalUriParseError; - - fn try_from(value: &str) -> Result { - if value.is_empty() { - return Err(LocalUriParseError::Empty); - } - - let url = match Url::parse(value) { - Ok(url) => url, - Err(e) => { - return Err(LocalUriParseError::UrlParseErr( - value.to_string(), - e, - )); - } - }; - - if url.scheme() != "local" { - return Err(LocalUriParseError::NotLocal(value.to_string())); - } - - let room_id = url - .host() - .map(|id| id.to_string()) - .filter(|id| !id.is_empty()) - .map(RoomId) - .ok_or_else(|| { - LocalUriParseError::MissingFields(value.to_string()) - })?; - - let mut path = match url.path_segments() { - Some(path) => path, - None => { - return Ok(StatefulLocalUri::Room(LocalUri::::new( - room_id, - ))); - } - }; - - let member_id = path - .next() - .filter(|id| !id.is_empty()) - .map(|id| MemberId(id.to_string())); - - let endpoint_id = path - .next() - .filter(|id| !id.is_empty()) - .map(|id| id.to_string()); - - if path.next().is_some() { - return Err(LocalUriParseError::TooManyFields(value.to_string())); - } - - if let Some(member_id) = member_id { - if let Some(endpoint_id) = endpoint_id { - Ok(StatefulLocalUri::Endpoint(LocalUri::::new( - room_id, - member_id, - endpoint_id, - ))) - } else { - Ok(StatefulLocalUri::Member(LocalUri::::new( - room_id, member_id, - ))) - } - } else if endpoint_id.is_some() { - Err(LocalUriParseError::MissingFields(value.to_string())) - } else { - Ok(StatefulLocalUri::Room(LocalUri::::new(room_id))) - } - } -} - impl fmt::Display for LocalUri { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "local://{}", self.state.0) @@ -388,7 +407,7 @@ mod tests { ) { Ok(_) => unreachable!(), Err(e) => match e { - LocalUriParseError::TooManyFields(_) => (), + LocalUriParseError::TooManyPaths(_) => (), _ => unreachable!(), }, } @@ -416,7 +435,7 @@ mod tests { match StatefulLocalUri::try_from(local_uri_str) { Ok(_) => unreachable!(local_uri_str), Err(e) => match e { - LocalUriParseError::MissingFields(_) => (), + LocalUriParseError::MissingPaths(_) => (), _ => unreachable!(local_uri_str), }, } diff --git a/src/api/control/member.rs b/src/api/control/member.rs index a7553953f..7f0fb3730 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -35,13 +35,13 @@ pub enum MemberElement { /// Represent [`WebRtcPublishEndpoint`]. /// Can transform into [`Endpoint`] enum by `Endpoint::try_from`. /// - /// [`Endpoint`]: crate::api::control::endpoint::Endpoint + /// [`Endpoint`]: crate::api::control::endpoints::Endpoint WebRtcPublishEndpoint { spec: WebRtcPublishEndpoint }, /// Represent [`WebRtcPlayEndpoint`]. /// Can transform into [`Endpoint`] enum by `Endpoint::try_from`. /// - /// [`Endpoint`]: crate::api::control::endpoint::Endpoint + /// [`Endpoint`]: crate::api::control::endpoints::Endpoint WebRtcPlayEndpoint { spec: WebRtcPlayEndpoint }, } diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index 7739dbce0..141d4a227 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -33,6 +33,9 @@ pub use self::{ #[derive(Debug, Fail, Display)] pub enum TryFromProtobufError { /// Error while parsing src uri of [`WebRtcPlayEndpoint`]. + /// + /// [`WebRtcPlayEndpoint`]: + /// crate::api::control::endpoints::WebRtcPlayEndpoint #[display(fmt = "Src uri parse error: {:?}", _0)] SrcUriError(SrcParseError), diff --git a/src/api/error_codes.rs b/src/api/error_codes.rs index 10cf6bcc9..b9f6b5a00 100644 --- a/src/api/error_codes.rs +++ b/src/api/error_codes.rs @@ -41,6 +41,8 @@ pub struct ErrorResponse { /// [`Display`] implementation's text. /// /// By default this field should be [`None`]. + /// + /// [`Display`]: std::fmt::Display explanation: Option, } @@ -74,14 +76,14 @@ impl ErrorResponse { } } - pub fn custom_text( + pub fn explain( error_code: ErrorCode, - text: String, + explanation: String, id: Option, ) -> Self { Self { error_code, - explanation: Some(text), + explanation: Some(explanation), element_id: id.map(|s| s.to_string()), } } @@ -204,6 +206,9 @@ pub enum ErrorCode { /// Provided not source URI in [`WebRtcPlayEndpoint`]. /// /// Code: __1107__. + /// + /// [`WebRtcPlayEndpoint`]: + /// crate::signalling::elements::endpoints::webrtc::WebRtcPlayEndpoint #[display(fmt = "Provided not source URI.")] NotSourceUri = 1107, @@ -238,11 +243,15 @@ pub enum ErrorCode { /// Provided not the same [`RoomId`]s in elements IDs. /// /// Code: __1205__. + /// + /// [`RoomId`]: crate::api::control::room::Id #[display(fmt = "Provided not the same Room IDs in elements IDs.")] ProvidedNotSameRoomIds = 1205, /// Provided ID for [`Room`] and for [`Room`]'s elements. /// /// Code: __1206__. + /// + /// [`Room`]: crate::signalling::room::Room #[display(fmt = "Provided ID for Room and for Room's elements.")] DeleteRoomAndFromRoom = 1206, @@ -305,7 +314,7 @@ impl From for ErrorResponse { match err { TryFromProtobufError::SrcUriError(e) => e.into(), TryFromProtobufError::NotMemberElementInRoomElement(id) => { - Self::custom_text( + Self::explain( ErrorCode::UnimplementedCall, "Not Member elements in Room element currently \ unimplemented." @@ -323,11 +332,11 @@ impl From for ErrorResponse { LocalUriParseError::NotLocal(text) => { Self::new(ErrorCode::ElementIdIsNotLocal, &text) } - LocalUriParseError::TooManyFields(text) => { + LocalUriParseError::TooManyPaths(text) => { Self::new(ErrorCode::ElementIdIsTooLong, &text) } LocalUriParseError::Empty => Self::empty(ErrorCode::EmptyElementId), - LocalUriParseError::MissingFields(text) => { + LocalUriParseError::MissingPaths(text) => { Self::new(ErrorCode::MissingFieldsInSrcUri, &text) } LocalUriParseError::UrlParseErr(id, _) => { @@ -425,7 +434,7 @@ impl From for ErrorResponse { Self::new(ErrorCode::RoomNotFoundForProvidedElement, &id) } RoomServiceError::NotSameRoomIds(ids, expected_room_id) => { - Self::custom_text( + Self::explain( ErrorCode::ProvidedNotSameRoomIds, format!( "Expected Room ID: '{}'. IDs with different Room ID: \ diff --git a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs index b3eaa4796..07822f134 100644 --- a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs @@ -89,7 +89,7 @@ impl Drop for WebRtcPlayEndpointInner { /// Signalling representation of Control API's [`WebRtcPlayEndpoint`]. /// -/// [`WebRtcPlayEndpoint`]: crate::api::control::endpoint::WebRtcPlayEndpoint +/// [`WebRtcPlayEndpoint`]: crate::api::control::endpoints::WebRtcPlayEndpoint #[allow(clippy::module_name_repetitions)] #[derive(Debug, Clone)] pub struct WebRtcPlayEndpoint(Rc>); diff --git a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs index 38529088c..df793286b 100644 --- a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs @@ -103,7 +103,7 @@ impl WebRtcPublishEndpointInner { /// Signalling representation of [`WebRtcPublishEndpoint`]. /// /// [`WebRtcPublishEndpoint`]: -/// crate::api::control::endpoint::WebRtcPublishEndpoint +/// crate::api::control::endpoints::WebRtcPublishEndpoint #[allow(clippy::module_name_repetitions)] #[derive(Debug, Clone)] pub struct WebRtcPublishEndpoint(Rc>); diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index 29dc68e64..c0441e447 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -336,7 +336,7 @@ impl Member { /// Lookup [`WebRtcPublishEndpoint`] source endpoint by [`WebRtcPublishId`]. /// - /// Returns [`MeberError::PublishEndpointNotFound`] when + /// Returns [`MemberError::PublishEndpointNotFound`] when /// [`WebRtcPublishEndpoint`] not found. pub fn get_src( &self, @@ -360,7 +360,7 @@ impl Member { self.0.borrow().sinks.get(id).cloned() } - /// Lookup [`WebRtcPlayEndpoint`] sink endpoint by [`EndpointId`]. + /// Lookup [`WebRtcPlayEndpoint`] sink endpoint by [`WebRtcPlayId`]. /// /// Returns [`MemberError::PlayEndpointNotFound`] when /// [`WebRtcPlayEndpoint`] not found. diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 4cb2df2b3..10f2d22a1 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -371,6 +371,8 @@ impl ParticipantService { /// Delete [`Member`] from [`ParticipantService`], remove this user from /// [`TurnAuthService`], close RPC connection with him and remove drop /// connection task. + /// + /// [`TurnAuthService`]: crate::turn::service::TurnAuthService pub fn delete_member( &mut self, member_id: &MemberId, diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index 103bb17a8..2ef0f4273 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -174,9 +174,11 @@ impl PeerRepository { } /// Delete [`PeerStateMachine`]s from this [`PeerRepository`] and send - /// [`PeersRemoved`] to [`Member`]s. + /// [`Event::PeersRemoved`] to [`Member`]s. /// /// __Note:__ this also delete partner peers. + /// + /// [`Event::PeersRemoved`]: medea_client_api_proto::Event::PeersRemoved pub fn remove_peers( &mut self, member_id: &MemberId, @@ -245,9 +247,11 @@ impl PeerRepository { } /// Delete [`PeerStateMachine`] from this [`PeerRepository`] and send - /// [`PeersRemoved`] to [`Member`]s. + /// [`Event::PeersRemoved`] to [`Member`]s. /// /// __Note:__ this also delete partner peer. + /// + /// [`Event::PeersRemoved`]: medea_client_api_proto::Event::PeersRemoved pub fn remove_peer( &mut self, member_id: &MemberId, diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index 707f7ae1e..f09da1421 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -388,6 +388,8 @@ impl Handler for RoomService { } /// Signal for create new [`Member`] in [`Room`] +/// +/// [`Member`]: crate::signalling::elements::member::Member #[derive(Message)] #[rtype(result = "Result<(), RoomServiceError>")] pub struct CreateMemberInRoom { @@ -423,6 +425,8 @@ impl Handler for RoomService { } /// Signal for create new [`Endpoint`] in [`Room`] +/// +/// [`Endpoint`]: crate::signalling::elements::endpoints::Endpoint #[derive(Message)] #[rtype(result = "Result<(), RoomServiceError>")] pub struct CreateEndpointInRoom { From e0d83eb932b17a6edf016f37a303efdaa8faefb6 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 10 Sep 2019 17:49:48 +0300 Subject: [PATCH 608/735] Add missing docs --- src/api/control/grpc/server.rs | 81 ++++++++++++++++++++-------------- src/api/control/local_uri.rs | 5 +++ src/api/control/mod.rs | 17 +++++++ src/api/error_codes.rs | 21 ++++----- src/signalling/room_service.rs | 56 +++++++++++++++++++---- 5 files changed, 126 insertions(+), 54 deletions(-) diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index 6c2d0d428..4b34da7a6 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -38,23 +38,30 @@ use crate::{ log::prelude::*, shutdown::ShutdownGracefully, signalling::room_service::{ - CreateEndpointInRoom, CreateMemberInRoom, DeleteElements, Get, - RoomService, RoomServiceError, StartRoom, + CreateEndpointInRoom, CreateMemberInRoom, CreateRoom, DeleteElements, + Get, RoomService, RoomServiceError, }, AppContext, }; +/// Errors which can happen while processing request to gRPC [Control API]. +/// +/// [Control API]: http://tiny.cc/380uaz #[derive(Debug, Fail, Display)] -pub enum ControlApiError { +pub enum GrpcControlApiError { /// Error while parsing local URI of element. LocalUri(LocalUriParseError), - /// This error is rather abnormal, since what it catches must be caught at - /// the level of the gRPC. + /// Error which can happen while converting protoc object into interior + /// [medea] [Control API] objects. + /// + /// [Control API]: http://tiny.cc/380uaz + /// [medea]: https://github.com/instrumentisto/medea TryFromProtobuf(TryFromProtobufError), - /// This error is rather abnormal, since what it catches must be caught at - /// the level of the gRPC. + /// Some error in provided [Control API] spec. + /// + /// [Control API]: http://tiny.cc/380uaz TryFromElement(TryFromElementError), /// [`MailboxError`] for [`RoomService`]. @@ -74,27 +81,27 @@ pub enum ControlApiError { RoomServiceError(RoomServiceError), } -impl From for ControlApiError { +impl From for GrpcControlApiError { fn from(from: LocalUriParseError) -> Self { - ControlApiError::LocalUri(from) + GrpcControlApiError::LocalUri(from) } } -impl From for ControlApiError { +impl From for GrpcControlApiError { fn from(from: RoomServiceError) -> Self { Self::RoomServiceError(from) } } -impl From for ControlApiError { +impl From for GrpcControlApiError { fn from(from: TryFromProtobufError) -> Self { - ControlApiError::TryFromProtobuf(from) + GrpcControlApiError::TryFromProtobuf(from) } } -impl From for ControlApiError { +impl From for GrpcControlApiError { fn from(from: TryFromElementError) -> Self { - ControlApiError::TryFromElement(from) + GrpcControlApiError::TryFromElement(from) } } @@ -107,9 +114,9 @@ macro_rules! fut_try { match $call { Ok(o) => o, Err(e) => { - return Either::B(futures::future::err(ControlApiError::from( - e, - ))) + return Either::B(futures::future::err( + GrpcControlApiError::from(e), + )) } } }; @@ -185,7 +192,7 @@ impl ControlApiService { &mut self, req: &CreateRequest, uri: LocalUri, - ) -> impl Future { + ) -> impl Future { let room = fut_try!(RoomSpec::try_from_protobuf( uri.room_id().clone(), req.get_room() @@ -203,13 +210,13 @@ impl ControlApiService { Either::A( self.room_service - .send(StartRoom { + .send(CreateRoom { id: uri, spec: room, }) - .map_err(ControlApiError::RoomServiceMailboxError) + .map_err(GrpcControlApiError::RoomServiceMailboxError) .and_then(move |r| { - r.map_err(ControlApiError::from).map(|_| sid) + r.map_err(GrpcControlApiError::from).map(|_| sid) }), ) } @@ -219,7 +226,7 @@ impl ControlApiService { &mut self, req: &CreateRequest, uri: LocalUri, - ) -> impl Future { + ) -> impl Future { let spec = fut_try!(MemberSpec::try_from(req.get_member())); let sid = @@ -230,8 +237,10 @@ impl ControlApiService { Either::A( self.room_service .send(CreateMemberInRoom { uri, spec }) - .map_err(ControlApiError::RoomServiceMailboxError) - .and_then(|r| r.map_err(ControlApiError::from).map(|_| sids)), + .map_err(GrpcControlApiError::RoomServiceMailboxError) + .and_then(|r| { + r.map_err(GrpcControlApiError::from).map(|_| sids) + }), ) } @@ -241,7 +250,7 @@ impl ControlApiService { &mut self, req: &CreateRequest, uri: LocalUri, - ) -> impl Future { + ) -> impl Future { let endpoint = fut_try!(Endpoint::try_from(req)); Either::A( @@ -250,9 +259,9 @@ impl ControlApiService { uri, spec: endpoint, }) - .map_err(ControlApiError::RoomServiceMailboxError) + .map_err(GrpcControlApiError::RoomServiceMailboxError) .and_then(|r| { - r.map_err(ControlApiError::from).map(|_| HashMap::new()) + r.map_err(GrpcControlApiError::from).map(|_| HashMap::new()) }), ) } @@ -278,7 +287,7 @@ impl ControlApi for ControlApiService { } let response_fut: Box< - dyn Future + Send, + dyn Future + Send, > = match parse_local_uri!(req.get_id(), ctx, sink, CreateResponse) { StatefulLocalUri::Room(local_uri) => { if req.has_room() { @@ -376,8 +385,8 @@ impl ControlApi for ControlApiService { ctx.spawn( self.room_service .send(delete_elements) - .map_err(ControlApiError::RoomServiceMailboxError) - .and_then(|r| r.map_err(ControlApiError::from)) + .map_err(GrpcControlApiError::RoomServiceMailboxError) + .and_then(|r| r.map_err(GrpcControlApiError::from)) .then(move |result| { let mut response = Response::new(); if let Err(e) = result { @@ -410,8 +419,8 @@ impl ControlApi for ControlApiService { ctx.spawn( self.room_service .send(Get(uris)) - .map_err(ControlApiError::RoomServiceMailboxError) - .and_then(|r| r.map_err(ControlApiError::from)) + .map_err(GrpcControlApiError::RoomServiceMailboxError) + .and_then(|r| r.map_err(GrpcControlApiError::from)) .then(|res| { let mut response = GetResponse::new(); match res { @@ -440,7 +449,9 @@ impl ControlApi for ControlApiService { } } -/// Actor wrapper for `grcio` gRPC server. +/// Actor wrapper for `grcio` gRPC server which provides dynamic [Control API]. +/// +/// [Control API]: http://tiny.cc/380uaz #[allow(clippy::module_name_repetitions)] pub struct GrpcServer { server: Server, @@ -476,7 +487,9 @@ impl Handler for GrpcServer { } } -/// Run gRPC server in actix actor. +/// Run gRPC [Control API] server in actix actor. +/// +/// [Control API]: http://tiny.cc/380uaz pub fn run(room_repo: Addr, app: AppContext) -> Addr { let bind_ip = app.config.control.grpc.bind_ip.to_string(); let bind_port = app.config.control.grpc.bind_port; diff --git a/src/api/control/local_uri.rs b/src/api/control/local_uri.rs index bb33c2b0e..a322d7767 100644 --- a/src/api/control/local_uri.rs +++ b/src/api/control/local_uri.rs @@ -19,6 +19,8 @@ pub enum LocalUriParseError { NotLocal(String), /// Too many paths in provided URI. + /// + /// `local://room_id/member_id/endpoint_id/redundant_path` for example. #[display(fmt = "Too many paths in provided URI ({}).", _0)] TooManyPaths(String), @@ -52,6 +54,9 @@ pub enum StatefulLocalUri { } impl StatefulLocalUri { + /// Returns reference to [`RoomId`]. + /// + /// This is possible in any [`LocalUri`] state. pub fn room_id(&self) -> &RoomId { match self { StatefulLocalUri::Room(uri) => uri.room_id(), diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index 141d4a227..5413c1215 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -85,17 +85,34 @@ pub enum TryFromElementError { NotMember, } +/// Errors which can happen while loading static [Control API] specs. #[derive(From, Debug, Fail, Display)] pub enum LoadStaticControlSpecsError { + /// Default or provided in config static [Control API] specs dir not + /// exists. + /// + /// [Control API]: http://tiny.cc/380uaz #[display(fmt = "Directory with specs not found.")] SpecDirNotFound, + + /// I/O error while reading static [Control API] specs. + /// + /// [Control API]: http://tiny.cc/380uaz #[display(fmt = "I/O error while reading specs. {:?}", _0)] IoError(std::io::Error), + + /// Conflict in static [Control API] specs. + /// + /// [Control API]: http://tiny.cc/380uaz #[display( fmt = "Try from element error while loading static specs. {:?}", _0 )] TryFromElementError(TryFromElementError), + + /// Error while deserialization static [Control API] specs from YAML file. + /// + /// [Control API]: http://tiny.cc/380uaz #[display(fmt = "Error while deserialization static spec. {:?}", _0)] YamlDeserializationError(serde_yaml::Error), } diff --git a/src/api/error_codes.rs b/src/api/error_codes.rs index b9f6b5a00..7e4ed8d03 100644 --- a/src/api/error_codes.rs +++ b/src/api/error_codes.rs @@ -15,7 +15,7 @@ use medea_grpc_proto::control::Error as ErrorProto; use crate::{ api::control::{ endpoints::webrtc_play_endpoint::SrcParseError, - grpc::server::ControlApiError, local_uri::LocalUriParseError, + grpc::server::GrpcControlApiError, local_uri::LocalUriParseError, TryFromElementError, TryFromProtobufError, }, signalling::{ @@ -447,9 +447,6 @@ impl From for ErrorResponse { None, ) } - RoomServiceError::DeleteRoomAndFromRoom => { - Self::empty(ErrorCode::DeleteRoomAndFromRoom) - } RoomServiceError::RoomMailboxErr(_) | RoomServiceError::FailedToLoadStaticSpecs(_) => { Self::unknown(&err) @@ -458,15 +455,15 @@ impl From for ErrorResponse { } } -impl From for ErrorResponse { - fn from(err: ControlApiError) -> Self { +impl From for ErrorResponse { + fn from(err: GrpcControlApiError) -> Self { match err { - ControlApiError::LocalUri(e) => e.into(), - ControlApiError::TryFromProtobuf(e) => e.into(), - ControlApiError::RoomServiceError(e) => e.into(), - ControlApiError::RoomServiceMailboxError(_) - | ControlApiError::TryFromElement(_) - | ControlApiError::UnknownMailboxErr(_) => Self::unknown(&err), + GrpcControlApiError::LocalUri(e) => e.into(), + GrpcControlApiError::TryFromProtobuf(e) => e.into(), + GrpcControlApiError::RoomServiceError(e) => e.into(), + GrpcControlApiError::RoomServiceMailboxError(_) + | GrpcControlApiError::TryFromElement(_) + | GrpcControlApiError::UnknownMailboxErr(_) => Self::unknown(&err), } } } diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index f09da1421..e31150b4c 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -1,6 +1,6 @@ //! Service which control [`Room`]. -use std::collections::HashMap; +use std::{collections::HashMap, marker::PhantomData}; use actix::{ fut::wrap_future, Actor, ActorFuture, Addr, Context, Handler, MailboxError, @@ -32,35 +32,57 @@ use crate::{ }, AppContext, }; -use failure::_core::marker::PhantomData; type ActFuture = Box>; +/// Errors of [`RoomService`]. #[allow(clippy::module_name_repetitions)] #[derive(Debug, Fail, Display)] pub enum RoomServiceError { + /// [`Room`] not found in [`RoomRepository`]. #[display(fmt = "Room [id = {}] not found.", _0)] RoomNotFound(LocalUri), + + /// Wrapper for [`Room`]'s [`MailboxError`]. #[display(fmt = "Room mailbox error: {:?}", _0)] RoomMailboxErr(MailboxError), + + /// Try to create [`Room`] with [`RoomId`] which already exists in + /// [`RoomRepository`]. #[display(fmt = "Room [id = {}] already exists.", _0)] RoomAlreadyExists(LocalUri), + + /// Some error happened in [`Room`]. + /// + /// For more info read [`RoomError`] docs. #[display(fmt = "{}", _0)] RoomError(RoomError), + + /// Error which can happen while loading static [Control API] specs. + /// + /// [Control API]: http://tiny.cc/380uaz #[display(fmt = "Failed to load static specs. {:?}", _0)] FailedToLoadStaticSpecs(LoadStaticControlSpecsError), + + /// Provided empty [`LocalUri`] list. #[display(fmt = "Empty URIs list.")] EmptyUrisList, + + /// Provided [`LocalUri`] to some element from [`Room`] but [`Room`] with + /// ID from this [`LocalUri`] not found in [`RoomRepository`]. #[display(fmt = "Room not found for element [id = {}]", _0)] RoomNotFoundForElement(StatefulLocalUri), + + /// Provided not the same [`RoomId`]s in [`LocalUri`] list. + /// + /// Atm this error can happen in `Delete` method because `Delete` should be + /// called only for one [`Room`]. #[display( fmt = "Provided not the same Room IDs in elements IDs [ids = {:?}].", _0 )] NotSameRoomIds(Vec, RoomId), - #[display(fmt = "Provided Room IDs with Room elements IDs.")] - DeleteRoomAndFromRoom, } impl From for RoomServiceError { @@ -87,6 +109,7 @@ pub struct RoomService { } impl RoomService { + /// Create new [`RoomService`]. pub fn new( room_repo: RoomRepository, app: AppContext, @@ -99,6 +122,9 @@ impl RoomService { } } + /// Closes [`Room`] with provided [`RoomId`]. + /// + /// This is also deletes this [`Room`] from [`RoomRepository`]. fn close_room( &self, id: RoomId, @@ -173,19 +199,22 @@ impl Handler for RoomService { } } +/// Implementation of [Control API]'s `Create` method. +/// +/// [Control API]: http://tiny.cc/380uaz #[derive(Message)] #[rtype(result = "Result<(), RoomServiceError>")] -pub struct StartRoom { +pub struct CreateRoom { pub id: LocalUri, pub spec: RoomSpec, } -impl Handler for RoomService { +impl Handler for RoomService { type Result = Result<(), RoomServiceError>; fn handle( &mut self, - msg: StartRoom, + msg: CreateRoom, _ctx: &mut Self::Context, ) -> Self::Result { let room_id = msg.id.take_room_id(); @@ -212,7 +241,13 @@ impl Handler for RoomService { } } +/// State which indicates that [`DeleteElements`] message was validated and can +/// be send to [`RoomService`]. pub struct Validated; + +/// State which indicates that [`DeleteElements`] message is unvalidated and +/// should be validated with `validate()` function of [`DeleteElements`] in +/// [`Unvalidated`] state. pub struct Unvalidated; impl DeleteElements { @@ -264,7 +299,9 @@ impl DeleteElements { } } -/// Signal for delete [`Room`]. +/// Signal for delete [Control API] elements. +/// +/// [Control API]: http://tiny.cc/380uaz #[derive(Message)] #[rtype(result = "Result<(), RoomServiceError>")] pub struct DeleteElements { @@ -328,6 +365,9 @@ impl Handler> for RoomService { } } +/// Implementation of [Control API]'s `Get` method. +/// +/// [Control API]: http://tiny.cc/380uaz #[derive(Message)] #[rtype(result = "Result, \ RoomServiceError>")] From 7340fb45d8f0491b632ee4bc4be5e2f0e8c27843 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 10 Sep 2019 18:30:56 +0300 Subject: [PATCH 609/735] Refactor, add missing docs --- Makefile | 3 ++- {build => _build}/medea/Dockerfile | 0 src/api/control/local_uri.rs | 10 ++++++---- src/api/control/pipeline.rs | 1 + src/api/error_codes.rs | 29 +++++++++++------------------ src/conf/control.rs | 7 ++++++- src/lib.rs | 6 ++++++ src/signalling/room.rs | 4 ++++ src/signalling/room_repo.rs | 4 ++++ src/signalling/room_service.rs | 4 ++++ 10 files changed, 44 insertions(+), 24 deletions(-) rename {build => _build}/medea/Dockerfile (100%) diff --git a/Makefile b/Makefile index 0c43ad9e4..f75f3622e 100644 --- a/Makefile +++ b/Makefile @@ -397,7 +397,7 @@ docker.build.demo: # make docker.build.medea-build docker.build.medea-build: - docker build -t medea-build -f build/medea/Dockerfile . + docker build -t medea-build -f _build/medea/Dockerfile . # Build medea project Docker image. @@ -705,6 +705,7 @@ build.jason: .PHONY: build build.jason build.medea \ cargo cargo.build cargo.fmt cargo.lint \ docker.build.demo docker.build.medea docker.down.demo docker.up.demo \ + docker.build.medea-build \ docs docs.rust \ down down.demo down.coturn down.medea \ helm helm.down helm.init helm.lint helm.list \ diff --git a/build/medea/Dockerfile b/_build/medea/Dockerfile similarity index 100% rename from build/medea/Dockerfile rename to _build/medea/Dockerfile diff --git a/src/api/control/local_uri.rs b/src/api/control/local_uri.rs index a322d7767..6879a71f8 100644 --- a/src/api/control/local_uri.rs +++ b/src/api/control/local_uri.rs @@ -180,7 +180,7 @@ pub struct IsEndpointId(LocalUri, String); /// /// // We can get reference to room_id from this LocalUri /// // without taking ownership: -/// assert_eq!(local_uri.room_id(), &orig_member_id); +/// assert_eq!(local_uri.room_id(), &orig_room_id); /// /// // If you want to take all IDs ownership, you should do this steps: /// let (endpoint_id, member_uri) = local_uri.take_endpoint_id(); @@ -229,7 +229,7 @@ impl LocalUri { } /// Push [`MemberId`] to the end of URI and returns - /// [`LocalUri`] in [`IsMemberId`]. + /// [`LocalUri`] in [`IsMemberId`] state. pub fn push_member_id(self, member_id: MemberId) -> LocalUri { LocalUri::::new(self.state.0, member_id) } @@ -271,7 +271,7 @@ impl LocalUri { } impl LocalUri { - /// Create new [`LocalUri`] in [`IsEndpointId`] state. + /// Creates new [`LocalUri`] in [`IsEndpointId`] state. pub fn new( room_id: RoomId, member_id: MemberId, @@ -302,7 +302,9 @@ impl LocalUri { &self.state.1 } - /// Return endpoint id and [`LocalUri`] in [`IsMemberId`] state. + /// Returns [`Endpoint`] id and [`LocalUri`] in [`IsMemberId`] state. + /// + /// [`Endpoint`]: crate::signalling::elements::endpoints::Endpoint pub fn take_endpoint_id(self) -> (String, LocalUri) { (self.state.1, self.state.0) } diff --git a/src/api/control/pipeline.rs b/src/api/control/pipeline.rs index 973c58e04..82b79ccd1 100644 --- a/src/api/control/pipeline.rs +++ b/src/api/control/pipeline.rs @@ -19,6 +19,7 @@ pub struct Pipeline { } impl Pipeline { + /// Creates new [`Pipeline`] from provided [`HashMap`]. pub fn new(pipeline: HashMap) -> Self { Self { pipeline } } diff --git a/src/api/error_codes.rs b/src/api/error_codes.rs index 7e4ed8d03..42dfae495 100644 --- a/src/api/error_codes.rs +++ b/src/api/error_codes.rs @@ -1,11 +1,12 @@ //! All errors which medea can return to control API user. //! //! # Error codes ranges -//! * __1000...1000__ Unknow server error +//! * __1000...1000__ Unexpected server error //! * __1001...1099__ Not found errors //! * __1100...1199__ Spec errors //! * __1200...1299__ Parse errors //! * __1300...1399__ Conflicts +//! * __1400...1499__ Misc errors use std::string::ToString; @@ -70,12 +71,16 @@ impl ErrorResponse { /// Provide unexpected `Error` in this function. pub fn unknown(unknown_error: &B) -> Self { Self { - error_code: ErrorCode::UnknownError, + error_code: ErrorCode::UnexpectedError, explanation: Some(unknown_error.to_string()), element_id: None, } } + /// [`ErrorResponse`] with some additional info. + /// + /// With this method you can add additional text to error message of + /// [`ErrorCode`]. pub fn explain( error_code: ErrorCode, explanation: String, @@ -115,7 +120,7 @@ impl Into for ErrorResponse { /// Medea control API errors. #[derive(Display)] pub enum ErrorCode { - /// Unknown server error. + /// Unexpected server error. /// /// Use this [`ErrorCode`] only with [`ErrorResponse::unknown`] function. /// In error text with this code should be error message which explain what @@ -123,7 +128,7 @@ pub enum ErrorCode { /// /// Code: __1000__. #[display(fmt = "Unexpected error happened.")] - UnknownError = 1000, + UnexpectedError = 1000, //////////////////////////////////// // Not found (1001 - 1099 codes) // @@ -198,19 +203,14 @@ pub enum ErrorCode { #[display(fmt = "You provided ID for Endpoint but element's spec is not \ for Endpoint.")] ElementIdForEndpointButElementIsNot = 1105, - /// Invalid ID for element. - /// - /// Code: __1106__ - #[display(fmt = "Invalid element's URI.")] - InvalidElementUri = 1106, /// Provided not source URI in [`WebRtcPlayEndpoint`]. /// - /// Code: __1107__. + /// Code: __1106__. /// /// [`WebRtcPlayEndpoint`]: /// crate::signalling::elements::endpoints::webrtc::WebRtcPlayEndpoint #[display(fmt = "Provided not source URI.")] - NotSourceUri = 1107, + NotSourceUri = 1106, ///////////////////////////////// // Parse errors (1200 - 1299) // @@ -247,13 +247,6 @@ pub enum ErrorCode { /// [`RoomId`]: crate::api::control::room::Id #[display(fmt = "Provided not the same Room IDs in elements IDs.")] ProvidedNotSameRoomIds = 1205, - /// Provided ID for [`Room`] and for [`Room`]'s elements. - /// - /// Code: __1206__. - /// - /// [`Room`]: crate::signalling::room::Room - #[display(fmt = "Provided ID for Room and for Room's elements.")] - DeleteRoomAndFromRoom = 1206, ///////////////////////////// // Conflict (1300 - 1399) // diff --git a/src/conf/control.rs b/src/conf/control.rs index 06cdbe688..7e425afed 100644 --- a/src/conf/control.rs +++ b/src/conf/control.rs @@ -1,7 +1,12 @@ -use crate::conf::Grpc; +//! [Control API] settings. +//! +//! [Control API]: http://tiny.cc/380uaz + use serde::{Deserialize, Serialize}; use smart_default::SmartDefault; +use crate::conf::Grpc; + /// [Control API] settings. /// /// [Control API]: http://tiny.cc/380uaz diff --git a/src/lib.rs b/src/lib.rs index 0731f3577..f10016153 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -17,11 +17,17 @@ use crate::{conf::Conf, turn::TurnAuthService}; /// Global app context. #[derive(Debug, Clone)] pub struct AppContext { + /// [Medea] configuration. + /// + /// [Medea]: https://github.com/instrumentisto/medea pub config: Arc, + + /// Reference to [`TurnAuthService`]. pub turn_service: Arc, } impl AppContext { + /// Creates new [`AppContext`]. pub fn new(config: Conf, turn: Arc) -> Self { Self { config: Arc::new(config), diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 3971a9158..5c50b9c17 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -670,6 +670,8 @@ impl Into for &mut Room { } } +/// Message for serializing this [`Room`] and [`Room`] elements to protobuf +/// spec. #[derive(Message)] #[rtype(result = "Result, RoomError>")] pub struct SerializeProto(pub Vec); @@ -867,6 +869,7 @@ impl Handler for Room { } } +/// Signal for closing this [`Room`]. #[derive(Message, Debug)] #[rtype(result = "()")] pub struct Close; @@ -900,6 +903,7 @@ impl Handler for Room { } } +/// Signal for delete elements from this [`Room`]. #[derive(Message, Debug)] #[rtype(result = "()")] pub struct Delete(pub Vec); diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs index abfafe840..ab81c5b59 100644 --- a/src/signalling/room_repo.rs +++ b/src/signalling/room_repo.rs @@ -31,14 +31,18 @@ impl RoomRepository { rooms.get(id).cloned() } + /// Removes [`Room`] from [`RoomRepository`] by [`RoomId`]. pub fn remove(&self, id: &RoomId) { self.rooms.lock().unwrap().remove(id); } + /// Adds new [`Room`] into [`RoomRepository`]. pub fn add(&self, id: RoomId, room: Addr) { self.rooms.lock().unwrap().insert(id, room); } + /// Check existence of [`Room`] in [`RoomRepository`] by provided + /// [`RoomId`]. pub fn is_contains_room_with_id(&self, id: &RoomId) -> bool { self.rooms.lock().unwrap().contains_key(id) } diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index e31150b4c..8d4bd6980 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -105,6 +105,10 @@ pub struct RoomService { /// Global app context. app: AppContext, + /// Address to [`GracefulShutdown`]. + /// + /// Use for subscribe newly created [`Room`]s to [`GracefulShutdown`] and + /// unsubscribe deleted [`Room`]s from [`GracefulShutdown`]. graceful_shutdown: Addr, } From 78d0f11a3f7b7359aa373e2b5cd41126899a911b Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 10 Sep 2019 20:25:29 +0300 Subject: [PATCH 610/735] Reread [run ci] --- .dockerignore | 3 +- _build/medea/Dockerfile | 6 +- src/api/control/endpoints/mod.rs | 3 + .../control/endpoints/webrtc_play_endpoint.rs | 19 ++- src/api/control/grpc/mod.rs | 4 +- src/api/control/grpc/server.rs | 143 +++++++++--------- src/api/control/local_uri.rs | 30 ++-- src/api/control/member.rs | 11 +- src/api/control/mod.rs | 35 ++++- src/api/control/pipeline.rs | 12 +- src/api/error_codes.rs | 81 +++++----- src/bin/client.rs | 7 + src/conf/client.rs | 13 +- src/conf/control.rs | 3 + src/conf/grpc.rs | 8 +- src/main.rs | 7 +- src/signalling/elements/endpoints/mod.rs | 3 +- .../endpoints/webrtc/publish_endpoint.rs | 1 + src/signalling/elements/member.rs | 26 ++-- src/signalling/participants.rs | 15 +- src/signalling/peers.rs | 4 +- src/signalling/room.rs | 5 +- src/signalling/room_service.rs | 6 +- 23 files changed, 273 insertions(+), 172 deletions(-) diff --git a/.dockerignore b/.dockerignore index 746486524..c0efd9e8d 100644 --- a/.dockerignore +++ b/.dockerignore @@ -4,7 +4,6 @@ !Cargo.toml !Cargo.lock !src/ -!build.rs # Medea uses this sub-crates. !crates/ @@ -18,6 +17,8 @@ # Medea dependencies cache. !.cache/cargo/ +# Here we have some scripts which install missing toolchains for CI +# but it usable for Docker images also. !_ci # !target/{mode} is added and removed dynamically to reduce image build times. diff --git a/_build/medea/Dockerfile b/_build/medea/Dockerfile index 5aeabd608..19f3e8196 100644 --- a/_build/medea/Dockerfile +++ b/_build/medea/Dockerfile @@ -9,16 +9,18 @@ ARG rustc_mode=release ARG rustc_opts=--release ARG cargo_home=/usr/local/cargo +COPY / /app/ + # Create the user and group files that will be used in the running container to # run the process as an unprivileged user. RUN mkdir -p /out/etc/ \ && echo 'nobody:x:65534:65534:nobody:/:' > /out/etc/passwd \ && echo 'nobody:x:65534:' > /out/etc/group +RUN bash /app/_ci/protoc_install.sh + RUN apt-get update RUN apt-get install -y cmake golang ENV GOPATH /usr/lib/go -COPY / /app/ -RUN bash /app/_ci/protoc_install.sh WORKDIR "/app" diff --git a/src/api/control/endpoints/mod.rs b/src/api/control/endpoints/mod.rs index df50f182a..100e05b58 100644 --- a/src/api/control/endpoints/mod.rs +++ b/src/api/control/endpoints/mod.rs @@ -20,7 +20,10 @@ pub use webrtc_publish_endpoint::WebRtcPublishEndpoint; /// flow through. #[derive(Debug)] pub enum Endpoint { + /// [`WebRtcPublishEndpoint`] element. WebRtcPublish(WebRtcPublishEndpoint), + + /// [`WebRtcPlayEndpoint`] element. WebRtcPlay(WebRtcPlayEndpoint), } diff --git a/src/api/control/endpoints/webrtc_play_endpoint.rs b/src/api/control/endpoints/webrtc_play_endpoint.rs index cffc81136..fc9361438 100644 --- a/src/api/control/endpoints/webrtc_play_endpoint.rs +++ b/src/api/control/endpoints/webrtc_play_endpoint.rs @@ -1,4 +1,4 @@ -//! `WebRtcPlayEndpoint` implementation. +//! `WebRtcPlayEndpoint` element implementation. use std::{convert::TryFrom, fmt}; @@ -38,10 +38,17 @@ impl TryFrom<&WebRtcPlayEndpointProto> for WebRtcPlayEndpoint { } } +/// Errors which can happen while parsing [`SrcUri`] from [Control API] specs. +/// +/// [Control API]: http://tiny.cc/380uaz #[derive(Debug, Fail, Display)] pub enum SrcParseError { + /// Provided not source URI. #[display(fmt = "Provided not src uri {}", _0)] NotSrcUri(String), + + /// Error from [`LocalUri`] parser. This is general errors for [`SrcUri`] + /// parsing because [`SrcUri`] parses with [`LocalUri`] parser. #[display(fmt = "Local URI '{}' parse error: {:?}", _0, _1)] LocalUriParseError(String, LocalUriParseError), } @@ -49,6 +56,12 @@ pub enum SrcParseError { /// Special uri with pattern `local://{room_id}/{member_id}/{endpoint_id}`. /// This uri can pointing only to [`WebRtcPublishEndpoint`]. /// +/// Note that [`SrcUri`] parsing with [`LocalUri`] parser. +/// Actually difference between [`SrcUri`] and [`LocalUri`] +/// in endpoint ID's type. In [`SrcUri`] it [`WebRtcPublishId`], and in +/// [`LocalUri`] it [`String`]. Also [`SrcUri`] can be deserialized with +/// [`serde`]. +/// /// [`WebRtcPublishEndpoint`]: /// crate::api::control::endpoints::WebRtcPublishEndpoint #[derive(Clone, Debug)] @@ -99,8 +112,10 @@ impl From> for SrcUri { } } -/// Serde deserializer for [`SrcUri`]. +/// [Serde] deserializer for [`SrcUri`]. /// Deserialize URIs with pattern `local://{room_id}/{member_id}/{endpoint_id}`. +/// +/// [Serde]: serde impl<'de> Deserialize<'de> for SrcUri { fn deserialize(deserializer: D) -> Result where diff --git a/src/api/control/grpc/mod.rs b/src/api/control/grpc/mod.rs index 03e5f96fc..6243fe909 100644 --- a/src/api/control/grpc/mod.rs +++ b/src/api/control/grpc/mod.rs @@ -1,3 +1,5 @@ -//! Implementation of gRPC server and generated gRPC protos. +//! Implementation of [Control API] gRPC server. +//! +//! [Control API]: http://tiny.cc/380uaz pub mod server; diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index 4b34da7a6..54b45057c 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -44,15 +44,15 @@ use crate::{ AppContext, }; -/// Errors which can happen while processing request to gRPC [Control API]. +/// Errors which can happen while processing requests to gRPC [Control API]. /// /// [Control API]: http://tiny.cc/380uaz #[derive(Debug, Fail, Display)] pub enum GrpcControlApiError { - /// Error while parsing local URI of element. + /// Error while parsing [`LocalUri`] of element. LocalUri(LocalUriParseError), - /// Error which can happen while converting protoc object into interior + /// Error which can happen while converting protobuf objects into interior /// [medea] [Control API] objects. /// /// [Control API]: http://tiny.cc/380uaz @@ -69,7 +69,7 @@ pub enum GrpcControlApiError { RoomServiceMailboxError(MailboxError), /// [`MailboxError`] which never can happen. This error needed - /// for `fut_try!` macro because they use `From` trait. + /// for [`fut_try!`] macro because using [`From`] trait. /// With this error we cover [`MailboxError`] in places where /// it cannot happen. /// @@ -77,7 +77,7 @@ pub enum GrpcControlApiError { #[display(fmt = "Mailbox error which never can happen. {:?}", _0)] UnknownMailboxErr(MailboxError), - /// Wrapper aroung [`RoomServiceError`]. + /// Wrapper around [`RoomServiceError`]. RoomServiceError(RoomServiceError), } @@ -139,10 +139,10 @@ macro_rules! parse_local_uri { /// Macro for send [`Error`] to client and `return` from current function. /// -/// `$error_code` - some object which can tranform into [`Error`] by `Into` +/// `$error_code` - some object which can converts into [`Error`] by [`Into`] /// trait. /// -/// `$response` - is type of response ([`GetResponse`], [`Response`] +/// `$response` - type of response ([`GetResponse`], [`Response`] /// etc). /// /// `$ctx` - context where `Future` for send gRPC response will be spawned. @@ -175,6 +175,8 @@ struct ControlApiService { } impl ControlApiService { + /// Returns [Control API] sid based on provided arguments and + /// `MEDEA_CLIENT.PUBLIC_URL` config value. fn get_sid( &self, room_id: &RoomId, @@ -187,18 +189,18 @@ impl ControlApiService { ) } - /// Implementation of `Create` method for `Room` element. + /// Implementation of `Create` method for [`Room`]. pub fn create_room( &mut self, req: &CreateRequest, uri: LocalUri, ) -> impl Future { - let room = fut_try!(RoomSpec::try_from_protobuf( + let spec = fut_try!(RoomSpec::try_from_protobuf( uri.room_id().clone(), req.get_room() )); - let sid: HashMap = fut_try!(room.members()) + let sid: HashMap = fut_try!(spec.members()) .iter() .map(|(id, member)| { let uri = @@ -210,10 +212,7 @@ impl ControlApiService { Either::A( self.room_service - .send(CreateRoom { - id: uri, - spec: room, - }) + .send(CreateRoom { uri, spec }) .map_err(GrpcControlApiError::RoomServiceMailboxError) .and_then(move |r| { r.map_err(GrpcControlApiError::from).map(|_| sid) @@ -221,7 +220,7 @@ impl ControlApiService { ) } - /// Implementation of `Create` method for `Member` element. + /// Implementation of `Create` method for [`Member`] element. pub fn create_member( &mut self, req: &CreateRequest, @@ -244,21 +243,17 @@ impl ControlApiService { ) } - /// Implementation of `Create` method for `WebRtcPublishEndpoint` and - /// `WebRtcPlayEndpoint` elements. + /// Implementation of `Create` method for [`Endpoint`] elements. pub fn create_endpoint( &mut self, req: &CreateRequest, uri: LocalUri, ) -> impl Future { - let endpoint = fut_try!(Endpoint::try_from(req)); + let spec = fut_try!(Endpoint::try_from(req)); Either::A( self.room_service - .send(CreateEndpointInRoom { - uri, - spec: endpoint, - }) + .send(CreateEndpointInRoom { uri, spec }) .map_err(GrpcControlApiError::RoomServiceMailboxError) .and_then(|r| { r.map_err(GrpcControlApiError::from).map(|_| HashMap::new()) @@ -268,7 +263,9 @@ impl ControlApiService { } impl ControlApi for ControlApiService { - /// Implementation for `Create` method of gRPC control API. + /// Implementation for `Create` method of gRPC [Control API]. + /// + /// [Control API]: http://tiny.cc/380uaz fn create( &mut self, ctx: RpcContext, @@ -286,37 +283,40 @@ impl ControlApi for ControlApiService { }; } - let response_fut: Box< - dyn Future + Send, - > = match parse_local_uri!(req.get_id(), ctx, sink, CreateResponse) { - StatefulLocalUri::Room(local_uri) => { - if req.has_room() { - Box::new(self.create_room(&req, local_uri)) - } else { - send_error_response_code!( - ErrorCode::ElementIdForRoomButElementIsNot - ); + type CreateFuture = + Box + Send>; + + let response_fut: CreateFuture = + match parse_local_uri!(req.get_id(), ctx, sink, CreateResponse) { + StatefulLocalUri::Room(local_uri) => { + if req.has_room() { + Box::new(self.create_room(&req, local_uri)) + } else { + send_error_response_code!( + ErrorCode::ElementIdForRoomButElementIsNot + ); + } } - } - StatefulLocalUri::Member(local_uri) => { - if req.has_member() { - Box::new(self.create_member(&req, local_uri)) - } else { - send_error_response_code!( - ErrorCode::ElementIdForMemberButElementIsNot - ); + StatefulLocalUri::Member(local_uri) => { + if req.has_member() { + Box::new(self.create_member(&req, local_uri)) + } else { + send_error_response_code!( + ErrorCode::ElementIdForMemberButElementIsNot + ); + } } - } - StatefulLocalUri::Endpoint(local_uri) => { - if req.has_webrtc_pub() || req.has_webrtc_play() { - Box::new(self.create_endpoint(&req, local_uri)) - } else { - send_error_response_code!( - ErrorCode::ElementIdForEndpointButElementIsNot - ); + StatefulLocalUri::Endpoint(local_uri) => { + if req.has_webrtc_pub() || req.has_webrtc_play() { + Box::new(self.create_endpoint(&req, local_uri)) + } else { + send_error_response_code!( + ErrorCode::ElementIdForEndpointButElementIsNot + ); + } } - } - }; + }; + ctx.spawn(response_fut.then(move |result| { let mut response = CreateResponse::new(); match result { @@ -331,11 +331,13 @@ impl ControlApi for ControlApiService { })); } - /// Implementation for `Apply` method of gRPC control API. + /// Implementation for `Apply` method of gRPC [Control API]. + /// + /// [Control API]: http://tiny.cc/380uaz fn apply( &mut self, ctx: RpcContext, - _req: ApplyRequest, + _: ApplyRequest, sink: UnarySink, ) { ctx.spawn( @@ -355,22 +357,24 @@ impl ControlApi for ControlApiService { ); } - /// Implementation for `Delete` method of gRPC control API. + /// Implementation for `Delete` method of gRPC [Control API]. + /// + /// [Control API]: http://tiny.cc/380uaz fn delete( &mut self, ctx: RpcContext, req: IdRequest, sink: UnarySink, ) { - let mut delete_elements = DeleteElements::new(); + let mut delete_elements_msg = DeleteElements::new(); for id in req.get_id() { let uri: StatefulLocalUri = parse_local_uri!(id, ctx, sink, Response); - delete_elements.add_uri(uri); + delete_elements_msg.add_uri(uri); } - let delete_elements = match delete_elements.validate() { + let delete_elements_msg = match delete_elements_msg.validate() { Ok(d) => d, Err(e) => { send_error_response!( @@ -384,7 +388,7 @@ impl ControlApi for ControlApiService { ctx.spawn( self.room_service - .send(delete_elements) + .send(delete_elements_msg) .map_err(GrpcControlApiError::RoomServiceMailboxError) .and_then(|r| r.map_err(GrpcControlApiError::from)) .then(move |result| { @@ -404,7 +408,9 @@ impl ControlApi for ControlApiService { ); } - /// Implementation for `Get` method of gRPC control API. + /// Implementation for `Get` method of gRPC [Control API]. + /// + /// [Control API]: http://tiny.cc/380uaz fn get( &mut self, ctx: RpcContext, @@ -416,6 +422,7 @@ impl ControlApi for ControlApiService { let local_uri = parse_local_uri!(id, ctx, sink, GetResponse); uris.push(local_uri); } + ctx.spawn( self.room_service .send(Get(uris)) @@ -449,19 +456,18 @@ impl ControlApi for ControlApiService { } } -/// Actor wrapper for `grcio` gRPC server which provides dynamic [Control API]. +/// Actor wrapper for [`grcio`] gRPC server which provides dynamic [Control +/// API]. /// /// [Control API]: http://tiny.cc/380uaz #[allow(clippy::module_name_repetitions)] -pub struct GrpcServer { - server: Server, -} +pub struct GrpcServer(Server); impl Actor for GrpcServer { type Context = Context; fn started(&mut self, _ctx: &mut Self::Context) { - self.server.start(); + self.0.start(); info!("gRPC Control API server started."); } } @@ -478,9 +484,10 @@ impl Handler for GrpcServer { "gRPC Control API server received ShutdownGracefully message so \ shutting down.", ); - Box::new(self.server.shutdown().map_err(|e| { + Box::new(self.0.shutdown().map_err(|e| { warn!( - "Error while graceful shutdown of gRPC Contro API server: {:?}", + "Error while graceful shutdown of gRPC Control API server: \ + {:?}", e ) })) @@ -509,7 +516,5 @@ pub fn run(room_repo: Addr, app: AppContext) -> Addr { .build() .unwrap(); - GrpcServer::start_in_arbiter(&Arbiter::new(), move |_| GrpcServer { - server, - }) + GrpcServer::start_in_arbiter(&Arbiter::new(), move |_| GrpcServer(server)) } diff --git a/src/api/control/local_uri.rs b/src/api/control/local_uri.rs index 6879a71f8..57771af66 100644 --- a/src/api/control/local_uri.rs +++ b/src/api/control/local_uri.rs @@ -39,7 +39,7 @@ pub enum LocalUriParseError { Empty, } -/// Enum for store all kinds of [`LocalUri`]s. +/// Enum for store [`LocalUri`]s in all states. #[allow(clippy::module_name_repetitions)] #[derive(Debug, Hash, PartialEq, Eq, Clone, Display, From)] pub enum StatefulLocalUri { @@ -167,6 +167,7 @@ pub struct IsEndpointId(LocalUri, String); /// ``` /// # use crate::api::control::local_uri::{LocalUri, IsEndpointId}; /// # use crate::api::control::{RoomId, MemberId}; +/// # /// let orig_room_id = RoomId("room".to_string()); /// let orig_member_id = MemberId("member".to_string()); /// let orig_endpoint_id = "endpoint".to_string(); @@ -200,10 +201,8 @@ pub struct IsEndpointId(LocalUri, String); /// [`Room`]: crate::signalling::room::Room /// [`WebRtcPlayEndpoint`]: /// crate::signalling::elements::endpoints::webrtc::WebRtcPlayEndpoint -/// /// [`WebRtcPublishEndpoint`]: /// crate::signalling::elements::endpoints::webrtc::WebRtcPublishEndpoint -/// /// [`Endpoint`]: crate::signalling::elements::endpoints::Endpoint #[derive(Debug, PartialEq, Hash, Eq, Clone)] pub struct LocalUri { @@ -357,13 +356,17 @@ mod tests { let local_uri = StatefulLocalUri::try_from("local://room_id/room_element_id") .unwrap(); - if let StatefulLocalUri::Member(member) = local_uri { + if let StatefulLocalUri::Member(member) = local_uri.clone() { let (element_id, room_uri) = member.take_member_id(); assert_eq!(element_id, MemberId("room_element_id".to_string())); let room_id = room_uri.take_room_id(); assert_eq!(room_id, RoomId("room_id".to_string())); } else { - unreachable!(); + unreachable!( + "Local URI '{}' parsed to {:?} state but should be in \ + IsMemberId state.", + local_uri, local_uri + ); } } @@ -373,7 +376,7 @@ mod tests { "local://room_id/room_element_id/endpoint_id", ) .unwrap(); - if let StatefulLocalUri::Endpoint(endpoint) = local_uri { + if let StatefulLocalUri::Endpoint(endpoint) = local_uri.clone() { let (endpoint_id, member_uri) = endpoint.take_endpoint_id(); assert_eq!(endpoint_id, "endpoint_id".to_string()); let (member_id, room_uri) = member_uri.take_member_id(); @@ -381,7 +384,11 @@ mod tests { let room_id = room_uri.take_room_id(); assert_eq!(room_id, RoomId("room_id".to_string())); } else { - unreachable!(); + unreachable!( + "Local URI '{}' parsed to {:?} state but should be in \ + IsEndpointId state.", + local_uri, local_uri + ); } } @@ -402,7 +409,7 @@ mod tests { Ok(_) => unreachable!(), Err(e) => match e { LocalUriParseError::Empty => (), - _ => unreachable!(), + _ => unreachable!("Unreachable LocalUriParseError: {:?}", e), }, } } @@ -415,7 +422,7 @@ mod tests { Ok(_) => unreachable!(), Err(e) => match e { LocalUriParseError::TooManyPaths(_) => (), - _ => unreachable!(), + _ => unreachable!("Unreachable LocalUriParseError: {:?}", e), }, } } @@ -443,7 +450,10 @@ mod tests { Ok(_) => unreachable!(local_uri_str), Err(e) => match e { LocalUriParseError::MissingPaths(_) => (), - _ => unreachable!(local_uri_str), + _ => unreachable!( + "Unreachable LocalUriParseError {:?} for uri '{}'", + e, local_uri_str + ), }, } } diff --git a/src/api/control/member.rs b/src/api/control/member.rs index 7f0fb3730..f5c6c9095 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -2,7 +2,7 @@ //! //! [Control API]: http://tiny.cc/380uaz -use std::{collections::HashMap as StdHashMap, convert::TryFrom}; +use std::{collections::HashMap, convert::TryFrom}; use derive_more::{Display, From}; use medea_grpc_proto::control::Member as MemberProto; @@ -109,6 +109,12 @@ impl MemberSpec { } } +/// Generates [`Member`] alphanumeric credentials with +/// [`MEMBER_CREDENTIALS_LEN`] length. +/// +/// This credentials will be generated if in dynamic [Control API] spec not +/// provided credentials for [`Member`]. This logic you can find in [`TryFrom`] +/// [`MemberProto`] implemented for [`MemberSpec`]. fn generate_member_credentials() -> String { rand::thread_rng() .sample_iter(&Alphanumeric) @@ -121,7 +127,7 @@ impl TryFrom<&MemberProto> for MemberSpec { /// Serialize [`MemberSpec`] from protobuf object. fn try_from(value: &MemberProto) -> Result { - let mut pipeline = StdHashMap::new(); + let mut pipeline = HashMap::new(); for (id, member_element) in value.get_pipeline() { let endpoint = Endpoint::try_from(member_element)?; pipeline.insert(id.clone(), endpoint.into()); @@ -135,7 +141,6 @@ impl TryFrom<&MemberProto> for MemberSpec { proto_credentials.to_string() }; - // Credentials here maybe absent. Ok(Self { pipeline, credentials, diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index 5413c1215..c5d708104 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -11,7 +11,7 @@ pub mod room; use std::{convert::TryFrom as _, fs::File, io::Read as _, path::Path}; -use derive_more::{Display, From}; +use derive_more::Display; use failure::Fail; use serde::Deserialize; @@ -86,14 +86,17 @@ pub enum TryFromElementError { } /// Errors which can happen while loading static [Control API] specs. -#[derive(From, Debug, Fail, Display)] +#[derive(Debug, Fail, Display)] pub enum LoadStaticControlSpecsError { - /// Default or provided in config static [Control API] specs dir not - /// exists. + /// Error while reading default or provided in config static [Control API] + /// specs dir. + /// + /// Atm we only should print `warn!` message to log which prints that + /// static specs not loaded. /// /// [Control API]: http://tiny.cc/380uaz - #[display(fmt = "Directory with specs not found.")] - SpecDirNotFound, + #[display(fmt = "Error while reading static control API specs dir.")] + SpecDirReadError(std::io::Error), /// I/O error while reading static [Control API] specs. /// @@ -117,6 +120,24 @@ pub enum LoadStaticControlSpecsError { YamlDeserializationError(serde_yaml::Error), } +impl From for LoadStaticControlSpecsError { + fn from(err: std::io::Error) -> Self { + Self::IoError(err) + } +} + +impl From for LoadStaticControlSpecsError { + fn from(err: TryFromElementError) -> Self { + Self::TryFromElementError(err) + } +} + +impl From for LoadStaticControlSpecsError { + fn from(err: serde_yaml::Error) -> Self { + Self::YamlDeserializationError(err) + } +} + /// Load [`RoomSpec`] from file with YAML format. pub fn load_from_yaml_file>( path: P, @@ -135,7 +156,7 @@ pub fn load_static_specs_from_dir>( ) -> Result, LoadStaticControlSpecsError> { let mut specs = Vec::new(); for entry in std::fs::read_dir(path) - .map_err(|_| LoadStaticControlSpecsError::SpecDirNotFound)? + .map_err(LoadStaticControlSpecsError::SpecDirReadError)? { let entry = entry?; let spec = load_from_yaml_file(entry.path())?; diff --git a/src/api/control/pipeline.rs b/src/api/control/pipeline.rs index 82b79ccd1..a1407af5c 100644 --- a/src/api/control/pipeline.rs +++ b/src/api/control/pipeline.rs @@ -14,14 +14,12 @@ use serde::Deserialize; /// Entity that represents some pipeline of spec. #[derive(Clone, Deserialize, Debug)] -pub struct Pipeline { - pipeline: HashMap, -} +pub struct Pipeline(HashMap); impl Pipeline { /// Creates new [`Pipeline`] from provided [`HashMap`]. pub fn new(pipeline: HashMap) -> Self { - Self { pipeline } + Self(pipeline) } /// Iterate over pipeline by reference. @@ -33,7 +31,7 @@ impl Pipeline { /// Lookup element of [`Pipeline`] by ID. #[inline] pub fn get(&self, id: &str) -> Option<&T> { - self.pipeline.get(id) + self.0.get(id) } } @@ -42,7 +40,7 @@ impl IntoIterator for Pipeline { type Item = (String, T); fn into_iter(self) -> Self::IntoIter { - self.pipeline.into_iter() + self.0.into_iter() } } @@ -52,6 +50,6 @@ impl<'a, T> IntoIterator for &'a Pipeline { #[inline] fn into_iter(self) -> Self::IntoIter { - self.pipeline.iter() + self.0.iter() } } diff --git a/src/api/error_codes.rs b/src/api/error_codes.rs index 42dfae495..78ea1551f 100644 --- a/src/api/error_codes.rs +++ b/src/api/error_codes.rs @@ -37,12 +37,14 @@ pub struct ErrorResponse { /// All [`ErrorCode`]s have [`Display`] implementation. And this /// implementation will be used if this field is [`None`]. But - /// some time we want to add some error explanation. Then we set this field - /// to [`Some`] and this text will be added to + /// some times we want to add some error explanation. Then we set this + /// field to [`Some`] and this text will be added to /// [`Display`] implementation's text. /// /// By default this field should be [`None`]. /// + /// For providing error explanation use [`ErrorResponse::explain`] method. + /// /// [`Display`]: std::fmt::Display explanation: Option, } @@ -58,7 +60,7 @@ impl ErrorResponse { } /// New [`ErrorResponse`] only with [`ErrorCode`]. - pub fn empty(error_code: ErrorCode) -> Self { + pub fn without_id(error_code: ErrorCode) -> Self { Self { error_code, element_id: None, @@ -68,8 +70,10 @@ impl ErrorResponse { /// [`ErrorResponse`] for all unexpected errors. /// - /// Provide unexpected `Error` in this function. - pub fn unknown(unknown_error: &B) -> Self { + /// Provide unexpected `Error` to this function. + /// This error will be printed with [`Display`] implementation + /// of provided `Error`. + pub fn unexpected(unknown_error: &B) -> Self { Self { error_code: ErrorCode::UnexpectedError, explanation: Some(unknown_error.to_string()), @@ -81,7 +85,7 @@ impl ErrorResponse { /// /// With this method you can add additional text to error message of /// [`ErrorCode`]. - pub fn explain( + pub fn with_explanation( error_code: ErrorCode, explanation: String, id: Option, @@ -175,7 +179,7 @@ pub enum ErrorCode { /// Medea expects `Member` element in pipeline but received not him. /// /// Code: __1101__. - #[display(fmt = "Expecting Member element but it's not.")] + #[display(fmt = "Expected Member element but it's not.")] NotMemberInSpec = 1101, /// Invalid source URI in play endpoint. /// @@ -186,21 +190,21 @@ pub enum ErrorCode { /// /// Code: __1103__. #[display( - fmt = "You provided ID for Room but element's spec is not for Room." + fmt = "You provided URI to Room but element's spec is not for Room." )] ElementIdForRoomButElementIsNot = 1103, /// Provided element ID to Member element but element spec is not for /// Member. /// /// Code: __1104__. - #[display(fmt = "You provided ID for Member but element's spec is not \ + #[display(fmt = "You provided URI to Member but element's spec is not \ for Member.")] ElementIdForMemberButElementIsNot = 1104, /// Provided element ID to Endpoint element but element spec is not for /// Endpoint. /// /// Code: __1105__. - #[display(fmt = "You provided ID for Endpoint but element's spec is not \ + #[display(fmt = "You provided URI to Endpoint but element's spec is not \ for Endpoint.")] ElementIdForEndpointButElementIsNot = 1105, /// Provided not source URI in [`WebRtcPlayEndpoint`]. @@ -220,51 +224,56 @@ pub enum ErrorCode { /// Code: __1200__. #[display(fmt = "Element's ID's URI not have 'local://' protocol.")] ElementIdIsNotLocal = 1200, - /// Element's ID have too many paths (slashes). + /// Provided element's URI with too many paths. /// /// Code: __1201__. - #[display(fmt = "In provided element's ID too many slashes.")] + #[display(fmt = "You provided element's URI with too many paths.")] ElementIdIsTooLong = 1201, - /// Missing some fields in element's ID. + /// Missing some fields in source URI of WebRtcPublishEndpoint. /// /// Code: __1202__. - #[display(fmt = "Missing some fields in element ID.")] + #[display( + fmt = "Missing some fields in source URI of WebRtcPublishEndpoint." + )] MissingFieldsInSrcUri = 1202, /// Empty element ID. /// /// Code: __1203__. - #[display(fmt = "Provided empty element ID.")] + #[display(fmt = "Provided empty element URI.")] EmptyElementId = 1203, - /// Provided empty elements IDs list. + /// Provided empty elements URIs list. /// /// Code: __1204__. - #[display(fmt = "Provided empty elements IDs list.")] + #[display(fmt = "Provided empty elements URIs list.")] EmptyElementsList = 1204, - /// Provided not the same [`RoomId`]s in elements IDs. + /// Provided not the same Room IDs in elements IDs. Probably you try use + /// Delete method for elements with different Room IDs /// /// Code: __1205__. /// /// [`RoomId`]: crate::api::control::room::Id - #[display(fmt = "Provided not the same Room IDs in elements IDs.")] + #[display(fmt = "Provided not the same Room IDs in elements IDs. \ + Probably you try use Delete method for elements with \ + different Room IDs")] ProvidedNotSameRoomIds = 1205, ///////////////////////////// // Conflict (1300 - 1399) // /////////////////////////// - /// Member already exists. + /// Member with provided URI already exists. /// /// Code: __1300__. - #[display(fmt = "Member already exists.")] + #[display(fmt = "Member with provided URI already exists.")] MemberAlreadyExists = 1300, - /// Endpoint already exists. + /// Endpoint with provided URI already exists. /// /// Code: __1301__. - #[display(fmt = "Endpoint already exists.")] + #[display(fmt = "Endpoint with provided URI already exists.")] EndpointAlreadyExists = 1301, - /// Room already exists. + /// Room with provided URI already exists. /// /// Code: __1302__. - #[display(fmt = "Room already exists.")] + #[display(fmt = "Room with provided URI already exists.")] RoomAlreadyExists = 1302, //////////////////////// @@ -297,7 +306,7 @@ impl From for ErrorResponse { Self::new(ErrorCode::EndpointAlreadyExists, &id) } ParticipantServiceErr::TurnServiceErr(_) - | ParticipantServiceErr::MemberError(_) => Self::unknown(&err), + | ParticipantServiceErr::MemberError(_) => Self::unexpected(&err), } } } @@ -307,9 +316,9 @@ impl From for ErrorResponse { match err { TryFromProtobufError::SrcUriError(e) => e.into(), TryFromProtobufError::NotMemberElementInRoomElement(id) => { - Self::explain( + Self::with_explanation( ErrorCode::UnimplementedCall, - "Not Member elements in Room element currently \ + "Not Member elements in Room element currently is \ unimplemented." .to_string(), Some(id), @@ -328,7 +337,9 @@ impl From for ErrorResponse { LocalUriParseError::TooManyPaths(text) => { Self::new(ErrorCode::ElementIdIsTooLong, &text) } - LocalUriParseError::Empty => Self::empty(ErrorCode::EmptyElementId), + LocalUriParseError::Empty => { + Self::without_id(ErrorCode::EmptyElementId) + } LocalUriParseError::MissingPaths(text) => { Self::new(ErrorCode::MissingFieldsInSrcUri, &text) } @@ -354,7 +365,7 @@ impl From for ErrorResponse { | RoomError::TryFromElementError(_) | RoomError::BadRoomSpec(_) | RoomError::TurnServiceError(_) - | RoomError::ClientError(_) => Self::unknown(&err), + | RoomError::ClientError(_) => Self::unexpected(&err), } } } @@ -421,13 +432,13 @@ impl From for ErrorResponse { } RoomServiceError::RoomError(e) => e.into(), RoomServiceError::EmptyUrisList => { - Self::empty(ErrorCode::EmptyElementsList) + Self::without_id(ErrorCode::EmptyElementsList) } RoomServiceError::RoomNotFoundForElement(id) => { Self::new(ErrorCode::RoomNotFoundForProvidedElement, &id) } RoomServiceError::NotSameRoomIds(ids, expected_room_id) => { - Self::explain( + Self::with_explanation( ErrorCode::ProvidedNotSameRoomIds, format!( "Expected Room ID: '{}'. IDs with different Room ID: \ @@ -442,7 +453,7 @@ impl From for ErrorResponse { } RoomServiceError::RoomMailboxErr(_) | RoomServiceError::FailedToLoadStaticSpecs(_) => { - Self::unknown(&err) + Self::unexpected(&err) } } } @@ -456,7 +467,9 @@ impl From for ErrorResponse { GrpcControlApiError::RoomServiceError(e) => e.into(), GrpcControlApiError::RoomServiceMailboxError(_) | GrpcControlApiError::TryFromElement(_) - | GrpcControlApiError::UnknownMailboxErr(_) => Self::unknown(&err), + | GrpcControlApiError::UnknownMailboxErr(_) => { + Self::unexpected(&err) + } } } } diff --git a/src/bin/client.rs b/src/bin/client.rs index 90daaf490..813237dab 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -1,3 +1,10 @@ +//! This is temporary binary for testing gRPC Control API implementation +//! purposes. +//! +//! In `control-api-mock-server` this will be deleted. After +//! `control-api-mock-server` you will be able to test it with Control API mock +//! server by calling REST API endpoints. + #![allow(dead_code)] use std::{collections::HashMap, sync::Arc}; diff --git a/src/conf/client.rs b/src/conf/client.rs index 67eff61c5..8a8ff1970 100644 --- a/src/conf/client.rs +++ b/src/conf/client.rs @@ -1,15 +1,19 @@ -//! HTTP server settings. +//! [Client API] HTTP server settings. +//! +//! [Client API]: http://tiny.cc/c80uaz use std::net::{IpAddr, Ipv4Addr, SocketAddr, ToSocketAddrs as _}; use serde::{Deserialize, Serialize}; use smart_default::SmartDefault; -/// HTTP server settings. +/// [Client API] HTTP server settings. +/// +/// [Client API]: http://tiny.cc/c80uaz #[derive(Clone, Debug, Deserialize, Serialize, SmartDefault)] #[serde(default)] pub struct Client { - /// Public URI of server. Address for exposed [Client API]. + /// Public URL of server. Address for exposed [Client API]. /// /// This address will be returned from [Control API] in `sids` and to /// this address will connect [Jason] for start session. @@ -28,9 +32,6 @@ pub struct Client { /// Port to bind HTTP server to. Defaults to `8080`. #[default(8080)] pub bind_port: u16, - - /// Path to directory with static control API specs. - pub static_specs_path: Option, } impl Client { diff --git a/src/conf/control.rs b/src/conf/control.rs index 7e425afed..26921d83c 100644 --- a/src/conf/control.rs +++ b/src/conf/control.rs @@ -19,6 +19,9 @@ pub struct Control { #[default(String::from("specs/"))] pub static_specs_dir: String, + /// gRPC [Control API] server settings. + /// + /// [Control API]: http://tiny.cc/380uaz pub grpc: Grpc, } diff --git a/src/conf/grpc.rs b/src/conf/grpc.rs index b02154bd3..4bc16fb0a 100644 --- a/src/conf/grpc.rs +++ b/src/conf/grpc.rs @@ -1,11 +1,15 @@ -//! gRPC server settings. +//! [Control API] gRPC server settings. +//! +//! [Control API]: http://tiny.cc/380uaz use std::net::{IpAddr, Ipv4Addr}; use serde::{Deserialize, Serialize}; use smart_default::SmartDefault; -/// gRPC server settings. +/// [Control API] gRPC server settings. +/// +/// [Control API]: http://tiny.cc/380uaz #[derive(Clone, Debug, Deserialize, Serialize, SmartDefault)] #[serde(default)] pub struct Grpc { diff --git a/src/main.rs b/src/main.rs index da3fce371..972d65f58 100644 --- a/src/main.rs +++ b/src/main.rs @@ -29,10 +29,11 @@ fn start_static_rooms( if let Err(e) = result { match e { RoomServiceError::FailedToLoadStaticSpecs(e) => match e { - LoadStaticControlSpecsError::SpecDirNotFound => { + LoadStaticControlSpecsError::SpecDirReadError(e) => { warn!( - "Specs dir not exists. Control API specs not \ - loaded." + "Error while reading static control API specs \ + dir. Control API specs not loaded. {}", + e ); } _ => panic!("{}", e), diff --git a/src/signalling/elements/endpoints/mod.rs b/src/signalling/elements/endpoints/mod.rs index 98056d0aa..74f5a2d0b 100644 --- a/src/signalling/elements/endpoints/mod.rs +++ b/src/signalling/elements/endpoints/mod.rs @@ -2,14 +2,15 @@ pub mod webrtc; +use derive_more::From; use medea_grpc_proto::control::Element as RootElementProto; +#[derive(Clone, Debug, From)] pub enum Endpoint { WebRtcPublishEndpoint(webrtc::WebRtcPublishEndpoint), WebRtcPlayEndpoint(webrtc::WebRtcPlayEndpoint), } -// TODO: maybe better? impl Into for Endpoint { fn into(self) -> RootElementProto { match self { diff --git a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs index df793286b..c7ca8b3b3 100644 --- a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs @@ -182,6 +182,7 @@ impl WebRtcPublishEndpoint { .retain(|e| e.safe_upgrade().is_some()); } + /// Peer-to-peer mode of this [`WebRtcPublishEndpoint`]. pub fn p2p(&self) -> P2pMode { self.0.borrow().p2p.clone() } diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index c0441e447..5e8377bc3 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -118,7 +118,7 @@ impl Member { }))) } - /// Lookup [`MemberSpec`] by ID from [`MemberSpec`]. + /// Lookup [`MemberSpec`] by [`MemberId`] from [`MemberSpec`]. /// /// Returns [`MembersLoadError::MemberNotFound`] when member not found. /// Returns [`MembersLoadError::TryFromError`] when found element which is @@ -388,12 +388,12 @@ impl Member { self.0.borrow_mut().srcs.remove(id); } - /// Take sink from [`Member`]'s `sinks`. + /// Takes sink from [`Member`]'s `sinks`. pub fn take_sink(&self, id: &WebRtcPlayId) -> Option { self.0.borrow_mut().sinks.remove(id) } - /// Take src from [`Member`]'s `srsc`. + /// Takes src from [`Member`]'s `srsc`. pub fn take_src( &self, id: &WebRtcPublishId, @@ -401,6 +401,7 @@ impl Member { self.0.borrow_mut().srcs.remove(id) } + /// Returns [`RoomId`] of this [`Member`]. pub fn room_id(&self) -> RoomId { self.0.borrow().room_id.clone() } @@ -452,7 +453,7 @@ impl Member { } /// Compares pointers. If both pointers point to the same address, then - /// returns true. + /// returns `true`. #[cfg(test)] pub fn ptr_eq(&self, another_member: &Self) -> bool { Rc::ptr_eq(&self.0, &another_member.0) @@ -485,17 +486,12 @@ impl WeakMember { pub fn parse_members( room_spec: &RoomSpec, ) -> Result, MembersLoadError> { - let members_spec = match room_spec.members() { - Ok(o) => o, - Err(e) => { - return Err(MembersLoadError::TryFromError( - e, - StatefulLocalUri::Room(LocalUri::::new( - room_spec.id.clone(), - )), - )) - } - }; + let members_spec = room_spec.members().map_err(|e| { + MembersLoadError::TryFromError( + e, + LocalUri::::new(room_spec.id.clone()).into(), + ) + })?; let members: HashMap = members_spec .iter() diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 10f2d22a1..3dfc1ed46 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -55,16 +55,27 @@ use crate::{ #[derive(Fail, Debug, Display)] #[allow(clippy::module_name_repetitions)] pub enum ParticipantServiceErr { + /// Some error happened in [`TurnAuthService`]. #[display(fmt = "TurnService Error in ParticipantService: {}", _0)] TurnServiceErr(TurnServiceErr), + + /// [`Member`] with provided [`LocalUri`] not found. #[display(fmt = "Participant [id = {}] not found", _0)] ParticipantNotFound(LocalUri), + + /// [`Endpoint`] with provided URI not found. #[display(fmt = "Endpoint [id = {}] not found.", _0)] EndpointNotFound(LocalUri), + + /// Some error happened in [`Member`]. #[display(fmt = "{}", _0)] MemberError(MemberError), + + /// Try to create [`Member`] with ID which already exists. #[display(fmt = "Participant [id = {}] already exists.", _0)] ParticipantAlreadyExists(LocalUri), + + /// Try to create [`Endpoint`] with ID which already exists. #[display(fmt = "Endpoint [id = {}] already exists.", _0)] EndpointAlreadyExists(LocalUri), } @@ -368,7 +379,7 @@ impl ParticipantService { join_all(close_fut).map(|_| ()) } - /// Delete [`Member`] from [`ParticipantService`], remove this user from + /// Deletes [`Member`] from [`ParticipantService`], remove this user from /// [`TurnAuthService`], close RPC connection with him and remove drop /// connection task. /// @@ -397,7 +408,7 @@ impl ParticipantService { } } - /// Create new [`Member`] in this [`ParticipantService`]. + /// Creates new [`Member`] in this [`ParticipantService`]. /// /// This function will check that new [`Member`]'s ID is not present in /// [`ParticipantService`]. diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index 2ef0f4273..a964cc3cb 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -173,7 +173,7 @@ impl PeerRepository { } } - /// Delete [`PeerStateMachine`]s from this [`PeerRepository`] and send + /// Deletes [`PeerStateMachine`]s from this [`PeerRepository`] and send /// [`Event::PeersRemoved`] to [`Member`]s. /// /// __Note:__ this also delete partner peers. @@ -246,7 +246,7 @@ impl PeerRepository { peers_to_remove } - /// Delete [`PeerStateMachine`] from this [`PeerRepository`] and send + /// Deletes [`PeerStateMachine`] from this [`PeerRepository`] and send /// [`Event::PeersRemoved`] to [`Member`]s. /// /// __Note:__ this also delete partner peer. diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 5c50b9c17..53eb61c8c 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -922,8 +922,9 @@ impl Handler for Room { StatefulLocalUri::Endpoint(endpoint_uri) => { endpoint_ids.push(endpoint_uri); } - // TODO (evdokimovs): better message - _ => warn!("Delete method in Room found LocalUri."), + _ => warn!( + "Found LocalUri while deleting __from__ Room." + ), } } member_ids.into_iter().for_each(|uri| { diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index 8d4bd6980..f55ae813d 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -1,4 +1,4 @@ -//! Service which control [`Room`]. +//! Service which provide CRUD actions for [`Room`]. use std::{collections::HashMap, marker::PhantomData}; @@ -209,7 +209,7 @@ impl Handler for RoomService { #[derive(Message)] #[rtype(result = "Result<(), RoomServiceError>")] pub struct CreateRoom { - pub id: LocalUri, + pub uri: LocalUri, pub spec: RoomSpec, } @@ -221,7 +221,7 @@ impl Handler for RoomService { msg: CreateRoom, _ctx: &mut Self::Context, ) -> Self::Result { - let room_id = msg.id.take_room_id(); + let room_id = msg.uri.take_room_id(); if self.room_repo.get(&room_id).is_some() { return Err(RoomServiceError::RoomAlreadyExists( From a45af9a987e517f18649125d09784206477e9bb8 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 11 Sep 2019 00:43:31 +0300 Subject: [PATCH 611/735] Fix lints [run ci] --- src/api/control/local_uri.rs | 8 +++++--- src/api/control/mod.rs | 1 + src/signalling/room_service.rs | 12 +++++++++--- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/api/control/local_uri.rs b/src/api/control/local_uri.rs index 57771af66..050fe9115 100644 --- a/src/api/control/local_uri.rs +++ b/src/api/control/local_uri.rs @@ -1,6 +1,8 @@ //! URI for pointing to some medea element. -use std::{convert::TryFrom, fmt}; +#![allow(clippy::use_self)] + +use std::{convert::TryFrom, fmt, string::ToString}; use derive_more::{Display, From}; use failure::Fail; @@ -110,7 +112,7 @@ impl TryFrom<&str> for StatefulLocalUri { let endpoint_id = path .next() .filter(|id| !id.is_empty()) - .map(|id| id.to_string()); + .map(ToString::to_string); if path.next().is_some() { return Err(LocalUriParseError::TooManyPaths(value.to_string())); @@ -159,7 +161,7 @@ pub struct IsEndpointId(LocalUri, String); /// [`IsRoomId`]. This is used for compile time guarantees that some /// [`LocalUri`] have all mandatory fields. /// -/// You also can take value from [`LocalUri`] without copy, but you have to do +/// You also can take value from [`LocalUri`] without clone, but you have to do /// it consistently. For example, if you wish to get [`RoomId`], [`MemberId`] /// and [`Endpoint`] ID from [`LocalUri`] in [`IsEndpointId`] state you should /// make this steps: diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index c5d708104..ed6ea6d1f 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -86,6 +86,7 @@ pub enum TryFromElementError { } /// Errors which can happen while loading static [Control API] specs. +#[allow(clippy::pub_enum_variant_names)] #[derive(Debug, Fail, Display)] pub enum LoadStaticControlSpecsError { /// Error while reading default or provided in config static [Control API] diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index f55ae813d..ef657f9cb 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -251,9 +251,10 @@ pub struct Validated; /// State which indicates that [`DeleteElements`] message is unvalidated and /// should be validated with `validate()` function of [`DeleteElements`] in -/// [`Unvalidated`] state. +/// [`Unvalidated`] state before sending to [`RoomService`]. pub struct Unvalidated; +#[allow(clippy::use_self)] impl DeleteElements { pub fn new() -> DeleteElements { Self { @@ -266,6 +267,8 @@ impl DeleteElements { self.uris.push(uri) } + // TODO: delete this allow when drain_filter TODO will be resolved. + #[allow(clippy::unnecessary_filter_map)] pub fn validate( self, ) -> Result, RoomServiceError> { @@ -276,6 +279,7 @@ impl DeleteElements { let mut ignored_uris = Vec::new(); let first_room = self.uris[0].room_id().clone(); + // TODO: rewrite using Vec::drain_filter when it will be in stable let uris: Vec = self .uris .into_iter() @@ -289,7 +293,7 @@ impl DeleteElements { }) .collect(); - if ignored_uris.len() > 0 { + if !ignored_uris.is_empty() { return Err(RoomServiceError::NotSameRoomIds( ignored_uris, first_room, @@ -306,7 +310,7 @@ impl DeleteElements { /// Signal for delete [Control API] elements. /// /// [Control API]: http://tiny.cc/380uaz -#[derive(Message)] +#[derive(Message, Default)] #[rtype(result = "Result<(), RoomServiceError>")] pub struct DeleteElements { uris: Vec, @@ -318,6 +322,7 @@ impl Handler> for RoomService { // TODO: delete this allow when drain_filter TODO will be resolved. #[allow(clippy::unnecessary_filter_map)] + #[allow(clippy::if_not_else)] fn handle( &mut self, msg: DeleteElements, @@ -381,6 +386,7 @@ impl Handler for RoomService { type Result = ActFuture, RoomServiceError>; + // TODO: use validation state machine same as Delete method fn handle(&mut self, msg: Get, _: &mut Self::Context) -> Self::Result { let mut rooms_elements = HashMap::new(); for uri in msg.0 { From b30e6f45f36c1c543ac0e688d0a3ab52fb3c6338 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 11 Sep 2019 00:53:55 +0300 Subject: [PATCH 612/735] Set permament nightly build date for rustfmt in CI [run ci] --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e3f99a562..f69ac7834 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,7 +29,7 @@ jobs: - name: rustfmt stage: check - rust: nightly + rust: nightly-2019-09-05 cache: false env: DONT_INSTALL_PROTOC=1 before_script: rustup component add rustfmt From edd527dba8295a8763be561686f84e30cd134690 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 11 Sep 2019 00:55:15 +0300 Subject: [PATCH 613/735] Disallow failures on check [run ci] --- .travis.yml | 1 + src/signalling/room_service.rs | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f69ac7834..e8bce2eed 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,6 +19,7 @@ stages: jobs: allow_failures: - rust: nightly + stage: build include: - name: Clippy diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index ef657f9cb..189014cd9 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -294,7 +294,8 @@ impl DeleteElements { .collect(); if !ignored_uris.is_empty() { - return Err(RoomServiceError::NotSameRoomIds( + return Err( + RoomServiceError::NotSameRoomIds( ignored_uris, first_room, )); From 4c41e0d1b5cdb0650f926e5aab1e6e76cc901c5c Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 11 Sep 2019 00:58:40 +0300 Subject: [PATCH 614/735] Fix nightly rust version in Makefile [run ci] --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index f75f3622e..1fe6d6090 100644 --- a/Makefile +++ b/Makefile @@ -200,7 +200,7 @@ cargo.fmt: ifeq ($(build),yes) cargo build endif - cargo +nightly fmt --all $(if $(call eq,$(check),yes),-- --check,) + cargo +nightly-2019-09-05 fmt --all $(if $(call eq,$(check),yes),-- --check,) # Lint Rust sources with clippy. From e426438655b4caaf1150d34bcbcd3658ee8e8105 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 11 Sep 2019 01:04:58 +0300 Subject: [PATCH 615/735] Add TODO, fix broken formatting for testing [run ci] --- .travis.yml | 1 + src/signalling/room_service.rs | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index e8bce2eed..f280d5841 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,6 +28,7 @@ jobs: before_script: rustup component add clippy script: make lint +# TODO: write script for check last nightly version with available component - name: rustfmt stage: check rust: nightly-2019-09-05 diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index 189014cd9..ef657f9cb 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -294,8 +294,7 @@ impl DeleteElements { .collect(); if !ignored_uris.is_empty() { - return Err( - RoomServiceError::NotSameRoomIds( + return Err(RoomServiceError::NotSameRoomIds( ignored_uris, first_room, )); From 3ec085ec0428ee222daffe358aaee94627997c1e Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 11 Sep 2019 10:52:02 +0300 Subject: [PATCH 616/735] Fix Pipeline deserialization [run ci] --- src/api/control/pipeline.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/api/control/pipeline.rs b/src/api/control/pipeline.rs index a1407af5c..82b79ccd1 100644 --- a/src/api/control/pipeline.rs +++ b/src/api/control/pipeline.rs @@ -14,12 +14,14 @@ use serde::Deserialize; /// Entity that represents some pipeline of spec. #[derive(Clone, Deserialize, Debug)] -pub struct Pipeline(HashMap); +pub struct Pipeline { + pipeline: HashMap, +} impl Pipeline { /// Creates new [`Pipeline`] from provided [`HashMap`]. pub fn new(pipeline: HashMap) -> Self { - Self(pipeline) + Self { pipeline } } /// Iterate over pipeline by reference. @@ -31,7 +33,7 @@ impl Pipeline { /// Lookup element of [`Pipeline`] by ID. #[inline] pub fn get(&self, id: &str) -> Option<&T> { - self.0.get(id) + self.pipeline.get(id) } } @@ -40,7 +42,7 @@ impl IntoIterator for Pipeline { type Item = (String, T); fn into_iter(self) -> Self::IntoIter { - self.0.into_iter() + self.pipeline.into_iter() } } @@ -50,6 +52,6 @@ impl<'a, T> IntoIterator for &'a Pipeline { #[inline] fn into_iter(self) -> Self::IntoIter { - self.0.iter() + self.pipeline.iter() } } From 69fe27bbb3cdc038cfdea8337dbb15423df3d07a Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 11 Sep 2019 11:06:23 +0300 Subject: [PATCH 617/735] Try to set last available nightly version with env variable [run ci] --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f280d5841..1fd346707 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,7 @@ cache: cargo install: - bash _ci/protoc_install.sh + - export RUSTFMT_NIGHTLY_AVAILABLE_VERSION=`curl https://rust-lang.github.io/rustup-components-history/x86_64-unknown-linux-gnu/rustfmt` - rustc -vV - cargo -vV @@ -31,7 +32,7 @@ jobs: # TODO: write script for check last nightly version with available component - name: rustfmt stage: check - rust: nightly-2019-09-05 + rust: nightly-${RUSTFMT_NIGHTLY_AVAILABLE_VERSION} cache: false env: DONT_INSTALL_PROTOC=1 before_script: rustup component add rustfmt From 8d0fa1d0807c2ccffab6ebe391b020ee322b5daf Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 11 Sep 2019 11:15:27 +0300 Subject: [PATCH 618/735] Use last available rustfmt nightly rust version [run ci] --- .travis.yml | 10 +++++----- Makefile | 4 +++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1fd346707..4f4a3e5a9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,6 @@ cache: cargo install: - bash _ci/protoc_install.sh - - export RUSTFMT_NIGHTLY_AVAILABLE_VERSION=`curl https://rust-lang.github.io/rustup-components-history/x86_64-unknown-linux-gnu/rustfmt` - rustc -vV - cargo -vV @@ -29,14 +28,15 @@ jobs: before_script: rustup component add clippy script: make lint -# TODO: write script for check last nightly version with available component - name: rustfmt stage: check - rust: nightly-${RUSTFMT_NIGHTLY_AVAILABLE_VERSION} + rust: nightly cache: false env: DONT_INSTALL_PROTOC=1 - before_script: rustup component add rustfmt - script: make fmt check=yes + before_script: + - export RUSTFMT_RUST_VER=`curl https://rust-lang.github.io/rustup-components-history/x86_64-unknown-linux-gnu/rustfmt` + - rustup component add rustfmt --toolchain nightly-${RUSTFMT_RUST_VER}-x86_64-unknown-linux-gnu + script: make fmt check=yes rustfmt-rust-ver=nightly-${RUSTFMT_RUST_VER} - name: medea-jason (stable) stage: build diff --git a/Makefile b/Makefile index 1fe6d6090..f314dd9d9 100644 --- a/Makefile +++ b/Makefile @@ -196,11 +196,13 @@ cargo: # Usage: # make cargo.fmt [check=(no|yes)] [build=(no|yes)] +rustfmt-rust-ver=nightly + cargo.fmt: ifeq ($(build),yes) cargo build endif - cargo +nightly-2019-09-05 fmt --all $(if $(call eq,$(check),yes),-- --check,) + cargo +${rustfmt-rust-ver} fmt --all $(if $(call eq,$(check),yes),-- --check,) # Lint Rust sources with clippy. From c1f641f97b40224c76cac0fa43ef18519fe99020 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 11 Sep 2019 11:19:11 +0300 Subject: [PATCH 619/735] Install rust [run ci] --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 4f4a3e5a9..7621767e8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,6 +35,7 @@ jobs: env: DONT_INSTALL_PROTOC=1 before_script: - export RUSTFMT_RUST_VER=`curl https://rust-lang.github.io/rustup-components-history/x86_64-unknown-linux-gnu/rustfmt` + - rustup toolchain install nightly-${RUSTFMT_RUST_VER} - rustup component add rustfmt --toolchain nightly-${RUSTFMT_RUST_VER}-x86_64-unknown-linux-gnu script: make fmt check=yes rustfmt-rust-ver=nightly-${RUSTFMT_RUST_VER} From 2ab9b0a838634a740aa89bfea5523e42c60ed9dd Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 11 Sep 2019 11:28:57 +0300 Subject: [PATCH 620/735] Meh [run ci] --- src/turn/service.rs | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/turn/service.rs b/src/turn/service.rs index e7f60e6c6..84cbbae79 100644 --- a/src/turn/service.rs +++ b/src/turn/service.rs @@ -245,21 +245,19 @@ impl Handler for Service { self.new_password(TURN_PASS_LEN), ); - Box::new( - self.turn_db.insert(&ice_user).into_actor(self).then( - move |result, act, _| { - wrap_future(match result { - Ok(_) => ok(ice_user), - Err(e) => match msg.policy { - UnreachablePolicy::ReturnErr => err(e.into()), - UnreachablePolicy::ReturnStatic => { - ok(act.static_user()) - } - }, - }) - }, - ), - ) + Box::new(self.turn_db.insert(&ice_user).into_actor(self).then( + move |result, act, _| { + wrap_future(match result { + Ok(_) => ok(ice_user), + Err(e) => match msg.policy { + UnreachablePolicy::ReturnErr => err(e.into()), + UnreachablePolicy::ReturnStatic => { + ok(act.static_user()) + } + }, + }) + }, + )) } } From 488bc53c0585685ba40aaec31b8a3c683ba5781c Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 11 Sep 2019 12:14:54 +0300 Subject: [PATCH 621/735] Fix e2e tests in CI, move rustfmt installation into CI bash script [run ci] --- .travis.yml | 7 ++----- _ci/rustfmt_install.sh | 9 +++++++++ 2 files changed, 11 insertions(+), 5 deletions(-) create mode 100644 _ci/rustfmt_install.sh diff --git a/.travis.yml b/.travis.yml index 7621767e8..1ae981a4e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,10 +34,8 @@ jobs: cache: false env: DONT_INSTALL_PROTOC=1 before_script: - - export RUSTFMT_RUST_VER=`curl https://rust-lang.github.io/rustup-components-history/x86_64-unknown-linux-gnu/rustfmt` - - rustup toolchain install nightly-${RUSTFMT_RUST_VER} - - rustup component add rustfmt --toolchain nightly-${RUSTFMT_RUST_VER}-x86_64-unknown-linux-gnu - script: make fmt check=yes rustfmt-rust-ver=nightly-${RUSTFMT_RUST_VER} + - bash _ci/rustfmt_install.sh + script: make fmt check=yes rustfmt-rust-ver="${RUSTFMT_RUST_VER}" - name: medea-jason (stable) stage: build @@ -77,7 +75,6 @@ jobs: - name: e2e signalling (stable) stage: test rust: stable - env: DONT_INSTALL_PROTOC=1 services: - docker script: diff --git a/_ci/rustfmt_install.sh b/_ci/rustfmt_install.sh new file mode 100644 index 000000000..e30ccc627 --- /dev/null +++ b/_ci/rustfmt_install.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +# Gets latest nightly version which presents rustfmt. +last_nightly_with_rustfmt=$(curl https://rust-lang.github.io/rustup-components-history/x86_64-unknown-linux-gnu/rustfmt) +RUSTFMT_RUST_VER=nightly-${last_nightly_with_rustfmt} +export RUSTFMT_RUST_VER + +rustup toolchain install "${RUSTFMT_RUST_VER}" +rustup component add rustfmt --toolchain "${RUSTFMT_RUST_VER}"-x86_64-unknown-linux-gnu From fef6ed2c7848bcb313119078a852d03077e95725 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 11 Sep 2019 12:25:22 +0300 Subject: [PATCH 622/735] Fix starting bash script [run ci] --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 1ae981a4e..2be7864f2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,7 +34,7 @@ jobs: cache: false env: DONT_INSTALL_PROTOC=1 before_script: - - bash _ci/rustfmt_install.sh + - . ./_ci/rustfmt_install.sh script: make fmt check=yes rustfmt-rust-ver="${RUSTFMT_RUST_VER}" - name: medea-jason (stable) From f720ee6adf1b79b8077234365691615088f47605 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 11 Sep 2019 16:33:19 +0300 Subject: [PATCH 623/735] Reread [run ci] --- .dockerignore | 1 + Makefile | 9 +- _build/{medea => medea-build}/Dockerfile | 0 proto/grpc/CHANGELOG.md | 1 + proto/grpc/Cargo.toml | 2 +- proto/grpc/README.md | 3 +- proto/grpc/src/lib.rs | 5 +- src/api/control/endpoints/mod.rs | 7 +- .../control/endpoints/webrtc_play_endpoint.rs | 16 +- .../endpoints/webrtc_publish_endpoint.rs | 4 +- src/api/control/grpc/server.rs | 28 +- src/api/control/local_uri.rs | 251 +++++++++--------- src/api/control/member.rs | 7 +- src/api/control/mod.rs | 17 +- src/api/control/pipeline.rs | 14 +- src/api/control/room.rs | 6 +- src/api/error_codes.rs | 13 +- src/bin/client.rs | 6 +- src/conf/client.rs | 4 +- src/conf/control.rs | 2 +- src/conf/log.rs | 5 +- src/conf/mod.rs | 2 +- src/shutdown.rs | 4 +- src/signalling/elements/endpoints/mod.rs | 7 +- .../endpoints/webrtc/publish_endpoint.rs | 2 +- src/signalling/elements/member.rs | 6 +- src/signalling/participants.rs | 53 ++-- src/signalling/peers.rs | 4 +- src/signalling/room.rs | 91 ++++--- src/signalling/room_repo.rs | 2 +- src/signalling/room_service.rs | 15 +- src/turn/service.rs | 28 +- 32 files changed, 329 insertions(+), 286 deletions(-) rename _build/{medea => medea-build}/Dockerfile (100%) diff --git a/.dockerignore b/.dockerignore index c0efd9e8d..b9c5b1895 100644 --- a/.dockerignore +++ b/.dockerignore @@ -22,3 +22,4 @@ !_ci # !target/{mode} is added and removed dynamically to reduce image build times. +!target/debug/ diff --git a/Makefile b/Makefile index 605e49978..a9a3c40f3 100644 --- a/Makefile +++ b/Makefile @@ -322,11 +322,11 @@ endif # [up=yes [dockerized=no [debug=(yes|no)]] # [dockerized=yes [TAG=(dev|)] # [registry=] -# [log=(no|yes)]] +# [logs=(no|yes)]] # [wait=(5|)]] test-e2e-env = RUST_BACKTRACE=1 \ - $(if $(call eq,$(log),yes),,RUST_LOG=warn) \ + $(if $(call eq,$(logs),yes),,RUST_LOG=warn) \ MEDEA_CONTROL.STATIC_SPECS_DIR=tests/specs/ \ MEDEA_CONTROL_STATIC_SPECS_DIR=tests/specs/ @@ -334,7 +334,7 @@ test.e2e: ifeq ($(up),yes) make docker.up.coturn background=yes env $(test-e2e-env) \ - make docker.up.medea debug=$(debug) background=yes log=$(log) \ + make docker.up.medea debug=$(debug) background=yes logs=$(logs) \ dockerized=$(dockerized) \ TAG=$(TAG) registry=$(registry) sleep $(if $(call eq,$(wait),),5,$(wait)) @@ -430,7 +430,7 @@ docker.build.demo: # make docker.build.medea-build docker.build.medea-build: - docker build -t medea-build -f _build/medea/Dockerfile . + docker build -t medea-build -f _build/medea-build/Dockerfile . # Build medea project Docker image. @@ -792,6 +792,7 @@ endef .PHONY: build build.jason build.medea \ cargo cargo.build cargo.fmt cargo.lint \ docker.auth docker.build.demo docker.build.medea \ + docker.build.medea-build \ docker.down.coturn docker.down.demo docker.down.medea \ docker.pull docker.push \ docker.up.coturn docker.up.demo docker.up.medea \ diff --git a/_build/medea/Dockerfile b/_build/medea-build/Dockerfile similarity index 100% rename from _build/medea/Dockerfile rename to _build/medea-build/Dockerfile diff --git a/proto/grpc/CHANGELOG.md b/proto/grpc/CHANGELOG.md index 53cccff17..d75e87f60 100644 --- a/proto/grpc/CHANGELOG.md +++ b/proto/grpc/CHANGELOG.md @@ -16,6 +16,7 @@ All user visible changes to this project will be documented in this file. This p - Methods ([#33](/../../pull/33)): - `Create`, - `Get`, + - `Apply`, - `Delete`. - Elements ([#33](/../../pull/33)): - `Room`, diff --git a/proto/grpc/Cargo.toml b/proto/grpc/Cargo.toml index db0b99334..2e7cc7b2b 100644 --- a/proto/grpc/Cargo.toml +++ b/proto/grpc/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT/Apache-2.0" homepage = "https://github.com/instrumentisto/medea/tree/master/proto/grpc" repository = "https://github.com/instrumentisto/medea/tree/master/proto/grpc" readme = "README.md" -keywords = ["medea", "grpc", "control-api"] +keywords = ["medea", "grpc", "control", "api"] categories = ["api-bindings", "web-programming"] [dependencies] diff --git a/proto/grpc/README.md b/proto/grpc/README.md index 922618ac7..64608db8a 100644 --- a/proto/grpc/README.md +++ b/proto/grpc/README.md @@ -6,7 +6,7 @@ Medea Control API gRPC specs [Changelog](https://github.com/instrumentisto/medea/blob/master/proto/grpc/CHANGELOG.md) -Compiled gRPC specs for [Medea] media server control API. +Compiled gRPC specs for [Medea] media server [Control API]. __Currently, in early development phase.__ @@ -42,3 +42,4 @@ Unless you explicitly state otherwise, any contribution intentionally submitted [Medea]: https://github.com/instrumentisto/medea +[Control API]: https://github.com/instrumentisto/medea/blob/master/docs/rfc/0001-control-api.md diff --git a/proto/grpc/src/lib.rs b/proto/grpc/src/lib.rs index a828042da..e55623f21 100644 --- a/proto/grpc/src/lib.rs +++ b/proto/grpc/src/lib.rs @@ -1,4 +1,7 @@ -//! gRPC generated specs. +//! Generated [medea]'s [Control API] specs. +//! +//! [medea]: https://github.com/instrumentisto/medea +//! [Control API]: http://tiny.cc/380uaz #![allow(bare_trait_objects)] #![allow(clippy::pedantic)] diff --git a/src/api/control/endpoints/mod.rs b/src/api/control/endpoints/mod.rs index 100e05b58..80e3f20ce 100644 --- a/src/api/control/endpoints/mod.rs +++ b/src/api/control/endpoints/mod.rs @@ -1,4 +1,6 @@ -//! Endpoint elements of medea spec. +//! Endpoint elements of [medea] spec. +//! +//! [medea]: https://github.com/instrumentisto/medea pub mod webrtc_play_endpoint; pub mod webrtc_publish_endpoint; @@ -16,8 +18,7 @@ pub use webrtc_play_endpoint::WebRtcPlayEndpoint; #[doc(inline)] pub use webrtc_publish_endpoint::WebRtcPublishEndpoint; -/// [`Endpoint`] represents a media element that one or more media data streams -/// flow through. +/// Media element that one or more media data streams flow through. #[derive(Debug)] pub enum Endpoint { /// [`WebRtcPublishEndpoint`] element. diff --git a/src/api/control/endpoints/webrtc_play_endpoint.rs b/src/api/control/endpoints/webrtc_play_endpoint.rs index fc9361438..800d5b184 100644 --- a/src/api/control/endpoints/webrtc_play_endpoint.rs +++ b/src/api/control/endpoints/webrtc_play_endpoint.rs @@ -1,4 +1,6 @@ -//! `WebRtcPlayEndpoint` element implementation. +//! `WebRtcPlayEndpoint` [Control API]'s element implementation. +//! +//! [Control API]: http://tiny.cc/380uaz use std::{convert::TryFrom, fmt}; @@ -56,14 +58,17 @@ pub enum SrcParseError { /// Special uri with pattern `local://{room_id}/{member_id}/{endpoint_id}`. /// This uri can pointing only to [`WebRtcPublishEndpoint`]. /// -/// Note that [`SrcUri`] parsing with [`LocalUri`] parser. +/// Note that [`SrcUri`] is parsing with [`LocalUri`] parser. /// Actually difference between [`SrcUri`] and [`LocalUri`] /// in endpoint ID's type. In [`SrcUri`] it [`WebRtcPublishId`], and in /// [`LocalUri`] it [`String`]. Also [`SrcUri`] can be deserialized with /// [`serde`]. /// +/// Atm used only in [Control API] specs. +/// /// [`WebRtcPublishEndpoint`]: /// crate::api::control::endpoints::WebRtcPublishEndpoint +/// [Control API]: http://tiny.cc/380uaz #[derive(Clone, Debug)] pub struct SrcUri { /// ID of [`Room`]. @@ -76,9 +81,7 @@ pub struct SrcUri { /// [`MemberSpec`]: crate::api::control::member::MemberSpec pub member_id: MemberId, - /// Control ID of [`Endpoint`]. - /// - /// [`Endpoint`]: crate::api::control::endpoints::Endpoint + /// ID of [`WebRtcPublishEndpoint`]. pub endpoint_id: WebRtcPublishId, } @@ -113,7 +116,8 @@ impl From> for SrcUri { } /// [Serde] deserializer for [`SrcUri`]. -/// Deserialize URIs with pattern `local://{room_id}/{member_id}/{endpoint_id}`. +/// Deserializes URIs with pattern: +/// `local://room_id/member_id/publish_endpoint_id`. /// /// [Serde]: serde impl<'de> Deserialize<'de> for SrcUri { diff --git a/src/api/control/endpoints/webrtc_publish_endpoint.rs b/src/api/control/endpoints/webrtc_publish_endpoint.rs index 62e435881..f48d93838 100644 --- a/src/api/control/endpoints/webrtc_publish_endpoint.rs +++ b/src/api/control/endpoints/webrtc_publish_endpoint.rs @@ -1,4 +1,6 @@ -//! `WebRtcPublishEndpoint` implementation. +//! `WebRtcPublishEndpoint` [Control API]'s element implementation. +//! +//! [Control API]: http://tiny.cc/380uaz use derive_more::{Display, From}; use serde::Deserialize; diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index 54b45057c..d4ea00acd 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -1,6 +1,8 @@ -//! Implementation of gRPC control API. +//! Implementation of [Control API] gRPC server. +//! +//! [Control API]: http://tiny.cc/380uaz -// Fix clippy needless_return in macro. +// Fix clippy's needless_return bug in try_fut! macro. #![allow(clippy::needless_return)] use std::{collections::HashMap, convert::TryFrom, sync::Arc}; @@ -59,7 +61,9 @@ pub enum GrpcControlApiError { /// [medea]: https://github.com/instrumentisto/medea TryFromProtobuf(TryFromProtobufError), - /// Some error in provided [Control API] spec. + /// This is __unexpected error__ because this kind of errors + /// should be catched by `try_from_protobuf` function which returns + /// [`TryFromProtobufError`]. /// /// [Control API]: http://tiny.cc/380uaz TryFromElement(TryFromElementError), @@ -105,8 +109,8 @@ impl From for GrpcControlApiError { } } -/// Try to unwrap some [`Result`] and if it `Err` then return err future with -/// [`ControlApiError`]. +/// Tries to unwrap some [`Result`] and if it `Err` then returns err [`Future`] +/// with [`ControlApiError`]. /// /// __Note:__ this macro returns [`Either::B`]. macro_rules! fut_try { @@ -122,7 +126,8 @@ macro_rules! fut_try { }; } -/// Macro for parse [`LocalUri`] and send error to client if some error occurs. +/// Macro for [`LocalUri`] parsing and sending error to client if some error +/// occurs. /// /// See `send_error_response` doc for details about arguments for this macro. macro_rules! parse_local_uri { @@ -145,9 +150,9 @@ macro_rules! parse_local_uri { /// `$response` - type of response ([`GetResponse`], [`Response`] /// etc). /// -/// `$ctx` - context where `Future` for send gRPC response will be spawned. +/// `$ctx` - context where [`Future`] for send gRPC response will be spawned. /// -/// `$sink` - `grpcio` sink for response. +/// `$sink` - [`grpcio`]'s sink for response. macro_rules! send_error_response { ($ctx:tt, $sink:tt, $error_code:expr, $response:ty) => { let mut response = <$response>::new(); @@ -165,6 +170,7 @@ macro_rules! send_error_response { /// Type alias for success [`CreateResponse`]'s sids. type Sids = HashMap; +/// Service which provides gRPC [Control API] implementation. #[derive(Clone)] struct ControlApiService { /// [`Addr`] of [`RoomService`]. @@ -331,7 +337,11 @@ impl ControlApi for ControlApiService { })); } - /// Implementation for `Apply` method of gRPC [Control API]. + /// Implementation for `Apply` method of gRPC [Control API] (__unimplemented + /// atm__). + /// + /// Currently this is stub which returns fail response with + /// [`RpcStatusCode::Unimplemented`]. /// /// [Control API]: http://tiny.cc/380uaz fn apply( diff --git a/src/api/control/local_uri.rs b/src/api/control/local_uri.rs index 050fe9115..7a6770d35 100644 --- a/src/api/control/local_uri.rs +++ b/src/api/control/local_uri.rs @@ -1,5 +1,6 @@ //! URI for pointing to some medea element. +// Fix clippy's wrong errors for `Self` in `LocalUri`s with states as generics. #![allow(clippy::use_self)] use std::{convert::TryFrom, fmt, string::ToString}; @@ -12,127 +13,6 @@ use crate::api::control::endpoints::webrtc_play_endpoint::SrcUri; use super::{MemberId, RoomId}; -/// Error which can happen while [`LocalUri`] parsing. -#[allow(clippy::module_name_repetitions)] -#[derive(Debug, Fail, Display)] -pub enum LocalUriParseError { - /// Protocol of provided URI is not "local://". - #[display(fmt = "Provided URIs protocol is not 'local://'.")] - NotLocal(String), - - /// Too many paths in provided URI. - /// - /// `local://room_id/member_id/endpoint_id/redundant_path` for example. - #[display(fmt = "Too many paths in provided URI ({}).", _0)] - TooManyPaths(String), - - /// Some paths is missing in URI. - /// - /// `local://room_id//qwerty` for example. - #[display(fmt = "Missing fields. {}", _0)] - MissingPaths(String), - - /// Error while parsing URI by [`url::Url`]. - #[display(fmt = "Error while parsing URL. {:?}", _0)] - UrlParseErr(String, url::ParseError), - - /// Provided empty URI. - #[display(fmt = "You provided empty local uri.")] - Empty, -} - -/// Enum for store [`LocalUri`]s in all states. -#[allow(clippy::module_name_repetitions)] -#[derive(Debug, Hash, PartialEq, Eq, Clone, Display, From)] -pub enum StatefulLocalUri { - /// Stores [`LocalUri`] in [`IsRoomId`] state. - Room(LocalUri), - - /// Stores [`LocalUri`] in [`IsMemberId`] state. - Member(LocalUri), - - /// Stores [`LocalUri`] in [`IsEndpointId`] state. - Endpoint(LocalUri), -} - -impl StatefulLocalUri { - /// Returns reference to [`RoomId`]. - /// - /// This is possible in any [`LocalUri`] state. - pub fn room_id(&self) -> &RoomId { - match self { - StatefulLocalUri::Room(uri) => uri.room_id(), - StatefulLocalUri::Member(uri) => uri.room_id(), - StatefulLocalUri::Endpoint(uri) => uri.room_id(), - } - } -} - -impl TryFrom<&str> for StatefulLocalUri { - type Error = LocalUriParseError; - - fn try_from(value: &str) -> Result { - if value.is_empty() { - return Err(LocalUriParseError::Empty); - } - - let url = match Url::parse(value) { - Ok(url) => url, - Err(e) => { - return Err(LocalUriParseError::UrlParseErr( - value.to_string(), - e, - )); - } - }; - - if url.scheme() != "local" { - return Err(LocalUriParseError::NotLocal(value.to_string())); - } - - let room_uri = url - .host() - .map(|id| id.to_string()) - .filter(|id| !id.is_empty()) - .map(|id| LocalUri::::new(id.into())) - .ok_or_else(|| { - LocalUriParseError::MissingPaths(value.to_string()) - })?; - - let mut path = match url.path_segments() { - Some(path) => path, - None => return Ok(Self::from(room_uri)), - }; - - let member_id = path - .next() - .filter(|id| !id.is_empty()) - .map(|id| MemberId(id.to_string())); - - let endpoint_id = path - .next() - .filter(|id| !id.is_empty()) - .map(ToString::to_string); - - if path.next().is_some() { - return Err(LocalUriParseError::TooManyPaths(value.to_string())); - } - - if let Some(member_id) = member_id { - let member_uri = room_uri.push_member_id(member_id); - if let Some(endpoint_id) = endpoint_id { - Ok(Self::from(member_uri.push_endpoint_id(endpoint_id))) - } else { - Ok(Self::from(member_uri)) - } - } else if endpoint_id.is_some() { - Err(LocalUriParseError::MissingPaths(value.to_string())) - } else { - Ok(Self::from(room_uri)) - } - } -} - /// State of [`LocalUri`] which points to [`Room`]. /// /// [`Room`]: crate::signalling::room::Room @@ -151,9 +31,9 @@ pub struct IsMemberId(LocalUri, MemberId); #[derive(Debug, PartialEq, Hash, Eq, Clone)] pub struct IsEndpointId(LocalUri, String); -/// Uri in format `local://room_id/member_id/endpoint_id`. +/// URI in format `local://room_id/member_id/endpoint_id`. /// -/// This kind of uri used for pointing to some element in spec ([`Room`], +/// This kind of URI used for pointing to some element in spec ([`Room`], /// [`Member`], [`WebRtcPlayEndpoint`], [`WebRtcPublishEndpoint`], etc) based on /// state. /// @@ -339,6 +219,121 @@ impl fmt::Display for LocalUri { } } +/// Error which can happen while [`LocalUri`] parsing. +#[allow(clippy::module_name_repetitions)] +#[derive(Debug, Fail, Display)] +pub enum LocalUriParseError { + /// Protocol of provided URI is not "local://". + #[display(fmt = "Provided URIs protocol is not 'local://'.")] + NotLocal(String), + + /// Too many paths in provided URI. + /// + /// `local://room_id/member_id/endpoint_id/redundant_path` for example. + #[display(fmt = "Too many paths in provided URI ({}).", _0)] + TooManyPaths(String), + + /// Some paths is missing in URI. + /// + /// `local://room_id//qwerty` for example. + #[display(fmt = "Missing fields. {}", _0)] + MissingPaths(String), + + /// Error while parsing URI by [`url::Url`]. + #[display(fmt = "Error while parsing URL. {:?}", _0)] + UrlParseErr(String, url::ParseError), + + /// Provided empty URI. + #[display(fmt = "You provided empty local uri.")] + Empty, +} + +/// Enum for storing [`LocalUri`]s in all states. +#[allow(clippy::module_name_repetitions)] +#[derive(Debug, Hash, PartialEq, Eq, Clone, Display, From)] +pub enum StatefulLocalUri { + /// Stores [`LocalUri`] in [`IsRoomId`] state. + Room(LocalUri), + + /// Stores [`LocalUri`] in [`IsMemberId`] state. + Member(LocalUri), + + /// Stores [`LocalUri`] in [`IsEndpointId`] state. + Endpoint(LocalUri), +} + +impl StatefulLocalUri { + /// Returns reference to [`RoomId`]. + /// + /// This is possible in any [`LocalUri`] state. + pub fn room_id(&self) -> &RoomId { + match self { + StatefulLocalUri::Room(uri) => uri.room_id(), + StatefulLocalUri::Member(uri) => uri.room_id(), + StatefulLocalUri::Endpoint(uri) => uri.room_id(), + } + } +} + +impl TryFrom<&str> for StatefulLocalUri { + type Error = LocalUriParseError; + + fn try_from(value: &str) -> Result { + if value.is_empty() { + return Err(LocalUriParseError::Empty); + } + + let url = Url::parse(value).map_err(|e| { + LocalUriParseError::UrlParseErr(value.to_string(), e) + })?; + + if url.scheme() != "local" { + return Err(LocalUriParseError::NotLocal(value.to_string())); + } + + let room_uri = url + .host() + .map(|id| id.to_string()) + .filter(|id| !id.is_empty()) + .map(|id| LocalUri::::new(id.into())) + .ok_or_else(|| { + LocalUriParseError::MissingPaths(value.to_string()) + })?; + + let mut path = match url.path_segments() { + Some(path) => path, + None => return Ok(room_uri.into()), + }; + + let member_id = path + .next() + .filter(|id| !id.is_empty()) + .map(|id| MemberId(id.to_string())); + + let endpoint_id = path + .next() + .filter(|id| !id.is_empty()) + .map(ToString::to_string); + + if path.next().is_some() { + return Err(LocalUriParseError::TooManyPaths(value.to_string())); + } + + if let Some(member_id) = member_id { + let member_uri = room_uri.push_member_id(member_id); + if let Some(endpoint_id) = endpoint_id { + Ok(member_uri.push_endpoint_id(endpoint_id).into()) + } else { + Ok(member_uri.into()) + } + } else if endpoint_id.is_some() { + Err(LocalUriParseError::MissingPaths(value.to_string())) + } else { + Ok(room_uri.into()) + } + } +} + #[cfg(test)] mod tests { use super::*; @@ -349,7 +344,11 @@ mod tests { if let StatefulLocalUri::Room(room) = local_uri { assert_eq!(room.take_room_id(), RoomId("room_id".to_string())); } else { - unreachable!("{:?}", local_uri); + unreachable!( + "Local uri '{}' parsed to {:?} state but should be in \ + IsRoomId state.", + local_uri, local_uri + ); } } @@ -358,7 +357,7 @@ mod tests { let local_uri = StatefulLocalUri::try_from("local://room_id/room_element_id") .unwrap(); - if let StatefulLocalUri::Member(member) = local_uri.clone() { + if let StatefulLocalUri::Member(member) = local_uri { let (element_id, room_uri) = member.take_member_id(); assert_eq!(element_id, MemberId("room_element_id".to_string())); let room_id = room_uri.take_room_id(); @@ -378,7 +377,7 @@ mod tests { "local://room_id/room_element_id/endpoint_id", ) .unwrap(); - if let StatefulLocalUri::Endpoint(endpoint) = local_uri.clone() { + if let StatefulLocalUri::Endpoint(endpoint) = local_uri { let (endpoint_id, member_uri) = endpoint.take_endpoint_id(); assert_eq!(endpoint_id, "endpoint_id".to_string()); let (member_id, room_uri) = member_uri.take_member_id(); diff --git a/src/api/control/member.rs b/src/api/control/member.rs index 54d5fc653..be8e6e4e3 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -109,7 +109,7 @@ impl MemberSpec { } } -/// Generates [`Member`] alphanumeric credentials with +/// Generates alphanumeric credentials for [`Member`] with /// [`MEMBER_CREDENTIALS_LEN`] length. /// /// This credentials will be generated if in dynamic [Control API] spec not @@ -125,7 +125,10 @@ fn generate_member_credentials() -> String { impl TryFrom<&MemberProto> for MemberSpec { type Error = TryFromProtobufError; - /// Serialize [`MemberSpec`] from protobuf object. + /// Deserializes [`MemberSpec`] from protobuf object. + /// + /// Additionally generates [`Member`] credentials if + /// they not provided in protobuf object. fn try_from(value: &MemberProto) -> Result { let mut pipeline = HashMap::new(); for (id, member_element) in value.get_pipeline() { diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index ed6ea6d1f..998590adf 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -32,17 +32,17 @@ pub use self::{ /// Errors which may occur while deserialize protobuf spec. #[derive(Debug, Fail, Display)] pub enum TryFromProtobufError { - /// Error while parsing src uri of [`WebRtcPlayEndpoint`]. + /// Error while parsing [`SrcUri`] of [`WebRtcPlayEndpoint`]. /// /// [`WebRtcPlayEndpoint`]: /// crate::api::control::endpoints::WebRtcPlayEndpoint #[display(fmt = "Src uri parse error: {:?}", _0)] SrcUriError(SrcParseError), - /// Room element doesn't have Member element. Currently this is + /// `Room` element doesn't have `Member` element. Currently this is /// unimplemented. #[display( - fmt = "Room element [id = {}]doesn't have Member element. Currently \ + fmt = "Room element [id = {}] doesn't have Member element. Currently \ this is unimplemented.", _0 )] @@ -61,7 +61,7 @@ impl From for TryFromProtobufError { #[derive(Clone, Deserialize, Debug)] #[serde(tag = "kind")] pub enum RootElement { - /// Represent [`RoomSpec`]. + /// Represents [`RoomSpec`]. /// Can transform into [`RoomSpec`] by `RoomSpec::try_from`. Room { id: RoomId, @@ -89,8 +89,9 @@ pub enum TryFromElementError { #[allow(clippy::pub_enum_variant_names)] #[derive(Debug, Fail, Display)] pub enum LoadStaticControlSpecsError { - /// Error while reading default or provided in config static [Control API] - /// specs dir. + /// Error while reading default or provided in config + /// (`MEDEA_CONTROL.STATIC_SPECS_DIR` environment variable) static [Control + /// API] specs dir. /// /// Atm we only should print `warn!` message to log which prints that /// static specs not loaded. @@ -139,7 +140,7 @@ impl From for LoadStaticControlSpecsError { } } -/// Load [`RoomSpec`] from file with YAML format. +/// Loads [`RoomSpec`] from file with YAML format. pub fn load_from_yaml_file>( path: P, ) -> Result { @@ -151,7 +152,7 @@ pub fn load_from_yaml_file>( Ok(room) } -/// Load all [`RoomSpec`] from YAML files from provided path. +/// Loads all [`RoomSpec`] from YAML files from provided path. pub fn load_static_specs_from_dir>( path: P, ) -> Result, LoadStaticControlSpecsError> { diff --git a/src/api/control/pipeline.rs b/src/api/control/pipeline.rs index 6f53fcd28..205227a3b 100644 --- a/src/api/control/pipeline.rs +++ b/src/api/control/pipeline.rs @@ -3,10 +3,7 @@ //! [Control API]: http://tiny.cc/380uaz use std::{ - collections::{ - hash_map::{IntoIter, Iter}, - HashMap, - }, + collections::{hash_map::Iter, HashMap}, iter::IntoIterator, }; @@ -37,15 +34,6 @@ impl Pipeline { } } -impl IntoIterator for Pipeline { - type IntoIter = IntoIter; - type Item = (String, T); - - fn into_iter(self) -> Self::IntoIter { - self.pipeline.into_iter() - } -} - impl<'a, T> IntoIterator for &'a Pipeline { type IntoIter = Iter<'a, String, T>; type Item = (&'a String, &'a T); diff --git a/src/api/control/room.rs b/src/api/control/room.rs index ce0e2a825..e7a2a625c 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -37,9 +37,9 @@ pub enum RoomElement { }, } -/// [Control API]'s `Room` element specification +/// [Control API]'s `Room` element specification. /// -/// Newtype for [`RootElement::Room`] +/// Newtype for [`RootElement::Room`]. /// /// [Control API]: http://tiny.cc/380uaz #[allow(clippy::module_name_repetitions)] @@ -50,7 +50,7 @@ pub struct RoomSpec { } impl RoomSpec { - /// Deserialize [`RoomSpec`] from protobuf object. + /// Deserializes [`RoomSpec`] from protobuf object. pub fn try_from_protobuf( id: Id, proto: &RoomProto, diff --git a/src/api/error_codes.rs b/src/api/error_codes.rs index 78ea1551f..8fd270842 100644 --- a/src/api/error_codes.rs +++ b/src/api/error_codes.rs @@ -37,7 +37,7 @@ pub struct ErrorResponse { /// All [`ErrorCode`]s have [`Display`] implementation. And this /// implementation will be used if this field is [`None`]. But - /// some times we want to add some error explanation. Then we set this + /// sometimes we want to add some error explanation. Then we set this /// field to [`Some`] and this text will be added to /// [`Display`] implementation's text. /// @@ -50,7 +50,7 @@ pub struct ErrorResponse { } impl ErrorResponse { - /// New normal [`ErrorResponse`] with [`ErrorCode`] and element ID. + /// New [`ErrorResponse`] with [`ErrorCode`] and element ID. pub fn new(error_code: ErrorCode, element_id: &T) -> Self { Self { error_code, @@ -72,7 +72,7 @@ impl ErrorResponse { /// /// Provide unexpected `Error` to this function. /// This error will be printed with [`Display`] implementation - /// of provided `Error`. + /// of provided `Error` as error explanation. pub fn unexpected(unknown_error: &B) -> Self { Self { error_code: ErrorCode::UnexpectedError, @@ -121,8 +121,11 @@ impl Into for ErrorResponse { } } -/// Medea control API errors. -#[derive(Display)] +/// [Medea]'s [Control API] errors. +/// +/// [Medea]: https://github.com/instrumentisto/medea +/// [Control API]: http://tiny.cc/380uaz +#[derive(Debug, Display)] pub enum ErrorCode { /// Unexpected server error. /// diff --git a/src/bin/client.rs b/src/bin/client.rs index 813237dab..554fd1ecf 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -1,9 +1,9 @@ //! This is temporary binary for testing gRPC Control API implementation //! purposes. //! -//! In `control-api-mock-server` this will be deleted. After -//! `control-api-mock-server` you will be able to test it with Control API mock -//! server by calling REST API endpoints. +//! In `control-api-mock-server` branch this will be deleted. After +//! `control-api-mock-server` branch you will be able to test it with Control +//! API mock server by calling REST API endpoints. #![allow(dead_code)] diff --git a/src/conf/client.rs b/src/conf/client.rs index 8a8ff1970..fe09d7f35 100644 --- a/src/conf/client.rs +++ b/src/conf/client.rs @@ -1,4 +1,4 @@ -//! [Client API] HTTP server settings. +//! [Client API]'s HTTP server settings. //! //! [Client API]: http://tiny.cc/c80uaz @@ -7,7 +7,7 @@ use std::net::{IpAddr, Ipv4Addr, SocketAddr, ToSocketAddrs as _}; use serde::{Deserialize, Serialize}; use smart_default::SmartDefault; -/// [Client API] HTTP server settings. +/// [Client API]'s HTTP server settings. /// /// [Client API]: http://tiny.cc/c80uaz #[derive(Clone, Debug, Deserialize, Serialize, SmartDefault)] diff --git a/src/conf/control.rs b/src/conf/control.rs index 26921d83c..97e04a38d 100644 --- a/src/conf/control.rs +++ b/src/conf/control.rs @@ -5,7 +5,7 @@ use serde::{Deserialize, Serialize}; use smart_default::SmartDefault; -use crate::conf::Grpc; +use super::Grpc; /// [Control API] settings. /// diff --git a/src/conf/log.rs b/src/conf/log.rs index 2600d2840..8a787307e 100644 --- a/src/conf/log.rs +++ b/src/conf/log.rs @@ -4,6 +4,7 @@ use std::str::FromStr as _; use serde::{Deserialize, Serialize}; use smart_default::SmartDefault; +use std::borrow::Cow; /// Logging settings. #[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, SmartDefault)] @@ -11,8 +12,8 @@ use smart_default::SmartDefault; pub struct Log { /// Maximum allowed level of application log entries. /// Defaults to `INFO`. - #[default(String::from("INFO"))] - pub level: String, + #[default("INFO")] + pub level: Cow<'static, str>, } impl Log { diff --git a/src/conf/mod.rs b/src/conf/mod.rs index 8acf4c4a2..66360bde4 100644 --- a/src/conf/mod.rs +++ b/src/conf/mod.rs @@ -36,7 +36,7 @@ static APP_CONF_PATH_ENV_VAR_NAME: &str = "MEDEA_CONF"; #[derive(Clone, Debug, Deserialize, Serialize, Default)] #[serde(default)] pub struct Conf { - /// HTTP server settings. + /// RPC connection settings. pub rpc: Rpc, /// [Client API] connection settings. diff --git a/src/shutdown.rs b/src/shutdown.rs index 52607cdcb..0ace9dcc1 100644 --- a/src/shutdown.rs +++ b/src/shutdown.rs @@ -223,7 +223,7 @@ impl Handler for GracefulShutdown { } } -/// Subscribe recipient to [`GracefulShutdown`]. +/// Subscribes recipient to [`GracefulShutdown`]. pub fn subscribe( shutdown_addr: &Addr, subscriber: Recipient, @@ -235,7 +235,7 @@ pub fn subscribe( })); } -/// Unsubscribe recipient from [`GracefulShutdown`]. +/// Unsubscribes recipient from [`GracefulShutdown`]. pub fn unsubscribe( shutdown_addr: &Addr, subscriber: Recipient, diff --git a/src/signalling/elements/endpoints/mod.rs b/src/signalling/elements/endpoints/mod.rs index 74f5a2d0b..b0d0d6be8 100644 --- a/src/signalling/elements/endpoints/mod.rs +++ b/src/signalling/elements/endpoints/mod.rs @@ -1,10 +1,15 @@ -//! Medea endpoints implementations. +//! [Medea] endpoints implementations. +//! +//! [Medea]: https://github.com/instrumentisto/medea pub mod webrtc; use derive_more::From; use medea_grpc_proto::control::Element as RootElementProto; +/// Enum which can store all kinds of [medea] endpoints. +/// +/// [medea]: https://github.com/instrumentisto/medea #[derive(Clone, Debug, From)] pub enum Endpoint { WebRtcPublishEndpoint(webrtc::WebRtcPublishEndpoint), diff --git a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs index 05d95cd3e..869aedd21 100644 --- a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs @@ -24,7 +24,7 @@ use crate::{ use super::play_endpoint::WebRtcPlayEndpoint; -#[derive(Debug, Clone)] +#[derive(Clone, Debug)] struct WebRtcPublishEndpointInner { /// ID of this [`WebRtcPublishEndpoint`]. id: Id, diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index 7997f1450..8edebebcc 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -83,7 +83,7 @@ pub struct Member(Rc>); #[allow(clippy::module_name_repetitions)] #[derive(Debug)] struct MemberInner { - /// [`RoomId`] of [`Room`] to which this member relates. + /// [`RoomId`] of [`Room`] to which this [`Member`] relates. room_id: RoomId, /// ID of this [`Member`]. @@ -118,7 +118,7 @@ impl Member { }))) } - /// Lookup [`MemberSpec`] by [`MemberId`] from [`MemberSpec`]. + /// Lookups [`MemberSpec`] by [`MemberId`] from [`MemberSpec`]. /// /// Returns [`MembersLoadError::MemberNotFound`] when member not found. /// Returns [`MembersLoadError::TryFromError`] when found element which is @@ -431,6 +431,8 @@ impl Member { member.insert_sink(sink); } + /// Lookups [`WebRtcPublishEndpoint`] and [`WebRtcPlayEndpoint`] at one + /// moment by ID. pub fn get_endpoint_by_id( &self, id: String, diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 8bd90dca0..0a1f5aaf7 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -139,10 +139,11 @@ impl ParticipantService { self.members.get(id).cloned() } - /// Generates [`LocalUri`] which point to some [`Member`] in this `Room`. + /// Generates [`LocalUri`] which point to some [`Member`] in this + /// [`ParticipantService`]'s [`Room`]. /// - /// __Note__ this function don't check presence of [`Member`] in this - /// `Room`. + /// __Note__ this function don't check presence of [`Member`] in + /// [`ParticipantService`]. fn get_local_uri_to_member( &self, member_id: MemberId, @@ -152,7 +153,7 @@ impl ParticipantService { /// Lookups [`Member`] by [`MemberId`]. /// - /// Returns [`ParticipantServiceErr::ParticipantNotFound`] if member not + /// Returns [`ParticipantServiceErr::ParticipantNotFound`] if [`Member`] not /// found. pub fn get_member( &self, @@ -296,8 +297,11 @@ impl ParticipantService { debug!("Connection for member [id = {}] removed.", member_id); self.connections.remove(&member_id); ctx.spawn(wrap_future( - self.delete_ice_user(&member_id).map_err(|err| { - error!("Error deleting IceUser {:?}", err) + self.delete_ice_user(&member_id).map_err(move |err| { + error!( + "Error deleting IceUser of Member [id = {}]. {:?}", + member_id, err + ) }), )); // TODO: we have no way to handle absence of RpcConnection right @@ -308,11 +312,13 @@ impl ParticipantService { member_id.clone(), ctx.run_later( self.app.config.rpc.reconnect_timeout, - move |_, ctx| { + move |room, ctx| { info!( "Member [id = {}] connection lost at {:?}. \ - Room will be be stopped.", - member_id, closed_at + Room [id = {}] will be be stopped.", + member_id, + closed_at, + room.id() ); ctx.notify(RpcConnectionClosed { member_id, @@ -380,7 +386,7 @@ impl ParticipantService { } /// Deletes [`Member`] from [`ParticipantService`], remove this user from - /// [`TurnAuthService`], close RPC connection with him and remove drop + /// [`TurnAuthService`], closes RPC connection with him and removes drop /// connection task. /// /// [`TurnAuthService`]: crate::turn::service::TurnAuthService @@ -465,7 +471,7 @@ impl ParticipantService { Ok(()) } - /// Create new [`WebRtcPlayEndpoint`] in specified [`Member`]. + /// Creates new [`WebRtcPlayEndpoint`] in specified [`Member`]. /// /// This function will check that new [`WebRtcPlayEndpoint`]'s ID is not /// present in [`ParticipantService`]. @@ -479,11 +485,13 @@ impl ParticipantService { spec: WebRtcPlayEndpointSpec, ) -> Result<(), ParticipantServiceErr> { let member = self.get_member(&member_id)?; - if member.get_sink_by_id(&endpoint_id).is_some() - || member - .get_src_by_id(&WebRtcPublishId(endpoint_id.0.clone())) - .is_some() - { + + let is_member_have_this_sink_id = + member.get_sink_by_id(&endpoint_id).is_some(); + let is_member_have_this_src_id = member + .get_src_by_id(&WebRtcPublishId(endpoint_id.0.clone())) + .is_some(); + if is_member_have_this_sink_id || is_member_have_this_src_id { return Err(ParticipantServiceErr::EndpointAlreadyExists( member.get_local_uri_to_endpoint(endpoint_id.to_string()), )); @@ -511,7 +519,7 @@ impl ParticipantService { Ok(()) } - /// Create new [`WebRtcPlayEndpoint`] in specified [`Member`]. + /// Creates new [`WebRtcPlayEndpoint`] in specified [`Member`]. /// /// This function will check that new [`WebRtcPublishEndpoint`]'s ID is not /// present in [`ParticipantService`]. @@ -526,11 +534,12 @@ impl ParticipantService { ) -> Result<(), ParticipantServiceErr> { let member = self.get_member(&member_id)?; - if member.get_src_by_id(&endpoint_id).is_some() - || member - .get_sink_by_id(&WebRtcPlayId(endpoint_id.0.clone())) - .is_some() - { + let is_member_have_this_src_id = + member.get_src_by_id(&endpoint_id).is_some(); + let is_member_have_this_sink_id = member + .get_sink_by_id(&WebRtcPlayId(endpoint_id.0.clone())) + .is_some(); + if is_member_have_this_sink_id || is_member_have_this_src_id { return Err(ParticipantServiceErr::EndpointAlreadyExists( member.get_local_uri_to_endpoint(endpoint_id.to_string()), )); diff --git a/src/signalling/peers.rs b/src/signalling/peers.rs index 13db43b04..1e05eb10a 100644 --- a/src/signalling/peers.rs +++ b/src/signalling/peers.rs @@ -175,7 +175,7 @@ impl PeerRepository { /// Deletes [`PeerStateMachine`]s from this [`PeerRepository`] and send /// [`Event::PeersRemoved`] to [`Member`]s. /// - /// __Note:__ this also delete partner peers. + /// __Note:__ this also deletes partner peers. /// /// [`Event::PeersRemoved`]: medea_client_api_proto::Event::PeersRemoved pub fn remove_peers( @@ -248,7 +248,7 @@ impl PeerRepository { /// Deletes [`PeerStateMachine`] from this [`PeerRepository`] and send /// [`Event::PeersRemoved`] to [`Member`]s. /// - /// __Note:__ this also delete partner peer. + /// __Note:__ this also deletes partner peer. /// /// [`Event::PeersRemoved`]: medea_client_api_proto::Event::PeersRemoved pub fn remove_peer( diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 717d88a2e..24309deb7 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -166,6 +166,11 @@ impl Room { self.id.clone() } + /// Returns reference to [`RoomId`] of this [`Room`]. + pub fn id(&self) -> &RoomId { + &self.id + } + /// Sends [`Event::PeerCreated`] to one of specified [`Peer`]s based on /// which of them has any outbound tracks. That [`Peer`] state will be /// changed to [`WaitLocalSdp`] state. Both provided peers must be in @@ -557,7 +562,7 @@ impl Room { )) } - /// Remove [`Peer`]s and call [`Room::member_peers_removed`] for every + /// Removes [`Peer`]s and call [`Room::member_peers_removed`] for every /// [`Member`]. /// /// This will delete [`Peer`]s from [`PeerRepository`] and send @@ -568,32 +573,32 @@ impl Room { peer_ids_to_remove: HashSet, ctx: &mut Context, ) { - let removed_peers = - self.peers.remove_peers(&member_id, peer_ids_to_remove); - for (member_id, peers_id) in removed_peers { - self.member_peers_removed(peers_id, member_id, ctx); - } + self.peers + .remove_peers(&member_id, peer_ids_to_remove) + .into_iter() + .for_each(|(member_id, peers_id)| { + self.member_peers_removed(peers_id, member_id, ctx); + }); } - /// Signal for delete [`Member`] from this [`Room`] + /// Deletes [`Member`] from this [`Room`] by [`MemberId`]. fn delete_member(&mut self, member_id: &MemberId, ctx: &mut Context) { debug!( "Delete Member [id = {}] in room [id = {}].", member_id, self.id ); if let Some(member) = self.members.get_member_by_id(member_id) { - let mut peers = HashSet::new(); - for (_, sink) in member.sinks() { - if let Some(peer_id) = sink.peer_id() { - peers.insert(peer_id); - } - } - - for (_, src) in member.srcs() { - for peer_id in src.peer_ids() { - peers.insert(peer_id); - } - } + let peers: HashSet = member + .sinks() + .values() + .filter_map(WebRtcPlayEndpoint::peer_id) + .chain( + member + .srcs() + .values() + .flat_map(WebRtcPublishEndpoint::peer_ids), + ) + .collect(); self.remove_peers(&member.id(), peers, ctx); } @@ -601,12 +606,12 @@ impl Room { self.members.delete_member(member_id, ctx); debug!( - "Member [id = {}] removed from Room [id = {}].", + "Member [id = {}] deleted from Room [id = {}].", member_id, self.id ); } - /// Signal for delete endpoint from this [`Room`] + /// Deletes endpoint from this [`Room`] by ID. fn delete_endpoint( &mut self, member_id: &MemberId, @@ -657,21 +662,24 @@ impl Into for &mut Room { let mut element = ElementProto::new(); let mut room = RoomProto::new(); - let mut pipeline = HashMap::new(); - for (id, member) in self.members.members() { - let local_uri = LocalUri::::new(self.get_id(), id); + let pipeline = self + .members + .members() + .into_iter() + .map(|(id, member)| { + let local_uri = LocalUri::::new(self.get_id(), id); + (local_uri.to_string(), member.into()) + }) + .collect(); - pipeline.insert(local_uri.to_string(), member.into()); - } room.set_pipeline(pipeline); - element.set_room(room); element } } -/// Message for serializing this [`Room`] and [`Room`] elements to protobuf +/// Message for serializing this [`Room`] and [`Room`]'s elements to protobuf /// spec. #[derive(Message)] #[rtype(result = "Result, RoomError>")] @@ -882,13 +890,13 @@ impl Handler for Room { if self.members.member_has_connection(&id) { let peer_ids_to_remove: HashSet = member .sinks() - .into_iter() - .filter_map(|(_, sink)| sink.peer_id()) + .values() + .filter_map(WebRtcPlayEndpoint::peer_id) .chain( member .srcs() - .into_iter() - .flat_map(|(_, src)| src.peer_ids().into_iter()), + .values() + .flat_map(|src| src.peer_ids().into_iter()), ) .collect(); @@ -939,7 +947,7 @@ impl Handler for Room { } } -/// Create new [`Member`] in this [`Room`]. +/// Signal for create new [`Member`] in this [`Room`]. #[derive(Message, Debug)] #[rtype(result = "Result<(), RoomError>")] pub struct CreateMember(pub MemberId, pub MemberSpec); @@ -950,15 +958,18 @@ impl Handler for Room { fn handle( &mut self, msg: CreateMember, - _ctx: &mut Self::Context, + _: &mut Self::Context, ) -> Self::Result { self.members.create_member(msg.0.clone(), &msg.1)?; - debug!("Create Member [id = {}] in Room [id = {}].", msg.0, self.id); + debug!( + "Member [id = {}] created in Room [id = {}].", + msg.0, self.id + ); Ok(()) } } -/// Create new `Endpoint` from [`EndpointSpec`]. +/// Signal for create new `Endpoint` from [`EndpointSpec`]. #[derive(Message, Debug)] #[rtype(result = "Result<(), RoomError>")] pub struct CreateEndpoint { @@ -976,18 +987,18 @@ impl Handler for Room { _ctx: &mut Self::Context, ) -> Self::Result { match msg.spec { - EndpointSpec::WebRtcPlay(e) => { + EndpointSpec::WebRtcPlay(endpoint) => { self.members.create_sink_endpoint( &msg.member_id, &WebRtcPlayId(msg.endpoint_id), - e, + endpoint, )?; } - EndpointSpec::WebRtcPublish(e) => { + EndpointSpec::WebRtcPublish(endpoint) => { self.members.create_src_endpoint( &msg.member_id, &WebRtcPublishId(msg.endpoint_id), - e, + endpoint, )?; } } diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs index f9852a1c5..706d18fe5 100644 --- a/src/signalling/room_repo.rs +++ b/src/signalling/room_repo.rs @@ -41,7 +41,7 @@ impl RoomRepository { self.rooms.lock().unwrap().insert(id, room); } - /// Check existence of [`Room`] in [`RoomRepository`] by provided + /// Checks existence of [`Room`] in [`RoomRepository`] by provided /// [`RoomId`]. pub fn is_contains_room_with_id(&self, id: &RoomId) -> bool { self.rooms.lock().unwrap().contains_key(id) diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index ef657f9cb..214ee52dc 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -113,7 +113,7 @@ pub struct RoomService { } impl RoomService { - /// Create new [`RoomService`]. + /// Creates new [`RoomService`]. pub fn new( room_repo: RoomRepository, app: AppContext, @@ -203,9 +203,7 @@ impl Handler for RoomService { } } -/// Implementation of [Control API]'s `Create` method. -/// -/// [Control API]: http://tiny.cc/380uaz +/// Signal for creating new `Room`. #[derive(Message)] #[rtype(result = "Result<(), RoomServiceError>")] pub struct CreateRoom { @@ -219,7 +217,7 @@ impl Handler for RoomService { fn handle( &mut self, msg: CreateRoom, - _ctx: &mut Self::Context, + _: &mut Self::Context, ) -> Self::Result { let room_id = msg.uri.take_room_id(); @@ -254,6 +252,8 @@ pub struct Validated; /// [`Unvalidated`] state before sending to [`RoomService`]. pub struct Unvalidated; +// Clippy lint show use_self errors for DeleteElements with generic state. This +// is fix for it. #[allow(clippy::use_self)] impl DeleteElements { pub fn new() -> DeleteElements { @@ -374,9 +374,8 @@ impl Handler> for RoomService { } } -/// Implementation of [Control API]'s `Get` method. -/// -/// [Control API]: http://tiny.cc/380uaz +/// Message which returns serialized to protobuf objects by provided +/// [`LocalUri`]. #[derive(Message)] #[rtype(result = "Result, \ RoomServiceError>")] diff --git a/src/turn/service.rs b/src/turn/service.rs index ab9c2b80a..bdc18018e 100644 --- a/src/turn/service.rs +++ b/src/turn/service.rs @@ -245,21 +245,19 @@ impl Handler for Service { self.new_password(TURN_PASS_LEN), ); - Box::new( - self.turn_db.insert(&ice_user).into_actor(self).then( - move |result, act, _| { - wrap_future(match result { - Ok(_) => ok(ice_user), - Err(e) => match msg.policy { - UnreachablePolicy::ReturnErr => err(e.into()), - UnreachablePolicy::ReturnStatic => { - ok(act.static_user()) - } - }, - }) - }, - ), - ) + Box::new(self.turn_db.insert(&ice_user).into_actor(self).then( + move |result, act, _| { + wrap_future(match result { + Ok(_) => ok(ice_user), + Err(e) => match msg.policy { + UnreachablePolicy::ReturnErr => err(e.into()), + UnreachablePolicy::ReturnStatic => { + ok(act.static_user()) + } + }, + }) + }, + )) } } From 644eedd8869159a77e838ef99ee53cb08619f1f6 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 11 Sep 2019 16:56:32 +0300 Subject: [PATCH 624/735] Fix building of medea-build in CI [run ci] --- .travis.yml | 1 + _build/medea-build/Dockerfile | 2 +- src/signalling/room.rs | 35 +++++++++-------------------------- 3 files changed, 11 insertions(+), 27 deletions(-) diff --git a/.travis.yml b/.travis.yml index bee232a2a..9363e8e79 100644 --- a/.travis.yml +++ b/.travis.yml @@ -52,6 +52,7 @@ jobs: stage: build rust: stable services: ["docker"] + before_script: make docker.build.medea-build script: make docker.build.medea debug=no TAG=build-${TRAVIS_BUILD_ID} registry=quay.io before_deploy: echo "$QUAYIO_PASS" diff --git a/_build/medea-build/Dockerfile b/_build/medea-build/Dockerfile index 19f3e8196..7171ae7be 100644 --- a/_build/medea-build/Dockerfile +++ b/_build/medea-build/Dockerfile @@ -4,7 +4,7 @@ # https://hub.docker.com/_/rust ARG rust_ver=latest -FROM rust:${rust_ver} AS dist +FROM rust:${rust_ver} ARG rustc_mode=release ARG rustc_opts=--release ARG cargo_home=/usr/local/cargo diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 24309deb7..5b78c9f4d 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -584,7 +584,7 @@ impl Room { /// Deletes [`Member`] from this [`Room`] by [`MemberId`]. fn delete_member(&mut self, member_id: &MemberId, ctx: &mut Context) { debug!( - "Delete Member [id = {}] in room [id = {}].", + "Deleting Member [id = {}] in Room [id = {}].", member_id, self.id ); if let Some(member) = self.members.get_member_by_id(member_id) { @@ -601,14 +601,14 @@ impl Room { .collect(); self.remove_peers(&member.id(), peers, ctx); - } - self.members.delete_member(member_id, ctx); + self.members.delete_member(member_id, ctx); - debug!( - "Member [id = {}] deleted from Room [id = {}].", - member_id, self.id - ); + debug!( + "Member [id = {}] deleted from Room [id = {}].", + member_id, self.id + ); + } } /// Deletes endpoint from this [`Room`] by ID. @@ -886,25 +886,8 @@ impl Handler for Room { type Result = (); fn handle(&mut self, _: Close, ctx: &mut Self::Context) -> Self::Result { - for (id, member) in self.members.members() { - if self.members.member_has_connection(&id) { - let peer_ids_to_remove: HashSet = member - .sinks() - .values() - .filter_map(WebRtcPlayEndpoint::peer_id) - .chain( - member - .srcs() - .values() - .flat_map(|src| src.peer_ids().into_iter()), - ) - .collect(); - - let member_id = id.clone(); - - self.remove_peers(&member_id, peer_ids_to_remove, ctx); - self.members.delete_member(&member_id, ctx); - } + for id in self.members.members().keys() { + self.delete_member(id, ctx); } let drop_fut = self.members.drop_connections(ctx); ctx.wait(wrap_future(drop_fut)); From d3ca6027a7be9417ddc3b346229da7df740ca0fa Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 11 Sep 2019 18:10:25 +0300 Subject: [PATCH 625/735] Reread --- Makefile | 6 +++--- .../demo/chart/medea-demo/conf/nginx.vh.conf | 5 ++++- .../control/endpoints/webrtc_play_endpoint.rs | 6 +++++- src/api/control/grpc/server.rs | 8 ++++---- src/api/control/local_uri.rs | 8 ++++---- src/api/control/member.rs | 2 ++ src/api/control/mod.rs | 8 ++++++-- src/api/error_codes.rs | 16 ++++++++++------ src/conf/log.rs | 3 +-- src/conf/mod.rs | 2 +- src/main.rs | 2 +- src/signalling/elements/member.rs | 19 ++++++++----------- src/signalling/participants.rs | 6 ++++++ src/signalling/room.rs | 8 ++++++-- src/signalling/room_service.rs | 14 +++++--------- tests/e2e/signalling/mod.rs | 6 +++--- 16 files changed, 69 insertions(+), 50 deletions(-) diff --git a/Makefile b/Makefile index a9a3c40f3..bf3baac97 100644 --- a/Makefile +++ b/Makefile @@ -322,11 +322,11 @@ endif # [up=yes [dockerized=no [debug=(yes|no)]] # [dockerized=yes [TAG=(dev|)] # [registry=] -# [logs=(no|yes)]] +# [log=(no|yes)]] # [wait=(5|)]] test-e2e-env = RUST_BACKTRACE=1 \ - $(if $(call eq,$(logs),yes),,RUST_LOG=warn) \ + $(if $(call eq,$(log),yes),,RUST_LOG=warn) \ MEDEA_CONTROL.STATIC_SPECS_DIR=tests/specs/ \ MEDEA_CONTROL_STATIC_SPECS_DIR=tests/specs/ @@ -334,7 +334,7 @@ test.e2e: ifeq ($(up),yes) make docker.up.coturn background=yes env $(test-e2e-env) \ - make docker.up.medea debug=$(debug) background=yes logs=$(logs) \ + make docker.up.medea debug=$(debug) background=yes log=$(log) \ dockerized=$(dockerized) \ TAG=$(TAG) registry=$(registry) sleep $(if $(call eq,$(wait),),5,$(wait)) diff --git a/jason/demo/chart/medea-demo/conf/nginx.vh.conf b/jason/demo/chart/medea-demo/conf/nginx.vh.conf index 2d096c38f..fa37561f5 100644 --- a/jason/demo/chart/medea-demo/conf/nginx.vh.conf +++ b/jason/demo/chart/medea-demo/conf/nginx.vh.conf @@ -11,7 +11,10 @@ server { } location ^~ /ws/ { - proxy_pass http://127.0.0.1:8080/; + proxy_pass http://127.0.0.1:8080/ws/; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "Upgrade"; } # Disable unnecessary access logs. diff --git a/src/api/control/endpoints/webrtc_play_endpoint.rs b/src/api/control/endpoints/webrtc_play_endpoint.rs index 800d5b184..64652e2fd 100644 --- a/src/api/control/endpoints/webrtc_play_endpoint.rs +++ b/src/api/control/endpoints/webrtc_play_endpoint.rs @@ -55,7 +55,7 @@ pub enum SrcParseError { LocalUriParseError(String, LocalUriParseError), } -/// Special uri with pattern `local://{room_id}/{member_id}/{endpoint_id}`. +/// Special URI with pattern `local://{room_id}/{member_id}/{endpoint_id}`. /// This uri can pointing only to [`WebRtcPublishEndpoint`]. /// /// Note that [`SrcUri`] is parsing with [`LocalUri`] parser. @@ -82,6 +82,9 @@ pub struct SrcUri { pub member_id: MemberId, /// ID of [`WebRtcPublishEndpoint`]. + /// + /// [`WebRtcPublishEndpoint`]: + /// crate::api::control::endpoints::WebRtcPublishEndpoint pub endpoint_id: WebRtcPublishId, } @@ -116,6 +119,7 @@ impl From> for SrcUri { } /// [Serde] deserializer for [`SrcUri`]. +/// /// Deserializes URIs with pattern: /// `local://room_id/member_id/publish_endpoint_id`. /// diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index d4ea00acd..b9be7cb0f 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -49,7 +49,7 @@ use crate::{ /// Errors which can happen while processing requests to gRPC [Control API]. /// /// [Control API]: http://tiny.cc/380uaz -#[derive(Debug, Fail, Display)] +#[derive(Debug, Display, Fail)] pub enum GrpcControlApiError { /// Error while parsing [`LocalUri`] of element. LocalUri(LocalUriParseError), @@ -438,9 +438,9 @@ impl ControlApi for ControlApiService { .send(Get(uris)) .map_err(GrpcControlApiError::RoomServiceMailboxError) .and_then(|r| r.map_err(GrpcControlApiError::from)) - .then(|res| { + .then(|result| { let mut response = GetResponse::new(); - match res { + match result { Ok(elements) => { response.set_elements( elements @@ -466,7 +466,7 @@ impl ControlApi for ControlApiService { } } -/// Actor wrapper for [`grcio`] gRPC server which provides dynamic [Control +/// Actor wrapper for [`grpcio`] gRPC server which provides dynamic [Control /// API]. /// /// [Control API]: http://tiny.cc/380uaz diff --git a/src/api/control/local_uri.rs b/src/api/control/local_uri.rs index 7a6770d35..c3e56702f 100644 --- a/src/api/control/local_uri.rs +++ b/src/api/control/local_uri.rs @@ -16,19 +16,19 @@ use super::{MemberId, RoomId}; /// State of [`LocalUri`] which points to [`Room`]. /// /// [`Room`]: crate::signalling::room::Room -#[derive(Debug, PartialEq, Hash, Eq, Clone)] +#[derive(Clone, Debug, Eq, Hash, PartialEq)] pub struct IsRoomId(RoomId); /// State of [`LocalUri`] which points to [`Member`]. /// /// [`Member`]: crate::signalling::elements::member::Member -#[derive(Debug, PartialEq, Hash, Eq, Clone)] +#[derive(Clone, Debug, Eq, Hash, PartialEq)] pub struct IsMemberId(LocalUri, MemberId); /// State of [`LocalUri`] which points to [`Endpoint`]. /// /// [`Endpoint`]: crate::signalling::elements::endpoints::Endpoint -#[derive(Debug, PartialEq, Hash, Eq, Clone)] +#[derive(Clone, Debug, Eq, Hash, PartialEq)] pub struct IsEndpointId(LocalUri, String); /// URI in format `local://room_id/member_id/endpoint_id`. @@ -86,7 +86,7 @@ pub struct IsEndpointId(LocalUri, String); /// [`WebRtcPublishEndpoint`]: /// crate::signalling::elements::endpoints::webrtc::WebRtcPublishEndpoint /// [`Endpoint`]: crate::signalling::elements::endpoints::Endpoint -#[derive(Debug, PartialEq, Hash, Eq, Clone)] +#[derive(Clone, Debug, Eq, Hash, PartialEq)] pub struct LocalUri { state: T, } diff --git a/src/api/control/member.rs b/src/api/control/member.rs index be8e6e4e3..6c89f6cfa 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -129,6 +129,8 @@ impl TryFrom<&MemberProto> for MemberSpec { /// /// Additionally generates [`Member`] credentials if /// they not provided in protobuf object. + /// + /// [`Member`]: crate::signalling::elements::member::Member fn try_from(value: &MemberProto) -> Result { let mut pipeline = HashMap::new(); for (id, member_element) in value.get_pipeline() { diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index 998590adf..cacdafc52 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -36,6 +36,8 @@ pub enum TryFromProtobufError { /// /// [`WebRtcPlayEndpoint`]: /// crate::api::control::endpoints::WebRtcPlayEndpoint + /// [`SrcUri`]: + /// crate::api::control::endpoints::webrtc_play_endpoint::SrcUri #[display(fmt = "Src uri parse error: {:?}", _0)] SrcUriError(SrcParseError), @@ -76,16 +78,18 @@ pub enum RootElement { #[allow(clippy::pub_enum_variant_names)] #[derive(Debug, Fail, Clone)] pub enum TryFromElementError { - /// Element is not Room. + /// Element is not `Room`. #[fail(display = "Element is not Room")] NotRoom, - /// Element is not Member. + /// Element is not `Member`. #[fail(display = "Element is not Member")] NotMember, } /// Errors which can happen while loading static [Control API] specs. +/// +/// [Control API]: http://tiny.cc/380uaz #[allow(clippy::pub_enum_variant_names)] #[derive(Debug, Fail, Display)] pub enum LoadStaticControlSpecsError { diff --git a/src/api/error_codes.rs b/src/api/error_codes.rs index 8fd270842..842ab7b03 100644 --- a/src/api/error_codes.rs +++ b/src/api/error_codes.rs @@ -43,7 +43,8 @@ pub struct ErrorResponse { /// /// By default this field should be [`None`]. /// - /// For providing error explanation use [`ErrorResponse::explain`] method. + /// For providing error explanation use [`ErrorResponse::with_explanation`] + /// method. /// /// [`Display`]: std::fmt::Display explanation: Option, @@ -73,6 +74,8 @@ impl ErrorResponse { /// Provide unexpected `Error` to this function. /// This error will be printed with [`Display`] implementation /// of provided `Error` as error explanation. + /// + /// [`Display`]: std::fmt::Display pub fn unexpected(unknown_error: &B) -> Self { Self { error_code: ErrorCode::UnexpectedError, @@ -129,9 +132,10 @@ impl Into for ErrorResponse { pub enum ErrorCode { /// Unexpected server error. /// - /// Use this [`ErrorCode`] only with [`ErrorResponse::unknown`] function. - /// In error text with this code should be error message which explain what - /// exactly goes wrong ([`ErrorResponse::unknown`] do this). + /// Use this [`ErrorCode`] only with [`ErrorResponse::unexpected`] + /// function. In error text with this code should be error message + /// which explain what exactly goes wrong + /// ([`ErrorResponse::unexpected`] do this). /// /// Code: __1000__. #[display(fmt = "Unexpected error happened.")] @@ -285,8 +289,8 @@ pub enum ErrorCode { /// Unimplemented API call. /// /// This code should be with additional text which explains what - /// exactly unimplemented (you can do it with [`ErrorResponse::explain`] - /// function). + /// exactly unimplemented (you can do it with + /// [`ErrorResponse::with_explanation`] function). /// /// Code: __1400__. #[display(fmt = "Unimplemented API call.")] diff --git a/src/conf/log.rs b/src/conf/log.rs index 8a787307e..afd007260 100644 --- a/src/conf/log.rs +++ b/src/conf/log.rs @@ -1,10 +1,9 @@ //! Logging settings. -use std::str::FromStr as _; +use std::{borrow::Cow, str::FromStr as _}; use serde::{Deserialize, Serialize}; use smart_default::SmartDefault; -use std::borrow::Cow; /// Logging settings. #[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, SmartDefault)] diff --git a/src/conf/mod.rs b/src/conf/mod.rs index 66360bde4..a12a48c6d 100644 --- a/src/conf/mod.rs +++ b/src/conf/mod.rs @@ -39,7 +39,7 @@ pub struct Conf { /// RPC connection settings. pub rpc: Rpc, - /// [Client API] connection settings. + /// [Client API] server settings. /// /// [Client API]: http://tiny.cc/c80uaz pub client: Client, diff --git a/src/main.rs b/src/main.rs index 972d65f58..7d58af39e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -77,7 +77,7 @@ fn main() -> Result<(), Error> { grpc::server::run(room_service, app_context); shutdown::subscribe( &graceful_shutdown, - grpc_addr.clone().recipient(), + grpc_addr.recipient(), shutdown::Priority(1), ); diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index 8edebebcc..b782b638c 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -138,10 +138,8 @@ impl Member { MemberSpec::try_from(element).map_err(|e| { MembersLoadError::TryFromError( e, - StatefulLocalUri::Member(LocalUri::::new( - self.room_id(), - member_id.clone(), - )), + LocalUri::::new(self.room_id(), member_id.clone()) + .into(), ) }) } @@ -235,14 +233,13 @@ impl Member { // to which none [`WebRtcPlayEndpoint`] refers. this_member_spec .publish_endpoints() + .filter(|(endpoint_id, _)| self.srcs().get(endpoint_id).is_none()) .for_each(|(endpoint_id, e)| { - if self.srcs().get(&endpoint_id).is_none() { - self.insert_src(WebRtcPublishEndpoint::new( - endpoint_id, - e.p2p.clone(), - this_member.downgrade(), - )); - } + self.insert_src(WebRtcPublishEndpoint::new( + endpoint_id, + e.p2p.clone(), + this_member.downgrade(), + )); }); Ok(()) diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 0a1f5aaf7..2f16739fd 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -56,6 +56,8 @@ use crate::{ #[derive(Debug, Display, Fail)] pub enum ParticipantServiceErr { /// Some error happened in [`TurnAuthService`]. + /// + /// [`TurnAuthService`]: crate::turn::service::TurnAuthService #[display(fmt = "TurnService Error in ParticipantService: {}", _0)] TurnServiceErr(TurnServiceErr), @@ -64,6 +66,8 @@ pub enum ParticipantServiceErr { ParticipantNotFound(LocalUri), /// [`Endpoint`] with provided URI not found. + /// + /// [`Endpoint`]: crate::signalling::elements::endpoints::Endpoint #[display(fmt = "Endpoint [id = {}] not found.", _0)] EndpointNotFound(LocalUri), @@ -76,6 +80,8 @@ pub enum ParticipantServiceErr { ParticipantAlreadyExists(LocalUri), /// Try to create [`Endpoint`] with ID which already exists. + /// + /// [`Endpoint`]: crate::signalling::elements::endpoints::Endpoint #[display(fmt = "Endpoint [id = {}] already exists.", _0)] EndpointAlreadyExists(LocalUri), } diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 5b78c9f4d..3f6b545e7 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -352,7 +352,7 @@ impl Room { } /// Creates [`Peer`] for endpoints if [`Peer`] between endpoint's members - /// doesn't exist. + /// not exist. /// /// Adds `send` track to source member's [`Peer`] and `recv` to /// sink member's [`Peer`]. @@ -655,6 +655,10 @@ impl Room { /// to interact with [`Room`]. impl Actor for Room { type Context = Context; + + fn started(&mut self, _: &mut Self::Context) { + debug!("Room [id = {}] started.", self.id); + } } impl Into for &mut Room { @@ -967,7 +971,7 @@ impl Handler for Room { fn handle( &mut self, msg: CreateEndpoint, - _ctx: &mut Self::Context, + _: &mut Self::Context, ) -> Self::Result { match msg.spec { EndpointSpec::WebRtcPlay(endpoint) => { diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index 214ee52dc..4eaf9089d 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -364,9 +364,7 @@ impl Handler> for RoomService { .map_err(RoomServiceError::RoomMailboxErr), )) } else { - Box::new(actix::fut::err(RoomServiceError::RoomNotFound( - get_local_uri_to_room(room_id), - ))) + Box::new(actix::fut::ok(())) } } else { Box::new(actix::fut::err(RoomServiceError::EmptyUrisList)) @@ -385,7 +383,6 @@ impl Handler for RoomService { type Result = ActFuture, RoomServiceError>; - // TODO: use validation state machine same as Delete method fn handle(&mut self, msg: Get, _: &mut Self::Context) -> Self::Result { let mut rooms_elements = HashMap::new(); for uri in msg.0 { @@ -406,15 +403,14 @@ impl Handler for RoomService { } let mut futs = Vec::new(); - for (room_id, elements) in rooms_elements { + for (room_id, mut elements) in rooms_elements { if let Some(room) = self.room_repo.get(&room_id) { futs.push(room.send(SerializeProto(elements))); } else { return Box::new(actix::fut::err( - // TODO: better return RoomNotFoundForElement err - RoomServiceError::RoomNotFound(get_local_uri_to_room( - room_id, - )), + RoomServiceError::RoomNotFoundForElement( + elements.remove(0), + ), )); } } diff --git a/tests/e2e/signalling/mod.rs b/tests/e2e/signalling/mod.rs index e8253ff76..e4c8b2ee7 100644 --- a/tests/e2e/signalling/mod.rs +++ b/tests/e2e/signalling/mod.rs @@ -92,9 +92,9 @@ impl TestMember { impl Actor for TestMember { type Context = Context; - /// Starts heartbeat and sets a timer that will panic when 5 seconds will - /// expire. The timer is needed because some tests may just stuck and listen - /// socket forever. + /// Start heartbeat and set a timer that will panic when 5 seconds expire. + /// The timer is needed because some tests may just stuck + /// and listen socket forever. fn started(&mut self, ctx: &mut Self::Context) { self.start_heartbeat(ctx); From eb0d72f203f0bb2a52ac938bfd0000f184c0fe53 Mon Sep 17 00:00:00 2001 From: tyranron Date: Wed, 11 Sep 2019 19:59:55 +0300 Subject: [PATCH 626/735] Fix Clippy options --- .clippy.toml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.clippy.toml b/.clippy.toml index a145d07db..34d811afe 100644 --- a/.clippy.toml +++ b/.clippy.toml @@ -8,12 +8,11 @@ doc-valid-idents = [ "IPv4", "IPv6", "JavaScript", "NaN", "NaNs", "OAuth", "OpenGL", "OpenSSH", "OpenSSL", "OpenStreetMap", "TrueType", "iOS", "macOS", "TeX", "LaTeX", "BibTeX", "BibLaTeX", "MinGW", - "WebRTC", "WebSocket", + "gRPC", "WebRTC", "WebSocket", "MediaStream", "MediaStreamConstraints", "MediaStreamTrack", - "RTCConfiguration", "RTCIceCandidate", "RTCIceServer", + "RTCConfiguration", + "RTCIceCandidate", "RTCIceCandidateInit", "RTCIceServer", "RTCPeerConnection", "RTCPeerConnectionIceEvent", "RTCRtpTransceiver", "RTCRtpTransceiverDirection", - "RTCSdpType", "RTCIceCandidateInit", - "WebRTC", "RtcPeerConnection", - "gRPC", + "RTCSdpType", ] From 9c768f8d185f252a3c03fba34c5a7d28ddbcd22c Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 11 Sep 2019 20:30:33 +0300 Subject: [PATCH 627/735] Refactor --- .travis.yml | 6 +- Makefile | 6 +- _ci/rustfmt_install.sh | 9 - proto/grpc/src/lib.rs | 4 +- src/api/client/server.rs | 2 +- src/api/control/grpc/server.rs | 11 +- src/api/control/member.rs | 4 +- src/api/error_codes.rs | 183 ++++++++++----------- src/conf/{client.rs => client_api_http.rs} | 4 +- src/conf/{control.rs => control_api.rs} | 9 +- src/conf/{grpc.rs => control_api_grpc.rs} | 2 +- src/conf/mod.rs | 20 +-- src/conf/server.rs | 33 ++++ src/signalling/room_service.rs | 15 +- 14 files changed, 160 insertions(+), 148 deletions(-) delete mode 100644 _ci/rustfmt_install.sh rename src/conf/{client.rs => client_api_http.rs} (97%) rename src/conf/{control.rs => control_api.rs} (86%) rename src/conf/{grpc.rs => control_api_grpc.rs} (98%) create mode 100644 src/conf/server.rs diff --git a/.travis.yml b/.travis.yml index 9363e8e79..edddd33db 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,7 +22,6 @@ stages: jobs: allow_failures: - rust: nightly - stage: build include: - name: Clippy @@ -36,9 +35,8 @@ jobs: rust: nightly cache: false env: DONT_INSTALL_PROTOC=1 - before_script: - - . ./_ci/rustfmt_install.sh - script: make fmt check=yes rustfmt-rust-ver="${RUSTFMT_RUST_VER}" + before_script: rustup component add rustfmt + script: make fmt check=yes - name: medea-jason (stable) stage: build diff --git a/Makefile b/Makefile index bf3baac97..9d998b013 100644 --- a/Makefile +++ b/Makefile @@ -215,12 +215,10 @@ endif # Format Rust sources with rustfmt. # # Usage: -# make cargo.fmt [check=(no|yes)] [build=(no|yes)] - -rustfmt-rust-ver=nightly +# make cargo.fmt [check=(no|yes)] cargo.fmt: - cargo +${rustfmt-rust-ver} fmt --all $(if $(call eq,$(check),yes),-- --check,) + cargo +nightly fmt --all $(if $(call eq,$(check),yes),-- --check,) # Lint Rust sources with clippy. diff --git a/_ci/rustfmt_install.sh b/_ci/rustfmt_install.sh deleted file mode 100644 index e30ccc627..000000000 --- a/_ci/rustfmt_install.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash - -# Gets latest nightly version which presents rustfmt. -last_nightly_with_rustfmt=$(curl https://rust-lang.github.io/rustup-components-history/x86_64-unknown-linux-gnu/rustfmt) -RUSTFMT_RUST_VER=nightly-${last_nightly_with_rustfmt} -export RUSTFMT_RUST_VER - -rustup toolchain install "${RUSTFMT_RUST_VER}" -rustup component add rustfmt --toolchain "${RUSTFMT_RUST_VER}"-x86_64-unknown-linux-gnu diff --git a/proto/grpc/src/lib.rs b/proto/grpc/src/lib.rs index e55623f21..c8ed4e7f7 100644 --- a/proto/grpc/src/lib.rs +++ b/proto/grpc/src/lib.rs @@ -1,6 +1,6 @@ -//! Generated [medea]'s [Control API] specs. +//! Generated [Medea]'s [Control API] specs. //! -//! [medea]: https://github.com/instrumentisto/medea +//! [Medea]: https://github.com/instrumentisto/medea //! [Control API]: http://tiny.cc/380uaz #![allow(bare_trait_objects)] diff --git a/src/api/client/server.rs b/src/api/client/server.rs index caa078e44..6d70e0f80 100644 --- a/src/api/client/server.rs +++ b/src/api/client/server.rs @@ -98,7 +98,7 @@ pub struct Server(ActixServer); impl Server { /// Starts Client API HTTP server. pub fn run(rooms: RoomRepository, config: Conf) -> io::Result> { - let server_addr = config.client.bind_addr(); + let server_addr = config.server.client.http.bind_addr(); let server = HttpServer::new(move || { App::new() diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index b9be7cb0f..cfbb9feef 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -191,7 +191,10 @@ impl ControlApiService { ) -> String { format!( "{}/{}/{}/{}", - self.app.config.client.public_url, room_id, member_id, credentials + self.app.config.server.client.http.public_url, + room_id, + member_id, + credentials ) } @@ -508,9 +511,9 @@ impl Handler for GrpcServer { /// /// [Control API]: http://tiny.cc/380uaz pub fn run(room_repo: Addr, app: AppContext) -> Addr { - let bind_ip = app.config.control.grpc.bind_ip.to_string(); - let bind_port = app.config.control.grpc.bind_port; - let cq_count = app.config.control.grpc.completion_queue_count; + let bind_ip = app.config.server.control.grpc.bind_ip.to_string(); + let bind_port = app.config.server.control.grpc.bind_port; + let cq_count = app.config.server.control.grpc.completion_queue_count; let service = create_control_api(ControlApiService { app, diff --git a/src/api/control/member.rs b/src/api/control/member.rs index 6c89f6cfa..f30895e2d 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -19,7 +19,7 @@ use crate::api::control::{ Endpoint, TryFromElementError, TryFromProtobufError, WebRtcPlayId, }; -const MEMBER_CREDENTIALS_LEN: usize = 32; +const CREDENTIALS_LEN: usize = 32; /// ID of `Member`. #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, From, Display)] @@ -118,7 +118,7 @@ impl MemberSpec { fn generate_member_credentials() -> String { rand::thread_rng() .sample_iter(&Alphanumeric) - .take(MEMBER_CREDENTIALS_LEN) + .take(CREDENTIALS_LEN) .collect() } diff --git a/src/api/error_codes.rs b/src/api/error_codes.rs index 842ab7b03..c1c425125 100644 --- a/src/api/error_codes.rs +++ b/src/api/error_codes.rs @@ -1,12 +1,12 @@ //! All errors which medea can return to control API user. //! //! # Error codes ranges -//! * __1000...1000__ Unexpected server error -//! * __1001...1099__ Not found errors -//! * __1100...1199__ Spec errors -//! * __1200...1299__ Parse errors -//! * __1300...1399__ Conflicts -//! * __1400...1499__ Misc errors +//! - __1000...1000__ Unexpected server error +//! - __1001...1099__ Not found errors +//! - __1100...1199__ Spec errors +//! - __1200...1299__ Parse errors +//! - __1300...1399__ Conflicts +//! - __1400...1499__ Misc errors use std::string::ToString; @@ -299,88 +299,87 @@ pub enum ErrorCode { impl From for ErrorResponse { fn from(err: ParticipantServiceErr) -> Self { + use ParticipantServiceErr::*; + match err { - ParticipantServiceErr::EndpointNotFound(id) => { - Self::new(ErrorCode::EndpointNotFound, &id) - } - ParticipantServiceErr::ParticipantNotFound(id) => { + EndpointNotFound(id) => Self::new(ErrorCode::EndpointNotFound, &id), + ParticipantNotFound(id) => { Self::new(ErrorCode::MemberNotFound, &id) } - ParticipantServiceErr::ParticipantAlreadyExists(id) => { + ParticipantAlreadyExists(id) => { Self::new(ErrorCode::MemberAlreadyExists, &id) } - ParticipantServiceErr::EndpointAlreadyExists(id) => { + EndpointAlreadyExists(id) => { Self::new(ErrorCode::EndpointAlreadyExists, &id) } - ParticipantServiceErr::TurnServiceErr(_) - | ParticipantServiceErr::MemberError(_) => Self::unexpected(&err), + TurnServiceErr(_) | MemberError(_) => Self::unexpected(&err), } } } impl From for ErrorResponse { fn from(err: TryFromProtobufError) -> Self { + use TryFromProtobufError::*; + match err { - TryFromProtobufError::SrcUriError(e) => e.into(), - TryFromProtobufError::NotMemberElementInRoomElement(id) => { - Self::with_explanation( - ErrorCode::UnimplementedCall, - "Not Member elements in Room element currently is \ - unimplemented." - .to_string(), - Some(id), - ) - } + SrcUriError(e) => e.into(), + NotMemberElementInRoomElement(id) => Self::with_explanation( + ErrorCode::UnimplementedCall, + "Not Member elements in Room element currently is \ + unimplemented." + .to_string(), + Some(id), + ), } } } impl From for ErrorResponse { fn from(err: LocalUriParseError) -> Self { + use LocalUriParseError::*; + match err { - LocalUriParseError::NotLocal(text) => { - Self::new(ErrorCode::ElementIdIsNotLocal, &text) - } - LocalUriParseError::TooManyPaths(text) => { + NotLocal(text) => Self::new(ErrorCode::ElementIdIsNotLocal, &text), + TooManyPaths(text) => { Self::new(ErrorCode::ElementIdIsTooLong, &text) } - LocalUriParseError::Empty => { - Self::without_id(ErrorCode::EmptyElementId) - } - LocalUriParseError::MissingPaths(text) => { + Empty => Self::without_id(ErrorCode::EmptyElementId), + MissingPaths(text) => { Self::new(ErrorCode::MissingFieldsInSrcUri, &text) } - LocalUriParseError::UrlParseErr(id, _) => { - Self::new(ErrorCode::InvalidSrcUri, &id) - } + UrlParseErr(id, _) => Self::new(ErrorCode::InvalidSrcUri, &id), } } } impl From for ErrorResponse { fn from(err: RoomError) -> Self { + use RoomError::*; + match err { - RoomError::MemberError(e) => e.into(), - RoomError::MembersLoadError(e) => e.into(), - RoomError::ParticipantServiceErr(e) => e.into(), - RoomError::WrongRoomId(_, _) - | RoomError::PeerNotFound(_) - | RoomError::NoTurnCredentials(_) - | RoomError::ConnectionNotExists(_) - | RoomError::UnableToSendEvent(_) - | RoomError::PeerError(_) - | RoomError::TryFromElementError(_) - | RoomError::BadRoomSpec(_) - | RoomError::TurnServiceError(_) - | RoomError::ClientError(_) => Self::unexpected(&err), + MemberError(e) => e.into(), + MembersLoadError(e) => e.into(), + ParticipantServiceErr(e) => e.into(), + WrongRoomId(_, _) + | PeerNotFound(_) + | NoTurnCredentials(_) + | ConnectionNotExists(_) + | UnableToSendEvent(_) + | PeerError(_) + | TryFromElementError(_) + | BadRoomSpec(_) + | TurnServiceError(_) + | ClientError(_) => Self::unexpected(&err), } } } impl From for ErrorResponse { fn from(err: MembersLoadError) -> Self { + use MembersLoadError::*; + match err { - MembersLoadError::TryFromError(e, id) => match e { + TryFromError(e, id) => match e { TryFromElementError::NotMember => { Self::new(ErrorCode::NotMemberInSpec, &id) } @@ -388,13 +387,11 @@ impl From for ErrorResponse { Self::new(ErrorCode::NotRoomInSpec, &id) } }, - MembersLoadError::MemberNotFound(id) => { - Self::new(ErrorCode::MemberNotFound, &id) - } - MembersLoadError::PublishEndpointNotFound(id) => { + MemberNotFound(id) => Self::new(ErrorCode::MemberNotFound, &id), + PublishEndpointNotFound(id) => { Self::new(ErrorCode::PublishEndpointNotFound, &id) } - MembersLoadError::PlayEndpointNotFound(id) => { + PlayEndpointNotFound(id) => { Self::new(ErrorCode::PlayEndpointNotFound, &id) } } @@ -403,63 +400,57 @@ impl From for ErrorResponse { impl From for ErrorResponse { fn from(err: MemberError) -> Self { + use MemberError::*; + match err { - MemberError::PlayEndpointNotFound(id) => { + PlayEndpointNotFound(id) => { Self::new(ErrorCode::PlayEndpointNotFound, &id) } - MemberError::PublishEndpointNotFound(id) => { + PublishEndpointNotFound(id) => { Self::new(ErrorCode::PublishEndpointNotFound, &id) } - MemberError::EndpointNotFound(id) => { - Self::new(ErrorCode::EndpointNotFound, &id) - } + EndpointNotFound(id) => Self::new(ErrorCode::EndpointNotFound, &id), } } } impl From for ErrorResponse { fn from(err: SrcParseError) -> Self { + use SrcParseError::*; + match err { - SrcParseError::NotSrcUri(text) => { - Self::new(ErrorCode::NotSourceUri, &text) - } - SrcParseError::LocalUriParseError(_, err) => err.into(), + NotSrcUri(text) => Self::new(ErrorCode::NotSourceUri, &text), + LocalUriParseError(_, err) => err.into(), } } } impl From for ErrorResponse { fn from(err: RoomServiceError) -> Self { + use RoomServiceError::*; + match err { - RoomServiceError::RoomNotFound(id) => { - Self::new(ErrorCode::RoomNotFound, &id) - } - RoomServiceError::RoomAlreadyExists(id) => { + RoomNotFound(id) => Self::new(ErrorCode::RoomNotFound, &id), + RoomAlreadyExists(id) => { Self::new(ErrorCode::RoomAlreadyExists, &id) } - RoomServiceError::RoomError(e) => e.into(), - RoomServiceError::EmptyUrisList => { - Self::without_id(ErrorCode::EmptyElementsList) - } - RoomServiceError::RoomNotFoundForElement(id) => { + RoomError(e) => e.into(), + EmptyUrisList => Self::without_id(ErrorCode::EmptyElementsList), + RoomNotFoundForElement(id) => { Self::new(ErrorCode::RoomNotFoundForProvidedElement, &id) } - RoomServiceError::NotSameRoomIds(ids, expected_room_id) => { - Self::with_explanation( - ErrorCode::ProvidedNotSameRoomIds, - format!( - "Expected Room ID: '{}'. IDs with different Room ID: \ - {:?}", - expected_room_id, - ids.into_iter() - .map(|id| id.to_string()) - .collect::>() - ), - None, - ) - } - RoomServiceError::RoomMailboxErr(_) - | RoomServiceError::FailedToLoadStaticSpecs(_) => { + NotSameRoomIds(ids, expected_room_id) => Self::with_explanation( + ErrorCode::ProvidedNotSameRoomIds, + format!( + "Expected Room ID: '{}'. IDs with different Room ID: {:?}", + expected_room_id, + ids.into_iter() + .map(|id| id.to_string()) + .collect::>() + ), + None, + ), + RoomMailboxErr(_) | FailedToLoadStaticSpecs(_) => { Self::unexpected(&err) } } @@ -468,15 +459,15 @@ impl From for ErrorResponse { impl From for ErrorResponse { fn from(err: GrpcControlApiError) -> Self { + use GrpcControlApiError::*; + match err { - GrpcControlApiError::LocalUri(e) => e.into(), - GrpcControlApiError::TryFromProtobuf(e) => e.into(), - GrpcControlApiError::RoomServiceError(e) => e.into(), - GrpcControlApiError::RoomServiceMailboxError(_) - | GrpcControlApiError::TryFromElement(_) - | GrpcControlApiError::UnknownMailboxErr(_) => { - Self::unexpected(&err) - } + LocalUri(e) => e.into(), + TryFromProtobuf(e) => e.into(), + RoomServiceError(e) => e.into(), + RoomServiceMailboxError(_) + | TryFromElement(_) + | UnknownMailboxErr(_) => Self::unexpected(&err), } } } diff --git a/src/conf/client.rs b/src/conf/client_api_http.rs similarity index 97% rename from src/conf/client.rs rename to src/conf/client_api_http.rs index fe09d7f35..1f09d290a 100644 --- a/src/conf/client.rs +++ b/src/conf/client_api_http.rs @@ -12,7 +12,7 @@ use smart_default::SmartDefault; /// [Client API]: http://tiny.cc/c80uaz #[derive(Clone, Debug, Deserialize, Serialize, SmartDefault)] #[serde(default)] -pub struct Client { +pub struct ClientApiHttpServer { /// Public URL of server. Address for exposed [Client API]. /// /// This address will be returned from [Control API] in `sids` and to @@ -34,7 +34,7 @@ pub struct Client { pub bind_port: u16, } -impl Client { +impl ClientApiHttpServer { /// Builds [`SocketAddr`] from `bind_ip` and `bind_port`. #[inline] pub fn bind_addr(&self) -> SocketAddr { diff --git a/src/conf/control.rs b/src/conf/control_api.rs similarity index 86% rename from src/conf/control.rs rename to src/conf/control_api.rs index 97e04a38d..51d044f28 100644 --- a/src/conf/control.rs +++ b/src/conf/control_api.rs @@ -5,24 +5,17 @@ use serde::{Deserialize, Serialize}; use smart_default::SmartDefault; -use super::Grpc; - /// [Control API] settings. /// /// [Control API]: http://tiny.cc/380uaz #[derive(Clone, Debug, Deserialize, Serialize, SmartDefault)] #[serde(default)] -pub struct Control { +pub struct ControlApi { /// Path to directory with static [Сontrol API] specs. /// /// [Control API]: http://tiny.cc/380uaz #[default(String::from("specs/"))] pub static_specs_dir: String, - - /// gRPC [Control API] server settings. - /// - /// [Control API]: http://tiny.cc/380uaz - pub grpc: Grpc, } #[cfg(test)] diff --git a/src/conf/grpc.rs b/src/conf/control_api_grpc.rs similarity index 98% rename from src/conf/grpc.rs rename to src/conf/control_api_grpc.rs index 4bc16fb0a..b49b7e541 100644 --- a/src/conf/grpc.rs +++ b/src/conf/control_api_grpc.rs @@ -12,7 +12,7 @@ use smart_default::SmartDefault; /// [Control API]: http://tiny.cc/380uaz #[derive(Clone, Debug, Deserialize, Serialize, SmartDefault)] #[serde(default)] -pub struct Grpc { +pub struct ControlApiGrpcServer { /// IP address to bind gRPC server to. Defaults to `0.0.0.0`. #[default(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)))] pub bind_ip: IpAddr, diff --git a/src/conf/mod.rs b/src/conf/mod.rs index a12a48c6d..5f96a0587 100644 --- a/src/conf/mod.rs +++ b/src/conf/mod.rs @@ -1,10 +1,11 @@ //! Provides application configuration options. -pub mod client; -pub mod control; -pub mod grpc; +pub mod client_api_http; +pub mod control_api; +pub mod control_api_grpc; pub mod log; pub mod rpc; +pub mod server; pub mod shutdown; pub mod turn; @@ -16,11 +17,10 @@ use serde::{Deserialize, Serialize}; #[doc(inline)] pub use self::{ - client::Client, - control::Control, - grpc::Grpc, + control_api::ControlApi, log::Log, rpc::Rpc, + server::Server, shutdown::Shutdown, turn::{Redis, Turn}, }; @@ -39,10 +39,8 @@ pub struct Conf { /// RPC connection settings. pub rpc: Rpc, - /// [Client API] server settings. - /// - /// [Client API]: http://tiny.cc/c80uaz - pub client: Client, + /// Servers settings. + pub server: Server, /// TURN server settings. pub turn: Turn, @@ -56,7 +54,7 @@ pub struct Conf { /// [Control API] settings. /// /// [Control API]: http://tiny.cc/380uaz - pub control: Control, + pub control_api: ControlApi, } impl Conf { diff --git a/src/conf/server.rs b/src/conf/server.rs new file mode 100644 index 000000000..24fde0e77 --- /dev/null +++ b/src/conf/server.rs @@ -0,0 +1,33 @@ +use serde::{Deserialize, Serialize}; +use smart_default::SmartDefault; + +use super::{ + client_api_http::ClientApiHttpServer, + control_api_grpc::ControlApiGrpcServer, +}; + +#[derive(Clone, Debug, Deserialize, Serialize, SmartDefault)] +#[serde(default)] +pub struct ClientApiServer { + /// [Client API] server settings. + /// + /// [Client API]: http://tiny.cc/c80uaz + pub http: ClientApiHttpServer, +} + +#[derive(Clone, Debug, Deserialize, Serialize, SmartDefault)] +#[serde(default)] +pub struct ControlApiServer { + /// gRPC [Control API] server settings. + /// + /// [Control API]: http://tiny.cc/380uaz + pub grpc: ControlApiGrpcServer, +} + +#[derive(Clone, Debug, Deserialize, Serialize, SmartDefault)] +#[serde(default)] +pub struct Server { + pub client: ClientApiServer, + + pub control: ControlApiServer, +} diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index 4eaf9089d..31efa66c1 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -178,7 +178,7 @@ impl Handler for RoomService { _: &mut Self::Context, ) -> Self::Result { let room_specs = load_static_specs_from_dir( - self.app.config.control.static_specs_dir.clone(), + self.app.config.control_api.static_specs_dir.clone(), )?; for spec in room_specs { @@ -259,7 +259,7 @@ impl DeleteElements { pub fn new() -> DeleteElements { Self { uris: Vec::new(), - _state: PhantomData, + _validation_state: PhantomData, } } @@ -302,19 +302,26 @@ impl DeleteElements { Ok(DeleteElements { uris, - _state: PhantomData, + _validation_state: PhantomData, }) } } /// Signal for delete [Control API] elements. /// +/// This message can be in two states: [`Validated`] and [`Unvalidated`]. +/// +/// For ability to send this message to [`RoomService`] [`DeleteElements`] +/// should be in [`Validated`] state. You can go to [`Validated`] state +/// from [`Unvalidated`] with [`DeleteElements::validate`] function +/// which will validate all [`StatefulLocalUri`]s. +/// /// [Control API]: http://tiny.cc/380uaz #[derive(Message, Default)] #[rtype(result = "Result<(), RoomServiceError>")] pub struct DeleteElements { uris: Vec, - _state: PhantomData, + _validation_state: PhantomData, } impl Handler> for RoomService { From 36dd20e4994fc9503a4539abb1daa3d83ac71fb8 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 12 Sep 2019 12:41:38 +0300 Subject: [PATCH 628/735] Refactor --- .travis.yml | 1 - Dockerfile | 9 ++- Makefile | 9 --- _build/medea-build/Dockerfile | 26 ------ .../control/endpoints/webrtc_play_endpoint.rs | 6 +- src/api/control/grpc/server.rs | 8 +- src/api/control/local_uri.rs | 80 +++++++++---------- src/conf/client_api_http.rs | 18 ++--- src/conf/control_api.rs | 8 +- src/conf/control_api_grpc.rs | 24 +++--- src/signalling/elements/member.rs | 30 +++---- src/signalling/participants.rs | 14 ++-- src/signalling/room.rs | 4 +- src/signalling/room_service.rs | 23 +++--- 14 files changed, 118 insertions(+), 142 deletions(-) delete mode 100644 _build/medea-build/Dockerfile diff --git a/.travis.yml b/.travis.yml index edddd33db..c92a541da 100644 --- a/.travis.yml +++ b/.travis.yml @@ -50,7 +50,6 @@ jobs: stage: build rust: stable services: ["docker"] - before_script: make docker.build.medea-build script: make docker.build.medea debug=no TAG=build-${TRAVIS_BUILD_ID} registry=quay.io before_deploy: echo "$QUAYIO_PASS" diff --git a/Dockerfile b/Dockerfile index 8e905e133..bb5b16eec 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,8 @@ # # https://hub.docker.com/_/rust -FROM medea-build AS dist +ARG rust_ver=latest +FROM rust:${rust_ver} as dist ARG rustc_mode=release ARG rustc_opts=--release ARG cargo_home=/usr/local/cargo @@ -16,6 +17,12 @@ RUN mkdir -p /out/etc/ \ COPY / /app/ +RUN bash /app/_ci/protoc_install.sh \ + && apt-get update \ + && apt-get install -y cmake golang + +ENV GOPATH /usr/lib/go + # Build project distribution. RUN cd /app \ # Compile project. diff --git a/Makefile b/Makefile index 9d998b013..e14467c34 100644 --- a/Makefile +++ b/Makefile @@ -422,15 +422,6 @@ docker.build.demo: jason/demo -# Build medea's build image. -# -# Usage: -# make docker.build.medea-build - -docker.build.medea-build: - docker build -t medea-build -f _build/medea-build/Dockerfile . - - # Build medea project Docker image. # # Usage: diff --git a/_build/medea-build/Dockerfile b/_build/medea-build/Dockerfile deleted file mode 100644 index 7171ae7be..000000000 --- a/_build/medea-build/Dockerfile +++ /dev/null @@ -1,26 +0,0 @@ -# -# Stage 'dist' creates project distribution. -# - -# https://hub.docker.com/_/rust -ARG rust_ver=latest -FROM rust:${rust_ver} -ARG rustc_mode=release -ARG rustc_opts=--release -ARG cargo_home=/usr/local/cargo - -COPY / /app/ - -# Create the user and group files that will be used in the running container to -# run the process as an unprivileged user. -RUN mkdir -p /out/etc/ \ - && echo 'nobody:x:65534:65534:nobody:/:' > /out/etc/passwd \ - && echo 'nobody:x:65534:' > /out/etc/group - -RUN bash /app/_ci/protoc_install.sh - -RUN apt-get update -RUN apt-get install -y cmake golang -ENV GOPATH /usr/lib/go - -WORKDIR "/app" diff --git a/src/api/control/endpoints/webrtc_play_endpoint.rs b/src/api/control/endpoints/webrtc_play_endpoint.rs index 64652e2fd..bad4d0291 100644 --- a/src/api/control/endpoints/webrtc_play_endpoint.rs +++ b/src/api/control/endpoints/webrtc_play_endpoint.rs @@ -14,7 +14,7 @@ use serde::{ use crate::api::control::{ endpoints::webrtc_publish_endpoint::WebRtcPublishId, - local_uri::{IsEndpointId, LocalUri, LocalUriParseError, StatefulLocalUri}, + local_uri::{ToEndpoint, LocalUri, LocalUriParseError, StatefulLocalUri}, MemberId, RoomId, TryFromProtobufError, }; @@ -104,8 +104,8 @@ impl TryFrom<&str> for SrcUri { } } -impl From> for SrcUri { - fn from(uri: LocalUri) -> Self { +impl From> for SrcUri { + fn from(uri: LocalUri) -> Self { let (endpoint_id, member_uri) = uri.take_endpoint_id(); let (member_id, room_uri) = member_uri.take_member_id(); let room_id = room_uri.take_room_id(); diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index cfbb9feef..77ecaf66e 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -29,7 +29,7 @@ use crate::{ api::{ control::{ local_uri::{ - IsEndpointId, IsMemberId, IsRoomId, LocalUri, + ToEndpoint, ToMember, ToRoom, LocalUri, LocalUriParseError, StatefulLocalUri, }, Endpoint, MemberId, MemberSpec, RoomId, RoomSpec, @@ -202,7 +202,7 @@ impl ControlApiService { pub fn create_room( &mut self, req: &CreateRequest, - uri: LocalUri, + uri: LocalUri, ) -> impl Future { let spec = fut_try!(RoomSpec::try_from_protobuf( uri.room_id().clone(), @@ -233,7 +233,7 @@ impl ControlApiService { pub fn create_member( &mut self, req: &CreateRequest, - uri: LocalUri, + uri: LocalUri, ) -> impl Future { let spec = fut_try!(MemberSpec::try_from(req.get_member())); @@ -256,7 +256,7 @@ impl ControlApiService { pub fn create_endpoint( &mut self, req: &CreateRequest, - uri: LocalUri, + uri: LocalUri, ) -> impl Future { let spec = fut_try!(Endpoint::try_from(req)); diff --git a/src/api/control/local_uri.rs b/src/api/control/local_uri.rs index c3e56702f..bf647c335 100644 --- a/src/api/control/local_uri.rs +++ b/src/api/control/local_uri.rs @@ -17,19 +17,19 @@ use super::{MemberId, RoomId}; /// /// [`Room`]: crate::signalling::room::Room #[derive(Clone, Debug, Eq, Hash, PartialEq)] -pub struct IsRoomId(RoomId); +pub struct ToRoom(RoomId); /// State of [`LocalUri`] which points to [`Member`]. /// /// [`Member`]: crate::signalling::elements::member::Member #[derive(Clone, Debug, Eq, Hash, PartialEq)] -pub struct IsMemberId(LocalUri, MemberId); +pub struct ToMember(LocalUri, MemberId); /// State of [`LocalUri`] which points to [`Endpoint`]. /// /// [`Endpoint`]: crate::signalling::elements::endpoints::Endpoint #[derive(Clone, Debug, Eq, Hash, PartialEq)] -pub struct IsEndpointId(LocalUri, String); +pub struct ToEndpoint(LocalUri, String); /// URI in format `local://room_id/member_id/endpoint_id`. /// @@ -37,17 +37,17 @@ pub struct IsEndpointId(LocalUri, String); /// [`Member`], [`WebRtcPlayEndpoint`], [`WebRtcPublishEndpoint`], etc) based on /// state. /// -/// [`LocalUri`] can be in three states: [`IsRoomId`], [`IsMemberId`], -/// [`IsRoomId`]. This is used for compile time guarantees that some +/// [`LocalUri`] can be in three states: [`ToRoom`], [`ToMember`], +/// [`ToRoom`]. This is used for compile time guarantees that some /// [`LocalUri`] have all mandatory fields. /// /// You also can take value from [`LocalUri`] without clone, but you have to do /// it consistently. For example, if you wish to get [`RoomId`], [`MemberId`] -/// and [`Endpoint`] ID from [`LocalUri`] in [`IsEndpointId`] state you should +/// and [`Endpoint`] ID from [`LocalUri`] in [`ToEndpoint`] state you should /// make this steps: /// /// ``` -/// # use crate::api::control::local_uri::{LocalUri, IsEndpointId}; +/// # use crate::api::control::local_uri::{LocalUri, ToEndpoint}; /// # use crate::api::control::{RoomId, MemberId}; /// # /// let orig_room_id = RoomId("room".to_string()); @@ -55,7 +55,7 @@ pub struct IsEndpointId(LocalUri, String); /// let orig_endpoint_id = "endpoint".to_string(); /// /// // Create new LocalUri for endpoint. -/// let local_uri = LocalUri::::new( +/// let local_uri = LocalUri::::new( /// orig_room_id.clone(), /// orig_member_id.clone(), /// orig_endpoint_id.clone() @@ -91,11 +91,11 @@ pub struct LocalUri { state: T, } -impl LocalUri { - /// Create new [`LocalUri`] in [`IsRoomId`] state. +impl LocalUri { + /// Create new [`LocalUri`] in [`ToRoom`] state. pub fn new(room_id: RoomId) -> Self { Self { - state: IsRoomId(room_id), + state: ToRoom(room_id), } } @@ -110,17 +110,17 @@ impl LocalUri { } /// Push [`MemberId`] to the end of URI and returns - /// [`LocalUri`] in [`IsMemberId`] state. - pub fn push_member_id(self, member_id: MemberId) -> LocalUri { - LocalUri::::new(self.state.0, member_id) + /// [`LocalUri`] in [`ToMember`] state. + pub fn push_member_id(self, member_id: MemberId) -> LocalUri { + LocalUri::::new(self.state.0, member_id) } } -impl LocalUri { - /// Create new [`LocalUri`] in [`IsMemberId`] state. +impl LocalUri { + /// Create new [`LocalUri`] in [`ToMember`] state. pub fn new(room_id: RoomId, member_id: MemberId) -> Self { Self { - state: IsMemberId(LocalUri::::new(room_id), member_id), + state: ToMember(LocalUri::::new(room_id), member_id), } } @@ -134,33 +134,33 @@ impl LocalUri { &self.state.1 } - /// Return [`MemberId`] and [`LocalUri`] in state [`IsRoomId`]. - pub fn take_member_id(self) -> (MemberId, LocalUri) { + /// Return [`MemberId`] and [`LocalUri`] in state [`ToRoom`]. + pub fn take_member_id(self) -> (MemberId, LocalUri) { (self.state.1, self.state.0) } /// Push endpoint ID to the end of URI and returns - /// [`LocalUri`] in [`IsEndpointId`] state. + /// [`LocalUri`] in [`ToEndpoint`] state. pub fn push_endpoint_id( self, endpoint_id: String, - ) -> LocalUri { + ) -> LocalUri { let (member_id, room_uri) = self.take_member_id(); let room_id = room_uri.take_room_id(); - LocalUri::::new(room_id, member_id, endpoint_id) + LocalUri::::new(room_id, member_id, endpoint_id) } } -impl LocalUri { - /// Creates new [`LocalUri`] in [`IsEndpointId`] state. +impl LocalUri { + /// Creates new [`LocalUri`] in [`ToEndpoint`] state. pub fn new( room_id: RoomId, member_id: MemberId, endpoint_id: String, ) -> Self { Self { - state: IsEndpointId( - LocalUri::::new(room_id, member_id), + state: ToEndpoint( + LocalUri::::new(room_id, member_id), endpoint_id, ), } @@ -183,17 +183,17 @@ impl LocalUri { &self.state.1 } - /// Returns [`Endpoint`] id and [`LocalUri`] in [`IsMemberId`] state. + /// Returns [`Endpoint`] id and [`LocalUri`] in [`ToMember`] state. /// /// [`Endpoint`]: crate::signalling::elements::endpoints::Endpoint - pub fn take_endpoint_id(self) -> (String, LocalUri) { + pub fn take_endpoint_id(self) -> (String, LocalUri) { (self.state.1, self.state.0) } } -impl From for LocalUri { +impl From for LocalUri { fn from(uri: SrcUri) -> Self { - LocalUri::::new( + LocalUri::::new( uri.room_id, uri.member_id, uri.endpoint_id.0, @@ -201,19 +201,19 @@ impl From for LocalUri { } } -impl fmt::Display for LocalUri { +impl fmt::Display for LocalUri { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "local://{}", self.state.0) } } -impl fmt::Display for LocalUri { +impl fmt::Display for LocalUri { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}/{}", self.state.0, self.state.1) } } -impl fmt::Display for LocalUri { +impl fmt::Display for LocalUri { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}/{}", self.state.0, self.state.1) } @@ -252,14 +252,14 @@ pub enum LocalUriParseError { #[allow(clippy::module_name_repetitions)] #[derive(Debug, Hash, PartialEq, Eq, Clone, Display, From)] pub enum StatefulLocalUri { - /// Stores [`LocalUri`] in [`IsRoomId`] state. - Room(LocalUri), + /// Stores [`LocalUri`] in [`ToRoom`] state. + Room(LocalUri), - /// Stores [`LocalUri`] in [`IsMemberId`] state. - Member(LocalUri), + /// Stores [`LocalUri`] in [`ToMember`] state. + Member(LocalUri), - /// Stores [`LocalUri`] in [`IsEndpointId`] state. - Endpoint(LocalUri), + /// Stores [`LocalUri`] in [`ToEndpoint`] state. + Endpoint(LocalUri), } impl StatefulLocalUri { @@ -295,7 +295,7 @@ impl TryFrom<&str> for StatefulLocalUri { .host() .map(|id| id.to_string()) .filter(|id| !id.is_empty()) - .map(|id| LocalUri::::new(id.into())) + .map(|id| LocalUri::::new(id.into())) .ok_or_else(|| { LocalUriParseError::MissingPaths(value.to_string()) })?; diff --git a/src/conf/client_api_http.rs b/src/conf/client_api_http.rs index 1f09d290a..c43b19159 100644 --- a/src/conf/client_api_http.rs +++ b/src/conf/client_api_http.rs @@ -61,21 +61,21 @@ mod server_spec { fn overrides_defaults_and_gets_bind_addr() { let default_conf = Conf::default(); - env::set_var("MEDEA_CLIENT.BIND_IP", "5.5.5.5"); - env::set_var("MEDEA_CLIENT.BIND_PORT", "1234"); + env::set_var("MEDEA_SERVER.CLIENT.HTTP.BIND_IP", "5.5.5.5"); + env::set_var("MEDEA_SERVER.CLIENT.HTTP.BIND_PORT", "1234"); let env_conf = Conf::parse().unwrap(); - env::remove_var("MEDEA_CLIENT.BIND_IP"); - env::remove_var("MEDEA_CLIENT.BIND_PORT"); + env::remove_var("MEDEA_SERVER.CLIENT.HTTP.BIND_IP"); + env::remove_var("MEDEA_SERVER.CLIENT.HTTP.BIND_PORT"); - assert_ne!(default_conf.client.bind_ip, env_conf.client.bind_ip); - assert_ne!(default_conf.client.bind_port, env_conf.client.bind_port); + assert_ne!(default_conf.server.client.http.bind_ip, env_conf.server.client.http.bind_ip); + assert_ne!(default_conf.server.client.http.bind_port, env_conf.server.client.http.bind_port); - assert_eq!(env_conf.client.bind_ip, Ipv4Addr::new(5, 5, 5, 5)); - assert_eq!(env_conf.client.bind_port, 1234); + assert_eq!(env_conf.server.client.http.bind_ip, Ipv4Addr::new(5, 5, 5, 5)); + assert_eq!(env_conf.server.client.http.bind_port, 1234); assert_eq!( - env_conf.client.bind_addr(), + env_conf.server.client.http.bind_addr(), "5.5.5.5:1234".parse().unwrap(), ); } diff --git a/src/conf/control_api.rs b/src/conf/control_api.rs index 51d044f28..e572e8b42 100644 --- a/src/conf/control_api.rs +++ b/src/conf/control_api.rs @@ -31,13 +31,13 @@ mod control_conf_specs { fn overrides_defaults() { let default_conf = Conf::default(); - env::set_var("MEDEA_CONTROL.STATIC_SPECS_DIR", "test/"); + env::set_var("MEDEA_CONTROL_API.STATIC_SPECS_DIR", "test/"); let env_conf = Conf::parse().unwrap(); - env::remove_var("MEDEA_CONTROL.STATIC_SPECS_DIR"); + env::remove_var("MEDEA_CONTROL_API.STATIC_SPECS_DIR"); assert_ne!( - default_conf.control.static_specs_dir, - env_conf.control.static_specs_dir + default_conf.control_api.static_specs_dir, + env_conf.control_api.static_specs_dir ); } } diff --git a/src/conf/control_api_grpc.rs b/src/conf/control_api_grpc.rs index b49b7e541..a1d730826 100644 --- a/src/conf/control_api_grpc.rs +++ b/src/conf/control_api_grpc.rs @@ -39,25 +39,25 @@ mod control_grpc_conf_specs { fn overrides_defaults() { let default_conf = Conf::default(); - env::set_var("MEDEA_CONTROL.GRPC.BIND_IP", "127.0.0.1"); - env::set_var("MEDEA_CONTROL.GRPC.BIND_PORT", "44444"); - env::set_var("MEDEA_CONTROL.GRPC.COMPLETION_QUEUE_COUNT", "10"); + env::set_var("MEDEA_SERVER.CONTROL.GRPC.BIND_IP", "127.0.0.1"); + env::set_var("MEDEA_SERVER.CONTROL.GRPC.BIND_PORT", "44444"); + env::set_var("MEDEA_SERVER.CONTROL.GRPC.COMPLETION_QUEUE_COUNT", "10"); let env_conf = Conf::parse().unwrap(); - env::remove_var("MEDEA_CONTROL.GRPC.BIND_IP"); - env::remove_var("MEDEA_CONTROL.GRPC.BIND_PORT"); - env::remove_var("MEDEA_CONTROL.GRPC.COMPLETION_QUEUE_COUNT"); + env::remove_var("MEDEA_SERVER.CONTROL.GRPC.BIND_IP"); + env::remove_var("MEDEA_SERVER.CONTROL.GRPC.BIND_PORT"); + env::remove_var("MEDEA_SERVER.CONTROL.GRPC.COMPLETION_QUEUE_COUNT"); assert_ne!( - default_conf.control.grpc.bind_ip, - env_conf.control.grpc.bind_ip + default_conf.server.control.grpc.bind_ip, + env_conf.server.control.grpc.bind_ip ); assert_ne!( - default_conf.control.grpc.bind_port, - env_conf.control.grpc.bind_port + default_conf.server.control.grpc.bind_port, + env_conf.server.control.grpc.bind_port ); assert_ne!( - default_conf.control.grpc.completion_queue_count, - env_conf.control.grpc.completion_queue_count + default_conf.server.control.grpc.completion_queue_count, + env_conf.server.control.grpc.completion_queue_count ); } } diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index b782b638c..aa352065b 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -21,7 +21,7 @@ use crate::{ api::control::{ endpoints::WebRtcPlayEndpoint as WebRtcPlayEndpointSpec, local_uri::{ - IsEndpointId, IsMemberId, IsRoomId, LocalUri, StatefulLocalUri, + ToEndpoint, ToMember, ToRoom, LocalUri, StatefulLocalUri, }, MemberId, MemberSpec, RoomId, RoomSpec, TryFromElementError, WebRtcPlayId, WebRtcPublishId, @@ -44,34 +44,34 @@ pub enum MembersLoadError { /// [`Member`] not found. #[display(fmt = "Member [id = {}] not found.", _0)] - MemberNotFound(LocalUri), + MemberNotFound(LocalUri), /// [`WebRtcPlayEndpoint`] not found. #[display( fmt = "Play endpoint [id = {}] not found while loading spec,", _0 )] - PlayEndpointNotFound(LocalUri), + PlayEndpointNotFound(LocalUri), /// [`WebRtcPublishEndpoint`] not found. #[display( fmt = "Publish endpoint [id = {}] not found while loading spec.", _0 )] - PublishEndpointNotFound(LocalUri), + PublishEndpointNotFound(LocalUri), } #[allow(clippy::module_name_repetitions, clippy::pub_enum_variant_names)] #[derive(Debug, Fail, Display)] pub enum MemberError { #[display(fmt = "Publish endpoint [id = {}] not found.", _0)] - PublishEndpointNotFound(LocalUri), + PublishEndpointNotFound(LocalUri), #[display(fmt = "Play endpoint [id = {}] not found.", _0)] - PlayEndpointNotFound(LocalUri), + PlayEndpointNotFound(LocalUri), #[display(fmt = "Endpoint [id = {}] not found.", _0)] - EndpointNotFound(LocalUri), + EndpointNotFound(LocalUri), } /// [`Member`] is member of [`Room`]. @@ -130,7 +130,7 @@ impl Member { ) -> Result { let element = room_spec.pipeline.get(&member_id.0).map_or( Err(MembersLoadError::MemberNotFound( - LocalUri::::new(self.room_id(), member_id.clone()), + LocalUri::::new(self.room_id(), member_id.clone()), )), Ok, )?; @@ -138,7 +138,7 @@ impl Member { MemberSpec::try_from(element).map_err(|e| { MembersLoadError::TryFromError( e, - LocalUri::::new(self.room_id(), member_id.clone()) + LocalUri::::new(self.room_id(), member_id.clone()) .into(), ) }) @@ -167,7 +167,7 @@ impl Member { let publisher_member = store.get(&publisher_id).ok_or_else(|| { MembersLoadError::MemberNotFound( - LocalUri::::new( + LocalUri::::new( self.room_id(), publisher_id, ), @@ -246,8 +246,8 @@ impl Member { } /// Returns [`LocalUri`] to this [`Member`]. - fn get_local_uri(&self) -> LocalUri { - LocalUri::::new(self.room_id(), self.id()) + fn get_local_uri(&self) -> LocalUri { + LocalUri::::new(self.room_id(), self.id()) } /// Returns [`LocalUri`] to some endpoint from this [`Member`]. @@ -257,8 +257,8 @@ impl Member { pub fn get_local_uri_to_endpoint( &self, endpoint_id: String, - ) -> LocalUri { - LocalUri::::new(self.room_id(), self.id(), endpoint_id) + ) -> LocalUri { + LocalUri::::new(self.room_id(), self.id(), endpoint_id) } /// Notifies [`Member`] that some [`Peer`]s removed. @@ -490,7 +490,7 @@ pub fn parse_members( let members_spec = room_spec.members().map_err(|e| { MembersLoadError::TryFromError( e, - LocalUri::::new(room_spec.id.clone()).into(), + LocalUri::::new(room_spec.id.clone()).into(), ) })?; diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 2f16739fd..cc8108e69 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -32,7 +32,7 @@ use crate::{ WebRtcPlayEndpoint as WebRtcPlayEndpointSpec, WebRtcPublishEndpoint as WebRtcPublishEndpointSpec, }, - local_uri::{IsEndpointId, IsMemberId, LocalUri}, + local_uri::{ToEndpoint, ToMember, LocalUri}, MemberId, MemberSpec, RoomId, RoomSpec, WebRtcPlayId, WebRtcPublishId, }, @@ -63,13 +63,13 @@ pub enum ParticipantServiceErr { /// [`Member`] with provided [`LocalUri`] not found. #[display(fmt = "Participant [id = {}] not found", _0)] - ParticipantNotFound(LocalUri), + ParticipantNotFound(LocalUri), /// [`Endpoint`] with provided URI not found. /// /// [`Endpoint`]: crate::signalling::elements::endpoints::Endpoint #[display(fmt = "Endpoint [id = {}] not found.", _0)] - EndpointNotFound(LocalUri), + EndpointNotFound(LocalUri), /// Some error happened in [`Member`]. #[display(fmt = "{}", _0)] @@ -77,13 +77,13 @@ pub enum ParticipantServiceErr { /// Try to create [`Member`] with ID which already exists. #[display(fmt = "Participant [id = {}] already exists.", _0)] - ParticipantAlreadyExists(LocalUri), + ParticipantAlreadyExists(LocalUri), /// Try to create [`Endpoint`] with ID which already exists. /// /// [`Endpoint`]: crate::signalling::elements::endpoints::Endpoint #[display(fmt = "Endpoint [id = {}] already exists.", _0)] - EndpointAlreadyExists(LocalUri), + EndpointAlreadyExists(LocalUri), } impl From for ParticipantServiceErr { @@ -153,8 +153,8 @@ impl ParticipantService { fn get_local_uri_to_member( &self, member_id: MemberId, - ) -> LocalUri { - LocalUri::::new(self.room_id.clone(), member_id) + ) -> LocalUri { + LocalUri::::new(self.room_id.clone(), member_id) } /// Lookups [`Member`] by [`MemberId`]. diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 3f6b545e7..da13fc961 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -22,7 +22,7 @@ use crate::{ RpcConnectionClosed, RpcConnectionEstablished, }, control::{ - local_uri::{IsMemberId, LocalUri, StatefulLocalUri}, + local_uri::{ToMember, LocalUri, StatefulLocalUri}, room::RoomSpec, Endpoint as EndpointSpec, MemberId, MemberSpec, RoomId, TryFromElementError, WebRtcPlayId, WebRtcPublishId, @@ -671,7 +671,7 @@ impl Into for &mut Room { .members() .into_iter() .map(|(id, member)| { - let local_uri = LocalUri::::new(self.get_id(), id); + let local_uri = LocalUri::::new(self.get_id(), id); (local_uri.to_string(), member.into()) }) .collect(); diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index 31efa66c1..df9b7e4fe 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -16,7 +16,7 @@ use crate::{ endpoints::Endpoint as EndpointSpec, load_static_specs_from_dir, local_uri::{ - IsEndpointId, IsMemberId, IsRoomId, LocalUri, StatefulLocalUri, + ToEndpoint, ToMember, ToRoom, LocalUri, StatefulLocalUri, }, LoadStaticControlSpecsError, MemberSpec, RoomId, RoomSpec, }, @@ -42,7 +42,7 @@ type ActFuture = pub enum RoomServiceError { /// [`Room`] not found in [`RoomRepository`]. #[display(fmt = "Room [id = {}] not found.", _0)] - RoomNotFound(LocalUri), + RoomNotFound(LocalUri), /// Wrapper for [`Room`]'s [`MailboxError`]. #[display(fmt = "Room mailbox error: {:?}", _0)] @@ -51,7 +51,7 @@ pub enum RoomServiceError { /// Try to create [`Room`] with [`RoomId`] which already exists in /// [`RoomRepository`]. #[display(fmt = "Room [id = {}] already exists.", _0)] - RoomAlreadyExists(LocalUri), + RoomAlreadyExists(LocalUri), /// Some error happened in [`Room`]. /// @@ -160,8 +160,8 @@ impl Actor for RoomService { /// /// __Note__ this function don't check presence of [`Room`] in this /// [`RoomService`]. -fn get_local_uri_to_room(room_id: RoomId) -> LocalUri { - LocalUri::::new(room_id) +fn get_local_uri_to_room(room_id: RoomId) -> LocalUri { + LocalUri::::new(room_id) } /// Signal for load all static specs and start [`Room`]s. @@ -203,11 +203,16 @@ impl Handler for RoomService { } } -/// Signal for creating new `Room`. +/// Signal for creating new [`Room`]. #[derive(Message)] #[rtype(result = "Result<(), RoomServiceError>")] pub struct CreateRoom { - pub uri: LocalUri, + /// [`LocalUri`] with which will be created new [`Room`]. + pub uri: LocalUri, + + /// [Control API] spec for [`Room`]. + /// + /// [Control API]: http://tiny.cc/380uaz pub spec: RoomSpec, } @@ -445,7 +450,7 @@ impl Handler for RoomService { #[derive(Message)] #[rtype(result = "Result<(), RoomServiceError>")] pub struct CreateMemberInRoom { - pub uri: LocalUri, + pub uri: LocalUri, pub spec: MemberSpec, } @@ -482,7 +487,7 @@ impl Handler for RoomService { #[derive(Message)] #[rtype(result = "Result<(), RoomServiceError>")] pub struct CreateEndpointInRoom { - pub uri: LocalUri, + pub uri: LocalUri, pub spec: EndpointSpec, } From aa2d1aa2d4691c8f27cb2cd2fe75e9f58f0f0368 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 12 Sep 2019 16:01:12 +0300 Subject: [PATCH 629/735] Generate medea-control-api-proto and add it to git index, refactor [run ci] --- .rustfmt.toml | 2 + CONTRIBUTING.md | 14 +- Cargo.lock | 4 +- Cargo.toml | 6 +- Dockerfile | 8 +- Makefile | 28 +- _ci/protoc_install.sh | 13 - _dev/config.toml | 2 +- config.toml | 37 +- docker-compose.medea.yml | 4 +- .../demo/chart/medea-demo/conf/nginx.vh.conf | 2 +- .../templates/deployment.server.yaml | 4 +- jason/demo/chart/medea-demo/values.yaml | 8 +- jason/demo/minikube.vals.yaml | 7 +- jason/demo/staging.vals.yaml | 8 +- proto/{grpc => control-api}/CHANGELOG.md | 2 +- proto/{grpc => control-api}/Cargo.toml | 16 +- proto/{grpc => control-api}/LICENSE-APACHE.md | 0 proto/{grpc => control-api}/LICENSE-MIT.md | 0 proto/{grpc => control-api}/README.md | 19 +- proto/control-api/build.rs | 33 + proto/control-api/src/grpc/control_api.proto | 250 + proto/control-api/src/grpc/control_api.rs | 6151 +++++++++++++++++ .../control-api/src/grpc/control_api_grpc.rs | 155 + proto/control-api/src/grpc/mod.rs | 9 + proto/control-api/src/lib.rs | 7 + proto/grpc/build.rs | 22 - proto/grpc/proto/control.proto | 140 - proto/grpc/src/lib.rs | 11 - src/api/control/endpoints/mod.rs | 2 +- .../control/endpoints/webrtc_play_endpoint.rs | 5 +- .../endpoints/webrtc_publish_endpoint.rs | 2 +- src/api/control/grpc/server.rs | 10 +- src/api/control/local_uri.rs | 5 +- src/api/control/member.rs | 2 +- src/api/control/room.rs | 2 +- src/api/error_codes.rs | 14 +- src/bin/client.rs | 6 +- src/conf/client_api_http.rs | 16 +- src/conf/control_api.rs | 1 + src/conf/control_api_grpc.rs | 1 + src/conf/server.rs | 17 + src/signalling/elements/endpoints/mod.rs | 2 +- .../endpoints/webrtc/play_endpoint.rs | 2 +- .../endpoints/webrtc/publish_endpoint.rs | 2 +- src/signalling/elements/member.rs | 23 +- src/signalling/participants.rs | 2 +- src/signalling/room.rs | 6 +- src/signalling/room_service.rs | 6 +- 49 files changed, 6780 insertions(+), 308 deletions(-) delete mode 100644 _ci/protoc_install.sh rename proto/{grpc => control-api}/CHANGELOG.md (95%) rename proto/{grpc => control-api}/Cargo.toml (53%) rename proto/{grpc => control-api}/LICENSE-APACHE.md (100%) rename proto/{grpc => control-api}/LICENSE-MIT.md (100%) rename proto/{grpc => control-api}/README.md (56%) create mode 100644 proto/control-api/build.rs create mode 100644 proto/control-api/src/grpc/control_api.proto create mode 100644 proto/control-api/src/grpc/control_api.rs create mode 100644 proto/control-api/src/grpc/control_api_grpc.rs create mode 100644 proto/control-api/src/grpc/mod.rs create mode 100644 proto/control-api/src/lib.rs delete mode 100644 proto/grpc/build.rs delete mode 100644 proto/grpc/proto/control.proto delete mode 100644 proto/grpc/src/lib.rs diff --git a/.rustfmt.toml b/.rustfmt.toml index 2051bcb37..036432c26 100644 --- a/.rustfmt.toml +++ b/.rustfmt.toml @@ -1,6 +1,8 @@ # See full list at: # https://github.com/rust-lang-nursery/rustfmt/blob/master/Configurations.md +ignore = ["proto/control-api/src/grpc"] + max_width = 80 format_strings = true merge_imports = true diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8943d1208..986aaf196 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -8,9 +8,9 @@ Contribution Guide In addition to default stable [Rust] toolchain you will need [rustfmt] and [Clippy] components, and a nightly [Rust] toolchain (for better tooling). ```bash -rustup toolchain install nightly -rustup component add rustfmt -rustup component add clippy +$ rustup toolchain install nightly +$ rustup component add rustfmt +$ rustup component add clippy ``` Also, you need install [wasm-pack] for [Jason] building and testing: @@ -18,6 +18,8 @@ Also, you need install [wasm-pack] for [Jason] building and testing: $ curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sudo sh ``` +[Protoc] if you want to rebuild protobuf specs for [Medea]'s gRPC Control API. + @@ -64,6 +66,11 @@ $ make build.jason $ make build.jason dockerized=yes ``` +To rebuild protobuf specs for [Medea]'s gRPC Control API: +```bash +$ make protoc.rebuild +``` + ### Formatting @@ -129,3 +136,4 @@ Add `[run ci]` mark to your commit message for triggering CI build. [Rust]: https://www.rust-lang.org [rustfmt]: https://github.com/rust-lang/rustfmt [wasm-pack]: https://github.com/rustwasm/wasm-pack +[Protoc]: https://github.com/protocolbuffers/protobuf diff --git a/Cargo.lock b/Cargo.lock index 80e821054..d662fa167 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1093,7 +1093,7 @@ dependencies = [ "humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "humantime-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "medea-client-api-proto 0.1.1-dev", - "medea-grpc-proto 0.1.0-dev", + "medea-control-api-proto 0.1.0-dev", "medea-macro 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1128,7 +1128,7 @@ dependencies = [ ] [[package]] -name = "medea-grpc-proto" +name = "medea-control-api-proto" version = "0.1.0-dev" dependencies = [ "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index a72b40464..8063a62b1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,7 +18,7 @@ members = [ "crates/medea-macro", "jason", "proto/client-api", - "proto/grpc", + "proto/control-api", ] [profile.release] @@ -36,11 +36,11 @@ dotenv = "0.14" derive_more = "0.15" failure = "0.1" futures = "0.1" -grpcio = "0.4" +grpcio = { version = "0.4", features = ["openssl"] } humantime = "1.2" humantime-serde = "0.1" medea-client-api-proto = { path = "proto/client-api", features = ["medea"] } -medea-grpc-proto = { path = "proto/grpc" } +medea-control-api-proto = { path = "proto/control-api" } medea-macro = "0.1" protobuf = "2.7" rand = "0.7" diff --git a/Dockerfile b/Dockerfile index bb5b16eec..6a659f6a4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,11 +17,9 @@ RUN mkdir -p /out/etc/ \ COPY / /app/ -RUN bash /app/_ci/protoc_install.sh \ - && apt-get update \ - && apt-get install -y cmake golang - -ENV GOPATH /usr/lib/go +# Install dependencies needed for grpcio crate. +RUN apt-get update \ + && apt-get install -y cmake # Build project distribution. RUN cd /app \ diff --git a/Makefile b/Makefile index e14467c34..5ddf99af9 100644 --- a/Makefile +++ b/Makefile @@ -325,8 +325,8 @@ endif test-e2e-env = RUST_BACKTRACE=1 \ $(if $(call eq,$(log),yes),,RUST_LOG=warn) \ - MEDEA_CONTROL.STATIC_SPECS_DIR=tests/specs/ \ - MEDEA_CONTROL_STATIC_SPECS_DIR=tests/specs/ + MEDEA_CONTROL_API.STATIC_SPECS_DIR=tests/specs/ \ + MEDEA_CONTROL_API_STATIC_SPECS_DIR=tests/specs/ test.e2e: ifeq ($(up),yes) @@ -435,12 +435,7 @@ docker-build-medea-image-name = $(strip \ docker.build.medea: ifneq ($(no-cache),yes) - docker run --rm --network=host -v "$(PWD)":/app -w /app \ - -u $(shell id -u):$(shell id -g) \ - -e CARGO_HOME=.cache/cargo \ - medea-build \ - cargo build --bin=medea \ - $(if $(call eq,$(debug),no),--release,) + cargo build --bin=medea $(if $(call eq,$(debug),no),--release,) endif $(call docker.build.clean.ignore) @echo "!target/$(if $(call eq,$(debug),no),release,debug)/" >> .dockerignore @@ -774,6 +769,21 @@ endef +################### +# Protoc commands # +################### + +# Rebuild gRPC protobuf specs for medea-control-api-proto. +# +# Usage: +# make protoc.rebuild + +protoc.rebuild: + rm -f proto/control-api/src/grpc/control_api*.rs + cargo build -p medea-control-api-proto + + + ################## # .PHONY section # ################## @@ -781,7 +791,6 @@ endef .PHONY: build build.jason build.medea \ cargo cargo.build cargo.fmt cargo.lint \ docker.auth docker.build.demo docker.build.medea \ - docker.build.medea-build \ docker.down.coturn docker.down.demo docker.down.medea \ docker.pull docker.push \ docker.up.coturn docker.up.demo docker.up.medea \ @@ -790,6 +799,7 @@ endef helm helm.down helm.init helm.lint helm.list \ helm.package helm.package.release helm.up \ minikube.boot \ + protoc.rebuild \ release release.crates release.helm release.npm \ test test.e2e test.unit \ up up.coturn up.demo up.dev up.jason up.medea \ diff --git a/_ci/protoc_install.sh b/_ci/protoc_install.sh deleted file mode 100644 index c7b82c7ed..000000000 --- a/_ci/protoc_install.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash - -if [[ ! $DONT_INSTALL_PROTOC ]] ; then - echo "Installing protoc" - PROTOBUF_VERSION=3.3.0 - PROTOC_FILENAME=protoc-${PROTOBUF_VERSION}-linux-x86_64.zip - pushd "${HOME}" || exit - wget https://github.com/google/protobuf/releases/download/v${PROTOBUF_VERSION}/${PROTOC_FILENAME} - unzip ${PROTOC_FILENAME} - cp bin/protoc /usr/bin - protoc --version - popd || exit -fi diff --git a/_dev/config.toml b/_dev/config.toml index 95a873013..c0cb3272d 100644 --- a/_dev/config.toml +++ b/_dev/config.toml @@ -1,2 +1,2 @@ -[control] +[control_api] static_specs_dir = "_dev/specs/" diff --git a/config.toml b/config.toml index 4d486098d..aed3d29a5 100644 --- a/config.toml +++ b/config.toml @@ -1,60 +1,57 @@ -[server.http] +[server.client.http] # Server host. # -# Environment variable: MEDEA_SERVER.HTTP.HOST +# Environment variable: MEDEA_SERVER.CLIENT.HTTP.HOST # # Default: # host = "ws://0.0.0.0:8080" # IP address to bind HTTP server to. # -# Environment variable: MEDEA_SERVER.HTTP.BIND_IP +# Environment variable: MEDEA_SERVER.CLIENT.HTTP.BIND_IP # # Default: # bind_ip = "0.0.0.0" # Port to bind HTTP server to. # -# Environment variable: MEDEA_SERVER.HTTP.BIND_PORT +# Environment variable: MEDEA_SERVER.CLIENT.HTTP.BIND_PORT # # Default: # bind_port = 8080 - - - -[control] -# Path to directory with static Сontrol API specs. -# -# Environment variable: MEDEA_CONTROL.STATIC_SPECS_DIR -# -# Default: -# static_specs_dir = "specs/" - - -[server.grpc] +[server.control.grpc] # IP address to bind gRPC server to. # -# Environment variable: MEDEA_SERVER.GRPC.BIND_IP +# Environment variable: MEDEA_SERVER.CONTROL.GRPC.BIND_IP # # Default: # bind_ip = "0.0.0.0" # Port to bind gRPC server to. # -# Environment variable: MEDEA_SERVER.GRPC.BIND_PORT +# Environment variable: MEDEA_SERVER.CONTROL.GRPC.BIND_PORT # # Default: # bind_port = 50051 # Completion queue count of gRPC server. # -# Environment variable: MEDEA_SERVER.GRPC.COMPLETION_QUEUE_COUNT +# Environment variable: MEDEA_SERVER.CONTROL.GRPC.COMPLETION_QUEUE_COUNT # # Default: # completion_queue_count = 2 +[control_api] +# Path to directory with static Сontrol API specs. +# +# Environment variable: MEDEA_CONTROL_API.STATIC_SPECS_DIR +# +# Default: +# static_specs_dir = "specs/" + + [rpc] diff --git a/docker-compose.medea.yml b/docker-compose.medea.yml index 5c6ce6625..fbedf30f0 100644 --- a/docker-compose.medea.yml +++ b/docker-compose.medea.yml @@ -7,10 +7,10 @@ services: environment: RUST_LOG: ${RUST_LOG} MEDEA_CONF: ${MEDEA_CONF} - "MEDEA_CONTROL.STATIC_SPECS_DIR": ${MEDEA_CONTROL_STATIC_SPECS_DIR} + "MEDEA_CONTROL.STATIC_SPECS_DIR": ${MEDEA_CONTROL_API_STATIC_SPECS_DIR} ports: - "8080:8080" volumes: - ./${MEDEA_CONF}:/${MEDEA_CONF}:ro - - ./${MEDEA_CONTROL_STATIC_SPECS_DIR}:/${MEDEA_CONTROL_STATIC_SPECS_DIR}:ro + - ./${MEDEA_CONTROL_API_STATIC_SPECS_DIR}:/${MEDEA_CONTROL_API_STATIC_SPECS_DIR}:ro network_mode: host diff --git a/jason/demo/chart/medea-demo/conf/nginx.vh.conf b/jason/demo/chart/medea-demo/conf/nginx.vh.conf index fa37561f5..b1d9435f4 100644 --- a/jason/demo/chart/medea-demo/conf/nginx.vh.conf +++ b/jason/demo/chart/medea-demo/conf/nginx.vh.conf @@ -12,7 +12,7 @@ server { location ^~ /ws/ { proxy_pass http://127.0.0.1:8080/ws/; - proxy_http_version 1.1; + proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "Upgrade"; } diff --git a/jason/demo/chart/medea-demo/templates/deployment.server.yaml b/jason/demo/chart/medea-demo/templates/deployment.server.yaml index fa58b70b1..5996cbcab 100644 --- a/jason/demo/chart/medea-demo/templates/deployment.server.yaml +++ b/jason/demo/chart/medea-demo/templates/deployment.server.yaml @@ -64,8 +64,8 @@ spec: value: {{ $coturn.conf.listening_port | quote }} - name: MEDEA_TURN.DB.REDIS.PORT value: {{ $coturnDb.conf.port | quote }} - - name: MEDEA_CLIENT.HOST - value: {{ .Values.server.conf.client.public_url }} + - name: MEDEA_SERVER.CLIENT.HTTP.PUBLIC_URL + value: {{ .Values.server.conf.server.client.http.public_url }} envFrom: - secretRef: name: {{ template "medea-demo.fullname" . }}.server.cred diff --git a/jason/demo/chart/medea-demo/values.yaml b/jason/demo/chart/medea-demo/values.yaml index 10a9f895b..3b127b92c 100644 --- a/jason/demo/chart/medea-demo/values.yaml +++ b/jason/demo/chart/medea-demo/values.yaml @@ -15,9 +15,11 @@ server: # ports and passwords) are auto-wired and specifying them in this # configuration will have no effect. conf: - client: - bind_port: 8080 - public_url: "" + server: + client: + http: + bind_port: 8080 + public_url: "" turn: user: USER pass: PASS diff --git a/jason/demo/minikube.vals.yaml b/jason/demo/minikube.vals.yaml index a11ead5c4..8cff0fe55 100644 --- a/jason/demo/minikube.vals.yaml +++ b/jason/demo/minikube.vals.yaml @@ -8,8 +8,11 @@ server: tag: dev pullPolicy: IfNotPresent conf: - client: - public_url: "wss://medea-demo.test" + server: + client: + http: + public_url: "wss://medea-demo.test" + turn: host: medea-demo.test diff --git a/jason/demo/staging.vals.yaml b/jason/demo/staging.vals.yaml index 735341f6e..47d836bdf 100644 --- a/jason/demo/staging.vals.yaml +++ b/jason/demo/staging.vals.yaml @@ -8,9 +8,11 @@ server: tag: edge pullPolicy: Always conf: - client: - public_url: "wss://demo.medea.stg.t11913.org" - bind_port: 9980 + server: + client: + http: + public_url: "wss://demo.medea.stg.t11913.org" + bind_port: 9980 turn: host: demo.medea.stg.t11913.org pass: changeme diff --git a/proto/grpc/CHANGELOG.md b/proto/control-api/CHANGELOG.md similarity index 95% rename from proto/grpc/CHANGELOG.md rename to proto/control-api/CHANGELOG.md index d75e87f60..e3d794180 100644 --- a/proto/grpc/CHANGELOG.md +++ b/proto/control-api/CHANGELOG.md @@ -1,4 +1,4 @@ -`medea-grpc-proto` changelog +`medea-control-api` changelog ================================== All user visible changes to this project will be documented in this file. This project uses [Semantic Versioning 2.0.0]. diff --git a/proto/grpc/Cargo.toml b/proto/control-api/Cargo.toml similarity index 53% rename from proto/grpc/Cargo.toml rename to proto/control-api/Cargo.toml index 2e7cc7b2b..6ffc4d9a8 100644 --- a/proto/grpc/Cargo.toml +++ b/proto/control-api/Cargo.toml @@ -1,8 +1,8 @@ [package] -name = "medea-grpc-proto" +name = "medea-control-api-proto" version = "0.1.0-dev" edition = "2018" -description = "Compiled gRPC specs for Medea media server control API." +description = "Control API protocol implementation for Medea media server" authors = ["Instrumentisto Team "] license = "MIT/Apache-2.0" homepage = "https://github.com/instrumentisto/medea/tree/master/proto/grpc" @@ -11,10 +11,14 @@ readme = "README.md" keywords = ["medea", "grpc", "control", "api"] categories = ["api-bindings", "web-programming"] +[features] +default = ["grpc"] +grpc = ["grpcio", "futures", "protobuf", "protoc-grpcio"] + [dependencies] -grpcio = "0.4" -futures = "0.1" -protobuf = "2.7" +grpcio = { version = "0.4", optional = true } +futures = { version = "0.1", optional = true } +protobuf = { version = "2.7", optional = true } [build-dependencies] -protoc-grpcio = "1.0" +protoc-grpcio = { version = "1.0", optional = true } diff --git a/proto/grpc/LICENSE-APACHE.md b/proto/control-api/LICENSE-APACHE.md similarity index 100% rename from proto/grpc/LICENSE-APACHE.md rename to proto/control-api/LICENSE-APACHE.md diff --git a/proto/grpc/LICENSE-MIT.md b/proto/control-api/LICENSE-MIT.md similarity index 100% rename from proto/grpc/LICENSE-MIT.md rename to proto/control-api/LICENSE-MIT.md diff --git a/proto/grpc/README.md b/proto/control-api/README.md similarity index 56% rename from proto/grpc/README.md rename to proto/control-api/README.md index 64608db8a..c8e9a04d1 100644 --- a/proto/grpc/README.md +++ b/proto/control-api/README.md @@ -1,12 +1,12 @@ -Medea Control API gRPC specs +Medea Control API protocol ========================= -[![Crates.io](https://img.shields.io/crates/v/medea-grpc-proto)](https://crates.io/crates/medea-grpc-proto) -![Crates.io license](https://img.shields.io/crates/l/medea-grpc-proto) +[![Crates.io](https://img.shields.io/crates/v/medea-control-api-proto)](https://crates.io/crates/medea-grpc-proto) +![Crates.io license](https://img.shields.io/crates/l/medea-control-api-proto) -[Changelog](https://github.com/instrumentisto/medea/blob/master/proto/grpc/CHANGELOG.md) +[Changelog](https://github.com/instrumentisto/medea/blob/master/proto/control-api/CHANGELOG.md) -Compiled gRPC specs for [Medea] media server [Control API]. +Client API protocol implementation for [Medea] media server. __Currently, in early development phase.__ @@ -18,7 +18,10 @@ __Currently, in early development phase.__ - Rust >= 1.19.0 - binutils >= 2.22 - LLVM and Clang >= 3.9 -- [protoc](https://github.com/protocolbuffers/protobuf) + +### For rebuilding protobuf specs + +- [protoc](https://github.com/protocolbuffers/protobuf)>=3.7.0 @@ -27,8 +30,8 @@ __Currently, in early development phase.__ This project is licensed under either of -- Apache License, Version 2.0, ([LICENSE-APACHE](https://github.com/instrumentisto/medea/blob/master/proto/client-api/LICENSE-APACHE.md) or http://www.apache.org/licenses/LICENSE-2.0) -- MIT license ([LICENSE-MIT](https://github.com/instrumentisto/medea/blob/master/proto/client-api/LICENSE-MIT.md) or http://opensource.org/licenses/MIT) +- Apache License, Version 2.0, ([LICENSE-APACHE](https://github.com/instrumentisto/medea/blob/master/proto/control-api/LICENSE-APACHE.md) or http://www.apache.org/licenses/LICENSE-2.0) +- MIT license ([LICENSE-MIT](https://github.com/instrumentisto/medea/blob/master/proto/control-api/LICENSE-MIT.md) or http://opensource.org/licenses/MIT) at your option. diff --git a/proto/control-api/build.rs b/proto/control-api/build.rs new file mode 100644 index 000000000..2bf467587 --- /dev/null +++ b/proto/control-api/build.rs @@ -0,0 +1,33 @@ +use std::{error::Error, fs::File, io::ErrorKind}; + +#[cfg(feature = "grpc")] +fn main() -> Result<(), Box> { + const GRPC_DIR: &str = "src/grpc"; + const GRPC_SPEC_FILE: &str = "src/grpc/control_api.proto"; + const OUT_FILES: [&str; 2] = + ["src/grpc/control_api.rs", "src/grpc/control_api_grpc.rs"]; + + println!("cargo:rerun-if-changed={}", GRPC_DIR); + + for filename in &OUT_FILES { + if let Err(e) = File::open(filename) { + if let ErrorKind::NotFound = e.kind() { + protoc_grpcio::compile_grpc_protos( + &[GRPC_SPEC_FILE], + &[GRPC_DIR], + &GRPC_DIR, + None, + ) + .expect("Failed to compile gRPC definitions!"); + break; + } else { + panic!("{:?}", e); + } + } + } + + Ok(()) +} + +#[cfg(not(feature = "grpc"))] +fn main() {} diff --git a/proto/control-api/src/grpc/control_api.proto b/proto/control-api/src/grpc/control_api.proto new file mode 100644 index 000000000..22c255538 --- /dev/null +++ b/proto/control-api/src/grpc/control_api.proto @@ -0,0 +1,250 @@ +// File which describes Medea's Control API. + +syntax = "proto3"; + +package medea; + +// Service for handling Control API requests. +service ControlApi { + // Creates new Element with given ID. + // + // Not idempotent. Errors if Element with the same ID already exists. + rpc Create (CreateRequest) returns (CreateResponse); + + // Applies given spec to Element by its ID. + // + // Idempotent. If no Element with such ID exists, + // then it will be created, otherwise it will be reconfigured. + rpc Apply (ApplyRequest) returns (Response); + + // Removes Element by its ID. + // Allows referring multiple Elements on the last two levels. + // + // Idempotent. + rpc Delete (IdRequest) returns (Response); + + // Returns Element by its ID. Allows referring multiple Elements. + // If no ID specified, returns all Elements declared. + rpc Get (IdRequest) returns (GetResponse); +} + +// Creates new Element with given ID. +// +// Not idempotent. Errors if Element with the same ID already exists. +message CreateRequest { + // ID with which new Control API element will be created. + // + // Not idempotent. Errors if Element with the same ID already exists. + string id = 1; + // Spec of element to create. + oneof el { + Hub hub = 2; + FileRecorder file_recorder = 3; + Member member = 4; + Relay relay = 5; + Room room = 6; + WebRtcPlayEndpoint webrtc_play = 7; + WebRtcPublishEndpoint webrtc_pub = 8; + } +} + +// Applies given spec to Element by its ID. +// +// Idempotent. If no Element with such ID exists, +// then it will be created, otherwise it will be reconfigured. +message ApplyRequest { + // ID of Control API element which you want to update. + string id = 1; + // Control API element spec to which this element should be updated. + oneof el { + Hub hub = 2; + FileRecorder file_recorder = 3; + Member member = 4; + Relay relay = 5; + Room room = 6; + WebRtcPlayEndpoint webrtc_play = 7; + WebRtcPublishEndpoint webrtc_pub = 8; + } + // Updating policy. + Policy policy = 9; + + enum Policy { + // Elements that exist, but are not + // specified in provided pipeline + // will be removed. + APPLY = 0; + // Elements that exists, but are not + // specified in provided pipeline + // not will be removed. + APPEND = 1; + } +} + +// Request with many IDs. +message IdRequest { + // Vector of IDs. + repeated string id = 1; +} + +// Response for requests which don't +// return anything on successful +// result, but can return Error. +// +// If request fails, then an error field will be returned. +// The request should be considered successful only +// if its response does not contain error. +message Response { + // Error which can be returned if request fails. + Error error = 1; +} + +// Response for Create request. +// +// If request fails, then an error field will be returned. +// The request should be considered successful only +// if its response does not contain error. +message CreateResponse { + // Hashmap with IDs (key) and URIs (value) of elements + // with which Jason can connect to the Medea media server. + // Returns only if request was fully successful. + map sid = 1; + // Error which can be returned if request fails. + Error error = 2; +} + +// Response for Get request. +// +// If request fails, then an error field will be returned. +// The request should be considered successful only +// if its response does not contain error. +message GetResponse { + // Hashmap with IDs (key) and Control API elements specs (value). + // + // Returns only if request was fully successful. + map elements = 1; + // Error which can be returned if request fails. + Error error = 2; +} + +// Error which can be returned if request fails. +// +// If this Error not returned then request should +// be considered as successful. +message Error { + // Concrete unique code of error. + uint32 code = 2; + // Human-readable text description of error. + string text = 3; + // Optional. + // Link to online documentation of error. + string doc = 4; + // Full ID of Element that error is related to. + string element = 5; +} + +// Control API spec element. +message Element { + oneof el { + Hub hub = 2; + FileRecorder file_recorder = 3; + Member member = 4; + Relay relay = 5; + Room room = 6; + WebRtcPlayEndpoint webrtc_play = 7; + WebRtcPublishEndpoint webrtc_pub = 8; + } +} + +// Control API spec Room element. +message Room { + // Pipeline of Room element. + map pipeline = 1; + + // Elements which can contain Room's pipeline. + message Element { + oneof el { + Hub hub = 1; + FileRecorder file_recorder = 2; + Member member = 3; + Relay relay = 4; + WebRtcPlayEndpoint webrtc_play = 5; + WebRtcPublishEndpoint webrtc_pub = 6; + } + } +} + +// Member element of Control API spec. +message Member { + // Callback which fires when this Member + // connects to media server via WebSocket + // for WebRTC negotiation. + string on_join = 1; + // Callback which fires when this Member + // disconnects from media server via WebSocket. + string on_leave = 2; + // Credentials with which this Member can + // connect to media server via WebSocket. + string credentials = 3; + // Pipeline of Member element. + map pipeline = 4; + + // Elements which can contain Member's pipeline. + message Element { + oneof el { + Hub hub = 1; + FileRecorder file_recorder = 2; + Relay relay = 3; + WebRtcPlayEndpoint webrtc_play = 4; + WebRtcPublishEndpoint webrtc_pub = 5; + } + } +} + +// Media element which is able to receive +// media data from client via WebRTC. +message WebRtcPublishEndpoint { + // P2P mode of WebRtc connection. + P2P p2p = 1; + // Callback which fires when Member client + // starts publishing media data. + string on_start = 3; + // Callback which fires when Member client + // stops publishing media data. + string on_stop = 4; + + enum P2P { + // Always connect through media server. + NEVER = 0; + // Connect P2P if it possible. + IF_POSSIBLE = 1; + // Always connect P2P. + ALWAYS = 2; + } +} + +// Media element which is able to play +// media data for client via WebRTC. +message WebRtcPlayEndpoint { + // The source to get media data from. + string src = 1; + // Callback which fires when Member client + // starts playing media data of source client. + string on_start = 2; + // Callback which fires when Member client + // stops playing media data of source client. + string on_stop = 3; +} + +message Hub {} + +message FileRecorder { + string src = 1; + string dst = 2; + string on_start = 3; + string on_stop = 4; +} + +message Relay { + string src = 1; + string dst = 2; +} diff --git a/proto/control-api/src/grpc/control_api.rs b/proto/control-api/src/grpc/control_api.rs new file mode 100644 index 000000000..5673c4d58 --- /dev/null +++ b/proto/control-api/src/grpc/control_api.rs @@ -0,0 +1,6151 @@ +// This file is generated by rust-protobuf 2.8.1. Do not edit +// @generated + +// https://github.com/Manishearth/rust-clippy/issues/702 +#![allow(unknown_lints)] +#![allow(clippy::all)] + +#![cfg_attr(rustfmt, rustfmt_skip)] + +#![allow(box_pointers)] +#![allow(dead_code)] +#![allow(missing_docs)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] +#![allow(non_upper_case_globals)] +#![allow(trivial_casts)] +#![allow(unsafe_code)] +#![allow(unused_imports)] +#![allow(unused_results)] +//! Generated file from `control_api.proto` + +use protobuf::Message as Message_imported_for_functions; +use protobuf::ProtobufEnum as ProtobufEnum_imported_for_functions; + +/// Generated files are compatible only with the same version +/// of protobuf runtime. +const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_8_1; + +#[derive(PartialEq,Clone,Default)] +pub struct CreateRequest { + // message fields + pub id: ::std::string::String, + // message oneof groups + pub el: ::std::option::Option, + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a CreateRequest { + fn default() -> &'a CreateRequest { + ::default_instance() + } +} + +#[derive(Clone,PartialEq,Debug)] +pub enum CreateRequest_oneof_el { + hub(Hub), + file_recorder(FileRecorder), + member(Member), + relay(Relay), + room(Room), + webrtc_play(WebRtcPlayEndpoint), + webrtc_pub(WebRtcPublishEndpoint), +} + +impl CreateRequest { + pub fn new() -> CreateRequest { + ::std::default::Default::default() + } + + // string id = 1; + + + pub fn get_id(&self) -> &str { + &self.id + } + pub fn clear_id(&mut self) { + self.id.clear(); + } + + // Param is passed by value, moved + pub fn set_id(&mut self, v: ::std::string::String) { + self.id = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_id(&mut self) -> &mut ::std::string::String { + &mut self.id + } + + // Take field + pub fn take_id(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.id, ::std::string::String::new()) + } + + // .medea.Hub hub = 2; + + + pub fn get_hub(&self) -> &Hub { + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::hub(ref v)) => v, + _ => Hub::default_instance(), + } + } + pub fn clear_hub(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_hub(&self) -> bool { + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::hub(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_hub(&mut self, v: Hub) { + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::hub(v)) + } + + // Mutable pointer to the field. + pub fn mut_hub(&mut self) -> &mut Hub { + if let ::std::option::Option::Some(CreateRequest_oneof_el::hub(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::hub(Hub::new())); + } + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::hub(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_hub(&mut self) -> Hub { + if self.has_hub() { + match self.el.take() { + ::std::option::Option::Some(CreateRequest_oneof_el::hub(v)) => v, + _ => panic!(), + } + } else { + Hub::new() + } + } + + // .medea.FileRecorder file_recorder = 3; + + + pub fn get_file_recorder(&self) -> &FileRecorder { + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::file_recorder(ref v)) => v, + _ => FileRecorder::default_instance(), + } + } + pub fn clear_file_recorder(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_file_recorder(&self) -> bool { + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::file_recorder(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_file_recorder(&mut self, v: FileRecorder) { + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::file_recorder(v)) + } + + // Mutable pointer to the field. + pub fn mut_file_recorder(&mut self) -> &mut FileRecorder { + if let ::std::option::Option::Some(CreateRequest_oneof_el::file_recorder(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::file_recorder(FileRecorder::new())); + } + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::file_recorder(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_file_recorder(&mut self) -> FileRecorder { + if self.has_file_recorder() { + match self.el.take() { + ::std::option::Option::Some(CreateRequest_oneof_el::file_recorder(v)) => v, + _ => panic!(), + } + } else { + FileRecorder::new() + } + } + + // .medea.Member member = 4; + + + pub fn get_member(&self) -> &Member { + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::member(ref v)) => v, + _ => Member::default_instance(), + } + } + pub fn clear_member(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_member(&self) -> bool { + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::member(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_member(&mut self, v: Member) { + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::member(v)) + } + + // Mutable pointer to the field. + pub fn mut_member(&mut self) -> &mut Member { + if let ::std::option::Option::Some(CreateRequest_oneof_el::member(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::member(Member::new())); + } + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::member(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_member(&mut self) -> Member { + if self.has_member() { + match self.el.take() { + ::std::option::Option::Some(CreateRequest_oneof_el::member(v)) => v, + _ => panic!(), + } + } else { + Member::new() + } + } + + // .medea.Relay relay = 5; + + + pub fn get_relay(&self) -> &Relay { + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::relay(ref v)) => v, + _ => Relay::default_instance(), + } + } + pub fn clear_relay(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_relay(&self) -> bool { + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::relay(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_relay(&mut self, v: Relay) { + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::relay(v)) + } + + // Mutable pointer to the field. + pub fn mut_relay(&mut self) -> &mut Relay { + if let ::std::option::Option::Some(CreateRequest_oneof_el::relay(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::relay(Relay::new())); + } + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::relay(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_relay(&mut self) -> Relay { + if self.has_relay() { + match self.el.take() { + ::std::option::Option::Some(CreateRequest_oneof_el::relay(v)) => v, + _ => panic!(), + } + } else { + Relay::new() + } + } + + // .medea.Room room = 6; + + + pub fn get_room(&self) -> &Room { + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::room(ref v)) => v, + _ => Room::default_instance(), + } + } + pub fn clear_room(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_room(&self) -> bool { + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::room(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_room(&mut self, v: Room) { + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::room(v)) + } + + // Mutable pointer to the field. + pub fn mut_room(&mut self) -> &mut Room { + if let ::std::option::Option::Some(CreateRequest_oneof_el::room(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::room(Room::new())); + } + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::room(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_room(&mut self) -> Room { + if self.has_room() { + match self.el.take() { + ::std::option::Option::Some(CreateRequest_oneof_el::room(v)) => v, + _ => panic!(), + } + } else { + Room::new() + } + } + + // .medea.WebRtcPlayEndpoint webrtc_play = 7; + + + pub fn get_webrtc_play(&self) -> &WebRtcPlayEndpoint { + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_play(ref v)) => v, + _ => WebRtcPlayEndpoint::default_instance(), + } + } + pub fn clear_webrtc_play(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_webrtc_play(&self) -> bool { + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_play(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_webrtc_play(&mut self, v: WebRtcPlayEndpoint) { + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_play(v)) + } + + // Mutable pointer to the field. + pub fn mut_webrtc_play(&mut self) -> &mut WebRtcPlayEndpoint { + if let ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_play(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_play(WebRtcPlayEndpoint::new())); + } + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_play(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_webrtc_play(&mut self) -> WebRtcPlayEndpoint { + if self.has_webrtc_play() { + match self.el.take() { + ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_play(v)) => v, + _ => panic!(), + } + } else { + WebRtcPlayEndpoint::new() + } + } + + // .medea.WebRtcPublishEndpoint webrtc_pub = 8; + + + pub fn get_webrtc_pub(&self) -> &WebRtcPublishEndpoint { + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_pub(ref v)) => v, + _ => WebRtcPublishEndpoint::default_instance(), + } + } + pub fn clear_webrtc_pub(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_webrtc_pub(&self) -> bool { + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_pub(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_webrtc_pub(&mut self, v: WebRtcPublishEndpoint) { + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_pub(v)) + } + + // Mutable pointer to the field. + pub fn mut_webrtc_pub(&mut self) -> &mut WebRtcPublishEndpoint { + if let ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_pub(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_pub(WebRtcPublishEndpoint::new())); + } + match self.el { + ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_pub(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_webrtc_pub(&mut self) -> WebRtcPublishEndpoint { + if self.has_webrtc_pub() { + match self.el.take() { + ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_pub(v)) => v, + _ => panic!(), + } + } else { + WebRtcPublishEndpoint::new() + } + } +} + +impl ::protobuf::Message for CreateRequest { + fn is_initialized(&self) -> bool { + if let Some(CreateRequest_oneof_el::hub(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(CreateRequest_oneof_el::file_recorder(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(CreateRequest_oneof_el::member(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(CreateRequest_oneof_el::relay(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(CreateRequest_oneof_el::room(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(CreateRequest_oneof_el::webrtc_play(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(CreateRequest_oneof_el::webrtc_pub(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.id)?; + }, + 2 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::hub(is.read_message()?)); + }, + 3 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::file_recorder(is.read_message()?)); + }, + 4 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::member(is.read_message()?)); + }, + 5 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::relay(is.read_message()?)); + }, + 6 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::room(is.read_message()?)); + }, + 7 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_play(is.read_message()?)); + }, + 8 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_pub(is.read_message()?)); + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if !self.id.is_empty() { + my_size += ::protobuf::rt::string_size(1, &self.id); + } + if let ::std::option::Option::Some(ref v) = self.el { + match v { + &CreateRequest_oneof_el::hub(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &CreateRequest_oneof_el::file_recorder(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &CreateRequest_oneof_el::member(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &CreateRequest_oneof_el::relay(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &CreateRequest_oneof_el::room(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &CreateRequest_oneof_el::webrtc_play(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &CreateRequest_oneof_el::webrtc_pub(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + }; + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { + if !self.id.is_empty() { + os.write_string(1, &self.id)?; + } + if let ::std::option::Option::Some(ref v) = self.el { + match v { + &CreateRequest_oneof_el::hub(ref v) => { + os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &CreateRequest_oneof_el::file_recorder(ref v) => { + os.write_tag(3, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &CreateRequest_oneof_el::member(ref v) => { + os.write_tag(4, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &CreateRequest_oneof_el::relay(ref v) => { + os.write_tag(5, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &CreateRequest_oneof_el::room(ref v) => { + os.write_tag(6, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &CreateRequest_oneof_el::webrtc_play(ref v) => { + os.write_tag(7, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &CreateRequest_oneof_el::webrtc_pub(ref v) => { + os.write_tag(8, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + }; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &dyn (::std::any::Any) { + self as &dyn (::std::any::Any) + } + fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) { + self as &mut dyn (::std::any::Any) + } + fn into_any(self: Box) -> ::std::boxed::Box { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> CreateRequest { + CreateRequest::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "id", + |m: &CreateRequest| { &m.id }, + |m: &mut CreateRequest| { &mut m.id }, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Hub>( + "hub", + CreateRequest::has_hub, + CreateRequest::get_hub, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, FileRecorder>( + "file_recorder", + CreateRequest::has_file_recorder, + CreateRequest::get_file_recorder, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Member>( + "member", + CreateRequest::has_member, + CreateRequest::get_member, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Relay>( + "relay", + CreateRequest::has_relay, + CreateRequest::get_relay, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Room>( + "room", + CreateRequest::has_room, + CreateRequest::get_room, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPlayEndpoint>( + "webrtc_play", + CreateRequest::has_webrtc_play, + CreateRequest::get_webrtc_play, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPublishEndpoint>( + "webrtc_pub", + CreateRequest::has_webrtc_pub, + CreateRequest::get_webrtc_pub, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "CreateRequest", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static CreateRequest { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const CreateRequest, + }; + unsafe { + instance.get(CreateRequest::new) + } + } +} + +impl ::protobuf::Clear for CreateRequest { + fn clear(&mut self) { + self.id.clear(); + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for CreateRequest { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for CreateRequest { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct ApplyRequest { + // message fields + pub id: ::std::string::String, + pub policy: ApplyRequest_Policy, + // message oneof groups + pub el: ::std::option::Option, + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a ApplyRequest { + fn default() -> &'a ApplyRequest { + ::default_instance() + } +} + +#[derive(Clone,PartialEq,Debug)] +pub enum ApplyRequest_oneof_el { + hub(Hub), + file_recorder(FileRecorder), + member(Member), + relay(Relay), + room(Room), + webrtc_play(WebRtcPlayEndpoint), + webrtc_pub(WebRtcPublishEndpoint), +} + +impl ApplyRequest { + pub fn new() -> ApplyRequest { + ::std::default::Default::default() + } + + // string id = 1; + + + pub fn get_id(&self) -> &str { + &self.id + } + pub fn clear_id(&mut self) { + self.id.clear(); + } + + // Param is passed by value, moved + pub fn set_id(&mut self, v: ::std::string::String) { + self.id = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_id(&mut self) -> &mut ::std::string::String { + &mut self.id + } + + // Take field + pub fn take_id(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.id, ::std::string::String::new()) + } + + // .medea.Hub hub = 2; + + + pub fn get_hub(&self) -> &Hub { + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::hub(ref v)) => v, + _ => Hub::default_instance(), + } + } + pub fn clear_hub(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_hub(&self) -> bool { + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::hub(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_hub(&mut self, v: Hub) { + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::hub(v)) + } + + // Mutable pointer to the field. + pub fn mut_hub(&mut self) -> &mut Hub { + if let ::std::option::Option::Some(ApplyRequest_oneof_el::hub(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::hub(Hub::new())); + } + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::hub(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_hub(&mut self) -> Hub { + if self.has_hub() { + match self.el.take() { + ::std::option::Option::Some(ApplyRequest_oneof_el::hub(v)) => v, + _ => panic!(), + } + } else { + Hub::new() + } + } + + // .medea.FileRecorder file_recorder = 3; + + + pub fn get_file_recorder(&self) -> &FileRecorder { + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::file_recorder(ref v)) => v, + _ => FileRecorder::default_instance(), + } + } + pub fn clear_file_recorder(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_file_recorder(&self) -> bool { + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::file_recorder(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_file_recorder(&mut self, v: FileRecorder) { + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::file_recorder(v)) + } + + // Mutable pointer to the field. + pub fn mut_file_recorder(&mut self) -> &mut FileRecorder { + if let ::std::option::Option::Some(ApplyRequest_oneof_el::file_recorder(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::file_recorder(FileRecorder::new())); + } + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::file_recorder(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_file_recorder(&mut self) -> FileRecorder { + if self.has_file_recorder() { + match self.el.take() { + ::std::option::Option::Some(ApplyRequest_oneof_el::file_recorder(v)) => v, + _ => panic!(), + } + } else { + FileRecorder::new() + } + } + + // .medea.Member member = 4; + + + pub fn get_member(&self) -> &Member { + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::member(ref v)) => v, + _ => Member::default_instance(), + } + } + pub fn clear_member(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_member(&self) -> bool { + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::member(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_member(&mut self, v: Member) { + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::member(v)) + } + + // Mutable pointer to the field. + pub fn mut_member(&mut self) -> &mut Member { + if let ::std::option::Option::Some(ApplyRequest_oneof_el::member(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::member(Member::new())); + } + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::member(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_member(&mut self) -> Member { + if self.has_member() { + match self.el.take() { + ::std::option::Option::Some(ApplyRequest_oneof_el::member(v)) => v, + _ => panic!(), + } + } else { + Member::new() + } + } + + // .medea.Relay relay = 5; + + + pub fn get_relay(&self) -> &Relay { + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::relay(ref v)) => v, + _ => Relay::default_instance(), + } + } + pub fn clear_relay(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_relay(&self) -> bool { + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::relay(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_relay(&mut self, v: Relay) { + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::relay(v)) + } + + // Mutable pointer to the field. + pub fn mut_relay(&mut self) -> &mut Relay { + if let ::std::option::Option::Some(ApplyRequest_oneof_el::relay(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::relay(Relay::new())); + } + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::relay(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_relay(&mut self) -> Relay { + if self.has_relay() { + match self.el.take() { + ::std::option::Option::Some(ApplyRequest_oneof_el::relay(v)) => v, + _ => panic!(), + } + } else { + Relay::new() + } + } + + // .medea.Room room = 6; + + + pub fn get_room(&self) -> &Room { + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::room(ref v)) => v, + _ => Room::default_instance(), + } + } + pub fn clear_room(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_room(&self) -> bool { + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::room(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_room(&mut self, v: Room) { + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::room(v)) + } + + // Mutable pointer to the field. + pub fn mut_room(&mut self) -> &mut Room { + if let ::std::option::Option::Some(ApplyRequest_oneof_el::room(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::room(Room::new())); + } + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::room(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_room(&mut self) -> Room { + if self.has_room() { + match self.el.take() { + ::std::option::Option::Some(ApplyRequest_oneof_el::room(v)) => v, + _ => panic!(), + } + } else { + Room::new() + } + } + + // .medea.WebRtcPlayEndpoint webrtc_play = 7; + + + pub fn get_webrtc_play(&self) -> &WebRtcPlayEndpoint { + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(ref v)) => v, + _ => WebRtcPlayEndpoint::default_instance(), + } + } + pub fn clear_webrtc_play(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_webrtc_play(&self) -> bool { + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_webrtc_play(&mut self, v: WebRtcPlayEndpoint) { + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(v)) + } + + // Mutable pointer to the field. + pub fn mut_webrtc_play(&mut self) -> &mut WebRtcPlayEndpoint { + if let ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(WebRtcPlayEndpoint::new())); + } + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_webrtc_play(&mut self) -> WebRtcPlayEndpoint { + if self.has_webrtc_play() { + match self.el.take() { + ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(v)) => v, + _ => panic!(), + } + } else { + WebRtcPlayEndpoint::new() + } + } + + // .medea.WebRtcPublishEndpoint webrtc_pub = 8; + + + pub fn get_webrtc_pub(&self) -> &WebRtcPublishEndpoint { + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(ref v)) => v, + _ => WebRtcPublishEndpoint::default_instance(), + } + } + pub fn clear_webrtc_pub(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_webrtc_pub(&self) -> bool { + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_webrtc_pub(&mut self, v: WebRtcPublishEndpoint) { + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(v)) + } + + // Mutable pointer to the field. + pub fn mut_webrtc_pub(&mut self) -> &mut WebRtcPublishEndpoint { + if let ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(WebRtcPublishEndpoint::new())); + } + match self.el { + ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_webrtc_pub(&mut self) -> WebRtcPublishEndpoint { + if self.has_webrtc_pub() { + match self.el.take() { + ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(v)) => v, + _ => panic!(), + } + } else { + WebRtcPublishEndpoint::new() + } + } + + // .medea.ApplyRequest.Policy policy = 9; + + + pub fn get_policy(&self) -> ApplyRequest_Policy { + self.policy + } + pub fn clear_policy(&mut self) { + self.policy = ApplyRequest_Policy::APPLY; + } + + // Param is passed by value, moved + pub fn set_policy(&mut self, v: ApplyRequest_Policy) { + self.policy = v; + } +} + +impl ::protobuf::Message for ApplyRequest { + fn is_initialized(&self) -> bool { + if let Some(ApplyRequest_oneof_el::hub(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(ApplyRequest_oneof_el::file_recorder(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(ApplyRequest_oneof_el::member(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(ApplyRequest_oneof_el::relay(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(ApplyRequest_oneof_el::room(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(ApplyRequest_oneof_el::webrtc_play(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(ApplyRequest_oneof_el::webrtc_pub(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.id)?; + }, + 2 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::hub(is.read_message()?)); + }, + 3 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::file_recorder(is.read_message()?)); + }, + 4 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::member(is.read_message()?)); + }, + 5 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::relay(is.read_message()?)); + }, + 6 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::room(is.read_message()?)); + }, + 7 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(is.read_message()?)); + }, + 8 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(is.read_message()?)); + }, + 9 => { + ::protobuf::rt::read_proto3_enum_with_unknown_fields_into(wire_type, is, &mut self.policy, 9, &mut self.unknown_fields)? + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if !self.id.is_empty() { + my_size += ::protobuf::rt::string_size(1, &self.id); + } + if self.policy != ApplyRequest_Policy::APPLY { + my_size += ::protobuf::rt::enum_size(9, self.policy); + } + if let ::std::option::Option::Some(ref v) = self.el { + match v { + &ApplyRequest_oneof_el::hub(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &ApplyRequest_oneof_el::file_recorder(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &ApplyRequest_oneof_el::member(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &ApplyRequest_oneof_el::relay(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &ApplyRequest_oneof_el::room(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &ApplyRequest_oneof_el::webrtc_play(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &ApplyRequest_oneof_el::webrtc_pub(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + }; + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { + if !self.id.is_empty() { + os.write_string(1, &self.id)?; + } + if self.policy != ApplyRequest_Policy::APPLY { + os.write_enum(9, self.policy.value())?; + } + if let ::std::option::Option::Some(ref v) = self.el { + match v { + &ApplyRequest_oneof_el::hub(ref v) => { + os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &ApplyRequest_oneof_el::file_recorder(ref v) => { + os.write_tag(3, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &ApplyRequest_oneof_el::member(ref v) => { + os.write_tag(4, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &ApplyRequest_oneof_el::relay(ref v) => { + os.write_tag(5, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &ApplyRequest_oneof_el::room(ref v) => { + os.write_tag(6, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &ApplyRequest_oneof_el::webrtc_play(ref v) => { + os.write_tag(7, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &ApplyRequest_oneof_el::webrtc_pub(ref v) => { + os.write_tag(8, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + }; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &dyn (::std::any::Any) { + self as &dyn (::std::any::Any) + } + fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) { + self as &mut dyn (::std::any::Any) + } + fn into_any(self: Box) -> ::std::boxed::Box { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> ApplyRequest { + ApplyRequest::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "id", + |m: &ApplyRequest| { &m.id }, + |m: &mut ApplyRequest| { &mut m.id }, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Hub>( + "hub", + ApplyRequest::has_hub, + ApplyRequest::get_hub, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, FileRecorder>( + "file_recorder", + ApplyRequest::has_file_recorder, + ApplyRequest::get_file_recorder, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Member>( + "member", + ApplyRequest::has_member, + ApplyRequest::get_member, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Relay>( + "relay", + ApplyRequest::has_relay, + ApplyRequest::get_relay, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Room>( + "room", + ApplyRequest::has_room, + ApplyRequest::get_room, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPlayEndpoint>( + "webrtc_play", + ApplyRequest::has_webrtc_play, + ApplyRequest::get_webrtc_play, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPublishEndpoint>( + "webrtc_pub", + ApplyRequest::has_webrtc_pub, + ApplyRequest::get_webrtc_pub, + )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeEnum>( + "policy", + |m: &ApplyRequest| { &m.policy }, + |m: &mut ApplyRequest| { &mut m.policy }, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "ApplyRequest", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static ApplyRequest { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ApplyRequest, + }; + unsafe { + instance.get(ApplyRequest::new) + } + } +} + +impl ::protobuf::Clear for ApplyRequest { + fn clear(&mut self) { + self.id.clear(); + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.policy = ApplyRequest_Policy::APPLY; + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for ApplyRequest { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for ApplyRequest { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(Clone,PartialEq,Eq,Debug,Hash)] +pub enum ApplyRequest_Policy { + APPLY = 0, + APPEND = 1, +} + +impl ::protobuf::ProtobufEnum for ApplyRequest_Policy { + fn value(&self) -> i32 { + *self as i32 + } + + fn from_i32(value: i32) -> ::std::option::Option { + match value { + 0 => ::std::option::Option::Some(ApplyRequest_Policy::APPLY), + 1 => ::std::option::Option::Some(ApplyRequest_Policy::APPEND), + _ => ::std::option::Option::None + } + } + + fn values() -> &'static [Self] { + static values: &'static [ApplyRequest_Policy] = &[ + ApplyRequest_Policy::APPLY, + ApplyRequest_Policy::APPEND, + ]; + values + } + + fn enum_descriptor_static() -> &'static ::protobuf::reflect::EnumDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::EnumDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::EnumDescriptor, + }; + unsafe { + descriptor.get(|| { + ::protobuf::reflect::EnumDescriptor::new("ApplyRequest_Policy", file_descriptor_proto()) + }) + } + } +} + +impl ::std::marker::Copy for ApplyRequest_Policy { +} + +impl ::std::default::Default for ApplyRequest_Policy { + fn default() -> Self { + ApplyRequest_Policy::APPLY + } +} + +impl ::protobuf::reflect::ProtobufValue for ApplyRequest_Policy { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Enum(self.descriptor()) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct IdRequest { + // message fields + pub id: ::protobuf::RepeatedField<::std::string::String>, + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a IdRequest { + fn default() -> &'a IdRequest { + ::default_instance() + } +} + +impl IdRequest { + pub fn new() -> IdRequest { + ::std::default::Default::default() + } + + // repeated string id = 1; + + + pub fn get_id(&self) -> &[::std::string::String] { + &self.id + } + pub fn clear_id(&mut self) { + self.id.clear(); + } + + // Param is passed by value, moved + pub fn set_id(&mut self, v: ::protobuf::RepeatedField<::std::string::String>) { + self.id = v; + } + + // Mutable pointer to the field. + pub fn mut_id(&mut self) -> &mut ::protobuf::RepeatedField<::std::string::String> { + &mut self.id + } + + // Take field + pub fn take_id(&mut self) -> ::protobuf::RepeatedField<::std::string::String> { + ::std::mem::replace(&mut self.id, ::protobuf::RepeatedField::new()) + } +} + +impl ::protobuf::Message for IdRequest { + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_repeated_string_into(wire_type, is, &mut self.id)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + for value in &self.id { + my_size += ::protobuf::rt::string_size(1, &value); + }; + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { + for v in &self.id { + os.write_string(1, &v)?; + }; + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &dyn (::std::any::Any) { + self as &dyn (::std::any::Any) + } + fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) { + self as &mut dyn (::std::any::Any) + } + fn into_any(self: Box) -> ::std::boxed::Box { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> IdRequest { + IdRequest::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "id", + |m: &IdRequest| { &m.id }, + |m: &mut IdRequest| { &mut m.id }, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "IdRequest", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static IdRequest { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const IdRequest, + }; + unsafe { + instance.get(IdRequest::new) + } + } +} + +impl ::protobuf::Clear for IdRequest { + fn clear(&mut self) { + self.id.clear(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for IdRequest { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for IdRequest { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct Response { + // message fields + pub error: ::protobuf::SingularPtrField, + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a Response { + fn default() -> &'a Response { + ::default_instance() + } +} + +impl Response { + pub fn new() -> Response { + ::std::default::Default::default() + } + + // .medea.Error error = 1; + + + pub fn get_error(&self) -> &Error { + self.error.as_ref().unwrap_or_else(|| Error::default_instance()) + } + pub fn clear_error(&mut self) { + self.error.clear(); + } + + pub fn has_error(&self) -> bool { + self.error.is_some() + } + + // Param is passed by value, moved + pub fn set_error(&mut self, v: Error) { + self.error = ::protobuf::SingularPtrField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_error(&mut self) -> &mut Error { + if self.error.is_none() { + self.error.set_default(); + } + self.error.as_mut().unwrap() + } + + // Take field + pub fn take_error(&mut self) -> Error { + self.error.take().unwrap_or_else(|| Error::new()) + } +} + +impl ::protobuf::Message for Response { + fn is_initialized(&self) -> bool { + for v in &self.error { + if !v.is_initialized() { + return false; + } + }; + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_singular_message_into(wire_type, is, &mut self.error)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if let Some(ref v) = self.error.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { + if let Some(ref v) = self.error.as_ref() { + os.write_tag(1, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &dyn (::std::any::Any) { + self as &dyn (::std::any::Any) + } + fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) { + self as &mut dyn (::std::any::Any) + } + fn into_any(self: Box) -> ::std::boxed::Box { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> Response { + Response::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_singular_ptr_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( + "error", + |m: &Response| { &m.error }, + |m: &mut Response| { &mut m.error }, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "Response", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static Response { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const Response, + }; + unsafe { + instance.get(Response::new) + } + } +} + +impl ::protobuf::Clear for Response { + fn clear(&mut self) { + self.error.clear(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for Response { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for Response { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct CreateResponse { + // message fields + pub sid: ::std::collections::HashMap<::std::string::String, ::std::string::String>, + pub error: ::protobuf::SingularPtrField, + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a CreateResponse { + fn default() -> &'a CreateResponse { + ::default_instance() + } +} + +impl CreateResponse { + pub fn new() -> CreateResponse { + ::std::default::Default::default() + } + + // repeated .medea.CreateResponse.SidEntry sid = 1; + + + pub fn get_sid(&self) -> &::std::collections::HashMap<::std::string::String, ::std::string::String> { + &self.sid + } + pub fn clear_sid(&mut self) { + self.sid.clear(); + } + + // Param is passed by value, moved + pub fn set_sid(&mut self, v: ::std::collections::HashMap<::std::string::String, ::std::string::String>) { + self.sid = v; + } + + // Mutable pointer to the field. + pub fn mut_sid(&mut self) -> &mut ::std::collections::HashMap<::std::string::String, ::std::string::String> { + &mut self.sid + } + + // Take field + pub fn take_sid(&mut self) -> ::std::collections::HashMap<::std::string::String, ::std::string::String> { + ::std::mem::replace(&mut self.sid, ::std::collections::HashMap::new()) + } + + // .medea.Error error = 2; + + + pub fn get_error(&self) -> &Error { + self.error.as_ref().unwrap_or_else(|| Error::default_instance()) + } + pub fn clear_error(&mut self) { + self.error.clear(); + } + + pub fn has_error(&self) -> bool { + self.error.is_some() + } + + // Param is passed by value, moved + pub fn set_error(&mut self, v: Error) { + self.error = ::protobuf::SingularPtrField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_error(&mut self) -> &mut Error { + if self.error.is_none() { + self.error.set_default(); + } + self.error.as_mut().unwrap() + } + + // Take field + pub fn take_error(&mut self) -> Error { + self.error.take().unwrap_or_else(|| Error::new()) + } +} + +impl ::protobuf::Message for CreateResponse { + fn is_initialized(&self) -> bool { + for v in &self.error { + if !v.is_initialized() { + return false; + } + }; + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_map_into::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeString>(wire_type, is, &mut self.sid)?; + }, + 2 => { + ::protobuf::rt::read_singular_message_into(wire_type, is, &mut self.error)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + my_size += ::protobuf::rt::compute_map_size::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeString>(1, &self.sid); + if let Some(ref v) = self.error.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { + ::protobuf::rt::write_map_with_cached_sizes::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeString>(1, &self.sid, os)?; + if let Some(ref v) = self.error.as_ref() { + os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &dyn (::std::any::Any) { + self as &dyn (::std::any::Any) + } + fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) { + self as &mut dyn (::std::any::Any) + } + fn into_any(self: Box) -> ::std::boxed::Box { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> CreateResponse { + CreateResponse::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_map_accessor::<_, ::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeString>( + "sid", + |m: &CreateResponse| { &m.sid }, + |m: &mut CreateResponse| { &mut m.sid }, + )); + fields.push(::protobuf::reflect::accessor::make_singular_ptr_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( + "error", + |m: &CreateResponse| { &m.error }, + |m: &mut CreateResponse| { &mut m.error }, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "CreateResponse", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static CreateResponse { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const CreateResponse, + }; + unsafe { + instance.get(CreateResponse::new) + } + } +} + +impl ::protobuf::Clear for CreateResponse { + fn clear(&mut self) { + self.sid.clear(); + self.error.clear(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for CreateResponse { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for CreateResponse { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct GetResponse { + // message fields + pub elements: ::std::collections::HashMap<::std::string::String, Element>, + pub error: ::protobuf::SingularPtrField, + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a GetResponse { + fn default() -> &'a GetResponse { + ::default_instance() + } +} + +impl GetResponse { + pub fn new() -> GetResponse { + ::std::default::Default::default() + } + + // repeated .medea.GetResponse.ElementsEntry elements = 1; + + + pub fn get_elements(&self) -> &::std::collections::HashMap<::std::string::String, Element> { + &self.elements + } + pub fn clear_elements(&mut self) { + self.elements.clear(); + } + + // Param is passed by value, moved + pub fn set_elements(&mut self, v: ::std::collections::HashMap<::std::string::String, Element>) { + self.elements = v; + } + + // Mutable pointer to the field. + pub fn mut_elements(&mut self) -> &mut ::std::collections::HashMap<::std::string::String, Element> { + &mut self.elements + } + + // Take field + pub fn take_elements(&mut self) -> ::std::collections::HashMap<::std::string::String, Element> { + ::std::mem::replace(&mut self.elements, ::std::collections::HashMap::new()) + } + + // .medea.Error error = 2; + + + pub fn get_error(&self) -> &Error { + self.error.as_ref().unwrap_or_else(|| Error::default_instance()) + } + pub fn clear_error(&mut self) { + self.error.clear(); + } + + pub fn has_error(&self) -> bool { + self.error.is_some() + } + + // Param is passed by value, moved + pub fn set_error(&mut self, v: Error) { + self.error = ::protobuf::SingularPtrField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_error(&mut self) -> &mut Error { + if self.error.is_none() { + self.error.set_default(); + } + self.error.as_mut().unwrap() + } + + // Take field + pub fn take_error(&mut self) -> Error { + self.error.take().unwrap_or_else(|| Error::new()) + } +} + +impl ::protobuf::Message for GetResponse { + fn is_initialized(&self) -> bool { + for v in &self.error { + if !v.is_initialized() { + return false; + } + }; + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_map_into::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(wire_type, is, &mut self.elements)?; + }, + 2 => { + ::protobuf::rt::read_singular_message_into(wire_type, is, &mut self.error)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + my_size += ::protobuf::rt::compute_map_size::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(1, &self.elements); + if let Some(ref v) = self.error.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { + ::protobuf::rt::write_map_with_cached_sizes::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(1, &self.elements, os)?; + if let Some(ref v) = self.error.as_ref() { + os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &dyn (::std::any::Any) { + self as &dyn (::std::any::Any) + } + fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) { + self as &mut dyn (::std::any::Any) + } + fn into_any(self: Box) -> ::std::boxed::Box { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> GetResponse { + GetResponse::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_map_accessor::<_, ::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>( + "elements", + |m: &GetResponse| { &m.elements }, + |m: &mut GetResponse| { &mut m.elements }, + )); + fields.push(::protobuf::reflect::accessor::make_singular_ptr_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( + "error", + |m: &GetResponse| { &m.error }, + |m: &mut GetResponse| { &mut m.error }, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "GetResponse", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static GetResponse { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const GetResponse, + }; + unsafe { + instance.get(GetResponse::new) + } + } +} + +impl ::protobuf::Clear for GetResponse { + fn clear(&mut self) { + self.elements.clear(); + self.error.clear(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for GetResponse { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for GetResponse { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct Error { + // message fields + pub code: u32, + pub text: ::std::string::String, + pub doc: ::std::string::String, + pub element: ::std::string::String, + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a Error { + fn default() -> &'a Error { + ::default_instance() + } +} + +impl Error { + pub fn new() -> Error { + ::std::default::Default::default() + } + + // uint32 code = 2; + + + pub fn get_code(&self) -> u32 { + self.code + } + pub fn clear_code(&mut self) { + self.code = 0; + } + + // Param is passed by value, moved + pub fn set_code(&mut self, v: u32) { + self.code = v; + } + + // string text = 3; + + + pub fn get_text(&self) -> &str { + &self.text + } + pub fn clear_text(&mut self) { + self.text.clear(); + } + + // Param is passed by value, moved + pub fn set_text(&mut self, v: ::std::string::String) { + self.text = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_text(&mut self) -> &mut ::std::string::String { + &mut self.text + } + + // Take field + pub fn take_text(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.text, ::std::string::String::new()) + } + + // string doc = 4; + + + pub fn get_doc(&self) -> &str { + &self.doc + } + pub fn clear_doc(&mut self) { + self.doc.clear(); + } + + // Param is passed by value, moved + pub fn set_doc(&mut self, v: ::std::string::String) { + self.doc = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_doc(&mut self) -> &mut ::std::string::String { + &mut self.doc + } + + // Take field + pub fn take_doc(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.doc, ::std::string::String::new()) + } + + // string element = 5; + + + pub fn get_element(&self) -> &str { + &self.element + } + pub fn clear_element(&mut self) { + self.element.clear(); + } + + // Param is passed by value, moved + pub fn set_element(&mut self, v: ::std::string::String) { + self.element = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_element(&mut self) -> &mut ::std::string::String { + &mut self.element + } + + // Take field + pub fn take_element(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.element, ::std::string::String::new()) + } +} + +impl ::protobuf::Message for Error { + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 2 => { + if wire_type != ::protobuf::wire_format::WireTypeVarint { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + let tmp = is.read_uint32()?; + self.code = tmp; + }, + 3 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.text)?; + }, + 4 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.doc)?; + }, + 5 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.element)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if self.code != 0 { + my_size += ::protobuf::rt::value_size(2, self.code, ::protobuf::wire_format::WireTypeVarint); + } + if !self.text.is_empty() { + my_size += ::protobuf::rt::string_size(3, &self.text); + } + if !self.doc.is_empty() { + my_size += ::protobuf::rt::string_size(4, &self.doc); + } + if !self.element.is_empty() { + my_size += ::protobuf::rt::string_size(5, &self.element); + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { + if self.code != 0 { + os.write_uint32(2, self.code)?; + } + if !self.text.is_empty() { + os.write_string(3, &self.text)?; + } + if !self.doc.is_empty() { + os.write_string(4, &self.doc)?; + } + if !self.element.is_empty() { + os.write_string(5, &self.element)?; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &dyn (::std::any::Any) { + self as &dyn (::std::any::Any) + } + fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) { + self as &mut dyn (::std::any::Any) + } + fn into_any(self: Box) -> ::std::boxed::Box { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> Error { + Error::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeUint32>( + "code", + |m: &Error| { &m.code }, + |m: &mut Error| { &mut m.code }, + )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "text", + |m: &Error| { &m.text }, + |m: &mut Error| { &mut m.text }, + )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "doc", + |m: &Error| { &m.doc }, + |m: &mut Error| { &mut m.doc }, + )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "element", + |m: &Error| { &m.element }, + |m: &mut Error| { &mut m.element }, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "Error", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static Error { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const Error, + }; + unsafe { + instance.get(Error::new) + } + } +} + +impl ::protobuf::Clear for Error { + fn clear(&mut self) { + self.code = 0; + self.text.clear(); + self.doc.clear(); + self.element.clear(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for Error { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for Error { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct Element { + // message oneof groups + pub el: ::std::option::Option, + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a Element { + fn default() -> &'a Element { + ::default_instance() + } +} + +#[derive(Clone,PartialEq,Debug)] +pub enum Element_oneof_el { + hub(Hub), + file_recorder(FileRecorder), + member(Member), + relay(Relay), + room(Room), + webrtc_play(WebRtcPlayEndpoint), + webrtc_pub(WebRtcPublishEndpoint), +} + +impl Element { + pub fn new() -> Element { + ::std::default::Default::default() + } + + // .medea.Hub hub = 2; + + + pub fn get_hub(&self) -> &Hub { + match self.el { + ::std::option::Option::Some(Element_oneof_el::hub(ref v)) => v, + _ => Hub::default_instance(), + } + } + pub fn clear_hub(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_hub(&self) -> bool { + match self.el { + ::std::option::Option::Some(Element_oneof_el::hub(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_hub(&mut self, v: Hub) { + self.el = ::std::option::Option::Some(Element_oneof_el::hub(v)) + } + + // Mutable pointer to the field. + pub fn mut_hub(&mut self) -> &mut Hub { + if let ::std::option::Option::Some(Element_oneof_el::hub(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Element_oneof_el::hub(Hub::new())); + } + match self.el { + ::std::option::Option::Some(Element_oneof_el::hub(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_hub(&mut self) -> Hub { + if self.has_hub() { + match self.el.take() { + ::std::option::Option::Some(Element_oneof_el::hub(v)) => v, + _ => panic!(), + } + } else { + Hub::new() + } + } + + // .medea.FileRecorder file_recorder = 3; + + + pub fn get_file_recorder(&self) -> &FileRecorder { + match self.el { + ::std::option::Option::Some(Element_oneof_el::file_recorder(ref v)) => v, + _ => FileRecorder::default_instance(), + } + } + pub fn clear_file_recorder(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_file_recorder(&self) -> bool { + match self.el { + ::std::option::Option::Some(Element_oneof_el::file_recorder(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_file_recorder(&mut self, v: FileRecorder) { + self.el = ::std::option::Option::Some(Element_oneof_el::file_recorder(v)) + } + + // Mutable pointer to the field. + pub fn mut_file_recorder(&mut self) -> &mut FileRecorder { + if let ::std::option::Option::Some(Element_oneof_el::file_recorder(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Element_oneof_el::file_recorder(FileRecorder::new())); + } + match self.el { + ::std::option::Option::Some(Element_oneof_el::file_recorder(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_file_recorder(&mut self) -> FileRecorder { + if self.has_file_recorder() { + match self.el.take() { + ::std::option::Option::Some(Element_oneof_el::file_recorder(v)) => v, + _ => panic!(), + } + } else { + FileRecorder::new() + } + } + + // .medea.Member member = 4; + + + pub fn get_member(&self) -> &Member { + match self.el { + ::std::option::Option::Some(Element_oneof_el::member(ref v)) => v, + _ => Member::default_instance(), + } + } + pub fn clear_member(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_member(&self) -> bool { + match self.el { + ::std::option::Option::Some(Element_oneof_el::member(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_member(&mut self, v: Member) { + self.el = ::std::option::Option::Some(Element_oneof_el::member(v)) + } + + // Mutable pointer to the field. + pub fn mut_member(&mut self) -> &mut Member { + if let ::std::option::Option::Some(Element_oneof_el::member(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Element_oneof_el::member(Member::new())); + } + match self.el { + ::std::option::Option::Some(Element_oneof_el::member(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_member(&mut self) -> Member { + if self.has_member() { + match self.el.take() { + ::std::option::Option::Some(Element_oneof_el::member(v)) => v, + _ => panic!(), + } + } else { + Member::new() + } + } + + // .medea.Relay relay = 5; + + + pub fn get_relay(&self) -> &Relay { + match self.el { + ::std::option::Option::Some(Element_oneof_el::relay(ref v)) => v, + _ => Relay::default_instance(), + } + } + pub fn clear_relay(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_relay(&self) -> bool { + match self.el { + ::std::option::Option::Some(Element_oneof_el::relay(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_relay(&mut self, v: Relay) { + self.el = ::std::option::Option::Some(Element_oneof_el::relay(v)) + } + + // Mutable pointer to the field. + pub fn mut_relay(&mut self) -> &mut Relay { + if let ::std::option::Option::Some(Element_oneof_el::relay(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Element_oneof_el::relay(Relay::new())); + } + match self.el { + ::std::option::Option::Some(Element_oneof_el::relay(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_relay(&mut self) -> Relay { + if self.has_relay() { + match self.el.take() { + ::std::option::Option::Some(Element_oneof_el::relay(v)) => v, + _ => panic!(), + } + } else { + Relay::new() + } + } + + // .medea.Room room = 6; + + + pub fn get_room(&self) -> &Room { + match self.el { + ::std::option::Option::Some(Element_oneof_el::room(ref v)) => v, + _ => Room::default_instance(), + } + } + pub fn clear_room(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_room(&self) -> bool { + match self.el { + ::std::option::Option::Some(Element_oneof_el::room(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_room(&mut self, v: Room) { + self.el = ::std::option::Option::Some(Element_oneof_el::room(v)) + } + + // Mutable pointer to the field. + pub fn mut_room(&mut self) -> &mut Room { + if let ::std::option::Option::Some(Element_oneof_el::room(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Element_oneof_el::room(Room::new())); + } + match self.el { + ::std::option::Option::Some(Element_oneof_el::room(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_room(&mut self) -> Room { + if self.has_room() { + match self.el.take() { + ::std::option::Option::Some(Element_oneof_el::room(v)) => v, + _ => panic!(), + } + } else { + Room::new() + } + } + + // .medea.WebRtcPlayEndpoint webrtc_play = 7; + + + pub fn get_webrtc_play(&self) -> &WebRtcPlayEndpoint { + match self.el { + ::std::option::Option::Some(Element_oneof_el::webrtc_play(ref v)) => v, + _ => WebRtcPlayEndpoint::default_instance(), + } + } + pub fn clear_webrtc_play(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_webrtc_play(&self) -> bool { + match self.el { + ::std::option::Option::Some(Element_oneof_el::webrtc_play(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_webrtc_play(&mut self, v: WebRtcPlayEndpoint) { + self.el = ::std::option::Option::Some(Element_oneof_el::webrtc_play(v)) + } + + // Mutable pointer to the field. + pub fn mut_webrtc_play(&mut self) -> &mut WebRtcPlayEndpoint { + if let ::std::option::Option::Some(Element_oneof_el::webrtc_play(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Element_oneof_el::webrtc_play(WebRtcPlayEndpoint::new())); + } + match self.el { + ::std::option::Option::Some(Element_oneof_el::webrtc_play(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_webrtc_play(&mut self) -> WebRtcPlayEndpoint { + if self.has_webrtc_play() { + match self.el.take() { + ::std::option::Option::Some(Element_oneof_el::webrtc_play(v)) => v, + _ => panic!(), + } + } else { + WebRtcPlayEndpoint::new() + } + } + + // .medea.WebRtcPublishEndpoint webrtc_pub = 8; + + + pub fn get_webrtc_pub(&self) -> &WebRtcPublishEndpoint { + match self.el { + ::std::option::Option::Some(Element_oneof_el::webrtc_pub(ref v)) => v, + _ => WebRtcPublishEndpoint::default_instance(), + } + } + pub fn clear_webrtc_pub(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_webrtc_pub(&self) -> bool { + match self.el { + ::std::option::Option::Some(Element_oneof_el::webrtc_pub(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_webrtc_pub(&mut self, v: WebRtcPublishEndpoint) { + self.el = ::std::option::Option::Some(Element_oneof_el::webrtc_pub(v)) + } + + // Mutable pointer to the field. + pub fn mut_webrtc_pub(&mut self) -> &mut WebRtcPublishEndpoint { + if let ::std::option::Option::Some(Element_oneof_el::webrtc_pub(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Element_oneof_el::webrtc_pub(WebRtcPublishEndpoint::new())); + } + match self.el { + ::std::option::Option::Some(Element_oneof_el::webrtc_pub(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_webrtc_pub(&mut self) -> WebRtcPublishEndpoint { + if self.has_webrtc_pub() { + match self.el.take() { + ::std::option::Option::Some(Element_oneof_el::webrtc_pub(v)) => v, + _ => panic!(), + } + } else { + WebRtcPublishEndpoint::new() + } + } +} + +impl ::protobuf::Message for Element { + fn is_initialized(&self) -> bool { + if let Some(Element_oneof_el::hub(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(Element_oneof_el::file_recorder(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(Element_oneof_el::member(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(Element_oneof_el::relay(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(Element_oneof_el::room(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(Element_oneof_el::webrtc_play(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(Element_oneof_el::webrtc_pub(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 2 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Element_oneof_el::hub(is.read_message()?)); + }, + 3 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Element_oneof_el::file_recorder(is.read_message()?)); + }, + 4 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Element_oneof_el::member(is.read_message()?)); + }, + 5 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Element_oneof_el::relay(is.read_message()?)); + }, + 6 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Element_oneof_el::room(is.read_message()?)); + }, + 7 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Element_oneof_el::webrtc_play(is.read_message()?)); + }, + 8 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Element_oneof_el::webrtc_pub(is.read_message()?)); + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if let ::std::option::Option::Some(ref v) = self.el { + match v { + &Element_oneof_el::hub(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &Element_oneof_el::file_recorder(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &Element_oneof_el::member(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &Element_oneof_el::relay(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &Element_oneof_el::room(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &Element_oneof_el::webrtc_play(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &Element_oneof_el::webrtc_pub(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + }; + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { + if let ::std::option::Option::Some(ref v) = self.el { + match v { + &Element_oneof_el::hub(ref v) => { + os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &Element_oneof_el::file_recorder(ref v) => { + os.write_tag(3, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &Element_oneof_el::member(ref v) => { + os.write_tag(4, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &Element_oneof_el::relay(ref v) => { + os.write_tag(5, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &Element_oneof_el::room(ref v) => { + os.write_tag(6, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &Element_oneof_el::webrtc_play(ref v) => { + os.write_tag(7, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &Element_oneof_el::webrtc_pub(ref v) => { + os.write_tag(8, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + }; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &dyn (::std::any::Any) { + self as &dyn (::std::any::Any) + } + fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) { + self as &mut dyn (::std::any::Any) + } + fn into_any(self: Box) -> ::std::boxed::Box { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> Element { + Element::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Hub>( + "hub", + Element::has_hub, + Element::get_hub, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, FileRecorder>( + "file_recorder", + Element::has_file_recorder, + Element::get_file_recorder, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Member>( + "member", + Element::has_member, + Element::get_member, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Relay>( + "relay", + Element::has_relay, + Element::get_relay, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Room>( + "room", + Element::has_room, + Element::get_room, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPlayEndpoint>( + "webrtc_play", + Element::has_webrtc_play, + Element::get_webrtc_play, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPublishEndpoint>( + "webrtc_pub", + Element::has_webrtc_pub, + Element::get_webrtc_pub, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "Element", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static Element { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const Element, + }; + unsafe { + instance.get(Element::new) + } + } +} + +impl ::protobuf::Clear for Element { + fn clear(&mut self) { + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for Element { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for Element { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct Room { + // message fields + pub pipeline: ::std::collections::HashMap<::std::string::String, Room_Element>, + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a Room { + fn default() -> &'a Room { + ::default_instance() + } +} + +impl Room { + pub fn new() -> Room { + ::std::default::Default::default() + } + + // repeated .medea.Room.PipelineEntry pipeline = 1; + + + pub fn get_pipeline(&self) -> &::std::collections::HashMap<::std::string::String, Room_Element> { + &self.pipeline + } + pub fn clear_pipeline(&mut self) { + self.pipeline.clear(); + } + + // Param is passed by value, moved + pub fn set_pipeline(&mut self, v: ::std::collections::HashMap<::std::string::String, Room_Element>) { + self.pipeline = v; + } + + // Mutable pointer to the field. + pub fn mut_pipeline(&mut self) -> &mut ::std::collections::HashMap<::std::string::String, Room_Element> { + &mut self.pipeline + } + + // Take field + pub fn take_pipeline(&mut self) -> ::std::collections::HashMap<::std::string::String, Room_Element> { + ::std::mem::replace(&mut self.pipeline, ::std::collections::HashMap::new()) + } +} + +impl ::protobuf::Message for Room { + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_map_into::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(wire_type, is, &mut self.pipeline)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + my_size += ::protobuf::rt::compute_map_size::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(1, &self.pipeline); + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { + ::protobuf::rt::write_map_with_cached_sizes::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(1, &self.pipeline, os)?; + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &dyn (::std::any::Any) { + self as &dyn (::std::any::Any) + } + fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) { + self as &mut dyn (::std::any::Any) + } + fn into_any(self: Box) -> ::std::boxed::Box { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> Room { + Room::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_map_accessor::<_, ::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>( + "pipeline", + |m: &Room| { &m.pipeline }, + |m: &mut Room| { &mut m.pipeline }, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "Room", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static Room { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const Room, + }; + unsafe { + instance.get(Room::new) + } + } +} + +impl ::protobuf::Clear for Room { + fn clear(&mut self) { + self.pipeline.clear(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for Room { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for Room { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct Room_Element { + // message oneof groups + pub el: ::std::option::Option, + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a Room_Element { + fn default() -> &'a Room_Element { + ::default_instance() + } +} + +#[derive(Clone,PartialEq,Debug)] +pub enum Room_Element_oneof_el { + hub(Hub), + file_recorder(FileRecorder), + member(Member), + relay(Relay), + webrtc_play(WebRtcPlayEndpoint), + webrtc_pub(WebRtcPublishEndpoint), +} + +impl Room_Element { + pub fn new() -> Room_Element { + ::std::default::Default::default() + } + + // .medea.Hub hub = 1; + + + pub fn get_hub(&self) -> &Hub { + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::hub(ref v)) => v, + _ => Hub::default_instance(), + } + } + pub fn clear_hub(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_hub(&self) -> bool { + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::hub(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_hub(&mut self, v: Hub) { + self.el = ::std::option::Option::Some(Room_Element_oneof_el::hub(v)) + } + + // Mutable pointer to the field. + pub fn mut_hub(&mut self) -> &mut Hub { + if let ::std::option::Option::Some(Room_Element_oneof_el::hub(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Room_Element_oneof_el::hub(Hub::new())); + } + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::hub(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_hub(&mut self) -> Hub { + if self.has_hub() { + match self.el.take() { + ::std::option::Option::Some(Room_Element_oneof_el::hub(v)) => v, + _ => panic!(), + } + } else { + Hub::new() + } + } + + // .medea.FileRecorder file_recorder = 2; + + + pub fn get_file_recorder(&self) -> &FileRecorder { + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::file_recorder(ref v)) => v, + _ => FileRecorder::default_instance(), + } + } + pub fn clear_file_recorder(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_file_recorder(&self) -> bool { + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::file_recorder(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_file_recorder(&mut self, v: FileRecorder) { + self.el = ::std::option::Option::Some(Room_Element_oneof_el::file_recorder(v)) + } + + // Mutable pointer to the field. + pub fn mut_file_recorder(&mut self) -> &mut FileRecorder { + if let ::std::option::Option::Some(Room_Element_oneof_el::file_recorder(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Room_Element_oneof_el::file_recorder(FileRecorder::new())); + } + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::file_recorder(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_file_recorder(&mut self) -> FileRecorder { + if self.has_file_recorder() { + match self.el.take() { + ::std::option::Option::Some(Room_Element_oneof_el::file_recorder(v)) => v, + _ => panic!(), + } + } else { + FileRecorder::new() + } + } + + // .medea.Member member = 3; + + + pub fn get_member(&self) -> &Member { + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::member(ref v)) => v, + _ => Member::default_instance(), + } + } + pub fn clear_member(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_member(&self) -> bool { + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::member(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_member(&mut self, v: Member) { + self.el = ::std::option::Option::Some(Room_Element_oneof_el::member(v)) + } + + // Mutable pointer to the field. + pub fn mut_member(&mut self) -> &mut Member { + if let ::std::option::Option::Some(Room_Element_oneof_el::member(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Room_Element_oneof_el::member(Member::new())); + } + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::member(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_member(&mut self) -> Member { + if self.has_member() { + match self.el.take() { + ::std::option::Option::Some(Room_Element_oneof_el::member(v)) => v, + _ => panic!(), + } + } else { + Member::new() + } + } + + // .medea.Relay relay = 4; + + + pub fn get_relay(&self) -> &Relay { + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::relay(ref v)) => v, + _ => Relay::default_instance(), + } + } + pub fn clear_relay(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_relay(&self) -> bool { + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::relay(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_relay(&mut self, v: Relay) { + self.el = ::std::option::Option::Some(Room_Element_oneof_el::relay(v)) + } + + // Mutable pointer to the field. + pub fn mut_relay(&mut self) -> &mut Relay { + if let ::std::option::Option::Some(Room_Element_oneof_el::relay(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Room_Element_oneof_el::relay(Relay::new())); + } + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::relay(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_relay(&mut self) -> Relay { + if self.has_relay() { + match self.el.take() { + ::std::option::Option::Some(Room_Element_oneof_el::relay(v)) => v, + _ => panic!(), + } + } else { + Relay::new() + } + } + + // .medea.WebRtcPlayEndpoint webrtc_play = 5; + + + pub fn get_webrtc_play(&self) -> &WebRtcPlayEndpoint { + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(ref v)) => v, + _ => WebRtcPlayEndpoint::default_instance(), + } + } + pub fn clear_webrtc_play(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_webrtc_play(&self) -> bool { + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_webrtc_play(&mut self, v: WebRtcPlayEndpoint) { + self.el = ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(v)) + } + + // Mutable pointer to the field. + pub fn mut_webrtc_play(&mut self) -> &mut WebRtcPlayEndpoint { + if let ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(WebRtcPlayEndpoint::new())); + } + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_webrtc_play(&mut self) -> WebRtcPlayEndpoint { + if self.has_webrtc_play() { + match self.el.take() { + ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(v)) => v, + _ => panic!(), + } + } else { + WebRtcPlayEndpoint::new() + } + } + + // .medea.WebRtcPublishEndpoint webrtc_pub = 6; + + + pub fn get_webrtc_pub(&self) -> &WebRtcPublishEndpoint { + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(ref v)) => v, + _ => WebRtcPublishEndpoint::default_instance(), + } + } + pub fn clear_webrtc_pub(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_webrtc_pub(&self) -> bool { + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_webrtc_pub(&mut self, v: WebRtcPublishEndpoint) { + self.el = ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(v)) + } + + // Mutable pointer to the field. + pub fn mut_webrtc_pub(&mut self) -> &mut WebRtcPublishEndpoint { + if let ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(WebRtcPublishEndpoint::new())); + } + match self.el { + ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_webrtc_pub(&mut self) -> WebRtcPublishEndpoint { + if self.has_webrtc_pub() { + match self.el.take() { + ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(v)) => v, + _ => panic!(), + } + } else { + WebRtcPublishEndpoint::new() + } + } +} + +impl ::protobuf::Message for Room_Element { + fn is_initialized(&self) -> bool { + if let Some(Room_Element_oneof_el::hub(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(Room_Element_oneof_el::file_recorder(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(Room_Element_oneof_el::member(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(Room_Element_oneof_el::relay(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(Room_Element_oneof_el::webrtc_play(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(Room_Element_oneof_el::webrtc_pub(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Room_Element_oneof_el::hub(is.read_message()?)); + }, + 2 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Room_Element_oneof_el::file_recorder(is.read_message()?)); + }, + 3 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Room_Element_oneof_el::member(is.read_message()?)); + }, + 4 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Room_Element_oneof_el::relay(is.read_message()?)); + }, + 5 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(is.read_message()?)); + }, + 6 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(is.read_message()?)); + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if let ::std::option::Option::Some(ref v) = self.el { + match v { + &Room_Element_oneof_el::hub(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &Room_Element_oneof_el::file_recorder(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &Room_Element_oneof_el::member(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &Room_Element_oneof_el::relay(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &Room_Element_oneof_el::webrtc_play(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &Room_Element_oneof_el::webrtc_pub(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + }; + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { + if let ::std::option::Option::Some(ref v) = self.el { + match v { + &Room_Element_oneof_el::hub(ref v) => { + os.write_tag(1, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &Room_Element_oneof_el::file_recorder(ref v) => { + os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &Room_Element_oneof_el::member(ref v) => { + os.write_tag(3, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &Room_Element_oneof_el::relay(ref v) => { + os.write_tag(4, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &Room_Element_oneof_el::webrtc_play(ref v) => { + os.write_tag(5, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &Room_Element_oneof_el::webrtc_pub(ref v) => { + os.write_tag(6, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + }; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &dyn (::std::any::Any) { + self as &dyn (::std::any::Any) + } + fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) { + self as &mut dyn (::std::any::Any) + } + fn into_any(self: Box) -> ::std::boxed::Box { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> Room_Element { + Room_Element::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Hub>( + "hub", + Room_Element::has_hub, + Room_Element::get_hub, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, FileRecorder>( + "file_recorder", + Room_Element::has_file_recorder, + Room_Element::get_file_recorder, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Member>( + "member", + Room_Element::has_member, + Room_Element::get_member, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Relay>( + "relay", + Room_Element::has_relay, + Room_Element::get_relay, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPlayEndpoint>( + "webrtc_play", + Room_Element::has_webrtc_play, + Room_Element::get_webrtc_play, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPublishEndpoint>( + "webrtc_pub", + Room_Element::has_webrtc_pub, + Room_Element::get_webrtc_pub, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "Room_Element", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static Room_Element { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const Room_Element, + }; + unsafe { + instance.get(Room_Element::new) + } + } +} + +impl ::protobuf::Clear for Room_Element { + fn clear(&mut self) { + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for Room_Element { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for Room_Element { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct Member { + // message fields + pub on_join: ::std::string::String, + pub on_leave: ::std::string::String, + pub credentials: ::std::string::String, + pub pipeline: ::std::collections::HashMap<::std::string::String, Member_Element>, + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a Member { + fn default() -> &'a Member { + ::default_instance() + } +} + +impl Member { + pub fn new() -> Member { + ::std::default::Default::default() + } + + // string on_join = 1; + + + pub fn get_on_join(&self) -> &str { + &self.on_join + } + pub fn clear_on_join(&mut self) { + self.on_join.clear(); + } + + // Param is passed by value, moved + pub fn set_on_join(&mut self, v: ::std::string::String) { + self.on_join = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_on_join(&mut self) -> &mut ::std::string::String { + &mut self.on_join + } + + // Take field + pub fn take_on_join(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.on_join, ::std::string::String::new()) + } + + // string on_leave = 2; + + + pub fn get_on_leave(&self) -> &str { + &self.on_leave + } + pub fn clear_on_leave(&mut self) { + self.on_leave.clear(); + } + + // Param is passed by value, moved + pub fn set_on_leave(&mut self, v: ::std::string::String) { + self.on_leave = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_on_leave(&mut self) -> &mut ::std::string::String { + &mut self.on_leave + } + + // Take field + pub fn take_on_leave(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.on_leave, ::std::string::String::new()) + } + + // string credentials = 3; + + + pub fn get_credentials(&self) -> &str { + &self.credentials + } + pub fn clear_credentials(&mut self) { + self.credentials.clear(); + } + + // Param is passed by value, moved + pub fn set_credentials(&mut self, v: ::std::string::String) { + self.credentials = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_credentials(&mut self) -> &mut ::std::string::String { + &mut self.credentials + } + + // Take field + pub fn take_credentials(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.credentials, ::std::string::String::new()) + } + + // repeated .medea.Member.PipelineEntry pipeline = 4; + + + pub fn get_pipeline(&self) -> &::std::collections::HashMap<::std::string::String, Member_Element> { + &self.pipeline + } + pub fn clear_pipeline(&mut self) { + self.pipeline.clear(); + } + + // Param is passed by value, moved + pub fn set_pipeline(&mut self, v: ::std::collections::HashMap<::std::string::String, Member_Element>) { + self.pipeline = v; + } + + // Mutable pointer to the field. + pub fn mut_pipeline(&mut self) -> &mut ::std::collections::HashMap<::std::string::String, Member_Element> { + &mut self.pipeline + } + + // Take field + pub fn take_pipeline(&mut self) -> ::std::collections::HashMap<::std::string::String, Member_Element> { + ::std::mem::replace(&mut self.pipeline, ::std::collections::HashMap::new()) + } +} + +impl ::protobuf::Message for Member { + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.on_join)?; + }, + 2 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.on_leave)?; + }, + 3 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.credentials)?; + }, + 4 => { + ::protobuf::rt::read_map_into::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(wire_type, is, &mut self.pipeline)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if !self.on_join.is_empty() { + my_size += ::protobuf::rt::string_size(1, &self.on_join); + } + if !self.on_leave.is_empty() { + my_size += ::protobuf::rt::string_size(2, &self.on_leave); + } + if !self.credentials.is_empty() { + my_size += ::protobuf::rt::string_size(3, &self.credentials); + } + my_size += ::protobuf::rt::compute_map_size::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(4, &self.pipeline); + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { + if !self.on_join.is_empty() { + os.write_string(1, &self.on_join)?; + } + if !self.on_leave.is_empty() { + os.write_string(2, &self.on_leave)?; + } + if !self.credentials.is_empty() { + os.write_string(3, &self.credentials)?; + } + ::protobuf::rt::write_map_with_cached_sizes::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(4, &self.pipeline, os)?; + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &dyn (::std::any::Any) { + self as &dyn (::std::any::Any) + } + fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) { + self as &mut dyn (::std::any::Any) + } + fn into_any(self: Box) -> ::std::boxed::Box { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> Member { + Member::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "on_join", + |m: &Member| { &m.on_join }, + |m: &mut Member| { &mut m.on_join }, + )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "on_leave", + |m: &Member| { &m.on_leave }, + |m: &mut Member| { &mut m.on_leave }, + )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "credentials", + |m: &Member| { &m.credentials }, + |m: &mut Member| { &mut m.credentials }, + )); + fields.push(::protobuf::reflect::accessor::make_map_accessor::<_, ::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>( + "pipeline", + |m: &Member| { &m.pipeline }, + |m: &mut Member| { &mut m.pipeline }, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "Member", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static Member { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const Member, + }; + unsafe { + instance.get(Member::new) + } + } +} + +impl ::protobuf::Clear for Member { + fn clear(&mut self) { + self.on_join.clear(); + self.on_leave.clear(); + self.credentials.clear(); + self.pipeline.clear(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for Member { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for Member { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct Member_Element { + // message oneof groups + pub el: ::std::option::Option, + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a Member_Element { + fn default() -> &'a Member_Element { + ::default_instance() + } +} + +#[derive(Clone,PartialEq,Debug)] +pub enum Member_Element_oneof_el { + hub(Hub), + file_recorder(FileRecorder), + relay(Relay), + webrtc_play(WebRtcPlayEndpoint), + webrtc_pub(WebRtcPublishEndpoint), +} + +impl Member_Element { + pub fn new() -> Member_Element { + ::std::default::Default::default() + } + + // .medea.Hub hub = 1; + + + pub fn get_hub(&self) -> &Hub { + match self.el { + ::std::option::Option::Some(Member_Element_oneof_el::hub(ref v)) => v, + _ => Hub::default_instance(), + } + } + pub fn clear_hub(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_hub(&self) -> bool { + match self.el { + ::std::option::Option::Some(Member_Element_oneof_el::hub(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_hub(&mut self, v: Hub) { + self.el = ::std::option::Option::Some(Member_Element_oneof_el::hub(v)) + } + + // Mutable pointer to the field. + pub fn mut_hub(&mut self) -> &mut Hub { + if let ::std::option::Option::Some(Member_Element_oneof_el::hub(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Member_Element_oneof_el::hub(Hub::new())); + } + match self.el { + ::std::option::Option::Some(Member_Element_oneof_el::hub(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_hub(&mut self) -> Hub { + if self.has_hub() { + match self.el.take() { + ::std::option::Option::Some(Member_Element_oneof_el::hub(v)) => v, + _ => panic!(), + } + } else { + Hub::new() + } + } + + // .medea.FileRecorder file_recorder = 2; + + + pub fn get_file_recorder(&self) -> &FileRecorder { + match self.el { + ::std::option::Option::Some(Member_Element_oneof_el::file_recorder(ref v)) => v, + _ => FileRecorder::default_instance(), + } + } + pub fn clear_file_recorder(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_file_recorder(&self) -> bool { + match self.el { + ::std::option::Option::Some(Member_Element_oneof_el::file_recorder(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_file_recorder(&mut self, v: FileRecorder) { + self.el = ::std::option::Option::Some(Member_Element_oneof_el::file_recorder(v)) + } + + // Mutable pointer to the field. + pub fn mut_file_recorder(&mut self) -> &mut FileRecorder { + if let ::std::option::Option::Some(Member_Element_oneof_el::file_recorder(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Member_Element_oneof_el::file_recorder(FileRecorder::new())); + } + match self.el { + ::std::option::Option::Some(Member_Element_oneof_el::file_recorder(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_file_recorder(&mut self) -> FileRecorder { + if self.has_file_recorder() { + match self.el.take() { + ::std::option::Option::Some(Member_Element_oneof_el::file_recorder(v)) => v, + _ => panic!(), + } + } else { + FileRecorder::new() + } + } + + // .medea.Relay relay = 3; + + + pub fn get_relay(&self) -> &Relay { + match self.el { + ::std::option::Option::Some(Member_Element_oneof_el::relay(ref v)) => v, + _ => Relay::default_instance(), + } + } + pub fn clear_relay(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_relay(&self) -> bool { + match self.el { + ::std::option::Option::Some(Member_Element_oneof_el::relay(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_relay(&mut self, v: Relay) { + self.el = ::std::option::Option::Some(Member_Element_oneof_el::relay(v)) + } + + // Mutable pointer to the field. + pub fn mut_relay(&mut self) -> &mut Relay { + if let ::std::option::Option::Some(Member_Element_oneof_el::relay(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Member_Element_oneof_el::relay(Relay::new())); + } + match self.el { + ::std::option::Option::Some(Member_Element_oneof_el::relay(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_relay(&mut self) -> Relay { + if self.has_relay() { + match self.el.take() { + ::std::option::Option::Some(Member_Element_oneof_el::relay(v)) => v, + _ => panic!(), + } + } else { + Relay::new() + } + } + + // .medea.WebRtcPlayEndpoint webrtc_play = 4; + + + pub fn get_webrtc_play(&self) -> &WebRtcPlayEndpoint { + match self.el { + ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(ref v)) => v, + _ => WebRtcPlayEndpoint::default_instance(), + } + } + pub fn clear_webrtc_play(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_webrtc_play(&self) -> bool { + match self.el { + ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_webrtc_play(&mut self, v: WebRtcPlayEndpoint) { + self.el = ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(v)) + } + + // Mutable pointer to the field. + pub fn mut_webrtc_play(&mut self) -> &mut WebRtcPlayEndpoint { + if let ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(WebRtcPlayEndpoint::new())); + } + match self.el { + ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_webrtc_play(&mut self) -> WebRtcPlayEndpoint { + if self.has_webrtc_play() { + match self.el.take() { + ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(v)) => v, + _ => panic!(), + } + } else { + WebRtcPlayEndpoint::new() + } + } + + // .medea.WebRtcPublishEndpoint webrtc_pub = 5; + + + pub fn get_webrtc_pub(&self) -> &WebRtcPublishEndpoint { + match self.el { + ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(ref v)) => v, + _ => WebRtcPublishEndpoint::default_instance(), + } + } + pub fn clear_webrtc_pub(&mut self) { + self.el = ::std::option::Option::None; + } + + pub fn has_webrtc_pub(&self) -> bool { + match self.el { + ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_webrtc_pub(&mut self, v: WebRtcPublishEndpoint) { + self.el = ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(v)) + } + + // Mutable pointer to the field. + pub fn mut_webrtc_pub(&mut self) -> &mut WebRtcPublishEndpoint { + if let ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(_)) = self.el { + } else { + self.el = ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(WebRtcPublishEndpoint::new())); + } + match self.el { + ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_webrtc_pub(&mut self) -> WebRtcPublishEndpoint { + if self.has_webrtc_pub() { + match self.el.take() { + ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(v)) => v, + _ => panic!(), + } + } else { + WebRtcPublishEndpoint::new() + } + } +} + +impl ::protobuf::Message for Member_Element { + fn is_initialized(&self) -> bool { + if let Some(Member_Element_oneof_el::hub(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(Member_Element_oneof_el::file_recorder(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(Member_Element_oneof_el::relay(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(Member_Element_oneof_el::webrtc_play(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + if let Some(Member_Element_oneof_el::webrtc_pub(ref v)) = self.el { + if !v.is_initialized() { + return false; + } + } + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Member_Element_oneof_el::hub(is.read_message()?)); + }, + 2 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Member_Element_oneof_el::file_recorder(is.read_message()?)); + }, + 3 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Member_Element_oneof_el::relay(is.read_message()?)); + }, + 4 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(is.read_message()?)); + }, + 5 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.el = ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(is.read_message()?)); + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if let ::std::option::Option::Some(ref v) = self.el { + match v { + &Member_Element_oneof_el::hub(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &Member_Element_oneof_el::file_recorder(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &Member_Element_oneof_el::relay(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &Member_Element_oneof_el::webrtc_play(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &Member_Element_oneof_el::webrtc_pub(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + }; + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { + if let ::std::option::Option::Some(ref v) = self.el { + match v { + &Member_Element_oneof_el::hub(ref v) => { + os.write_tag(1, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &Member_Element_oneof_el::file_recorder(ref v) => { + os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &Member_Element_oneof_el::relay(ref v) => { + os.write_tag(3, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &Member_Element_oneof_el::webrtc_play(ref v) => { + os.write_tag(4, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &Member_Element_oneof_el::webrtc_pub(ref v) => { + os.write_tag(5, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + }; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &dyn (::std::any::Any) { + self as &dyn (::std::any::Any) + } + fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) { + self as &mut dyn (::std::any::Any) + } + fn into_any(self: Box) -> ::std::boxed::Box { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> Member_Element { + Member_Element::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Hub>( + "hub", + Member_Element::has_hub, + Member_Element::get_hub, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, FileRecorder>( + "file_recorder", + Member_Element::has_file_recorder, + Member_Element::get_file_recorder, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Relay>( + "relay", + Member_Element::has_relay, + Member_Element::get_relay, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPlayEndpoint>( + "webrtc_play", + Member_Element::has_webrtc_play, + Member_Element::get_webrtc_play, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPublishEndpoint>( + "webrtc_pub", + Member_Element::has_webrtc_pub, + Member_Element::get_webrtc_pub, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "Member_Element", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static Member_Element { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const Member_Element, + }; + unsafe { + instance.get(Member_Element::new) + } + } +} + +impl ::protobuf::Clear for Member_Element { + fn clear(&mut self) { + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.el = ::std::option::Option::None; + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for Member_Element { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for Member_Element { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct WebRtcPublishEndpoint { + // message fields + pub p2p: WebRtcPublishEndpoint_P2P, + pub on_start: ::std::string::String, + pub on_stop: ::std::string::String, + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a WebRtcPublishEndpoint { + fn default() -> &'a WebRtcPublishEndpoint { + ::default_instance() + } +} + +impl WebRtcPublishEndpoint { + pub fn new() -> WebRtcPublishEndpoint { + ::std::default::Default::default() + } + + // .medea.WebRtcPublishEndpoint.P2P p2p = 1; + + + pub fn get_p2p(&self) -> WebRtcPublishEndpoint_P2P { + self.p2p + } + pub fn clear_p2p(&mut self) { + self.p2p = WebRtcPublishEndpoint_P2P::NEVER; + } + + // Param is passed by value, moved + pub fn set_p2p(&mut self, v: WebRtcPublishEndpoint_P2P) { + self.p2p = v; + } + + // string on_start = 3; + + + pub fn get_on_start(&self) -> &str { + &self.on_start + } + pub fn clear_on_start(&mut self) { + self.on_start.clear(); + } + + // Param is passed by value, moved + pub fn set_on_start(&mut self, v: ::std::string::String) { + self.on_start = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_on_start(&mut self) -> &mut ::std::string::String { + &mut self.on_start + } + + // Take field + pub fn take_on_start(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.on_start, ::std::string::String::new()) + } + + // string on_stop = 4; + + + pub fn get_on_stop(&self) -> &str { + &self.on_stop + } + pub fn clear_on_stop(&mut self) { + self.on_stop.clear(); + } + + // Param is passed by value, moved + pub fn set_on_stop(&mut self, v: ::std::string::String) { + self.on_stop = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_on_stop(&mut self) -> &mut ::std::string::String { + &mut self.on_stop + } + + // Take field + pub fn take_on_stop(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.on_stop, ::std::string::String::new()) + } +} + +impl ::protobuf::Message for WebRtcPublishEndpoint { + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_proto3_enum_with_unknown_fields_into(wire_type, is, &mut self.p2p, 1, &mut self.unknown_fields)? + }, + 3 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.on_start)?; + }, + 4 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.on_stop)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if self.p2p != WebRtcPublishEndpoint_P2P::NEVER { + my_size += ::protobuf::rt::enum_size(1, self.p2p); + } + if !self.on_start.is_empty() { + my_size += ::protobuf::rt::string_size(3, &self.on_start); + } + if !self.on_stop.is_empty() { + my_size += ::protobuf::rt::string_size(4, &self.on_stop); + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { + if self.p2p != WebRtcPublishEndpoint_P2P::NEVER { + os.write_enum(1, self.p2p.value())?; + } + if !self.on_start.is_empty() { + os.write_string(3, &self.on_start)?; + } + if !self.on_stop.is_empty() { + os.write_string(4, &self.on_stop)?; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &dyn (::std::any::Any) { + self as &dyn (::std::any::Any) + } + fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) { + self as &mut dyn (::std::any::Any) + } + fn into_any(self: Box) -> ::std::boxed::Box { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> WebRtcPublishEndpoint { + WebRtcPublishEndpoint::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeEnum>( + "p2p", + |m: &WebRtcPublishEndpoint| { &m.p2p }, + |m: &mut WebRtcPublishEndpoint| { &mut m.p2p }, + )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "on_start", + |m: &WebRtcPublishEndpoint| { &m.on_start }, + |m: &mut WebRtcPublishEndpoint| { &mut m.on_start }, + )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "on_stop", + |m: &WebRtcPublishEndpoint| { &m.on_stop }, + |m: &mut WebRtcPublishEndpoint| { &mut m.on_stop }, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "WebRtcPublishEndpoint", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static WebRtcPublishEndpoint { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const WebRtcPublishEndpoint, + }; + unsafe { + instance.get(WebRtcPublishEndpoint::new) + } + } +} + +impl ::protobuf::Clear for WebRtcPublishEndpoint { + fn clear(&mut self) { + self.p2p = WebRtcPublishEndpoint_P2P::NEVER; + self.on_start.clear(); + self.on_stop.clear(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for WebRtcPublishEndpoint { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for WebRtcPublishEndpoint { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(Clone,PartialEq,Eq,Debug,Hash)] +pub enum WebRtcPublishEndpoint_P2P { + NEVER = 0, + IF_POSSIBLE = 1, + ALWAYS = 2, +} + +impl ::protobuf::ProtobufEnum for WebRtcPublishEndpoint_P2P { + fn value(&self) -> i32 { + *self as i32 + } + + fn from_i32(value: i32) -> ::std::option::Option { + match value { + 0 => ::std::option::Option::Some(WebRtcPublishEndpoint_P2P::NEVER), + 1 => ::std::option::Option::Some(WebRtcPublishEndpoint_P2P::IF_POSSIBLE), + 2 => ::std::option::Option::Some(WebRtcPublishEndpoint_P2P::ALWAYS), + _ => ::std::option::Option::None + } + } + + fn values() -> &'static [Self] { + static values: &'static [WebRtcPublishEndpoint_P2P] = &[ + WebRtcPublishEndpoint_P2P::NEVER, + WebRtcPublishEndpoint_P2P::IF_POSSIBLE, + WebRtcPublishEndpoint_P2P::ALWAYS, + ]; + values + } + + fn enum_descriptor_static() -> &'static ::protobuf::reflect::EnumDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::EnumDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::EnumDescriptor, + }; + unsafe { + descriptor.get(|| { + ::protobuf::reflect::EnumDescriptor::new("WebRtcPublishEndpoint_P2P", file_descriptor_proto()) + }) + } + } +} + +impl ::std::marker::Copy for WebRtcPublishEndpoint_P2P { +} + +impl ::std::default::Default for WebRtcPublishEndpoint_P2P { + fn default() -> Self { + WebRtcPublishEndpoint_P2P::NEVER + } +} + +impl ::protobuf::reflect::ProtobufValue for WebRtcPublishEndpoint_P2P { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Enum(self.descriptor()) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct WebRtcPlayEndpoint { + // message fields + pub src: ::std::string::String, + pub on_start: ::std::string::String, + pub on_stop: ::std::string::String, + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a WebRtcPlayEndpoint { + fn default() -> &'a WebRtcPlayEndpoint { + ::default_instance() + } +} + +impl WebRtcPlayEndpoint { + pub fn new() -> WebRtcPlayEndpoint { + ::std::default::Default::default() + } + + // string src = 1; + + + pub fn get_src(&self) -> &str { + &self.src + } + pub fn clear_src(&mut self) { + self.src.clear(); + } + + // Param is passed by value, moved + pub fn set_src(&mut self, v: ::std::string::String) { + self.src = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_src(&mut self) -> &mut ::std::string::String { + &mut self.src + } + + // Take field + pub fn take_src(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.src, ::std::string::String::new()) + } + + // string on_start = 2; + + + pub fn get_on_start(&self) -> &str { + &self.on_start + } + pub fn clear_on_start(&mut self) { + self.on_start.clear(); + } + + // Param is passed by value, moved + pub fn set_on_start(&mut self, v: ::std::string::String) { + self.on_start = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_on_start(&mut self) -> &mut ::std::string::String { + &mut self.on_start + } + + // Take field + pub fn take_on_start(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.on_start, ::std::string::String::new()) + } + + // string on_stop = 3; + + + pub fn get_on_stop(&self) -> &str { + &self.on_stop + } + pub fn clear_on_stop(&mut self) { + self.on_stop.clear(); + } + + // Param is passed by value, moved + pub fn set_on_stop(&mut self, v: ::std::string::String) { + self.on_stop = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_on_stop(&mut self) -> &mut ::std::string::String { + &mut self.on_stop + } + + // Take field + pub fn take_on_stop(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.on_stop, ::std::string::String::new()) + } +} + +impl ::protobuf::Message for WebRtcPlayEndpoint { + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.src)?; + }, + 2 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.on_start)?; + }, + 3 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.on_stop)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if !self.src.is_empty() { + my_size += ::protobuf::rt::string_size(1, &self.src); + } + if !self.on_start.is_empty() { + my_size += ::protobuf::rt::string_size(2, &self.on_start); + } + if !self.on_stop.is_empty() { + my_size += ::protobuf::rt::string_size(3, &self.on_stop); + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { + if !self.src.is_empty() { + os.write_string(1, &self.src)?; + } + if !self.on_start.is_empty() { + os.write_string(2, &self.on_start)?; + } + if !self.on_stop.is_empty() { + os.write_string(3, &self.on_stop)?; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &dyn (::std::any::Any) { + self as &dyn (::std::any::Any) + } + fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) { + self as &mut dyn (::std::any::Any) + } + fn into_any(self: Box) -> ::std::boxed::Box { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> WebRtcPlayEndpoint { + WebRtcPlayEndpoint::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "src", + |m: &WebRtcPlayEndpoint| { &m.src }, + |m: &mut WebRtcPlayEndpoint| { &mut m.src }, + )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "on_start", + |m: &WebRtcPlayEndpoint| { &m.on_start }, + |m: &mut WebRtcPlayEndpoint| { &mut m.on_start }, + )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "on_stop", + |m: &WebRtcPlayEndpoint| { &m.on_stop }, + |m: &mut WebRtcPlayEndpoint| { &mut m.on_stop }, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "WebRtcPlayEndpoint", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static WebRtcPlayEndpoint { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const WebRtcPlayEndpoint, + }; + unsafe { + instance.get(WebRtcPlayEndpoint::new) + } + } +} + +impl ::protobuf::Clear for WebRtcPlayEndpoint { + fn clear(&mut self) { + self.src.clear(); + self.on_start.clear(); + self.on_stop.clear(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for WebRtcPlayEndpoint { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for WebRtcPlayEndpoint { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct Hub { + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a Hub { + fn default() -> &'a Hub { + ::default_instance() + } +} + +impl Hub { + pub fn new() -> Hub { + ::std::default::Default::default() + } +} + +impl ::protobuf::Message for Hub { + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &dyn (::std::any::Any) { + self as &dyn (::std::any::Any) + } + fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) { + self as &mut dyn (::std::any::Any) + } + fn into_any(self: Box) -> ::std::boxed::Box { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> Hub { + Hub::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let fields = ::std::vec::Vec::new(); + ::protobuf::reflect::MessageDescriptor::new::( + "Hub", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static Hub { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const Hub, + }; + unsafe { + instance.get(Hub::new) + } + } +} + +impl ::protobuf::Clear for Hub { + fn clear(&mut self) { + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for Hub { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for Hub { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct FileRecorder { + // message fields + pub src: ::std::string::String, + pub dst: ::std::string::String, + pub on_start: ::std::string::String, + pub on_stop: ::std::string::String, + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a FileRecorder { + fn default() -> &'a FileRecorder { + ::default_instance() + } +} + +impl FileRecorder { + pub fn new() -> FileRecorder { + ::std::default::Default::default() + } + + // string src = 1; + + + pub fn get_src(&self) -> &str { + &self.src + } + pub fn clear_src(&mut self) { + self.src.clear(); + } + + // Param is passed by value, moved + pub fn set_src(&mut self, v: ::std::string::String) { + self.src = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_src(&mut self) -> &mut ::std::string::String { + &mut self.src + } + + // Take field + pub fn take_src(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.src, ::std::string::String::new()) + } + + // string dst = 2; + + + pub fn get_dst(&self) -> &str { + &self.dst + } + pub fn clear_dst(&mut self) { + self.dst.clear(); + } + + // Param is passed by value, moved + pub fn set_dst(&mut self, v: ::std::string::String) { + self.dst = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_dst(&mut self) -> &mut ::std::string::String { + &mut self.dst + } + + // Take field + pub fn take_dst(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.dst, ::std::string::String::new()) + } + + // string on_start = 3; + + + pub fn get_on_start(&self) -> &str { + &self.on_start + } + pub fn clear_on_start(&mut self) { + self.on_start.clear(); + } + + // Param is passed by value, moved + pub fn set_on_start(&mut self, v: ::std::string::String) { + self.on_start = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_on_start(&mut self) -> &mut ::std::string::String { + &mut self.on_start + } + + // Take field + pub fn take_on_start(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.on_start, ::std::string::String::new()) + } + + // string on_stop = 4; + + + pub fn get_on_stop(&self) -> &str { + &self.on_stop + } + pub fn clear_on_stop(&mut self) { + self.on_stop.clear(); + } + + // Param is passed by value, moved + pub fn set_on_stop(&mut self, v: ::std::string::String) { + self.on_stop = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_on_stop(&mut self) -> &mut ::std::string::String { + &mut self.on_stop + } + + // Take field + pub fn take_on_stop(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.on_stop, ::std::string::String::new()) + } +} + +impl ::protobuf::Message for FileRecorder { + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.src)?; + }, + 2 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.dst)?; + }, + 3 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.on_start)?; + }, + 4 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.on_stop)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if !self.src.is_empty() { + my_size += ::protobuf::rt::string_size(1, &self.src); + } + if !self.dst.is_empty() { + my_size += ::protobuf::rt::string_size(2, &self.dst); + } + if !self.on_start.is_empty() { + my_size += ::protobuf::rt::string_size(3, &self.on_start); + } + if !self.on_stop.is_empty() { + my_size += ::protobuf::rt::string_size(4, &self.on_stop); + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { + if !self.src.is_empty() { + os.write_string(1, &self.src)?; + } + if !self.dst.is_empty() { + os.write_string(2, &self.dst)?; + } + if !self.on_start.is_empty() { + os.write_string(3, &self.on_start)?; + } + if !self.on_stop.is_empty() { + os.write_string(4, &self.on_stop)?; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &dyn (::std::any::Any) { + self as &dyn (::std::any::Any) + } + fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) { + self as &mut dyn (::std::any::Any) + } + fn into_any(self: Box) -> ::std::boxed::Box { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> FileRecorder { + FileRecorder::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "src", + |m: &FileRecorder| { &m.src }, + |m: &mut FileRecorder| { &mut m.src }, + )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "dst", + |m: &FileRecorder| { &m.dst }, + |m: &mut FileRecorder| { &mut m.dst }, + )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "on_start", + |m: &FileRecorder| { &m.on_start }, + |m: &mut FileRecorder| { &mut m.on_start }, + )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "on_stop", + |m: &FileRecorder| { &m.on_stop }, + |m: &mut FileRecorder| { &mut m.on_stop }, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "FileRecorder", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static FileRecorder { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const FileRecorder, + }; + unsafe { + instance.get(FileRecorder::new) + } + } +} + +impl ::protobuf::Clear for FileRecorder { + fn clear(&mut self) { + self.src.clear(); + self.dst.clear(); + self.on_start.clear(); + self.on_stop.clear(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for FileRecorder { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for FileRecorder { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct Relay { + // message fields + pub src: ::std::string::String, + pub dst: ::std::string::String, + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a Relay { + fn default() -> &'a Relay { + ::default_instance() + } +} + +impl Relay { + pub fn new() -> Relay { + ::std::default::Default::default() + } + + // string src = 1; + + + pub fn get_src(&self) -> &str { + &self.src + } + pub fn clear_src(&mut self) { + self.src.clear(); + } + + // Param is passed by value, moved + pub fn set_src(&mut self, v: ::std::string::String) { + self.src = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_src(&mut self) -> &mut ::std::string::String { + &mut self.src + } + + // Take field + pub fn take_src(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.src, ::std::string::String::new()) + } + + // string dst = 2; + + + pub fn get_dst(&self) -> &str { + &self.dst + } + pub fn clear_dst(&mut self) { + self.dst.clear(); + } + + // Param is passed by value, moved + pub fn set_dst(&mut self, v: ::std::string::String) { + self.dst = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_dst(&mut self) -> &mut ::std::string::String { + &mut self.dst + } + + // Take field + pub fn take_dst(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.dst, ::std::string::String::new()) + } +} + +impl ::protobuf::Message for Relay { + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.src)?; + }, + 2 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.dst)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if !self.src.is_empty() { + my_size += ::protobuf::rt::string_size(1, &self.src); + } + if !self.dst.is_empty() { + my_size += ::protobuf::rt::string_size(2, &self.dst); + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { + if !self.src.is_empty() { + os.write_string(1, &self.src)?; + } + if !self.dst.is_empty() { + os.write_string(2, &self.dst)?; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &dyn (::std::any::Any) { + self as &dyn (::std::any::Any) + } + fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) { + self as &mut dyn (::std::any::Any) + } + fn into_any(self: Box) -> ::std::boxed::Box { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> Relay { + Relay::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "src", + |m: &Relay| { &m.src }, + |m: &mut Relay| { &mut m.src }, + )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "dst", + |m: &Relay| { &m.dst }, + |m: &mut Relay| { &mut m.dst }, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "Relay", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static Relay { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const Relay, + }; + unsafe { + instance.get(Relay::new) + } + } +} + +impl ::protobuf::Clear for Relay { + fn clear(&mut self) { + self.src.clear(); + self.dst.clear(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for Relay { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for Relay { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +static file_descriptor_proto_data: &'static [u8] = b"\ + \n\x11control_api.proto\x12\x05medea\"\xf0\x02\n\rCreateRequest\x12\x0e\ + \n\x02id\x18\x01\x20\x01(\tR\x02id\x12\x1e\n\x03hub\x18\x02\x20\x01(\x0b\ + 2\n.medea.HubH\0R\x03hub\x12:\n\rfile_recorder\x18\x03\x20\x01(\x0b2\x13\ + .medea.FileRecorderH\0R\x0cfileRecorder\x12'\n\x06member\x18\x04\x20\x01\ + (\x0b2\r.medea.MemberH\0R\x06member\x12$\n\x05relay\x18\x05\x20\x01(\x0b\ + 2\x0c.medea.RelayH\0R\x05relay\x12!\n\x04room\x18\x06\x20\x01(\x0b2\x0b.\ + medea.RoomH\0R\x04room\x12<\n\x0bwebrtc_play\x18\x07\x20\x01(\x0b2\x19.m\ + edea.WebRtcPlayEndpointH\0R\nwebrtcPlay\x12=\n\nwebrtc_pub\x18\x08\x20\ + \x01(\x0b2\x1c.medea.WebRtcPublishEndpointH\0R\twebrtcPubB\x04\n\x02el\"\ + \xc4\x03\n\x0cApplyRequest\x12\x0e\n\x02id\x18\x01\x20\x01(\tR\x02id\x12\ + \x1e\n\x03hub\x18\x02\x20\x01(\x0b2\n.medea.HubH\0R\x03hub\x12:\n\rfile_\ + recorder\x18\x03\x20\x01(\x0b2\x13.medea.FileRecorderH\0R\x0cfileRecorde\ + r\x12'\n\x06member\x18\x04\x20\x01(\x0b2\r.medea.MemberH\0R\x06member\ + \x12$\n\x05relay\x18\x05\x20\x01(\x0b2\x0c.medea.RelayH\0R\x05relay\x12!\ + \n\x04room\x18\x06\x20\x01(\x0b2\x0b.medea.RoomH\0R\x04room\x12<\n\x0bwe\ + brtc_play\x18\x07\x20\x01(\x0b2\x19.medea.WebRtcPlayEndpointH\0R\nwebrtc\ + Play\x12=\n\nwebrtc_pub\x18\x08\x20\x01(\x0b2\x1c.medea.WebRtcPublishEnd\ + pointH\0R\twebrtcPub\x122\n\x06policy\x18\t\x20\x01(\x0e2\x1a.medea.Appl\ + yRequest.PolicyR\x06policy\"\x1f\n\x06Policy\x12\t\n\x05APPLY\x10\0\x12\ + \n\n\x06APPEND\x10\x01B\x04\n\x02el\"\x1b\n\tIdRequest\x12\x0e\n\x02id\ + \x18\x01\x20\x03(\tR\x02id\".\n\x08Response\x12\"\n\x05error\x18\x01\x20\ + \x01(\x0b2\x0c.medea.ErrorR\x05error\"\x9e\x01\n\x0eCreateResponse\x120\ + \n\x03sid\x18\x01\x20\x03(\x0b2\x1e.medea.CreateResponse.SidEntryR\x03si\ + d\x12\"\n\x05error\x18\x02\x20\x01(\x0b2\x0c.medea.ErrorR\x05error\x1a6\ + \n\x08SidEntry\x12\x10\n\x03key\x18\x01\x20\x01(\tR\x03key\x12\x14\n\x05\ + value\x18\x02\x20\x01(\tR\x05value:\x028\x01\"\xbc\x01\n\x0bGetResponse\ + \x12<\n\x08elements\x18\x01\x20\x03(\x0b2\x20.medea.GetResponse.Elements\ + EntryR\x08elements\x12\"\n\x05error\x18\x02\x20\x01(\x0b2\x0c.medea.Erro\ + rR\x05error\x1aK\n\rElementsEntry\x12\x10\n\x03key\x18\x01\x20\x01(\tR\ + \x03key\x12$\n\x05value\x18\x02\x20\x01(\x0b2\x0e.medea.ElementR\x05valu\ + e:\x028\x01\"[\n\x05Error\x12\x12\n\x04code\x18\x02\x20\x01(\rR\x04code\ + \x12\x12\n\x04text\x18\x03\x20\x01(\tR\x04text\x12\x10\n\x03doc\x18\x04\ + \x20\x01(\tR\x03doc\x12\x18\n\x07element\x18\x05\x20\x01(\tR\x07element\ + \"\xda\x02\n\x07Element\x12\x1e\n\x03hub\x18\x02\x20\x01(\x0b2\n.medea.H\ + ubH\0R\x03hub\x12:\n\rfile_recorder\x18\x03\x20\x01(\x0b2\x13.medea.File\ + RecorderH\0R\x0cfileRecorder\x12'\n\x06member\x18\x04\x20\x01(\x0b2\r.me\ + dea.MemberH\0R\x06member\x12$\n\x05relay\x18\x05\x20\x01(\x0b2\x0c.medea\ + .RelayH\0R\x05relay\x12!\n\x04room\x18\x06\x20\x01(\x0b2\x0b.medea.RoomH\ + \0R\x04room\x12<\n\x0bwebrtc_play\x18\x07\x20\x01(\x0b2\x19.medea.WebRtc\ + PlayEndpointH\0R\nwebrtcPlay\x12=\n\nwebrtc_pub\x18\x08\x20\x01(\x0b2\ + \x1c.medea.WebRtcPublishEndpointH\0R\twebrtcPubB\x04\n\x02el\"\xc9\x03\n\ + \x04Room\x125\n\x08pipeline\x18\x01\x20\x03(\x0b2\x19.medea.Room.Pipelin\ + eEntryR\x08pipeline\x1aP\n\rPipelineEntry\x12\x10\n\x03key\x18\x01\x20\ + \x01(\tR\x03key\x12)\n\x05value\x18\x02\x20\x01(\x0b2\x13.medea.Room.Ele\ + mentR\x05value:\x028\x01\x1a\xb7\x02\n\x07Element\x12\x1e\n\x03hub\x18\ + \x01\x20\x01(\x0b2\n.medea.HubH\0R\x03hub\x12:\n\rfile_recorder\x18\x02\ + \x20\x01(\x0b2\x13.medea.FileRecorderH\0R\x0cfileRecorder\x12'\n\x06memb\ + er\x18\x03\x20\x01(\x0b2\r.medea.MemberH\0R\x06member\x12$\n\x05relay\ + \x18\x04\x20\x01(\x0b2\x0c.medea.RelayH\0R\x05relay\x12<\n\x0bwebrtc_pla\ + y\x18\x05\x20\x01(\x0b2\x19.medea.WebRtcPlayEndpointH\0R\nwebrtcPlay\x12\ + =\n\nwebrtc_pub\x18\x06\x20\x01(\x0b2\x1c.medea.WebRtcPublishEndpointH\0\ + R\twebrtcPubB\x04\n\x02el\"\xfc\x03\n\x06Member\x12\x17\n\x07on_join\x18\ + \x01\x20\x01(\tR\x06onJoin\x12\x19\n\x08on_leave\x18\x02\x20\x01(\tR\x07\ + onLeave\x12\x20\n\x0bcredentials\x18\x03\x20\x01(\tR\x0bcredentials\x127\ + \n\x08pipeline\x18\x04\x20\x03(\x0b2\x1b.medea.Member.PipelineEntryR\x08\ + pipeline\x1aR\n\rPipelineEntry\x12\x10\n\x03key\x18\x01\x20\x01(\tR\x03k\ + ey\x12+\n\x05value\x18\x02\x20\x01(\x0b2\x15.medea.Member.ElementR\x05va\ + lue:\x028\x01\x1a\x8e\x02\n\x07Element\x12\x1e\n\x03hub\x18\x01\x20\x01(\ + \x0b2\n.medea.HubH\0R\x03hub\x12:\n\rfile_recorder\x18\x02\x20\x01(\x0b2\ + \x13.medea.FileRecorderH\0R\x0cfileRecorder\x12$\n\x05relay\x18\x03\x20\ + \x01(\x0b2\x0c.medea.RelayH\0R\x05relay\x12<\n\x0bwebrtc_play\x18\x04\ + \x20\x01(\x0b2\x19.medea.WebRtcPlayEndpointH\0R\nwebrtcPlay\x12=\n\nwebr\ + tc_pub\x18\x05\x20\x01(\x0b2\x1c.medea.WebRtcPublishEndpointH\0R\twebrtc\ + PubB\x04\n\x02el\"\xae\x01\n\x15WebRtcPublishEndpoint\x122\n\x03p2p\x18\ + \x01\x20\x01(\x0e2\x20.medea.WebRtcPublishEndpoint.P2PR\x03p2p\x12\x19\n\ + \x08on_start\x18\x03\x20\x01(\tR\x07onStart\x12\x17\n\x07on_stop\x18\x04\ + \x20\x01(\tR\x06onStop\"-\n\x03P2P\x12\t\n\x05NEVER\x10\0\x12\x0f\n\x0bI\ + F_POSSIBLE\x10\x01\x12\n\n\x06ALWAYS\x10\x02\"Z\n\x12WebRtcPlayEndpoint\ + \x12\x10\n\x03src\x18\x01\x20\x01(\tR\x03src\x12\x19\n\x08on_start\x18\ + \x02\x20\x01(\tR\x07onStart\x12\x17\n\x07on_stop\x18\x03\x20\x01(\tR\x06\ + onStop\"\x05\n\x03Hub\"f\n\x0cFileRecorder\x12\x10\n\x03src\x18\x01\x20\ + \x01(\tR\x03src\x12\x10\n\x03dst\x18\x02\x20\x01(\tR\x03dst\x12\x19\n\ + \x08on_start\x18\x03\x20\x01(\tR\x07onStart\x12\x17\n\x07on_stop\x18\x04\ + \x20\x01(\tR\x06onStop\"+\n\x05Relay\x12\x10\n\x03src\x18\x01\x20\x01(\t\ + R\x03src\x12\x10\n\x03dst\x18\x02\x20\x01(\tR\x03dst2\xcc\x01\n\nControl\ + Api\x125\n\x06Create\x12\x14.medea.CreateRequest\x1a\x15.medea.CreateRes\ + ponse\x12-\n\x05Apply\x12\x13.medea.ApplyRequest\x1a\x0f.medea.Response\ + \x12+\n\x06Delete\x12\x10.medea.IdRequest\x1a\x0f.medea.Response\x12+\n\ + \x03Get\x12\x10.medea.IdRequest\x1a\x12.medea.GetResponseb\x06proto3\ +"; + +static mut file_descriptor_proto_lazy: ::protobuf::lazy::Lazy<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::descriptor::FileDescriptorProto, +}; + +fn parse_descriptor_proto() -> ::protobuf::descriptor::FileDescriptorProto { + ::protobuf::parse_from_bytes(file_descriptor_proto_data).unwrap() +} + +pub fn file_descriptor_proto() -> &'static ::protobuf::descriptor::FileDescriptorProto { + unsafe { + file_descriptor_proto_lazy.get(|| { + parse_descriptor_proto() + }) + } +} diff --git a/proto/control-api/src/grpc/control_api_grpc.rs b/proto/control-api/src/grpc/control_api_grpc.rs new file mode 100644 index 000000000..7445b78ef --- /dev/null +++ b/proto/control-api/src/grpc/control_api_grpc.rs @@ -0,0 +1,155 @@ +// This file is generated. Do not edit +// @generated + +// https://github.com/Manishearth/rust-clippy/issues/702 +#![allow(unknown_lints)] +#![allow(clippy::all)] + +#![cfg_attr(rustfmt, rustfmt_skip)] + +#![allow(box_pointers)] +#![allow(dead_code)] +#![allow(missing_docs)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] +#![allow(non_upper_case_globals)] +#![allow(trivial_casts)] +#![allow(unsafe_code)] +#![allow(unused_imports)] +#![allow(unused_results)] + +const METHOD_CONTROL_API_CREATE: ::grpcio::Method = ::grpcio::Method { + ty: ::grpcio::MethodType::Unary, + name: "/medea.ControlApi/Create", + req_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, + resp_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, +}; + +const METHOD_CONTROL_API_APPLY: ::grpcio::Method = ::grpcio::Method { + ty: ::grpcio::MethodType::Unary, + name: "/medea.ControlApi/Apply", + req_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, + resp_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, +}; + +const METHOD_CONTROL_API_DELETE: ::grpcio::Method = ::grpcio::Method { + ty: ::grpcio::MethodType::Unary, + name: "/medea.ControlApi/Delete", + req_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, + resp_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, +}; + +const METHOD_CONTROL_API_GET: ::grpcio::Method = ::grpcio::Method { + ty: ::grpcio::MethodType::Unary, + name: "/medea.ControlApi/Get", + req_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, + resp_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, +}; + +#[derive(Clone)] +pub struct ControlApiClient { + client: ::grpcio::Client, +} + +impl ControlApiClient { + pub fn new(channel: ::grpcio::Channel) -> Self { + ControlApiClient { + client: ::grpcio::Client::new(channel), + } + } + + pub fn create_opt(&self, req: &super::control_api::CreateRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result { + self.client.unary_call(&METHOD_CONTROL_API_CREATE, req, opt) + } + + pub fn create(&self, req: &super::control_api::CreateRequest) -> ::grpcio::Result { + self.create_opt(req, ::grpcio::CallOption::default()) + } + + pub fn create_async_opt(&self, req: &super::control_api::CreateRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { + self.client.unary_call_async(&METHOD_CONTROL_API_CREATE, req, opt) + } + + pub fn create_async(&self, req: &super::control_api::CreateRequest) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { + self.create_async_opt(req, ::grpcio::CallOption::default()) + } + + pub fn apply_opt(&self, req: &super::control_api::ApplyRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result { + self.client.unary_call(&METHOD_CONTROL_API_APPLY, req, opt) + } + + pub fn apply(&self, req: &super::control_api::ApplyRequest) -> ::grpcio::Result { + self.apply_opt(req, ::grpcio::CallOption::default()) + } + + pub fn apply_async_opt(&self, req: &super::control_api::ApplyRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { + self.client.unary_call_async(&METHOD_CONTROL_API_APPLY, req, opt) + } + + pub fn apply_async(&self, req: &super::control_api::ApplyRequest) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { + self.apply_async_opt(req, ::grpcio::CallOption::default()) + } + + pub fn delete_opt(&self, req: &super::control_api::IdRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result { + self.client.unary_call(&METHOD_CONTROL_API_DELETE, req, opt) + } + + pub fn delete(&self, req: &super::control_api::IdRequest) -> ::grpcio::Result { + self.delete_opt(req, ::grpcio::CallOption::default()) + } + + pub fn delete_async_opt(&self, req: &super::control_api::IdRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { + self.client.unary_call_async(&METHOD_CONTROL_API_DELETE, req, opt) + } + + pub fn delete_async(&self, req: &super::control_api::IdRequest) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { + self.delete_async_opt(req, ::grpcio::CallOption::default()) + } + + pub fn get_opt(&self, req: &super::control_api::IdRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result { + self.client.unary_call(&METHOD_CONTROL_API_GET, req, opt) + } + + pub fn get(&self, req: &super::control_api::IdRequest) -> ::grpcio::Result { + self.get_opt(req, ::grpcio::CallOption::default()) + } + + pub fn get_async_opt(&self, req: &super::control_api::IdRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { + self.client.unary_call_async(&METHOD_CONTROL_API_GET, req, opt) + } + + pub fn get_async(&self, req: &super::control_api::IdRequest) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { + self.get_async_opt(req, ::grpcio::CallOption::default()) + } + pub fn spawn(&self, f: F) where F: ::futures::Future + Send + 'static { + self.client.spawn(f) + } +} + +pub trait ControlApi { + fn create(&mut self, ctx: ::grpcio::RpcContext, req: super::control_api::CreateRequest, sink: ::grpcio::UnarySink); + fn apply(&mut self, ctx: ::grpcio::RpcContext, req: super::control_api::ApplyRequest, sink: ::grpcio::UnarySink); + fn delete(&mut self, ctx: ::grpcio::RpcContext, req: super::control_api::IdRequest, sink: ::grpcio::UnarySink); + fn get(&mut self, ctx: ::grpcio::RpcContext, req: super::control_api::IdRequest, sink: ::grpcio::UnarySink); +} + +pub fn create_control_api(s: S) -> ::grpcio::Service { + let mut builder = ::grpcio::ServiceBuilder::new(); + let mut instance = s.clone(); + builder = builder.add_unary_handler(&METHOD_CONTROL_API_CREATE, move |ctx, req, resp| { + instance.create(ctx, req, resp) + }); + let mut instance = s.clone(); + builder = builder.add_unary_handler(&METHOD_CONTROL_API_APPLY, move |ctx, req, resp| { + instance.apply(ctx, req, resp) + }); + let mut instance = s.clone(); + builder = builder.add_unary_handler(&METHOD_CONTROL_API_DELETE, move |ctx, req, resp| { + instance.delete(ctx, req, resp) + }); + let mut instance = s; + builder = builder.add_unary_handler(&METHOD_CONTROL_API_GET, move |ctx, req, resp| { + instance.get(ctx, req, resp) + }); + builder.build() +} diff --git a/proto/control-api/src/grpc/mod.rs b/proto/control-api/src/grpc/mod.rs new file mode 100644 index 000000000..ba68b1e7c --- /dev/null +++ b/proto/control-api/src/grpc/mod.rs @@ -0,0 +1,9 @@ +#![allow( + bare_trait_objects, + clippy::cargo, + clippy::nursery, + clippy::pedantic, +)] + +pub mod control_api; +pub mod control_api_grpc; diff --git a/proto/control-api/src/lib.rs b/proto/control-api/src/lib.rs new file mode 100644 index 000000000..d79956bf5 --- /dev/null +++ b/proto/control-api/src/lib.rs @@ -0,0 +1,7 @@ +//! Generated [Medea]'s [Control API] specs. +//! +//! [Medea]: https://github.com/instrumentisto/medea +//! [Control API]: http://tiny.cc/380uaz + +#[cfg(feature = "grpc")] +pub mod grpc; diff --git a/proto/grpc/build.rs b/proto/grpc/build.rs deleted file mode 100644 index 12a2919b5..000000000 --- a/proto/grpc/build.rs +++ /dev/null @@ -1,22 +0,0 @@ -use std::{env, error::Error, fs::File, io::Write as _}; - -static CONTROL_API_MOD_RS: &[u8] = b" -/// Generated from protobuf. -pub mod control; -/// Generated from protobuf. -pub mod control_grpc; -"; - -fn main() -> Result<(), Box> { - let out_dir = env::var("OUT_DIR")?; - - protoc_grpcio::compile_grpc_protos( - &["proto/control.proto"], - &["proto"], - &out_dir, - None, - ) - .expect("Failed to compile gRPC definitions!"); - File::create(out_dir + "/mod.rs")?.write_all(CONTROL_API_MOD_RS)?; - Ok(()) -} diff --git a/proto/grpc/proto/control.proto b/proto/grpc/proto/control.proto deleted file mode 100644 index a52434715..000000000 --- a/proto/grpc/proto/control.proto +++ /dev/null @@ -1,140 +0,0 @@ -syntax = "proto3"; - -package medea; - -service ControlApi { - rpc Create (CreateRequest) returns (CreateResponse); - rpc Apply (ApplyRequest) returns (Response); - rpc Delete (IdRequest) returns (Response); - rpc Get (IdRequest) returns (GetResponse); -} -message CreateRequest { - string id = 1; - oneof el { - Hub hub = 2; - FileRecorder file_recorder = 3; - Member member = 4; - Relay relay = 5; - Room room = 6; - WebRtcPlayEndpoint webrtc_play = 7; - WebRtcPublishEndpoint webrtc_pub = 8; - } -} -message ApplyRequest { - string id = 1; - oneof el { - Hub hub = 2; - FileRecorder file_recorder = 3; - Member member = 4; - Relay relay = 5; - Room room = 6; - WebRtcPlayEndpoint webrtc_play = 7; - WebRtcPublishEndpoint webrtc_pub = 8; - } - Policy policy = 9; - - enum Policy { - APPLY = 0; - APPEND = 1; - } -} -message IdRequest { - repeated string id = 1; -} -message Response { - Error error = 1; -} -message CreateResponse { - map sid = 1; - Error error = 2; -} -message GetResponse { - map elements = 1; - Error error = 2; -} -message Error { - uint32 code = 2; - string text = 3; - string doc = 4; - string element = 5; -} - -message Element { - oneof el { - Hub hub = 2; - FileRecorder file_recorder = 3; - Member member = 4; - Relay relay = 5; - Room room = 6; - WebRtcPlayEndpoint webrtc_play = 7; - WebRtcPublishEndpoint webrtc_pub = 8; - } -} - -message Room { - map pipeline = 1; - - message Element { - oneof el { - Hub hub = 1; - FileRecorder file_recorder = 2; - Member member = 3; - Relay relay = 4; - WebRtcPlayEndpoint webrtc_play = 5; - WebRtcPublishEndpoint webrtc_pub = 6; - } - } -} - -message Member { - string on_join = 1; - string on_leave = 2; - string credentials = 3; - map pipeline = 4; - - message Element { - oneof el { - Hub hub = 1; - FileRecorder file_recorder = 2; - Relay relay = 3; - WebRtcPlayEndpoint webrtc_play = 4; - WebRtcPublishEndpoint webrtc_pub = 5; - } - } -} - -message WebRtcPublishEndpoint { - P2P p2p = 1; - string on_start = 3; - string on_stop = 4; - - enum P2P { - NEVER = 0; - IF_POSSIBLE = 1; - ALWAYS = 2; - } -} - -message WebRtcPlayEndpoint { - string src = 1; - string on_start = 2; - string on_stop = 3; -} - -message Hub {} - -message FileRecorder { - string src = 1; - // TODO: Delete if while implementing FileRecorder this field - // did not become useful. - string dst = 2; - string on_start = 3; - string on_stop = 4; -} - -message Relay { - string src = 1; - // TODO: Delete if while implementing Relay this field - // did not become useful. - string dst = 2; -} diff --git a/proto/grpc/src/lib.rs b/proto/grpc/src/lib.rs deleted file mode 100644 index c8ed4e7f7..000000000 --- a/proto/grpc/src/lib.rs +++ /dev/null @@ -1,11 +0,0 @@ -//! Generated [Medea]'s [Control API] specs. -//! -//! [Medea]: https://github.com/instrumentisto/medea -//! [Control API]: http://tiny.cc/380uaz - -#![allow(bare_trait_objects)] -#![allow(clippy::pedantic)] -#![allow(clippy::cargo)] -#![allow(clippy::nursery)] -#![allow(bare_trait_objects)] -include!(concat!(env!("OUT_DIR"), "/mod.rs")); diff --git a/src/api/control/endpoints/mod.rs b/src/api/control/endpoints/mod.rs index 80e3f20ce..d0da9946e 100644 --- a/src/api/control/endpoints/mod.rs +++ b/src/api/control/endpoints/mod.rs @@ -7,7 +7,7 @@ pub mod webrtc_publish_endpoint; use std::convert::TryFrom; -use medea_grpc_proto::control::{ +use medea_control_api_proto::grpc::control_api::{ CreateRequest, Member_Element as MemberElementProto, }; diff --git a/src/api/control/endpoints/webrtc_play_endpoint.rs b/src/api/control/endpoints/webrtc_play_endpoint.rs index bad4d0291..887c5a2ab 100644 --- a/src/api/control/endpoints/webrtc_play_endpoint.rs +++ b/src/api/control/endpoints/webrtc_play_endpoint.rs @@ -6,7 +6,8 @@ use std::{convert::TryFrom, fmt}; use derive_more::{Display, From}; use failure::Fail; -use medea_grpc_proto::control::WebRtcPlayEndpoint as WebRtcPlayEndpointProto; +use medea_control_api_proto::grpc as medea_grpc; +use medea_grpc::control_api::WebRtcPlayEndpoint as WebRtcPlayEndpointProto; use serde::{ de::{self, Deserializer, Error, Visitor}, Deserialize, @@ -14,7 +15,7 @@ use serde::{ use crate::api::control::{ endpoints::webrtc_publish_endpoint::WebRtcPublishId, - local_uri::{ToEndpoint, LocalUri, LocalUriParseError, StatefulLocalUri}, + local_uri::{LocalUri, LocalUriParseError, StatefulLocalUri, ToEndpoint}, MemberId, RoomId, TryFromProtobufError, }; diff --git a/src/api/control/endpoints/webrtc_publish_endpoint.rs b/src/api/control/endpoints/webrtc_publish_endpoint.rs index f48d93838..2e342eb8f 100644 --- a/src/api/control/endpoints/webrtc_publish_endpoint.rs +++ b/src/api/control/endpoints/webrtc_publish_endpoint.rs @@ -5,7 +5,7 @@ use derive_more::{Display, From}; use serde::Deserialize; -use medea_grpc_proto::control::{ +use medea_control_api_proto::grpc::control_api::{ WebRtcPublishEndpoint as WebRtcPublishEndpointProto, WebRtcPublishEndpoint_P2P as WebRtcPublishEndpointP2pProto, }; diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index 77ecaf66e..8b500d3d0 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -17,20 +17,20 @@ use grpcio::{ Environment, RpcContext, RpcStatus, RpcStatusCode, Server, ServerBuilder, UnarySink, }; -use medea_grpc_proto::{ - control::{ +use medea_control_api_proto::grpc::{ + control_api::{ ApplyRequest, CreateRequest, CreateResponse, Error, GetResponse, IdRequest, Response, }, - control_grpc::{create_control_api, ControlApi}, + control_api_grpc::{create_control_api, ControlApi}, }; use crate::{ api::{ control::{ local_uri::{ - ToEndpoint, ToMember, ToRoom, LocalUri, - LocalUriParseError, StatefulLocalUri, + LocalUri, LocalUriParseError, StatefulLocalUri, ToEndpoint, + ToMember, ToRoom, }, Endpoint, MemberId, MemberSpec, RoomId, RoomSpec, TryFromElementError, TryFromProtobufError, diff --git a/src/api/control/local_uri.rs b/src/api/control/local_uri.rs index bf647c335..9971d7eec 100644 --- a/src/api/control/local_uri.rs +++ b/src/api/control/local_uri.rs @@ -141,10 +141,7 @@ impl LocalUri { /// Push endpoint ID to the end of URI and returns /// [`LocalUri`] in [`ToEndpoint`] state. - pub fn push_endpoint_id( - self, - endpoint_id: String, - ) -> LocalUri { + pub fn push_endpoint_id(self, endpoint_id: String) -> LocalUri { let (member_id, room_uri) = self.take_member_id(); let room_id = room_uri.take_room_id(); LocalUri::::new(room_id, member_id, endpoint_id) diff --git a/src/api/control/member.rs b/src/api/control/member.rs index f30895e2d..5fd68c39d 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -5,7 +5,7 @@ use std::{collections::HashMap, convert::TryFrom}; use derive_more::{Display, From}; -use medea_grpc_proto::control::Member as MemberProto; +use medea_control_api_proto::grpc::control_api::Member as MemberProto; use rand::{distributions::Alphanumeric, Rng}; use serde::Deserialize; diff --git a/src/api/control/room.rs b/src/api/control/room.rs index e7a2a625c..d8f7c5f36 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -5,7 +5,7 @@ use std::{collections::HashMap, convert::TryFrom}; use derive_more::{Display, From}; -use medea_grpc_proto::control::Room as RoomProto; +use medea_control_api_proto::grpc::control_api::Room as RoomProto; use serde::Deserialize; use crate::api::control::TryFromProtobufError; diff --git a/src/api/error_codes.rs b/src/api/error_codes.rs index c1c425125..59d8e1ea4 100644 --- a/src/api/error_codes.rs +++ b/src/api/error_codes.rs @@ -1,17 +1,17 @@ //! All errors which medea can return to control API user. //! //! # Error codes ranges -//! - __1000...1000__ Unexpected server error -//! - __1001...1099__ Not found errors -//! - __1100...1199__ Spec errors -//! - __1200...1299__ Parse errors -//! - __1300...1399__ Conflicts -//! - __1400...1499__ Misc errors +//! - `1000` ... `1000` Unexpected server error +//! - `1001` ... `1099` Not found errors +//! - `1100` ... `1199` Spec errors +//! - `1200` ... `1299` Parse errors +//! - `1300` ... `1399` Conflicts +//! - `1400` ... `1499` Misc errors use std::string::ToString; use derive_more::Display; -use medea_grpc_proto::control::Error as ErrorProto; +use medea_control_api_proto::grpc::control_api::Error as ErrorProto; use crate::{ api::control::{ diff --git a/src/bin/client.rs b/src/bin/client.rs index 554fd1ecf..0a568dbb5 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -10,13 +10,13 @@ use std::{collections::HashMap, sync::Arc}; use grpcio::{ChannelBuilder, EnvBuilder}; -use medea_grpc_proto::{ - control::{ +use medea_control_api_proto::grpc::{ + control_api::{ ApplyRequest, CreateRequest, IdRequest, Member, Member_Element, Room, Room_Element, WebRtcPlayEndpoint, WebRtcPublishEndpoint, WebRtcPublishEndpoint_P2P, }, - control_grpc::ControlApiClient, + control_api_grpc::ControlApiClient, }; use protobuf::RepeatedField; diff --git a/src/conf/client_api_http.rs b/src/conf/client_api_http.rs index c43b19159..097a5c985 100644 --- a/src/conf/client_api_http.rs +++ b/src/conf/client_api_http.rs @@ -10,6 +10,7 @@ use smart_default::SmartDefault; /// [Client API]'s HTTP server settings. /// /// [Client API]: http://tiny.cc/c80uaz +#[allow(clippy::module_name_repetitions)] #[derive(Clone, Debug, Deserialize, Serialize, SmartDefault)] #[serde(default)] pub struct ClientApiHttpServer { @@ -69,10 +70,19 @@ mod server_spec { env::remove_var("MEDEA_SERVER.CLIENT.HTTP.BIND_IP"); env::remove_var("MEDEA_SERVER.CLIENT.HTTP.BIND_PORT"); - assert_ne!(default_conf.server.client.http.bind_ip, env_conf.server.client.http.bind_ip); - assert_ne!(default_conf.server.client.http.bind_port, env_conf.server.client.http.bind_port); + assert_ne!( + default_conf.server.client.http.bind_ip, + env_conf.server.client.http.bind_ip + ); + assert_ne!( + default_conf.server.client.http.bind_port, + env_conf.server.client.http.bind_port + ); - assert_eq!(env_conf.server.client.http.bind_ip, Ipv4Addr::new(5, 5, 5, 5)); + assert_eq!( + env_conf.server.client.http.bind_ip, + Ipv4Addr::new(5, 5, 5, 5) + ); assert_eq!(env_conf.server.client.http.bind_port, 1234); assert_eq!( env_conf.server.client.http.bind_addr(), diff --git a/src/conf/control_api.rs b/src/conf/control_api.rs index e572e8b42..bddd8bbba 100644 --- a/src/conf/control_api.rs +++ b/src/conf/control_api.rs @@ -8,6 +8,7 @@ use smart_default::SmartDefault; /// [Control API] settings. /// /// [Control API]: http://tiny.cc/380uaz +#[allow(clippy::module_name_repetitions)] #[derive(Clone, Debug, Deserialize, Serialize, SmartDefault)] #[serde(default)] pub struct ControlApi { diff --git a/src/conf/control_api_grpc.rs b/src/conf/control_api_grpc.rs index a1d730826..65e357d31 100644 --- a/src/conf/control_api_grpc.rs +++ b/src/conf/control_api_grpc.rs @@ -10,6 +10,7 @@ use smart_default::SmartDefault; /// [Control API] gRPC server settings. /// /// [Control API]: http://tiny.cc/380uaz +#[allow(clippy::module_name_repetitions)] #[derive(Clone, Debug, Deserialize, Serialize, SmartDefault)] #[serde(default)] pub struct ControlApiGrpcServer { diff --git a/src/conf/server.rs b/src/conf/server.rs index 24fde0e77..0a507c43c 100644 --- a/src/conf/server.rs +++ b/src/conf/server.rs @@ -1,3 +1,5 @@ +//! Settings for application servers. + use serde::{Deserialize, Serialize}; use smart_default::SmartDefault; @@ -6,6 +8,10 @@ use super::{ control_api_grpc::ControlApiGrpcServer, }; +/// [Client API] servers settings. +/// +/// [Client API]: http://tiny.cc/c80uaz +#[allow(clippy::module_name_repetitions)] #[derive(Clone, Debug, Deserialize, Serialize, SmartDefault)] #[serde(default)] pub struct ClientApiServer { @@ -15,6 +21,10 @@ pub struct ClientApiServer { pub http: ClientApiHttpServer, } +/// [Control API] servers settings. +/// +/// [Control API]: http://tiny.cc/380uaz +#[allow(clippy::module_name_repetitions)] #[derive(Clone, Debug, Deserialize, Serialize, SmartDefault)] #[serde(default)] pub struct ControlApiServer { @@ -24,10 +34,17 @@ pub struct ControlApiServer { pub grpc: ControlApiGrpcServer, } +/// Settings for application servers. #[derive(Clone, Debug, Deserialize, Serialize, SmartDefault)] #[serde(default)] pub struct Server { + /// [Client API] servers settings. + /// + /// [Client API]: http://tiny.cc/c80uaz pub client: ClientApiServer, + /// [Control API] servers settings. + /// + /// [Control API]: http://tiny.cc/380uaz pub control: ControlApiServer, } diff --git a/src/signalling/elements/endpoints/mod.rs b/src/signalling/elements/endpoints/mod.rs index b0d0d6be8..ec74635b1 100644 --- a/src/signalling/elements/endpoints/mod.rs +++ b/src/signalling/elements/endpoints/mod.rs @@ -5,7 +5,7 @@ pub mod webrtc; use derive_more::From; -use medea_grpc_proto::control::Element as RootElementProto; +use medea_control_api_proto::grpc::control_api::Element as RootElementProto; /// Enum which can store all kinds of [medea] endpoints. /// diff --git a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs index 56ea002dd..6d605d1ea 100644 --- a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs @@ -6,7 +6,7 @@ use std::{ }; use medea_client_api_proto::PeerId; -use medea_grpc_proto::control::{ +use medea_control_api_proto::grpc::control_api::{ Element as RootElementProto, Member_Element as ElementProto, WebRtcPlayEndpoint as WebRtcPlayEndpointProto, }; diff --git a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs index 869aedd21..dfe3e5ad2 100644 --- a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs @@ -7,7 +7,7 @@ use std::{ }; use medea_client_api_proto::PeerId; -use medea_grpc_proto::control::{ +use medea_control_api_proto::grpc::control_api::{ Element as RootElementProto, Member_Element as ElementProto, WebRtcPublishEndpoint as WebRtcPublishEndpointProto, }; diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index aa352065b..60c3d4f62 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -12,7 +12,7 @@ use std::{ use derive_more::Display; use failure::Fail; use medea_client_api_proto::{IceServer, PeerId}; -use medea_grpc_proto::control::{ +use medea_control_api_proto::grpc::control_api::{ Element as RootElementProto, Member as MemberProto, Room_Element as ElementProto, }; @@ -20,9 +20,7 @@ use medea_grpc_proto::control::{ use crate::{ api::control::{ endpoints::WebRtcPlayEndpoint as WebRtcPlayEndpointSpec, - local_uri::{ - ToEndpoint, ToMember, ToRoom, LocalUri, StatefulLocalUri, - }, + local_uri::{LocalUri, StatefulLocalUri, ToEndpoint, ToMember, ToRoom}, MemberId, MemberSpec, RoomId, RoomSpec, TryFromElementError, WebRtcPlayId, WebRtcPublishId, }, @@ -129,9 +127,10 @@ impl Member { member_id: &MemberId, ) -> Result { let element = room_spec.pipeline.get(&member_id.0).map_or( - Err(MembersLoadError::MemberNotFound( - LocalUri::::new(self.room_id(), member_id.clone()), - )), + Err(MembersLoadError::MemberNotFound(LocalUri::::new( + self.room_id(), + member_id.clone(), + ))), Ok, )?; @@ -166,12 +165,10 @@ impl Member { MemberId(spec_play_endpoint.src.member_id.to_string()); let publisher_member = store.get(&publisher_id).ok_or_else(|| { - MembersLoadError::MemberNotFound( - LocalUri::::new( - self.room_id(), - publisher_id, - ), - ) + MembersLoadError::MemberNotFound(LocalUri::::new( + self.room_id(), + publisher_id, + )) })?; let publisher_spec = self.get_member_from_room_spec( room_spec, diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index cc8108e69..308d01cdc 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -32,7 +32,7 @@ use crate::{ WebRtcPlayEndpoint as WebRtcPlayEndpointSpec, WebRtcPublishEndpoint as WebRtcPublishEndpointSpec, }, - local_uri::{ToEndpoint, ToMember, LocalUri}, + local_uri::{LocalUri, ToEndpoint, ToMember}, MemberId, MemberSpec, RoomId, RoomSpec, WebRtcPlayId, WebRtcPublishId, }, diff --git a/src/signalling/room.rs b/src/signalling/room.rs index da13fc961..d55a4d059 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -13,7 +13,9 @@ use derive_more::Display; use failure::Fail; use futures::future; use medea_client_api_proto::{Command, Event, IceCandidate, PeerId, TrackId}; -use medea_grpc_proto::control::{Element as ElementProto, Room as RoomProto}; +use medea_control_api_proto::grpc::control_api::{ + Element as ElementProto, Room as RoomProto, +}; use crate::{ api::{ @@ -22,7 +24,7 @@ use crate::{ RpcConnectionClosed, RpcConnectionEstablished, }, control::{ - local_uri::{ToMember, LocalUri, StatefulLocalUri}, + local_uri::{LocalUri, StatefulLocalUri, ToMember}, room::RoomSpec, Endpoint as EndpointSpec, MemberId, MemberSpec, RoomId, TryFromElementError, WebRtcPlayId, WebRtcPublishId, diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index df9b7e4fe..c988cd591 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -9,15 +9,13 @@ use actix::{ use derive_more::Display; use failure::Fail; use futures::future::{self, Either, Future}; -use medea_grpc_proto::control::Element as ElementProto; +use medea_control_api_proto::grpc::control_api::Element as ElementProto; use crate::{ api::control::{ endpoints::Endpoint as EndpointSpec, load_static_specs_from_dir, - local_uri::{ - ToEndpoint, ToMember, ToRoom, LocalUri, StatefulLocalUri, - }, + local_uri::{LocalUri, StatefulLocalUri, ToEndpoint, ToMember, ToRoom}, LoadStaticControlSpecsError, MemberSpec, RoomId, RoomSpec, }, log::prelude::*, From 71b61a49d3c1f89f901be04a777fd7e4d71600e9 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 12 Sep 2019 16:30:23 +0300 Subject: [PATCH 630/735] Fix CI [run ci] --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index c92a541da..e6706e357 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,6 @@ language: rust cache: cargo install: - - bash _ci/protoc_install.sh - rustc -vV - cargo -vV @@ -34,7 +33,6 @@ jobs: stage: check rust: nightly cache: false - env: DONT_INSTALL_PROTOC=1 before_script: rustup component add rustfmt script: make fmt check=yes From 23ab751ccaa41bf0b653ae8a3607dd6589efdd12 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 12 Sep 2019 17:31:38 +0300 Subject: [PATCH 631/735] Final reread [run ci] --- .dockerignore | 5 ----- Dockerfile | 2 +- Makefile | 2 +- .../templates/deployment.server.yaml | 6 +++--- proto/control-api/CHANGELOG.md | 4 ++-- proto/control-api/build.rs | 2 +- proto/control-api/src/grpc/control_api.proto | 19 ++++++++++++------- src/api/client/session.rs | 2 +- src/api/control/grpc/server.rs | 2 +- src/api/control/mod.rs | 10 +++++----- src/signalling/elements/member.rs | 6 +++--- src/signalling/participants.rs | 2 +- src/signalling/room.rs | 16 +++++++++++----- src/signalling/room_service.rs | 16 ++++++++++------ tests/e2e/signalling/mod.rs | 10 +++++----- 15 files changed, 57 insertions(+), 47 deletions(-) diff --git a/.dockerignore b/.dockerignore index b9c5b1895..048f7761d 100644 --- a/.dockerignore +++ b/.dockerignore @@ -17,9 +17,4 @@ # Medea dependencies cache. !.cache/cargo/ -# Here we have some scripts which install missing toolchains for CI -# but it usable for Docker images also. -!_ci - # !target/{mode} is added and removed dynamically to reduce image build times. -!target/debug/ diff --git a/Dockerfile b/Dockerfile index 6a659f6a4..5b7d7424e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,7 @@ # https://hub.docker.com/_/rust ARG rust_ver=latest -FROM rust:${rust_ver} as dist +FROM rust:${rust_ver} AS dist ARG rustc_mode=release ARG rustc_opts=--release ARG cargo_home=/usr/local/cargo diff --git a/Makefile b/Makefile index 5ddf99af9..249d2ed0f 100644 --- a/Makefile +++ b/Makefile @@ -184,7 +184,7 @@ ifeq ($(dockerized),yes) docker run --rm -v "$(PWD)":/app -w /app \ -u $(shell id -u):$(shell id -g) \ -v "$(HOME)/.cargo/registry":/usr/local/cargo/registry \ - medea-build \ + rust:$(RUST_VER) \ make cargo.build crate=$(cargo-build-crate) \ debug=$(debug) dockerized=no else diff --git a/jason/demo/chart/medea-demo/templates/deployment.server.yaml b/jason/demo/chart/medea-demo/templates/deployment.server.yaml index 5996cbcab..3d3b9266c 100644 --- a/jason/demo/chart/medea-demo/templates/deployment.server.yaml +++ b/jason/demo/chart/medea-demo/templates/deployment.server.yaml @@ -71,7 +71,7 @@ spec: name: {{ template "medea-demo.fullname" . }}.server.cred ports: - name: http - containerPort: {{ .Values.server.conf.client.bind_port }} + containerPort: {{ .Values.server.conf.server.client.http.bind_port }} volumeMounts: - name: conf subPath: medea.toml @@ -82,11 +82,11 @@ spec: {{- end }} livenessProbe: tcpSocket: - port: {{ .Values.server.conf.client.bind_port }} + port: {{ .Values.server.conf.server.client.http.bind_port }} initialDelaySeconds: 3 readinessProbe: tcpSocket: - port: {{ .Values.server.conf.client.bind_port }} + port: {{ .Values.server.conf.server.client.http.bind_port }} initialDelaySeconds: 5 - name: coturn image: "{{ $coturn.image.repository }}:{{ $coturn.image.tag }}" diff --git a/proto/control-api/CHANGELOG.md b/proto/control-api/CHANGELOG.md index e3d794180..0342c97eb 100644 --- a/proto/control-api/CHANGELOG.md +++ b/proto/control-api/CHANGELOG.md @@ -1,4 +1,4 @@ -`medea-control-api` changelog +`medea-control-api-proto` changelog ================================== All user visible changes to this project will be documented in this file. This project uses [Semantic Versioning 2.0.0]. @@ -7,7 +7,7 @@ All user visible changes to this project will be documented in this file. This p ## TBD [0.1.0] · 2019-??-?? -[0.1.0]: /../../tree/medea-grpc-proto-0.1.0/proto/grpc +[0.1.0]: /../../tree/medea-control-api-proto-0.1.0/proto/control-api [Milestone](/../../milestone/2) | [Roadmap](/../../issues/27) diff --git a/proto/control-api/build.rs b/proto/control-api/build.rs index 2bf467587..e1b6488db 100644 --- a/proto/control-api/build.rs +++ b/proto/control-api/build.rs @@ -2,7 +2,7 @@ use std::{error::Error, fs::File, io::ErrorKind}; #[cfg(feature = "grpc")] fn main() -> Result<(), Box> { - const GRPC_DIR: &str = "src/grpc"; + const GRPC_DIR: &str = "src/grpc/"; const GRPC_SPEC_FILE: &str = "src/grpc/control_api.proto"; const OUT_FILES: [&str; 2] = ["src/grpc/control_api.rs", "src/grpc/control_api_grpc.rs"]; diff --git a/proto/control-api/src/grpc/control_api.proto b/proto/control-api/src/grpc/control_api.proto index 22c255538..ba7c666e0 100644 --- a/proto/control-api/src/grpc/control_api.proto +++ b/proto/control-api/src/grpc/control_api.proto @@ -53,7 +53,7 @@ message CreateRequest { // Idempotent. If no Element with such ID exists, // then it will be created, otherwise it will be reconfigured. message ApplyRequest { - // ID of Control API element which you want to update. + // ID of Control API element which you want update. string id = 1; // Control API element spec to which this element should be updated. oneof el { @@ -75,14 +75,14 @@ message ApplyRequest { APPLY = 0; // Elements that exists, but are not // specified in provided pipeline - // not will be removed. + // NOT will be removed. APPEND = 1; } } -// Request with many IDs. +// Request with many elements IDs. message IdRequest { - // Vector of IDs. + // Vector of elements IDs. repeated string id = 1; } @@ -135,10 +135,15 @@ message Error { uint32 code = 2; // Human-readable text description of error. string text = 3; - // Optional. // Link to online documentation of error. + // + // Optional field. string doc = 4; // Full ID of Element that error is related to. + // Some error doesn't relates to element ID and + // in this case element can be empty. + // + // Optional field. string element = 5; } @@ -160,7 +165,7 @@ message Room { // Pipeline of Room element. map pipeline = 1; - // Elements which can contain Room's pipeline. + // Elements which Room's pipeline can contain. message Element { oneof el { Hub hub = 1; @@ -188,7 +193,7 @@ message Member { // Pipeline of Member element. map pipeline = 4; - // Elements which can contain Member's pipeline. + // Elements which Member's pipeline can contain. message Element { oneof el { Hub hub = 1; diff --git a/src/api/client/session.rs b/src/api/client/session.rs index faca856d5..465c700bc 100644 --- a/src/api/client/session.rs +++ b/src/api/client/session.rs @@ -101,7 +101,7 @@ impl Actor for WsSession { /// Starts [`Heartbeat`] mechanism and sends [`RpcConnectionEstablished`] /// signal to the [`Room`]. fn started(&mut self, ctx: &mut Self::Context) { - debug!("Started WsSession for member {}", self.member_id); + debug!("Started WsSession for Member [id = {}]", self.member_id); self.start_watchdog(ctx); diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index 8b500d3d0..93339755e 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -209,7 +209,7 @@ impl ControlApiService { req.get_room() )); - let sid: HashMap = fut_try!(spec.members()) + let sid: Sids = fut_try!(spec.members()) .iter() .map(|(id, member)| { let uri = diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index cacdafc52..ce84d4020 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -76,14 +76,14 @@ pub enum RootElement { /// /// [`TryFrom`]: std::convert::TryFrom #[allow(clippy::pub_enum_variant_names)] -#[derive(Debug, Fail, Clone)] +#[derive(Clone, Debug, Display, Fail)] pub enum TryFromElementError { /// Element is not `Room`. - #[fail(display = "Element is not Room")] + #[display(fmt = "Element is not Room")] NotRoom, /// Element is not `Member`. - #[fail(display = "Element is not Member")] + #[display(fmt = "Element is not Member")] NotMember, } @@ -94,8 +94,8 @@ pub enum TryFromElementError { #[derive(Debug, Fail, Display)] pub enum LoadStaticControlSpecsError { /// Error while reading default or provided in config - /// (`MEDEA_CONTROL.STATIC_SPECS_DIR` environment variable) static [Control - /// API] specs dir. + /// (`MEDEA_CONTROL_API.STATIC_SPECS_DIR` environment variable) static + /// [Control API] specs dir. /// /// Atm we only should print `warn!` message to log which prints that /// static specs not loaded. diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index 60c3d4f62..fc6199ba6 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -402,7 +402,7 @@ impl Member { self.0.borrow().room_id.clone() } - /// Create new [`WebRtcPlayEndpoint`] based on provided + /// Creates new [`WebRtcPlayEndpoint`] based on provided /// [`WebRtcPlayEndpointSpec`]. /// /// This function will add created [`WebRtcPlayEndpoint`] to src's @@ -464,14 +464,14 @@ impl Member { pub struct WeakMember(Weak>); impl WeakMember { - /// Upgrade weak pointer to strong pointer. + /// Upgrades weak pointer to strong pointer. /// /// This function will __panic__ if weak pointer was dropped. pub fn upgrade(&self) -> Member { Member(Weak::upgrade(&self.0).unwrap()) } - /// Safe upgrade to [`Member`]. + /// Safe upgrades to [`Member`]. pub fn safe_upgrade(&self) -> Option { Weak::upgrade(&self.0).map(Member) } diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 308d01cdc..84dc4e3c2 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -184,7 +184,7 @@ impl ParticipantService { /// [`MemberId`] failed. /// /// Returns [`Err(AuthorizationError::InvalidCredentials)`] if [`Member`] - /// was found, but incorrect credentials was provided. + /// was found, but incorrect credentials were provided. pub fn get_member_by_id_and_credentials( &self, member_id: &MemberId, diff --git a/src/signalling/room.rs b/src/signalling/room.rs index d55a4d059..720fc1132 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -147,7 +147,7 @@ pub struct Room { } impl Room { - /// Create new instance of [`Room`]. + /// Creates new instance of [`Room`]. /// /// Returns [`RoomError::BadRoomSpec`] when errs while `Element` /// transformation happens. @@ -527,13 +527,16 @@ impl Room { member_id: MemberId, ctx: &mut Context, ) -> ActFuture<(), ()> { - info!("Peers {:?} removed for member '{}'.", peers_id, member_id); + info!( + "Peers {:?} removed for member [id = {}].", + peers_id, member_id + ); if let Some(member) = self.members.get_member_by_id(&member_id) { member.peers_removed(&peers_id); } else { error!( - "Participant with id {} for which received \ - Event::PeersRemoved not found. Closing room.", + "Member [id = {}] for which received Event::PeersRemoved not \ + found. Closing room.", member_id ); @@ -812,7 +815,10 @@ impl Handler for Room { msg: RpcConnectionEstablished, ctx: &mut Self::Context, ) -> Self::Result { - info!("RpcConnectionEstablished for member {}", msg.member_id); + info!( + "RpcConnectionEstablished for Member [id = {}].", + msg.member_id + ); let fut = self .members diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index c988cd591..0e2e52893 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -256,10 +256,10 @@ pub struct Validated; pub struct Unvalidated; // Clippy lint show use_self errors for DeleteElements with generic state. This -// is fix for it. +// is fix for it. This allow not works on function. #[allow(clippy::use_self)] impl DeleteElements { - pub fn new() -> DeleteElements { + pub fn new() -> Self { Self { uris: Vec::new(), _validation_state: PhantomData, @@ -319,6 +319,10 @@ impl DeleteElements { /// from [`Unvalidated`] with [`DeleteElements::validate`] function /// which will validate all [`StatefulLocalUri`]s. /// +/// Validation doesn't guarantee that message can't return [`RoomServiceError`]. +/// This is just validation for errors which we can catch before sending +/// message. +/// /// [Control API]: http://tiny.cc/380uaz #[derive(Message, Default)] #[rtype(result = "Result<(), RoomServiceError>")] @@ -330,9 +334,9 @@ pub struct DeleteElements { impl Handler> for RoomService { type Result = ActFuture<(), RoomServiceError>; - // TODO: delete this allow when drain_filter TODO will be resolved. - #[allow(clippy::unnecessary_filter_map)] - #[allow(clippy::if_not_else)] + // TODO: delete 'clippy::unnecessary_filter_map` when drain_filter TODO will + // be resolved. + #[allow(clippy::if_not_else, clippy::unnecessary_filter_map)] fn handle( &mut self, msg: DeleteElements, @@ -495,7 +499,7 @@ impl Handler for RoomService { fn handle( &mut self, msg: CreateEndpointInRoom, - _ctx: &mut Self::Context, + _: &mut Self::Context, ) -> Self::Result { let (endpoint_id, member_uri) = msg.uri.take_endpoint_id(); let (member_id, room_uri) = member_uri.take_member_id(); diff --git a/tests/e2e/signalling/mod.rs b/tests/e2e/signalling/mod.rs index e4c8b2ee7..91f9e50da 100644 --- a/tests/e2e/signalling/mod.rs +++ b/tests/e2e/signalling/mod.rs @@ -53,14 +53,14 @@ impl TestMember { }); } - /// Send command to the server. + /// Sends command to the server. fn send_command(&mut self, msg: Command) { let json = serde_json::to_string(&msg).unwrap(); self.writer.start_send(ws::Message::Text(json)).unwrap(); self.writer.poll_complete().unwrap(); } - /// Start test member in new [`Arbiter`] by given URI. + /// Starts test member in new [`Arbiter`] by given URI. /// `on_message` - is function which will be called at every [`Event`] /// received from server. pub fn start( @@ -92,9 +92,9 @@ impl TestMember { impl Actor for TestMember { type Context = Context; - /// Start heartbeat and set a timer that will panic when 5 seconds expire. - /// The timer is needed because some tests may just stuck - /// and listen socket forever. + /// Starts heartbeat and sets a timer that will panic when 5 seconds will + /// expire. The timer is needed because some tests may just stuck and listen + /// socket forever. fn started(&mut self, ctx: &mut Self::Context) { self.start_heartbeat(ctx); From 5f00db0dddff1f0c0a253063e4d04631b0bc6ca6 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 12 Sep 2019 18:54:06 +0300 Subject: [PATCH 632/735] Fix tests in CI [run ci] --- docker-compose.medea.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.medea.yml b/docker-compose.medea.yml index fbedf30f0..b305ce42e 100644 --- a/docker-compose.medea.yml +++ b/docker-compose.medea.yml @@ -7,7 +7,7 @@ services: environment: RUST_LOG: ${RUST_LOG} MEDEA_CONF: ${MEDEA_CONF} - "MEDEA_CONTROL.STATIC_SPECS_DIR": ${MEDEA_CONTROL_API_STATIC_SPECS_DIR} + "MEDEA_CONTROL_API.STATIC_SPECS_DIR": ${MEDEA_CONTROL_API_STATIC_SPECS_DIR} ports: - "8080:8080" volumes: From 05dba39a23f302fe7f1f0610b9285d5436ff3aaa Mon Sep 17 00:00:00 2001 From: alexlapa Date: Sun, 15 Sep 2019 21:36:05 +0300 Subject: [PATCH 633/735] add todos, minor refactor [run ci] --- Cargo.lock | 48 ++++++++++++++++---------------- Cargo.toml | 2 +- proto/control-api/README.md | 2 +- src/api/control/endpoints/mod.rs | 4 +-- src/api/control/local_uri.rs | 8 +++--- src/conf/client_api_http.rs | 1 + src/conf/control_api_grpc.rs | 1 + src/conf/rpc.rs | 1 + src/main.rs | 1 + 9 files changed, 36 insertions(+), 32 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d662fa167..9cd0ce753 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -14,7 +14,7 @@ name = "actix" version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "actix-http 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-http 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "actix-rt 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "actix_derive 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -57,7 +57,7 @@ dependencies = [ "actix-service 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "actix-utils 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", - "either 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "http 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -68,7 +68,7 @@ dependencies = [ [[package]] name = "actix-http" -version = "0.2.9" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -84,7 +84,7 @@ dependencies = [ "chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", "copyless 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", - "either 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "encoding_rs 0.8.19 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "flate2 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", @@ -99,7 +99,7 @@ dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "mime 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", "percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.100 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", @@ -123,7 +123,7 @@ dependencies = [ "actix-server 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "actix-service 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "actix-utils 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "awc 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "awc 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -229,7 +229,7 @@ dependencies = [ "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "actix-service 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "either 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-current-thread 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -242,7 +242,7 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-http 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-http 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "actix-router 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "actix-rt 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "actix-server 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -251,7 +251,7 @@ dependencies = [ "actix-threadpool 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "actix-utils 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "actix-web-codegen 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "awc 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "awc 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", "encoding_rs 0.8.19 (registry+https://github.com/rust-lang/crates.io-index)", @@ -276,7 +276,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "actix 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)", "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-http 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-http 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "actix-web 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", @@ -358,11 +358,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "awc" -version = "0.2.4" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-http 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-http 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "actix-service 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -371,7 +371,7 @@ dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "mime 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", "percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.100 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "serde_urlencoded 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -532,7 +532,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "ascii 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "either 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -700,7 +700,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "either" -version = "1.5.2" +version = "1.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1076,11 +1076,11 @@ version = "0.2.0-dev" dependencies = [ "actix 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)", "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-http 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-http 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "actix-http-test 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "actix-web 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", "actix-web-actors 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "awc 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "awc 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "bb8 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "bb8-redis 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1096,7 +1096,7 @@ dependencies = [ "medea-control-api-proto 0.1.0-dev", "medea-macro 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "redis 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.100 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1531,7 +1531,7 @@ dependencies = [ [[package]] name = "rand" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "getrandom 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2103,7 +2103,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", "remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2691,7 +2691,7 @@ dependencies = [ "checksum actix 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)" = "671ce3d27313f236827a5dd153a1073ad03ef31fc77f562020263e7830cf1ef7" "checksum actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9f2c11af4b06dc935d8e1b1491dad56bfb32febc49096a91e773f8535c176453" "checksum actix-connect 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "9fade9bd4bb46bacde89f1e726c7a3dd230536092712f5d94d77ca57c087fca0" -"checksum actix-http 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)" = "de5aaeef8b9eef653b910f957a02bea9c1b375f7fa49b411fb75dad8f41462eb" +"checksum actix-http 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "cdf758ebbc4abfecbdc1ce7408601b2d7e0cd7e4766ef61183cd8ce16c194d64" "checksum actix-http-test 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "beafa31d71c8fa8204ede1602a3dd221e5cf30ff354180f8ee87274ab81cf607" "checksum actix-router 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "23224bb527e204261d0291102cb9b52713084def67d94f7874923baefe04ccf7" "checksum actix-rt 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "168620aaf00fcd2a16e621790abaf180ef7377c2f8355b4ca5775d6afc778ed8" @@ -2713,7 +2713,7 @@ dependencies = [ "checksum ascii 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "eab1c04a571841102f5345a8fc0f6bb3d31c315dec879b5c6e42e40ce7ffa34e" "checksum atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1803c647a3ec87095e7ae7acfca019e98de5ec9a7d01343f611cf3152ed71a90" "checksum autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "b671c8fb71b457dd4ae18c4ba1e59aa81793daacc361d82fcd410cef0d491875" -"checksum awc 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "96ff50f02103155c49ced9711b00198f6dacefceb234ece4fcaa4f7ad270e1d5" +"checksum awc 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "78c9c1e32d6084343b3857eacb1f43aaefb93a816e15aae4685bc3c0a9052964" "checksum backtrace 0.3.37 (registry+https://github.com/rust-lang/crates.io-index)" = "5180c5a20655b14a819b652fd2378fa5f1697b6c9ddad3e695c2f9cedf6df4e2" "checksum backtrace-sys 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)" = "82a830b4ef2d1124a711c71d263c5abdc710ef8e907bd508c88be475cebc422b" "checksum base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" @@ -2750,7 +2750,7 @@ dependencies = [ "checksum dirs 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3fd78930633bd1c6e35c4b42b1df7b0cbc6bc191146e512bb3bedf243fcc3901" "checksum dotenv 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4424bad868b0ffe6ae351ee463526ba625bbca817978293bbe6bb7dc1804a175" "checksum dtoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "ea57b42383d091c85abcc2706240b94ab2a8fa1fc81c10ff23c4de06e2a90b5e" -"checksum either 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5527cfe0d098f36e3f8839852688e63c8fff1c90b2b405aef730615f9a7bcf7b" +"checksum either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3" "checksum encoding_rs 0.8.19 (registry+https://github.com/rust-lang/crates.io-index)" = "79906e1ad1f7f8bc48864fcc6ffd58336fb5992e627bf61928099cb25fdf4314" "checksum enum-as-inner 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3d58266c97445680766be408285e798d3401c6d4c378ec5552e78737e681e37d" "checksum env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "aafcde04e90a5226a6443b7aabdb016ba2f8307c847d524724bd9b346dd1a2d3" @@ -2838,7 +2838,7 @@ dependencies = [ "checksum rand 0.3.23 (registry+https://github.com/rust-lang/crates.io-index)" = "64ac302d8f83c0c1974bf758f6b041c6c8ada916fbb44a609158ca8b064cc76c" "checksum rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" "checksum rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" -"checksum rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d47eab0e83d9693d40f825f86948aa16eff6750ead4bdffc4ab95b8b3a7f052c" +"checksum rand 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "59cea0d944b32347a1863e95942fd6ebdb486afb4f038119494f2860380c1d51" "checksum rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" "checksum rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "03a2a90da8c7523f554344f921aa97283eadf6ac484a6d2a7d0212fa7f8d6853" "checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" diff --git a/Cargo.toml b/Cargo.toml index 8063a62b1..bdc12a608 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,7 +37,7 @@ derive_more = "0.15" failure = "0.1" futures = "0.1" grpcio = { version = "0.4", features = ["openssl"] } -humantime = "1.2" +humantime = "1.3" humantime-serde = "0.1" medea-client-api-proto = { path = "proto/client-api", features = ["medea"] } medea-control-api-proto = { path = "proto/control-api" } diff --git a/proto/control-api/README.md b/proto/control-api/README.md index c8e9a04d1..3a2caee60 100644 --- a/proto/control-api/README.md +++ b/proto/control-api/README.md @@ -6,7 +6,7 @@ Medea Control API protocol [Changelog](https://github.com/instrumentisto/medea/blob/master/proto/control-api/CHANGELOG.md) -Client API protocol implementation for [Medea] media server. +Control API protocol implementation for [Medea] media server. __Currently, in early development phase.__ diff --git a/src/api/control/endpoints/mod.rs b/src/api/control/endpoints/mod.rs index d0da9946e..7e0b7992e 100644 --- a/src/api/control/endpoints/mod.rs +++ b/src/api/control/endpoints/mod.rs @@ -56,8 +56,8 @@ macro_rules! impl_try_from_proto_for_endpoint { WebRtcPublishEndpoint::from(proto.get_webrtc_pub()); Ok(Endpoint::WebRtcPublish(publish)) } else { - // TODO implement another endpoints when they will be - // implemented + // TODO: implement another endpoints when they will be + // implemented unimplemented!() } } diff --git a/src/api/control/local_uri.rs b/src/api/control/local_uri.rs index 9971d7eec..83fb78d7b 100644 --- a/src/api/control/local_uri.rs +++ b/src/api/control/local_uri.rs @@ -427,24 +427,24 @@ mod tests { #[test] fn properly_serialize() { - for local_uri_str in vec![ + for local_uri_str in &[ "local://room_id", "local://room_id/member_id", "local://room_id/member_id/endpoint_id", ] { - let local_uri = StatefulLocalUri::try_from(local_uri_str).unwrap(); + let local_uri = StatefulLocalUri::try_from(*local_uri_str).unwrap(); assert_eq!(local_uri_str.to_string(), local_uri.to_string()); } } #[test] fn return_error_when_local_uri_not_full() { - for local_uri_str in vec![ + for local_uri_str in &[ "local://room_id//endpoint_id", "local:////endpoint_id", "local:///member_id/endpoint_id", ] { - match StatefulLocalUri::try_from(local_uri_str) { + match StatefulLocalUri::try_from(*local_uri_str) { Ok(_) => unreachable!(local_uri_str), Err(e) => match e { LocalUriParseError::MissingPaths(_) => (), diff --git a/src/conf/client_api_http.rs b/src/conf/client_api_http.rs index 097a5c985..94a237d66 100644 --- a/src/conf/client_api_http.rs +++ b/src/conf/client_api_http.rs @@ -7,6 +7,7 @@ use std::net::{IpAddr, Ipv4Addr, SocketAddr, ToSocketAddrs as _}; use serde::{Deserialize, Serialize}; use smart_default::SmartDefault; +// TODO: abstract HttpListener, move public_url to ClientApiServer /// [Client API]'s HTTP server settings. /// /// [Client API]: http://tiny.cc/c80uaz diff --git a/src/conf/control_api_grpc.rs b/src/conf/control_api_grpc.rs index 65e357d31..6d11a0572 100644 --- a/src/conf/control_api_grpc.rs +++ b/src/conf/control_api_grpc.rs @@ -7,6 +7,7 @@ use std::net::{IpAddr, Ipv4Addr}; use serde::{Deserialize, Serialize}; use smart_default::SmartDefault; +// TODO: abstract GrpcListener /// [Control API] gRPC server settings. /// /// [Control API]: http://tiny.cc/380uaz diff --git a/src/conf/rpc.rs b/src/conf/rpc.rs index 4744dde1b..211aa418e 100644 --- a/src/conf/rpc.rs +++ b/src/conf/rpc.rs @@ -22,6 +22,7 @@ pub struct Rpc { pub reconnect_timeout: Duration, } +// TODO: are you sure its not failing? #[cfg(test)] mod log_conf_specs { use std::env; diff --git a/src/main.rs b/src/main.rs index 7d58af39e..59a6443af 100644 --- a/src/main.rs +++ b/src/main.rs @@ -19,6 +19,7 @@ use medea::{ AppContext, }; +// TODO: move somewhere else fn start_static_rooms( room_service: &Addr, ) -> impl Future { From 167fd51c791302fafe380001105f290bdb3201d2 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Sun, 15 Sep 2019 22:14:07 +0300 Subject: [PATCH 634/735] Fix seprator in conf tests [run ci] --- src/conf/client_api_http.rs | 8 ++++---- src/conf/control_api.rs | 4 ++-- src/conf/control_api_grpc.rs | 15 +++++++++------ src/conf/log.rs | 4 ++-- src/conf/rpc.rs | 8 ++++---- src/conf/shutdown.rs | 4 ++-- src/conf/turn.rs | 36 ++++++++++++++++++------------------ 7 files changed, 41 insertions(+), 38 deletions(-) diff --git a/src/conf/client_api_http.rs b/src/conf/client_api_http.rs index 94a237d66..2809d1e13 100644 --- a/src/conf/client_api_http.rs +++ b/src/conf/client_api_http.rs @@ -63,13 +63,13 @@ mod server_spec { fn overrides_defaults_and_gets_bind_addr() { let default_conf = Conf::default(); - env::set_var("MEDEA_SERVER.CLIENT.HTTP.BIND_IP", "5.5.5.5"); - env::set_var("MEDEA_SERVER.CLIENT.HTTP.BIND_PORT", "1234"); + env::set_var("MEDEA_SERVER__CLIENT__HTTP__BIND_IP", "5.5.5.5"); + env::set_var("MEDEA_SERVER__CLIENT__HTTP__BIND_PORT", "1234"); let env_conf = Conf::parse().unwrap(); - env::remove_var("MEDEA_SERVER.CLIENT.HTTP.BIND_IP"); - env::remove_var("MEDEA_SERVER.CLIENT.HTTP.BIND_PORT"); + env::remove_var("MEDEA_SERVER__CLIENT__HTTP__BIND_IP"); + env::remove_var("MEDEA_SERVER__CLIENT__HTTP__BIND_PORT"); assert_ne!( default_conf.server.client.http.bind_ip, diff --git a/src/conf/control_api.rs b/src/conf/control_api.rs index bddd8bbba..335a3a708 100644 --- a/src/conf/control_api.rs +++ b/src/conf/control_api.rs @@ -32,9 +32,9 @@ mod control_conf_specs { fn overrides_defaults() { let default_conf = Conf::default(); - env::set_var("MEDEA_CONTROL_API.STATIC_SPECS_DIR", "test/"); + env::set_var("MEDEA_CONTROL_API__STATIC_SPECS_DIR", "test/"); let env_conf = Conf::parse().unwrap(); - env::remove_var("MEDEA_CONTROL_API.STATIC_SPECS_DIR"); + env::remove_var("MEDEA_CONTROL_API__STATIC_SPECS_DIR"); assert_ne!( default_conf.control_api.static_specs_dir, diff --git a/src/conf/control_api_grpc.rs b/src/conf/control_api_grpc.rs index 6d11a0572..45c1cbbd9 100644 --- a/src/conf/control_api_grpc.rs +++ b/src/conf/control_api_grpc.rs @@ -41,13 +41,16 @@ mod control_grpc_conf_specs { fn overrides_defaults() { let default_conf = Conf::default(); - env::set_var("MEDEA_SERVER.CONTROL.GRPC.BIND_IP", "127.0.0.1"); - env::set_var("MEDEA_SERVER.CONTROL.GRPC.BIND_PORT", "44444"); - env::set_var("MEDEA_SERVER.CONTROL.GRPC.COMPLETION_QUEUE_COUNT", "10"); + env::set_var("MEDEA_SERVER__CONTROL__GRPC__BIND_IP", "127.0.0.1"); + env::set_var("MEDEA_SERVER__CONTROL__GRPC__BIND_PORT", "44444"); + env::set_var( + "MEDEA_SERVER__CONTROL__GRPC__COMPLETION_QUEUE_COUNT", + "10", + ); let env_conf = Conf::parse().unwrap(); - env::remove_var("MEDEA_SERVER.CONTROL.GRPC.BIND_IP"); - env::remove_var("MEDEA_SERVER.CONTROL.GRPC.BIND_PORT"); - env::remove_var("MEDEA_SERVER.CONTROL.GRPC.COMPLETION_QUEUE_COUNT"); + env::remove_var("MEDEA_SERVER__CONTROL__GRPC__BIND_IP"); + env::remove_var("MEDEA_SERVER__CONTROL__GRPC__BIND_PORT"); + env::remove_var("MEDEA_SERVER__CONTROL__GRPC__COMPLETION_QUEUE_COUNT"); assert_ne!( default_conf.server.control.grpc.bind_ip, diff --git a/src/conf/log.rs b/src/conf/log.rs index afd007260..ccf91363e 100644 --- a/src/conf/log.rs +++ b/src/conf/log.rs @@ -35,9 +35,9 @@ mod log_conf_specs { fn overrides_defaults() { let default_conf = Conf::default(); - env::set_var("MEDEA_LOG.LEVEL", "DEBUG"); + env::set_var("MEDEA_LOG__LEVEL", "DEBUG"); let env_conf = Conf::parse().unwrap(); - env::remove_var("MEDEA_LOG.LEVEL"); + env::remove_var("MEDEA_LOG__LEVEL"); assert_ne!(default_conf.log.level, env_conf.log.level); } diff --git a/src/conf/rpc.rs b/src/conf/rpc.rs index 211aa418e..4d1f76c2e 100644 --- a/src/conf/rpc.rs +++ b/src/conf/rpc.rs @@ -36,11 +36,11 @@ mod log_conf_specs { fn overrides_defaults() { let default_conf = Conf::default(); - env::set_var("MEDEA_RPC.IDLE_TIMEOUT", "20s"); - env::set_var("MEDEA_RPC.RECONNECT_TIMEOUT", "30s"); + env::set_var("MEDEA_RPC__IDLE_TIMEOUT", "20s"); + env::set_var("MEDEA_RPC__RECONNECT_TIMEOUT", "30s"); let env_conf = Conf::parse().unwrap(); - env::remove_var("MEDEA_RPC.IDLE_TIMEOUT"); - env::remove_var("MEDEA_RPC.RECONNECT_TIMEOUT"); + env::remove_var("MEDEA_RPC__IDLE_TIMEOUT"); + env::remove_var("MEDEA_RPC__RECONNECT_TIMEOUT"); assert_ne!(default_conf.rpc.idle_timeout, env_conf.rpc.idle_timeout); assert_ne!( diff --git a/src/conf/shutdown.rs b/src/conf/shutdown.rs index f43e814a6..a103eecf7 100644 --- a/src/conf/shutdown.rs +++ b/src/conf/shutdown.rs @@ -28,9 +28,9 @@ mod shutdown_conf_specs { fn overrides_defaults() { let default_conf = Conf::default(); - env::set_var("MEDEA_SHUTDOWN.TIMEOUT", "20s"); + env::set_var("MEDEA_SHUTDOWN__TIMEOUT", "20s"); let env_conf = Conf::parse().unwrap(); - env::remove_var("MEDEA_SHUTDOWN.TIMEOUT"); + env::remove_var("MEDEA_SHUTDOWN__TIMEOUT"); assert_ne!(default_conf.shutdown.timeout, env_conf.shutdown.timeout); } diff --git a/src/conf/turn.rs b/src/conf/turn.rs index 45481915d..3801f7e4c 100644 --- a/src/conf/turn.rs +++ b/src/conf/turn.rs @@ -82,25 +82,25 @@ mod turn_conf_specs { fn overrides_defaults() { let default_conf = Conf::default(); - env::set_var("MEDEA_TURN.DB.REDIS.IP", "0.0.0.0"); - env::set_var("MEDEA_TURN.DB.REDIS.PORT", "4444"); - env::set_var("MEDEA_TURN.DB.REDIS.PASS", "hellofellow"); - env::set_var("MEDEA_TURN.DB.REDIS.DB_NUMBER", "10"); - env::set_var("MEDEA_TURN.DB.REDIS.CONNECTION_TIMEOUT", "10s"); - env::set_var("MEDEA_TURN.HOST", "example.com"); - env::set_var("MEDEA_TURN.PORT", "4444"); - env::set_var("MEDEA_TURN.USER", "ferris"); - env::set_var("MEDEA_TURN.PASS", "qwerty"); + env::set_var("MEDEA_TURN__DB__REDIS__IP", "0.0.0.0"); + env::set_var("MEDEA_TURN__DB__REDIS__PORT", "4444"); + env::set_var("MEDEA_TURN__DB__REDIS__PASS", "hellofellow"); + env::set_var("MEDEA_TURN__DB__REDIS__DB_NUMBER", "10"); + env::set_var("MEDEA_TURN__DB__REDIS__CONNECTION_TIMEOUT", "10s"); + env::set_var("MEDEA_TURN__HOST", "example.com"); + env::set_var("MEDEA_TURN__PORT", "4444"); + env::set_var("MEDEA_TURN__USER", "ferris"); + env::set_var("MEDEA_TURN__PASS", "qwerty"); let env_conf = Conf::parse().unwrap(); - env::remove_var("MEDEA_TURN.DB.REDIS.IP"); - env::remove_var("MEDEA_TURN.DB.REDIS.PORT"); - env::remove_var("MEDEA_TURN.DB.REDIS.PASS"); - env::remove_var("MEDEA_TURN.DB.REDIS.DB_NUMBER"); - env::remove_var("MEDEA_TURN.DB.REDIS.CONNECTION_TIMEOUT"); - env::remove_var("MEDEA_TURN.HOST"); - env::remove_var("MEDEA_TURN.PORT"); - env::remove_var("MEDEA_TURN.USER"); - env::remove_var("MEDEA_TURN.PASS"); + env::remove_var("MEDEA_TURN__DB__REDIS__IP"); + env::remove_var("MEDEA_TURN__DB__REDIS__PORT"); + env::remove_var("MEDEA_TURN__DB__REDIS__PASS"); + env::remove_var("MEDEA_TURN__DB__REDIS__DB_NUMBER"); + env::remove_var("MEDEA_TURN__DB__REDIS__CONNECTION_TIMEOUT"); + env::remove_var("MEDEA_TURN__HOST"); + env::remove_var("MEDEA_TURN__PORT"); + env::remove_var("MEDEA_TURN__USER"); + env::remove_var("MEDEA_TURN__PASS"); assert_ne!(default_conf.turn.db.redis.ip, env_conf.turn.db.redis.ip); assert_ne!( From 61c1a7425aabd123deddb5fec2b5639c32d9c1ed Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 16 Sep 2019 12:11:18 +0300 Subject: [PATCH 635/735] Fix E2E tests [run ci] --- .env | 2 +- .travis.yml | 2 +- Makefile | 2 +- docker-compose.medea.yml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.env b/.env index 239083bed..353dbda31 100644 --- a/.env +++ b/.env @@ -1,7 +1,7 @@ RUST_LOG=debug MEDEA_CONF=_dev/config.toml -MEDEA_CONTROL_STATIC_SPECS_DIR=_dev/specs/ +MEDEA_CONTROL_API__STATIC_SPECS_DIR=_dev/specs/ COMPOSE_PROJECT_NAME=medea COMPOSE_IMAGE_NAME=instrumentisto/medea diff --git a/.travis.yml b/.travis.yml index 7c6652406..faef13e9e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -95,7 +95,7 @@ jobs: - name: unit medea-jason (nightly) stage: test - # Run on stable when -Z install-upgrade is out, + # TODO: Run on stable when -Z install-upgrade is out, # see: https://github.com/rust-lang/cargo/issues/6797 rust: nightly addons: diff --git a/Makefile b/Makefile index 54302a56f..3a5911546 100644 --- a/Makefile +++ b/Makefile @@ -336,7 +336,7 @@ endif test-e2e-env = RUST_BACKTRACE=1 \ $(if $(call eq,$(log),yes),,RUST_LOG=warn) \ - MEDEA_CONTROL__STATIC_SPECS_DIR=tests/specs/ + MEDEA_CONTROL_API__STATIC_SPECS_DIR=tests/specs/ test.e2e: ifeq ($(up),yes) diff --git a/docker-compose.medea.yml b/docker-compose.medea.yml index ed15ce61b..61f399bd3 100644 --- a/docker-compose.medea.yml +++ b/docker-compose.medea.yml @@ -7,10 +7,10 @@ services: environment: RUST_LOG: ${RUST_LOG} MEDEA_CONF: ${MEDEA_CONF} - MEDEA_CONTROL__STATIC_SPECS_DIR: ${MEDEA_CONTROL__STATIC_SPECS_DIR} + MEDEA_CONTROL__STATIC_SPECS_DIR: ${MEDEA_CONTROL_API__STATIC_SPECS_DIR} ports: - "8080:8080" volumes: - ./${MEDEA_CONF}:/${MEDEA_CONF}:ro - - ./${MEDEA_CONTROL__STATIC_SPECS_DIR}:/${MEDEA_CONTROL__STATIC_SPECS_DIR}:ro + - ./${MEDEA_CONTROL_API__STATIC_SPECS_DIR}:/${MEDEA_CONTROL_API__STATIC_SPECS_DIR}:ro network_mode: host From b69444cfbedfd506fbf74958abc2f5d9f3ab60d2 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 16 Sep 2019 12:34:14 +0300 Subject: [PATCH 636/735] Abstract HTTP and gRPC listeners --- config.toml | 9 +-- src/api/control/grpc/server.rs | 2 +- src/conf/client_api_http.rs | 93 ------------------------------ src/conf/control_api_grpc.rs | 68 ---------------------- src/conf/grpc_listener.rs | 24 ++++++++ src/conf/http_listener.rs | 32 +++++++++++ src/conf/mod.rs | 4 +- src/conf/server.rs | 102 +++++++++++++++++++++++++++++++-- 8 files changed, 160 insertions(+), 174 deletions(-) delete mode 100644 src/conf/client_api_http.rs delete mode 100644 src/conf/control_api_grpc.rs create mode 100644 src/conf/grpc_listener.rs create mode 100644 src/conf/http_listener.rs diff --git a/config.toml b/config.toml index aed3d29a5..4ee1ce91b 100644 --- a/config.toml +++ b/config.toml @@ -1,11 +1,12 @@ -[server.client.http] -# Server host. +[server.client] +# Server's public URL. # -# Environment variable: MEDEA_SERVER.CLIENT.HTTP.HOST +# Environment variable: MEDEA_SERVER.CLIENT.PUBLIC_URL # # Default: -# host = "ws://0.0.0.0:8080" +# public_url = "ws://0.0.0.0:8080" +[server.client.http] # IP address to bind HTTP server to. # # Environment variable: MEDEA_SERVER.CLIENT.HTTP.BIND_IP diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index 93339755e..ab6519849 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -191,7 +191,7 @@ impl ControlApiService { ) -> String { format!( "{}/{}/{}/{}", - self.app.config.server.client.http.public_url, + self.app.config.server.client.public_url, room_id, member_id, credentials diff --git a/src/conf/client_api_http.rs b/src/conf/client_api_http.rs deleted file mode 100644 index 2809d1e13..000000000 --- a/src/conf/client_api_http.rs +++ /dev/null @@ -1,93 +0,0 @@ -//! [Client API]'s HTTP server settings. -//! -//! [Client API]: http://tiny.cc/c80uaz - -use std::net::{IpAddr, Ipv4Addr, SocketAddr, ToSocketAddrs as _}; - -use serde::{Deserialize, Serialize}; -use smart_default::SmartDefault; - -// TODO: abstract HttpListener, move public_url to ClientApiServer -/// [Client API]'s HTTP server settings. -/// -/// [Client API]: http://tiny.cc/c80uaz -#[allow(clippy::module_name_repetitions)] -#[derive(Clone, Debug, Deserialize, Serialize, SmartDefault)] -#[serde(default)] -pub struct ClientApiHttpServer { - /// Public URL of server. Address for exposed [Client API]. - /// - /// This address will be returned from [Control API] in `sids` and to - /// this address will connect [Jason] for start session. - /// - /// Defaults to `ws://0.0.0.0:8080`. - /// - /// [Client API]: http://tiny.cc/c80uaz - /// [Jason]: https://github.com/instrumentisto/medea/tree/master/jason - #[default("ws://0.0.0.0:8080".to_string())] - pub public_url: String, - - /// IP address to bind HTTP server to. Defaults to `0.0.0.0`. - #[default(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)))] - pub bind_ip: IpAddr, - - /// Port to bind HTTP server to. Defaults to `8080`. - #[default(8080)] - pub bind_port: u16, -} - -impl ClientApiHttpServer { - /// Builds [`SocketAddr`] from `bind_ip` and `bind_port`. - #[inline] - pub fn bind_addr(&self) -> SocketAddr { - (self.bind_ip, self.bind_port) - .to_socket_addrs() - .unwrap() - .next() - .unwrap() - } -} - -#[cfg(test)] -mod server_spec { - use std::env; - - use serial_test_derive::serial; - - use crate::conf::Conf; - - use super::*; - - #[test] - #[serial] - fn overrides_defaults_and_gets_bind_addr() { - let default_conf = Conf::default(); - - env::set_var("MEDEA_SERVER__CLIENT__HTTP__BIND_IP", "5.5.5.5"); - env::set_var("MEDEA_SERVER__CLIENT__HTTP__BIND_PORT", "1234"); - - let env_conf = Conf::parse().unwrap(); - - env::remove_var("MEDEA_SERVER__CLIENT__HTTP__BIND_IP"); - env::remove_var("MEDEA_SERVER__CLIENT__HTTP__BIND_PORT"); - - assert_ne!( - default_conf.server.client.http.bind_ip, - env_conf.server.client.http.bind_ip - ); - assert_ne!( - default_conf.server.client.http.bind_port, - env_conf.server.client.http.bind_port - ); - - assert_eq!( - env_conf.server.client.http.bind_ip, - Ipv4Addr::new(5, 5, 5, 5) - ); - assert_eq!(env_conf.server.client.http.bind_port, 1234); - assert_eq!( - env_conf.server.client.http.bind_addr(), - "5.5.5.5:1234".parse().unwrap(), - ); - } -} diff --git a/src/conf/control_api_grpc.rs b/src/conf/control_api_grpc.rs deleted file mode 100644 index 45c1cbbd9..000000000 --- a/src/conf/control_api_grpc.rs +++ /dev/null @@ -1,68 +0,0 @@ -//! [Control API] gRPC server settings. -//! -//! [Control API]: http://tiny.cc/380uaz - -use std::net::{IpAddr, Ipv4Addr}; - -use serde::{Deserialize, Serialize}; -use smart_default::SmartDefault; - -// TODO: abstract GrpcListener -/// [Control API] gRPC server settings. -/// -/// [Control API]: http://tiny.cc/380uaz -#[allow(clippy::module_name_repetitions)] -#[derive(Clone, Debug, Deserialize, Serialize, SmartDefault)] -#[serde(default)] -pub struct ControlApiGrpcServer { - /// IP address to bind gRPC server to. Defaults to `0.0.0.0`. - #[default(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)))] - pub bind_ip: IpAddr, - - /// Port to bind gRPC server to. Defaults to `50_051`. - #[default(50_051)] - pub bind_port: u16, - - /// Completion queue count of gRPC server. Defaults to `2`. - #[default(2)] - pub completion_queue_count: usize, -} - -#[cfg(test)] -mod control_grpc_conf_specs { - use std::env; - - use serial_test_derive::serial; - - use crate::conf::Conf; - - #[test] - #[serial] - fn overrides_defaults() { - let default_conf = Conf::default(); - - env::set_var("MEDEA_SERVER__CONTROL__GRPC__BIND_IP", "127.0.0.1"); - env::set_var("MEDEA_SERVER__CONTROL__GRPC__BIND_PORT", "44444"); - env::set_var( - "MEDEA_SERVER__CONTROL__GRPC__COMPLETION_QUEUE_COUNT", - "10", - ); - let env_conf = Conf::parse().unwrap(); - env::remove_var("MEDEA_SERVER__CONTROL__GRPC__BIND_IP"); - env::remove_var("MEDEA_SERVER__CONTROL__GRPC__BIND_PORT"); - env::remove_var("MEDEA_SERVER__CONTROL__GRPC__COMPLETION_QUEUE_COUNT"); - - assert_ne!( - default_conf.server.control.grpc.bind_ip, - env_conf.server.control.grpc.bind_ip - ); - assert_ne!( - default_conf.server.control.grpc.bind_port, - env_conf.server.control.grpc.bind_port - ); - assert_ne!( - default_conf.server.control.grpc.completion_queue_count, - env_conf.server.control.grpc.completion_queue_count - ); - } -} diff --git a/src/conf/grpc_listener.rs b/src/conf/grpc_listener.rs new file mode 100644 index 000000000..927de6470 --- /dev/null +++ b/src/conf/grpc_listener.rs @@ -0,0 +1,24 @@ +//! gRPC server settings. + +use std::net::{IpAddr, Ipv4Addr}; + +use serde::{Deserialize, Serialize}; +use smart_default::SmartDefault; + +/// gRPC server settings. +#[allow(clippy::module_name_repetitions)] +#[derive(Clone, Debug, Deserialize, Serialize, SmartDefault)] +#[serde(default)] +pub struct GrpcListener { + /// IP address to bind gRPC server to. Defaults to `0.0.0.0`. + #[default(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)))] + pub bind_ip: IpAddr, + + /// Port to bind gRPC server to. Defaults to `50_051`. + #[default(50_051)] + pub bind_port: u16, + + /// Completion queue count of gRPC server. Defaults to `2`. + #[default(2)] + pub completion_queue_count: usize, +} diff --git a/src/conf/http_listener.rs b/src/conf/http_listener.rs new file mode 100644 index 000000000..6413f1f2e --- /dev/null +++ b/src/conf/http_listener.rs @@ -0,0 +1,32 @@ +//! HTTP server settings. + +use std::net::{IpAddr, Ipv4Addr, SocketAddr, ToSocketAddrs as _}; + +use serde::{Deserialize, Serialize}; +use smart_default::SmartDefault; + +/// HTTP server settings. +#[allow(clippy::module_name_repetitions)] +#[derive(Clone, Debug, Deserialize, Serialize, SmartDefault)] +#[serde(default)] +pub struct HttpListener { + /// IP address to bind HTTP server to. Defaults to `0.0.0.0`. + #[default(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)))] + pub bind_ip: IpAddr, + + /// Port to bind HTTP server to. Defaults to `8080`. + #[default(8080)] + pub bind_port: u16, +} + +impl HttpListener { + /// Builds [`SocketAddr`] from `bind_ip` and `bind_port`. + #[inline] + pub fn bind_addr(&self) -> SocketAddr { + (self.bind_ip, self.bind_port) + .to_socket_addrs() + .unwrap() + .next() + .unwrap() + } +} diff --git a/src/conf/mod.rs b/src/conf/mod.rs index 4aa96ad30..3739ea300 100644 --- a/src/conf/mod.rs +++ b/src/conf/mod.rs @@ -1,8 +1,8 @@ //! Provides application configuration options. -pub mod client_api_http; pub mod control_api; -pub mod control_api_grpc; +pub mod grpc_listener; +pub mod http_listener; pub mod log; pub mod rpc; pub mod server; diff --git a/src/conf/server.rs b/src/conf/server.rs index 0a507c43c..7732c7f29 100644 --- a/src/conf/server.rs +++ b/src/conf/server.rs @@ -3,10 +3,7 @@ use serde::{Deserialize, Serialize}; use smart_default::SmartDefault; -use super::{ - client_api_http::ClientApiHttpServer, - control_api_grpc::ControlApiGrpcServer, -}; +use super::{grpc_listener::GrpcListener, http_listener::HttpListener}; /// [Client API] servers settings. /// @@ -18,7 +15,19 @@ pub struct ClientApiServer { /// [Client API] server settings. /// /// [Client API]: http://tiny.cc/c80uaz - pub http: ClientApiHttpServer, + pub http: HttpListener, + + /// Public URL of server. Address for exposed [Client API]. + /// + /// This address will be returned from [Control API] in `sids` and to + /// this address will connect [Jason] for start session. + /// + /// Defaults to `ws://0.0.0.0:8080`. + /// + /// [Client API]: http://tiny.cc/c80uaz + /// [Jason]: https://github.com/instrumentisto/medea/tree/master/jason + #[default("ws://0.0.0.0:8080".to_string())] + pub public_url: String, } /// [Control API] servers settings. @@ -31,7 +40,7 @@ pub struct ControlApiServer { /// gRPC [Control API] server settings. /// /// [Control API]: http://tiny.cc/380uaz - pub grpc: ControlApiGrpcServer, + pub grpc: GrpcListener, } /// Settings for application servers. @@ -48,3 +57,84 @@ pub struct Server { /// [Control API]: http://tiny.cc/380uaz pub control: ControlApiServer, } + +#[cfg(test)] +mod server_spec { + use std::{env, net::Ipv4Addr}; + + use serial_test_derive::serial; + + use crate::conf::Conf; + + #[test] + #[serial] + fn overrides_defaults_and_gets_bind_addr() { + let default_conf = Conf::default(); + + env::set_var("MEDEA_SERVER__CLIENT__HTTP__BIND_IP", "5.5.5.5"); + env::set_var("MEDEA_SERVER__CLIENT__HTTP__BIND_PORT", "1234"); + + let env_conf = Conf::parse().unwrap(); + + env::remove_var("MEDEA_SERVER__CLIENT__HTTP__BIND_IP"); + env::remove_var("MEDEA_SERVER__CLIENT__HTTP__BIND_PORT"); + + assert_ne!( + default_conf.server.client.http.bind_ip, + env_conf.server.client.http.bind_ip + ); + assert_ne!( + default_conf.server.client.http.bind_port, + env_conf.server.client.http.bind_port + ); + + assert_eq!( + env_conf.server.client.http.bind_ip, + Ipv4Addr::new(5, 5, 5, 5) + ); + assert_eq!(env_conf.server.client.http.bind_port, 1234); + assert_eq!( + env_conf.server.client.http.bind_addr(), + "5.5.5.5:1234".parse().unwrap(), + ); + } +} + +#[cfg(test)] +mod control_grpc_conf_specs { + use std::env; + + use serial_test_derive::serial; + + use crate::conf::Conf; + + #[test] + #[serial] + fn overrides_defaults() { + let default_conf = Conf::default(); + + env::set_var("MEDEA_SERVER__CONTROL__GRPC__BIND_IP", "127.0.0.1"); + env::set_var("MEDEA_SERVER__CONTROL__GRPC__BIND_PORT", "44444"); + env::set_var( + "MEDEA_SERVER__CONTROL__GRPC__COMPLETION_QUEUE_COUNT", + "10", + ); + let env_conf = Conf::parse().unwrap(); + env::remove_var("MEDEA_SERVER__CONTROL__GRPC__BIND_IP"); + env::remove_var("MEDEA_SERVER__CONTROL__GRPC__BIND_PORT"); + env::remove_var("MEDEA_SERVER__CONTROL__GRPC__COMPLETION_QUEUE_COUNT"); + + assert_ne!( + default_conf.server.control.grpc.bind_ip, + env_conf.server.control.grpc.bind_ip + ); + assert_ne!( + default_conf.server.control.grpc.bind_port, + env_conf.server.control.grpc.bind_port + ); + assert_ne!( + default_conf.server.control.grpc.completion_queue_count, + env_conf.server.control.grpc.completion_queue_count + ); + } +} From abe3f10e6c2d5d89d0efcde9bebe3cf7cbf87e50 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 16 Sep 2019 12:50:36 +0300 Subject: [PATCH 637/735] Refactor config --- src/conf/control_api.rs | 2 + src/conf/log.rs | 8 ++- src/conf/mod.rs | 133 ---------------------------------------- src/conf/rpc.rs | 50 ++++++++++++++- src/conf/server.rs | 11 +++- src/conf/shutdown.rs | 3 +- src/conf/turn.rs | 56 +++++++++++++---- 7 files changed, 110 insertions(+), 153 deletions(-) diff --git a/src/conf/control_api.rs b/src/conf/control_api.rs index 335a3a708..f72edd5ab 100644 --- a/src/conf/control_api.rs +++ b/src/conf/control_api.rs @@ -40,5 +40,7 @@ mod control_conf_specs { default_conf.control_api.static_specs_dir, env_conf.control_api.static_specs_dir ); + + assert_eq!(env_conf.control_api.static_specs_dir, "test/"); } } diff --git a/src/conf/log.rs b/src/conf/log.rs index ccf91363e..1b5ae5ce8 100644 --- a/src/conf/log.rs +++ b/src/conf/log.rs @@ -35,10 +35,12 @@ mod log_conf_specs { fn overrides_defaults() { let default_conf = Conf::default(); - env::set_var("MEDEA_LOG__LEVEL", "DEBUG"); + env::set_var("MEDEA_LOG__LEVEL", "WARN"); let env_conf = Conf::parse().unwrap(); - env::remove_var("MEDEA_LOG__LEVEL"); + env::set_var("MEDEA_LOG__LEVEL", "OFF"); - assert_ne!(default_conf.log.level, env_conf.log.level); + assert_ne!(default_conf.log.level(), env_conf.log.level()); + assert_eq!(env_conf.log.level(), Some(slog::Level::Warning)); + assert_eq!(Conf::parse().unwrap().log.level(), None); } } diff --git a/src/conf/mod.rs b/src/conf/mod.rs index 3739ea300..8445bd728 100644 --- a/src/conf/mod.rs +++ b/src/conf/mod.rs @@ -160,137 +160,4 @@ mod tests { ); env::remove_var(APP_CONF_PATH_ENV_VAR_NAME); } - - #[test] - #[serial] - fn conf_parse_spec_file_overrides_defaults() { - let defaults = Conf::default(); - let test_config_file_path = "test_config.toml"; - - let data = "[rpc]\nidle_timeout = \"45s\"".to_owned(); - fs::write(test_config_file_path, data).unwrap(); - env::set_var(APP_CONF_PATH_ENV_VAR_NAME, test_config_file_path); - - let new_config = Conf::parse().unwrap(); - - env::remove_var(APP_CONF_PATH_ENV_VAR_NAME); - fs::remove_file(test_config_file_path).unwrap(); - - assert_eq!(new_config.rpc.idle_timeout, Duration::from_secs(45)); - assert_ne!(new_config.rpc.idle_timeout, defaults.rpc.idle_timeout); - } - - #[test] - #[serial] - fn conf_parse_spec_env_overrides_defaults() { - let defaults = Conf::default(); - - env::set_var("MEDEA_RPC__IDLE_TIMEOUT", "46s"); - let new_config = Conf::parse().unwrap(); - env::remove_var("MEDEA_RPC__IDLE_TIMEOUT"); - - assert_eq!(new_config.rpc.idle_timeout, Duration::from_secs(46)); - assert_ne!(new_config.rpc.idle_timeout, defaults.rpc.idle_timeout); - } - - #[test] - #[serial] - fn conf_parse_spec_env_overrides_file() { - let test_config_file_path = "test_config.toml"; - - let data = "[rpc]\nidle_timeout = \"47s\"".to_owned(); - fs::write(test_config_file_path, data).unwrap(); - env::set_var(APP_CONF_PATH_ENV_VAR_NAME, test_config_file_path); - - let file_config = Conf::parse().unwrap(); - - env::set_var("MEDEA_RPC__IDLE_TIMEOUT", "48s"); - let file_env_config = Conf::parse().unwrap(); - - env::remove_var(APP_CONF_PATH_ENV_VAR_NAME); - fs::remove_file(test_config_file_path).unwrap(); - env::remove_var("MEDEA_RPC__IDLE_TIMEOUT"); - - assert_eq!(file_config.rpc.idle_timeout, Duration::from_secs(47)); - - assert_eq!(file_env_config.rpc.idle_timeout, Duration::from_secs(48)); - } - - #[test] - #[serial] - fn redis_conf() { - let default_conf = Conf::default(); - - env::set_var("MEDEA_TURN__DB__REDIS__IP", "5.5.5.5"); - env::set_var("MEDEA_TURN__DB__REDIS__PORT", "1234"); - env::set_var("MEDEA_TURN__DB__REDIS__CONNECTION_TIMEOUT", "10s"); - - let env_conf = Conf::parse().unwrap(); - - assert_ne!(default_conf.turn.db.redis.ip, env_conf.turn.db.redis.ip); - assert_ne!( - default_conf.turn.db.redis.connection_timeout, - env_conf.turn.db.redis.connection_timeout - ); - assert_ne!( - default_conf.turn.db.redis.connection_timeout, - env_conf.turn.db.redis.connection_timeout - ); - - assert_eq!(env_conf.turn.db.redis.ip, Ipv4Addr::new(5, 5, 5, 5)); - assert_eq!(env_conf.turn.db.redis.port, 1234); - assert_eq!( - env_conf.turn.db.redis.connection_timeout, - Duration::from_secs(10) - ) - } - - #[test] - #[serial] - fn turn_conf() { - let default_conf = Conf::default(); - - env::set_var("MEDEA_TURN__HOST", "example.com"); - env::set_var("MEDEA_TURN__PORT", "1234"); - - let env_conf = Conf::parse().unwrap(); - - assert_ne!(default_conf.turn.host, env_conf.turn.host); - assert_ne!(default_conf.turn.port, env_conf.turn.port); - - assert_eq!(env_conf.turn.host, "example.com"); - assert_eq!(env_conf.turn.port, 1234); - assert_eq!(env_conf.turn.addr(), "example.com:1234"); - } - - #[test] - #[serial] - fn log_conf() { - let default_conf = Conf::default(); - - env::set_var("MEDEA_LOG__LEVEL", "WARN"); - - let env_conf = Conf::parse().unwrap(); - - assert_ne!(default_conf.log.level(), env_conf.log.level()); - - assert_eq!(env_conf.log.level(), Some(slog::Level::Warning)); - - env::set_var("MEDEA_LOG__LEVEL", "OFF"); - - assert_eq!(Conf::parse().unwrap().log.level(), None); - } - - #[test] - #[serial] - fn shutdown_conf_test() { - let default_conf = Conf::default(); - - env::set_var("MEDEA_SHUTDOWN__TIMEOUT", "700ms"); - - let env_conf = Conf::parse().unwrap(); - - assert_ne!(default_conf.shutdown.timeout, env_conf.shutdown.timeout); - assert_eq!(env_conf.shutdown.timeout, Duration::from_millis(700)); - } } diff --git a/src/conf/rpc.rs b/src/conf/rpc.rs index 4d1f76c2e..71f93fb0a 100644 --- a/src/conf/rpc.rs +++ b/src/conf/rpc.rs @@ -24,12 +24,12 @@ pub struct Rpc { // TODO: are you sure its not failing? #[cfg(test)] -mod log_conf_specs { - use std::env; +mod rpc_conf_specs { + use std::{env, fs, time::Duration}; use serial_test_derive::serial; - use crate::conf::Conf; + use crate::conf::{Conf, APP_CONF_PATH_ENV_VAR_NAME}; #[test] #[serial] @@ -47,5 +47,49 @@ mod log_conf_specs { default_conf.rpc.reconnect_timeout, env_conf.rpc.reconnect_timeout ); + + assert_eq!(env_conf.rpc.idle_timeout, Duration::from_secs(20)); + assert_eq!(env_conf.rpc.reconnect_timeout, Duration::from_secs(30)); + } + + #[test] + #[serial] + fn conf_parse_spec_file_overrides_defaults() { + let defaults = Conf::default(); + let test_config_file_path = "test_config.toml"; + + let data = "[rpc]\nidle_timeout = \"45s\"".to_owned(); + fs::write(test_config_file_path, data).unwrap(); + env::set_var(APP_CONF_PATH_ENV_VAR_NAME, test_config_file_path); + + let new_config = Conf::parse().unwrap(); + + env::remove_var(APP_CONF_PATH_ENV_VAR_NAME); + fs::remove_file(test_config_file_path).unwrap(); + + assert_eq!(new_config.rpc.idle_timeout, Duration::from_secs(45)); + assert_ne!(new_config.rpc.idle_timeout, defaults.rpc.idle_timeout); + } + + #[test] + #[serial] + fn conf_parse_spec_env_overrides_file() { + let test_config_file_path = "test_config.toml"; + + let data = "[rpc]\nidle_timeout = \"47s\"".to_owned(); + fs::write(test_config_file_path, data).unwrap(); + env::set_var(APP_CONF_PATH_ENV_VAR_NAME, test_config_file_path); + + let file_config = Conf::parse().unwrap(); + + env::set_var("MEDEA_RPC__IDLE_TIMEOUT", "48s"); + let file_env_config = Conf::parse().unwrap(); + + env::remove_var(APP_CONF_PATH_ENV_VAR_NAME); + fs::remove_file(test_config_file_path).unwrap(); + env::remove_var("MEDEA_RPC__IDLE_TIMEOUT"); + + assert_eq!(file_config.rpc.idle_timeout, Duration::from_secs(47)); + assert_eq!(file_env_config.rpc.idle_timeout, Duration::from_secs(48)); } } diff --git a/src/conf/server.rs b/src/conf/server.rs index 7732c7f29..e839751e4 100644 --- a/src/conf/server.rs +++ b/src/conf/server.rs @@ -102,7 +102,7 @@ mod server_spec { #[cfg(test)] mod control_grpc_conf_specs { - use std::env; + use std::{env, net::Ipv4Addr}; use serial_test_derive::serial; @@ -113,7 +113,7 @@ mod control_grpc_conf_specs { fn overrides_defaults() { let default_conf = Conf::default(); - env::set_var("MEDEA_SERVER__CONTROL__GRPC__BIND_IP", "127.0.0.1"); + env::set_var("MEDEA_SERVER__CONTROL__GRPC__BIND_IP", "182.98.12.48"); env::set_var("MEDEA_SERVER__CONTROL__GRPC__BIND_PORT", "44444"); env::set_var( "MEDEA_SERVER__CONTROL__GRPC__COMPLETION_QUEUE_COUNT", @@ -136,5 +136,12 @@ mod control_grpc_conf_specs { default_conf.server.control.grpc.completion_queue_count, env_conf.server.control.grpc.completion_queue_count ); + + assert_eq!(env_conf.server.control.grpc.completion_queue_count, 10); + assert_eq!(env_conf.server.control.grpc.bind_port, 44444); + assert_eq!( + env_conf.server.control.grpc.bind_ip, + Ipv4Addr::new(182, 98, 12, 48) + ); } } diff --git a/src/conf/shutdown.rs b/src/conf/shutdown.rs index a103eecf7..5b93d4ea7 100644 --- a/src/conf/shutdown.rs +++ b/src/conf/shutdown.rs @@ -17,7 +17,7 @@ pub struct Shutdown { #[cfg(test)] mod shutdown_conf_specs { - use std::env; + use std::{env, time::Duration}; use serial_test_derive::serial; @@ -33,5 +33,6 @@ mod shutdown_conf_specs { env::remove_var("MEDEA_SHUTDOWN__TIMEOUT"); assert_ne!(default_conf.shutdown.timeout, env_conf.shutdown.timeout); + assert_eq!(env_conf.shutdown.timeout, Duration::from_secs(20)); } } diff --git a/src/conf/turn.rs b/src/conf/turn.rs index 3801f7e4c..789dbcdbe 100644 --- a/src/conf/turn.rs +++ b/src/conf/turn.rs @@ -76,31 +76,24 @@ mod turn_conf_specs { use serial_test_derive::serial; use crate::conf::Conf; + use std::{net::Ipv4Addr, time::Duration}; #[test] #[serial] - fn overrides_defaults() { + fn redis_db_overrides_defaults() { let default_conf = Conf::default(); - env::set_var("MEDEA_TURN__DB__REDIS__IP", "0.0.0.0"); - env::set_var("MEDEA_TURN__DB__REDIS__PORT", "4444"); + env::set_var("MEDEA_TURN__DB__REDIS__IP", "5.5.5.5"); + env::set_var("MEDEA_TURN__DB__REDIS__PORT", "1234"); env::set_var("MEDEA_TURN__DB__REDIS__PASS", "hellofellow"); env::set_var("MEDEA_TURN__DB__REDIS__DB_NUMBER", "10"); env::set_var("MEDEA_TURN__DB__REDIS__CONNECTION_TIMEOUT", "10s"); - env::set_var("MEDEA_TURN__HOST", "example.com"); - env::set_var("MEDEA_TURN__PORT", "4444"); - env::set_var("MEDEA_TURN__USER", "ferris"); - env::set_var("MEDEA_TURN__PASS", "qwerty"); let env_conf = Conf::parse().unwrap(); env::remove_var("MEDEA_TURN__DB__REDIS__IP"); env::remove_var("MEDEA_TURN__DB__REDIS__PORT"); env::remove_var("MEDEA_TURN__DB__REDIS__PASS"); env::remove_var("MEDEA_TURN__DB__REDIS__DB_NUMBER"); env::remove_var("MEDEA_TURN__DB__REDIS__CONNECTION_TIMEOUT"); - env::remove_var("MEDEA_TURN__HOST"); - env::remove_var("MEDEA_TURN__PORT"); - env::remove_var("MEDEA_TURN__USER"); - env::remove_var("MEDEA_TURN__PASS"); assert_ne!(default_conf.turn.db.redis.ip, env_conf.turn.db.redis.ip); assert_ne!( @@ -119,9 +112,50 @@ mod turn_conf_specs { default_conf.turn.db.redis.connection_timeout, env_conf.turn.db.redis.connection_timeout ); + + assert_eq!(env_conf.turn.db.redis.ip, Ipv4Addr::new(5, 5, 5, 5)); + assert_eq!(env_conf.turn.db.redis.port, 1234); + assert_eq!( + env_conf.turn.db.redis.connection_timeout, + Duration::from_secs(10) + ); + } + + #[test] + #[serial] + fn overrides_defaults() { + let default_conf = Conf::default(); + + env::set_var("MEDEA_TURN__HOST", "example.com"); + env::set_var("MEDEA_TURN__PORT", "1234"); + env::set_var("MEDEA_TURN__USER", "ferris"); + env::set_var("MEDEA_TURN__PASS", "qwerty"); + let env_conf = Conf::parse().unwrap(); + env::remove_var("MEDEA_TURN__HOST"); + env::remove_var("MEDEA_TURN__PORT"); + env::remove_var("MEDEA_TURN__USER"); + env::remove_var("MEDEA_TURN__PASS"); + assert_ne!(default_conf.turn.host, env_conf.turn.host); assert_ne!(default_conf.turn.port, env_conf.turn.port); assert_ne!(default_conf.turn.user, env_conf.turn.user); assert_ne!(default_conf.turn.pass, env_conf.turn.pass); + assert_eq!(env_conf.turn.host, "example.com"); + assert_eq!(env_conf.turn.port, 1234); + assert_eq!(env_conf.turn.addr(), "example.com:1234"); + } + + #[test] + #[serial] + fn turn_conf() { + let default_conf = Conf::default(); + + env::set_var("MEDEA_TURN__HOST", "example.com"); + env::set_var("MEDEA_TURN__PORT", "1234"); + + let env_conf = Conf::parse().unwrap(); + + assert_ne!(default_conf.turn.host, env_conf.turn.host); + assert_ne!(default_conf.turn.port, env_conf.turn.port); } } From 71317e50411a3114b54bfbce1e34637fa97f6699 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 16 Sep 2019 13:29:01 +0300 Subject: [PATCH 638/735] Add macro for auto removing overrided envs in conf tests [run ci] --- src/conf/control_api.rs | 11 ++++----- src/conf/log.rs | 17 +++++++------- src/conf/mod.rs | 35 ++++++++++++++++++++++++++--- src/conf/rpc.rs | 16 +++++++------- src/conf/server.rs | 18 +++++---------- src/conf/shutdown.rs | 11 +++++---- src/conf/turn.rs | 49 ++++++++++++++++------------------------- 7 files changed, 83 insertions(+), 74 deletions(-) diff --git a/src/conf/control_api.rs b/src/conf/control_api.rs index f72edd5ab..171d2a748 100644 --- a/src/conf/control_api.rs +++ b/src/conf/control_api.rs @@ -21,20 +21,17 @@ pub struct ControlApi { #[cfg(test)] mod control_conf_specs { - use std::env; - use serial_test_derive::serial; - use crate::conf::Conf; + use crate::{conf::Conf, overrided_by_env_conf}; #[test] #[serial] fn overrides_defaults() { let default_conf = Conf::default(); - - env::set_var("MEDEA_CONTROL_API__STATIC_SPECS_DIR", "test/"); - let env_conf = Conf::parse().unwrap(); - env::remove_var("MEDEA_CONTROL_API__STATIC_SPECS_DIR"); + let env_conf = overrided_by_env_conf!( + "MEDEA_CONTROL_API__STATIC_SPECS_DIR" => "test/" + ); assert_ne!( default_conf.control_api.static_specs_dir, diff --git a/src/conf/log.rs b/src/conf/log.rs index 1b5ae5ce8..b035ac613 100644 --- a/src/conf/log.rs +++ b/src/conf/log.rs @@ -24,23 +24,24 @@ impl Log { #[cfg(test)] mod log_conf_specs { - use std::env; - use serial_test_derive::serial; - use crate::conf::Conf; + use crate::{conf::Conf, overrided_by_env_conf}; #[test] #[serial] fn overrides_defaults() { let default_conf = Conf::default(); - env::set_var("MEDEA_LOG__LEVEL", "WARN"); - let env_conf = Conf::parse().unwrap(); - env::set_var("MEDEA_LOG__LEVEL", "OFF"); - + let env_conf = overrided_by_env_conf!( + "MEDEA_LOG__LEVEL" => "WARN" + ); assert_ne!(default_conf.log.level(), env_conf.log.level()); assert_eq!(env_conf.log.level(), Some(slog::Level::Warning)); - assert_eq!(Conf::parse().unwrap().log.level(), None); + + let none_lvl = overrided_by_env_conf!( + "MEDEA_LOG__LEVEL" => "OFF" + ); + assert_eq!(none_lvl.log.level(), None); } } diff --git a/src/conf/mod.rs b/src/conf/mod.rs index 8445bd728..6d2896ab1 100644 --- a/src/conf/mod.rs +++ b/src/conf/mod.rs @@ -98,13 +98,42 @@ where } #[cfg(test)] -mod tests { - use std::{fs, net::Ipv4Addr, time::Duration}; - +pub mod tests { use serial_test_derive::serial; use super::*; + /// Macro which overrides environment variables + /// with provided values, parses [`Conf`] and + /// finally removes all overrided variables. + /// + /// # Usage + /// + /// ```rust + /// # use crate::conf::Conf; + /// # + /// let default_conf = Conf::default(); + /// let env_conf = overrided_by_env_conf!( + /// "MEDEA_TURN__HOST" => "example.com", + /// "MEDEA_TURN__PORT" => "1234", + /// "MEDEA_TURN__USER" => "ferris", + /// "MEDEA_TURN__PASS" => "qwerty" + /// ); + /// + /// assert_ne!(default_conf.turn.host, env_conf.turn.host); + /// assert_ne!(default_conf.turn.port, env_conf.turn.port); + /// // ... + /// ``` + #[macro_export] + macro_rules! overrided_by_env_conf { + ($($env:expr => $value:expr),+) => {{ + $(std::env::set_var($env, $value);)+ + let conf = crate::conf::Conf::parse().unwrap(); + $(std::env::remove_var($env);)+ + conf + }}; + } + #[test] #[serial] fn get_conf_file_name_spec_none_if_nothing_is_set() { diff --git a/src/conf/rpc.rs b/src/conf/rpc.rs index 71f93fb0a..934b1b59a 100644 --- a/src/conf/rpc.rs +++ b/src/conf/rpc.rs @@ -22,25 +22,25 @@ pub struct Rpc { pub reconnect_timeout: Duration, } -// TODO: are you sure its not failing? #[cfg(test)] mod rpc_conf_specs { use std::{env, fs, time::Duration}; use serial_test_derive::serial; - use crate::conf::{Conf, APP_CONF_PATH_ENV_VAR_NAME}; + use crate::{ + conf::{Conf, APP_CONF_PATH_ENV_VAR_NAME}, + overrided_by_env_conf, + }; #[test] #[serial] fn overrides_defaults() { let default_conf = Conf::default(); - - env::set_var("MEDEA_RPC__IDLE_TIMEOUT", "20s"); - env::set_var("MEDEA_RPC__RECONNECT_TIMEOUT", "30s"); - let env_conf = Conf::parse().unwrap(); - env::remove_var("MEDEA_RPC__IDLE_TIMEOUT"); - env::remove_var("MEDEA_RPC__RECONNECT_TIMEOUT"); + let env_conf = overrided_by_env_conf!( + "MEDEA_RPC__IDLE_TIMEOUT" => "20s", + "MEDEA_RPC__RECONNECT_TIMEOUT" => "30s" + ); assert_ne!(default_conf.rpc.idle_timeout, env_conf.rpc.idle_timeout); assert_ne!( diff --git a/src/conf/server.rs b/src/conf/server.rs index e839751e4..9267ebc89 100644 --- a/src/conf/server.rs +++ b/src/conf/server.rs @@ -102,27 +102,21 @@ mod server_spec { #[cfg(test)] mod control_grpc_conf_specs { - use std::{env, net::Ipv4Addr}; + use std::net::Ipv4Addr; use serial_test_derive::serial; - use crate::conf::Conf; + use crate::{conf::Conf, overrided_by_env_conf}; #[test] #[serial] fn overrides_defaults() { let default_conf = Conf::default(); - - env::set_var("MEDEA_SERVER__CONTROL__GRPC__BIND_IP", "182.98.12.48"); - env::set_var("MEDEA_SERVER__CONTROL__GRPC__BIND_PORT", "44444"); - env::set_var( - "MEDEA_SERVER__CONTROL__GRPC__COMPLETION_QUEUE_COUNT", - "10", + let env_conf = overrided_by_env_conf!( + "MEDEA_SERVER__CONTROL__GRPC__BIND_IP" => "182.98.12.48", + "MEDEA_SERVER__CONTROL__GRPC__BIND_PORT" => "44444", + "MEDEA_SERVER__CONTROL__GRPC__COMPLETION_QUEUE_COUNT" => "10" ); - let env_conf = Conf::parse().unwrap(); - env::remove_var("MEDEA_SERVER__CONTROL__GRPC__BIND_IP"); - env::remove_var("MEDEA_SERVER__CONTROL__GRPC__BIND_PORT"); - env::remove_var("MEDEA_SERVER__CONTROL__GRPC__COMPLETION_QUEUE_COUNT"); assert_ne!( default_conf.server.control.grpc.bind_ip, diff --git a/src/conf/shutdown.rs b/src/conf/shutdown.rs index 5b93d4ea7..72de34df1 100644 --- a/src/conf/shutdown.rs +++ b/src/conf/shutdown.rs @@ -17,20 +17,19 @@ pub struct Shutdown { #[cfg(test)] mod shutdown_conf_specs { - use std::{env, time::Duration}; + use std::time::Duration; use serial_test_derive::serial; - use crate::conf::Conf; + use crate::{conf::Conf, overrided_by_env_conf}; #[test] #[serial] fn overrides_defaults() { let default_conf = Conf::default(); - - env::set_var("MEDEA_SHUTDOWN__TIMEOUT", "20s"); - let env_conf = Conf::parse().unwrap(); - env::remove_var("MEDEA_SHUTDOWN__TIMEOUT"); + let env_conf = overrided_by_env_conf!( + "MEDEA_SHUTDOWN__TIMEOUT" => "20s" + ); assert_ne!(default_conf.shutdown.timeout, env_conf.shutdown.timeout); assert_eq!(env_conf.shutdown.timeout, Duration::from_secs(20)); diff --git a/src/conf/turn.rs b/src/conf/turn.rs index 789dbcdbe..6a54239a4 100644 --- a/src/conf/turn.rs +++ b/src/conf/turn.rs @@ -71,29 +71,23 @@ pub struct Redis { #[cfg(test)] mod turn_conf_specs { - use std::env; + use std::{net::Ipv4Addr, time::Duration}; use serial_test_derive::serial; - use crate::conf::Conf; - use std::{net::Ipv4Addr, time::Duration}; + use crate::{conf::Conf, overrided_by_env_conf}; #[test] #[serial] fn redis_db_overrides_defaults() { let default_conf = Conf::default(); - - env::set_var("MEDEA_TURN__DB__REDIS__IP", "5.5.5.5"); - env::set_var("MEDEA_TURN__DB__REDIS__PORT", "1234"); - env::set_var("MEDEA_TURN__DB__REDIS__PASS", "hellofellow"); - env::set_var("MEDEA_TURN__DB__REDIS__DB_NUMBER", "10"); - env::set_var("MEDEA_TURN__DB__REDIS__CONNECTION_TIMEOUT", "10s"); - let env_conf = Conf::parse().unwrap(); - env::remove_var("MEDEA_TURN__DB__REDIS__IP"); - env::remove_var("MEDEA_TURN__DB__REDIS__PORT"); - env::remove_var("MEDEA_TURN__DB__REDIS__PASS"); - env::remove_var("MEDEA_TURN__DB__REDIS__DB_NUMBER"); - env::remove_var("MEDEA_TURN__DB__REDIS__CONNECTION_TIMEOUT"); + let env_conf = overrided_by_env_conf!( + "MEDEA_TURN__DB__REDIS__IP" => "5.5.5.5", + "MEDEA_TURN__DB__REDIS__PORT" => "1234", + "MEDEA_TURN__DB__REDIS__PASS" => "hellofellow", + "MEDEA_TURN__DB__REDIS__DB_NUMBER" => "10", + "MEDEA_TURN__DB__REDIS__CONNECTION_TIMEOUT" => "10s" + ); assert_ne!(default_conf.turn.db.redis.ip, env_conf.turn.db.redis.ip); assert_ne!( @@ -125,16 +119,12 @@ mod turn_conf_specs { #[serial] fn overrides_defaults() { let default_conf = Conf::default(); - - env::set_var("MEDEA_TURN__HOST", "example.com"); - env::set_var("MEDEA_TURN__PORT", "1234"); - env::set_var("MEDEA_TURN__USER", "ferris"); - env::set_var("MEDEA_TURN__PASS", "qwerty"); - let env_conf = Conf::parse().unwrap(); - env::remove_var("MEDEA_TURN__HOST"); - env::remove_var("MEDEA_TURN__PORT"); - env::remove_var("MEDEA_TURN__USER"); - env::remove_var("MEDEA_TURN__PASS"); + let env_conf = overrided_by_env_conf!( + "MEDEA_TURN__HOST" => "example.com", + "MEDEA_TURN__PORT" => "1234", + "MEDEA_TURN__USER" => "ferris", + "MEDEA_TURN__PASS" => "qwerty" + ); assert_ne!(default_conf.turn.host, env_conf.turn.host); assert_ne!(default_conf.turn.port, env_conf.turn.port); @@ -149,11 +139,10 @@ mod turn_conf_specs { #[serial] fn turn_conf() { let default_conf = Conf::default(); - - env::set_var("MEDEA_TURN__HOST", "example.com"); - env::set_var("MEDEA_TURN__PORT", "1234"); - - let env_conf = Conf::parse().unwrap(); + let env_conf = overrided_by_env_conf!( + "MEDEA_TURN__HOST" => "example.com", + "MEDEA_TURN__PORT" => "1234" + ); assert_ne!(default_conf.turn.host, env_conf.turn.host); assert_ne!(default_conf.turn.port, env_conf.turn.port); From a192445f2552261514cf226fa608f13911d339e1 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 16 Sep 2019 13:37:45 +0300 Subject: [PATCH 639/735] Move start_static_rooms into control module [run ci] --- src/api/control/mod.rs | 34 ++++++++++++++++++++ src/main.rs | 70 ++++++++++++------------------------------ 2 files changed, 54 insertions(+), 50 deletions(-) diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index ce84d4020..bdafbde10 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -11,10 +11,19 @@ pub mod room; use std::{convert::TryFrom as _, fs::File, io::Read as _, path::Path}; +use actix::Addr; use derive_more::Display; use failure::Fail; +use futures::Future; use serde::Deserialize; +use crate::{ + log::prelude::*, + signalling::room_service::{ + RoomService, RoomServiceError, StartStaticRooms, + }, +}; + use self::{ endpoints::webrtc_play_endpoint::SrcParseError, pipeline::Pipeline, }; @@ -170,3 +179,28 @@ pub fn load_static_specs_from_dir>( } Ok(specs) } + +pub fn start_static_rooms( + room_service: &Addr, +) -> impl Future { + room_service + .send(StartStaticRooms) + .map_err(|e| error!("StartStaticRooms mailbox error: {:?}", e)) + .map(|result| { + if let Err(e) = result { + match e { + RoomServiceError::FailedToLoadStaticSpecs(e) => match e { + LoadStaticControlSpecsError::SpecDirReadError(e) => { + warn!( + "Error while reading static control API specs \ + dir. Control API specs not loaded. {}", + e + ); + } + _ => panic!("{}", e), + }, + _ => panic!("{}", e), + } + } + }) +} diff --git a/src/main.rs b/src/main.rs index 59a6443af..713debdf2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,50 +1,18 @@ use std::collections::HashMap; -use actix::{Actor, Addr}; +use actix::Actor; use failure::Error; use futures::future::Future; use medea::{ - api::{ - client::server::Server, - control::{grpc, LoadStaticControlSpecsError}, - }, + api::{client::server::Server, control::grpc}, conf::Conf, log::{self, prelude::*}, shutdown::{self, GracefulShutdown}, - signalling::{ - room_repo::RoomRepository, - room_service::{RoomService, RoomServiceError, StartStaticRooms}, - }, + signalling::{room_repo::RoomRepository, room_service::RoomService}, turn::new_turn_auth_service, AppContext, }; -// TODO: move somewhere else -fn start_static_rooms( - room_service: &Addr, -) -> impl Future { - room_service - .send(StartStaticRooms) - .map_err(|e| error!("StartStaticRooms mailbox error: {:?}", e)) - .map(|result| { - if let Err(e) = result { - match e { - RoomServiceError::FailedToLoadStaticSpecs(e) => match e { - LoadStaticControlSpecsError::SpecDirReadError(e) => { - warn!( - "Error while reading static control API specs \ - dir. Control API specs not loaded. {}", - e - ); - } - _ => panic!("{}", e), - }, - _ => panic!("{}", e), - } - } - }) -} - fn main() -> Result<(), Error> { dotenv::dotenv().ok(); let logger = log::new_dual_logger(std::io::stdout(), std::io::stderr()); @@ -73,22 +41,24 @@ fn main() -> Result<(), Error> { ) .start(); - start_static_rooms(&room_service).map(move |_| { - let grpc_addr = - grpc::server::run(room_service, app_context); - shutdown::subscribe( - &graceful_shutdown, - grpc_addr.recipient(), - shutdown::Priority(1), - ); + medea::api::control::start_static_rooms(&room_service).map( + move |_| { + let grpc_addr = + grpc::server::run(room_service, app_context); + shutdown::subscribe( + &graceful_shutdown, + grpc_addr.recipient(), + shutdown::Priority(1), + ); - let server = Server::run(room_repo, config).unwrap(); - shutdown::subscribe( - &graceful_shutdown, - server.recipient(), - shutdown::Priority(1), - ); - }) + let server = Server::run(room_repo, config).unwrap(); + shutdown::subscribe( + &graceful_shutdown, + server.recipient(), + shutdown::Priority(1), + ); + }, + ) }) }) .unwrap(); From d8276b552baea8cc5ca0f09b341357ac2efca0bf Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 16 Sep 2019 13:43:24 +0300 Subject: [PATCH 640/735] Fix [run ci] --- src/conf/mod.rs | 4 ++-- src/conf/server.rs | 15 ++++++--------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/conf/mod.rs b/src/conf/mod.rs index 6d2896ab1..125620507 100644 --- a/src/conf/mod.rs +++ b/src/conf/mod.rs @@ -127,9 +127,9 @@ pub mod tests { #[macro_export] macro_rules! overrided_by_env_conf { ($($env:expr => $value:expr),+) => {{ - $(std::env::set_var($env, $value);)+ + $(::std::env::set_var($env, $value);)+ let conf = crate::conf::Conf::parse().unwrap(); - $(std::env::remove_var($env);)+ + $(::std::env::remove_var($env);)+ conf }}; } diff --git a/src/conf/server.rs b/src/conf/server.rs index 9267ebc89..9097ccb53 100644 --- a/src/conf/server.rs +++ b/src/conf/server.rs @@ -60,24 +60,21 @@ pub struct Server { #[cfg(test)] mod server_spec { - use std::{env, net::Ipv4Addr}; + use std::net::Ipv4Addr; use serial_test_derive::serial; - use crate::conf::Conf; + use crate::{conf::Conf, overrided_by_env_conf}; #[test] #[serial] fn overrides_defaults_and_gets_bind_addr() { let default_conf = Conf::default(); - env::set_var("MEDEA_SERVER__CLIENT__HTTP__BIND_IP", "5.5.5.5"); - env::set_var("MEDEA_SERVER__CLIENT__HTTP__BIND_PORT", "1234"); - - let env_conf = Conf::parse().unwrap(); - - env::remove_var("MEDEA_SERVER__CLIENT__HTTP__BIND_IP"); - env::remove_var("MEDEA_SERVER__CLIENT__HTTP__BIND_PORT"); + let env_conf = overrided_by_env_conf!( + "MEDEA_SERVER__CLIENT__HTTP__BIND_IP" => "5.5.5.5", + "MEDEA_SERVER__CLIENT__HTTP__BIND_PORT" => "1234" + ); assert_ne!( default_conf.server.client.http.bind_ip, From 45d57d537d5999c19df1a6d55538eb39eda0aac6 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 16 Sep 2019 13:56:43 +0300 Subject: [PATCH 641/735] Reread [run ci] --- jason/demo/chart/medea-demo/templates/deployment.server.yaml | 4 ++-- jason/demo/chart/medea-demo/values.yaml | 2 +- jason/demo/minikube.vals.yaml | 3 +-- jason/demo/staging.vals.yaml | 2 +- src/api/control/member.rs | 2 +- src/api/control/mod.rs | 4 ++++ src/conf/turn.rs | 1 + src/signalling/room_service.rs | 2 +- 8 files changed, 12 insertions(+), 8 deletions(-) diff --git a/jason/demo/chart/medea-demo/templates/deployment.server.yaml b/jason/demo/chart/medea-demo/templates/deployment.server.yaml index 4664734d8..42e5fdfc8 100644 --- a/jason/demo/chart/medea-demo/templates/deployment.server.yaml +++ b/jason/demo/chart/medea-demo/templates/deployment.server.yaml @@ -64,8 +64,8 @@ spec: value: {{ $coturn.conf.listening_port | quote }} - name: MEDEA_TURN__DB__REDIS__PORT value: {{ $coturnDb.conf.port | quote }} - - name: MEDEA_SERVER.CLIENT.HTTP.PUBLIC_URL - value: {{ .Values.server.conf.server.client.http.public_url }} + - name: MEDEA_SERVER.CLIENT.PUBLIC_URL + value: {{ .Values.server.conf.server.client.public_url }} envFrom: - secretRef: name: {{ template "medea-demo.fullname" . }}.server.cred diff --git a/jason/demo/chart/medea-demo/values.yaml b/jason/demo/chart/medea-demo/values.yaml index 3b127b92c..720a98687 100644 --- a/jason/demo/chart/medea-demo/values.yaml +++ b/jason/demo/chart/medea-demo/values.yaml @@ -17,9 +17,9 @@ server: conf: server: client: + public_url: "" http: bind_port: 8080 - public_url: "" turn: user: USER pass: PASS diff --git a/jason/demo/minikube.vals.yaml b/jason/demo/minikube.vals.yaml index 8cff0fe55..ff68bf230 100644 --- a/jason/demo/minikube.vals.yaml +++ b/jason/demo/minikube.vals.yaml @@ -10,8 +10,7 @@ server: conf: server: client: - http: - public_url: "wss://medea-demo.test" + public_url: "wss://medea-demo.test" turn: host: medea-demo.test diff --git a/jason/demo/staging.vals.yaml b/jason/demo/staging.vals.yaml index 47d836bdf..bd3ed841b 100644 --- a/jason/demo/staging.vals.yaml +++ b/jason/demo/staging.vals.yaml @@ -10,8 +10,8 @@ server: conf: server: client: + public_url: "wss://demo.medea.stg.t11913.org" http: - public_url: "wss://demo.medea.stg.t11913.org" bind_port: 9980 turn: host: demo.medea.stg.t11913.org diff --git a/src/api/control/member.rs b/src/api/control/member.rs index 5fd68c39d..f8e7337f6 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -110,7 +110,7 @@ impl MemberSpec { } /// Generates alphanumeric credentials for [`Member`] with -/// [`MEMBER_CREDENTIALS_LEN`] length. +/// [`CREDENTIALS_LEN`] length. /// /// This credentials will be generated if in dynamic [Control API] spec not /// provided credentials for [`Member`]. This logic you can find in [`TryFrom`] diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index bdafbde10..68f30e10c 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -180,6 +180,10 @@ pub fn load_static_specs_from_dir>( Ok(specs) } +/// Starts all [`Room`]s from static [Control API] specs. +/// +/// [Control API]: http://tiny.cc/380uaz +/// [`Room`]: crate::signalling::room::Room pub fn start_static_rooms( room_service: &Addr, ) -> impl Future { diff --git a/src/conf/turn.rs b/src/conf/turn.rs index 6a54239a4..a9d2c4734 100644 --- a/src/conf/turn.rs +++ b/src/conf/turn.rs @@ -130,6 +130,7 @@ mod turn_conf_specs { assert_ne!(default_conf.turn.port, env_conf.turn.port); assert_ne!(default_conf.turn.user, env_conf.turn.user); assert_ne!(default_conf.turn.pass, env_conf.turn.pass); + assert_eq!(env_conf.turn.host, "example.com"); assert_eq!(env_conf.turn.port, 1234); assert_eq!(env_conf.turn.addr(), "example.com:1234"); diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index 0e2e52893..1f5c123f3 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -1,4 +1,4 @@ -//! Service which provide CRUD actions for [`Room`]. +//! Service which provides CRUD actions for [`Room`]. use std::{collections::HashMap, marker::PhantomData}; From 9f257b7049f92939cce8176d96e56a663219b144 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 16 Sep 2019 14:39:31 +0300 Subject: [PATCH 642/735] Fix env in docker-compose [run ci] --- docker-compose.medea.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.medea.yml b/docker-compose.medea.yml index 61f399bd3..865ed7457 100644 --- a/docker-compose.medea.yml +++ b/docker-compose.medea.yml @@ -7,7 +7,7 @@ services: environment: RUST_LOG: ${RUST_LOG} MEDEA_CONF: ${MEDEA_CONF} - MEDEA_CONTROL__STATIC_SPECS_DIR: ${MEDEA_CONTROL_API__STATIC_SPECS_DIR} + MEDEA_CONTROL_API__STATIC_SPECS_DIR: ${MEDEA_CONTROL_API__STATIC_SPECS_DIR} ports: - "8080:8080" volumes: From 7aea8e2b37dc83f1a31c5b781ec6403fe7e492da Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 17 Sep 2019 13:13:35 +0300 Subject: [PATCH 643/735] Add Dockerfile for medea-build [run ci] --- .dockerignore | 1 + .travis.yml | 4 +++- Dockerfile | 8 ++------ Makefile | 25 +++++++++++++++++++++++-- _build/medea-build/Dockerfile | 7 +++++++ 5 files changed, 36 insertions(+), 9 deletions(-) create mode 100644 _build/medea-build/Dockerfile diff --git a/.dockerignore b/.dockerignore index 5e3b4966a..4ca1a4a54 100644 --- a/.dockerignore +++ b/.dockerignore @@ -20,3 +20,4 @@ !.cache/cargo/ # !target/{mode} is added and removed dynamically to reduce image build times. +!target/debug/ diff --git a/.travis.yml b/.travis.yml index faef13e9e..04517aa47 100644 --- a/.travis.yml +++ b/.travis.yml @@ -111,8 +111,10 @@ jobs: stage: test rust: stable services: ["docker"] - before_script: make docker.pull TAGS=build-${TRAVIS_BUILD_ID} + before_script: + - make docker.pull TAGS=build-${TRAVIS_BUILD_ID} registry=quay.io + - make docker.build.medea-build script: make test.e2e up=yes dockerized=yes log=yes wait=30 TAG=build-${TRAVIS_BUILD_ID} registry=quay.io diff --git a/Dockerfile b/Dockerfile index 32f2acc38..97af1ef2e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,8 +8,8 @@ # # https://hub.docker.com/_/rust -ARG rust_ver=latest -FROM rust:${rust_ver} AS dist +ARG medea_build_ver=dev +FROM instrumentisto/medea-build:${medea_build_ver} AS dist ARG rustc_mode=release ARG rustc_opts=--release ARG cargo_home=/usr/local/cargo @@ -22,10 +22,6 @@ RUN mkdir -p /out/etc/ \ COPY / /app/ -# Install dependencies needed for grpcio crate. -RUN apt-get update \ - && apt-get install -y cmake - # Build project distribution. RUN cd /app \ # Compile project. diff --git a/Makefile b/Makefile index 3a5911546..bd7e8a112 100644 --- a/Makefile +++ b/Makefile @@ -18,6 +18,7 @@ eq = $(if $(or $(1),$(2)),$(and $(findstring $(1),$(2)),\ MEDEA_IMAGE_NAME := $(strip \ $(shell grep 'COMPOSE_IMAGE_NAME=' .env | cut -d '=' -f2)) DEMO_IMAGE_NAME := instrumentisto/medea-demo +MEDEA_BUILD_IMAGE_NAME := instrumentisto/medea-build RUST_VER := 1.37 @@ -175,6 +176,7 @@ cargo: # [dockerized=(no|yes)] cargo-build-crate = $(if $(call eq,$(crate),),@all,$(crate)) +cargo-build-medea-build-image-name = $(MEDEA_BUILD_IMAGE_NAME) cargo.build: ifeq ($(cargo-build-crate),@all) @@ -186,7 +188,7 @@ ifeq ($(dockerized),yes) docker run --rm -v "$(PWD)":/app -w /app \ -u $(shell id -u):$(shell id -g) \ -v "$(HOME)/.cargo/registry":/usr/local/cargo/registry \ - rust:$(RUST_VER) \ + $(cargo-build-medea-build-image-name):dev \ make cargo.build crate=$(cargo-build-crate) \ debug=$(debug) dockerized=no else @@ -438,6 +440,19 @@ else endif +# Build Docker image for medea building. +# +# Usage: +# make docker.build.medea-build [TAG=(dev|)] + +docker-build-medea-build-image-name = $(MEDEA_BUILD_IMAGE_NAME) + +docker.build.medea-build: + docker build \ + -t $(docker-build-medea-build-image-name):$(if $(call eq,$(TAG),),dev,$(TAG)) \ + - < _build/medea-build/Dockerfile + + # Build medea project Docker image. # # Usage: @@ -448,10 +463,16 @@ endif docker-build-medea-image-name = $(strip \ $(if $(call eq,$(registry),),,$(registry)/)$(MEDEA_IMAGE_NAME)) +docker-build-medea-medea-build-image-name = $(MEDEA_BUILD_IMAGE_NAME) docker.build.medea: ifneq ($(no-cache),yes) - cargo build --bin=medea $(if $(call eq,$(debug),no),--release,) + docker run --rm --network=host -v "$(PWD)":/app -w /app \ + -u $(shell id -u):$(shell id -g) \ + -e CARGO_HOME=.cache/cargo \ + $(docker-build-medea-medea-build-image-name):dev \ + cargo build --bin=medea \ + $(if $(call eq,$(debug),no),--release,) endif $(call docker.build.clean.ignore) @echo "!target/$(if $(call eq,$(debug),no),release,debug)/" >> .dockerignore diff --git a/_build/medea-build/Dockerfile b/_build/medea-build/Dockerfile new file mode 100644 index 000000000..ea0c6e3fd --- /dev/null +++ b/_build/medea-build/Dockerfile @@ -0,0 +1,7 @@ +# https://hub.docker.com/_/rust +ARG rust_ver=latest +FROM rust:${rust_ver} AS dist + +RUN apt-get update \ + # Dependencies for grpcio + && apt-get install -y cmake From 95981fa60117d6397a2b606cdaafffd50510606c Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 17 Sep 2019 13:27:11 +0300 Subject: [PATCH 644/735] Fix travis [run ci] --- .travis.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 04517aa47..df6255778 100644 --- a/.travis.yml +++ b/.travis.yml @@ -51,6 +51,7 @@ jobs: stage: build rust: stable services: ["docker"] + before_script: make docker.build.medea-build script: make docker.build.medea debug=no TAG=build-${TRAVIS_BUILD_ID} registry=quay.io before_deploy: echo "$QUAYIO_PASS" @@ -111,10 +112,8 @@ jobs: stage: test rust: stable services: ["docker"] - before_script: - - make docker.pull TAGS=build-${TRAVIS_BUILD_ID} + before_script: make docker.pull TAGS=build-${TRAVIS_BUILD_ID} registry=quay.io - - make docker.build.medea-build script: make test.e2e up=yes dockerized=yes log=yes wait=30 TAG=build-${TRAVIS_BUILD_ID} registry=quay.io From 395c3e4a13b05040110b63f44eef2efa403ed913 Mon Sep 17 00:00:00 2001 From: alexlapa Date: Tue, 17 Sep 2019 14:31:11 +0300 Subject: [PATCH 645/735] refactor ControlApiService::create --- src/api/control/grpc/server.rs | 115 ++++++++++++++++++--------------- 1 file changed, 62 insertions(+), 53 deletions(-) diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index ab6519849..5847618d9 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -199,8 +199,8 @@ impl ControlApiService { } /// Implementation of `Create` method for [`Room`]. - pub fn create_room( - &mut self, + fn create_room( + &self, req: &CreateRequest, uri: LocalUri, ) -> impl Future { @@ -230,8 +230,8 @@ impl ControlApiService { } /// Implementation of `Create` method for [`Member`] element. - pub fn create_member( - &mut self, + fn create_member( + &self, req: &CreateRequest, uri: LocalUri, ) -> impl Future { @@ -253,8 +253,8 @@ impl ControlApiService { } /// Implementation of `Create` method for [`Endpoint`] elements. - pub fn create_endpoint( - &mut self, + fn create_endpoint( + &self, req: &CreateRequest, uri: LocalUri, ) -> impl Future { @@ -269,6 +269,60 @@ impl ControlApiService { }), ) } + + pub fn create_element( + &self, + req: &CreateRequest, + ) -> Box + Send> { + let uri = match StatefulLocalUri::try_from(req.get_id().as_ref()) { + Ok(uri) => uri, + Err(e) => { + return Box::new(futures::future::err(e.into())); + } + }; + + match uri { + StatefulLocalUri::Room(local_uri) => { + if req.has_room() { + Box::new( + self.create_room(&req, local_uri) + .map_err(|err| err.into()), + ) + } else { + Box::new(futures::future::err(ErrorResponse::new( + ErrorCode::ElementIdForRoomButElementIsNot, + &req.get_id(), + ))) + } + } + StatefulLocalUri::Member(local_uri) => { + if req.has_member() { + Box::new( + self.create_member(&req, local_uri) + .map_err(|err| err.into()), + ) + } else { + Box::new(futures::future::err(ErrorResponse::new( + ErrorCode::ElementIdForMemberButElementIsNot, + &req.get_id(), + ))) + } + } + StatefulLocalUri::Endpoint(local_uri) => { + if req.has_webrtc_pub() || req.has_webrtc_play() { + Box::new( + self.create_endpoint(&req, local_uri) + .map_err(|err| err.into()), + ) + } else { + Box::new(futures::future::err(ErrorResponse::new( + ErrorCode::ElementIdForEndpointButElementIsNot, + &req.get_id(), + ))) + } + } + } + } } impl ControlApi for ControlApiService { @@ -281,58 +335,13 @@ impl ControlApi for ControlApiService { req: CreateRequest, sink: UnarySink, ) { - macro_rules! send_error_response_code { - ($response_code:expr) => { - send_error_response!( - ctx, - sink, - ErrorResponse::new($response_code, &req.get_id()), - CreateResponse - ) - }; - } - - type CreateFuture = - Box + Send>; - - let response_fut: CreateFuture = - match parse_local_uri!(req.get_id(), ctx, sink, CreateResponse) { - StatefulLocalUri::Room(local_uri) => { - if req.has_room() { - Box::new(self.create_room(&req, local_uri)) - } else { - send_error_response_code!( - ErrorCode::ElementIdForRoomButElementIsNot - ); - } - } - StatefulLocalUri::Member(local_uri) => { - if req.has_member() { - Box::new(self.create_member(&req, local_uri)) - } else { - send_error_response_code!( - ErrorCode::ElementIdForMemberButElementIsNot - ); - } - } - StatefulLocalUri::Endpoint(local_uri) => { - if req.has_webrtc_pub() || req.has_webrtc_play() { - Box::new(self.create_endpoint(&req, local_uri)) - } else { - send_error_response_code!( - ErrorCode::ElementIdForEndpointButElementIsNot - ); - } - } - }; - - ctx.spawn(response_fut.then(move |result| { + ctx.spawn(self.create_element(&req).then(move |result| { let mut response = CreateResponse::new(); match result { Ok(sid) => { response.set_sid(sid); } - Err(e) => response.set_error(ErrorResponse::from(e).into()), + Err(e) => response.set_error(e.into()), } sink.success(response).map_err(|e| { warn!("Error while sending Create response by gRPC. {:?}", e) From 01f3b849e0d972c86ebae1bd4aac77bf7610c69b Mon Sep 17 00:00:00 2001 From: alexlapa Date: Tue, 17 Sep 2019 18:12:42 +0300 Subject: [PATCH 646/735] refactor --- src/api/control/endpoints/mod.rs | 8 +- .../endpoints/webrtc_publish_endpoint.rs | 12 +- src/api/control/grpc/server.rs | 202 +++++++++--------- src/api/control/mod.rs | 2 +- src/signalling/participants.rs | 2 +- src/signalling/room_service.rs | 2 +- 6 files changed, 114 insertions(+), 114 deletions(-) diff --git a/src/api/control/endpoints/mod.rs b/src/api/control/endpoints/mod.rs index 7e0b7992e..014b7c18a 100644 --- a/src/api/control/endpoints/mod.rs +++ b/src/api/control/endpoints/mod.rs @@ -31,10 +31,10 @@ pub enum Endpoint { impl Into for Endpoint { fn into(self) -> MemberElement { match self { - Endpoint::WebRtcPublish(e) => { + Self::WebRtcPublish(e) => { MemberElement::WebRtcPublishEndpoint { spec: e } } - Endpoint::WebRtcPlay(e) => { + Self::WebRtcPlay(e) => { MemberElement::WebRtcPlayEndpoint { spec: e } } } @@ -50,11 +50,11 @@ macro_rules! impl_try_from_proto_for_endpoint { if proto.has_webrtc_play() { let play = WebRtcPlayEndpoint::try_from(proto.get_webrtc_play())?; - Ok(Endpoint::WebRtcPlay(play)) + Ok(Self::WebRtcPlay(play)) } else if proto.has_webrtc_pub() { let publish = WebRtcPublishEndpoint::from(proto.get_webrtc_pub()); - Ok(Endpoint::WebRtcPublish(publish)) + Ok(Self::WebRtcPublish(publish)) } else { // TODO: implement another endpoints when they will be // implemented diff --git a/src/api/control/endpoints/webrtc_publish_endpoint.rs b/src/api/control/endpoints/webrtc_publish_endpoint.rs index 2e342eb8f..b69912e58 100644 --- a/src/api/control/endpoints/webrtc_publish_endpoint.rs +++ b/src/api/control/endpoints/webrtc_publish_endpoint.rs @@ -30,9 +30,9 @@ pub enum P2pMode { impl From for P2pMode { fn from(value: WebRtcPublishEndpointP2pProto) -> Self { match value { - WebRtcPublishEndpointP2pProto::ALWAYS => P2pMode::Always, - WebRtcPublishEndpointP2pProto::IF_POSSIBLE => P2pMode::IfPossible, - WebRtcPublishEndpointP2pProto::NEVER => P2pMode::Never, + WebRtcPublishEndpointP2pProto::ALWAYS => Self::Always, + WebRtcPublishEndpointP2pProto::IF_POSSIBLE => Self::IfPossible, + WebRtcPublishEndpointP2pProto::NEVER => Self::Never, } } } @@ -40,9 +40,9 @@ impl From for P2pMode { impl Into for P2pMode { fn into(self) -> WebRtcPublishEndpointP2pProto { match self { - P2pMode::Always => WebRtcPublishEndpointP2pProto::ALWAYS, - P2pMode::IfPossible => WebRtcPublishEndpointP2pProto::IF_POSSIBLE, - P2pMode::Never => WebRtcPublishEndpointP2pProto::NEVER, + Self::Always => WebRtcPublishEndpointP2pProto::ALWAYS, + Self::IfPossible => WebRtcPublishEndpointP2pProto::IF_POSSIBLE, + Self::Never => WebRtcPublishEndpointP2pProto::NEVER, } } } diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index 5847618d9..eaf52f6ea 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -12,14 +12,14 @@ use actix::{ }; use derive_more::Display; use failure::Fail; -use futures::future::{Either, Future}; +use futures::future::{self, Either, Future, IntoFuture}; use grpcio::{ Environment, RpcContext, RpcStatus, RpcStatusCode, Server, ServerBuilder, UnarySink, }; use medea_control_api_proto::grpc::{ control_api::{ - ApplyRequest, CreateRequest, CreateResponse, Error, GetResponse, + ApplyRequest, CreateRequest, CreateResponse, Element, GetResponse, IdRequest, Response, }, control_api_grpc::{create_control_api, ControlApi}, @@ -87,7 +87,7 @@ pub enum GrpcControlApiError { impl From for GrpcControlApiError { fn from(from: LocalUriParseError) -> Self { - GrpcControlApiError::LocalUri(from) + Self::LocalUri(from) } } @@ -99,13 +99,13 @@ impl From for GrpcControlApiError { impl From for GrpcControlApiError { fn from(from: TryFromProtobufError) -> Self { - GrpcControlApiError::TryFromProtobuf(from) + Self::TryFromProtobuf(from) } } impl From for GrpcControlApiError { fn from(from: TryFromElementError) -> Self { - GrpcControlApiError::TryFromElement(from) + Self::TryFromElement(from) } } @@ -118,55 +118,12 @@ macro_rules! fut_try { match $call { Ok(o) => o, Err(e) => { - return Either::B(futures::future::err( - GrpcControlApiError::from(e), - )) + return Either::B(future::err(GrpcControlApiError::from(e))) } } }; } -/// Macro for [`LocalUri`] parsing and sending error to client if some error -/// occurs. -/// -/// See `send_error_response` doc for details about arguments for this macro. -macro_rules! parse_local_uri { - ($uri:expr, $ctx:expr, $sink:expr, $response:ty) => { - match StatefulLocalUri::try_from($uri.as_ref()) { - Ok(o) => o, - Err(e) => { - let error: ErrorResponse = e.into(); - send_error_response!($ctx, $sink, error, $response); - } - } - }; -} - -/// Macro for send [`Error`] to client and `return` from current function. -/// -/// `$error_code` - some object which can converts into [`Error`] by [`Into`] -/// trait. -/// -/// `$response` - type of response ([`GetResponse`], [`Response`] -/// etc). -/// -/// `$ctx` - context where [`Future`] for send gRPC response will be spawned. -/// -/// `$sink` - [`grpcio`]'s sink for response. -macro_rules! send_error_response { - ($ctx:tt, $sink:tt, $error_code:expr, $response:ty) => { - let mut response = <$response>::new(); - let error: Error = $error_code.into(); - response.set_error(error); - - $ctx.spawn($sink.success(response).map_err(|e| { - warn!("Error while sending Error response by gRPC. {:?}", e) - })); - - return; - }; -} - /// Type alias for success [`CreateResponse`]'s sids. type Sids = HashMap; @@ -277,7 +234,7 @@ impl ControlApiService { let uri = match StatefulLocalUri::try_from(req.get_id().as_ref()) { Ok(uri) => uri, Err(e) => { - return Box::new(futures::future::err(e.into())); + return Box::new(future::err(e.into())); } }; @@ -289,7 +246,7 @@ impl ControlApiService { .map_err(|err| err.into()), ) } else { - Box::new(futures::future::err(ErrorResponse::new( + Box::new(future::err(ErrorResponse::new( ErrorCode::ElementIdForRoomButElementIsNot, &req.get_id(), ))) @@ -302,7 +259,7 @@ impl ControlApiService { .map_err(|err| err.into()), ) } else { - Box::new(futures::future::err(ErrorResponse::new( + Box::new(future::err(ErrorResponse::new( ErrorCode::ElementIdForMemberButElementIsNot, &req.get_id(), ))) @@ -315,7 +272,7 @@ impl ControlApiService { .map_err(|err| err.into()), ) } else { - Box::new(futures::future::err(ErrorResponse::new( + Box::new(future::err(ErrorResponse::new( ErrorCode::ElementIdForEndpointButElementIsNot, &req.get_id(), ))) @@ -323,6 +280,74 @@ impl ControlApiService { } } } + + pub fn delete_element( + &self, + req: &IdRequest, + ) -> impl Future { + let mut delete_elements_msg = DeleteElements::new(); + + for id in req.get_id() { + match StatefulLocalUri::try_from(id.as_str()) { + Ok(uri) => { + delete_elements_msg.add_uri(uri); + } + Err(e) => { + return future::Either::A(future::err(e.into())); + } + } + } + + let room_service = Addr::clone(&self.room_service); + future::Either::B( + delete_elements_msg + .validate() + .into_future() + .map_err(ErrorResponse::from) + .and_then(move |del_msg| { + room_service.send(del_msg).map_err(|err| { + ErrorResponse::from( + GrpcControlApiError::RoomServiceMailboxError(err), + ) + }) + }) + .and_then(|delete_result| { + delete_result.map_err(ErrorResponse::from) + }), + ) + } + + pub fn get_element( + &self, + req: &IdRequest, + ) -> impl Future, Error = ErrorResponse> + { + let mut uris = Vec::new(); + for id in req.get_id() { + match StatefulLocalUri::try_from(id.as_str()) { + Ok(uri) => { + uris.push(uri); + } + Err(e) => { + return future::Either::A(future::err(e.into())); + } + } + } + + future::Either::B( + self.room_service + .send(Get(uris)) + .map_err(GrpcControlApiError::RoomServiceMailboxError) + .and_then(|r| r.map_err(GrpcControlApiError::from)) + .map(|elements: HashMap| { + elements + .into_iter() + .map(|(id, value)| (id.to_string(), value)) + .collect() + }) + .map_err(ErrorResponse::from), + ) + } } impl ControlApi for ControlApiService { @@ -335,18 +360,25 @@ impl ControlApi for ControlApiService { req: CreateRequest, sink: UnarySink, ) { - ctx.spawn(self.create_element(&req).then(move |result| { - let mut response = CreateResponse::new(); - match result { - Ok(sid) => { - response.set_sid(sid); - } - Err(e) => response.set_error(e.into()), - } - sink.success(response).map_err(|e| { - warn!("Error while sending Create response by gRPC. {:?}", e) - }) - })); + ctx.spawn( + self.create_element(&req) + .then(move |result| { + let mut response = CreateResponse::new(); + match result { + Ok(sid) => { + response.set_sid(sid); + } + Err(e) => response.set_error(e.into()), + } + sink.success(response) + }) + .map_err(|e| { + warn!( + "Error while sending Create response by gRPC. {:?}", + e + ) + }), + ); } /// Implementation for `Apply` method of gRPC [Control API] (__unimplemented @@ -388,35 +420,12 @@ impl ControlApi for ControlApiService { req: IdRequest, sink: UnarySink, ) { - let mut delete_elements_msg = DeleteElements::new(); - - for id in req.get_id() { - let uri: StatefulLocalUri = - parse_local_uri!(id, ctx, sink, Response); - delete_elements_msg.add_uri(uri); - } - - let delete_elements_msg = match delete_elements_msg.validate() { - Ok(d) => d, - Err(e) => { - send_error_response!( - ctx, - sink, - ErrorResponse::from(e), - Response - ); - } - }; - ctx.spawn( - self.room_service - .send(delete_elements_msg) - .map_err(GrpcControlApiError::RoomServiceMailboxError) - .and_then(|r| r.map_err(GrpcControlApiError::from)) + self.delete_element(&req) .then(move |result| { let mut response = Response::new(); if let Err(e) = result { - response.set_error(ErrorResponse::from(e).into()); + response.set_error(e.into()); } sink.success(response) }) @@ -439,17 +448,8 @@ impl ControlApi for ControlApiService { req: IdRequest, sink: UnarySink, ) { - let mut uris = Vec::new(); - for id in req.get_id() { - let local_uri = parse_local_uri!(id, ctx, sink, GetResponse); - uris.push(local_uri); - } - ctx.spawn( - self.room_service - .send(Get(uris)) - .map_err(GrpcControlApiError::RoomServiceMailboxError) - .and_then(|r| r.map_err(GrpcControlApiError::from)) + self.get_element(&req) .then(|result| { let mut response = GetResponse::new(); match result { @@ -462,7 +462,7 @@ impl ControlApi for ControlApiService { ); } Err(e) => { - response.set_error(ErrorResponse::from(e).into()); + response.set_error(e.into()); } } sink.success(response) diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index 68f30e10c..3bd8e607b 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -62,7 +62,7 @@ pub enum TryFromProtobufError { impl From for TryFromProtobufError { fn from(from: SrcParseError) -> Self { - TryFromProtobufError::SrcUriError(from) + Self::SrcUriError(from) } } diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 84dc4e3c2..ea5e82ae7 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -94,7 +94,7 @@ impl From for ParticipantServiceErr { impl From for ParticipantServiceErr { fn from(err: MemberError) -> Self { - ParticipantServiceErr::MemberError(err) + Self::MemberError(err) } } diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index 1f5c123f3..0cc9ff512 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -85,7 +85,7 @@ pub enum RoomServiceError { impl From for RoomServiceError { fn from(err: RoomError) -> Self { - RoomServiceError::RoomError(err) + Self::RoomError(err) } } From b1da658bb5a2e0bd9a49c9661215a42232a10079 Mon Sep 17 00:00:00 2001 From: alexlapa Date: Wed, 18 Sep 2019 00:34:07 +0300 Subject: [PATCH 647/735] refactor [run ci] --- .dockerignore | 1 - Dockerfile | 4 ++-- Makefile | 33 ++++++++++++++------------------- _build/medea-build/Dockerfile | 4 ++-- 4 files changed, 18 insertions(+), 24 deletions(-) diff --git a/.dockerignore b/.dockerignore index 08285d64b..efcb829f2 100644 --- a/.dockerignore +++ b/.dockerignore @@ -23,4 +23,3 @@ !Makefile # !target/{mode} is added and removed dynamically to reduce image build times. -!target/debug/ diff --git a/Dockerfile b/Dockerfile index 97af1ef2e..99cdc1467 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,8 +8,8 @@ # # https://hub.docker.com/_/rust -ARG medea_build_ver=dev -FROM instrumentisto/medea-build:${medea_build_ver} AS dist +ARG medea_build_image=instrumentisto/medea-build:latest +FROM ${medea_build_image} AS dist ARG rustc_mode=release ARG rustc_opts=--release ARG cargo_home=/usr/local/cargo diff --git a/Makefile b/Makefile index bd7e8a112..9536239e6 100644 --- a/Makefile +++ b/Makefile @@ -18,8 +18,9 @@ eq = $(if $(or $(1),$(2)),$(and $(findstring $(1),$(2)),\ MEDEA_IMAGE_NAME := $(strip \ $(shell grep 'COMPOSE_IMAGE_NAME=' .env | cut -d '=' -f2)) DEMO_IMAGE_NAME := instrumentisto/medea-demo -MEDEA_BUILD_IMAGE_NAME := instrumentisto/medea-build +MEDEA_BUILD_IMAGE_NAME := alexlapa/medea-build +MEDEA_BUILD_IMAGE_VER := latest RUST_VER := 1.37 CURRENT_BRANCH := $(strip $(shell git branch | grep \* | cut -d ' ' -f2)) @@ -176,7 +177,7 @@ cargo: # [dockerized=(no|yes)] cargo-build-crate = $(if $(call eq,$(crate),),@all,$(crate)) -cargo-build-medea-build-image-name = $(MEDEA_BUILD_IMAGE_NAME) +medea-build-image = $(MEDEA_BUILD_IMAGE_NAME):$(MEDEA_BUILD_IMAGE_VER) cargo.build: ifeq ($(cargo-build-crate),@all) @@ -188,7 +189,7 @@ ifeq ($(dockerized),yes) docker run --rm -v "$(PWD)":/app -w /app \ -u $(shell id -u):$(shell id -g) \ -v "$(HOME)/.cargo/registry":/usr/local/cargo/registry \ - $(cargo-build-medea-build-image-name):dev \ + $(medea-build-image) \ make cargo.build crate=$(cargo-build-crate) \ debug=$(debug) dockerized=no else @@ -202,14 +203,10 @@ ifeq ($(dockerized),yes) -v "$(HOME)/.cargo/registry":/usr/local/cargo/registry \ -v "$(HOME):$(HOME)" \ -e XDG_CACHE_HOME=$(HOME) \ - rust:$(RUST_VER) \ + $(medea-build-image) \ make cargo.build crate=$(cargo-build-crate) \ - debug=$(debug) dockerized=no \ - pre-install=yes + debug=$(debug) dockerized=no else -ifeq ($(pre-install),yes) - curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh -endif @rm -rf $(crate-dir)/pkg/ wasm-pack build -t web $(crate-dir)/ endif @@ -445,14 +442,14 @@ endif # Usage: # make docker.build.medea-build [TAG=(dev|)] -docker-build-medea-build-image-name = $(MEDEA_BUILD_IMAGE_NAME) - docker.build.medea-build: docker build \ - -t $(docker-build-medea-build-image-name):$(if $(call eq,$(TAG),),dev,$(TAG)) \ + --build-arg rust_ver=$(RUST_VER) \ + -t $(MEDEA_BUILD_IMAGE_NAME):$(if $(call eq,$(TAG),),dev,$(TAG)) \ - < _build/medea-build/Dockerfile + # Build medea project Docker image. # # Usage: @@ -463,14 +460,14 @@ docker.build.medea-build: docker-build-medea-image-name = $(strip \ $(if $(call eq,$(registry),),,$(registry)/)$(MEDEA_IMAGE_NAME)) -docker-build-medea-medea-build-image-name = $(MEDEA_BUILD_IMAGE_NAME) +medea-build-image = $(MEDEA_BUILD_IMAGE_NAME):$(MEDEA_BUILD_IMAGE_VER) docker.build.medea: ifneq ($(no-cache),yes) docker run --rm --network=host -v "$(PWD)":/app -w /app \ -u $(shell id -u):$(shell id -g) \ -e CARGO_HOME=.cache/cargo \ - $(docker-build-medea-medea-build-image-name):dev \ + $(medea-build-image) \ cargo build --bin=medea \ $(if $(call eq,$(debug),no),--release,) endif @@ -481,12 +478,10 @@ endif $(if $(call eq,$(no-cache),yes),\ --no-cache --pull,) \ $(if $(call eq,$(IMAGE),),\ - --build-arg rust_ver=$(RUST_VER) \ - --build-arg rustc_mode=$(if \ - $(call eq,$(debug),no),release,debug) \ - --build-arg rustc_opts=$(if \ - $(call eq,$(debug),no),--release,) \ + --build-arg rustc_mode=$(if $(call eq,$(debug),no),release,debug) \ + --build-arg rustc_opts=$(if $(call eq,$(debug),no),--release,) \ --build-arg cargo_home=.cache/cargo,) \ + --build-arg medea_build_image=$(medea-build-image) \ -t $(docker-build-medea-image-name):$(if $(call eq,$(TAG),),dev,$(TAG)) . $(call docker.build.clean.ignore) define docker.build.clean.ignore diff --git a/_build/medea-build/Dockerfile b/_build/medea-build/Dockerfile index ea0c6e3fd..96cdab1cc 100644 --- a/_build/medea-build/Dockerfile +++ b/_build/medea-build/Dockerfile @@ -3,5 +3,5 @@ ARG rust_ver=latest FROM rust:${rust_ver} AS dist RUN apt-get update \ - # Dependencies for grpcio - && apt-get install -y cmake + && apt-get install -y cmake \ + && curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh From 089892a1eea519e7fe22570079c866d372944cb5 Mon Sep 17 00:00:00 2001 From: alexlapa Date: Mon, 23 Sep 2019 00:02:03 +0300 Subject: [PATCH 648/735] refactor [run ci] --- Cargo.lock | 117 ++++---- config.toml | 2 +- src/api/control/endpoints/mod.rs | 112 +++++-- .../control/endpoints/webrtc_play_endpoint.rs | 43 +-- .../endpoints/webrtc_publish_endpoint.rs | 8 +- src/api/control/grpc/server.rs | 171 +++++------ src/api/control/local_uri.rs | 150 ++++++---- src/api/control/member.rs | 92 +++--- src/api/control/mod.rs | 16 +- src/api/control/pipeline.rs | 19 +- src/api/control/room.rs | 62 ++-- src/api/error_codes.rs | 229 +++++++------- src/conf/grpc_listener.rs | 4 +- src/log/mod.rs | 3 + .../endpoints/webrtc/play_endpoint.rs | 1 + src/signalling/elements/member.rs | 106 ++----- src/signalling/participants.rs | 61 ++-- src/signalling/room.rs | 24 +- src/signalling/room_repo.rs | 2 +- src/signalling/room_service.rs | 282 ++++++++---------- 20 files changed, 748 insertions(+), 756 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2da8fbff4..410edd042 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -85,7 +85,7 @@ dependencies = [ "copyless 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", "either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "encoding_rs 0.8.19 (registry+https://github.com/rust-lang/crates.io-index)", + "encoding_rs 0.8.20 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "flate2 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", @@ -99,9 +99,9 @@ dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "mime 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", "percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.100 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "serde_urlencoded 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -115,10 +115,11 @@ dependencies = [ [[package]] name = "actix-http-test" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-connect 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "actix-rt 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "actix-server 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "actix-service 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -131,9 +132,9 @@ dependencies = [ "http 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.100 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_urlencoded 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_urlencoded 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", @@ -150,7 +151,7 @@ dependencies = [ "http 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.100 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", "string 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -254,7 +255,7 @@ dependencies = [ "awc 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", - "encoding_rs 0.8.19 (registry+https://github.com/rust-lang/crates.io-index)", + "encoding_rs 0.8.20 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "hashbrown 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -262,7 +263,7 @@ dependencies = [ "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.100 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "serde_urlencoded 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", @@ -303,7 +304,7 @@ dependencies = [ [[package]] name = "adler32" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -321,7 +322,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "arc-swap" -version = "0.4.2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -371,8 +372,8 @@ dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "mime 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", "percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.100 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "serde_urlencoded 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", @@ -545,7 +546,7 @@ dependencies = [ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "nom 4.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "rust-ini 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.100 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", "serde-hjson 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", @@ -644,7 +645,7 @@ name = "derive-new" version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -715,7 +716,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "encoding_rs" -version = "0.8.19" +version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -938,7 +939,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.100 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1100,7 +1101,7 @@ dependencies = [ "actix 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)", "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "actix-http 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-http-test 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-http-test 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "actix-web 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", "actix-web-actors 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "awc 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1119,10 +1120,10 @@ dependencies = [ "medea-control-api-proto 0.1.0-dev", "medea-macro 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "redis 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.100 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "serde_yaml 0.8.9 (registry+https://github.com/rust-lang/crates.io-index)", "serial_test 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1146,7 +1147,7 @@ version = "0.1.1-dev" dependencies = [ "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", "medea-macro 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.100 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1175,7 +1176,7 @@ dependencies = [ "mockall 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "newtype_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "predicates-tree 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.100 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-futures 0.3.27 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1189,7 +1190,7 @@ name = "medea-macro" version = "0.1.0" dependencies = [ "Inflector 0.11.4 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1242,7 +1243,7 @@ name = "miniz_oxide" version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "adler32 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1512,7 +1513,7 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1570,7 +1571,7 @@ name = "quote" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1614,7 +1615,7 @@ dependencies = [ [[package]] name = "rand" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "getrandom 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1902,10 +1903,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde" -version = "1.0.100" +version = "1.0.101" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde_derive 1.0.100 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1922,10 +1923,10 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.100" +version = "1.0.101" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1937,7 +1938,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.100 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1948,17 +1949,6 @@ dependencies = [ "serde 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "serde_urlencoded" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "dtoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.100 (registry+https://github.com/rust-lang/crates.io-index)", - "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "serde_urlencoded" version = "0.6.1" @@ -1966,7 +1956,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "dtoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.100 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", "url 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1977,7 +1967,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "dtoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.100 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", "yaml-rust 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2017,7 +2007,7 @@ name = "signal-hook-registry" version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "arc-swap 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "arc-swap 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2061,7 +2051,7 @@ version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.100 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2158,7 +2148,7 @@ name = "syn" version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2186,7 +2176,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", "remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2426,7 +2416,7 @@ name = "toml" version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.100 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2434,7 +2424,7 @@ name = "toml" version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.100 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2564,7 +2554,7 @@ version = "0.2.50" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.100 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-macro 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2577,7 +2567,7 @@ dependencies = [ "bumpalo 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-shared 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2609,7 +2599,7 @@ name = "wasm-bindgen-macro-support" version = "0.2.50" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-backend 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2652,7 +2642,7 @@ dependencies = [ "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-backend 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2780,7 +2770,7 @@ dependencies = [ "checksum actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9f2c11af4b06dc935d8e1b1491dad56bfb32febc49096a91e773f8535c176453" "checksum actix-connect 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "9fade9bd4bb46bacde89f1e726c7a3dd230536092712f5d94d77ca57c087fca0" "checksum actix-http 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "cdf758ebbc4abfecbdc1ce7408601b2d7e0cd7e4766ef61183cd8ce16c194d64" -"checksum actix-http-test 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "beafa31d71c8fa8204ede1602a3dd221e5cf30ff354180f8ee87274ab81cf607" +"checksum actix-http-test 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "4c29c11568a1fd24163f7757aea88737082c1b8317f550262f9a1f47e9832f54" "checksum actix-router 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "23224bb527e204261d0291102cb9b52713084def67d94f7874923baefe04ccf7" "checksum actix-rt 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "168620aaf00fcd2a16e621790abaf180ef7377c2f8355b4ca5775d6afc778ed8" "checksum actix-server 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fb3038e9e457e0a498ea682723e0f4e6cc2c4f362a1868d749808355275ad959" @@ -2792,10 +2782,10 @@ dependencies = [ "checksum actix-web-actors 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "008c1b686048a16fef4ef2fc6b6e5fcf5f29829891ad87fc0848ade26b285627" "checksum actix-web-codegen 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3fe9e3cdec1e645b675f354766e0688c5705021c85ab3cf739be1c8999b91c76" "checksum actix_derive 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0bf5f6d7bf2d220ae8b4a7ae02a572bb35b7c4806b24049af905ab8110de156c" -"checksum adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7e522997b529f05601e05166c07ed17789691f562762c7f3b987263d2dedee5c" +"checksum adler32 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5d2e7343e7fc9de883d1b0341e0b13970f764c14101234857d2ddafa1cb1cac2" "checksum aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "58fb5e95d83b38284460a5fda7d6470aa0b8844d283a0b614b8535e880800d2d" "checksum arc-swap 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)" = "bc4662175ead9cd84451d5c35070517777949a2ed84551764129cedb88384841" -"checksum arc-swap 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "854ede29f7a0ce90519fb2439d030320c6201119b87dab0ee96044603e1130b9" +"checksum arc-swap 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "f1a1eca3195b729bbd64e292ef2f5fff6b1c28504fed762ce2b1013dde4d8e92" "checksum arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0d382e583f07208808f6b1249e60848879ba3543f57c32277bf52d69c2f0f0ee" "checksum arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)" = "b8d73f9beda665eaa98ab9e4f7442bd4e7de6652587de55b2525e52e29c1b0ba" "checksum ascii 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "eab1c04a571841102f5345a8fc0f6bb3d31c315dec879b5c6e42e40ce7ffa34e" @@ -2841,7 +2831,7 @@ dependencies = [ "checksum downcast 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4bb454f0228b18c7f4c3b0ebbee346ed9c52e7443b0999cd543ff3571205701d" "checksum dtoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "ea57b42383d091c85abcc2706240b94ab2a8fa1fc81c10ff23c4de06e2a90b5e" "checksum either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3" -"checksum encoding_rs 0.8.19 (registry+https://github.com/rust-lang/crates.io-index)" = "79906e1ad1f7f8bc48864fcc6ffd58336fb5992e627bf61928099cb25fdf4314" +"checksum encoding_rs 0.8.20 (registry+https://github.com/rust-lang/crates.io-index)" = "87240518927716f79692c2ed85bfe6e98196d18c6401ec75355760233a7e12e9" "checksum enum-as-inner 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3d58266c97445680766be408285e798d3401c6d4c378ec5552e78737e681e37d" "checksum env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "aafcde04e90a5226a6443b7aabdb016ba2f8307c847d524724bd9b346dd1a2d3" "checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" @@ -2925,7 +2915,7 @@ dependencies = [ "checksum predicates-core 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "06075c3a3e92559ff8929e7a280684489ea27fe44805174c3ebd9328dcb37178" "checksum predicates-tree 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8e63c4859013b38a76eca2414c64911fba30def9e3202ac461a2d22831220124" "checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" -"checksum proc-macro2 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e98a83a9f9b331f54b924e68a66acb1bb35cb01fb0a23645139967abefb697e8" +"checksum proc-macro2 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "afdc77cc74ec70ed262262942ebb7dac3d479e9e5cfa2da1841c0806f6cdabcc" "checksum protobuf 2.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "40361836defdd5871ff7e84096c6f6444af7fc157f8ef1789f54f147687caa20" "checksum protobuf-codegen 2.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "12c6abd78435445fc86898ebbd0521a68438063d4a73e23527b7134e6bf58b4a" "checksum protoc 2.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3998c4bc0af8ccbd3cc68245ee9f72663c5ae2fb78bc48ff7719aef11562edea" @@ -2936,7 +2926,7 @@ dependencies = [ "checksum rand 0.3.23 (registry+https://github.com/rust-lang/crates.io-index)" = "64ac302d8f83c0c1974bf758f6b041c6c8ada916fbb44a609158ca8b064cc76c" "checksum rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" "checksum rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" -"checksum rand 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "59cea0d944b32347a1863e95942fd6ebdb486afb4f038119494f2860380c1d51" +"checksum rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3ae1b169243eaf61759b8475a998f0a385e42042370f3a7dbaf35246eacc8412" "checksum rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" "checksum rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "03a2a90da8c7523f554344f921aa97283eadf6ac484a6d2a7d0212fa7f8d6853" "checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" @@ -2972,12 +2962,11 @@ dependencies = [ "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" "checksum serde 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)" = "9dad3f759919b92c3068c696c15c3d17238234498bbdcc80f2c469606f948ac8" -"checksum serde 1.0.100 (registry+https://github.com/rust-lang/crates.io-index)" = "f4473e8506b213730ff2061073b48fa51dcc66349219e2e7c5608f0296a1d95a" +"checksum serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)" = "9796c9b7ba2ffe7a9ce53c2287dfc48080f4b2b362fcc245a259b3a7201119dd" "checksum serde-hjson 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0b833c5ad67d52ced5f5938b2980f32a9c1c5ef047f0b4fb3127e7a423c76153" -"checksum serde_derive 1.0.100 (registry+https://github.com/rust-lang/crates.io-index)" = "11e410fde43e157d789fc290d26bc940778ad0fdd47836426fbac36573710dbb" +"checksum serde_derive 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)" = "4b133a43a1ecd55d4086bd5b4dc6c1751c68b1bfbeba7a5040442022c7e7c02e" "checksum serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)" = "051c49229f282f7c6f3813f8286cc1e3323e8051823fce42c7ea80fe13521704" "checksum serde_test 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)" = "110b3dbdf8607ec493c22d5d947753282f3bae73c0f56d322af1e8c78e4c23d5" -"checksum serde_urlencoded 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "642dd69105886af2efd227f75a520ec9b44a820d65bc133a9131f7d229fd165a" "checksum serde_urlencoded 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9ec5d77e2d4c73717816afac02670d5c4f534ea95ed430442cad02e7a6e32c97" "checksum serde_yaml 0.8.9 (registry+https://github.com/rust-lang/crates.io-index)" = "38b08a9a90e5260fe01c6480ec7c811606df6d3a660415808c3c3fa8ed95b582" "checksum serial_test 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "50bfbc39343545618d97869d77f38ed43e48dd77432717dbc7ed39d797f3ecbe" diff --git a/config.toml b/config.toml index 4ee1ce91b..33d803a99 100644 --- a/config.toml +++ b/config.toml @@ -34,7 +34,7 @@ # Environment variable: MEDEA_SERVER.CONTROL.GRPC.BIND_PORT # # Default: -# bind_port = 50051 +# bind_port = 6565 # Completion queue count of gRPC server. # diff --git a/src/api/control/endpoints/mod.rs b/src/api/control/endpoints/mod.rs index 014b7c18a..afcadf403 100644 --- a/src/api/control/endpoints/mod.rs +++ b/src/api/control/endpoints/mod.rs @@ -7,20 +7,49 @@ pub mod webrtc_publish_endpoint; use std::convert::TryFrom; +use derive_more::{Display, From, Into}; +use serde::Deserialize; + use medea_control_api_proto::grpc::control_api::{ - CreateRequest, Member_Element as MemberElementProto, + CreateRequest_oneof_el as ElementProto, + Member_Element_oneof_el as MemberElementProto, }; use super::{member::MemberElement, TryFromProtobufError}; #[doc(inline)] -pub use webrtc_play_endpoint::WebRtcPlayEndpoint; +pub use webrtc_play_endpoint::{WebRtcPlayEndpoint, WebRtcPlayId}; #[doc(inline)] -pub use webrtc_publish_endpoint::WebRtcPublishEndpoint; +pub use webrtc_publish_endpoint::{WebRtcPublishEndpoint, WebRtcPublishId}; + +/// ID of `Endpoint`. +#[derive( + Clone, Debug, Eq, Hash, Deserialize, PartialEq, From, Display, Into, +)] +pub struct Id(pub String); + +macro_rules! impl_from_into { + ($id:ty) => { + impl std::convert::From for $id { + fn from(id: Id) -> Self { + String::from(id).into() + } + } + + impl std::convert::From<$id> for Id { + fn from(id: $id) -> Self { + String::from(id).into() + } + } + }; +} + +impl_from_into!(WebRtcPublishId); +impl_from_into!(WebRtcPlayId); /// Media element that one or more media data streams flow through. #[derive(Debug)] -pub enum Endpoint { +pub enum EndpointSpec { /// [`WebRtcPublishEndpoint`] element. WebRtcPublish(WebRtcPublishEndpoint), @@ -28,7 +57,7 @@ pub enum Endpoint { WebRtcPlay(WebRtcPlayEndpoint), } -impl Into for Endpoint { +impl Into for EndpointSpec { fn into(self) -> MemberElement { match self { Self::WebRtcPublish(e) => { @@ -41,29 +70,58 @@ impl Into for Endpoint { } } -macro_rules! impl_try_from_proto_for_endpoint { - ($proto:ty) => { - impl TryFrom<$proto> for Endpoint { - type Error = TryFromProtobufError; - - fn try_from(proto: $proto) -> Result { - if proto.has_webrtc_play() { - let play = - WebRtcPlayEndpoint::try_from(proto.get_webrtc_play())?; - Ok(Self::WebRtcPlay(play)) - } else if proto.has_webrtc_pub() { - let publish = - WebRtcPublishEndpoint::from(proto.get_webrtc_pub()); - Ok(Self::WebRtcPublish(publish)) - } else { - // TODO: implement another endpoints when they will be - // implemented - unimplemented!() - } +impl TryFrom<(Id, MemberElementProto)> for EndpointSpec { + type Error = TryFromProtobufError; + + fn try_from(value: (Id, MemberElementProto)) -> Result { + use MemberElementProto::*; + + let id = value.0; + let proto = value.1; + + match proto { + webrtc_play(elem) => { + let play = WebRtcPlayEndpoint::try_from(&elem)?; + Ok(Self::WebRtcPlay(play)) + } + webrtc_pub(elem) => { + let publish = WebRtcPublishEndpoint::from(&elem); + Ok(Self::WebRtcPublish(publish)) + } + hub(_) | file_recorder(_) | relay(_) => { + Err(TryFromProtobufError::UnimplementedEndpoint(id.0)) } } - }; + } } -impl_try_from_proto_for_endpoint!(&MemberElementProto); -impl_try_from_proto_for_endpoint!(&CreateRequest); +impl TryFrom<(Id, ElementProto)> for EndpointSpec { + type Error = TryFromProtobufError; + + fn try_from(value: (Id, ElementProto)) -> Result { + use ElementProto::*; + + let id = value.0; + let proto = value.1; + + match proto { + webrtc_play(elem) => { + let play = WebRtcPlayEndpoint::try_from(&elem)?; + Ok(Self::WebRtcPlay(play)) + } + webrtc_pub(elem) => { + let publish = WebRtcPublishEndpoint::from(&elem); + Ok(Self::WebRtcPublish(publish)) + } + hub(_) | file_recorder(_) | relay(_) => { + Err(TryFromProtobufError::UnimplementedEndpoint(id.0)) + } + member(_) | room(_) => { + Err(TryFromProtobufError::ExpectedOtherElement( + String::from("Endpoint"), + id.0, + )) + } + } + } +} diff --git a/src/api/control/endpoints/webrtc_play_endpoint.rs b/src/api/control/endpoints/webrtc_play_endpoint.rs index 887c5a2ab..b24069e62 100644 --- a/src/api/control/endpoints/webrtc_play_endpoint.rs +++ b/src/api/control/endpoints/webrtc_play_endpoint.rs @@ -4,7 +4,7 @@ use std::{convert::TryFrom, fmt}; -use derive_more::{Display, From}; +use derive_more::{Display, From, Into}; use failure::Fail; use medea_control_api_proto::grpc as medea_grpc; use medea_grpc::control_api::WebRtcPlayEndpoint as WebRtcPlayEndpointProto; @@ -20,8 +20,10 @@ use crate::api::control::{ }; /// ID of [`WebRtcPlayEndpoint`]. -#[derive(Clone, Debug, Deserialize, Display, Eq, Hash, PartialEq, From)] -pub struct WebRtcPlayId(pub String); +#[derive( + Clone, Debug, Deserialize, Display, Eq, Hash, PartialEq, From, Into, +)] +pub struct WebRtcPlayId(String); /// Media element which is able to play media data for client via WebRTC. #[allow(clippy::module_name_repetitions)] @@ -36,7 +38,7 @@ impl TryFrom<&WebRtcPlayEndpointProto> for WebRtcPlayEndpoint { fn try_from(value: &WebRtcPlayEndpointProto) -> Result { Ok(Self { - src: SrcUri::try_from(value.get_src())?, + src: SrcUri::try_from(value.get_src().to_owned())?, }) } } @@ -52,8 +54,8 @@ pub enum SrcParseError { /// Error from [`LocalUri`] parser. This is general errors for [`SrcUri`] /// parsing because [`SrcUri`] parses with [`LocalUri`] parser. - #[display(fmt = "Local URI '{}' parse error: {:?}", _0, _1)] - LocalUriParseError(String, LocalUriParseError), + #[display(fmt = "Local URI parse error: {:?}", _0)] + LocalUriParseError(LocalUriParseError), } /// Special URI with pattern `local://{room_id}/{member_id}/{endpoint_id}`. @@ -89,32 +91,33 @@ pub struct SrcUri { pub endpoint_id: WebRtcPublishId, } -impl TryFrom<&str> for SrcUri { +impl TryFrom for SrcUri { type Error = SrcParseError; - fn try_from(value: &str) -> Result { - let local_uri = StatefulLocalUri::try_from(value).map_err(|e| { - SrcParseError::LocalUriParseError(value.to_string(), e) - })?; + fn try_from(value: String) -> Result { + let local_uri = StatefulLocalUri::try_from(value) + .map_err(SrcParseError::LocalUriParseError)?; - if let StatefulLocalUri::Endpoint(endpoint_uri) = local_uri { - Ok(endpoint_uri.into()) - } else { - Err(SrcParseError::NotSrcUri(value.to_string())) + match local_uri { + StatefulLocalUri::Room(uri) => { + Err(SrcParseError::NotSrcUri(uri.to_string())) + } + StatefulLocalUri::Member(uri) => { + Err(SrcParseError::NotSrcUri(uri.to_string())) + } + StatefulLocalUri::Endpoint(uri) => Ok(uri.into()), } } } impl From> for SrcUri { fn from(uri: LocalUri) -> Self { - let (endpoint_id, member_uri) = uri.take_endpoint_id(); - let (member_id, room_uri) = member_uri.take_member_id(); - let room_id = room_uri.take_room_id(); + let (room_id, member_id, endpoint_id) = uri.take_all(); Self { room_id, member_id, - endpoint_id: WebRtcPublishId(endpoint_id), + endpoint_id: endpoint_id.into(), } } } @@ -145,7 +148,7 @@ impl<'de> Deserialize<'de> for SrcUri { where E: de::Error, { - match SrcUri::try_from(value) { + match SrcUri::try_from(value.to_owned()) { Ok(src_uri) => Ok(src_uri), Err(e) => Err(Error::custom(e)), } diff --git a/src/api/control/endpoints/webrtc_publish_endpoint.rs b/src/api/control/endpoints/webrtc_publish_endpoint.rs index b69912e58..f3e3a2cb0 100644 --- a/src/api/control/endpoints/webrtc_publish_endpoint.rs +++ b/src/api/control/endpoints/webrtc_publish_endpoint.rs @@ -2,7 +2,7 @@ //! //! [Control API]: http://tiny.cc/380uaz -use derive_more::{Display, From}; +use derive_more::{Display, From, Into}; use serde::Deserialize; use medea_control_api_proto::grpc::control_api::{ @@ -11,8 +11,10 @@ use medea_control_api_proto::grpc::control_api::{ }; /// ID of [`WebRtcPublishEndpoint`]. -#[derive(Clone, Debug, Deserialize, Display, Eq, Hash, PartialEq, From)] -pub struct WebRtcPublishId(pub String); +#[derive( + Clone, Debug, Deserialize, Display, Eq, Hash, PartialEq, From, Into, +)] +pub struct WebRtcPublishId(String); /// Peer-to-peer mode of [`WebRtcPublishEndpoint`]. #[derive(Clone, Deserialize, Debug)] diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index eaf52f6ea..61f2c15de 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -2,9 +2,6 @@ //! //! [Control API]: http://tiny.cc/380uaz -// Fix clippy's needless_return bug in try_fut! macro. -#![allow(clippy::needless_return)] - use std::{collections::HashMap, convert::TryFrom, sync::Arc}; use actix::{ @@ -30,9 +27,9 @@ use crate::{ control::{ local_uri::{ LocalUri, LocalUriParseError, StatefulLocalUri, ToEndpoint, - ToMember, ToRoom, + ToMember, }, - Endpoint, MemberId, MemberSpec, RoomId, RoomSpec, + EndpointSpec, MemberId, MemberSpec, RoomId, RoomSpec, TryFromElementError, TryFromProtobufError, }, error_codes::{ErrorCode, ErrorResponse}, @@ -158,27 +155,20 @@ impl ControlApiService { /// Implementation of `Create` method for [`Room`]. fn create_room( &self, - req: &CreateRequest, - uri: LocalUri, + spec: RoomSpec, ) -> impl Future { - let spec = fut_try!(RoomSpec::try_from_protobuf( - uri.room_id().clone(), - req.get_room() - )); - let sid: Sids = fut_try!(spec.members()) .iter() - .map(|(id, member)| { + .map(|(member_id, member)| { let uri = - self.get_sid(uri.room_id(), &id, member.credentials()); - - (id.clone().to_string(), uri) + self.get_sid(spec.id(), &member_id, member.credentials()); + (member_id.clone().to_string(), uri) }) .collect(); Either::A( self.room_service - .send(CreateRoom { uri, spec }) + .send(CreateRoom { spec }) .map_err(GrpcControlApiError::RoomServiceMailboxError) .and_then(move |r| { r.map_err(GrpcControlApiError::from).map(|_| sid) @@ -189,106 +179,95 @@ impl ControlApiService { /// Implementation of `Create` method for [`Member`] element. fn create_member( &self, - req: &CreateRequest, uri: LocalUri, + spec: MemberSpec, ) -> impl Future { - let spec = fut_try!(MemberSpec::try_from(req.get_member())); - let sid = self.get_sid(uri.room_id(), uri.member_id(), spec.credentials()); let mut sids = HashMap::new(); sids.insert(uri.member_id().to_string(), sid); - Either::A( - self.room_service - .send(CreateMemberInRoom { uri, spec }) - .map_err(GrpcControlApiError::RoomServiceMailboxError) - .and_then(|r| { - r.map_err(GrpcControlApiError::from).map(|_| sids) - }), - ) + self.room_service + .send(CreateMemberInRoom { uri, spec }) + .map_err(GrpcControlApiError::RoomServiceMailboxError) + .and_then(|r| r.map_err(GrpcControlApiError::from).map(|_| sids)) } /// Implementation of `Create` method for [`Endpoint`] elements. fn create_endpoint( &self, - req: &CreateRequest, uri: LocalUri, + spec: EndpointSpec, ) -> impl Future { - let spec = fut_try!(Endpoint::try_from(req)); - - Either::A( - self.room_service - .send(CreateEndpointInRoom { uri, spec }) - .map_err(GrpcControlApiError::RoomServiceMailboxError) - .and_then(|r| { - r.map_err(GrpcControlApiError::from).map(|_| HashMap::new()) - }), - ) + self.room_service + .send(CreateEndpointInRoom { uri, spec }) + .map_err(GrpcControlApiError::RoomServiceMailboxError) + .and_then(|r| { + r.map_err(GrpcControlApiError::from).map(|_| HashMap::new()) + }) } + /// Creates element based on provided pub fn create_element( &self, - req: &CreateRequest, + mut req: CreateRequest, ) -> Box + Send> { - let uri = match StatefulLocalUri::try_from(req.get_id().as_ref()) { + let uri = match StatefulLocalUri::try_from(req.take_id()) { Ok(uri) => uri, Err(e) => { return Box::new(future::err(e.into())); } }; + let elem = if let Some(elem) = req.el { + elem + } else { + return Box::new(future::err(ErrorResponse::new( + ErrorCode::NoElement, + &uri, + ))); + }; + match uri { - StatefulLocalUri::Room(local_uri) => { - if req.has_room() { - Box::new( - self.create_room(&req, local_uri) - .map_err(|err| err.into()), - ) - } else { - Box::new(future::err(ErrorResponse::new( - ErrorCode::ElementIdForRoomButElementIsNot, - &req.get_id(), - ))) - } - } - StatefulLocalUri::Member(local_uri) => { - if req.has_member() { - Box::new( - self.create_member(&req, local_uri) - .map_err(|err| err.into()), - ) - } else { - Box::new(future::err(ErrorResponse::new( - ErrorCode::ElementIdForMemberButElementIsNot, - &req.get_id(), - ))) - } - } - StatefulLocalUri::Endpoint(local_uri) => { - if req.has_webrtc_pub() || req.has_webrtc_play() { - Box::new( - self.create_endpoint(&req, local_uri) - .map_err(|err| err.into()), - ) - } else { - Box::new(future::err(ErrorResponse::new( - ErrorCode::ElementIdForEndpointButElementIsNot, - &req.get_id(), - ))) - } - } + StatefulLocalUri::Room(uri) => Box::new( + RoomSpec::try_from((uri.take_room_id(), elem)) + .map_err(ErrorResponse::from) + .map(|spec| { + self.create_room(spec).map_err(ErrorResponse::from) + }) + .into_future() + .and_then(|create_result| create_result), + ), + StatefulLocalUri::Member(uri) => Box::new( + MemberSpec::try_from((uri.member_id().clone(), elem)) + .map_err(ErrorResponse::from) + .map(|spec| { + self.create_member(uri, spec) + .map_err(ErrorResponse::from) + }) + .into_future() + .and_then(|create_result| create_result), + ), + StatefulLocalUri::Endpoint(uri) => Box::new( + EndpointSpec::try_from((uri.endpoint_id().clone(), elem)) + .map_err(ErrorResponse::from) + .map(|spec| { + self.create_endpoint(uri, spec) + .map_err(ErrorResponse::from) + }) + .into_future() + .and_then(|create_result| create_result), + ), } } pub fn delete_element( &self, - req: &IdRequest, + mut req: IdRequest, ) -> impl Future { let mut delete_elements_msg = DeleteElements::new(); - - for id in req.get_id() { - match StatefulLocalUri::try_from(id.as_str()) { + for id in req.take_id().into_iter() { + match StatefulLocalUri::try_from(id) { Ok(uri) => { delete_elements_msg.add_uri(uri); } @@ -298,33 +277,31 @@ impl ControlApiService { } } - let room_service = Addr::clone(&self.room_service); future::Either::B( delete_elements_msg .validate() - .into_future() .map_err(ErrorResponse::from) - .and_then(move |del_msg| { - room_service.send(del_msg).map_err(|err| { + .map(|msg| self.room_service.send(msg)) + .into_future() + .and_then(move |delete_result| { + delete_result.map_err(|err| { ErrorResponse::from( GrpcControlApiError::RoomServiceMailboxError(err), ) }) }) - .and_then(|delete_result| { - delete_result.map_err(ErrorResponse::from) - }), + .and_then(|result| result.map_err(ErrorResponse::from)), ) } pub fn get_element( &self, - req: &IdRequest, + mut req: IdRequest, ) -> impl Future, Error = ErrorResponse> { let mut uris = Vec::new(); - for id in req.get_id() { - match StatefulLocalUri::try_from(id.as_str()) { + for id in req.take_id().into_iter() { + match StatefulLocalUri::try_from(id) { Ok(uri) => { uris.push(uri); } @@ -361,7 +338,7 @@ impl ControlApi for ControlApiService { sink: UnarySink, ) { ctx.spawn( - self.create_element(&req) + self.create_element(req) .then(move |result| { let mut response = CreateResponse::new(); match result { @@ -421,7 +398,7 @@ impl ControlApi for ControlApiService { sink: UnarySink, ) { ctx.spawn( - self.delete_element(&req) + self.delete_element(req) .then(move |result| { let mut response = Response::new(); if let Err(e) = result { @@ -449,7 +426,7 @@ impl ControlApi for ControlApiService { sink: UnarySink, ) { ctx.spawn( - self.get_element(&req) + self.get_element(req) .then(|result| { let mut response = GetResponse::new(); match result { diff --git a/src/api/control/local_uri.rs b/src/api/control/local_uri.rs index 83fb78d7b..33da16b0e 100644 --- a/src/api/control/local_uri.rs +++ b/src/api/control/local_uri.rs @@ -11,7 +11,7 @@ use url::Url; use crate::api::control::endpoints::webrtc_play_endpoint::SrcUri; -use super::{MemberId, RoomId}; +use super::{EndpointId, MemberId, RoomId}; /// State of [`LocalUri`] which points to [`Room`]. /// @@ -29,7 +29,7 @@ pub struct ToMember(LocalUri, MemberId); /// /// [`Endpoint`]: crate::signalling::elements::endpoints::Endpoint #[derive(Clone, Debug, Eq, Hash, PartialEq)] -pub struct ToEndpoint(LocalUri, String); +pub struct ToEndpoint(LocalUri, EndpointId); /// URI in format `local://room_id/member_id/endpoint_id`. /// @@ -116,6 +116,23 @@ impl LocalUri { } } +impl From for LocalUri { + fn from(from: StatefulLocalUri) -> Self { + match from { + StatefulLocalUri::Room(uri) => uri, + StatefulLocalUri::Member(uri) => { + let (_, uri) = uri.take_member_id(); + uri + } + StatefulLocalUri::Endpoint(uri) => { + let (_, uri) = uri.take_endpoint_id(); + let (_, uri) = uri.take_member_id(); + uri + } + } + } +} + impl LocalUri { /// Create new [`LocalUri`] in [`ToMember`] state. pub fn new(room_id: RoomId, member_id: MemberId) -> Self { @@ -141,11 +158,21 @@ impl LocalUri { /// Push endpoint ID to the end of URI and returns /// [`LocalUri`] in [`ToEndpoint`] state. - pub fn push_endpoint_id(self, endpoint_id: String) -> LocalUri { + pub fn push_endpoint_id( + self, + endpoint_id: EndpointId, + ) -> LocalUri { let (member_id, room_uri) = self.take_member_id(); let room_id = room_uri.take_room_id(); LocalUri::::new(room_id, member_id, endpoint_id) } + + /// Returns [`RoomId`] and [`MemberId`]. + pub fn take_all(self) -> (RoomId, MemberId) { + let (member_id, room_url) = self.take_member_id(); + + (room_url.take_room_id(), member_id) + } } impl LocalUri { @@ -153,7 +180,7 @@ impl LocalUri { pub fn new( room_id: RoomId, member_id: MemberId, - endpoint_id: String, + endpoint_id: EndpointId, ) -> Self { Self { state: ToEndpoint( @@ -173,19 +200,25 @@ impl LocalUri { &self.state.0.member_id() } - /// Returns reference to [`Endpoint`] ID. - /// - /// [`Endpoint`]: crate::signalling::elements::endpoints::Endpoint - pub fn endpoint_id(&self) -> &str { + /// Returns reference to [`EndpointId`]. + pub fn endpoint_id(&self) -> &EndpointId { &self.state.1 } /// Returns [`Endpoint`] id and [`LocalUri`] in [`ToMember`] state. /// /// [`Endpoint`]: crate::signalling::elements::endpoints::Endpoint - pub fn take_endpoint_id(self) -> (String, LocalUri) { + pub fn take_endpoint_id(self) -> (EndpointId, LocalUri) { (self.state.1, self.state.0) } + + /// Returns [`EndpointId`], [`RoomId`] and [`MemberId`]. + pub fn take_all(self) -> (RoomId, MemberId, EndpointId) { + let (endpoint_id, member_url) = self.take_endpoint_id(); + let (member_id, room_url) = member_url.take_member_id(); + + (room_url.take_room_id(), member_id, endpoint_id) + } } impl From for LocalUri { @@ -193,7 +226,7 @@ impl From for LocalUri { LocalUri::::new( uri.room_id, uri.member_id, - uri.endpoint_id.0, + uri.endpoint_id.into(), ) } } @@ -272,30 +305,36 @@ impl StatefulLocalUri { } } -impl TryFrom<&str> for StatefulLocalUri { +impl TryFrom for StatefulLocalUri { type Error = LocalUriParseError; - fn try_from(value: &str) -> Result { + fn try_from(value: String) -> Result { if value.is_empty() { return Err(LocalUriParseError::Empty); } - let url = Url::parse(value).map_err(|e| { - LocalUriParseError::UrlParseErr(value.to_string(), e) - })?; + let url = match Url::parse(&value) { + Ok(url) => url, + Err(err) => { + return Err(LocalUriParseError::UrlParseErr(value, err)) + } + }; if url.scheme() != "local" { - return Err(LocalUriParseError::NotLocal(value.to_string())); + return Err(LocalUriParseError::NotLocal(value)); } - let room_uri = url - .host() - .map(|id| id.to_string()) - .filter(|id| !id.is_empty()) - .map(|id| LocalUri::::new(id.into())) - .ok_or_else(|| { - LocalUriParseError::MissingPaths(value.to_string()) - })?; + let room_uri = match url.host() { + Some(host) => { + let host = host.to_string(); + if host.is_empty() { + return Err(LocalUriParseError::MissingPaths(value)); + } else { + LocalUri::::new(host.into()) + } + } + None => return Err(LocalUriParseError::MissingPaths(value)), + }; let mut path = match url.path_segments() { Some(path) => path, @@ -313,18 +352,18 @@ impl TryFrom<&str> for StatefulLocalUri { .map(ToString::to_string); if path.next().is_some() { - return Err(LocalUriParseError::TooManyPaths(value.to_string())); + return Err(LocalUriParseError::TooManyPaths(value)); } if let Some(member_id) = member_id { let member_uri = room_uri.push_member_id(member_id); if let Some(endpoint_id) = endpoint_id { - Ok(member_uri.push_endpoint_id(endpoint_id).into()) + Ok(member_uri.push_endpoint_id(endpoint_id.into()).into()) } else { Ok(member_uri.into()) } } else if endpoint_id.is_some() { - Err(LocalUriParseError::MissingPaths(value.to_string())) + Err(LocalUriParseError::MissingPaths(value)) } else { Ok(room_uri.into()) } @@ -337,7 +376,9 @@ mod tests { #[test] fn parse_local_uri_to_room_element() { - let local_uri = StatefulLocalUri::try_from("local://room_id").unwrap(); + let local_uri = + StatefulLocalUri::try_from(String::from("local://room_id")) + .unwrap(); if let StatefulLocalUri::Room(room) = local_uri { assert_eq!(room.take_room_id(), RoomId("room_id".to_string())); } else { @@ -351,9 +392,10 @@ mod tests { #[test] fn parse_local_uri_to_element_of_room() { - let local_uri = - StatefulLocalUri::try_from("local://room_id/room_element_id") - .unwrap(); + let local_uri = StatefulLocalUri::try_from(String::from( + "local://room_id/room_element_id", + )) + .unwrap(); if let StatefulLocalUri::Member(member) = local_uri { let (element_id, room_uri) = member.take_member_id(); assert_eq!(element_id, MemberId("room_element_id".to_string())); @@ -370,13 +412,13 @@ mod tests { #[test] fn parse_local_uri_to_endpoint() { - let local_uri = StatefulLocalUri::try_from( + let local_uri = StatefulLocalUri::try_from(String::from( "local://room_id/room_element_id/endpoint_id", - ) + )) .unwrap(); if let StatefulLocalUri::Endpoint(endpoint) = local_uri { let (endpoint_id, member_uri) = endpoint.take_endpoint_id(); - assert_eq!(endpoint_id, "endpoint_id".to_string()); + assert_eq!(endpoint_id, String::from("endpoint_id").into()); let (member_id, room_uri) = member_uri.take_member_id(); assert_eq!(member_id, MemberId("room_element_id".to_string())); let room_id = room_uri.take_room_id(); @@ -392,7 +434,7 @@ mod tests { #[test] fn returns_parse_error_if_local_uri_not_local() { - match StatefulLocalUri::try_from("not-local://room_id") { + match StatefulLocalUri::try_from(String::from("not-local://room_id")) { Ok(_) => unreachable!(), Err(e) => match e { LocalUriParseError::NotLocal(_) => (), @@ -403,55 +445,53 @@ mod tests { #[test] fn returns_parse_error_if_local_uri_empty() { - match StatefulLocalUri::try_from("") { + match StatefulLocalUri::try_from(String::from("")) { Ok(_) => unreachable!(), Err(e) => match e { LocalUriParseError::Empty => (), - _ => unreachable!("Unreachable LocalUriParseError: {:?}", e), + _ => unreachable!(), }, } } #[test] fn returns_error_if_local_uri_have_too_many_paths() { - match StatefulLocalUri::try_from( + match StatefulLocalUri::try_from(String::from( "local://room/member/endpoint/too_many", - ) { + )) { Ok(_) => unreachable!(), Err(e) => match e { LocalUriParseError::TooManyPaths(_) => (), - _ => unreachable!("Unreachable LocalUriParseError: {:?}", e), + _ => unreachable!(), }, } } #[test] fn properly_serialize() { - for local_uri_str in &[ - "local://room_id", - "local://room_id/member_id", - "local://room_id/member_id/endpoint_id", + for local_uri_str in vec![ + String::from("local://room_id"), + String::from("local://room_id/member_id"), + String::from("local://room_id/member_id/endpoint_id"), ] { - let local_uri = StatefulLocalUri::try_from(*local_uri_str).unwrap(); + let local_uri = + StatefulLocalUri::try_from(local_uri_str.clone()).unwrap(); assert_eq!(local_uri_str.to_string(), local_uri.to_string()); } } #[test] fn return_error_when_local_uri_not_full() { - for local_uri_str in &[ - "local://room_id//endpoint_id", - "local:////endpoint_id", - "local:///member_id/endpoint_id", + for local_uri_str in vec![ + String::from("local://room_id//endpoint_id"), + String::from("local:////endpoint_id"), + String::from("local:///member_id/endpoint_id"), ] { - match StatefulLocalUri::try_from(*local_uri_str) { - Ok(_) => unreachable!(local_uri_str), + match StatefulLocalUri::try_from(local_uri_str) { + Ok(_) => unreachable!(), Err(e) => match e { LocalUriParseError::MissingPaths(_) => (), - _ => unreachable!( - "Unreachable LocalUriParseError {:?} for uri '{}'", - e, local_uri_str - ), + _ => unreachable!(), }, } } diff --git a/src/api/control/member.rs b/src/api/control/member.rs index f8e7337f6..faf83cb79 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -5,7 +5,10 @@ use std::{collections::HashMap, convert::TryFrom}; use derive_more::{Display, From}; -use medea_control_api_proto::grpc::control_api::Member as MemberProto; +use medea_control_api_proto::grpc::control_api::{ + CreateRequest_oneof_el as ElementProto, + Room_Element_oneof_el as RoomElementProto, +}; use rand::{distributions::Alphanumeric, Rng}; use serde::Deserialize; @@ -16,7 +19,8 @@ use crate::api::control::{ }, pipeline::Pipeline, room::RoomElement, - Endpoint, TryFromElementError, TryFromProtobufError, WebRtcPlayId, + EndpointId, EndpointSpec, TryFromElementError, TryFromProtobufError, + WebRtcPlayId, }; const CREDENTIALS_LEN: usize = 32; @@ -50,7 +54,7 @@ pub enum MemberElement { #[derive(Clone, Debug)] pub struct MemberSpec { /// Spec of this `Member`. - pipeline: Pipeline, + pipeline: Pipeline, /// Credentials to authorize `Member` with. credentials: String, @@ -72,7 +76,7 @@ impl MemberSpec { ) -> impl Iterator { self.pipeline.iter().filter_map(|(id, e)| match e { MemberElement::WebRtcPlayEndpoint { spec } => { - Some((WebRtcPlayId(id.clone()), spec)) + Some((id.clone().into(), spec)) } _ => None, }) @@ -81,9 +85,9 @@ impl MemberSpec { /// Lookups [`WebRtcPublishEndpoint`] by ID. pub fn get_publish_endpoint_by_id( &self, - id: &WebRtcPublishId, + id: WebRtcPublishId, ) -> Option<&WebRtcPublishEndpoint> { - let e = self.pipeline.get(&id.0)?; + let e = self.pipeline.get(&id.into())?; if let MemberElement::WebRtcPublishEndpoint { spec } = e { Some(spec) } else { @@ -97,7 +101,7 @@ impl MemberSpec { ) -> impl Iterator { self.pipeline.iter().filter_map(|(id, e)| match e { MemberElement::WebRtcPublishEndpoint { spec } => { - Some((WebRtcPublishId(id.clone()), spec)) + Some((id.clone().into(), spec)) } _ => None, }) @@ -122,37 +126,55 @@ fn generate_member_credentials() -> String { .collect() } -impl TryFrom<&MemberProto> for MemberSpec { - type Error = TryFromProtobufError; - - /// Deserializes [`MemberSpec`] from protobuf object. - /// - /// Additionally generates [`Member`] credentials if - /// they not provided in protobuf object. - /// - /// [`Member`]: crate::signalling::elements::member::Member - fn try_from(value: &MemberProto) -> Result { - let mut pipeline = HashMap::new(); - for (id, member_element) in value.get_pipeline() { - let endpoint = Endpoint::try_from(member_element)?; - pipeline.insert(id.clone(), endpoint.into()); +macro_rules! impl_try_from_proto_for_member { + ($proto:tt) => { + impl TryFrom<(Id, $proto)> for MemberSpec { + type Error = TryFromProtobufError; + + fn try_from(value: (Id, $proto)) -> Result { + let id = value.0; + let proto = value.1; + + match proto { + $proto::member(mut member) => { + let mut pipeline = HashMap::new(); + for (id, member_element) in member.take_pipeline() { + if let Some(elem) = member_element.el { + let endpoint = EndpointSpec::try_from(( + EndpointId(id.clone()), + elem, + ))?; + pipeline.insert(id.into(), endpoint.into()); + } else { + return Err( + TryFromProtobufError::EmptyElement(id), + ); + } + } + + let mut credentials = member.take_credentials(); + if credentials.is_empty() { + credentials = generate_member_credentials(); + } + + Ok(Self { + pipeline: Pipeline::new(pipeline), + credentials, + }) + } + _ => Err(TryFromProtobufError::ExpectedOtherElement( + String::from("Member"), + id.to_string(), + )), + } + } } - let pipeline = Pipeline::new(pipeline); - - let proto_credentials = value.get_credentials(); - let credentials = if proto_credentials.is_empty() { - generate_member_credentials() - } else { - proto_credentials.to_string() - }; - - Ok(Self { - pipeline, - credentials, - }) - } + }; } +impl_try_from_proto_for_member!(RoomElementProto); +impl_try_from_proto_for_member!(ElementProto); + impl TryFrom<&RoomElement> for MemberSpec { type Error = TryFromElementError; diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index 3bd8e607b..82f340da8 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -32,7 +32,8 @@ use self::{ pub use self::{ endpoints::{ webrtc_play_endpoint::WebRtcPlayId, - webrtc_publish_endpoint::WebRtcPublishId, Endpoint, + webrtc_publish_endpoint::WebRtcPublishId, EndpointSpec, + Id as EndpointId, }, member::{Id as MemberId, MemberSpec}, room::{Id as RoomId, RoomElement, RoomSpec}, @@ -58,6 +59,17 @@ pub enum TryFromProtobufError { _0 )] NotMemberElementInRoomElement(String), + + /// `Room` element doesn't have `Member` element. Currently this is + /// unimplemented. + #[display(fmt = "Expected element of type [{}]. Id [{}]", _0, _1)] + ExpectedOtherElement(String, String), + + #[display(fmt = "Element is None, expected Some. Id [{}]", _0)] + EmptyElement(String), + + #[display(fmt = "Endpoint is unimplemented. Id [{}]", _0)] + UnimplementedEndpoint(String), } impl From for TryFromProtobufError { @@ -76,7 +88,7 @@ pub enum RootElement { /// Can transform into [`RoomSpec`] by `RoomSpec::try_from`. Room { id: RoomId, - spec: Pipeline, + spec: Pipeline, }, } diff --git a/src/api/control/pipeline.rs b/src/api/control/pipeline.rs index 205227a3b..ec6fdd4d8 100644 --- a/src/api/control/pipeline.rs +++ b/src/api/control/pipeline.rs @@ -4,6 +4,7 @@ use std::{ collections::{hash_map::Iter, HashMap}, + hash::Hash, iter::IntoIterator, }; @@ -11,32 +12,32 @@ use serde::Deserialize; /// Entity that represents some pipeline of spec. #[derive(Clone, Deserialize, Debug)] -pub struct Pipeline { - pipeline: HashMap, +pub struct Pipeline { + pipeline: HashMap, } -impl Pipeline { +impl Pipeline { /// Creates new [`Pipeline`] from provided [`HashMap`]. - pub fn new(pipeline: HashMap) -> Self { + pub fn new(pipeline: HashMap) -> Self { Self { pipeline } } /// Iterates over pipeline by reference. #[inline] - pub fn iter(&self) -> impl Iterator { + pub fn iter(&self) -> impl Iterator { self.into_iter() } /// Lookups element of [`Pipeline`] by ID. #[inline] - pub fn get(&self, id: &str) -> Option<&T> { + pub fn get(&self, id: &K) -> Option<&V> { self.pipeline.get(id) } } -impl<'a, T> IntoIterator for &'a Pipeline { - type IntoIter = Iter<'a, String, T>; - type Item = (&'a String, &'a T); +impl<'a, K: Eq + Hash, V> IntoIterator for &'a Pipeline { + type IntoIter = Iter<'a, K, V>; + type Item = (&'a K, &'a V); #[inline] fn into_iter(self) -> Self::IntoIter { diff --git a/src/api/control/room.rs b/src/api/control/room.rs index d8f7c5f36..dcc362308 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -5,10 +5,13 @@ use std::{collections::HashMap, convert::TryFrom}; use derive_more::{Display, From}; -use medea_control_api_proto::grpc::control_api::Room as RoomProto; +#[rustfmt::skip] +use medea_control_api_proto::grpc::control_api::{ + CreateRequest_oneof_el as ElementProto +}; use serde::Deserialize; -use crate::api::control::TryFromProtobufError; +use crate::api::control::{EndpointId, TryFromProtobufError}; use super::{ member::{MemberElement, MemberSpec}, @@ -32,7 +35,7 @@ pub enum RoomElement { /// Represent [`MemberSpec`]. /// Can transform into [`MemberSpec`] by `MemberSpec::try_from`. Member { - spec: Pipeline, + spec: Pipeline, credentials: String, }, } @@ -46,33 +49,41 @@ pub enum RoomElement { #[derive(Clone, Debug)] pub struct RoomSpec { pub id: Id, - pub pipeline: Pipeline, + pub pipeline: Pipeline, } -impl RoomSpec { - /// Deserializes [`RoomSpec`] from protobuf object. - pub fn try_from_protobuf( - id: Id, - proto: &RoomProto, - ) -> Result { - let mut pipeline = HashMap::new(); - for (id, room_element) in proto.get_pipeline() { - if !room_element.has_member() { - return Err( - TryFromProtobufError::NotMemberElementInRoomElement( - id.to_string(), - ), - ); +impl TryFrom<(Id, ElementProto)> for RoomSpec { + type Error = TryFromProtobufError; + + fn try_from(value: (Id, ElementProto)) -> Result { + let id = value.0; + let proto = value.1; + + match proto { + ElementProto::room(mut room) => { + let mut pipeline = HashMap::new(); + for (id, room_element) in room.take_pipeline() { + if let Some(elem) = room_element.el { + let member = + MemberSpec::try_from((MemberId(id.clone()), elem))?; + pipeline.insert(id.into(), member.into()); + } else { + return Err(TryFromProtobufError::EmptyElement(id)); + } + } + + let pipeline = Pipeline::new(pipeline); + Ok(Self { id, pipeline }) } - let member = MemberSpec::try_from(room_element.get_member())?; - pipeline.insert(id.clone(), member.into()); + _ => Err(TryFromProtobufError::ExpectedOtherElement( + String::from("Room"), + id.to_string(), + )), } - - let pipeline = Pipeline::new(pipeline); - - Ok(Self { pipeline, id }) } +} +impl RoomSpec { /// Returns all [`MemberSpec`]s of this [`RoomSpec`]. pub fn members( &self, @@ -80,9 +91,8 @@ impl RoomSpec { let mut members: HashMap = HashMap::new(); for (control_id, element) in self.pipeline.iter() { let member_spec = MemberSpec::try_from(element)?; - let member_id = MemberId(control_id.clone()); - members.insert(member_id.clone(), member_spec); + members.insert(control_id.clone(), member_spec); } Ok(members) diff --git a/src/api/error_codes.rs b/src/api/error_codes.rs index 59d8e1ea4..90d311158 100644 --- a/src/api/error_codes.rs +++ b/src/api/error_codes.rs @@ -1,12 +1,8 @@ //! All errors which medea can return to control API user. //! //! # Error codes ranges -//! - `1000` ... `1000` Unexpected server error -//! - `1001` ... `1099` Not found errors -//! - `1100` ... `1199` Spec errors -//! - `1200` ... `1299` Parse errors -//! - `1300` ... `1399` Conflicts -//! - `1400` ... `1499` Misc errors +//! - `1000` ... `1999` Client errors +//! - `2000` ... `2999` Server errors use std::string::ToString; @@ -130,171 +126,143 @@ impl Into for ErrorResponse { /// [Control API]: http://tiny.cc/380uaz #[derive(Debug, Display)] pub enum ErrorCode { - /// Unexpected server error. + /// Unimplemented API call. /// - /// Use this [`ErrorCode`] only with [`ErrorResponse::unexpected`] - /// function. In error text with this code should be error message - /// which explain what exactly goes wrong - /// ([`ErrorResponse::unexpected`] do this). + /// This code should be with additional text which explains what + /// exactly unimplemented (you can do it with + /// [`ErrorResponse::with_explanation`] function). /// /// Code: __1000__. - #[display(fmt = "Unexpected error happened.")] - UnexpectedError = 1000, + #[display(fmt = "Unimplemented API call.")] + UnimplementedCall = 1000, - //////////////////////////////////// - // Not found (1001 - 1099 codes) // - ////////////////////////////////// - /// Publish endpoint not found. + /// Request does not contain any elements. /// /// Code: __1001__. - #[display(fmt = "Publish endpoint not found.")] - PublishEndpointNotFound = 1001, - /// Play endpoint not found. + #[display(fmt = "Request does not contain any elements")] + NoElement = 1001, + + /// Provided uri can not point to provided element. /// /// Code: __1002__. - #[display(fmt = "Play endpoint not found.")] - PlayEndpointNotFound = 1002, - /// Member not found. + #[display(fmt = "Provided uri can not point to provided element")] + ElementIdMismatch = 1002, + + /// Room not found. /// /// Code: __1003__. - #[display(fmt = "Member not found.")] - MemberNotFound = 1003, - /// Room not found. + #[display(fmt = "Room not found.")] + RoomNotFound = 1003, + + /// Member not found. /// /// Code: __1004__. - #[display(fmt = "Room not found.")] - RoomNotFound = 1004, + #[display(fmt = "Member not found.")] + MemberNotFound = 1004, + /// Endpoint not found. /// /// Code: __1005__. #[display(fmt = "Endpoint not found.")] EndpointNotFound = 1005, - /// Room not found for provided element. - /// - /// Code: __1006__. - #[display(fmt = "Room not found for provided element.")] - RoomNotFoundForProvidedElement = 1006, - ////////////////////////////////////// - // Spec errors (1100 - 1199 codes) // - //////////////////////////////////// /// Medea expects `Room` element in pipeline but received not him. /// - /// Code: __1100__. + /// Code: __1006__. #[display(fmt = "Expecting Room element but it's not.")] - NotRoomInSpec = 1100, + NotRoomInSpec = 1006, + /// Medea expects `Member` element in pipeline but received not him. /// - /// Code: __1101__. + /// Code: __1007__. #[display(fmt = "Expected Member element but it's not.")] - NotMemberInSpec = 1101, + NotMemberInSpec = 1007, + /// Invalid source URI in play endpoint. /// - /// Code: __1102__. + /// Code: __1008__. #[display(fmt = "Invalid source ID in publish endpoint spec.")] - InvalidSrcUri = 1102, - /// Provided element ID to Room element but element spec is not for Room. - /// - /// Code: __1103__. - #[display( - fmt = "You provided URI to Room but element's spec is not for Room." - )] - ElementIdForRoomButElementIsNot = 1103, - /// Provided element ID to Member element but element spec is not for - /// Member. - /// - /// Code: __1104__. - #[display(fmt = "You provided URI to Member but element's spec is not \ - for Member.")] - ElementIdForMemberButElementIsNot = 1104, - /// Provided element ID to Endpoint element but element spec is not for - /// Endpoint. - /// - /// Code: __1105__. - #[display(fmt = "You provided URI to Endpoint but element's spec is not \ - for Endpoint.")] - ElementIdForEndpointButElementIsNot = 1105, + InvalidSrcUri = 1008, + /// Provided not source URI in [`WebRtcPlayEndpoint`]. /// - /// Code: __1106__. + /// Code: __1009__. /// /// [`WebRtcPlayEndpoint`]: /// crate::signalling::elements::endpoints::webrtc::WebRtcPlayEndpoint #[display(fmt = "Provided not source URI.")] - NotSourceUri = 1106, + NotSourceUri = 1009, - ///////////////////////////////// - // Parse errors (1200 - 1299) // - /////////////////////////////// /// Element's ID don't have "local://" prefix. /// - /// Code: __1200__. + /// Code: __1010__. #[display(fmt = "Element's ID's URI not have 'local://' protocol.")] - ElementIdIsNotLocal = 1200, + ElementIdIsNotLocal = 1010, + /// Provided element's URI with too many paths. /// - /// Code: __1201__. + /// Code: __1011__. #[display(fmt = "You provided element's URI with too many paths.")] - ElementIdIsTooLong = 1201, + ElementIdIsTooLong = 1011, + /// Missing some fields in source URI of WebRtcPublishEndpoint. /// - /// Code: __1202__. + /// Code: __1012__. #[display( fmt = "Missing some fields in source URI of WebRtcPublishEndpoint." )] - MissingFieldsInSrcUri = 1202, + MissingFieldsInSrcUri = 1012, + /// Empty element ID. /// - /// Code: __1203__. + /// Code: __1013__. #[display(fmt = "Provided empty element URI.")] - EmptyElementId = 1203, + EmptyElementId = 1013, + /// Provided empty elements URIs list. /// - /// Code: __1204__. + /// Code: __1014__. #[display(fmt = "Provided empty elements URIs list.")] - EmptyElementsList = 1204, + EmptyElementsList = 1014, + /// Provided not the same Room IDs in elements IDs. Probably you try use /// Delete method for elements with different Room IDs /// - /// Code: __1205__. + /// Code: __1015__. /// /// [`RoomId`]: crate::api::control::room::Id #[display(fmt = "Provided not the same Room IDs in elements IDs. \ Probably you try use Delete method for elements with \ different Room IDs")] - ProvidedNotSameRoomIds = 1205, + ProvidedNotSameRoomIds = 1015, + + /// Room with provided URI already exists. + /// + /// Code: __1016__. + #[display(fmt = "Room with provided URI already exists.")] + RoomAlreadyExists = 1016, - ///////////////////////////// - // Conflict (1300 - 1399) // - /////////////////////////// /// Member with provided URI already exists. /// - /// Code: __1300__. + /// Code: __1017__. #[display(fmt = "Member with provided URI already exists.")] - MemberAlreadyExists = 1300, + MemberAlreadyExists = 1017, /// Endpoint with provided URI already exists. /// - /// Code: __1301__. + /// Code: __1018__. #[display(fmt = "Endpoint with provided URI already exists.")] - EndpointAlreadyExists = 1301, - /// Room with provided URI already exists. - /// - /// Code: __1302__. - #[display(fmt = "Room with provided URI already exists.")] - RoomAlreadyExists = 1302, + EndpointAlreadyExists = 1018, - //////////////////////// - // Misc (1400 - 1499)// - ////////////////////// - /// Unimplemented API call. + /// Unexpected server error. /// - /// This code should be with additional text which explains what - /// exactly unimplemented (you can do it with - /// [`ErrorResponse::with_explanation`] function). + /// Use this [`ErrorCode`] only with [`ErrorResponse::unexpected`] + /// function. In error text with this code should be error message + /// which explain what exactly goes wrong + /// ([`ErrorResponse::unexpected`] do this). /// - /// Code: __1400__. - #[display(fmt = "Unimplemented API call.")] - UnimplementedCall = 1400, + /// Code: __2000__. + #[display(fmt = "Unexpected error happened.")] + UnexpectedError = 2000, } impl From for ErrorResponse { @@ -325,9 +293,28 @@ impl From for ErrorResponse { SrcUriError(e) => e.into(), NotMemberElementInRoomElement(id) => Self::with_explanation( ErrorCode::UnimplementedCall, - "Not Member elements in Room element currently is \ - unimplemented." - .to_string(), + String::from( + "Not Member elements in Room element currently is \ + unimplemented.", + ), + Some(id), + ), + UnimplementedEndpoint(id) => Self::with_explanation( + ErrorCode::UnimplementedCall, + String::from("Endpoint is not implemented."), + Some(id), + ), + ExpectedOtherElement(element, id) => Self::with_explanation( + ErrorCode::ElementIdMismatch, + format!( + "Provided uri can not point to element of type [{}]", + element + ), + Some(id), + ), + EmptyElement(id) => Self::with_explanation( + ErrorCode::NoElement, + String::from("No element was provided"), Some(id), ), } @@ -388,28 +375,17 @@ impl From for ErrorResponse { } }, MemberNotFound(id) => Self::new(ErrorCode::MemberNotFound, &id), - PublishEndpointNotFound(id) => { - Self::new(ErrorCode::PublishEndpointNotFound, &id) - } - PlayEndpointNotFound(id) => { - Self::new(ErrorCode::PlayEndpointNotFound, &id) - } + EndpointNotFound(id) => Self::new(ErrorCode::EndpointNotFound, &id), } } } impl From for ErrorResponse { fn from(err: MemberError) -> Self { - use MemberError::*; - match err { - PlayEndpointNotFound(id) => { - Self::new(ErrorCode::PlayEndpointNotFound, &id) - } - PublishEndpointNotFound(id) => { - Self::new(ErrorCode::PublishEndpointNotFound, &id) + MemberError::EndpointNotFound(id) => { + Self::new(ErrorCode::EndpointNotFound, &id) } - EndpointNotFound(id) => Self::new(ErrorCode::EndpointNotFound, &id), } } } @@ -420,7 +396,7 @@ impl From for ErrorResponse { match err { NotSrcUri(text) => Self::new(ErrorCode::NotSourceUri, &text), - LocalUriParseError(_, err) => err.into(), + LocalUriParseError(err) => err.into(), } } } @@ -436,17 +412,12 @@ impl From for ErrorResponse { } RoomError(e) => e.into(), EmptyUrisList => Self::without_id(ErrorCode::EmptyElementsList), - RoomNotFoundForElement(id) => { - Self::new(ErrorCode::RoomNotFoundForProvidedElement, &id) - } - NotSameRoomIds(ids, expected_room_id) => Self::with_explanation( + NotSameRoomIds(id1, id2) => Self::with_explanation( ErrorCode::ProvidedNotSameRoomIds, format!( - "Expected Room ID: '{}'. IDs with different Room ID: {:?}", - expected_room_id, - ids.into_iter() - .map(|id| id.to_string()) - .collect::>() + "All URI's must have equal room_id. Provided Id's are \ + different: [{}] != [{}]", + id1, id2 ), None, ), diff --git a/src/conf/grpc_listener.rs b/src/conf/grpc_listener.rs index 927de6470..137e411fa 100644 --- a/src/conf/grpc_listener.rs +++ b/src/conf/grpc_listener.rs @@ -14,8 +14,8 @@ pub struct GrpcListener { #[default(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)))] pub bind_ip: IpAddr, - /// Port to bind gRPC server to. Defaults to `50_051`. - #[default(50_051)] + /// Port to bind gRPC server to. Defaults to `6565`. + #[default(6565)] pub bind_port: u16, /// Completion queue count of gRPC server. Defaults to `2`. diff --git a/src/log/mod.rs b/src/log/mod.rs index d2ab8bb0d..ae3c13d90 100644 --- a/src/log/mod.rs +++ b/src/log/mod.rs @@ -63,6 +63,9 @@ fn add_default_keys(logger: &Logger) -> Logger { "msg" => PushFnValue(move |record : &Record, ser| { ser.emit(record.msg()) }), + "fqn" => PushFnValue(move |record : &Record, ser| { + ser.emit(format_args!("{}:{}", record.module(), record.line())) + }), "time" => PushFnValue(move |_ : &Record, ser| { ser.emit(Local::now().to_rfc3339()) }), diff --git a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs index 6d605d1ea..eee08a509 100644 --- a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs @@ -214,6 +214,7 @@ impl Into for WebRtcPlayEndpoint { let mut member_element: ElementProto = self.into(); let endpoint = member_element.take_webrtc_play(); element.set_webrtc_play(endpoint); + element } } diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index fc6199ba6..6badb39ad 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -21,8 +21,8 @@ use crate::{ api::control::{ endpoints::WebRtcPlayEndpoint as WebRtcPlayEndpointSpec, local_uri::{LocalUri, StatefulLocalUri, ToEndpoint, ToMember, ToRoom}, - MemberId, MemberSpec, RoomId, RoomSpec, TryFromElementError, - WebRtcPlayId, WebRtcPublishId, + EndpointId, MemberId, MemberSpec, RoomId, RoomSpec, + TryFromElementError, WebRtcPlayId, WebRtcPublishId, }, log::prelude::*, media::IceUser, @@ -44,32 +44,21 @@ pub enum MembersLoadError { #[display(fmt = "Member [id = {}] not found.", _0)] MemberNotFound(LocalUri), - /// [`WebRtcPlayEndpoint`] not found. - #[display( - fmt = "Play endpoint [id = {}] not found while loading spec,", - _0 - )] - PlayEndpointNotFound(LocalUri), - - /// [`WebRtcPublishEndpoint`] not found. + /// [`Endpoint`] not found. + /// + /// [`Endpoint`]: crate::api::control::endpoint::Endpoint #[display( - fmt = "Publish endpoint [id = {}] not found while loading spec.", + fmt = "Endpoint [id = {}] was referenced but not found in spec", _0 )] - PublishEndpointNotFound(LocalUri), + EndpointNotFound(String), } #[allow(clippy::module_name_repetitions, clippy::pub_enum_variant_names)] #[derive(Debug, Fail, Display)] pub enum MemberError { - #[display(fmt = "Publish endpoint [id = {}] not found.", _0)] - PublishEndpointNotFound(LocalUri), - - #[display(fmt = "Play endpoint [id = {}] not found.", _0)] - PlayEndpointNotFound(LocalUri), - #[display(fmt = "Endpoint [id = {}] not found.", _0)] - EndpointNotFound(LocalUri), + EndpointNotFound(String), } /// [`Member`] is member of [`Room`]. @@ -126,7 +115,7 @@ impl Member { room_spec: &RoomSpec, member_id: &MemberId, ) -> Result { - let element = room_spec.pipeline.get(&member_id.0).map_or( + let element = room_spec.pipeline.get(member_id).map_or( Err(MembersLoadError::MemberNotFound(LocalUri::::new( self.room_id(), member_id.clone(), @@ -176,24 +165,20 @@ impl Member { )?; let publisher_endpoint = publisher_spec - .get_publish_endpoint_by_id(&spec_play_endpoint.src.endpoint_id) + .get_publish_endpoint_by_id( + spec_play_endpoint.src.endpoint_id.clone(), + ) .ok_or_else(|| { - MembersLoadError::PublishEndpointNotFound( - publisher_member.get_local_uri_to_endpoint( - spec_play_endpoint.src.endpoint_id.to_string(), - ), + MembersLoadError::EndpointNotFound( + spec_play_endpoint.src.endpoint_id.to_string(), ) })?; - if let Some(publisher) = - publisher_member.get_src_by_id(&WebRtcPublishId( - spec_play_endpoint.src.endpoint_id.to_string(), - )) - { - let new_play_endpoint_id = - WebRtcPlayId(spec_play_name.to_string()); + if let Some(publisher) = publisher_member.get_src_by_id( + &spec_play_endpoint.src.endpoint_id.to_string().into(), + ) { let new_play_endpoint = WebRtcPlayEndpoint::new( - new_play_endpoint_id, + spec_play_name, spec_play_endpoint.src.clone(), publisher.downgrade(), this_member.downgrade(), @@ -210,9 +195,8 @@ impl Member { publisher_member.downgrade(), ); - let new_self_play_id = WebRtcPlayId(spec_play_name.to_string()); let new_self_play = WebRtcPlayEndpoint::new( - new_self_play_id, + spec_play_name, spec_play_endpoint.src.clone(), new_publish.downgrade(), this_member.downgrade(), @@ -253,7 +237,7 @@ impl Member { /// [`Member`]. pub fn get_local_uri_to_endpoint( &self, - endpoint_id: String, + endpoint_id: EndpointId, ) -> LocalUri { LocalUri::::new(self.room_id(), self.id(), endpoint_id) } @@ -329,25 +313,6 @@ impl Member { self.0.borrow().srcs.get(id).cloned() } - /// Lookups [`WebRtcPublishEndpoint`] source endpoint by - /// [`WebRtcPublishId`]. - /// - /// Returns [`MemberError::PublishEndpointNotFound`] when - /// [`WebRtcPublishEndpoint`] not found. - pub fn get_src( - &self, - id: &WebRtcPublishId, - ) -> Result { - self.0.borrow().srcs.get(id).cloned().map_or_else( - || { - Err(MemberError::PublishEndpointNotFound( - self.get_local_uri_to_endpoint(id.to_string()), - )) - }, - Ok, - ) - } - /// Lookups [`WebRtcPlayEndpoint`] sink endpoint by [`WebRtcPlayId`]. pub fn get_sink_by_id( &self, @@ -356,24 +321,6 @@ impl Member { self.0.borrow().sinks.get(id).cloned() } - /// Lookups [`WebRtcPlayEndpoint`] sink endpoint by [`WebRtcPlayId`]. - /// - /// Returns [`MemberError::PlayEndpointNotFound`] when - /// [`WebRtcPlayEndpoint`] not found. - pub fn get_sink( - &self, - id: &WebRtcPlayId, - ) -> Result { - self.0.borrow().sinks.get(id).cloned().map_or_else( - || { - Err(MemberError::PlayEndpointNotFound( - self.get_local_uri_to_endpoint(id.to_string()), - )) - }, - Ok, - ) - } - /// Removes sink [`WebRtcPlayEndpoint`] from this [`Member`]. pub fn remove_sink(&self, id: &WebRtcPlayId) { self.0.borrow_mut().sinks.remove(id); @@ -431,18 +378,17 @@ impl Member { &self, id: String, ) -> Result { - let webrtc_publish_id = WebRtcPublishId(id); + let webrtc_publish_id = id.into(); if let Some(publish_endpoint) = self.get_src_by_id(&webrtc_publish_id) { return Ok(Endpoint::WebRtcPublishEndpoint(publish_endpoint)); } - let webrtc_play_id = WebRtcPlayId(webrtc_publish_id.0); + + let webrtc_play_id = String::from(webrtc_publish_id).into(); if let Some(play_endpoint) = self.get_sink_by_id(&webrtc_play_id) { return Ok(Endpoint::WebRtcPlayEndpoint(play_endpoint)); } - Err(MemberError::EndpointNotFound( - self.get_local_uri_to_endpoint(webrtc_play_id.to_string()), - )) + Err(MemberError::EndpointNotFound(webrtc_play_id.into())) } /// Downgrades strong [`Member`]'s pointer to weak [`WeakMember`] pointer. @@ -538,11 +484,11 @@ impl Into for Member { let mut member_pipeline = HashMap::new(); for (id, play) in self.sinks() { - let local_uri = self.get_local_uri_to_endpoint(id.to_string()); + let local_uri = self.get_local_uri_to_endpoint(id.into()); member_pipeline.insert(local_uri.to_string(), play.into()); } for (id, publish) in self.srcs() { - let local_uri = self.get_local_uri_to_endpoint(id.to_string()); + let local_uri = self.get_local_uri_to_endpoint(id.into()); member_pipeline.insert(local_uri.to_string(), publish.into()); } diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index ea5e82ae7..98a8e1581 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -454,7 +454,13 @@ impl ParticipantService { for (id, play) in spec.play_endpoints() { let partner_member = self.get_member(&play.src.member_id)?; - let src = partner_member.get_src(&play.src.endpoint_id)?; + let src = partner_member + .get_src_by_id(&play.src.endpoint_id) + .ok_or_else(|| { + MemberError::EndpointNotFound( + play.src.endpoint_id.to_string(), + ) + })?; let sink = WebRtcPlayEndpoint::new( id.clone(), @@ -487,27 +493,32 @@ impl ParticipantService { pub fn create_sink_endpoint( &mut self, member_id: &MemberId, - endpoint_id: &WebRtcPlayId, + endpoint_id: WebRtcPlayId, spec: WebRtcPlayEndpointSpec, ) -> Result<(), ParticipantServiceErr> { let member = self.get_member(&member_id)?; let is_member_have_this_sink_id = member.get_sink_by_id(&endpoint_id).is_some(); - let is_member_have_this_src_id = member - .get_src_by_id(&WebRtcPublishId(endpoint_id.0.clone())) - .is_some(); + + let publish_id = String::from(endpoint_id).into(); + let is_member_have_this_src_id = + member.get_src_by_id(&publish_id).is_some(); if is_member_have_this_sink_id || is_member_have_this_src_id { return Err(ParticipantServiceErr::EndpointAlreadyExists( - member.get_local_uri_to_endpoint(endpoint_id.to_string()), + member.get_local_uri_to_endpoint(publish_id.into()), )); } let partner_member = self.get_member(&spec.src.member_id)?; - let src = partner_member.get_src(&spec.src.endpoint_id)?; + let src = partner_member + .get_src_by_id(&spec.src.endpoint_id) + .ok_or_else(|| { + MemberError::EndpointNotFound(spec.src.endpoint_id.to_string()) + })?; let sink = WebRtcPlayEndpoint::new( - endpoint_id.clone(), + String::from(publish_id).into(), spec.src, src.downgrade(), member.downgrade(), @@ -516,12 +527,6 @@ impl ParticipantService { src.add_sink(sink.downgrade()); member.insert_sink(sink); - debug!( - "Create WebRtcPlayEndpoint [id = {}] for Member [id = {}] in Room \ - [id = {}].", - endpoint_id, member_id, self.room_id - ); - Ok(()) } @@ -535,35 +540,29 @@ impl ParticipantService { pub fn create_src_endpoint( &mut self, member_id: &MemberId, - endpoint_id: &WebRtcPublishId, + pubilsh_id: WebRtcPublishId, spec: WebRtcPublishEndpointSpec, ) -> Result<(), ParticipantServiceErr> { let member = self.get_member(&member_id)?; let is_member_have_this_src_id = - member.get_src_by_id(&endpoint_id).is_some(); - let is_member_have_this_sink_id = member - .get_sink_by_id(&WebRtcPlayId(endpoint_id.0.clone())) - .is_some(); + member.get_src_by_id(&pubilsh_id).is_some(); + + let play_id = String::from(pubilsh_id).into(); + let is_member_have_this_sink_id = + member.get_sink_by_id(&play_id).is_some(); + if is_member_have_this_sink_id || is_member_have_this_src_id { return Err(ParticipantServiceErr::EndpointAlreadyExists( - member.get_local_uri_to_endpoint(endpoint_id.to_string()), + member.get_local_uri_to_endpoint(play_id.into()), )); } - let src = WebRtcPublishEndpoint::new( - endpoint_id.clone(), + member.insert_src(WebRtcPublishEndpoint::new( + String::from(play_id).into(), spec.p2p, member.downgrade(), - ); - - member.insert_src(src); - - debug!( - "Create WebRtcPublishEndpoint [id = {}] for Member [id = {}] in \ - Room [id = {}]", - endpoint_id, member_id, self.room_id - ); + )); Ok(()) } diff --git a/src/signalling/room.rs b/src/signalling/room.rs index ca1ea56d0..01e209365 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -26,8 +26,8 @@ use crate::{ control::{ local_uri::{LocalUri, StatefulLocalUri, ToMember}, room::RoomSpec, - Endpoint as EndpointSpec, MemberId, MemberSpec, RoomId, - TryFromElementError, WebRtcPlayId, WebRtcPublishId, + EndpointId, EndpointSpec, MemberId, MemberSpec, RoomId, + TryFromElementError, }, }, log::prelude::*, @@ -620,13 +620,13 @@ impl Room { fn delete_endpoint( &mut self, member_id: &MemberId, - endpoint_id: String, + endpoint_id: EndpointId, ctx: &mut Context, ) { let endpoint_id = if let Some(member) = self.members.get_member_by_id(member_id) { - let play_id = WebRtcPlayId(endpoint_id); + let play_id = endpoint_id.into(); if let Some(endpoint) = member.take_sink(&play_id) { if let Some(peer_id) = endpoint.peer_id() { let removed_peers = @@ -637,13 +637,13 @@ impl Room { } } - let publish_id = WebRtcPublishId(play_id.0); + let publish_id = String::from(play_id).into(); if let Some(endpoint) = member.take_src(&publish_id) { let peer_ids = endpoint.peer_ids(); self.remove_peers(member_id, peer_ids, ctx); } - publish_id.0 + publish_id.into() } else { endpoint_id }; @@ -938,12 +938,10 @@ impl Handler for Room { } } member_ids.into_iter().for_each(|uri| { - let (member_id, _) = uri.take_member_id(); - self.delete_member(&member_id, ctx); + self.delete_member(&uri.member_id(), ctx); }); endpoint_ids.into_iter().for_each(|uri| { - let (endpoint_id, member_uri) = uri.take_endpoint_id(); - let (member_id, _) = member_uri.take_member_id(); + let (_, member_id, endpoint_id) = uri.take_all(); self.delete_endpoint(&member_id, endpoint_id, ctx); }); } @@ -976,7 +974,7 @@ impl Handler for Room { #[rtype(result = "Result<(), RoomError>")] pub struct CreateEndpoint { pub member_id: MemberId, - pub endpoint_id: String, + pub endpoint_id: EndpointId, pub spec: EndpointSpec, } @@ -992,14 +990,14 @@ impl Handler for Room { EndpointSpec::WebRtcPlay(endpoint) => { self.members.create_sink_endpoint( &msg.member_id, - &WebRtcPlayId(msg.endpoint_id), + msg.endpoint_id.into(), endpoint, )?; } EndpointSpec::WebRtcPublish(endpoint) => { self.members.create_src_endpoint( &msg.member_id, - &WebRtcPublishId(msg.endpoint_id), + msg.endpoint_id.into(), endpoint, )?; } diff --git a/src/signalling/room_repo.rs b/src/signalling/room_repo.rs index 706d18fe5..a6b2377e1 100644 --- a/src/signalling/room_repo.rs +++ b/src/signalling/room_repo.rs @@ -43,7 +43,7 @@ impl RoomRepository { /// Checks existence of [`Room`] in [`RoomRepository`] by provided /// [`RoomId`]. - pub fn is_contains_room_with_id(&self, id: &RoomId) -> bool { + pub fn contains_room_with_id(&self, id: &RoomId) -> bool { self.rooms.lock().unwrap().contains_key(id) } } diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index 0cc9ff512..02cf66cff 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -3,17 +3,16 @@ use std::{collections::HashMap, marker::PhantomData}; use actix::{ - fut::wrap_future, Actor, ActorFuture, Addr, Context, Handler, MailboxError, - Message, + Actor, Addr, Context, Handler, MailboxError, Message, ResponseFuture, }; use derive_more::Display; use failure::Fail; -use futures::future::{self, Either, Future}; +use futures::future::{self, Future}; use medea_control_api_proto::grpc::control_api::Element as ElementProto; use crate::{ api::control::{ - endpoints::Endpoint as EndpointSpec, + endpoints::EndpointSpec, load_static_specs_from_dir, local_uri::{LocalUri, StatefulLocalUri, ToEndpoint, ToMember, ToRoom}, LoadStaticControlSpecsError, MemberSpec, RoomId, RoomSpec, @@ -31,9 +30,6 @@ use crate::{ AppContext, }; -type ActFuture = - Box>; - /// Errors of [`RoomService`]. #[allow(clippy::module_name_repetitions)] #[derive(Debug, Fail, Display)] @@ -67,20 +63,15 @@ pub enum RoomServiceError { #[display(fmt = "Empty URIs list.")] EmptyUrisList, - /// Provided [`LocalUri`] to some element from [`Room`] but [`Room`] with - /// ID from this [`LocalUri`] not found in [`RoomRepository`]. - #[display(fmt = "Room not found for element [id = {}]", _0)] - RoomNotFoundForElement(StatefulLocalUri), - /// Provided not the same [`RoomId`]s in [`LocalUri`] list. /// /// Atm this error can happen in `Delete` method because `Delete` should be /// called only for one [`Room`]. #[display( fmt = "Provided not the same Room IDs in elements IDs [ids = {:?}].", - _0 + _1 )] - NotSameRoomIds(Vec, RoomId), + NotSameRoomIds(RoomId, RoomId), } impl From for RoomServiceError { @@ -180,7 +171,7 @@ impl Handler for RoomService { )?; for spec in room_specs { - if self.room_repo.is_contains_room_with_id(spec.id()) { + if self.room_repo.contains_room_with_id(spec.id()) { return Err(RoomServiceError::RoomAlreadyExists( get_local_uri_to_room(spec.id), )); @@ -205,9 +196,6 @@ impl Handler for RoomService { #[derive(Message)] #[rtype(result = "Result<(), RoomServiceError>")] pub struct CreateRoom { - /// [`LocalUri`] with which will be created new [`Room`]. - pub uri: LocalUri, - /// [Control API] spec for [`Room`]. /// /// [Control API]: http://tiny.cc/380uaz @@ -222,15 +210,15 @@ impl Handler for RoomService { msg: CreateRoom, _: &mut Self::Context, ) -> Self::Result { - let room_id = msg.uri.take_room_id(); + let room_spec = msg.spec; - if self.room_repo.get(&room_id).is_some() { + if self.room_repo.get(&room_spec.id).is_some() { return Err(RoomServiceError::RoomAlreadyExists( - get_local_uri_to_room(room_id), + get_local_uri_to_room(room_spec.id), )); } - let room = Room::new(&msg.spec, self.app.clone())?; + let room = Room::new(&room_spec, self.app.clone())?; let room_addr = room.start(); shutdown::subscribe( @@ -239,13 +227,89 @@ impl Handler for RoomService { shutdown::Priority(2), ); - debug!("New Room [id = {}] started.", room_id); - self.room_repo.add(room_id, room_addr); + debug!("New Room [id = {}] started.", room_spec.id); + self.room_repo.add(room_spec.id, room_addr); Ok(()) } } +/// Signal for create new [`Member`] in [`Room`] +/// +/// [`Member`]: crate::signalling::elements::member::Member +#[derive(Message)] +#[rtype(result = "Result<(), RoomServiceError>")] +pub struct CreateMemberInRoom { + pub uri: LocalUri, + pub spec: MemberSpec, +} + +impl Handler for RoomService { + type Result = ResponseFuture<(), RoomServiceError>; + + fn handle( + &mut self, + msg: CreateMemberInRoom, + _: &mut Self::Context, + ) -> Self::Result { + let (room_id, member_id) = msg.uri.take_all(); + + if let Some(room) = self.room_repo.get(&room_id) { + Box::new( + room.send(CreateMember(member_id, msg.spec)) + .map_err(RoomServiceError::RoomMailboxErr) + .and_then(|r| r.map_err(RoomServiceError::from)), + ) + } else { + Box::new(future::err(RoomServiceError::RoomNotFound(LocalUri::< + ToRoom, + >::new( + room_id + )))) + } + } +} + +/// Signal for create new [`Endpoint`] in [`Room`] +/// +/// [`Endpoint`]: crate::signalling::elements::endpoints::Endpoint +#[derive(Message)] +#[rtype(result = "Result<(), RoomServiceError>")] +pub struct CreateEndpointInRoom { + pub uri: LocalUri, + pub spec: EndpointSpec, +} + +impl Handler for RoomService { + type Result = ResponseFuture<(), RoomServiceError>; + + fn handle( + &mut self, + msg: CreateEndpointInRoom, + _: &mut Self::Context, + ) -> Self::Result { + let (room_id, member_id, endpoint_id) = msg.uri.take_all(); + + if let Some(room) = self.room_repo.get(&room_id) { + Box::new( + room.send(CreateEndpoint { + member_id, + endpoint_id, + spec: msg.spec, + }) + .map_err(RoomServiceError::RoomMailboxErr) + .and_then(|r| r.map_err(RoomServiceError::from)), + ) + } else { + Box::new(future::err(RoomServiceError::RoomNotFound(LocalUri::< + ToRoom, + >::new( + room_id + )))) + } + } +} + /// State which indicates that [`DeleteElements`] message was validated and can /// be send to [`RoomService`]. pub struct Validated; @@ -270,8 +334,8 @@ impl DeleteElements { self.uris.push(uri) } - // TODO: delete this allow when drain_filter TODO will be resolved. - #[allow(clippy::unnecessary_filter_map)] + /// Validates request. It must have at least one uri, all uris must share + /// same [`RoomId`]. pub fn validate( self, ) -> Result, RoomServiceError> { @@ -279,32 +343,19 @@ impl DeleteElements { return Err(RoomServiceError::EmptyUrisList); } - let mut ignored_uris = Vec::new(); + let first_room_id = self.uris[0].room_id(); - let first_room = self.uris[0].room_id().clone(); - // TODO: rewrite using Vec::drain_filter when it will be in stable - let uris: Vec = self - .uris - .into_iter() - .filter_map(|uri| { - if uri.room_id() == &first_room { - Some(uri) - } else { - ignored_uris.push(uri); - None - } - }) - .collect(); - - if !ignored_uris.is_empty() { - return Err(RoomServiceError::NotSameRoomIds( - ignored_uris, - first_room, - )); + for id in &self.uris { + if first_room_id != id.room_id() { + return Err(RoomServiceError::NotSameRoomIds( + first_room_id.clone(), + id.room_id().clone(), + )); + } } Ok(DeleteElements { - uris, + uris: self.uris, _validation_state: PhantomData, }) } @@ -332,7 +383,7 @@ pub struct DeleteElements { } impl Handler> for RoomService { - type Result = ActFuture<(), RoomServiceError>; + type Result = ResponseFuture<(), RoomServiceError>; // TODO: delete 'clippy::unnecessary_filter_map` when drain_filter TODO will // be resolved. @@ -342,10 +393,6 @@ impl Handler> for RoomService { msg: DeleteElements, _: &mut Self::Context, ) -> Self::Result { - if msg.uris.is_empty() { - return Box::new(actix::fut::err(RoomServiceError::EmptyUrisList)); - } - let mut deletes_from_room: Vec = Vec::new(); // TODO: use Vec::drain_filter when it will be in stable let room_messages_futs: Vec< @@ -364,24 +411,24 @@ impl Handler> for RoomService { .collect(); if !room_messages_futs.is_empty() { - Box::new(wrap_future( + Box::new( futures::future::join_all(room_messages_futs) .map(|_| ()) .map_err(RoomServiceError::RoomMailboxErr), - )) + ) } else if !deletes_from_room.is_empty() { let room_id = deletes_from_room[0].room_id().clone(); if let Some(room) = self.room_repo.get(&room_id) { - Box::new(wrap_future( + Box::new( room.send(Delete(deletes_from_room)) .map_err(RoomServiceError::RoomMailboxErr), - )) + ) } else { - Box::new(actix::fut::ok(())) + Box::new(future::ok(())) } } else { - Box::new(actix::fut::err(RoomServiceError::EmptyUrisList)) + Box::new(future::err(RoomServiceError::EmptyUrisList)) } } } @@ -394,42 +441,34 @@ impl Handler> for RoomService { pub struct Get(pub Vec); impl Handler for RoomService { - type Result = - ActFuture, RoomServiceError>; + type Result = ResponseFuture< + HashMap, + RoomServiceError, + >; fn handle(&mut self, msg: Get, _: &mut Self::Context) -> Self::Result { let mut rooms_elements = HashMap::new(); for uri in msg.0 { - if self.room_repo.is_contains_room_with_id(uri.room_id()) { + let room_id = uri.room_id(); + + if let Some(room) = self.room_repo.get(room_id) { rooms_elements - .entry(uri.room_id().clone()) + .entry(room) .or_insert_with(Vec::new) .push(uri); - } else if let StatefulLocalUri::Room(room_uri) = uri { - return Box::new(actix::fut::err( - RoomServiceError::RoomNotFound(room_uri), - )); } else { - return Box::new(actix::fut::err( - RoomServiceError::RoomNotFoundForElement(uri), - )); + return Box::new(future::err(RoomServiceError::RoomNotFound( + uri.into(), + ))); } } let mut futs = Vec::new(); - for (room_id, mut elements) in rooms_elements { - if let Some(room) = self.room_repo.get(&room_id) { - futs.push(room.send(SerializeProto(elements))); - } else { - return Box::new(actix::fut::err( - RoomServiceError::RoomNotFoundForElement( - elements.remove(0), - ), - )); - } + for (room, elements) in rooms_elements { + futs.push(room.send(SerializeProto(elements))); } - Box::new(wrap_future( + Box::new( futures::future::join_all(futs) .map_err(RoomServiceError::RoomMailboxErr) .and_then(|results| { @@ -442,85 +481,6 @@ impl Handler for RoomService { } Ok(all) }), - )) - } -} - -/// Signal for create new [`Member`] in [`Room`] -/// -/// [`Member`]: crate::signalling::elements::member::Member -#[derive(Message)] -#[rtype(result = "Result<(), RoomServiceError>")] -pub struct CreateMemberInRoom { - pub uri: LocalUri, - pub spec: MemberSpec, -} - -impl Handler for RoomService { - type Result = ActFuture<(), RoomServiceError>; - - fn handle( - &mut self, - msg: CreateMemberInRoom, - _: &mut Self::Context, - ) -> Self::Result { - let (member_id, room_uri) = msg.uri.take_member_id(); - let room_id = room_uri.take_room_id(); - - let fut = if let Some(room) = self.room_repo.get(&room_id) { - Either::A( - room.send(CreateMember(member_id, msg.spec)) - .map_err(RoomServiceError::RoomMailboxErr) - .and_then(|r| r.map_err(RoomServiceError::from)), - ) - } else { - Either::B(future::err(RoomServiceError::RoomNotFound( - get_local_uri_to_room(room_id), - ))) - }; - - Box::new(wrap_future(fut)) - } -} - -/// Signal for create new [`Endpoint`] in [`Room`] -/// -/// [`Endpoint`]: crate::signalling::elements::endpoints::Endpoint -#[derive(Message)] -#[rtype(result = "Result<(), RoomServiceError>")] -pub struct CreateEndpointInRoom { - pub uri: LocalUri, - pub spec: EndpointSpec, -} - -impl Handler for RoomService { - type Result = ActFuture<(), RoomServiceError>; - - fn handle( - &mut self, - msg: CreateEndpointInRoom, - _: &mut Self::Context, - ) -> Self::Result { - let (endpoint_id, member_uri) = msg.uri.take_endpoint_id(); - let (member_id, room_uri) = member_uri.take_member_id(); - let room_id = room_uri.take_room_id(); - - let fut = if let Some(room) = self.room_repo.get(&room_id) { - Either::A( - room.send(CreateEndpoint { - member_id, - endpoint_id, - spec: msg.spec, - }) - .map_err(RoomServiceError::RoomMailboxErr) - .and_then(|r| r.map_err(RoomServiceError::from)), - ) - } else { - Either::B(future::err(RoomServiceError::RoomNotFound( - get_local_uri_to_room(room_id), - ))) - }; - - Box::new(wrap_future(fut)) + ) } } From 54760a8cc10fbe5b046cc024254e0afdbf0168f4 Mon Sep 17 00:00:00 2001 From: alexlapa Date: Mon, 23 Sep 2019 15:03:48 +0300 Subject: [PATCH 649/735] added todos --- src/api/control/endpoints/mod.rs | 2 ++ src/api/control/grpc/server.rs | 1 + src/api/control/member.rs | 3 +++ src/signalling/elements/member.rs | 6 +++-- src/signalling/participants.rs | 42 +++++++++++++++++++++++++------ src/signalling/room.rs | 1 + src/signalling/room_service.rs | 1 + 7 files changed, 46 insertions(+), 10 deletions(-) diff --git a/src/api/control/endpoints/mod.rs b/src/api/control/endpoints/mod.rs index afcadf403..0a262ac0f 100644 --- a/src/api/control/endpoints/mod.rs +++ b/src/api/control/endpoints/mod.rs @@ -50,6 +50,8 @@ impl_from_into!(WebRtcPlayId); /// Media element that one or more media data streams flow through. #[derive(Debug)] pub enum EndpointSpec { + //TODO: add id in endpoints + /// [`WebRtcPublishEndpoint`] element. WebRtcPublish(WebRtcPublishEndpoint), diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index 61f2c15de..f5d899598 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -134,6 +134,7 @@ struct ControlApiService { app: AppContext, } +// TODO: tests impl ControlApiService { /// Returns [Control API] sid based on provided arguments and /// `MEDEA_CLIENT.PUBLIC_URL` config value. diff --git a/src/api/control/member.rs b/src/api/control/member.rs index faf83cb79..be1d6caf3 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -53,6 +53,9 @@ pub enum MemberElement { #[allow(clippy::module_name_repetitions)] #[derive(Clone, Debug)] pub struct MemberSpec { + + //TODO: add id + /// Spec of this `Member`. pipeline: Pipeline, diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index 6badb39ad..403988373 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -58,7 +58,7 @@ pub enum MembersLoadError { #[derive(Debug, Fail, Display)] pub enum MemberError { #[display(fmt = "Endpoint [id = {}] not found.", _0)] - EndpointNotFound(String), + EndpointNotFound(LocalUri), } /// [`Member`] is member of [`Room`]. @@ -388,7 +388,9 @@ impl Member { return Ok(Endpoint::WebRtcPlayEndpoint(play_endpoint)); } - Err(MemberError::EndpointNotFound(webrtc_play_id.into())) + Err(MemberError::EndpointNotFound( + self.get_local_uri_to_endpoint(webrtc_play_id.into()), + )) } /// Downgrades strong [`Member`]'s pointer to weak [`WeakMember`] pointer. diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 98a8e1581..a5dbec37f 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -109,6 +109,7 @@ pub struct ParticipantService { /// [`Member`]s which currently are present in this [`Room`]. members: HashMap, + // TODO: dont store context, just grab everything you need in new. /// Global app context. app: AppContext, @@ -249,7 +250,7 @@ impl ParticipantService { if let Some(mut connection) = self.connections.remove(&member_id) { debug!("Closing old RpcConnection for member [id = {}]", member_id); - // cancel RpcConnection close task, since connection is + // cancel RpcConnect ion close task, since connection is // reestablished if let Some(handler) = self.drop_connection_tasks.remove(&member_id) { @@ -458,7 +459,9 @@ impl ParticipantService { .get_src_by_id(&play.src.endpoint_id) .ok_or_else(|| { MemberError::EndpointNotFound( - play.src.endpoint_id.to_string(), + partner_member.get_local_uri_to_endpoint( + play.src.endpoint_id.clone().into(), + ), ) })?; @@ -514,7 +517,11 @@ impl ParticipantService { let src = partner_member .get_src_by_id(&spec.src.endpoint_id) .ok_or_else(|| { - MemberError::EndpointNotFound(spec.src.endpoint_id.to_string()) + MemberError::EndpointNotFound( + partner_member.get_local_uri_to_endpoint( + spec.src.endpoint_id.clone().into(), + ), + ) })?; let sink = WebRtcPlayEndpoint::new( @@ -525,6 +532,15 @@ impl ParticipantService { ); src.add_sink(sink.downgrade()); + + debug!( + "Created WebRtcPlayEndpoint [id = {}] for Member [id = {}] in \ + Room [id = {}].", + sink.id(), + member_id, + self.room_id + ); + member.insert_sink(sink); Ok(()) @@ -540,15 +556,15 @@ impl ParticipantService { pub fn create_src_endpoint( &mut self, member_id: &MemberId, - pubilsh_id: WebRtcPublishId, + publish_id: WebRtcPublishId, spec: WebRtcPublishEndpointSpec, ) -> Result<(), ParticipantServiceErr> { let member = self.get_member(&member_id)?; let is_member_have_this_src_id = - member.get_src_by_id(&pubilsh_id).is_some(); + member.get_src_by_id(&publish_id).is_some(); - let play_id = String::from(pubilsh_id).into(); + let play_id = String::from(publish_id).into(); let is_member_have_this_sink_id = member.get_sink_by_id(&play_id).is_some(); @@ -558,11 +574,21 @@ impl ParticipantService { )); } - member.insert_src(WebRtcPublishEndpoint::new( + let endpoint = WebRtcPublishEndpoint::new( String::from(play_id).into(), spec.p2p, member.downgrade(), - )); + ); + + debug!( + "Create WebRtcPublishEndpoint [id = {}] for Member [id = {}] in \ + Room [id = {}]", + endpoint.id(), + member_id, + self.room_id + ); + + member.insert_src(endpoint); Ok(()) } diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 01e209365..9f34c503d 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -605,6 +605,7 @@ impl Room { ) .collect(); + //TODO: dont remove peers, add some meaningfull close frame: CloseRoom, Evicted self.remove_peers(&member.id(), peers, ctx); self.members.delete_member(member_id, ctx); diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index 02cf66cff..9c9daa14a 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -334,6 +334,7 @@ impl DeleteElements { self.uris.push(uri) } + // TODO: tests /// Validates request. It must have at least one uri, all uris must share /// same [`RoomId`]. pub fn validate( From 81fc987af54a228b19cebe86f0e9ceffb5b24417 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 23 Sep 2019 15:58:42 +0300 Subject: [PATCH 650/735] Don't store global context --- src/api/control/endpoints/mod.rs | 3 +-- src/api/control/member.rs | 4 +--- src/signalling/participants.rs | 36 ++++++++++++++++++-------------- src/signalling/room.rs | 5 +++-- src/signalling/room_service.rs | 14 ++++++++----- 5 files changed, 34 insertions(+), 28 deletions(-) diff --git a/src/api/control/endpoints/mod.rs b/src/api/control/endpoints/mod.rs index 0a262ac0f..72e0606d6 100644 --- a/src/api/control/endpoints/mod.rs +++ b/src/api/control/endpoints/mod.rs @@ -50,8 +50,7 @@ impl_from_into!(WebRtcPlayId); /// Media element that one or more media data streams flow through. #[derive(Debug)] pub enum EndpointSpec { - //TODO: add id in endpoints - + // TODO: add id in endpoints /// [`WebRtcPublishEndpoint`] element. WebRtcPublish(WebRtcPublishEndpoint), diff --git a/src/api/control/member.rs b/src/api/control/member.rs index be1d6caf3..cb82f86dc 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -53,9 +53,7 @@ pub enum MemberElement { #[allow(clippy::module_name_repetitions)] #[derive(Clone, Debug)] pub struct MemberSpec { - - //TODO: add id - + // TODO: add id /// Spec of this `Member`. pipeline: Pipeline, diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index a5dbec37f..4fbb13df4 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -48,9 +48,10 @@ use crate::{ room::{ActFuture, RoomError}, Room, }, - turn::{TurnServiceErr, UnreachablePolicy}, + turn::{TurnAuthService, TurnServiceErr, UnreachablePolicy}, AppContext, }; +use std::{sync::Arc, time::Duration}; #[allow(clippy::module_name_repetitions)] #[derive(Debug, Display, Fail)] @@ -109,10 +110,6 @@ pub struct ParticipantService { /// [`Member`]s which currently are present in this [`Room`]. members: HashMap, - // TODO: dont store context, just grab everything you need in new. - /// Global app context. - app: AppContext, - /// Established [`RpcConnection`]s of [`Member`]s in this [`Room`]. /// /// [`Member`]: crate::signalling::elements::member::Member @@ -124,20 +121,28 @@ pub struct ParticipantService { /// If [`RpcConnection`] is lost, [`Room`] waits for connection_timeout /// before dropping it irrevocably in case it gets reestablished. drop_connection_tasks: HashMap, + + /// Reference to [`TurnAuthService`]. + turn_service: Arc, + + /// Duration, after which the server deletes the client session if + /// the remote RPC client does not reconnect after it is idle. + rpc_reconnect_timeout: Duration, } impl ParticipantService { /// Creates new [`ParticipantService`] from [`RoomSpec`]. pub fn new( room_spec: &RoomSpec, - context: AppContext, + context: &AppContext, ) -> Result { Ok(Self { room_id: room_spec.id().clone(), members: parse_members(room_spec)?, - app: context, connections: HashMap::new(), drop_connection_tasks: HashMap::new(), + turn_service: context.turn_service.clone(), + rpc_reconnect_timeout: context.config.rpc.reconnect_timeout, }) } @@ -259,7 +264,7 @@ impl ParticipantService { Box::new(wrap_future(connection.close().then(move |_| Ok(member)))) } else { Box::new( - wrap_future(self.app.turn_service.create( + wrap_future(self.turn_service.create( member_id.clone(), self.room_id.clone(), UnreachablePolicy::ReturnErr, @@ -318,7 +323,7 @@ impl ParticipantService { self.drop_connection_tasks.insert( member_id.clone(), ctx.run_later( - self.app.config.rpc.reconnect_timeout, + self.rpc_reconnect_timeout, move |room, ctx| { info!( "Member [id = {}] connection lost at {:?}. \ @@ -346,7 +351,7 @@ impl ParticipantService { // TODO: rewrite using `Option::flatten` when it will be in stable rust. match self.get_member_by_id(&member_id) { Some(member) => match member.take_ice_user() { - Some(ice_user) => self.app.turn_service.delete(vec![ice_user]), + Some(ice_user) => self.turn_service.delete(vec![ice_user]), None => Box::new(future::ok(())), }, None => Box::new(future::ok(())), @@ -382,8 +387,7 @@ impl ParticipantService { room_users.push(ice_user); } }); - self.app - .turn_service + self.turn_service .delete(room_users) .map_err(|err| error!("Error removing IceUsers {:?}", err)) }); @@ -412,10 +416,10 @@ impl ParticipantService { if let Some(member) = self.members.remove(member_id) { if let Some(ice_user) = member.take_ice_user() { - let delete_ice_user_fut = - self.app.turn_service.delete(vec![ice_user]).map_err( - |err| error!("Error removing IceUser {:?}", err), - ); + let delete_ice_user_fut = self + .turn_service + .delete(vec![ice_user]) + .map_err(|err| error!("Error removing IceUser {:?}", err)); ctx.spawn(wrap_future(delete_ice_user_fut)); } } diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 9f34c503d..f910c166a 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -153,7 +153,7 @@ impl Room { /// transformation happens. pub fn new( room_spec: &RoomSpec, - context: AppContext, + context: &AppContext, ) -> Result { Ok(Self { id: room_spec.id().clone(), @@ -605,7 +605,8 @@ impl Room { ) .collect(); - //TODO: dont remove peers, add some meaningfull close frame: CloseRoom, Evicted + // TODO: dont remove peers, add some meaningfull close frame: + // CloseRoom, Evicted self.remove_peers(&member.id(), peers, ctx); self.members.delete_member(member_id, ctx); diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index 9c9daa14a..7d96571c8 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -99,6 +99,11 @@ pub struct RoomService { /// Use for subscribe newly created [`Room`]s to [`GracefulShutdown`] and /// unsubscribe deleted [`Room`]s from [`GracefulShutdown`]. graceful_shutdown: Addr, + + /// Path to directory with static [Сontrol API] specs. + /// + /// [Control API]: http://tiny.cc/380uaz + static_specs_dir: String, } impl RoomService { @@ -109,6 +114,7 @@ impl RoomService { graceful_shutdown: Addr, ) -> Self { Self { + static_specs_dir: app.config.control_api.static_specs_dir.clone(), room_repo, app, graceful_shutdown, @@ -166,9 +172,7 @@ impl Handler for RoomService { _: StartStaticRooms, _: &mut Self::Context, ) -> Self::Result { - let room_specs = load_static_specs_from_dir( - self.app.config.control_api.static_specs_dir.clone(), - )?; + let room_specs = load_static_specs_from_dir(&self.static_specs_dir)?; for spec in room_specs { if self.room_repo.contains_room_with_id(spec.id()) { @@ -179,7 +183,7 @@ impl Handler for RoomService { let room_id = spec.id().clone(); - let room = Room::new(&spec, self.app.clone())?.start(); + let room = Room::new(&spec, &self.app)?.start(); shutdown::subscribe( &self.graceful_shutdown, room.clone().recipient(), @@ -218,7 +222,7 @@ impl Handler for RoomService { )); } - let room = Room::new(&room_spec, self.app.clone())?; + let room = Room::new(&room_spec, &self.app)?; let room_addr = room.start(); shutdown::subscribe( From d05ea50ecf8d577121e21a27fcb30c8d81a22c56 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 23 Sep 2019 16:56:51 +0300 Subject: [PATCH 651/735] Add tests for DeleteElements validation --- src/api/client/server.rs | 2 +- src/signalling/room_service.rs | 66 ++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 1 deletion(-) diff --git a/src/api/client/server.rs b/src/api/client/server.rs index 6d70e0f80..ca5183a8e 100644 --- a/src/api/client/server.rs +++ b/src/api/client/server.rs @@ -163,7 +163,7 @@ mod test { let app = AppContext::new(conf, new_turn_auth_service_mock()); let room_id = room_spec.id.clone(); - let client_room = Room::new(&room_spec, app.clone()).unwrap().start(); + let client_room = Room::new(&room_spec, &app).unwrap().start(); let room_hash_map = hashmap! { room_id => client_room, }; diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index 7d96571c8..719375332 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -489,3 +489,69 @@ impl Handler for RoomService { ) } } + +#[cfg(test)] +mod delete_elements_validation_specs { + use std::convert::TryFrom as _; + + use super::*; + + #[test] + fn empty_uris_list() { + let elements = DeleteElements::new(); + match elements.validate() { + Ok(_) => panic!( + "Validation should fail with EmptyUrisList but returned Ok." + ), + Err(e) => match e { + RoomServiceError::EmptyUrisList => (), + _ => panic!( + "Validation should fail with EmptyList error but errored \ + with {:?}.", + e + ), + }, + } + } + + #[test] + fn error_if_not_same_room_ids() { + let mut elements = DeleteElements::new(); + ["local://room_id/member", "local://another_room_id/member"] + .into_iter() + .map(|uri| StatefulLocalUri::try_from(uri.to_string()).unwrap()) + .for_each(|uri| elements.add_uri(uri)); + + match elements.validate() { + Ok(_) => panic!( + "Validation should fail with NotSameRoomIds but returned Ok." + ), + Err(e) => match e { + RoomServiceError::NotSameRoomIds(first, another) => { + assert_eq!(&first.to_string(), "room_id"); + assert_eq!(&another.to_string(), "another_room_id"); + } + _ => panic!( + "Validation should fail with NotSameRoomIds error but \ + errored with {:?}.", + e + ), + }, + } + } + + #[test] + fn success_if_all_ok() { + let mut elements = DeleteElements::new(); + [ + "local://room_id/member_id", + "local://room_id/another_member_id", + "local://room_id/member_id/endpoint_id", + ] + .into_iter() + .map(|uri| StatefulLocalUri::try_from(uri.to_string()).unwrap()) + .for_each(|uri| elements.add_uri(uri)); + + assert!(elements.validate().is_ok()); + } +} From f915ef1507de0b6a05a6cd499b77b41c11996ff6 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 23 Sep 2019 17:15:38 +0300 Subject: [PATCH 652/735] Delete AppContext from GrpcServer --- src/api/control/grpc/server.rs | 15 +++++++-------- src/main.rs | 2 +- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index f5d899598..18b375a56 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -130,8 +130,10 @@ struct ControlApiService { /// [`Addr`] of [`RoomService`]. room_service: Addr, - /// Global app context. - app: AppContext, + /// Public URL of server. Address for exposed [Client API]. + /// + /// [Client API]: http://tiny.cc/c80uaz + public_url: String, } // TODO: tests @@ -146,10 +148,7 @@ impl ControlApiService { ) -> String { format!( "{}/{}/{}/{}", - self.app.config.server.client.public_url, - room_id, - member_id, - credentials + self.public_url, room_id, member_id, credentials ) } @@ -497,13 +496,13 @@ impl Handler for GrpcServer { /// Run gRPC [Control API] server in actix actor. /// /// [Control API]: http://tiny.cc/380uaz -pub fn run(room_repo: Addr, app: AppContext) -> Addr { +pub fn run(room_repo: Addr, app: &AppContext) -> Addr { let bind_ip = app.config.server.control.grpc.bind_ip.to_string(); let bind_port = app.config.server.control.grpc.bind_port; let cq_count = app.config.server.control.grpc.completion_queue_count; let service = create_control_api(ControlApiService { - app, + public_url: app.config.server.client.public_url.clone(), room_service: room_repo, }); let env = Arc::new(Environment::new(cq_count)); diff --git a/src/main.rs b/src/main.rs index 713debdf2..474f9fdff 100644 --- a/src/main.rs +++ b/src/main.rs @@ -44,7 +44,7 @@ fn main() -> Result<(), Error> { medea::api::control::start_static_rooms(&room_service).map( move |_| { let grpc_addr = - grpc::server::run(room_service, app_context); + grpc::server::run(room_service, &app_context); shutdown::subscribe( &graceful_shutdown, grpc_addr.recipient(), From a1698019e822c7b9caadea88300c4a338fdbe8e9 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 23 Sep 2019 18:28:19 +0300 Subject: [PATCH 653/735] Add test for creating room --- src/signalling/room_service.rs | 61 ++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index 719375332..705055f15 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -555,3 +555,64 @@ mod delete_elements_validation_specs { assert!(elements.validate().is_ok()); } } + +#[cfg(test)] +mod room_service_specs { + use crate::conf::Conf; + use std::convert::TryFrom as _; + use crate::api::control; + + use super::*; + + fn get_room_service() -> (Addr, RoomRepository) { + let conf = Conf::default(); + let shutdown_timeout = conf.shutdown.timeout.clone(); + + let room_repo = RoomRepository::new(HashMap::new()); + let turn_service = crate::turn::new_turn_auth_service_mock(); + let app = AppContext::new(conf, turn_service); + let graceful_shutdown = GracefulShutdown::new(shutdown_timeout).start(); + + ( + RoomService::new(room_repo.clone(), app, graceful_shutdown).start(), + room_repo, + ) + } + + #[test] + fn create_room() { + let sys = actix::System::new("room-service-tests"); + + let (room_service, room_repo) = get_room_service(); + + let spec = control::load_from_yaml_file( + "tests/specs/pub-sub-video-call.yml", + ) + .unwrap(); + let caller_uri = StatefulLocalUri::try_from( + "local://pub-sub-video-call/caller".to_string(), + ) + .unwrap(); + let caller_uri_clone = caller_uri.clone(); + + let test = room_service + .send(CreateRoom { spec }) + .and_then(move |_| { + let e = room_repo + .get(&"pub-sub-video-call".to_string().into()) + .unwrap(); + e.send(SerializeProto(vec![caller_uri])) + }) + .map(move |r| { + let r = r.unwrap(); + let member = r.get(&caller_uri_clone).unwrap(); + assert_eq!(member.get_member().get_pipeline().len(), 1); + }) + .map(|_| actix::System::current().stop()) + .map_err(|e| panic!("{:?}", e)); + + actix::spawn(test); + + let _ = sys.run().unwrap(); + } +} From 37c62c8d1a643a444ffce41816a560d9730f0a57 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 23 Sep 2019 18:48:11 +0300 Subject: [PATCH 654/735] Add delete room test --- src/signalling/room_service.rs | 69 ++++++++++++++++++++++++++-------- 1 file changed, 54 insertions(+), 15 deletions(-) diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index 705055f15..eafa139de 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -558,37 +558,39 @@ mod delete_elements_validation_specs { #[cfg(test)] mod room_service_specs { - use crate::conf::Conf; use std::convert::TryFrom as _; - use crate::api::control; + + use actix_web::web::delete; + + use crate::{api::control, conf::Conf}; use super::*; - fn get_room_service() -> (Addr, RoomRepository) { + fn get_context(conf: Conf) -> AppContext { + let turn_service = crate::turn::new_turn_auth_service_mock(); + AppContext::new(conf, turn_service) + } + + fn get_room_service(room_repo: RoomRepository) -> Addr { let conf = Conf::default(); let shutdown_timeout = conf.shutdown.timeout.clone(); - let room_repo = RoomRepository::new(HashMap::new()); - let turn_service = crate::turn::new_turn_auth_service_mock(); - let app = AppContext::new(conf, turn_service); + let app = get_context(conf); let graceful_shutdown = GracefulShutdown::new(shutdown_timeout).start(); - ( - RoomService::new(room_repo.clone(), app, graceful_shutdown).start(), - room_repo, - ) + RoomService::new(room_repo, app, graceful_shutdown).start() } #[test] fn create_room() { let sys = actix::System::new("room-service-tests"); - let (room_service, room_repo) = get_room_service(); + let room_repo = RoomRepository::new(HashMap::new()); + let room_service = get_room_service(room_repo.clone()); - let spec = control::load_from_yaml_file( - "tests/specs/pub-sub-video-call.yml", - ) - .unwrap(); + let spec = + control::load_from_yaml_file("tests/specs/pub-sub-video-call.yml") + .unwrap(); let caller_uri = StatefulLocalUri::try_from( "local://pub-sub-video-call/caller".to_string(), ) @@ -615,4 +617,41 @@ mod room_service_specs { let _ = sys.run().unwrap(); } + + #[test] + fn delete_room() { + let sys = actix::System::new("room-service-tests"); + + let spec = + control::load_from_yaml_file("tests/specs/pub-sub-video-call.yml") + .unwrap(); + let ctx = get_context(Conf::default()); + let room = Room::new(&spec, &ctx).unwrap().start(); + let room_repo = RoomRepository::new( + hashmap!("pub-sub-video-call".to_string().into() => room), + ); + let room_service = get_room_service(room_repo.clone()); + + let mut delete_elements = DeleteElements::new(); + let room_uri = StatefulLocalUri::try_from( + "local://pub-sub-video-call".to_string(), + ) + .unwrap(); + delete_elements.add_uri(room_uri); + let delete_elements = delete_elements.validate().unwrap(); + let test = room_service + .send(delete_elements) + .map(|_| ()) + .map(move |_| { + assert!(room_repo + .get(&"pub-sub-video-call".to_string().into()) + .is_none()); + actix::System::current().stop(); + }) + .map_err(|e| panic!("{:?}", e)); + + actix::spawn(test); + + sys.run().unwrap(); + } } From c913ab22fd08137af011708ed70842dd9eb97995 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 23 Sep 2019 19:03:48 +0300 Subject: [PATCH 655/735] Use tempfile and macro in config tests --- Cargo.lock | 1 + Cargo.toml | 1 + src/conf/rpc.rs | 44 ++++++++++++++++++---------------- src/signalling/room_service.rs | 2 -- 4 files changed, 25 insertions(+), 23 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 410edd042..62304c923 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1135,6 +1135,7 @@ dependencies = [ "slog-scope 4.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "slog-stdlog 4.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "smart-default 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-signal 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index bdc12a608..a9773d452 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -68,3 +68,4 @@ actix-http-test = "0.2" awc = "0.2" serial_test = "0.2" serial_test_derive = "0.2" +tempfile = "3.1" diff --git a/src/conf/rpc.rs b/src/conf/rpc.rs index 934b1b59a..dda835af2 100644 --- a/src/conf/rpc.rs +++ b/src/conf/rpc.rs @@ -24,7 +24,7 @@ pub struct Rpc { #[cfg(test)] mod rpc_conf_specs { - use std::{env, fs, time::Duration}; + use std::{fs, time::Duration}; use serial_test_derive::serial; @@ -55,39 +55,41 @@ mod rpc_conf_specs { #[test] #[serial] fn conf_parse_spec_file_overrides_defaults() { - let defaults = Conf::default(); - let test_config_file_path = "test_config.toml"; + let dir = tempfile::tempdir().unwrap(); + let test_config_file_path = + dir.path().join("test_config.toml").display().to_string(); let data = "[rpc]\nidle_timeout = \"45s\"".to_owned(); - fs::write(test_config_file_path, data).unwrap(); - env::set_var(APP_CONF_PATH_ENV_VAR_NAME, test_config_file_path); + fs::write(&test_config_file_path, data).unwrap(); - let new_config = Conf::parse().unwrap(); - - env::remove_var(APP_CONF_PATH_ENV_VAR_NAME); - fs::remove_file(test_config_file_path).unwrap(); + let new_config = overrided_by_env_conf!( + APP_CONF_PATH_ENV_VAR_NAME => &test_config_file_path + ); assert_eq!(new_config.rpc.idle_timeout, Duration::from_secs(45)); - assert_ne!(new_config.rpc.idle_timeout, defaults.rpc.idle_timeout); + assert_ne!( + new_config.rpc.idle_timeout, + Conf::default().rpc.idle_timeout + ); } #[test] #[serial] fn conf_parse_spec_env_overrides_file() { - let test_config_file_path = "test_config.toml"; + let dir = tempfile::tempdir().unwrap(); + let test_config_file_path = + dir.path().join("test_config.toml").display().to_string(); let data = "[rpc]\nidle_timeout = \"47s\"".to_owned(); - fs::write(test_config_file_path, data).unwrap(); - env::set_var(APP_CONF_PATH_ENV_VAR_NAME, test_config_file_path); + fs::write(&test_config_file_path, data).unwrap(); - let file_config = Conf::parse().unwrap(); - - env::set_var("MEDEA_RPC__IDLE_TIMEOUT", "48s"); - let file_env_config = Conf::parse().unwrap(); - - env::remove_var(APP_CONF_PATH_ENV_VAR_NAME); - fs::remove_file(test_config_file_path).unwrap(); - env::remove_var("MEDEA_RPC__IDLE_TIMEOUT"); + let file_config = overrided_by_env_conf!( + APP_CONF_PATH_ENV_VAR_NAME => &test_config_file_path + ); + let file_env_config = overrided_by_env_conf!( + APP_CONF_PATH_ENV_VAR_NAME => &test_config_file_path, + "MEDEA_RPC__IDLE_TIMEOUT" => "48s" + ); assert_eq!(file_config.rpc.idle_timeout, Duration::from_secs(47)); assert_eq!(file_env_config.rpc.idle_timeout, Duration::from_secs(48)); diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index eafa139de..0e5beb175 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -560,8 +560,6 @@ mod delete_elements_validation_specs { mod room_service_specs { use std::convert::TryFrom as _; - use actix_web::web::delete; - use crate::{api::control, conf::Conf}; use super::*; From 4c1964c5b9a24135bafcfafff468c021431c6eff Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 23 Sep 2019 19:10:50 +0300 Subject: [PATCH 656/735] Refactor tests, add trailing comma to env test macro --- src/conf/control_api.rs | 2 +- src/conf/log.rs | 4 ++-- src/conf/mod.rs | 2 +- src/conf/rpc.rs | 20 +++++++++++--------- src/conf/server.rs | 4 ++-- src/conf/shutdown.rs | 2 +- src/conf/turn.rs | 6 +++--- 7 files changed, 21 insertions(+), 19 deletions(-) diff --git a/src/conf/control_api.rs b/src/conf/control_api.rs index 171d2a748..056418285 100644 --- a/src/conf/control_api.rs +++ b/src/conf/control_api.rs @@ -30,7 +30,7 @@ mod control_conf_specs { fn overrides_defaults() { let default_conf = Conf::default(); let env_conf = overrided_by_env_conf!( - "MEDEA_CONTROL_API__STATIC_SPECS_DIR" => "test/" + "MEDEA_CONTROL_API__STATIC_SPECS_DIR" => "test/", ); assert_ne!( diff --git a/src/conf/log.rs b/src/conf/log.rs index b035ac613..d7484d154 100644 --- a/src/conf/log.rs +++ b/src/conf/log.rs @@ -34,13 +34,13 @@ mod log_conf_specs { let default_conf = Conf::default(); let env_conf = overrided_by_env_conf!( - "MEDEA_LOG__LEVEL" => "WARN" + "MEDEA_LOG__LEVEL" => "WARN", ); assert_ne!(default_conf.log.level(), env_conf.log.level()); assert_eq!(env_conf.log.level(), Some(slog::Level::Warning)); let none_lvl = overrided_by_env_conf!( - "MEDEA_LOG__LEVEL" => "OFF" + "MEDEA_LOG__LEVEL" => "OFF", ); assert_eq!(none_lvl.log.level(), None); } diff --git a/src/conf/mod.rs b/src/conf/mod.rs index 125620507..614edf3fb 100644 --- a/src/conf/mod.rs +++ b/src/conf/mod.rs @@ -126,7 +126,7 @@ pub mod tests { /// ``` #[macro_export] macro_rules! overrided_by_env_conf { - ($($env:expr => $value:expr),+) => {{ + ($($env:expr => $value:expr),+ $(,)?) => {{ $(::std::env::set_var($env, $value);)+ let conf = crate::conf::Conf::parse().unwrap(); $(::std::env::remove_var($env);)+ diff --git a/src/conf/rpc.rs b/src/conf/rpc.rs index dda835af2..9eb2badba 100644 --- a/src/conf/rpc.rs +++ b/src/conf/rpc.rs @@ -39,7 +39,7 @@ mod rpc_conf_specs { let default_conf = Conf::default(); let env_conf = overrided_by_env_conf!( "MEDEA_RPC__IDLE_TIMEOUT" => "20s", - "MEDEA_RPC__RECONNECT_TIMEOUT" => "30s" + "MEDEA_RPC__RECONNECT_TIMEOUT" => "30s", ); assert_ne!(default_conf.rpc.idle_timeout, env_conf.rpc.idle_timeout); @@ -55,15 +55,16 @@ mod rpc_conf_specs { #[test] #[serial] fn conf_parse_spec_file_overrides_defaults() { + // Don't delete me! Otherwise temporary dir will be deleted. let dir = tempfile::tempdir().unwrap(); - let test_config_file_path = + let conf_path = dir.path().join("test_config.toml").display().to_string(); let data = "[rpc]\nidle_timeout = \"45s\"".to_owned(); - fs::write(&test_config_file_path, data).unwrap(); + fs::write(&conf_path, data).unwrap(); let new_config = overrided_by_env_conf!( - APP_CONF_PATH_ENV_VAR_NAME => &test_config_file_path + APP_CONF_PATH_ENV_VAR_NAME => &conf_path, ); assert_eq!(new_config.rpc.idle_timeout, Duration::from_secs(45)); @@ -76,19 +77,20 @@ mod rpc_conf_specs { #[test] #[serial] fn conf_parse_spec_env_overrides_file() { + // Don't delete me! Otherwise temporary dir will be deleted. let dir = tempfile::tempdir().unwrap(); - let test_config_file_path = + let conf_path = dir.path().join("test_config.toml").display().to_string(); let data = "[rpc]\nidle_timeout = \"47s\"".to_owned(); - fs::write(&test_config_file_path, data).unwrap(); + fs::write(&conf_path, data).unwrap(); let file_config = overrided_by_env_conf!( - APP_CONF_PATH_ENV_VAR_NAME => &test_config_file_path + APP_CONF_PATH_ENV_VAR_NAME => &conf_path, ); let file_env_config = overrided_by_env_conf!( - APP_CONF_PATH_ENV_VAR_NAME => &test_config_file_path, - "MEDEA_RPC__IDLE_TIMEOUT" => "48s" + APP_CONF_PATH_ENV_VAR_NAME => &conf_path, + "MEDEA_RPC__IDLE_TIMEOUT" => "48s", ); assert_eq!(file_config.rpc.idle_timeout, Duration::from_secs(47)); diff --git a/src/conf/server.rs b/src/conf/server.rs index 9097ccb53..261140c91 100644 --- a/src/conf/server.rs +++ b/src/conf/server.rs @@ -73,7 +73,7 @@ mod server_spec { let env_conf = overrided_by_env_conf!( "MEDEA_SERVER__CLIENT__HTTP__BIND_IP" => "5.5.5.5", - "MEDEA_SERVER__CLIENT__HTTP__BIND_PORT" => "1234" + "MEDEA_SERVER__CLIENT__HTTP__BIND_PORT" => "1234", ); assert_ne!( @@ -112,7 +112,7 @@ mod control_grpc_conf_specs { let env_conf = overrided_by_env_conf!( "MEDEA_SERVER__CONTROL__GRPC__BIND_IP" => "182.98.12.48", "MEDEA_SERVER__CONTROL__GRPC__BIND_PORT" => "44444", - "MEDEA_SERVER__CONTROL__GRPC__COMPLETION_QUEUE_COUNT" => "10" + "MEDEA_SERVER__CONTROL__GRPC__COMPLETION_QUEUE_COUNT" => "10", ); assert_ne!( diff --git a/src/conf/shutdown.rs b/src/conf/shutdown.rs index 72de34df1..99bb44c62 100644 --- a/src/conf/shutdown.rs +++ b/src/conf/shutdown.rs @@ -28,7 +28,7 @@ mod shutdown_conf_specs { fn overrides_defaults() { let default_conf = Conf::default(); let env_conf = overrided_by_env_conf!( - "MEDEA_SHUTDOWN__TIMEOUT" => "20s" + "MEDEA_SHUTDOWN__TIMEOUT" => "20s", ); assert_ne!(default_conf.shutdown.timeout, env_conf.shutdown.timeout); diff --git a/src/conf/turn.rs b/src/conf/turn.rs index a9d2c4734..9a05d8bf8 100644 --- a/src/conf/turn.rs +++ b/src/conf/turn.rs @@ -86,7 +86,7 @@ mod turn_conf_specs { "MEDEA_TURN__DB__REDIS__PORT" => "1234", "MEDEA_TURN__DB__REDIS__PASS" => "hellofellow", "MEDEA_TURN__DB__REDIS__DB_NUMBER" => "10", - "MEDEA_TURN__DB__REDIS__CONNECTION_TIMEOUT" => "10s" + "MEDEA_TURN__DB__REDIS__CONNECTION_TIMEOUT" => "10s", ); assert_ne!(default_conf.turn.db.redis.ip, env_conf.turn.db.redis.ip); @@ -123,7 +123,7 @@ mod turn_conf_specs { "MEDEA_TURN__HOST" => "example.com", "MEDEA_TURN__PORT" => "1234", "MEDEA_TURN__USER" => "ferris", - "MEDEA_TURN__PASS" => "qwerty" + "MEDEA_TURN__PASS" => "qwerty", ); assert_ne!(default_conf.turn.host, env_conf.turn.host); @@ -142,7 +142,7 @@ mod turn_conf_specs { let default_conf = Conf::default(); let env_conf = overrided_by_env_conf!( "MEDEA_TURN__HOST" => "example.com", - "MEDEA_TURN__PORT" => "1234" + "MEDEA_TURN__PORT" => "1234", ); assert_ne!(default_conf.turn.host, env_conf.turn.host); From a8ac8d51229a5f8b489f0137464af36528a8bb87 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 23 Sep 2019 19:44:10 +0300 Subject: [PATCH 657/735] Send description on close WebSocket --- proto/client-api/src/lib.rs | 20 +++++++++++++++++++- src/api/client/rpc_connection.rs | 7 +++++-- src/api/client/session.rs | 15 ++++++++++++--- src/signalling/participants.rs | 31 ++++++++++++++++++++++++------- 4 files changed, 60 insertions(+), 13 deletions(-) diff --git a/proto/client-api/src/lib.rs b/proto/client-api/src/lib.rs index 64cd50237..646ff4513 100644 --- a/proto/client-api/src/lib.rs +++ b/proto/client-api/src/lib.rs @@ -2,7 +2,7 @@ use std::collections::HashMap; -use derive_more::Display; +use derive_more::{Constructor, Display}; use medea_macro::dispatchable; use serde::{de::Deserializer, ser::Serializer, Deserialize, Serialize}; @@ -130,6 +130,24 @@ pub enum Event { PeersRemoved { peer_ids: Vec }, } +#[derive(Debug, Deserialize, Serialize)] +/// Reason of disconnecting client from the server. +pub enum RpcConnectionCloseReason { + /// `Room` in which client presented was closed. + RoomClosed, + + /// Member deleted from `Room`. + Evicted, + + /// Member reconnects and old connection was closed. + ConnectionSwapped, +} + +#[derive(Constructor, Debug, Deserialize, Serialize)] +pub struct CloseDescription { + pub reason: RpcConnectionCloseReason, +} + /// Represents [RTCIceCandidateInit][1] object. /// /// [1]: https://www.w3.org/TR/webrtc/#dom-rtcicecandidateinit diff --git a/src/api/client/rpc_connection.rs b/src/api/client/rpc_connection.rs index 2b6d8a1c8..afa9d10fe 100644 --- a/src/api/client/rpc_connection.rs +++ b/src/api/client/rpc_connection.rs @@ -7,7 +7,7 @@ use std::fmt; use actix::Message; use derive_more::{From, Into}; use futures::Future; -use medea_client_api_proto::{Command, Event}; +use medea_client_api_proto::{CloseDescription, Command, Event}; use crate::api::control::MemberId; @@ -27,7 +27,10 @@ pub trait RpcConnection: fmt::Debug + Send { /// Closes [`RpcConnection`]. /// No [`RpcConnectionClosed`] signals should be emitted. /// Always returns success. - fn close(&mut self) -> Box>; + fn close( + &mut self, + close_description: CloseDescription, + ) -> Box>; /// Sends [`Event`] to remote [`Member`]. /// diff --git a/src/api/client/session.rs b/src/api/client/session.rs index 465c700bc..dce78b24e 100644 --- a/src/api/client/session.rs +++ b/src/api/client/session.rs @@ -8,7 +8,7 @@ use actix::{ }; use actix_web_actors::ws::{self, CloseReason, WebsocketContext}; use futures::future::Future; -use medea_client_api_proto::{ClientMsg, ServerMsg}; +use medea_client_api_proto::{ClientMsg, CloseDescription, ServerMsg}; use crate::{ api::{ @@ -148,10 +148,19 @@ impl RpcConnection for Addr { /// Closes [`WsSession`] by sending itself "normal closure" close message. /// /// Never returns error. - fn close(&mut self) -> Box> { + fn close( + &mut self, + close_description: CloseDescription, + ) -> Box> { + let reason = CloseReason { + code: ws::CloseCode::Normal, + description: Some( + serde_json::to_string(&close_description).unwrap(), + ), + }; let fut = self .send(Close { - reason: Some(ws::CloseCode::Normal.into()), + reason: Some(reason), }) .or_else(|_| Ok(())); Box::new(fut) diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 4fbb13df4..4ea69aaee 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -7,7 +7,11 @@ //! [`RpcConnection`]: crate::api::client::rpc_connection::RpcConnection //! [`ParticipantService`]: crate::signalling::participants::ParticipantService -use std::{collections::HashMap, time::Instant}; +use std::{ + collections::HashMap, + sync::Arc, + time::{Duration, Instant}, +}; use actix::{ fut::wrap_future, ActorFuture, AsyncContext, Context, SpawnHandle, @@ -19,7 +23,9 @@ use futures::{ Future, }; -use medea_client_api_proto::Event; +use medea_client_api_proto::{ + CloseDescription, Event, RpcConnectionCloseReason, +}; use crate::{ api::{ @@ -51,7 +57,6 @@ use crate::{ turn::{TurnAuthService, TurnServiceErr, UnreachablePolicy}, AppContext, }; -use std::{sync::Arc, time::Duration}; #[allow(clippy::module_name_repetitions)] #[derive(Debug, Display, Fail)] @@ -255,13 +260,19 @@ impl ParticipantService { if let Some(mut connection) = self.connections.remove(&member_id) { debug!("Closing old RpcConnection for member [id = {}]", member_id); - // cancel RpcConnect ion close task, since connection is + // cancel RpcConnection close task, since connection is // reestablished if let Some(handler) = self.drop_connection_tasks.remove(&member_id) { ctx.cancel_future(handler); } - Box::new(wrap_future(connection.close().then(move |_| Ok(member)))) + Box::new(wrap_future( + connection + .close(CloseDescription::new( + RpcConnectionCloseReason::Evicted, + )) + .then(move |_| Ok(member)), + )) } else { Box::new( wrap_future(self.turn_service.create( @@ -373,7 +384,11 @@ impl ParticipantService { let mut close_fut = self.connections.drain().fold( vec![], |mut futures, (_, mut connection)| { - futures.push(connection.close()); + // TODO: change close reason on 47-rpc-connection-loss branch + // (remove room or resetting room) + futures.push(connection.close(CloseDescription::new( + RpcConnectionCloseReason::RoomClosed, + ))); futures }, ); @@ -411,7 +426,9 @@ impl ParticipantService { } if let Some(mut conn) = self.connections.remove(member_id) { - ctx.spawn(wrap_future(conn.close())); + ctx.spawn(wrap_future(conn.close(CloseDescription::new( + RpcConnectionCloseReason::Evicted, + )))); } if let Some(member) = self.members.remove(member_id) { From 70c9c5d3a895c98e7c1905748a0ba8a38f204368 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 23 Sep 2019 20:18:08 +0300 Subject: [PATCH 658/735] Add member delete test --- src/signalling/room_service.rs | 64 ++++++++++++++++++++++++++++++---- 1 file changed, 57 insertions(+), 7 deletions(-) diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index 0e5beb175..066e28e17 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -560,10 +560,18 @@ mod delete_elements_validation_specs { mod room_service_specs { use std::convert::TryFrom as _; - use crate::{api::control, conf::Conf}; + use crate::{api::control::RootElement, conf::Conf}; use super::*; + const ROOM_SPEC: &str = + include_str!("../../tests/specs/pub-sub-video-call.yml"); + + fn get_room_spec() -> RoomSpec { + let parsed: RootElement = serde_yaml::from_str(ROOM_SPEC).unwrap(); + RoomSpec::try_from(&parsed).unwrap() + } + fn get_context(conf: Conf) -> AppContext { let turn_service = crate::turn::new_turn_auth_service_mock(); AppContext::new(conf, turn_service) @@ -586,9 +594,7 @@ mod room_service_specs { let room_repo = RoomRepository::new(HashMap::new()); let room_service = get_room_service(room_repo.clone()); - let spec = - control::load_from_yaml_file("tests/specs/pub-sub-video-call.yml") - .unwrap(); + let spec = get_room_spec(); let caller_uri = StatefulLocalUri::try_from( "local://pub-sub-video-call/caller".to_string(), ) @@ -620,9 +626,7 @@ mod room_service_specs { fn delete_room() { let sys = actix::System::new("room-service-tests"); - let spec = - control::load_from_yaml_file("tests/specs/pub-sub-video-call.yml") - .unwrap(); + let spec = get_room_spec(); let ctx = get_context(Conf::default()); let room = Room::new(&spec, &ctx).unwrap().start(); let room_repo = RoomRepository::new( @@ -652,4 +656,50 @@ mod room_service_specs { sys.run().unwrap(); } + + #[test] + fn create_member() { + let sys = actix::System::new("room-service-tests"); + + let spec = get_room_spec(); + let member_spec = spec + .members() + .unwrap() + .get(&"caller".to_string().into()) + .unwrap() + .clone(); + let ctx = get_context(Conf::default()); + let room = Room::new(&spec, &ctx).unwrap().start(); + let room_repo = RoomRepository::new( + hashmap!("pub-sub-video-call".to_string().into() => room), + ); + let room_service = get_room_service(room_repo.clone()); + let member_uri = LocalUri::::new( + "pub-sub-video-call".to_string().into(), + "test-member".to_string().into(), + ); + let stateful_member_uri: StatefulLocalUri = member_uri.clone().into(); + let stateful_member_uri_clone = stateful_member_uri.clone(); + let msg = CreateMemberInRoom { + spec: member_spec, + uri: member_uri, + }; + + let test = room_service + .send(msg) + .and_then(move |_| { + room_service.send(Get(vec![stateful_member_uri_clone])) + }) + .map(move |res| { + let elements = res.unwrap(); + let member_el = elements.get(&stateful_member_uri).unwrap(); + assert_eq!(member_el.get_member().get_pipeline().len(), 1); + actix::System::current().stop(); + }) + .map_err(|e| panic!("{:?}", e)); + + actix::spawn(test); + + sys.run().unwrap(); + } } From 60de1351ec43423fbab10fc3a67e992e165ad4b1 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 24 Sep 2019 14:31:20 +0300 Subject: [PATCH 659/735] Refactor test, add test for member --- src/signalling/room_service.rs | 55 ++++++++++++++++++++++++++++++---- 1 file changed, 49 insertions(+), 6 deletions(-) diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index 066e28e17..4f1d7553e 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -623,7 +623,7 @@ mod room_service_specs { } #[test] - fn delete_room() { + fn delete_and_get_room() { let sys = actix::System::new("room-service-tests"); let spec = get_room_spec(); @@ -639,15 +639,15 @@ mod room_service_specs { "local://pub-sub-video-call".to_string(), ) .unwrap(); - delete_elements.add_uri(room_uri); + + delete_elements.add_uri(room_uri.clone()); let delete_elements = delete_elements.validate().unwrap(); let test = room_service .send(delete_elements) .map(|_| ()) - .map(move |_| { - assert!(room_repo - .get(&"pub-sub-video-call".to_string().into()) - .is_none()); + .and_then(move |_| room_service.send(Get(vec![room_uri]))) + .map(move |res| { + assert!(res.is_err()); actix::System::current().stop(); }) .map_err(|e| panic!("{:?}", e)); @@ -702,4 +702,47 @@ mod room_service_specs { sys.run().unwrap(); } + + #[test] + fn delete_and_get_member() { + let sys = actix::System::new("room-service-tests"); + + let spec = get_room_spec(); + let member_spec = spec + .members() + .unwrap() + .get(&"caller".to_string().into()) + .unwrap() + .clone(); + let ctx = get_context(Conf::default()); + let room = Room::new(&spec, &ctx).unwrap().start(); + let room_repo = RoomRepository::new( + hashmap!("pub-sub-video-call".to_string().into() => room), + ); + let room_service = get_room_service(room_repo.clone()); + let member_uri = LocalUri::::new( + "pub-sub-video-call".to_string().into(), + "test-member".to_string().into(), + ); + let stateful_member_uri = StatefulLocalUri::from(member_uri.clone()); + + let mut delete_elements = DeleteElements::new(); + delete_elements.add_uri(stateful_member_uri.clone()); + let delete_elements = delete_elements.validate().unwrap(); + + let test = room_service + .send(delete_elements) + .and_then(move |_| { + room_service.send(Get(vec![stateful_member_uri])) + }) + .map(move |res| { + assert!(res.is_err()); + actix::System::current().stop(); + }) + .map_err(|e| panic!("{:?}", e)); + + actix::spawn(test); + + sys.run().unwrap(); + } } From 29b10c0a23379fc195322ba33271801f46df3812 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 24 Sep 2019 14:40:31 +0300 Subject: [PATCH 660/735] Add delete and get endpoint test --- src/signalling/room_service.rs | 51 ++++++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 8 deletions(-) diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index 4f1d7553e..4b8728728 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -708,12 +708,6 @@ mod room_service_specs { let sys = actix::System::new("room-service-tests"); let spec = get_room_spec(); - let member_spec = spec - .members() - .unwrap() - .get(&"caller".to_string().into()) - .unwrap() - .clone(); let ctx = get_context(Conf::default()); let room = Room::new(&spec, &ctx).unwrap().start(); let room_repo = RoomRepository::new( @@ -722,7 +716,7 @@ mod room_service_specs { let room_service = get_room_service(room_repo.clone()); let member_uri = LocalUri::::new( "pub-sub-video-call".to_string().into(), - "test-member".to_string().into(), + "caller".to_string().into(), ); let stateful_member_uri = StatefulLocalUri::from(member_uri.clone()); @@ -732,7 +726,8 @@ mod room_service_specs { let test = room_service .send(delete_elements) - .and_then(move |_| { + .and_then(move |res| { + res.unwrap(); room_service.send(Get(vec![stateful_member_uri])) }) .map(move |res| { @@ -745,4 +740,44 @@ mod room_service_specs { sys.run().unwrap(); } + + #[test] + fn delete_and_get_endpoint() { + let sys = actix::System::new("room-service-tests"); + + let spec = get_room_spec(); + let ctx = get_context(Conf::default()); + let room = Room::new(&spec, &ctx).unwrap().start(); + let room_repo = RoomRepository::new( + hashmap!("pub-sub-video-call".to_string().into() => room), + ); + let room_service = get_room_service(room_repo.clone()); + let endpoint_uri = LocalUri::::new( + "pub-sub-video-call".to_string().into(), + "caller".to_string().into(), + "publish".to_string().into(), + ); + let stateful_endpoint_uri = + StatefulLocalUri::from(endpoint_uri.clone()); + + let mut delete_elements = DeleteElements::new(); + delete_elements.add_uri(stateful_endpoint_uri.clone()); + let delete_elements = delete_elements.validate().unwrap(); + + let test = room_service + .send(delete_elements) + .and_then(move |res| { + res.unwrap(); + room_service.send(Get(vec![stateful_endpoint_uri])) + }) + .map(move |res| { + assert!(res.is_err()); + actix::System::current().stop(); + }) + .map_err(|e| panic!("{:?}", e)); + + actix::spawn(test); + + sys.run().unwrap(); + } } From eb1b353a89c4dc3c379dc4d20a9de4d38f4d2977 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 24 Sep 2019 14:47:04 +0300 Subject: [PATCH 661/735] Add test for endpoint creating --- src/api/control/endpoints/mod.rs | 2 +- src/signalling/room_service.rs | 55 ++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/src/api/control/endpoints/mod.rs b/src/api/control/endpoints/mod.rs index 72e0606d6..534a3937f 100644 --- a/src/api/control/endpoints/mod.rs +++ b/src/api/control/endpoints/mod.rs @@ -48,7 +48,7 @@ impl_from_into!(WebRtcPublishId); impl_from_into!(WebRtcPlayId); /// Media element that one or more media data streams flow through. -#[derive(Debug)] +#[derive(Debug, From)] pub enum EndpointSpec { // TODO: add id in endpoints /// [`WebRtcPublishEndpoint`] element. diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index 4b8728728..271d4aed7 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -563,6 +563,7 @@ mod room_service_specs { use crate::{api::control::RootElement, conf::Conf}; use super::*; + use crate::api::control::endpoints::webrtc_publish_endpoint::P2pMode; const ROOM_SPEC: &str = include_str!("../../tests/specs/pub-sub-video-call.yml"); @@ -780,4 +781,58 @@ mod room_service_specs { sys.run().unwrap(); } + + #[test] + fn create_endpoint() { + let sys = actix::System::new("room-service-tests"); + + let spec = get_room_spec(); + let mut member_spec = spec + .members() + .unwrap() + .get(&"caller".to_string().into()) + .unwrap() + .get_publish_endpoint_by_id("publish".to_string().into()) + .unwrap() + .clone(); + member_spec.p2p = P2pMode::Never; + let member_spec = member_spec.into(); + let ctx = get_context(Conf::default()); + let room = Room::new(&spec, &ctx).unwrap().start(); + let room_repo = RoomRepository::new( + hashmap!("pub-sub-video-call".to_string().into() => room), + ); + let room_service = get_room_service(room_repo.clone()); + let member_uri = LocalUri::::new( + "pub-sub-video-call".to_string().into(), + "caller".to_string().into(), + "test-publish".to_string().into(), + ); + let stateful_member_uri: StatefulLocalUri = member_uri.clone().into(); + let stateful_member_uri_clone = stateful_member_uri.clone(); + let msg = CreateEndpointInRoom { + spec: member_spec, + uri: member_uri, + }; + + let test = room_service + .send(msg) + .and_then(move |_| { + room_service.send(Get(vec![stateful_member_uri_clone])) + }) + .map(move |res| { + let elements = res.unwrap(); + let member_el = elements.get(&stateful_member_uri).unwrap(); + assert_eq!( + member_el.get_webrtc_pub().get_p2p(), + P2pMode::Never.into() + ); + actix::System::current().stop(); + }) + .map_err(|e| panic!("{:?}", e)); + + actix::spawn(test); + + sys.run().unwrap(); + } } From 807ae5749450627f760ca9226200d7695277ef8e Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 24 Sep 2019 16:09:58 +0300 Subject: [PATCH 662/735] Refactor tests --- src/signalling/room_service.rs | 352 +++++++++++++++------------------ 1 file changed, 163 insertions(+), 189 deletions(-) diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index 271d4aed7..bbf5ae799 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -560,100 +560,81 @@ mod delete_elements_validation_specs { mod room_service_specs { use std::convert::TryFrom as _; - use crate::{api::control::RootElement, conf::Conf}; + use crate::{ + api::control::{ + endpoints::webrtc_publish_endpoint::P2pMode, RootElement, + }, + conf::Conf, + }; use super::*; - use crate::api::control::endpoints::webrtc_publish_endpoint::P2pMode; - const ROOM_SPEC: &str = - include_str!("../../tests/specs/pub-sub-video-call.yml"); + fn room_spec() -> RoomSpec { + const ROOM_SPEC: &str = + include_str!("../../tests/specs/pub-sub-video-call.yml"); - fn get_room_spec() -> RoomSpec { let parsed: RootElement = serde_yaml::from_str(ROOM_SPEC).unwrap(); RoomSpec::try_from(&parsed).unwrap() } - fn get_context(conf: Conf) -> AppContext { + fn app_ctx() -> AppContext { let turn_service = crate::turn::new_turn_auth_service_mock(); - AppContext::new(conf, turn_service) + AppContext::new(Conf::default(), turn_service) } - fn get_room_service(room_repo: RoomRepository) -> Addr { + fn room_service(room_repo: RoomRepository) -> Addr { let conf = Conf::default(); let shutdown_timeout = conf.shutdown.timeout.clone(); - let app = get_context(conf); + let app = app_ctx(); let graceful_shutdown = GracefulShutdown::new(shutdown_timeout).start(); RoomService::new(room_repo, app, graceful_shutdown).start() } + macro_rules! test_for_create { + ( + $room_service:expr, + $create_msg:expr, + $caller_uri:expr, + $test:expr + ) => {{ + let get_msg = Get(vec![$caller_uri.clone()]); + $room_service + .send($create_msg) + .and_then(move |res| { + res.unwrap(); + $room_service.send(get_msg) + }) + .map(move |r| { + let mut resp = r.unwrap(); + resp.remove(&$caller_uri).unwrap() + }) + .map($test) + .map(|_| actix::System::current().stop()) + .map_err(|e| panic!("{:?}", e)) + }}; + } + #[test] fn create_room() { let sys = actix::System::new("room-service-tests"); - let room_repo = RoomRepository::new(HashMap::new()); - let room_service = get_room_service(room_repo.clone()); - - let spec = get_room_spec(); + let room_service = room_service(RoomRepository::new(HashMap::new())); + let spec = room_spec(); let caller_uri = StatefulLocalUri::try_from( "local://pub-sub-video-call/caller".to_string(), ) .unwrap(); - let caller_uri_clone = caller_uri.clone(); - - let test = room_service - .send(CreateRoom { spec }) - .and_then(move |_| { - let e = room_repo - .get(&"pub-sub-video-call".to_string().into()) - .unwrap(); - e.send(SerializeProto(vec![caller_uri])) - }) - .map(move |r| { - let r = r.unwrap(); - let member = r.get(&caller_uri_clone).unwrap(); - assert_eq!(member.get_member().get_pipeline().len(), 1); - }) - .map(|_| actix::System::current().stop()) - .map_err(|e| panic!("{:?}", e)); - - actix::spawn(test); - - let _ = sys.run().unwrap(); - } - - #[test] - fn delete_and_get_room() { - let sys = actix::System::new("room-service-tests"); - - let spec = get_room_spec(); - let ctx = get_context(Conf::default()); - let room = Room::new(&spec, &ctx).unwrap().start(); - let room_repo = RoomRepository::new( - hashmap!("pub-sub-video-call".to_string().into() => room), - ); - let room_service = get_room_service(room_repo.clone()); - - let mut delete_elements = DeleteElements::new(); - let room_uri = StatefulLocalUri::try_from( - "local://pub-sub-video-call".to_string(), - ) - .unwrap(); - - delete_elements.add_uri(room_uri.clone()); - let delete_elements = delete_elements.validate().unwrap(); - let test = room_service - .send(delete_elements) - .map(|_| ()) - .and_then(move |_| room_service.send(Get(vec![room_uri]))) - .map(move |res| { - assert!(res.is_err()); - actix::System::current().stop(); - }) - .map_err(|e| panic!("{:?}", e)); - actix::spawn(test); + actix::spawn(test_for_create!( + room_service, + CreateRoom { spec }, + caller_uri, + |member_el| { + assert_eq!(member_el.get_member().get_pipeline().len(), 1); + } + )); sys.run().unwrap(); } @@ -662,176 +643,169 @@ mod room_service_specs { fn create_member() { let sys = actix::System::new("room-service-tests"); - let spec = get_room_spec(); + let spec = room_spec(); let member_spec = spec .members() .unwrap() .get(&"caller".to_string().into()) .unwrap() .clone(); - let ctx = get_context(Conf::default()); - let room = Room::new(&spec, &ctx).unwrap().start(); - let room_repo = RoomRepository::new( - hashmap!("pub-sub-video-call".to_string().into() => room), - ); - let room_service = get_room_service(room_repo.clone()); + + let room_id: RoomId = "pub-sub-video-call".to_string().into(); + let room_service = room_service(RoomRepository::new(hashmap!( + room_id.clone() => Room::new(&spec, &app_ctx()).unwrap().start(), + ))); + let member_uri = LocalUri::::new( - "pub-sub-video-call".to_string().into(), + room_id, "test-member".to_string().into(), ); let stateful_member_uri: StatefulLocalUri = member_uri.clone().into(); - let stateful_member_uri_clone = stateful_member_uri.clone(); - let msg = CreateMemberInRoom { - spec: member_spec, - uri: member_uri, - }; - - let test = room_service - .send(msg) - .and_then(move |_| { - room_service.send(Get(vec![stateful_member_uri_clone])) - }) - .map(move |res| { - let elements = res.unwrap(); - let member_el = elements.get(&stateful_member_uri).unwrap(); - assert_eq!(member_el.get_member().get_pipeline().len(), 1); - actix::System::current().stop(); - }) - .map_err(|e| panic!("{:?}", e)); - actix::spawn(test); + actix::spawn(test_for_create!( + room_service, + CreateMemberInRoom { + spec: member_spec, + uri: member_uri, + }, + stateful_member_uri, + |member_el| { + assert_eq!(member_el.get_member().get_pipeline().len(), 1); + } + )); sys.run().unwrap(); } #[test] - fn delete_and_get_member() { + fn create_endpoint() { let sys = actix::System::new("room-service-tests"); - let spec = get_room_spec(); - let ctx = get_context(Conf::default()); - let room = Room::new(&spec, &ctx).unwrap().start(); - let room_repo = RoomRepository::new( - hashmap!("pub-sub-video-call".to_string().into() => room), - ); - let room_service = get_room_service(room_repo.clone()); - let member_uri = LocalUri::::new( - "pub-sub-video-call".to_string().into(), + let spec = room_spec(); + + let mut endpoint_spec = spec + .members() + .unwrap() + .get(&"caller".to_string().into()) + .unwrap() + .get_publish_endpoint_by_id("publish".to_string().into()) + .unwrap() + .clone(); + endpoint_spec.p2p = P2pMode::Never; + let endpoint_spec = endpoint_spec.into(); + + let room_id: RoomId = "pub-sub-video-call".to_string().into(); + let room_service = room_service(RoomRepository::new(hashmap!( + room_id.clone() => Room::new(&spec, &app_ctx()).unwrap().start(), + ))); + + let endpoint_uri = LocalUri::::new( + room_id, "caller".to_string().into(), + "test-publish".to_string().into(), ); - let stateful_member_uri = StatefulLocalUri::from(member_uri.clone()); + let stateful_endpoint_uri: StatefulLocalUri = + endpoint_uri.clone().into(); + + actix::spawn(test_for_create!( + room_service, + CreateEndpointInRoom { + spec: endpoint_spec, + uri: endpoint_uri, + }, + stateful_endpoint_uri, + |endpoint_el| { + assert_eq!( + endpoint_el.get_webrtc_pub().get_p2p(), + P2pMode::Never.into() + ); + } + )); + + sys.run().unwrap(); + } - let mut delete_elements = DeleteElements::new(); - delete_elements.add_uri(stateful_member_uri.clone()); - let delete_elements = delete_elements.validate().unwrap(); + fn test_for_delete_and_get( + room_service: Addr, + element_stateful_uri: StatefulLocalUri, + ) -> impl Future { + let mut delete_msg = DeleteElements::new(); + delete_msg.add_uri(element_stateful_uri.clone()); + let delete_msg = delete_msg.validate().unwrap(); - let test = room_service - .send(delete_elements) + room_service + .send(delete_msg) .and_then(move |res| { res.unwrap(); - room_service.send(Get(vec![stateful_member_uri])) + room_service.send(Get(vec![element_stateful_uri])) }) .map(move |res| { assert!(res.is_err()); actix::System::current().stop(); }) - .map_err(|e| panic!("{:?}", e)); + .map_err(|e| panic!("{:?}", e)) + } + + #[test] + fn delete_and_get_room() { + let sys = actix::System::new("room-service-tests"); + + let room_id: RoomId = "pub-sub-video-call".to_string().into(); + let stateful_room_uri = + StatefulLocalUri::from(LocalUri::::new(room_id.clone())); + + let room_service = room_service(RoomRepository::new(hashmap!( + room_id => Room::new(&room_spec(), &app_ctx()).unwrap().start(), + ))); - actix::spawn(test); + actix::spawn(test_for_delete_and_get(room_service, stateful_room_uri)); sys.run().unwrap(); } #[test] - fn delete_and_get_endpoint() { + fn delete_and_get_member() { let sys = actix::System::new("room-service-tests"); - let spec = get_room_spec(); - let ctx = get_context(Conf::default()); - let room = Room::new(&spec, &ctx).unwrap().start(); - let room_repo = RoomRepository::new( - hashmap!("pub-sub-video-call".to_string().into() => room), - ); - let room_service = get_room_service(room_repo.clone()); - let endpoint_uri = LocalUri::::new( - "pub-sub-video-call".to_string().into(), - "caller".to_string().into(), - "publish".to_string().into(), - ); - let stateful_endpoint_uri = - StatefulLocalUri::from(endpoint_uri.clone()); - - let mut delete_elements = DeleteElements::new(); - delete_elements.add_uri(stateful_endpoint_uri.clone()); - let delete_elements = delete_elements.validate().unwrap(); + let room_id: RoomId = "pub-sub-video-call".to_string().into(); + let stateful_member_uri = + StatefulLocalUri::from(LocalUri::::new( + room_id.clone(), + "caller".to_string().into(), + )); - let test = room_service - .send(delete_elements) - .and_then(move |res| { - res.unwrap(); - room_service.send(Get(vec![stateful_endpoint_uri])) - }) - .map(move |res| { - assert!(res.is_err()); - actix::System::current().stop(); - }) - .map_err(|e| panic!("{:?}", e)); + let room_service = room_service(RoomRepository::new(hashmap!( + room_id => Room::new(&room_spec(), &app_ctx()).unwrap().start(), + ))); - actix::spawn(test); + actix::spawn(test_for_delete_and_get( + room_service, + stateful_member_uri, + )); sys.run().unwrap(); } #[test] - fn create_endpoint() { + fn delete_and_get_endpoint() { let sys = actix::System::new("room-service-tests"); - let spec = get_room_spec(); - let mut member_spec = spec - .members() - .unwrap() - .get(&"caller".to_string().into()) - .unwrap() - .get_publish_endpoint_by_id("publish".to_string().into()) - .unwrap() - .clone(); - member_spec.p2p = P2pMode::Never; - let member_spec = member_spec.into(); - let ctx = get_context(Conf::default()); - let room = Room::new(&spec, &ctx).unwrap().start(); - let room_repo = RoomRepository::new( - hashmap!("pub-sub-video-call".to_string().into() => room), - ); - let room_service = get_room_service(room_repo.clone()); - let member_uri = LocalUri::::new( - "pub-sub-video-call".to_string().into(), - "caller".to_string().into(), - "test-publish".to_string().into(), - ); - let stateful_member_uri: StatefulLocalUri = member_uri.clone().into(); - let stateful_member_uri_clone = stateful_member_uri.clone(); - let msg = CreateEndpointInRoom { - spec: member_spec, - uri: member_uri, - }; - - let test = room_service - .send(msg) - .and_then(move |_| { - room_service.send(Get(vec![stateful_member_uri_clone])) - }) - .map(move |res| { - let elements = res.unwrap(); - let member_el = elements.get(&stateful_member_uri).unwrap(); - assert_eq!( - member_el.get_webrtc_pub().get_p2p(), - P2pMode::Never.into() - ); - actix::System::current().stop(); - }) - .map_err(|e| panic!("{:?}", e)); + let room_id: RoomId = "pub-sub-video-call".to_string().into(); + let stateful_endpoint_uri = + StatefulLocalUri::from(LocalUri::::new( + room_id.clone(), + "caller".to_string().into(), + "publish".to_string().into(), + )); + + let room_service = room_service(RoomRepository::new(hashmap!( + room_id => Room::new(&room_spec(), &app_ctx()).unwrap().start(), + ))); - actix::spawn(test); + actix::spawn(test_for_delete_and_get( + room_service, + stateful_endpoint_uri, + )); sys.run().unwrap(); } From 8f06e3393a43aab69ad03bc3f710694af9782331 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 24 Sep 2019 17:12:06 +0300 Subject: [PATCH 663/735] Fix, add docs, change tiny.cc to tinyurl --- proto/control-api/src/lib.rs | 2 +- src/api/client/mod.rs | 2 +- .../control/endpoints/webrtc_play_endpoint.rs | 6 +-- .../endpoints/webrtc_publish_endpoint.rs | 2 +- src/api/control/grpc/mod.rs | 2 +- src/api/control/grpc/server.rs | 24 ++++++----- src/api/control/member.rs | 10 ++--- src/api/control/mod.rs | 16 ++++---- src/api/control/pipeline.rs | 2 +- src/api/control/room.rs | 4 +- src/api/error_codes.rs | 2 +- src/conf/control_api.rs | 6 +-- src/conf/mod.rs | 2 +- src/conf/server.rs | 14 +++---- src/signalling/elements/member.rs | 4 +- src/signalling/room.rs | 4 +- src/signalling/room_service.rs | 40 +++++++++++++++---- 17 files changed, 85 insertions(+), 57 deletions(-) diff --git a/proto/control-api/src/lib.rs b/proto/control-api/src/lib.rs index d79956bf5..5a578d432 100644 --- a/proto/control-api/src/lib.rs +++ b/proto/control-api/src/lib.rs @@ -1,7 +1,7 @@ //! Generated [Medea]'s [Control API] specs. //! //! [Medea]: https://github.com/instrumentisto/medea -//! [Control API]: http://tiny.cc/380uaz +//! [Control API]: https://tinyurl.com/yxsqplq7 #[cfg(feature = "grpc")] pub mod grpc; diff --git a/src/api/client/mod.rs b/src/api/client/mod.rs index c1157a9e5..92972d0c9 100644 --- a/src/api/client/mod.rs +++ b/src/api/client/mod.rs @@ -1,6 +1,6 @@ //! Implementation of [Client API]. //! -//! [Client API]: http://tiny.cc/c80uaz +//! [Client API]: https://tinyurl.com/yx9thsnr mod session; diff --git a/src/api/control/endpoints/webrtc_play_endpoint.rs b/src/api/control/endpoints/webrtc_play_endpoint.rs index b24069e62..ac2f2e20a 100644 --- a/src/api/control/endpoints/webrtc_play_endpoint.rs +++ b/src/api/control/endpoints/webrtc_play_endpoint.rs @@ -1,6 +1,6 @@ //! `WebRtcPlayEndpoint` [Control API]'s element implementation. //! -//! [Control API]: http://tiny.cc/380uaz +//! [Control API]: https://tinyurl.com/yxsqplq7 use std::{convert::TryFrom, fmt}; @@ -45,7 +45,7 @@ impl TryFrom<&WebRtcPlayEndpointProto> for WebRtcPlayEndpoint { /// Errors which can happen while parsing [`SrcUri`] from [Control API] specs. /// -/// [Control API]: http://tiny.cc/380uaz +/// [Control API]: https://tinyurl.com/yxsqplq7 #[derive(Debug, Fail, Display)] pub enum SrcParseError { /// Provided not source URI. @@ -71,7 +71,7 @@ pub enum SrcParseError { /// /// [`WebRtcPublishEndpoint`]: /// crate::api::control::endpoints::WebRtcPublishEndpoint -/// [Control API]: http://tiny.cc/380uaz +/// [Control API]: https://tinyurl.com/yxsqplq7 #[derive(Clone, Debug)] pub struct SrcUri { /// ID of [`Room`]. diff --git a/src/api/control/endpoints/webrtc_publish_endpoint.rs b/src/api/control/endpoints/webrtc_publish_endpoint.rs index f3e3a2cb0..5b56d25a9 100644 --- a/src/api/control/endpoints/webrtc_publish_endpoint.rs +++ b/src/api/control/endpoints/webrtc_publish_endpoint.rs @@ -1,6 +1,6 @@ //! `WebRtcPublishEndpoint` [Control API]'s element implementation. //! -//! [Control API]: http://tiny.cc/380uaz +//! [Control API]: https://tinyurl.com/yxsqplq7 use derive_more::{Display, From, Into}; use serde::Deserialize; diff --git a/src/api/control/grpc/mod.rs b/src/api/control/grpc/mod.rs index 6243fe909..faabc3c40 100644 --- a/src/api/control/grpc/mod.rs +++ b/src/api/control/grpc/mod.rs @@ -1,5 +1,5 @@ //! Implementation of [Control API] gRPC server. //! -//! [Control API]: http://tiny.cc/380uaz +//! [Control API]: https://tinyurl.com/yxsqplq7 pub mod server; diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index 18b375a56..d4836c81e 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -1,6 +1,6 @@ //! Implementation of [Control API] gRPC server. //! -//! [Control API]: http://tiny.cc/380uaz +//! [Control API]: https://tinyurl.com/yxsqplq7 use std::{collections::HashMap, convert::TryFrom, sync::Arc}; @@ -45,7 +45,7 @@ use crate::{ /// Errors which can happen while processing requests to gRPC [Control API]. /// -/// [Control API]: http://tiny.cc/380uaz +/// [Control API]: https://tinyurl.com/yxsqplq7 #[derive(Debug, Display, Fail)] pub enum GrpcControlApiError { /// Error while parsing [`LocalUri`] of element. @@ -54,7 +54,7 @@ pub enum GrpcControlApiError { /// Error which can happen while converting protobuf objects into interior /// [medea] [Control API] objects. /// - /// [Control API]: http://tiny.cc/380uaz + /// [Control API]: https://tinyurl.com/yxsqplq7 /// [medea]: https://github.com/instrumentisto/medea TryFromProtobuf(TryFromProtobufError), @@ -62,7 +62,7 @@ pub enum GrpcControlApiError { /// should be catched by `try_from_protobuf` function which returns /// [`TryFromProtobufError`]. /// - /// [Control API]: http://tiny.cc/380uaz + /// [Control API]: https://tinyurl.com/yxsqplq7 TryFromElement(TryFromElementError), /// [`MailboxError`] for [`RoomService`]. @@ -132,7 +132,7 @@ struct ControlApiService { /// Public URL of server. Address for exposed [Client API]. /// - /// [Client API]: http://tiny.cc/c80uaz + /// [Client API]: https://tinyurl.com/yx9thsnr public_url: String, } @@ -261,6 +261,7 @@ impl ControlApiService { } } + /// Deletes element by [`IdRequest`]. pub fn delete_element( &self, mut req: IdRequest, @@ -294,6 +295,7 @@ impl ControlApiService { ) } + /// Returns requested by [`IdRequest`] [`Element`]s serialized to protobuf. pub fn get_element( &self, mut req: IdRequest, @@ -330,7 +332,7 @@ impl ControlApiService { impl ControlApi for ControlApiService { /// Implementation for `Create` method of gRPC [Control API]. /// - /// [Control API]: http://tiny.cc/380uaz + /// [Control API]: https://tinyurl.com/yxsqplq7 fn create( &mut self, ctx: RpcContext, @@ -364,7 +366,7 @@ impl ControlApi for ControlApiService { /// Currently this is stub which returns fail response with /// [`RpcStatusCode::Unimplemented`]. /// - /// [Control API]: http://tiny.cc/380uaz + /// [Control API]: https://tinyurl.com/yxsqplq7 fn apply( &mut self, ctx: RpcContext, @@ -390,7 +392,7 @@ impl ControlApi for ControlApiService { /// Implementation for `Delete` method of gRPC [Control API]. /// - /// [Control API]: http://tiny.cc/380uaz + /// [Control API]: https://tinyurl.com/yxsqplq7 fn delete( &mut self, ctx: RpcContext, @@ -418,7 +420,7 @@ impl ControlApi for ControlApiService { /// Implementation for `Get` method of gRPC [Control API]. /// - /// [Control API]: http://tiny.cc/380uaz + /// [Control API]: https://tinyurl.com/yxsqplq7 fn get( &mut self, ctx: RpcContext, @@ -458,7 +460,7 @@ impl ControlApi for ControlApiService { /// Actor wrapper for [`grpcio`] gRPC server which provides dynamic [Control /// API]. /// -/// [Control API]: http://tiny.cc/380uaz +/// [Control API]: https://tinyurl.com/yxsqplq7 #[allow(clippy::module_name_repetitions)] pub struct GrpcServer(Server); @@ -495,7 +497,7 @@ impl Handler for GrpcServer { /// Run gRPC [Control API] server in actix actor. /// -/// [Control API]: http://tiny.cc/380uaz +/// [Control API]: https://tinyurl.com/yxsqplq7 pub fn run(room_repo: Addr, app: &AppContext) -> Addr { let bind_ip = app.config.server.control.grpc.bind_ip.to_string(); let bind_port = app.config.server.control.grpc.bind_port; diff --git a/src/api/control/member.rs b/src/api/control/member.rs index cb82f86dc..b46922bd4 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -1,6 +1,6 @@ //! Definitions and implementations of [Control API]'s `Member` element. //! -//! [Control API]: http://tiny.cc/380uaz +//! [Control API]: https://tinyurl.com/yxsqplq7 use std::{collections::HashMap, convert::TryFrom}; @@ -37,15 +37,15 @@ pub struct Id(pub String); #[serde(tag = "kind")] pub enum MemberElement { /// Represent [`WebRtcPublishEndpoint`]. - /// Can transform into [`Endpoint`] enum by `Endpoint::try_from`. + /// Can transform into [`EndpointSpec`] enum by `EndpointSpec::try_from`. /// - /// [`Endpoint`]: crate::api::control::endpoints::Endpoint + /// [`EndpointSpec`]: crate::api::control::endpoints::EndpointSpec WebRtcPublishEndpoint { spec: WebRtcPublishEndpoint }, /// Represent [`WebRtcPlayEndpoint`]. - /// Can transform into [`Endpoint`] enum by `Endpoint::try_from`. + /// Can transform into [`EndpointSpec`] enum by `EndpointSpec::try_from`. /// - /// [`Endpoint`]: crate::api::control::endpoints::Endpoint + /// [`EndpointSpec`]: crate::api::control::endpoints::EndpointSpec WebRtcPlayEndpoint { spec: WebRtcPlayEndpoint }, } diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index 82f340da8..d8a9f7882 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -1,6 +1,6 @@ //! Implementation and definitions of [Control API] specs. //! -//! [Control API]: http://tiny.cc/380uaz +//! [Control API]: https://tinyurl.com/yxsqplq7 pub mod endpoints; pub mod grpc; @@ -80,7 +80,7 @@ impl From for TryFromProtobufError { /// Root elements of [Control API] spec. /// -/// [Control API]: http://tiny.cc/380uaz +/// [Control API]: https://tinyurl.com/yxsqplq7 #[derive(Clone, Deserialize, Debug)] #[serde(tag = "kind")] pub enum RootElement { @@ -110,7 +110,7 @@ pub enum TryFromElementError { /// Errors which can happen while loading static [Control API] specs. /// -/// [Control API]: http://tiny.cc/380uaz +/// [Control API]: https://tinyurl.com/yxsqplq7 #[allow(clippy::pub_enum_variant_names)] #[derive(Debug, Fail, Display)] pub enum LoadStaticControlSpecsError { @@ -121,19 +121,19 @@ pub enum LoadStaticControlSpecsError { /// Atm we only should print `warn!` message to log which prints that /// static specs not loaded. /// - /// [Control API]: http://tiny.cc/380uaz + /// [Control API]: https://tinyurl.com/yxsqplq7 #[display(fmt = "Error while reading static control API specs dir.")] SpecDirReadError(std::io::Error), /// I/O error while reading static [Control API] specs. /// - /// [Control API]: http://tiny.cc/380uaz + /// [Control API]: https://tinyurl.com/yxsqplq7 #[display(fmt = "I/O error while reading specs. {:?}", _0)] IoError(std::io::Error), /// Conflict in static [Control API] specs. /// - /// [Control API]: http://tiny.cc/380uaz + /// [Control API]: https://tinyurl.com/yxsqplq7 #[display( fmt = "Try from element error while loading static specs. {:?}", _0 @@ -142,7 +142,7 @@ pub enum LoadStaticControlSpecsError { /// Error while deserialization static [Control API] specs from YAML file. /// - /// [Control API]: http://tiny.cc/380uaz + /// [Control API]: https://tinyurl.com/yxsqplq7 #[display(fmt = "Error while deserialization static spec. {:?}", _0)] YamlDeserializationError(serde_yaml::Error), } @@ -194,7 +194,7 @@ pub fn load_static_specs_from_dir>( /// Starts all [`Room`]s from static [Control API] specs. /// -/// [Control API]: http://tiny.cc/380uaz +/// [Control API]: https://tinyurl.com/yxsqplq7 /// [`Room`]: crate::signalling::room::Room pub fn start_static_rooms( room_service: &Addr, diff --git a/src/api/control/pipeline.rs b/src/api/control/pipeline.rs index ec6fdd4d8..d94d1ad52 100644 --- a/src/api/control/pipeline.rs +++ b/src/api/control/pipeline.rs @@ -1,6 +1,6 @@ //! Definitions and implementations of [Control API]'s `Pipeline`. //! -//! [Control API]: http://tiny.cc/380uaz +//! [Control API]: https://tinyurl.com/yxsqplq7 use std::{ collections::{hash_map::Iter, HashMap}, diff --git a/src/api/control/room.rs b/src/api/control/room.rs index dcc362308..cb0f84aab 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -1,6 +1,6 @@ //! Definitions and implementations of [Control API]'s `Room` element. //! -//! [Control API]: http://tiny.cc/380uaz +//! [Control API]: https://tinyurl.com/yxsqplq7 use std::{collections::HashMap, convert::TryFrom}; @@ -44,7 +44,7 @@ pub enum RoomElement { /// /// Newtype for [`RootElement::Room`]. /// -/// [Control API]: http://tiny.cc/380uaz +/// [Control API]: https://tinyurl.com/yxsqplq7 #[allow(clippy::module_name_repetitions)] #[derive(Clone, Debug)] pub struct RoomSpec { diff --git a/src/api/error_codes.rs b/src/api/error_codes.rs index 90d311158..4edfba0d6 100644 --- a/src/api/error_codes.rs +++ b/src/api/error_codes.rs @@ -123,7 +123,7 @@ impl Into for ErrorResponse { /// [Medea]'s [Control API] errors. /// /// [Medea]: https://github.com/instrumentisto/medea -/// [Control API]: http://tiny.cc/380uaz +/// [Control API]: https://tinyurl.com/yxsqplq7 #[derive(Debug, Display)] pub enum ErrorCode { /// Unimplemented API call. diff --git a/src/conf/control_api.rs b/src/conf/control_api.rs index 056418285..6f5f49d55 100644 --- a/src/conf/control_api.rs +++ b/src/conf/control_api.rs @@ -1,20 +1,20 @@ //! [Control API] settings. //! -//! [Control API]: http://tiny.cc/380uaz +//! [Control API]: https://tinyurl.com/yxsqplq7 use serde::{Deserialize, Serialize}; use smart_default::SmartDefault; /// [Control API] settings. /// -/// [Control API]: http://tiny.cc/380uaz +/// [Control API]: https://tinyurl.com/yxsqplq7 #[allow(clippy::module_name_repetitions)] #[derive(Clone, Debug, Deserialize, Serialize, SmartDefault)] #[serde(default)] pub struct ControlApi { /// Path to directory with static [Сontrol API] specs. /// - /// [Control API]: http://tiny.cc/380uaz + /// [Control API]: https://tinyurl.com/yxsqplq7 #[default(String::from("specs/"))] pub static_specs_dir: String, } diff --git a/src/conf/mod.rs b/src/conf/mod.rs index 614edf3fb..eb888b530 100644 --- a/src/conf/mod.rs +++ b/src/conf/mod.rs @@ -53,7 +53,7 @@ pub struct Conf { /// [Control API] settings. /// - /// [Control API]: http://tiny.cc/380uaz + /// [Control API]: https://tinyurl.com/yxsqplq7 pub control_api: ControlApi, } diff --git a/src/conf/server.rs b/src/conf/server.rs index 261140c91..35362c898 100644 --- a/src/conf/server.rs +++ b/src/conf/server.rs @@ -7,14 +7,14 @@ use super::{grpc_listener::GrpcListener, http_listener::HttpListener}; /// [Client API] servers settings. /// -/// [Client API]: http://tiny.cc/c80uaz +/// [Client API]: https://tinyurl.com/yx9thsnr #[allow(clippy::module_name_repetitions)] #[derive(Clone, Debug, Deserialize, Serialize, SmartDefault)] #[serde(default)] pub struct ClientApiServer { /// [Client API] server settings. /// - /// [Client API]: http://tiny.cc/c80uaz + /// [Client API]: https://tinyurl.com/yx9thsnr pub http: HttpListener, /// Public URL of server. Address for exposed [Client API]. @@ -24,7 +24,7 @@ pub struct ClientApiServer { /// /// Defaults to `ws://0.0.0.0:8080`. /// - /// [Client API]: http://tiny.cc/c80uaz + /// [Client API]: https://tinyurl.com/yx9thsnr /// [Jason]: https://github.com/instrumentisto/medea/tree/master/jason #[default("ws://0.0.0.0:8080".to_string())] pub public_url: String, @@ -32,14 +32,14 @@ pub struct ClientApiServer { /// [Control API] servers settings. /// -/// [Control API]: http://tiny.cc/380uaz +/// [Control API]: https://tinyurl.com/yxsqplq7 #[allow(clippy::module_name_repetitions)] #[derive(Clone, Debug, Deserialize, Serialize, SmartDefault)] #[serde(default)] pub struct ControlApiServer { /// gRPC [Control API] server settings. /// - /// [Control API]: http://tiny.cc/380uaz + /// [Control API]: https://tinyurl.com/yxsqplq7 pub grpc: GrpcListener, } @@ -49,12 +49,12 @@ pub struct ControlApiServer { pub struct Server { /// [Client API] servers settings. /// - /// [Client API]: http://tiny.cc/c80uaz + /// [Client API]: https://tinyurl.com/yx9thsnr pub client: ClientApiServer, /// [Control API] servers settings. /// - /// [Control API]: http://tiny.cc/380uaz + /// [Control API]: https://tinyurl.com/yxsqplq7 pub control: ControlApiServer, } diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index 403988373..2f94f4af2 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -44,9 +44,9 @@ pub enum MembersLoadError { #[display(fmt = "Member [id = {}] not found.", _0)] MemberNotFound(LocalUri), - /// [`Endpoint`] not found. + /// [`EndpointSpec`] not found. /// - /// [`Endpoint`]: crate::api::control::endpoint::Endpoint + /// [`EndpointSpec`]: crate::api::control::endpoints::EndpointSpec #[display( fmt = "Endpoint [id = {}] was referenced but not found in spec", _0 diff --git a/src/signalling/room.rs b/src/signalling/room.rs index f910c166a..1b5086754 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -605,8 +605,8 @@ impl Room { ) .collect(); - // TODO: dont remove peers, add some meaningfull close frame: - // CloseRoom, Evicted + // Send PeersRemoved to `Member`s which have related to this + // `Member` `Peer`s. self.remove_peers(&member.id(), peers, ctx); self.members.delete_member(member_id, ctx); diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index bbf5ae799..5d706a01e 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -55,7 +55,7 @@ pub enum RoomServiceError { /// Error which can happen while loading static [Control API] specs. /// - /// [Control API]: http://tiny.cc/380uaz + /// [Control API]: https://tinyurl.com/yxsqplq7 #[display(fmt = "Failed to load static specs. {:?}", _0)] FailedToLoadStaticSpecs(LoadStaticControlSpecsError), @@ -102,7 +102,7 @@ pub struct RoomService { /// Path to directory with static [Сontrol API] specs. /// - /// [Control API]: http://tiny.cc/380uaz + /// [Control API]: https://tinyurl.com/yxsqplq7 static_specs_dir: String, } @@ -202,7 +202,7 @@ impl Handler for RoomService { pub struct CreateRoom { /// [Control API] spec for [`Room`]. /// - /// [Control API]: http://tiny.cc/380uaz + /// [Control API]: https://tinyurl.com/yxsqplq7 pub spec: RoomSpec, } @@ -379,7 +379,7 @@ impl DeleteElements { /// This is just validation for errors which we can catch before sending /// message. /// -/// [Control API]: http://tiny.cc/380uaz +/// [Control API]: https://tinyurl.com/yxsqplq7 #[derive(Message, Default)] #[rtype(result = "Result<(), RoomServiceError>")] pub struct DeleteElements { @@ -569,6 +569,11 @@ mod room_service_specs { use super::*; + /// Returns [`RoomSpec`] parsed from + /// `../../tests/specs/pub-sub-video-call.yml` file. + /// + /// Note that YAML spec is loading on compile time with [`include_str`] + /// macro. fn room_spec() -> RoomSpec { const ROOM_SPEC: &str = include_str!("../../tests/specs/pub-sub-video-call.yml"); @@ -577,11 +582,14 @@ mod room_service_specs { RoomSpec::try_from(&parsed).unwrap() } + /// Returns [`AppContext`] with default [`Conf`] and mocked + /// [`TurnAuthService`]. fn app_ctx() -> AppContext { let turn_service = crate::turn::new_turn_auth_service_mock(); AppContext::new(Conf::default(), turn_service) } + /// Returns [`Addr`] to [`RoomService`]. fn room_service(room_repo: RoomRepository) -> Addr { let conf = Conf::default(); let shutdown_timeout = conf.shutdown.timeout.clone(); @@ -592,14 +600,24 @@ mod room_service_specs { RoomService::new(room_repo, app, graceful_shutdown).start() } + /// Returns [`Future`] used for testing of all create methods of + /// [`RoomService`]. + /// + /// This macro automatically stops [`actix::System`] when test completed. + /// + /// `$room_service` - [`Addr`] to [`RoomService`], + /// `$create_msg` - [`actix::Message`] which will create `Element`, + /// `$element_uri` - [`StatefulLocalUri`] to `Element` which you try to + /// create, `$test` - closure in which will be provided created + /// [`Element`]. macro_rules! test_for_create { ( $room_service:expr, $create_msg:expr, - $caller_uri:expr, + $element_uri:expr, $test:expr ) => {{ - let get_msg = Get(vec![$caller_uri.clone()]); + let get_msg = Get(vec![$element_uri.clone()]); $room_service .send($create_msg) .and_then(move |res| { @@ -608,7 +626,7 @@ mod room_service_specs { }) .map(move |r| { let mut resp = r.unwrap(); - resp.remove(&$caller_uri).unwrap() + resp.remove(&$element_uri).unwrap() }) .map($test) .map(|_| actix::System::current().stop()) @@ -725,6 +743,14 @@ mod room_service_specs { sys.run().unwrap(); } + /// Returns [`Future`] used for testing of all delete/get methods of + /// [`RoomService`]. + /// + /// This test is simply try to delete element with provided + /// [`StatefulLocalUri`] and the try to get it. If result of getting + /// deleted element is error then test considers successful. + /// + /// This function automatically stops [`actix::System`] when test completed. fn test_for_delete_and_get( room_service: Addr, element_stateful_uri: StatefulLocalUri, From 07f15dcfbabea8101a05c53618de990510657081 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 24 Sep 2019 19:45:05 +0300 Subject: [PATCH 664/735] Reread [run ci] --- config.toml | 40 ++++++++++++++++---------------- src/api/control/endpoints/mod.rs | 5 +--- src/api/control/member.rs | 7 +++--- src/api/control/room.rs | 5 +--- src/signalling/participants.rs | 2 -- src/signalling/room_service.rs | 13 +++++++---- 6 files changed, 34 insertions(+), 38 deletions(-) diff --git a/config.toml b/config.toml index 33d803a99..d3b591a78 100644 --- a/config.toml +++ b/config.toml @@ -1,7 +1,7 @@ [server.client] # Server's public URL. # -# Environment variable: MEDEA_SERVER.CLIENT.PUBLIC_URL +# Environment variable: MEDEA_SERVER__CLIENT__PUBLIC_URL # # Default: # public_url = "ws://0.0.0.0:8080" @@ -9,14 +9,14 @@ [server.client.http] # IP address to bind HTTP server to. # -# Environment variable: MEDEA_SERVER.CLIENT.HTTP.BIND_IP +# Environment variable: MEDEA_SERVER__CLIENT__HTTP__BIND_IP # # Default: # bind_ip = "0.0.0.0" # Port to bind HTTP server to. # -# Environment variable: MEDEA_SERVER.CLIENT.HTTP.BIND_PORT +# Environment variable: MEDEA_SERVER__CLIENT__HTTP__BIND_PORT # # Default: # bind_port = 8080 @@ -24,21 +24,21 @@ [server.control.grpc] # IP address to bind gRPC server to. # -# Environment variable: MEDEA_SERVER.CONTROL.GRPC.BIND_IP +# Environment variable: MEDEA_SERVER__CONTROL__GRPC__BIND_IP # # Default: # bind_ip = "0.0.0.0" # Port to bind gRPC server to. # -# Environment variable: MEDEA_SERVER.CONTROL.GRPC.BIND_PORT +# Environment variable: MEDEA_SERVER__CONTROL__GRPC__BIND_PORT # # Default: # bind_port = 6565 # Completion queue count of gRPC server. # -# Environment variable: MEDEA_SERVER.CONTROL.GRPC.COMPLETION_QUEUE_COUNT +# Environment variable: MEDEA_SERVER__CONTROL__GRPC__COMPLETION_QUEUE_COUNT # # Default: # completion_queue_count = 2 @@ -47,7 +47,7 @@ [control_api] # Path to directory with static Сontrol API specs. # -# Environment variable: MEDEA_CONTROL_API.STATIC_SPECS_DIR +# Environment variable: MEDEA_CONTROL_API__STATIC_SPECS_DIR # # Default: # static_specs_dir = "specs/" @@ -59,7 +59,7 @@ # Duration, after which remote RPC client will be considered idle if no # heartbeat messages received. # -# Environment variable: MEDEA_RPC.IDLE_TIMEOUT +# Environment variable: MEDEA_RPC__IDLE_TIMEOUT # # Default: # idle_timeout = "10s" @@ -67,7 +67,7 @@ # Duration, after which the server deletes the client session if # the remote RPC client does not reconnect after it is idle. # -# Environment variable: MEDEA_RPC.RECONNECT_TIMEOUT +# Environment variable: MEDEA_RPC__RECONNECT_TIMEOUT # # Default: # reconnect_timeout = "10s" @@ -78,28 +78,28 @@ [turn] # Turn server host. # -# Environment variable: MEDEA_TURN.HOST +# Environment variable: MEDEA_TURN__HOST # # Default: # host = "localhost" # Turn server port. # -# Environment variable: MEDEA_TURN.PORT +# Environment variable: MEDEA_TURN__PORT # # Default: # port = 3478 # Static user on Turn server. # -# Environment variable: MEDEA_TURN.USER +# Environment variable: MEDEA_TURN__USER # # Default: # user = "USER" # Static user password on Turn server. # -# Environment variable: MEDEA_TURN.PASS +# Environment variable: MEDEA_TURN__PASS # # Default: # pass = "PASS" @@ -107,35 +107,35 @@ [turn.db.redis] # Host of Coturn's Redis database. # -# Environment variable: MEDEA_TURN.DB.REDIS.IP +# Environment variable: MEDEA_TURN__DB__REDIS__IP # # Default: # ip = "127.0.0.1" # Port of Coturn's Redis database for client connections. # -# Environment variable: MEDEA_TURN.DB.REDIS.PORT +# Environment variable: MEDEA_TURN__DB__REDIS__PORT # # Default: # port = 6379 # Password to connect to Coturn's Redis database with. # -# Environment variable: MEDEA_TURN.DB.REDIS.PASS +# Environment variable: MEDEA_TURN__DB__REDIS__PASS # # Default: # pass = "turn" # Number of Coturn's database in Redis. # -# Environment variable: MEDEA_TURN.DB.REDIS.DB_NUMBER +# Environment variable: MEDEA_TURN__DB__REDIS__DB_NUMBER # # Default: # db_number = 0 # Timeout for establishing connection with Coturn's Redis database. # -# Environment variable: MEDEA_TURN.DB.REDIS.CONNECTION_TIMEOUT +# Environment variable: MEDEA_TURN__DB__REDIS__CONNECTION_TIMEOUT # # Default: # connection_timeout = "5s" @@ -146,7 +146,7 @@ [log] # Maximum allowed level of application log entries. # -# Environment variable: MEDEA_LOG.LEVEL +# Environment variable: MEDEA_LOG__LEVEL # # Possible values: # "OFF", "CRITICAL", "ERROR", "WARN", "INFO", "DEBUG", "TRACE" @@ -160,7 +160,7 @@ [shutdown] # Maximum duration given to shutdown the whole application gracefully. # -# Environment variable: MEDEA_SHUTDOWN.TIMEOUT +# Environment variable: MEDEA_SHUTDOWN__TIMEOUT # # Default: # timeout = "5s" diff --git a/src/api/control/endpoints/mod.rs b/src/api/control/endpoints/mod.rs index 534a3937f..238a31ca9 100644 --- a/src/api/control/endpoints/mod.rs +++ b/src/api/control/endpoints/mod.rs @@ -99,12 +99,9 @@ impl TryFrom<(Id, MemberElementProto)> for EndpointSpec { impl TryFrom<(Id, ElementProto)> for EndpointSpec { type Error = TryFromProtobufError; - fn try_from(value: (Id, ElementProto)) -> Result { + fn try_from((id, proto): (Id, ElementProto)) -> Result { use ElementProto::*; - let id = value.0; - let proto = value.1; - match proto { webrtc_play(elem) => { let play = WebRtcPlayEndpoint::try_from(&elem)?; diff --git a/src/api/control/member.rs b/src/api/control/member.rs index b46922bd4..e9b1b25b9 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -132,10 +132,9 @@ macro_rules! impl_try_from_proto_for_member { impl TryFrom<(Id, $proto)> for MemberSpec { type Error = TryFromProtobufError; - fn try_from(value: (Id, $proto)) -> Result { - let id = value.0; - let proto = value.1; - + fn try_from( + (id, proto): (Id, $proto), + ) -> Result { match proto { $proto::member(mut member) => { let mut pipeline = HashMap::new(); diff --git a/src/api/control/room.rs b/src/api/control/room.rs index cb0f84aab..e3eb311fa 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -55,10 +55,7 @@ pub struct RoomSpec { impl TryFrom<(Id, ElementProto)> for RoomSpec { type Error = TryFromProtobufError; - fn try_from(value: (Id, ElementProto)) -> Result { - let id = value.0; - let proto = value.1; - + fn try_from((id, proto): (Id, ElementProto)) -> Result { match proto { ElementProto::room(mut room) => { let mut pipeline = HashMap::new(); diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 4ea69aaee..6d6cce6bb 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -384,8 +384,6 @@ impl ParticipantService { let mut close_fut = self.connections.drain().fold( vec![], |mut futures, (_, mut connection)| { - // TODO: change close reason on 47-rpc-connection-loss branch - // (remove room or resetting room) futures.push(connection.close(CloseDescription::new( RpcConnectionCloseReason::RoomClosed, ))); diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index 5d706a01e..3cada6185 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -92,6 +92,8 @@ pub struct RoomService { room_repo: RoomRepository, /// Global app context. + /// + /// Used for providing [`AppContext`] to the newly created [`Room`]s. app: AppContext, /// Address to [`GracefulShutdown`]. @@ -338,7 +340,6 @@ impl DeleteElements { self.uris.push(uri) } - // TODO: tests /// Validates request. It must have at least one uri, all uris must share /// same [`RoomId`]. pub fn validate( @@ -391,7 +392,7 @@ impl Handler> for RoomService { type Result = ResponseFuture<(), RoomServiceError>; // TODO: delete 'clippy::unnecessary_filter_map` when drain_filter TODO will - // be resolved. + // be resolved. #[allow(clippy::if_not_else, clippy::unnecessary_filter_map)] fn handle( &mut self, @@ -572,7 +573,7 @@ mod room_service_specs { /// Returns [`RoomSpec`] parsed from /// `../../tests/specs/pub-sub-video-call.yml` file. /// - /// Note that YAML spec is loading on compile time with [`include_str`] + /// Note that YAML spec is loads on compile time with [`include_str`] /// macro. fn room_spec() -> RoomSpec { const ROOM_SPEC: &str = @@ -606,9 +607,13 @@ mod room_service_specs { /// This macro automatically stops [`actix::System`] when test completed. /// /// `$room_service` - [`Addr`] to [`RoomService`], + /// /// `$create_msg` - [`actix::Message`] which will create `Element`, + /// /// `$element_uri` - [`StatefulLocalUri`] to `Element` which you try to - /// create, `$test` - closure in which will be provided created + /// create, + /// + /// `$test` - closure in which will be provided created /// [`Element`]. macro_rules! test_for_create { ( From 1f0f8e75d444a29c145318e68607eff424ea0f0d Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 25 Sep 2019 14:43:24 +0300 Subject: [PATCH 665/735] Add E2E tests for gRPC Control API --- tests/e2e/grpc_control_api/mod.rs | 261 ++++++++++++++++++++++++++++++ tests/e2e/main.rs | 1 + 2 files changed, 262 insertions(+) create mode 100644 tests/e2e/grpc_control_api/mod.rs diff --git a/tests/e2e/grpc_control_api/mod.rs b/tests/e2e/grpc_control_api/mod.rs new file mode 100644 index 000000000..303057ac8 --- /dev/null +++ b/tests/e2e/grpc_control_api/mod.rs @@ -0,0 +1,261 @@ +use std::{collections::HashMap, sync::Arc}; + +use actix_web::web::delete; +use grpcio::{ChannelBuilder, EnvBuilder}; +use medea::api::error_codes::ErrorCode as MedeaErrorCode; +use medea_control_api_proto::grpc::{ + control_api::{ + ApplyRequest, CreateRequest, CreateResponse, Element, Error, + GetResponse, IdRequest, Member, Member_Element, Room, Room_Element, + WebRtcPlayEndpoint, WebRtcPublishEndpoint, WebRtcPublishEndpoint_P2P, + }, + control_api_grpc::ControlApiClient, +}; +use protobuf::RepeatedField; +use serde_json::error::ErrorCode::ControlCharacterWhileParsingString; + +struct ControlClient(ControlApiClient); + +impl ControlClient { + pub fn new() -> Self { + let env = Arc::new(EnvBuilder::new().build()); + let ch = ChannelBuilder::new(env).connect("localhost:6565"); + ControlClient(ControlApiClient::new(ch)) + } + + pub fn get(&self, uri: &str) -> Element { + let mut get_room_request = IdRequest::new(); + let mut room = RepeatedField::new(); + room.push(uri.to_string()); + get_room_request.set_id(room); + + let mut resp = self.0.get(&get_room_request).expect("get room"); + if resp.has_error() { + panic!("{:?}", resp.get_error()); + } + resp.take_elements().remove(&uri.to_string()).unwrap() + } + + pub fn try_get(&self, uri: &str) -> Result { + let mut get_room_request = IdRequest::new(); + let mut room = RepeatedField::new(); + room.push(uri.to_string()); + get_room_request.set_id(room); + + let mut resp = self.0.get(&get_room_request).expect("get room"); + if resp.has_error() { + return Err(resp.take_error()); + } + Ok(resp.take_elements().remove(&uri.to_string()).unwrap()) + } + + pub fn create(&self, req: CreateRequest) -> HashMap { + let resp = self.0.create(&req).expect("create endpoint"); + if resp.has_error() { + panic!("{:?}", resp.get_error()); + } + + resp.sid + } + + pub fn delete(&self, ids: &[&str]) { + let mut delete_req = IdRequest::new(); + let mut delete_ids = RepeatedField::new(); + ids.into_iter() + .for_each(|id| delete_ids.push(id.to_string())); + delete_req.set_id(delete_ids); + + let resp = self.0.delete(&delete_req).unwrap(); + if resp.has_error() { + panic!("{:?}", resp.get_error()); + } + } +} + +fn create_room_req(room_id: &str) -> CreateRequest { + let mut create_req = CreateRequest::new(); + let mut room = Room::new(); + let mut publisher = Member::new(); + let mut responder = Member::new(); + let mut play_endpoint = WebRtcPlayEndpoint::new(); + let mut publish_endpoint = WebRtcPublishEndpoint::new(); + + play_endpoint.set_src(format!("local://{}/publisher/publish", room_id)); + let mut play_endpoint_element = Member_Element::new(); + play_endpoint_element.set_webrtc_play(play_endpoint); + let mut responder_pipeline = HashMap::new(); + responder_pipeline.insert("play".to_string(), play_endpoint_element); + responder.set_pipeline(responder_pipeline); + responder.set_credentials("test".to_string()); + + publish_endpoint.set_p2p(WebRtcPublishEndpoint_P2P::ALWAYS); + let mut publish_endpoint_element = Member_Element::new(); + publish_endpoint_element.set_webrtc_pub(publish_endpoint); + let mut publisher_pipeline = HashMap::new(); + publisher_pipeline.insert("publish".to_string(), publish_endpoint_element); + publisher.set_pipeline(publisher_pipeline); + + let mut publisher_member_element = Room_Element::new(); + publisher_member_element.set_member(publisher); + let mut responder_member_element = Room_Element::new(); + responder_member_element.set_member(responder); + let mut room_pipeline = HashMap::new(); + room_pipeline.insert("publisher".to_string(), publisher_member_element); + room_pipeline.insert("responder".to_string(), responder_member_element); + room.set_pipeline(room_pipeline); + create_req.set_room(room.clone()); + create_req.set_id(format!("local://{}", room_id)); + + create_req +} + +#[test] +fn create_room() { + let create_req = create_room_req("create-room-e2e-test"); + + let client = ControlClient::new(); + let resp = client.create(create_req); + + let mut get_resp = client.get("local://create-room-e2e-test"); + let room = get_resp.take_room(); + + let responder = room + .get_pipeline() + .get(&"local://create-room-e2e-test/responder".to_string()) + .unwrap() + .get_member(); + assert_eq!(responder.get_credentials(), "test"); + let responder_pipeline = responder.get_pipeline(); + assert_eq!(responder_pipeline.len(), 1); + let responder_play = responder_pipeline + .get(&"local://create-room-e2e-test/responder/play".to_string()) + .unwrap() + .get_webrtc_play(); + assert_eq!( + responder_play.get_src(), + "local://create-room-e2e-test/publisher/publish" + ); + + let publisher = room + .get_pipeline() + .get(&"local://create-room-e2e-test/publisher".to_string()) + .unwrap() + .get_member(); + assert_ne!(publisher.get_credentials(), "test"); + assert_ne!(publisher.get_credentials(), ""); + let publisher_pipeline = responder.get_pipeline(); + assert_eq!(publisher_pipeline.len(), 1); +} + +#[test] +fn create_member() { + let client = ControlClient::new(); + client.create(create_room_req("create-member-e2e-test")); + + let create_req = { + let mut create_member_request = CreateRequest::new(); + let mut member = Member::new(); + let mut member_pipeline = HashMap::new(); + + let mut play_endpoint = WebRtcPlayEndpoint::new(); + play_endpoint.set_src( + "local://create-member-e2e-test/publisher/publish".to_string(), + ); + let mut member_element = Member_Element::new(); + member_element.set_webrtc_play(play_endpoint); + member_pipeline.insert("play".to_string(), member_element); + + member.set_credentials("qwerty".to_string()); + member.set_pipeline(member_pipeline); + create_member_request.set_id( + "local://create-member-e2e-test/e2e-test-member".to_string(), + ); + create_member_request.set_member(member); + + create_member_request + }; + + let sids = client.create(create_req); + let e2e_test_member_sid = + sids.get(&"e2e-test-member".to_string()).unwrap().as_str(); + assert_eq!( + e2e_test_member_sid, + "ws://0.0.0.0:8080/create-member-e2e-test/e2e-test-member/qwerty" + ); + + let member = client + .get("local://create-member-e2e-test/e2e-test-member") + .take_member(); + assert_eq!(member.get_pipeline().len(), 1); + assert_eq!(member.get_credentials(), "qwerty"); +} + +#[test] +fn create_endpoint() { + let client = ControlClient::new(); + client.create(create_room_req("create-endpoint-e2e-test")); + + let create_req = { + let mut create_endpoint_request = CreateRequest::new(); + let mut endpoint = WebRtcPublishEndpoint::new(); + endpoint.set_p2p(WebRtcPublishEndpoint_P2P::NEVER); + create_endpoint_request.set_id( + "local://create-endpoint-e2e-test/responder/publish".to_string(), + ); + create_endpoint_request.set_webrtc_pub(endpoint); + + create_endpoint_request + }; + let sids = client.create(create_req); + assert_eq!(sids.len(), 0); + + let endpoint = client + .get("local://create-endpoint-e2e-test/responder/publish") + .take_webrtc_pub(); + assert_eq!(endpoint.get_p2p(), WebRtcPublishEndpoint_P2P::NEVER); +} + +#[test] +fn delete_room() { + let client = ControlClient::new(); + client.create(create_room_req("delete-room-e2e-test")); + client.delete(&["local://delete-room-e2e-test"]); + + let get_room_err = match client.try_get("local://delete-room-e2e-test") { + Ok(_) => panic!("Room not deleted!"), + Err(e) => e, + }; + assert_eq!(get_room_err.code, MedeaErrorCode::RoomNotFound as u32); +} + +#[test] +fn delete_member() { + let client = ControlClient::new(); + client.create(create_room_req("delete-member-e2e-test")); + client.delete(&["local://delete-member-e2e-test/publisher"]); + + let get_member_err = + match client.try_get("local://delete-member-e2e-test/publisher") { + Ok(_) => panic!("Member not deleted!"), + Err(e) => e, + }; + assert_eq!(get_member_err.code, MedeaErrorCode::MemberNotFound as u32); +} + +#[test] +fn delete_endpoint() { + let client = ControlClient::new(); + client.create(create_room_req("delete-endpoint-e2e-test")); + client.delete(&["local://delete-endpoint-e2e-test/publisher/publish"]); + + let get_endpoint_err = match client + .try_get("local://delete-endpoint-e2e-test/publisher/publish") + { + Ok(_) => panic!("Endpoint not deleted!"), + Err(e) => e, + }; + assert_eq!( + get_endpoint_err.code, + MedeaErrorCode::EndpointNotFound as u32 + ); +} diff --git a/tests/e2e/main.rs b/tests/e2e/main.rs index 406a0fb40..3fe555569 100644 --- a/tests/e2e/main.rs +++ b/tests/e2e/main.rs @@ -1 +1,2 @@ +mod grpc_control_api; mod signalling; From 28fbbaa41f4a37f14ca971045197aacaed7f29b0 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 25 Sep 2019 15:34:33 +0300 Subject: [PATCH 666/735] Add some tests, refactor --- tests/e2e/grpc_control_api/create.rs | 116 +++++++++++++++++++ tests/e2e/grpc_control_api/delete.rs | 87 ++++++++++++++ tests/e2e/grpc_control_api/mod.rs | 165 ++------------------------- 3 files changed, 210 insertions(+), 158 deletions(-) create mode 100644 tests/e2e/grpc_control_api/create.rs create mode 100644 tests/e2e/grpc_control_api/delete.rs diff --git a/tests/e2e/grpc_control_api/create.rs b/tests/e2e/grpc_control_api/create.rs new file mode 100644 index 000000000..c5b4294bb --- /dev/null +++ b/tests/e2e/grpc_control_api/create.rs @@ -0,0 +1,116 @@ +use std::collections::HashMap; + +use medea_control_api_proto::grpc::control_api::{ + CreateRequest, Member, Member_Element, WebRtcPlayEndpoint, + WebRtcPublishEndpoint, WebRtcPublishEndpoint_P2P, +}; + +use super::{create_room_req, ControlClient}; + +#[test] +fn room() { + let client = ControlClient::new(); + let sids = client.create(&create_room_req("create-room")); + assert_eq!(sids.len(), 2); + sids.get(&"publisher".to_string()).unwrap(); + let responder_sid = sids.get(&"responder".to_string()).unwrap().as_str(); + assert_eq!( + responder_sid, + "ws://0.0.0.0:8080/create-room/responder/test" + ); + + let mut get_resp = client.get("local://create-room"); + let room = get_resp.take_room(); + + let responder = room + .get_pipeline() + .get(&"local://create-room/responder".to_string()) + .unwrap() + .get_member(); + assert_eq!(responder.get_credentials(), "test"); + let responder_pipeline = responder.get_pipeline(); + assert_eq!(responder_pipeline.len(), 1); + let responder_play = responder_pipeline + .get(&"local://create-room/responder/play".to_string()) + .unwrap() + .get_webrtc_play(); + assert_eq!( + responder_play.get_src(), + "local://create-room/publisher/publish" + ); + + let publisher = room + .get_pipeline() + .get(&"local://create-room/publisher".to_string()) + .unwrap() + .get_member(); + assert_ne!(publisher.get_credentials(), "test"); + assert_ne!(publisher.get_credentials(), ""); + let publisher_pipeline = responder.get_pipeline(); + assert_eq!(publisher_pipeline.len(), 1); +} + +#[test] +fn member() { + let client = ControlClient::new(); + client.create(&create_room_req("create-member")); + + let create_req = { + let mut create_member_request = CreateRequest::new(); + let mut member = Member::new(); + let mut member_pipeline = HashMap::new(); + + let mut play_endpoint = WebRtcPlayEndpoint::new(); + play_endpoint + .set_src("local://create-member/publisher/publish".to_string()); + let mut member_element = Member_Element::new(); + member_element.set_webrtc_play(play_endpoint); + member_pipeline.insert("play".to_string(), member_element); + + member.set_credentials("qwerty".to_string()); + member.set_pipeline(member_pipeline); + create_member_request + .set_id("local://create-member/test-member".to_string()); + create_member_request.set_member(member); + + create_member_request + }; + + let sids = client.create(&create_req); + let e2e_test_member_sid = + sids.get(&"test-member".to_string()).unwrap().as_str(); + assert_eq!( + e2e_test_member_sid, + "ws://0.0.0.0:8080/create-member/test-member/qwerty" + ); + + let member = client + .get("local://create-member/test-member") + .take_member(); + assert_eq!(member.get_pipeline().len(), 1); + assert_eq!(member.get_credentials(), "qwerty"); +} + +#[test] +fn endpoint() { + let client = ControlClient::new(); + client.create(&create_room_req("create-endpoint")); + + let create_req = { + let mut create_endpoint_request = CreateRequest::new(); + let mut endpoint = WebRtcPublishEndpoint::new(); + endpoint.set_p2p(WebRtcPublishEndpoint_P2P::NEVER); + create_endpoint_request + .set_id("local://create-endpoint/responder/publish".to_string()); + create_endpoint_request.set_webrtc_pub(endpoint); + + create_endpoint_request + }; + let sids = client.create(&create_req); + assert_eq!(sids.len(), 0); + + let endpoint = client + .get("local://create-endpoint/responder/publish") + .take_webrtc_pub(); + assert_eq!(endpoint.get_p2p(), WebRtcPublishEndpoint_P2P::NEVER); +} diff --git a/tests/e2e/grpc_control_api/delete.rs b/tests/e2e/grpc_control_api/delete.rs new file mode 100644 index 000000000..3d502ce7a --- /dev/null +++ b/tests/e2e/grpc_control_api/delete.rs @@ -0,0 +1,87 @@ +use medea::api::error_codes::{ErrorCode as MedeaErrorCode, ErrorCode}; + +use super::{create_room_req, ControlClient}; + +fn delete_test(room_id: &str, element_id: &str, error_code: MedeaErrorCode) { + let client = ControlClient::new(); + client.create(&create_room_req(room_id)); + client.delete(&[element_id]); + + let get_room_err = match client.try_get(element_id) { + Ok(_) => panic!("{} not deleted!", element_id), + Err(e) => e, + }; + assert_eq!(get_room_err.code, error_code as u32); +} + +#[test] +fn room() { + delete_test( + "delete-room", + "local://delete-room", + ErrorCode::RoomNotFound, + ); +} + +#[test] +fn member() { + delete_test( + "delete-member", + "local://delete-member/publisher", + ErrorCode::MemberNotFound, + ); +} + +#[test] +fn endpoint() { + delete_test( + "delete-endpoint", + "local://delete-endpoint/publisher/publish", + ErrorCode::EndpointNotFound, + ); +} + +fn delete_elements_at_same_time_test( + room_id: &str, + elements_ids: &[&str], + code: MedeaErrorCode, + root_elem_id: &str, +) { + let client = ControlClient::new(); + client.create(&create_room_req(room_id)); + client.delete(elements_ids); + + match client.try_get(root_elem_id) { + Ok(_) => panic!("Member not deleted!"), + Err(e) => { + assert_eq!(e.code, code as u32); + } + } +} + +#[test] +fn member_and_endpoint_same_time() { + delete_elements_at_same_time_test( + "medea-and-endpoint-same-time", + &[ + "local://medea-and-endpoint-same-time/publisher", + "local://medea-and-endpoint-same-time/publisher/publish", + ], + MedeaErrorCode::MemberNotFound, + "local://medea-and-endpoint-same-time/publisher", + ); +} + +#[test] +fn room_and_inner_elements_same_time() { + delete_elements_at_same_time_test( + "room-and-inner-elements-same-time", + &[ + "local://room-and-inner-elements-same-time", + "local://room-and-inner-elements-same-time/publisher", + "local://room-and-inner-elements-same-time/publisher/publish", + ], + MedeaErrorCode::RoomNotFound, + "local://room-and-inner-elements-same-time", + ); +} diff --git a/tests/e2e/grpc_control_api/mod.rs b/tests/e2e/grpc_control_api/mod.rs index 303057ac8..d546a47c8 100644 --- a/tests/e2e/grpc_control_api/mod.rs +++ b/tests/e2e/grpc_control_api/mod.rs @@ -1,18 +1,18 @@ +mod create; +mod delete; + use std::{collections::HashMap, sync::Arc}; -use actix_web::web::delete; use grpcio::{ChannelBuilder, EnvBuilder}; -use medea::api::error_codes::ErrorCode as MedeaErrorCode; use medea_control_api_proto::grpc::{ control_api::{ - ApplyRequest, CreateRequest, CreateResponse, Element, Error, - GetResponse, IdRequest, Member, Member_Element, Room, Room_Element, - WebRtcPlayEndpoint, WebRtcPublishEndpoint, WebRtcPublishEndpoint_P2P, + CreateRequest, Element, Error, IdRequest, Member, Member_Element, Room, + Room_Element, WebRtcPlayEndpoint, WebRtcPublishEndpoint, + WebRtcPublishEndpoint_P2P, }, control_api_grpc::ControlApiClient, }; use protobuf::RepeatedField; -use serde_json::error::ErrorCode::ControlCharacterWhileParsingString; struct ControlClient(ControlApiClient); @@ -49,7 +49,7 @@ impl ControlClient { Ok(resp.take_elements().remove(&uri.to_string()).unwrap()) } - pub fn create(&self, req: CreateRequest) -> HashMap { + pub fn create(&self, req: &CreateRequest) -> HashMap { let resp = self.0.create(&req).expect("create endpoint"); if resp.has_error() { panic!("{:?}", resp.get_error()); @@ -108,154 +108,3 @@ fn create_room_req(room_id: &str) -> CreateRequest { create_req } - -#[test] -fn create_room() { - let create_req = create_room_req("create-room-e2e-test"); - - let client = ControlClient::new(); - let resp = client.create(create_req); - - let mut get_resp = client.get("local://create-room-e2e-test"); - let room = get_resp.take_room(); - - let responder = room - .get_pipeline() - .get(&"local://create-room-e2e-test/responder".to_string()) - .unwrap() - .get_member(); - assert_eq!(responder.get_credentials(), "test"); - let responder_pipeline = responder.get_pipeline(); - assert_eq!(responder_pipeline.len(), 1); - let responder_play = responder_pipeline - .get(&"local://create-room-e2e-test/responder/play".to_string()) - .unwrap() - .get_webrtc_play(); - assert_eq!( - responder_play.get_src(), - "local://create-room-e2e-test/publisher/publish" - ); - - let publisher = room - .get_pipeline() - .get(&"local://create-room-e2e-test/publisher".to_string()) - .unwrap() - .get_member(); - assert_ne!(publisher.get_credentials(), "test"); - assert_ne!(publisher.get_credentials(), ""); - let publisher_pipeline = responder.get_pipeline(); - assert_eq!(publisher_pipeline.len(), 1); -} - -#[test] -fn create_member() { - let client = ControlClient::new(); - client.create(create_room_req("create-member-e2e-test")); - - let create_req = { - let mut create_member_request = CreateRequest::new(); - let mut member = Member::new(); - let mut member_pipeline = HashMap::new(); - - let mut play_endpoint = WebRtcPlayEndpoint::new(); - play_endpoint.set_src( - "local://create-member-e2e-test/publisher/publish".to_string(), - ); - let mut member_element = Member_Element::new(); - member_element.set_webrtc_play(play_endpoint); - member_pipeline.insert("play".to_string(), member_element); - - member.set_credentials("qwerty".to_string()); - member.set_pipeline(member_pipeline); - create_member_request.set_id( - "local://create-member-e2e-test/e2e-test-member".to_string(), - ); - create_member_request.set_member(member); - - create_member_request - }; - - let sids = client.create(create_req); - let e2e_test_member_sid = - sids.get(&"e2e-test-member".to_string()).unwrap().as_str(); - assert_eq!( - e2e_test_member_sid, - "ws://0.0.0.0:8080/create-member-e2e-test/e2e-test-member/qwerty" - ); - - let member = client - .get("local://create-member-e2e-test/e2e-test-member") - .take_member(); - assert_eq!(member.get_pipeline().len(), 1); - assert_eq!(member.get_credentials(), "qwerty"); -} - -#[test] -fn create_endpoint() { - let client = ControlClient::new(); - client.create(create_room_req("create-endpoint-e2e-test")); - - let create_req = { - let mut create_endpoint_request = CreateRequest::new(); - let mut endpoint = WebRtcPublishEndpoint::new(); - endpoint.set_p2p(WebRtcPublishEndpoint_P2P::NEVER); - create_endpoint_request.set_id( - "local://create-endpoint-e2e-test/responder/publish".to_string(), - ); - create_endpoint_request.set_webrtc_pub(endpoint); - - create_endpoint_request - }; - let sids = client.create(create_req); - assert_eq!(sids.len(), 0); - - let endpoint = client - .get("local://create-endpoint-e2e-test/responder/publish") - .take_webrtc_pub(); - assert_eq!(endpoint.get_p2p(), WebRtcPublishEndpoint_P2P::NEVER); -} - -#[test] -fn delete_room() { - let client = ControlClient::new(); - client.create(create_room_req("delete-room-e2e-test")); - client.delete(&["local://delete-room-e2e-test"]); - - let get_room_err = match client.try_get("local://delete-room-e2e-test") { - Ok(_) => panic!("Room not deleted!"), - Err(e) => e, - }; - assert_eq!(get_room_err.code, MedeaErrorCode::RoomNotFound as u32); -} - -#[test] -fn delete_member() { - let client = ControlClient::new(); - client.create(create_room_req("delete-member-e2e-test")); - client.delete(&["local://delete-member-e2e-test/publisher"]); - - let get_member_err = - match client.try_get("local://delete-member-e2e-test/publisher") { - Ok(_) => panic!("Member not deleted!"), - Err(e) => e, - }; - assert_eq!(get_member_err.code, MedeaErrorCode::MemberNotFound as u32); -} - -#[test] -fn delete_endpoint() { - let client = ControlClient::new(); - client.create(create_room_req("delete-endpoint-e2e-test")); - client.delete(&["local://delete-endpoint-e2e-test/publisher/publish"]); - - let get_endpoint_err = match client - .try_get("local://delete-endpoint-e2e-test/publisher/publish") - { - Ok(_) => panic!("Endpoint not deleted!"), - Err(e) => e, - }; - assert_eq!( - get_endpoint_err.code, - MedeaErrorCode::EndpointNotFound as u32 - ); -} From 0f98e2d4bc1e2b3866be58a8938d04576c9dd195 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 25 Sep 2019 16:30:40 +0300 Subject: [PATCH 667/735] Add docs for tests --- tests/e2e/grpc_control_api/create.rs | 7 +++ tests/e2e/grpc_control_api/delete.rs | 48 +++++++++++++++++++-- tests/e2e/grpc_control_api/mod.rs | 64 ++++++++++++++++++++++++++++ 3 files changed, 115 insertions(+), 4 deletions(-) diff --git a/tests/e2e/grpc_control_api/create.rs b/tests/e2e/grpc_control_api/create.rs index c5b4294bb..a86fe29dc 100644 --- a/tests/e2e/grpc_control_api/create.rs +++ b/tests/e2e/grpc_control_api/create.rs @@ -1,3 +1,10 @@ +//! Tests for `Create` method of gRPC [Control API]. +//! +//! The specificity of these tests is such that the `Get` method is also +//! being tested at the same time. +//! +//! [Control API]: https://tinyurl.com/yxsqplq7 + use std::collections::HashMap; use medea_control_api_proto::grpc::control_api::{ diff --git a/tests/e2e/grpc_control_api/delete.rs b/tests/e2e/grpc_control_api/delete.rs index 3d502ce7a..ea883f406 100644 --- a/tests/e2e/grpc_control_api/delete.rs +++ b/tests/e2e/grpc_control_api/delete.rs @@ -1,7 +1,29 @@ +//! Tests for `Delete` method of gRPC [Control API]. +//! +//! The specificity of these tests is such that the `Get` method is also +//! being tested at the same time. +//! +//! [Control API]: https://tinyurl.com/yxsqplq7 + use medea::api::error_codes::{ErrorCode as MedeaErrorCode, ErrorCode}; use super::{create_room_req, ControlClient}; +/// Tests `Delete` method of [Medea]'s [Control API]. +/// +/// # Arguments +/// +/// `room_id`: `Room` ID which will be created and from will be deleted +/// `Element`s, +/// +/// `element_id`: `Element` ID which will be deleted from this `Room`, +/// +/// `error_code`: [`ErrorCode`] which should be returned from [ControlAPI] when +/// we tries get deleted `Element`. +/// +/// [Medea]: https://github.com/instrumentisto/medea +/// [Control API]: https://tinyurl.com/yxsqplq7 +/// [`ErrorCode`]: medea::api::error_codes::ErrorCode fn delete_test(room_id: &str, element_id: &str, error_code: MedeaErrorCode) { let client = ControlClient::new(); client.create(&create_room_req(room_id)); @@ -41,17 +63,35 @@ fn endpoint() { ); } +/// Tests `Delete` method of [Control API] by trying to delete child `Element` +/// from the also deleting parent `Element`. +/// +/// # Arguments +/// +/// `room_id`: `Room` ID which will be created and from will be deleted +/// `Element`s, +/// +/// `elements_uris`: `Element`s IDs which will be deleted from this `Element`, +/// +/// `error_code`: [`ErrorCode`] which should be returned from [ControlAPI] when +/// we tries get deleted `Element`, +/// +/// `root_elem_uri`: URI to parent `Element`. +/// +/// [Medea]: https://github.com/instrumentisto/medea +/// [Control API]: https://tinyurl.com/yxsqplq7 +/// [`ErrorCode`]: medea::api::error_codes::ErrorCode fn delete_elements_at_same_time_test( room_id: &str, - elements_ids: &[&str], + elements_uris: &[&str], code: MedeaErrorCode, - root_elem_id: &str, + root_elem_uri: &str, ) { let client = ControlClient::new(); client.create(&create_room_req(room_id)); - client.delete(elements_ids); + client.delete(elements_uris); - match client.try_get(root_elem_id) { + match client.try_get(root_elem_uri) { Ok(_) => panic!("Member not deleted!"), Err(e) => { assert_eq!(e.code, code as u32); diff --git a/tests/e2e/grpc_control_api/mod.rs b/tests/e2e/grpc_control_api/mod.rs index d546a47c8..7f7a529c3 100644 --- a/tests/e2e/grpc_control_api/mod.rs +++ b/tests/e2e/grpc_control_api/mod.rs @@ -1,3 +1,7 @@ +/// Tests for gRPC [Medea]'s [Control API]. +/// +/// [Medea]: https://github.com/instrumentisto/medea +/// [Control API]: https://tinyurl.com/yxsqplq7 mod create; mod delete; @@ -14,15 +18,31 @@ use medea_control_api_proto::grpc::{ }; use protobuf::RepeatedField; +/// Client for [Medea]'s gRPC [Control API]. +/// +/// [Medea]: https://github.com/instrumentisto/medea struct ControlClient(ControlApiClient); impl ControlClient { + /// Create new [`ControlClient`]. + /// + /// Client will connect to `localhost:6565`. + /// + /// Note that this function don't connects to the server. This mean that + /// when you call [`ControlClient::new`] and server not working you will + /// don't know it until try to send something with this client. pub fn new() -> Self { let env = Arc::new(EnvBuilder::new().build()); let ch = ChannelBuilder::new(env).connect("localhost:6565"); ControlClient(ControlApiClient::new(ch)) } + /// Gets some [`Element`] by local URI. + /// + /// # Panics + /// + /// - if [`GetResponse`] has error + /// - if connection with server failed pub fn get(&self, uri: &str) -> Element { let mut get_room_request = IdRequest::new(); let mut room = RepeatedField::new(); @@ -36,6 +56,11 @@ impl ControlClient { resp.take_elements().remove(&uri.to_string()).unwrap() } + /// Tries to get some [`Element`] by local URI. + /// + /// # Panics + /// + /// - if connection with server failed. pub fn try_get(&self, uri: &str) -> Result { let mut get_room_request = IdRequest::new(); let mut room = RepeatedField::new(); @@ -49,6 +74,12 @@ impl ControlClient { Ok(resp.take_elements().remove(&uri.to_string()).unwrap()) } + /// Creates `Element` and returns it sids. + /// + /// # Panics + /// + /// - if [`CreateResponse`] has error. + /// - if connection with server failed. pub fn create(&self, req: &CreateRequest) -> HashMap { let resp = self.0.create(&req).expect("create endpoint"); if resp.has_error() { @@ -58,6 +89,12 @@ impl ControlClient { resp.sid } + /// Deletes `Element`s by local URIs. + /// + /// # Panics + /// + /// - if [`Response`] has error + /// - if connection with server failed. pub fn delete(&self, ids: &[&str]) { let mut delete_req = IdRequest::new(); let mut delete_ids = RepeatedField::new(); @@ -72,6 +109,33 @@ impl ControlClient { } } +/// Creates [`CreateRequest`] for creating `Room` element with provided room ID. +/// +/// # Spec of `Room` which will be created with this [`CreateRequest`] +/// +/// ```yaml +/// kind: Room +/// id: {{ PROVIDED_ROOM_ID }} +/// spec: +/// pipeline: +/// caller: +/// kind: Member +/// spec: +/// pipeline: +/// publish: +/// kind: WebRtcPublishEndpoint +/// spec: +/// p2p: Always +/// responder: +/// kind: Member +/// credentials: test +/// spec: +/// pipeline: +/// play: +/// kind: WebRtcPlayEndpoint +/// spec: +/// src: "local://{{ PROVIDED_ROOM_ID }}/caller/publish" +/// ``` fn create_room_req(room_id: &str) -> CreateRequest { let mut create_req = CreateRequest::new(); let mut room = Room::new(); From fdbbc1e10e5ee4ec4feb3956ee380b277691a58f Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 25 Sep 2019 17:42:23 +0300 Subject: [PATCH 668/735] Reread [run ci] --- CHANGELOG.md | 3 +- proto/client-api/CHANGELOG.md | 3 +- src/api/control/endpoints/mod.rs | 1 - src/api/{ => control}/error_codes.rs | 6 +-- src/api/control/grpc/server.rs | 69 +++++++++++----------------- src/api/control/local_uri.rs | 5 +- src/api/control/mod.rs | 3 +- src/api/mod.rs | 1 - src/shutdown.rs | 2 +- src/signalling/elements/member.rs | 1 + src/signalling/room.rs | 2 +- src/signalling/room_service.rs | 18 ++++---- tests/e2e/grpc_control_api/delete.rs | 26 +++++++---- tests/e2e/grpc_control_api/mod.rs | 10 ++-- 14 files changed, 73 insertions(+), 77 deletions(-) rename src/api/{ => control}/error_codes.rs (99%) diff --git a/CHANGELOG.md b/CHANGELOG.md index b500b7c9a..c29115205 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,7 +22,8 @@ All user visible changes to this project will be documented in this file. This p - Signalling: - Dynamic `Peer`s creation when client connects ([#28]); - Auto-removing `Peer`s when `Member` disconnects ([#28]); - - Filter `SetIceCandidate` messages without `candidate` ([#50](/../../pull/50)). + - Filter `SetIceCandidate` messages without `candidate` ([#50](/../../pull/50)); + - Send reason of WebSocket close by server as close frame's description. - Testing: - E2E tests for signalling ([#28]). diff --git a/proto/client-api/CHANGELOG.md b/proto/client-api/CHANGELOG.md index 32c8174e6..49180968f 100644 --- a/proto/client-api/CHANGELOG.md +++ b/proto/client-api/CHANGELOG.md @@ -12,7 +12,8 @@ All user visible changes to this project will be documented in this file. This p ### Added - `TrackId` and `PeerId` types ([#28]); -- `Incrementable` trait ([#28]). +- `Incrementable` trait ([#28]); +- `RpcConnectionClosed` and `CloseDescription` ([#33](/../../pull/28)). [#28]: /../../pull/28 diff --git a/src/api/control/endpoints/mod.rs b/src/api/control/endpoints/mod.rs index 238a31ca9..36d2449f8 100644 --- a/src/api/control/endpoints/mod.rs +++ b/src/api/control/endpoints/mod.rs @@ -50,7 +50,6 @@ impl_from_into!(WebRtcPlayId); /// Media element that one or more media data streams flow through. #[derive(Debug, From)] pub enum EndpointSpec { - // TODO: add id in endpoints /// [`WebRtcPublishEndpoint`] element. WebRtcPublish(WebRtcPublishEndpoint), diff --git a/src/api/error_codes.rs b/src/api/control/error_codes.rs similarity index 99% rename from src/api/error_codes.rs rename to src/api/control/error_codes.rs index 4edfba0d6..c3631209e 100644 --- a/src/api/error_codes.rs +++ b/src/api/control/error_codes.rs @@ -436,9 +436,9 @@ impl From for ErrorResponse { LocalUri(e) => e.into(), TryFromProtobuf(e) => e.into(), RoomServiceError(e) => e.into(), - RoomServiceMailboxError(_) - | TryFromElement(_) - | UnknownMailboxErr(_) => Self::unexpected(&err), + RoomServiceMailboxError(_) | TryFromElement(_) => { + Self::unexpected(&err) + } } } } diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index d4836c81e..c7ae502b4 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -23,16 +23,14 @@ use medea_control_api_proto::grpc::{ }; use crate::{ - api::{ - control::{ - local_uri::{ - LocalUri, LocalUriParseError, StatefulLocalUri, ToEndpoint, - ToMember, - }, - EndpointSpec, MemberId, MemberSpec, RoomId, RoomSpec, - TryFromElementError, TryFromProtobufError, - }, + api::control::{ error_codes::{ErrorCode, ErrorResponse}, + local_uri::{ + LocalUri, LocalUriParseError, StatefulLocalUri, ToEndpoint, + ToMember, + }, + EndpointSpec, MemberId, MemberSpec, RoomId, RoomSpec, + TryFromElementError, TryFromProtobufError, }, log::prelude::*, shutdown::ShutdownGracefully, @@ -69,15 +67,6 @@ pub enum GrpcControlApiError { #[display(fmt = "Room service mailbox error: {:?}", _0)] RoomServiceMailboxError(MailboxError), - /// [`MailboxError`] which never can happen. This error needed - /// for [`fut_try!`] macro because using [`From`] trait. - /// With this error we cover [`MailboxError`] in places where - /// it cannot happen. - /// - /// __Never use this error.__ - #[display(fmt = "Mailbox error which never can happen. {:?}", _0)] - UnknownMailboxErr(MailboxError), - /// Wrapper around [`RoomServiceError`]. RoomServiceError(RoomServiceError), } @@ -106,21 +95,6 @@ impl From for GrpcControlApiError { } } -/// Tries to unwrap some [`Result`] and if it `Err` then returns err [`Future`] -/// with [`ControlApiError`]. -/// -/// __Note:__ this macro returns [`Either::B`]. -macro_rules! fut_try { - ($call:expr) => { - match $call { - Ok(o) => o, - Err(e) => { - return Either::B(future::err(GrpcControlApiError::from(e))) - } - } - }; -} - /// Type alias for success [`CreateResponse`]'s sids. type Sids = HashMap; @@ -136,7 +110,6 @@ struct ControlApiService { public_url: String, } -// TODO: tests impl ControlApiService { /// Returns [Control API] sid based on provided arguments and /// `MEDEA_CLIENT.PUBLIC_URL` config value. @@ -157,14 +130,24 @@ impl ControlApiService { &self, spec: RoomSpec, ) -> impl Future { - let sid: Sids = fut_try!(spec.members()) - .iter() - .map(|(member_id, member)| { - let uri = - self.get_sid(spec.id(), &member_id, member.credentials()); - (member_id.clone().to_string(), uri) - }) - .collect(); + let sid = match spec.members() { + Ok(members) => members + .iter() + .map(|(member_id, member)| { + let uri = self.get_sid( + spec.id(), + &member_id, + member.credentials(), + ); + (member_id.clone().to_string(), uri) + }) + .collect(), + Err(e) => { + return Either::B(future::err( + GrpcControlApiError::TryFromElement(e), + )) + } + }; Either::A( self.room_service @@ -207,7 +190,7 @@ impl ControlApiService { }) } - /// Creates element based on provided + /// Creates element based on provided [`CreateRequest`]. pub fn create_element( &self, mut req: CreateRequest, diff --git a/src/api/control/local_uri.rs b/src/api/control/local_uri.rs index 33da16b0e..631a15205 100644 --- a/src/api/control/local_uri.rs +++ b/src/api/control/local_uri.rs @@ -66,7 +66,7 @@ pub struct ToEndpoint(LocalUri, EndpointId); /// assert_eq!(local_uri.room_id(), &orig_room_id); /// /// // If you want to take all IDs ownership, you should do this steps: -/// let (endpoint_id, member_uri) = local_uri.take_endpoint_id(); +/// let (endpoint_id, member_uri) = local_uri.clone().take_endpoint_id(); /// assert_eq!(endpoint_id, orig_endpoint_id); /// /// let (member_id, room_uri) = member_uri.take_member_id(); @@ -74,6 +74,9 @@ pub struct ToEndpoint(LocalUri, EndpointId); /// /// let room_id = room_uri.take_room_id(); /// assert_eq!(room_id, orig_room_id); +/// +/// // Or simply +/// let (room_id, member_id, endpoint_id) = local_uri.take_all(); /// ``` /// /// This is necessary so that it is not possible to get the address in the diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index d8a9f7882..1e9ac94ec 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -3,6 +3,7 @@ //! [Control API]: https://tinyurl.com/yxsqplq7 pub mod endpoints; +pub mod error_codes; pub mod grpc; pub mod local_uri; pub mod member; @@ -39,7 +40,7 @@ pub use self::{ room::{Id as RoomId, RoomElement, RoomSpec}, }; -/// Errors which may occur while deserialize protobuf spec. +/// Errors which may occur while deserializing protobuf spec. #[derive(Debug, Fail, Display)] pub enum TryFromProtobufError { /// Error while parsing [`SrcUri`] of [`WebRtcPlayEndpoint`]. diff --git a/src/api/mod.rs b/src/api/mod.rs index ac72696fa..1c66e73e5 100644 --- a/src/api/mod.rs +++ b/src/api/mod.rs @@ -2,4 +2,3 @@ pub mod client; pub mod control; -pub mod error_codes; diff --git a/src/shutdown.rs b/src/shutdown.rs index 27d59fb60..e50ecfa36 100644 --- a/src/shutdown.rs +++ b/src/shutdown.rs @@ -26,7 +26,7 @@ pub struct Priority(pub u8); /// Message that [`Subscriber`] is informed with to perform its graceful /// shutdown. #[allow(clippy::module_name_repetitions)] -#[derive(Message)] +#[derive(Debug, Message)] #[rtype(result = "Result<(), ()>")] pub struct ShutdownGracefully; diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index 2f94f4af2..a51a30383 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -108,6 +108,7 @@ impl Member { /// Lookups [`MemberSpec`] by [`MemberId`] from [`MemberSpec`]. /// /// Returns [`MembersLoadError::MemberNotFound`] when member not found. + /// /// Returns [`MembersLoadError::TryFromError`] when found element which is /// not [`MemberSpec`]. fn get_member_from_room_spec( diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 1b5086754..25a4181af 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -354,7 +354,7 @@ impl Room { } /// Creates [`Peer`] for endpoints if [`Peer`] between endpoint's members - /// not exist. + /// doesn't exist. /// /// Adds `send` track to source member's [`Peer`] and `recv` to /// sink member's [`Peer`]. diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index 3cada6185..b636b786f 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -240,7 +240,7 @@ impl Handler for RoomService { } } -/// Signal for create new [`Member`] in [`Room`] +/// Signal for create new [`Member`] in [`Room`]. /// /// [`Member`]: crate::signalling::elements::member::Member #[derive(Message)] @@ -276,7 +276,7 @@ impl Handler for RoomService { } } -/// Signal for create new [`Endpoint`] in [`Room`] +/// Signal for create new [`Endpoint`] in [`Room`]. /// /// [`Endpoint`]: crate::signalling::elements::endpoints::Endpoint #[derive(Message)] @@ -329,6 +329,7 @@ pub struct Unvalidated; // is fix for it. This allow not works on function. #[allow(clippy::use_self)] impl DeleteElements { + /// Creates new [`DeleteElements`] in [`Unvalidated`] state. pub fn new() -> Self { Self { uris: Vec::new(), @@ -336,6 +337,7 @@ impl DeleteElements { } } + /// Adds [`StatefulLocalUri`] to request. pub fn add_uri(&mut self, uri: StatefulLocalUri) { self.uris.push(uri) } @@ -439,18 +441,18 @@ impl Handler> for RoomService { } } +/// Serialized to protobuf `Element`s which will be returned from [`Get`] on +/// success result. +type SerializedElements = HashMap; + /// Message which returns serialized to protobuf objects by provided /// [`LocalUri`]. #[derive(Message)] -#[rtype(result = "Result, \ - RoomServiceError>")] +#[rtype(result = "Result")] pub struct Get(pub Vec); impl Handler for RoomService { - type Result = ResponseFuture< - HashMap, - RoomServiceError, - >; + type Result = ResponseFuture; fn handle(&mut self, msg: Get, _: &mut Self::Context) -> Self::Result { let mut rooms_elements = HashMap::new(); diff --git a/tests/e2e/grpc_control_api/delete.rs b/tests/e2e/grpc_control_api/delete.rs index ea883f406..345fcd7c4 100644 --- a/tests/e2e/grpc_control_api/delete.rs +++ b/tests/e2e/grpc_control_api/delete.rs @@ -5,7 +5,9 @@ //! //! [Control API]: https://tinyurl.com/yxsqplq7 -use medea::api::error_codes::{ErrorCode as MedeaErrorCode, ErrorCode}; +use medea::api::control::error_codes::{ + ErrorCode as MedeaErrorCode, ErrorCode, +}; use super::{create_room_req, ControlClient}; @@ -23,8 +25,12 @@ use super::{create_room_req, ControlClient}; /// /// [Medea]: https://github.com/instrumentisto/medea /// [Control API]: https://tinyurl.com/yxsqplq7 -/// [`ErrorCode`]: medea::api::error_codes::ErrorCode -fn delete_test(room_id: &str, element_id: &str, error_code: MedeaErrorCode) { +/// [`ErrorCode`]: medea::api::control::error_codes::ErrorCode +fn test_for_delete( + room_id: &str, + element_id: &str, + error_code: MedeaErrorCode, +) { let client = ControlClient::new(); client.create(&create_room_req(room_id)); client.delete(&[element_id]); @@ -38,7 +44,7 @@ fn delete_test(room_id: &str, element_id: &str, error_code: MedeaErrorCode) { #[test] fn room() { - delete_test( + test_for_delete( "delete-room", "local://delete-room", ErrorCode::RoomNotFound, @@ -47,7 +53,7 @@ fn room() { #[test] fn member() { - delete_test( + test_for_delete( "delete-member", "local://delete-member/publisher", ErrorCode::MemberNotFound, @@ -56,7 +62,7 @@ fn member() { #[test] fn endpoint() { - delete_test( + test_for_delete( "delete-endpoint", "local://delete-endpoint/publisher/publish", ErrorCode::EndpointNotFound, @@ -80,8 +86,8 @@ fn endpoint() { /// /// [Medea]: https://github.com/instrumentisto/medea /// [Control API]: https://tinyurl.com/yxsqplq7 -/// [`ErrorCode`]: medea::api::error_codes::ErrorCode -fn delete_elements_at_same_time_test( +/// [`ErrorCode`]: medea::api::control::error_codes::ErrorCode +fn test_for_delete_elements_at_same_time_test( room_id: &str, elements_uris: &[&str], code: MedeaErrorCode, @@ -101,7 +107,7 @@ fn delete_elements_at_same_time_test( #[test] fn member_and_endpoint_same_time() { - delete_elements_at_same_time_test( + test_for_delete_elements_at_same_time_test( "medea-and-endpoint-same-time", &[ "local://medea-and-endpoint-same-time/publisher", @@ -114,7 +120,7 @@ fn member_and_endpoint_same_time() { #[test] fn room_and_inner_elements_same_time() { - delete_elements_at_same_time_test( + test_for_delete_elements_at_same_time_test( "room-and-inner-elements-same-time", &[ "local://room-and-inner-elements-same-time", diff --git a/tests/e2e/grpc_control_api/mod.rs b/tests/e2e/grpc_control_api/mod.rs index 7f7a529c3..0657c4ecc 100644 --- a/tests/e2e/grpc_control_api/mod.rs +++ b/tests/e2e/grpc_control_api/mod.rs @@ -49,7 +49,7 @@ impl ControlClient { room.push(uri.to_string()); get_room_request.set_id(room); - let mut resp = self.0.get(&get_room_request).expect("get room"); + let mut resp = self.0.get(&get_room_request).unwrap(); if resp.has_error() { panic!("{:?}", resp.get_error()); } @@ -67,7 +67,7 @@ impl ControlClient { room.push(uri.to_string()); get_room_request.set_id(room); - let mut resp = self.0.get(&get_room_request).expect("get room"); + let mut resp = self.0.get(&get_room_request).unwrap(); if resp.has_error() { return Err(resp.take_error()); } @@ -81,7 +81,7 @@ impl ControlClient { /// - if [`CreateResponse`] has error. /// - if connection with server failed. pub fn create(&self, req: &CreateRequest) -> HashMap { - let resp = self.0.create(&req).expect("create endpoint"); + let resp = self.0.create(&req).unwrap(); if resp.has_error() { panic!("{:?}", resp.get_error()); } @@ -115,7 +115,7 @@ impl ControlClient { /// /// ```yaml /// kind: Room -/// id: {{ PROVIDED_ROOM_ID }} +/// id: {{ room_id }} /// spec: /// pipeline: /// caller: @@ -134,7 +134,7 @@ impl ControlClient { /// play: /// kind: WebRtcPlayEndpoint /// spec: -/// src: "local://{{ PROVIDED_ROOM_ID }}/caller/publish" +/// src: "local://{{ room_id }}/caller/publish" /// ``` fn create_room_req(room_id: &str) -> CreateRequest { let mut create_req = CreateRequest::new(); From 2abcd98019749ceba1558401e91a886bc4d1965a Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 25 Sep 2019 17:44:24 +0300 Subject: [PATCH 669/735] Remove outdated TODO --- src/api/control/member.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/api/control/member.rs b/src/api/control/member.rs index e9b1b25b9..737b9f8d0 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -53,7 +53,6 @@ pub enum MemberElement { #[allow(clippy::module_name_repetitions)] #[derive(Clone, Debug)] pub struct MemberSpec { - // TODO: add id /// Spec of this `Member`. pipeline: Pipeline, From 0f641672cc502150aa690ff15c906f85cfc230cc Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 25 Sep 2019 19:33:19 +0300 Subject: [PATCH 670/735] Final reread [run ci] --- src/api/control/grpc/server.rs | 28 ++-------------------------- src/signalling/elements/member.rs | 6 +++--- 2 files changed, 5 insertions(+), 29 deletions(-) diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index c7ae502b4..e4739f795 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -7,7 +7,7 @@ use std::{collections::HashMap, convert::TryFrom, sync::Arc}; use actix::{ Actor, Addr, Arbiter, Context, Handler, MailboxError, ResponseFuture, }; -use derive_more::Display; +use derive_more::{Display, From}; use failure::Fail; use futures::future::{self, Either, Future, IntoFuture}; use grpcio::{ @@ -44,7 +44,7 @@ use crate::{ /// Errors which can happen while processing requests to gRPC [Control API]. /// /// [Control API]: https://tinyurl.com/yxsqplq7 -#[derive(Debug, Display, Fail)] +#[derive(Debug, Display, Fail, From)] pub enum GrpcControlApiError { /// Error while parsing [`LocalUri`] of element. LocalUri(LocalUriParseError), @@ -71,30 +71,6 @@ pub enum GrpcControlApiError { RoomServiceError(RoomServiceError), } -impl From for GrpcControlApiError { - fn from(from: LocalUriParseError) -> Self { - Self::LocalUri(from) - } -} - -impl From for GrpcControlApiError { - fn from(from: RoomServiceError) -> Self { - Self::RoomServiceError(from) - } -} - -impl From for GrpcControlApiError { - fn from(from: TryFromProtobufError) -> Self { - Self::TryFromProtobuf(from) - } -} - -impl From for GrpcControlApiError { - fn from(from: TryFromElementError) -> Self { - Self::TryFromElement(from) - } -} - /// Type alias for success [`CreateResponse`]'s sids. type Sids = HashMap; diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index a51a30383..d86165299 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -90,7 +90,7 @@ struct MemberInner { } impl Member { - /// Create new empty [`Member`]. + /// Creates new empty [`Member`]. /// /// To fill this [`Member`], you need to call [`Member::load`] /// function. @@ -265,12 +265,12 @@ impl Member { self.0.borrow().ice_user.as_ref().map(IceUser::servers_list) } - /// Returns and set to `None` [`IceUser`] of this [`Member`]. + /// Returns and sets to `None` [`IceUser`] of this [`Member`]. pub fn take_ice_user(&self) -> Option { self.0.borrow_mut().ice_user.take() } - /// Replace and return [`IceUser`] of this [`Member`]. + /// Replaces and returns [`IceUser`] of this [`Member`]. pub fn replace_ice_user(&self, new_ice_user: IceUser) -> Option { self.0.borrow_mut().ice_user.replace(new_ice_user) } From 9d25a59da5ac7fa6752d9fbefc8401df602355e3 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Thu, 26 Sep 2019 12:19:10 +0300 Subject: [PATCH 671/735] Fix some docs --- proto/client-api/src/lib.rs | 2 ++ src/signalling/elements/endpoints/mod.rs | 4 ++-- tests/e2e/grpc_control_api/mod.rs | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/proto/client-api/src/lib.rs b/proto/client-api/src/lib.rs index 646ff4513..6056e5888 100644 --- a/proto/client-api/src/lib.rs +++ b/proto/client-api/src/lib.rs @@ -143,8 +143,10 @@ pub enum RpcConnectionCloseReason { ConnectionSwapped, } +/// Description which will be sent in Close WebSocket frame. #[derive(Constructor, Debug, Deserialize, Serialize)] pub struct CloseDescription { + /// Reason of why connection was closed. pub reason: RpcConnectionCloseReason, } diff --git a/src/signalling/elements/endpoints/mod.rs b/src/signalling/elements/endpoints/mod.rs index ec74635b1..3783daca2 100644 --- a/src/signalling/elements/endpoints/mod.rs +++ b/src/signalling/elements/endpoints/mod.rs @@ -7,9 +7,9 @@ pub mod webrtc; use derive_more::From; use medea_control_api_proto::grpc::control_api::Element as RootElementProto; -/// Enum which can store all kinds of [medea] endpoints. +/// Enum which can store all kinds of [Medea] endpoints. /// -/// [medea]: https://github.com/instrumentisto/medea +/// [Medea]: https://github.com/instrumentisto/medea #[derive(Clone, Debug, From)] pub enum Endpoint { WebRtcPublishEndpoint(webrtc::WebRtcPublishEndpoint), diff --git a/tests/e2e/grpc_control_api/mod.rs b/tests/e2e/grpc_control_api/mod.rs index 0657c4ecc..66771e43e 100644 --- a/tests/e2e/grpc_control_api/mod.rs +++ b/tests/e2e/grpc_control_api/mod.rs @@ -118,7 +118,7 @@ impl ControlClient { /// id: {{ room_id }} /// spec: /// pipeline: -/// caller: +/// publisher: /// kind: Member /// spec: /// pipeline: @@ -134,7 +134,7 @@ impl ControlClient { /// play: /// kind: WebRtcPlayEndpoint /// spec: -/// src: "local://{{ room_id }}/caller/publish" +/// src: "local://{{ room_id }}/publisher/publish" /// ``` fn create_room_req(room_id: &str) -> CreateRequest { let mut create_req = CreateRequest::new(); From dee07e113a77daf5c96b57605df2c18163fed114 Mon Sep 17 00:00:00 2001 From: alexlapa Date: Fri, 27 Sep 2019 14:21:17 +0300 Subject: [PATCH 672/735] add todos --- src/signalling/participants.rs | 3 +++ tests/e2e/main.rs | 2 ++ 2 files changed, 5 insertions(+) diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 6d6cce6bb..6b4814fe9 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -447,6 +447,7 @@ impl ParticipantService { /// /// Returns [`ParticipantServiceErr::ParticipantAlreadyExists`] when /// [`Member`]'s ID already presented in [`ParticipantService`]. + // TODO: move to room pub fn create_member( &mut self, id: MemberId, @@ -512,6 +513,7 @@ impl ParticipantService { /// /// Returns [`ParticipantServiceErr::EndpointAlreadyExists`] when /// [`WebRtcPlayEndpoint`]'s ID already presented in [`Member`]. + // TODO: move to room pub fn create_sink_endpoint( &mut self, member_id: &MemberId, @@ -572,6 +574,7 @@ impl ParticipantService { /// /// Returns [`ParticipantServiceErr::EndpointAlreadyExists`] when /// [`WebRtcPublishEndpoint`]'s ID already presented in [`Member`]. + // TODO: move to room pub fn create_src_endpoint( &mut self, member_id: &MemberId, diff --git a/tests/e2e/main.rs b/tests/e2e/main.rs index 3fe555569..7abd8e2a8 100644 --- a/tests/e2e/main.rs +++ b/tests/e2e/main.rs @@ -1,2 +1,4 @@ mod grpc_control_api; mod signalling; + +// TODO: test ws messages caused by grpc commands \ No newline at end of file From 57238337b905671a7251cd61f8b20191520587ee Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 27 Sep 2019 19:03:09 +0300 Subject: [PATCH 673/735] Implement tests for dynamic Control API signaling, fix bugs --- src/signalling/room.rs | 8 +- tests/e2e/grpc_control_api/mod.rs | 5 +- tests/e2e/main.rs | 7 +- .../signaling_with_grpc_control_api/mod.rs | 178 ++++++++++++++++++ tests/e2e/signalling/mod.rs | 27 ++- 5 files changed, 216 insertions(+), 9 deletions(-) create mode 100644 tests/e2e/signaling_with_grpc_control_api/mod.rs diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 25a4181af..33de7239c 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -578,11 +578,13 @@ impl Room { peer_ids_to_remove: HashSet, ctx: &mut Context, ) { + debug!("Remove peers."); self.peers .remove_peers(&member_id, peer_ids_to_remove) .into_iter() .for_each(|(member_id, peers_id)| { - self.member_peers_removed(peers_id, member_id, ctx); + let fut = self.member_peers_removed(peers_id, member_id, ctx); + ctx.spawn(fut); }); } @@ -634,7 +636,9 @@ impl Room { let removed_peers = self.peers.remove_peer(member_id, peer_id); for (member_id, peers_ids) in removed_peers { - self.member_peers_removed(peers_ids, member_id, ctx); + let fut = self + .member_peers_removed(peers_ids, member_id, ctx); + ctx.spawn(fut); } } } diff --git a/tests/e2e/grpc_control_api/mod.rs b/tests/e2e/grpc_control_api/mod.rs index 66771e43e..f0c404416 100644 --- a/tests/e2e/grpc_control_api/mod.rs +++ b/tests/e2e/grpc_control_api/mod.rs @@ -21,7 +21,8 @@ use protobuf::RepeatedField; /// Client for [Medea]'s gRPC [Control API]. /// /// [Medea]: https://github.com/instrumentisto/medea -struct ControlClient(ControlApiClient); +#[derive(Clone)] +pub struct ControlClient(ControlApiClient); impl ControlClient { /// Create new [`ControlClient`]. @@ -136,7 +137,7 @@ impl ControlClient { /// spec: /// src: "local://{{ room_id }}/publisher/publish" /// ``` -fn create_room_req(room_id: &str) -> CreateRequest { +pub fn create_room_req(room_id: &str) -> CreateRequest { let mut create_req = CreateRequest::new(); let mut room = Room::new(); let mut publisher = Member::new(); diff --git a/tests/e2e/main.rs b/tests/e2e/main.rs index 7abd8e2a8..56a30863d 100644 --- a/tests/e2e/main.rs +++ b/tests/e2e/main.rs @@ -1,4 +1,5 @@ -mod grpc_control_api; -mod signalling; +pub mod grpc_control_api; +mod signaling_with_grpc_control_api; +pub mod signalling; -// TODO: test ws messages caused by grpc commands \ No newline at end of file +// TODO: test ws messages caused by grpc commands diff --git a/tests/e2e/signaling_with_grpc_control_api/mod.rs b/tests/e2e/signaling_with_grpc_control_api/mod.rs new file mode 100644 index 000000000..8c094bbb8 --- /dev/null +++ b/tests/e2e/signaling_with_grpc_control_api/mod.rs @@ -0,0 +1,178 @@ +use std::{cell::Cell, collections::HashMap, rc::Rc, time::Duration}; + +use actix::{Arbiter, AsyncContext, Context, System}; +use futures::future::Future as _; +use medea_client_api_proto::Event; +use medea_control_api_proto::grpc::control_api::{ + CreateRequest, Member, Member_Element, Room, Room_Element, + WebRtcPlayEndpoint, WebRtcPublishEndpoint, WebRtcPublishEndpoint_P2P, +}; + +use crate::{grpc_control_api::ControlClient, signalling::TestMember}; + +fn room_with_one_pub_member_req(room_id: &str) -> CreateRequest { + let mut create_req = CreateRequest::new(); + let mut room = Room::new(); + let mut publisher = Member::new(); + let mut publish_endpoint = WebRtcPublishEndpoint::new(); + + publish_endpoint.set_p2p(WebRtcPublishEndpoint_P2P::ALWAYS); + let mut publish_endpoint_element = Member_Element::new(); + publish_endpoint_element.set_webrtc_pub(publish_endpoint); + let mut publisher_pipeline = HashMap::new(); + publisher_pipeline.insert("publish".to_string(), publish_endpoint_element); + publisher.set_pipeline(publisher_pipeline); + publisher.set_credentials("test".to_string()); + + let mut publisher_member_element = Room_Element::new(); + publisher_member_element.set_member(publisher); + let mut room_pipeline = HashMap::new(); + room_pipeline.insert("publisher".to_string(), publisher_member_element); + room.set_pipeline(room_pipeline); + create_req.set_room(room.clone()); + create_req.set_id(format!("local://{}", room_id)); + + create_req +} + +fn create_play_member_req(room_id: &str) -> CreateRequest { + let mut create_member_request = CreateRequest::new(); + let mut member = Member::new(); + let mut member_pipeline = HashMap::new(); + + let mut play_endpoint = WebRtcPlayEndpoint::new(); + play_endpoint.set_src(format!("local://{}/publisher/publish", room_id)); + let mut member_element = Member_Element::new(); + member_element.set_webrtc_play(play_endpoint); + member_pipeline.insert("play".to_string(), member_element); + + member.set_credentials("qwerty".to_string()); + member.set_pipeline(member_pipeline); + create_member_request.set_id(format!("local://{}/responder", room_id)); + create_member_request.set_member(member); + + create_member_request +} + +fn create_room_req(room_id: &str) -> CreateRequest { + let mut create_req = CreateRequest::new(); + let mut room = Room::new(); + let mut publisher = Member::new(); + let mut responder = Member::new(); + let mut play_endpoint = WebRtcPlayEndpoint::new(); + let mut publish_endpoint = WebRtcPublishEndpoint::new(); + + play_endpoint.set_src(format!("local://{}/publisher/publish", room_id)); + let mut play_endpoint_element = Member_Element::new(); + play_endpoint_element.set_webrtc_play(play_endpoint); + let mut responder_pipeline = HashMap::new(); + responder_pipeline.insert("play".to_string(), play_endpoint_element); + responder.set_pipeline(responder_pipeline); + responder.set_credentials("test".to_string()); + + publish_endpoint.set_p2p(WebRtcPublishEndpoint_P2P::ALWAYS); + let mut publish_endpoint_element = Member_Element::new(); + publish_endpoint_element.set_webrtc_pub(publish_endpoint); + let mut publisher_pipeline = HashMap::new(); + publisher_pipeline.insert("publish".to_string(), publish_endpoint_element); + publisher.set_pipeline(publisher_pipeline); + publisher.set_credentials("test".to_string()); + + let mut publisher_member_element = Room_Element::new(); + publisher_member_element.set_member(publisher); + let mut responder_member_element = Room_Element::new(); + responder_member_element.set_member(responder); + let mut room_pipeline = HashMap::new(); + room_pipeline.insert("publisher".to_string(), publisher_member_element); + room_pipeline.insert("responder".to_string(), responder_member_element); + room.set_pipeline(room_pipeline); + create_req.set_room(room.clone()); + create_req.set_id(format!("local://{}", room_id)); + + create_req +} + +#[test] +fn create_play_member_after_pub_member() { + let sys = System::new("qwerty"); + let control_client = ControlClient::new(); + control_client.create(&room_with_one_pub_member_req("asdfg")); + + let peers_created = Rc::new(Cell::new(0)); + + let on_event = + move |event: &Event, ctx: &mut Context, _: Vec<&Event>| { + match event { + Event::PeerCreated { .. } => { + peers_created.set(peers_created.get() + 1); + if peers_created.get() == 2 { + ctx.run_later(Duration::from_secs(1), |_, _| { + actix::System::current().stop(); + }); + } + } + _ => {} + } + }; + + let deadline = Some(std::time::Duration::from_secs(5)); + Arbiter::spawn( + TestMember::connect( + "ws://127.0.0.1:8080/ws/asdfg/publisher/test", + Box::new(on_event.clone()), + deadline, + ) + .and_then(move |_| { + control_client.create(&create_play_member_req("asdfg")); + TestMember::connect( + "ws://127.0.0.1:8080/ws/asdfg/responder/qwerty", + Box::new(on_event), + deadline, + ) + }), + ); + + sys.run().unwrap(); +} + +#[test] +fn delete_member_check_peers_removed() { + let sys = System::new("qwerty"); + let control_client = ControlClient::new(); + control_client.create(&create_room_req("zxcv")); + + let peers_created = Rc::new(Cell::new(0)); + + let on_event = + move |event: &Event, ctx: &mut Context, _: Vec<&Event>| { + match event { + Event::PeerCreated { .. } => { + peers_created.set(peers_created.get() + 1); + if peers_created.get() == 2 { + control_client.delete(&["local://zxcv/responder"]); + } + } + Event::PeersRemoved { .. } => { + ctx.run_later(Duration::from_secs(1), |_, _| { + actix::System::current().stop(); + }); + } + _ => {} + } + }; + + let deadline = Some(Duration::from_secs(5)); + + TestMember::start( + "ws://127.0.0.1:8080/ws/zxcv/publisher/test", + Box::new(on_event.clone()), + deadline, + ); + TestMember::start( + "ws://127.0.0.1:8080/ws/zxcv/responder/test", + Box::new(on_event), + deadline, + ); + + sys.run().unwrap(); +} diff --git a/tests/e2e/signalling/mod.rs b/tests/e2e/signalling/mod.rs index 91f9e50da..0175ccda3 100644 --- a/tests/e2e/signalling/mod.rs +++ b/tests/e2e/signalling/mod.rs @@ -56,8 +56,31 @@ impl TestMember { /// Sends command to the server. fn send_command(&mut self, msg: Command) { let json = serde_json::to_string(&msg).unwrap(); - self.writer.start_send(ws::Message::Text(json)).unwrap(); - self.writer.poll_complete().unwrap(); + self.writer.start_send(ws::Message::Text(json)).ok(); + self.writer.poll_complete().ok(); + } + + pub fn connect( + uri: &str, + on_message: MessageHandler, + deadline: Option, + ) -> impl futures::future::Future { + awc::Client::new() + .ws(uri) + .connect() + .map_err(|e| panic!("Error: {}", e)) + .map(move |(_, framed)| { + let (sink, stream) = framed.split(); + TestMember::create(move |ctx| { + TestMember::add_stream(stream, ctx); + TestMember { + writer: sink, + events: Vec::new(), + deadline, + on_message, + } + }); + }) } /// Starts test member in new [`Arbiter`] by given URI. From 6370238e5ae0b6f788d140cb12a881c2758cf171 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 27 Sep 2019 19:58:31 +0300 Subject: [PATCH 674/735] Add format_name_macro --- tests/e2e/grpc_control_api/create.rs | 40 +++++++++++-------- tests/e2e/grpc_control_api/delete.rs | 39 +++++++++++------- tests/e2e/main.rs | 11 ++++- .../signaling_with_grpc_control_api/mod.rs | 29 +++++++++----- 4 files changed, 75 insertions(+), 44 deletions(-) diff --git a/tests/e2e/grpc_control_api/create.rs b/tests/e2e/grpc_control_api/create.rs index a86fe29dc..8454da45b 100644 --- a/tests/e2e/grpc_control_api/create.rs +++ b/tests/e2e/grpc_control_api/create.rs @@ -12,43 +12,47 @@ use medea_control_api_proto::grpc::control_api::{ WebRtcPublishEndpoint, WebRtcPublishEndpoint_P2P, }; +use crate::format_name_macro; + use super::{create_room_req, ControlClient}; #[test] fn room() { + format_name_macro!("create-room"); + let client = ControlClient::new(); - let sids = client.create(&create_room_req("create-room")); + let sids = client.create(&create_room_req(&format_name!("{}"))); assert_eq!(sids.len(), 2); sids.get(&"publisher".to_string()).unwrap(); let responder_sid = sids.get(&"responder".to_string()).unwrap().as_str(); assert_eq!( responder_sid, - "ws://0.0.0.0:8080/create-room/responder/test" + &format_name!("ws://0.0.0.0:8080/{}/responder/test") ); - let mut get_resp = client.get("local://create-room"); + let mut get_resp = client.get(&format_name!("local://{}")); let room = get_resp.take_room(); let responder = room .get_pipeline() - .get(&"local://create-room/responder".to_string()) + .get(&format_name!("local://{}/responder")) .unwrap() .get_member(); assert_eq!(responder.get_credentials(), "test"); let responder_pipeline = responder.get_pipeline(); assert_eq!(responder_pipeline.len(), 1); let responder_play = responder_pipeline - .get(&"local://create-room/responder/play".to_string()) + .get(&format_name!("local://{}/responder/play")) .unwrap() .get_webrtc_play(); assert_eq!( responder_play.get_src(), - "local://create-room/publisher/publish" + format_name!("local://{}/publisher/publish") ); let publisher = room .get_pipeline() - .get(&"local://create-room/publisher".to_string()) + .get(&format_name!("local://{}/publisher")) .unwrap() .get_member(); assert_ne!(publisher.get_credentials(), "test"); @@ -59,8 +63,10 @@ fn room() { #[test] fn member() { + format_name_macro!("create-member"); + let client = ControlClient::new(); - client.create(&create_room_req("create-member")); + client.create(&create_room_req(&format_name!("{}"))); let create_req = { let mut create_member_request = CreateRequest::new(); @@ -68,16 +74,14 @@ fn member() { let mut member_pipeline = HashMap::new(); let mut play_endpoint = WebRtcPlayEndpoint::new(); - play_endpoint - .set_src("local://create-member/publisher/publish".to_string()); + play_endpoint.set_src(format_name!("local://{}/publisher/publish")); let mut member_element = Member_Element::new(); member_element.set_webrtc_play(play_endpoint); member_pipeline.insert("play".to_string(), member_element); member.set_credentials("qwerty".to_string()); member.set_pipeline(member_pipeline); - create_member_request - .set_id("local://create-member/test-member".to_string()); + create_member_request.set_id(format_name!("local://{}/test-member")); create_member_request.set_member(member); create_member_request @@ -88,11 +92,11 @@ fn member() { sids.get(&"test-member".to_string()).unwrap().as_str(); assert_eq!( e2e_test_member_sid, - "ws://0.0.0.0:8080/create-member/test-member/qwerty" + format_name!("ws://0.0.0.0:8080/{}/test-member/qwerty") ); let member = client - .get("local://create-member/test-member") + .get(&format_name!("local://{}/test-member")) .take_member(); assert_eq!(member.get_pipeline().len(), 1); assert_eq!(member.get_credentials(), "qwerty"); @@ -100,15 +104,17 @@ fn member() { #[test] fn endpoint() { + format_name_macro!("create-endpoint"); + let client = ControlClient::new(); - client.create(&create_room_req("create-endpoint")); + client.create(&create_room_req(&format_name!("{}"))); let create_req = { let mut create_endpoint_request = CreateRequest::new(); let mut endpoint = WebRtcPublishEndpoint::new(); endpoint.set_p2p(WebRtcPublishEndpoint_P2P::NEVER); create_endpoint_request - .set_id("local://create-endpoint/responder/publish".to_string()); + .set_id(format_name!("local://{}/responder/publish")); create_endpoint_request.set_webrtc_pub(endpoint); create_endpoint_request @@ -117,7 +123,7 @@ fn endpoint() { assert_eq!(sids.len(), 0); let endpoint = client - .get("local://create-endpoint/responder/publish") + .get(&format_name!("local://{}/responder/publish")) .take_webrtc_pub(); assert_eq!(endpoint.get_p2p(), WebRtcPublishEndpoint_P2P::NEVER); } diff --git a/tests/e2e/grpc_control_api/delete.rs b/tests/e2e/grpc_control_api/delete.rs index 345fcd7c4..54808e2a5 100644 --- a/tests/e2e/grpc_control_api/delete.rs +++ b/tests/e2e/grpc_control_api/delete.rs @@ -9,6 +9,8 @@ use medea::api::control::error_codes::{ ErrorCode as MedeaErrorCode, ErrorCode, }; +use crate::format_name_macro; + use super::{create_room_req, ControlClient}; /// Tests `Delete` method of [Medea]'s [Control API]. @@ -44,27 +46,30 @@ fn test_for_delete( #[test] fn room() { + format_name_macro!("delete-room"); test_for_delete( - "delete-room", - "local://delete-room", + &format_name!("{}"), + &format_name!("local://{}"), ErrorCode::RoomNotFound, ); } #[test] fn member() { + format_name_macro!("delete-member"); test_for_delete( - "delete-member", - "local://delete-member/publisher", + &format_name!("{}"), + &format_name!("local://{}/publisher"), ErrorCode::MemberNotFound, ); } #[test] fn endpoint() { + format_name_macro!("delete-endpoint"); test_for_delete( - "delete-endpoint", - "local://delete-endpoint/publisher/publish", + &format_name!("{}"), + &format_name!("local://{}/publisher/publish"), ErrorCode::EndpointNotFound, ); } @@ -107,27 +112,31 @@ fn test_for_delete_elements_at_same_time_test( #[test] fn member_and_endpoint_same_time() { + format_name_macro!("member-and-endpoint-same-time"); + test_for_delete_elements_at_same_time_test( - "medea-and-endpoint-same-time", + &format_name!("{}"), &[ - "local://medea-and-endpoint-same-time/publisher", - "local://medea-and-endpoint-same-time/publisher/publish", + &format_name!("local://{}/publisher"), + &format_name!("local://{}/publisher/publish"), ], MedeaErrorCode::MemberNotFound, - "local://medea-and-endpoint-same-time/publisher", + &format_name!("local://{}/publisher"), ); } #[test] fn room_and_inner_elements_same_time() { + format_name_macro!("room-and-inner-elements-same-time"); + test_for_delete_elements_at_same_time_test( - "room-and-inner-elements-same-time", + &format_name!("{}"), &[ - "local://room-and-inner-elements-same-time", - "local://room-and-inner-elements-same-time/publisher", - "local://room-and-inner-elements-same-time/publisher/publish", + &format_name!("local://{}"), + &format_name!("local://{}/publisher"), + &format_name!("local://{}/publisher/publish"), ], MedeaErrorCode::RoomNotFound, - "local://room-and-inner-elements-same-time", + &format_name!("local://{}"), ); } diff --git a/tests/e2e/main.rs b/tests/e2e/main.rs index 56a30863d..73cd78951 100644 --- a/tests/e2e/main.rs +++ b/tests/e2e/main.rs @@ -2,4 +2,13 @@ pub mod grpc_control_api; mod signaling_with_grpc_control_api; pub mod signalling; -// TODO: test ws messages caused by grpc commands +#[macro_export] +macro_rules! format_name_macro { + ($name:expr) => { + macro_rules! format_name { + ($fmt:expr) => { + format!($fmt, $name) + }; + } + }; +} diff --git a/tests/e2e/signaling_with_grpc_control_api/mod.rs b/tests/e2e/signaling_with_grpc_control_api/mod.rs index 8c094bbb8..cdbd75f39 100644 --- a/tests/e2e/signaling_with_grpc_control_api/mod.rs +++ b/tests/e2e/signaling_with_grpc_control_api/mod.rs @@ -8,7 +8,9 @@ use medea_control_api_proto::grpc::control_api::{ WebRtcPlayEndpoint, WebRtcPublishEndpoint, WebRtcPublishEndpoint_P2P, }; -use crate::{grpc_control_api::ControlClient, signalling::TestMember}; +use crate::{ + format_name_macro, grpc_control_api::ControlClient, signalling::TestMember, +}; fn room_with_one_pub_member_req(room_id: &str) -> CreateRequest { let mut create_req = CreateRequest::new(); @@ -94,9 +96,11 @@ fn create_room_req(room_id: &str) -> CreateRequest { #[test] fn create_play_member_after_pub_member() { - let sys = System::new("qwerty"); + format_name_macro!("create-play-member-after-pub-member"); + + let sys = System::new(format_name!("{}")); let control_client = ControlClient::new(); - control_client.create(&room_with_one_pub_member_req("asdfg")); + control_client.create(&room_with_one_pub_member_req(&format_name!("{}"))); let peers_created = Rc::new(Cell::new(0)); @@ -118,14 +122,14 @@ fn create_play_member_after_pub_member() { let deadline = Some(std::time::Duration::from_secs(5)); Arbiter::spawn( TestMember::connect( - "ws://127.0.0.1:8080/ws/asdfg/publisher/test", + &format_name!("ws://127.0.0.1:8080/ws/{}/publisher/test"), Box::new(on_event.clone()), deadline, ) .and_then(move |_| { - control_client.create(&create_play_member_req("asdfg")); + control_client.create(&create_play_member_req(&format_name!("{}"))); TestMember::connect( - "ws://127.0.0.1:8080/ws/asdfg/responder/qwerty", + &format_name!("ws://127.0.0.1:8080/ws/{}/responder/qwerty"), Box::new(on_event), deadline, ) @@ -137,9 +141,11 @@ fn create_play_member_after_pub_member() { #[test] fn delete_member_check_peers_removed() { - let sys = System::new("qwerty"); + format_name_macro!("delete-member-check-peers-removed"); + + let sys = System::new(&format_name!("{}")); let control_client = ControlClient::new(); - control_client.create(&create_room_req("zxcv")); + control_client.create(&create_room_req(&format_name!("{}"))); let peers_created = Rc::new(Cell::new(0)); @@ -149,7 +155,8 @@ fn delete_member_check_peers_removed() { Event::PeerCreated { .. } => { peers_created.set(peers_created.get() + 1); if peers_created.get() == 2 { - control_client.delete(&["local://zxcv/responder"]); + control_client + .delete(&[&format_name!("local://{}/responder")]); } } Event::PeersRemoved { .. } => { @@ -164,12 +171,12 @@ fn delete_member_check_peers_removed() { let deadline = Some(Duration::from_secs(5)); TestMember::start( - "ws://127.0.0.1:8080/ws/zxcv/publisher/test", + &format_name!("ws://127.0.0.1:8080/ws/{}/publisher/test"), Box::new(on_event.clone()), deadline, ); TestMember::start( - "ws://127.0.0.1:8080/ws/zxcv/responder/test", + &format_name!("ws://127.0.0.1:8080/ws/{}/responder/test"), Box::new(on_event), deadline, ); From 00ffcea43ad7589fac022ba2f49229bf6375a07b Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Sun, 29 Sep 2019 12:21:22 +0300 Subject: [PATCH 675/735] Move some functions to Room --- src/api/control/error_codes.rs | 12 +- src/signalling/participants.rs | 198 +-------------------------------- src/signalling/room.rs | 195 +++++++++++++++++++++++++++++++- 3 files changed, 201 insertions(+), 204 deletions(-) diff --git a/src/api/control/error_codes.rs b/src/api/control/error_codes.rs index c3631209e..b4029537a 100644 --- a/src/api/control/error_codes.rs +++ b/src/api/control/error_codes.rs @@ -274,12 +274,6 @@ impl From for ErrorResponse { ParticipantNotFound(id) => { Self::new(ErrorCode::MemberNotFound, &id) } - ParticipantAlreadyExists(id) => { - Self::new(ErrorCode::MemberAlreadyExists, &id) - } - EndpointAlreadyExists(id) => { - Self::new(ErrorCode::EndpointAlreadyExists, &id) - } TurnServiceErr(_) | MemberError(_) => Self::unexpected(&err), } } @@ -347,6 +341,12 @@ impl From for ErrorResponse { MemberError(e) => e.into(), MembersLoadError(e) => e.into(), ParticipantServiceErr(e) => e.into(), + MemberAlreadyExists(id) => { + Self::new(ErrorCode::MemberAlreadyExists, &id) + } + EndpointAlreadyExists(id) => { + Self::new(ErrorCode::EndpointAlreadyExists, &id) + } WrongRoomId(_, _) | PeerNotFound(_) | NoTurnCredentials(_) diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 6b4814fe9..d8d142953 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -34,22 +34,15 @@ use crate::{ RpcConnectionClosed, }, control::{ - endpoints::{ - WebRtcPlayEndpoint as WebRtcPlayEndpointSpec, - WebRtcPublishEndpoint as WebRtcPublishEndpointSpec, - }, local_uri::{LocalUri, ToEndpoint, ToMember}, - MemberId, MemberSpec, RoomId, RoomSpec, WebRtcPlayId, - WebRtcPublishId, + MemberId, RoomId, RoomSpec, }, }, log::prelude::*, media::IceUser, signalling::{ elements::{ - endpoints::webrtc::{WebRtcPlayEndpoint, WebRtcPublishEndpoint}, - member::MemberError, - parse_members, Member, MembersLoadError, + member::MemberError, parse_members, Member, MembersLoadError, }, room::{ActFuture, RoomError}, Room, @@ -80,16 +73,6 @@ pub enum ParticipantServiceErr { /// Some error happened in [`Member`]. #[display(fmt = "{}", _0)] MemberError(MemberError), - - /// Try to create [`Member`] with ID which already exists. - #[display(fmt = "Participant [id = {}] already exists.", _0)] - ParticipantAlreadyExists(LocalUri), - - /// Try to create [`Endpoint`] with ID which already exists. - /// - /// [`Endpoint`]: crate::signalling::elements::endpoints::Endpoint - #[display(fmt = "Endpoint [id = {}] already exists.", _0)] - EndpointAlreadyExists(LocalUri), } impl From for ParticipantServiceErr { @@ -161,7 +144,7 @@ impl ParticipantService { /// /// __Note__ this function don't check presence of [`Member`] in /// [`ParticipantService`]. - fn get_local_uri_to_member( + pub fn get_local_uri_to_member( &self, member_id: MemberId, ) -> LocalUri { @@ -440,178 +423,7 @@ impl ParticipantService { } } - /// Creates new [`Member`] in this [`ParticipantService`]. - /// - /// This function will check that new [`Member`]'s ID is not present in - /// [`ParticipantService`]. - /// - /// Returns [`ParticipantServiceErr::ParticipantAlreadyExists`] when - /// [`Member`]'s ID already presented in [`ParticipantService`]. - // TODO: move to room - pub fn create_member( - &mut self, - id: MemberId, - spec: &MemberSpec, - ) -> Result<(), ParticipantServiceErr> { - if self.members.get(&id).is_some() { - return Err(ParticipantServiceErr::ParticipantAlreadyExists( - self.get_local_uri_to_member(id), - )); - } - let signalling_member = Member::new( - id.clone(), - spec.credentials().to_string(), - self.room_id.clone(), - ); - - for (id, publish) in spec.publish_endpoints() { - let signalling_publish = WebRtcPublishEndpoint::new( - id.clone(), - publish.p2p.clone(), - signalling_member.downgrade(), - ); - signalling_member.insert_src(signalling_publish); - } - - for (id, play) in spec.play_endpoints() { - let partner_member = self.get_member(&play.src.member_id)?; - let src = partner_member - .get_src_by_id(&play.src.endpoint_id) - .ok_or_else(|| { - MemberError::EndpointNotFound( - partner_member.get_local_uri_to_endpoint( - play.src.endpoint_id.clone().into(), - ), - ) - })?; - - let sink = WebRtcPlayEndpoint::new( - id.clone(), - play.src.clone(), - src.downgrade(), - signalling_member.downgrade(), - ); - - signalling_member.insert_sink(sink); - } - - // This is needed for atomicity. - for (_, sink) in signalling_member.sinks() { - let src = sink.src(); - src.add_sink(sink.downgrade()); - } - - self.members.insert(id, signalling_member); - - Ok(()) - } - - /// Creates new [`WebRtcPlayEndpoint`] in specified [`Member`]. - /// - /// This function will check that new [`WebRtcPlayEndpoint`]'s ID is not - /// present in [`ParticipantService`]. - /// - /// Returns [`ParticipantServiceErr::EndpointAlreadyExists`] when - /// [`WebRtcPlayEndpoint`]'s ID already presented in [`Member`]. - // TODO: move to room - pub fn create_sink_endpoint( - &mut self, - member_id: &MemberId, - endpoint_id: WebRtcPlayId, - spec: WebRtcPlayEndpointSpec, - ) -> Result<(), ParticipantServiceErr> { - let member = self.get_member(&member_id)?; - - let is_member_have_this_sink_id = - member.get_sink_by_id(&endpoint_id).is_some(); - - let publish_id = String::from(endpoint_id).into(); - let is_member_have_this_src_id = - member.get_src_by_id(&publish_id).is_some(); - if is_member_have_this_sink_id || is_member_have_this_src_id { - return Err(ParticipantServiceErr::EndpointAlreadyExists( - member.get_local_uri_to_endpoint(publish_id.into()), - )); - } - - let partner_member = self.get_member(&spec.src.member_id)?; - let src = partner_member - .get_src_by_id(&spec.src.endpoint_id) - .ok_or_else(|| { - MemberError::EndpointNotFound( - partner_member.get_local_uri_to_endpoint( - spec.src.endpoint_id.clone().into(), - ), - ) - })?; - - let sink = WebRtcPlayEndpoint::new( - String::from(publish_id).into(), - spec.src, - src.downgrade(), - member.downgrade(), - ); - - src.add_sink(sink.downgrade()); - - debug!( - "Created WebRtcPlayEndpoint [id = {}] for Member [id = {}] in \ - Room [id = {}].", - sink.id(), - member_id, - self.room_id - ); - - member.insert_sink(sink); - - Ok(()) - } - - /// Creates new [`WebRtcPlayEndpoint`] in specified [`Member`]. - /// - /// This function will check that new [`WebRtcPublishEndpoint`]'s ID is not - /// present in [`ParticipantService`]. - /// - /// Returns [`ParticipantServiceErr::EndpointAlreadyExists`] when - /// [`WebRtcPublishEndpoint`]'s ID already presented in [`Member`]. - // TODO: move to room - pub fn create_src_endpoint( - &mut self, - member_id: &MemberId, - publish_id: WebRtcPublishId, - spec: WebRtcPublishEndpointSpec, - ) -> Result<(), ParticipantServiceErr> { - let member = self.get_member(&member_id)?; - - let is_member_have_this_src_id = - member.get_src_by_id(&publish_id).is_some(); - - let play_id = String::from(publish_id).into(); - let is_member_have_this_sink_id = - member.get_sink_by_id(&play_id).is_some(); - - if is_member_have_this_sink_id || is_member_have_this_src_id { - return Err(ParticipantServiceErr::EndpointAlreadyExists( - member.get_local_uri_to_endpoint(play_id.into()), - )); - } - - let endpoint = WebRtcPublishEndpoint::new( - String::from(play_id).into(), - spec.p2p, - member.downgrade(), - ); - - debug!( - "Create WebRtcPublishEndpoint [id = {}] for Member [id = {}] in \ - Room [id = {}]", - endpoint.id(), - member_id, - self.room_id - ); - - member.insert_src(endpoint); - - Ok(()) + pub fn create_membe(&mut self, id: MemberId, member: Member) { + self.members.insert(id, member); } } diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 33de7239c..f50f317cc 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -24,10 +24,14 @@ use crate::{ RpcConnectionClosed, RpcConnectionEstablished, }, control::{ - local_uri::{LocalUri, StatefulLocalUri, ToMember}, + endpoints::{ + WebRtcPlayEndpoint as WebRtcPlayEndpointSpec, + WebRtcPublishEndpoint as WebRtcPublishEndpointSpec, + }, + local_uri::{LocalUri, StatefulLocalUri, ToEndpoint, ToMember}, room::RoomSpec, EndpointId, EndpointSpec, MemberId, MemberSpec, RoomId, - TryFromElementError, + TryFromElementError, WebRtcPlayId, WebRtcPublishId, }, }, log::prelude::*, @@ -85,6 +89,14 @@ pub enum RoomError { _1 )] WrongRoomId(StatefulLocalUri, RoomId), + /// Try to create [`Member`] with ID which already exists. + #[display(fmt = "Member [id = {}] already exists.", _0)] + MemberAlreadyExists(LocalUri), + /// Try to create [`Endpoint`] with ID which already exists. + /// + /// [`Endpoint`]: crate::signalling::elements::endpoints::Endpoint + #[display(fmt = "Endpoint [id = {}] already exists.", _0)] + EndpointAlreadyExists(LocalUri), } impl From for RoomError { @@ -660,6 +672,179 @@ impl Room { endpoint_id, member_id, self.id ); } + + /// Creates new [`WebRtcPlayEndpoint`] in specified [`Member`]. + /// + /// This function will check that new [`WebRtcPublishEndpoint`]'s ID is not + /// present in [`ParticipantService`]. + /// + /// Returns [`ParticipantServiceErr::EndpointAlreadyExists`] when + /// [`WebRtcPublishEndpoint`]'s ID already presented in [`Member`]. + pub fn create_src_endpoint( + &mut self, + member_id: &MemberId, + publish_id: WebRtcPublishId, + spec: WebRtcPublishEndpointSpec, + ) -> Result<(), RoomError> { + let member = self.members.get_member(&member_id)?; + + let is_member_have_this_src_id = + member.get_src_by_id(&publish_id).is_some(); + + let play_id = String::from(publish_id).into(); + let is_member_have_this_sink_id = + member.get_sink_by_id(&play_id).is_some(); + + if is_member_have_this_sink_id || is_member_have_this_src_id { + return Err(RoomError::EndpointAlreadyExists( + member.get_local_uri_to_endpoint(play_id.into()), + )); + } + + let endpoint = WebRtcPublishEndpoint::new( + String::from(play_id).into(), + spec.p2p, + member.downgrade(), + ); + + debug!( + "Create WebRtcPublishEndpoint [id = {}] for Member [id = {}] in \ + Room [id = {}]", + endpoint.id(), + member_id, + self.id + ); + + member.insert_src(endpoint); + + Ok(()) + } + + /// Creates new [`WebRtcPlayEndpoint`] in specified [`Member`]. + /// + /// This function will check that new [`WebRtcPlayEndpoint`]'s ID is not + /// present in [`ParticipantService`]. + /// + /// Returns [`ParticipantServiceErr::EndpointAlreadyExists`] when + /// [`WebRtcPlayEndpoint`]'s ID already presented in [`Member`]. + pub fn create_sink_endpoint( + &mut self, + member_id: &MemberId, + endpoint_id: WebRtcPlayId, + spec: WebRtcPlayEndpointSpec, + ) -> Result<(), RoomError> { + let member = self.members.get_member(&member_id)?; + + let is_member_have_this_sink_id = + member.get_sink_by_id(&endpoint_id).is_some(); + + let publish_id = String::from(endpoint_id).into(); + let is_member_have_this_src_id = + member.get_src_by_id(&publish_id).is_some(); + if is_member_have_this_sink_id || is_member_have_this_src_id { + return Err(RoomError::EndpointAlreadyExists( + member.get_local_uri_to_endpoint(publish_id.into()), + )); + } + + let partner_member = self.members.get_member(&spec.src.member_id)?; + let src = partner_member + .get_src_by_id(&spec.src.endpoint_id) + .ok_or_else(|| { + MemberError::EndpointNotFound( + partner_member.get_local_uri_to_endpoint( + spec.src.endpoint_id.clone().into(), + ), + ) + })?; + + let sink = WebRtcPlayEndpoint::new( + String::from(publish_id).into(), + spec.src, + src.downgrade(), + member.downgrade(), + ); + + src.add_sink(sink.downgrade()); + + debug!( + "Created WebRtcPlayEndpoint [id = {}] for Member [id = {}] in \ + Room [id = {}].", + sink.id(), + member_id, + self.id + ); + + member.insert_sink(sink); + + Ok(()) + } + + /// Creates new [`Member`] in this [`ParticipantService`]. + /// + /// This function will check that new [`Member`]'s ID is not present in + /// [`ParticipantService`]. + /// + /// Returns [`ParticipantServiceErr::ParticipantAlreadyExists`] when + /// [`Member`]'s ID already presented in [`ParticipantService`]. + pub fn create_member( + &mut self, + id: MemberId, + spec: &MemberSpec, + ) -> Result<(), RoomError> { + if self.members.get_member_by_id(&id).is_some() { + return Err(RoomError::MemberAlreadyExists( + self.members.get_local_uri_to_member(id), + )); + } + let signalling_member = Member::new( + id.clone(), + spec.credentials().to_string(), + self.id.clone(), + ); + + for (id, publish) in spec.publish_endpoints() { + let signalling_publish = WebRtcPublishEndpoint::new( + id.clone(), + publish.p2p.clone(), + signalling_member.downgrade(), + ); + signalling_member.insert_src(signalling_publish); + } + + for (id, play) in spec.play_endpoints() { + let partner_member = + self.members.get_member(&play.src.member_id)?; + let src = partner_member + .get_src_by_id(&play.src.endpoint_id) + .ok_or_else(|| { + MemberError::EndpointNotFound( + partner_member.get_local_uri_to_endpoint( + play.src.endpoint_id.clone().into(), + ), + ) + })?; + + let sink = WebRtcPlayEndpoint::new( + id.clone(), + play.src.clone(), + src.downgrade(), + signalling_member.downgrade(), + ); + + signalling_member.insert_sink(sink); + } + + // This is needed for atomicity. + for (_, sink) in signalling_member.sinks() { + let src = sink.src(); + src.add_sink(sink.downgrade()); + } + + self.members.create_membe(id, signalling_member); + + Ok(()) + } } /// [`Actor`] implementation that provides an ergonomic way @@ -966,7 +1151,7 @@ impl Handler for Room { msg: CreateMember, _: &mut Self::Context, ) -> Self::Result { - self.members.create_member(msg.0.clone(), &msg.1)?; + self.create_member(msg.0.clone(), &msg.1)?; debug!( "Member [id = {}] created in Room [id = {}].", msg.0, self.id @@ -994,14 +1179,14 @@ impl Handler for Room { ) -> Self::Result { match msg.spec { EndpointSpec::WebRtcPlay(endpoint) => { - self.members.create_sink_endpoint( + self.create_sink_endpoint( &msg.member_id, msg.endpoint_id.into(), endpoint, )?; } EndpointSpec::WebRtcPublish(endpoint) => { - self.members.create_src_endpoint( + self.create_src_endpoint( &msg.member_id, msg.endpoint_id.into(), endpoint, From a20f528835e9c5ae58d6b83a709b4379f2dede91 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Sun, 29 Sep 2019 12:52:27 +0300 Subject: [PATCH 676/735] Add docs in tests --- tests/e2e/grpc_control_api/mod.rs | 53 ++++++------- .../signaling_with_grpc_control_api/mod.rs | 76 +++++++++++++++++-- tests/e2e/signalling/mod.rs | 30 +++----- 3 files changed, 106 insertions(+), 53 deletions(-) diff --git a/tests/e2e/grpc_control_api/mod.rs b/tests/e2e/grpc_control_api/mod.rs index f0c404416..4bd7fb419 100644 --- a/tests/e2e/grpc_control_api/mod.rs +++ b/tests/e2e/grpc_control_api/mod.rs @@ -1,7 +1,8 @@ -/// Tests for gRPC [Medea]'s [Control API]. -/// -/// [Medea]: https://github.com/instrumentisto/medea -/// [Control API]: https://tinyurl.com/yxsqplq7 +//! Tests for gRPC [Medea]'s [Control API]. +//! +//! [Medea]: https://github.com/instrumentisto/medea +//! [Control API]: https://tinyurl.com/yxsqplq7 + mod create; mod delete; @@ -21,7 +22,7 @@ use protobuf::RepeatedField; /// Client for [Medea]'s gRPC [Control API]. /// /// [Medea]: https://github.com/instrumentisto/medea -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct ControlClient(ControlApiClient); impl ControlClient { @@ -110,32 +111,32 @@ impl ControlClient { } } -/// Creates [`CreateRequest`] for creating `Room` element with provided room ID. +/// Creates [`CreateRequest`] for creating `Room` element with provided `Room` ID. /// /// # Spec of `Room` which will be created with this [`CreateRequest`] /// /// ```yaml /// kind: Room -/// id: {{ room_id }} -/// spec: -/// pipeline: -/// publisher: -/// kind: Member -/// spec: -/// pipeline: -/// publish: -/// kind: WebRtcPublishEndpoint -/// spec: -/// p2p: Always -/// responder: -/// kind: Member -/// credentials: test -/// spec: -/// pipeline: -/// play: -/// kind: WebRtcPlayEndpoint -/// spec: -/// src: "local://{{ room_id }}/publisher/publish" +/// id: {{ room_id }} +/// spec: +/// pipeline: +/// publisher: +/// kind: Member +/// spec: +/// pipeline: +/// publish: +/// kind: WebRtcPublishEndpoint +/// spec: +/// p2p: Always +/// responder: +/// kind: Member +/// credentials: test +/// spec: +/// pipeline: +/// play: +/// kind: WebRtcPlayEndpoint +/// spec: +/// src: "local://{{ room_id }}/publisher/publish" /// ``` pub fn create_room_req(room_id: &str) -> CreateRequest { let mut create_req = CreateRequest::new(); diff --git a/tests/e2e/signaling_with_grpc_control_api/mod.rs b/tests/e2e/signaling_with_grpc_control_api/mod.rs index cdbd75f39..36e3d13ee 100644 --- a/tests/e2e/signaling_with_grpc_control_api/mod.rs +++ b/tests/e2e/signaling_with_grpc_control_api/mod.rs @@ -1,3 +1,7 @@ +//! Tests for signaling which should be happen after gRPC [Control API] call. +//! +//! [Control API]: https://tinyurl.com/yxsqplq7 + use std::{cell::Cell, collections::HashMap, rc::Rc, time::Duration}; use actix::{Arbiter, AsyncContext, Context, System}; @@ -12,6 +16,25 @@ use crate::{ format_name_macro, grpc_control_api::ControlClient, signalling::TestMember, }; +/// Creates [`CreateRequest`] for creating `Room` element with provided room ID and `Member` with `WebRtcPublishEndpoint`. +/// +/// # Spec of `Room` which will be created with this [`CreateRequest`] +/// +/// ```yaml +/// kind: Room +/// id: {{ room_id }} +/// spec: +/// pipeline: +/// publisher: +/// kind: Member +/// credentials: test +/// spec: +/// pipeline: +/// publish: +/// kind: WebRtcPublishEndpoint +/// spec: +/// p2p: Always +/// ``` fn room_with_one_pub_member_req(room_id: &str) -> CreateRequest { let mut create_req = CreateRequest::new(); let mut room = Room::new(); @@ -37,6 +60,21 @@ fn room_with_one_pub_member_req(room_id: &str) -> CreateRequest { create_req } +/// Creates [`CreateRequest`] for creating `Member` element in provided Room ID. +/// +/// # Spec of `Member` which will be created with this [`CreateRequest`] +/// +/// ```yaml +/// kind: Member +/// id: responder +/// credentials: qwerty +/// spec: +/// pipeline: +/// play: +/// kind: WebRtcPlayEndpoint +/// spec: +/// src: "local://{{ room_id }}/publisher/publish +/// ``` fn create_play_member_req(room_id: &str) -> CreateRequest { let mut create_member_request = CreateRequest::new(); let mut member = Member::new(); @@ -56,6 +94,34 @@ fn create_play_member_req(room_id: &str) -> CreateRequest { create_member_request } +/// Creates [`CreateRequest`] for creating `Room` element with provided room ID. +/// +/// # Spec of `Room` which will be created with this [`CreateRequest`] +/// +/// ```yaml +/// kind: Room +/// id: {{ room_id }} +/// spec: +/// pipeline: +/// publisher: +/// kind: Member +/// credentials: test +/// spec: +/// pipeline: +/// publish: +/// kind: WebRtcPublishEndpoint +/// spec: +/// p2p: Always +/// responder: +/// kind: Member +/// credentials: test +/// spec: +/// pipeline: +/// play: +/// kind: WebRtcPlayEndpoint +/// spec: +/// src: "local://{{ room_id }}/publisher/publish" +/// ``` fn create_room_req(room_id: &str) -> CreateRequest { let mut create_req = CreateRequest::new(); let mut room = Room::new(); @@ -97,13 +163,12 @@ fn create_room_req(room_id: &str) -> CreateRequest { #[test] fn create_play_member_after_pub_member() { format_name_macro!("create-play-member-after-pub-member"); - let sys = System::new(format_name!("{}")); + let control_client = ControlClient::new(); control_client.create(&room_with_one_pub_member_req(&format_name!("{}"))); let peers_created = Rc::new(Cell::new(0)); - let on_event = move |event: &Event, ctx: &mut Context, _: Vec<&Event>| { match event { @@ -133,7 +198,8 @@ fn create_play_member_after_pub_member() { Box::new(on_event), deadline, ) - }), + }) + .map(|_| ()), ); sys.run().unwrap(); @@ -142,13 +208,12 @@ fn create_play_member_after_pub_member() { #[test] fn delete_member_check_peers_removed() { format_name_macro!("delete-member-check-peers-removed"); - let sys = System::new(&format_name!("{}")); + let control_client = ControlClient::new(); control_client.create(&create_room_req(&format_name!("{}"))); let peers_created = Rc::new(Cell::new(0)); - let on_event = move |event: &Event, ctx: &mut Context, _: Vec<&Event>| { match event { @@ -169,7 +234,6 @@ fn delete_member_check_peers_removed() { }; let deadline = Some(Duration::from_secs(5)); - TestMember::start( &format_name!("ws://127.0.0.1:8080/ws/{}/publisher/test"), Box::new(on_event.clone()), diff --git a/tests/e2e/signalling/mod.rs b/tests/e2e/signalling/mod.rs index 0175ccda3..586f40a52 100644 --- a/tests/e2e/signalling/mod.rs +++ b/tests/e2e/signalling/mod.rs @@ -5,7 +5,10 @@ mod three_pubs; use std::time::Duration; -use actix::{Actor, Arbiter, AsyncContext, Context, Handler, StreamHandler}; +use actix::{ + Actor, Addr, Arbiter, AsyncContext, Context, Handler, StreamHandler, +}; +use futures::Future; use actix_codec::Framed; use actix_http::ws; use awc::{ @@ -60,11 +63,13 @@ impl TestMember { self.writer.poll_complete().ok(); } + /// Returns [`Future`] which will connect to the WebSocket and starts [`TestMember`] + /// actor. pub fn connect( uri: &str, on_message: MessageHandler, deadline: Option, - ) -> impl futures::future::Future { + ) -> impl Future, Error = ()> { awc::Client::new() .ws(uri) .connect() @@ -79,7 +84,7 @@ impl TestMember { deadline, on_message, } - }); + }) }) } @@ -91,24 +96,7 @@ impl TestMember { on_message: MessageHandler, deadline: Option, ) { - Arbiter::spawn( - awc::Client::new() - .ws(uri) - .connect() - .map_err(|e| panic!("Error: {}", e)) - .map(move |(_, framed)| { - let (sink, stream) = framed.split(); - TestMember::create(move |ctx| { - TestMember::add_stream(stream, ctx); - TestMember { - writer: sink, - events: Vec::new(), - deadline, - on_message, - } - }); - }), - ) + Arbiter::spawn(Self::connect(uri, on_message, deadline).map(|_| ())) } } From e62c39eeb050e9e1805c92252055dcd911780ebd Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Sun, 29 Sep 2019 13:16:42 +0300 Subject: [PATCH 677/735] Move Control API signaling tests into control_api_grpc module --- tests/e2e/grpc_control_api/mod.rs | 10 ++++--- .../mod.rs => grpc_control_api/signaling.rs} | 3 ++- tests/e2e/main.rs | 26 +++++++++++++++++-- tests/e2e/signalling/mod.rs | 7 +++-- 4 files changed, 35 insertions(+), 11 deletions(-) rename tests/e2e/{signaling_with_grpc_control_api/mod.rs => grpc_control_api/signaling.rs} (99%) diff --git a/tests/e2e/grpc_control_api/mod.rs b/tests/e2e/grpc_control_api/mod.rs index 4bd7fb419..3d4340479 100644 --- a/tests/e2e/grpc_control_api/mod.rs +++ b/tests/e2e/grpc_control_api/mod.rs @@ -5,6 +5,7 @@ mod create; mod delete; +mod signaling; use std::{collections::HashMap, sync::Arc}; @@ -22,8 +23,8 @@ use protobuf::RepeatedField; /// Client for [Medea]'s gRPC [Control API]. /// /// [Medea]: https://github.com/instrumentisto/medea -#[derive(Clone, Debug)] -pub struct ControlClient(ControlApiClient); +#[derive(Clone)] +struct ControlClient(ControlApiClient); impl ControlClient { /// Create new [`ControlClient`]. @@ -111,7 +112,8 @@ impl ControlClient { } } -/// Creates [`CreateRequest`] for creating `Room` element with provided `Room` ID. +/// Creates [`CreateRequest`] for creating `Room` element with provided `Room` +/// ID. /// /// # Spec of `Room` which will be created with this [`CreateRequest`] /// @@ -138,7 +140,7 @@ impl ControlClient { /// spec: /// src: "local://{{ room_id }}/publisher/publish" /// ``` -pub fn create_room_req(room_id: &str) -> CreateRequest { +fn create_room_req(room_id: &str) -> CreateRequest { let mut create_req = CreateRequest::new(); let mut room = Room::new(); let mut publisher = Member::new(); diff --git a/tests/e2e/signaling_with_grpc_control_api/mod.rs b/tests/e2e/grpc_control_api/signaling.rs similarity index 99% rename from tests/e2e/signaling_with_grpc_control_api/mod.rs rename to tests/e2e/grpc_control_api/signaling.rs index 36e3d13ee..a767806e2 100644 --- a/tests/e2e/signaling_with_grpc_control_api/mod.rs +++ b/tests/e2e/grpc_control_api/signaling.rs @@ -16,7 +16,8 @@ use crate::{ format_name_macro, grpc_control_api::ControlClient, signalling::TestMember, }; -/// Creates [`CreateRequest`] for creating `Room` element with provided room ID and `Member` with `WebRtcPublishEndpoint`. +/// Creates [`CreateRequest`] for creating `Room` element with provided room ID +/// and `Member` with `WebRtcPublishEndpoint`. /// /// # Spec of `Room` which will be created with this [`CreateRequest`] /// diff --git a/tests/e2e/main.rs b/tests/e2e/main.rs index 73cd78951..7cc210353 100644 --- a/tests/e2e/main.rs +++ b/tests/e2e/main.rs @@ -1,7 +1,29 @@ -pub mod grpc_control_api; -mod signaling_with_grpc_control_api; +mod grpc_control_api; pub mod signalling; +/// Macro which generates `format_name!` macro which will replaces `{}` with +/// provided to `format_name_macro!` name. +/// +/// # Example usage +/// +/// ``` +/// fn first_test() { +/// format_name_macro!("first-test"); +/// +/// let addr = format_name!("ws://127.0.0.1:8080/{}/publisher/test"); +/// assert_eq!(addr, "ws://127.0.0.1:8080/first-test/publisher/test"); +/// } +/// +/// fn second_test() { +/// format_name_macro!("second-test"); +/// +/// let addr = format_name!("local://{}/publisher"); +/// assert_eq!(addr, "local://second-test/publisher"); +/// } +/// +/// # first_test(); +/// # second_test(); +/// ``` #[macro_export] macro_rules! format_name_macro { ($name:expr) => { diff --git a/tests/e2e/signalling/mod.rs b/tests/e2e/signalling/mod.rs index 586f40a52..0b4995526 100644 --- a/tests/e2e/signalling/mod.rs +++ b/tests/e2e/signalling/mod.rs @@ -8,7 +8,6 @@ use std::time::Duration; use actix::{ Actor, Addr, Arbiter, AsyncContext, Context, Handler, StreamHandler, }; -use futures::Future; use actix_codec::Framed; use actix_http::ws; use awc::{ @@ -16,7 +15,7 @@ use awc::{ ws::{CloseCode, CloseReason, Frame}, BoxedSocket, }; -use futures::{stream::SplitSink, Future as _, Sink as _, Stream as _}; +use futures::{stream::SplitSink, Future, Future as _, Sink as _, Stream as _}; use medea_client_api_proto::{Command, Event, IceCandidate}; use serde_json::error::Error as SerdeError; @@ -63,8 +62,8 @@ impl TestMember { self.writer.poll_complete().ok(); } - /// Returns [`Future`] which will connect to the WebSocket and starts [`TestMember`] - /// actor. + /// Returns [`Future`] which will connect to the WebSocket and starts + /// [`TestMember`] actor. pub fn connect( uri: &str, on_message: MessageHandler, From dd8023f79f67dbfaafd7e7746e5ae2202651061d Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Sun, 29 Sep 2019 19:22:16 +0300 Subject: [PATCH 678/735] Fix updating Member's endpoints on new endpoint create [run ci] --- src/signalling/room.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/signalling/room.rs b/src/signalling/room.rs index f50f317cc..d35a2bd21 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -732,6 +732,7 @@ impl Room { member_id: &MemberId, endpoint_id: WebRtcPlayId, spec: WebRtcPlayEndpointSpec, + ctx: &mut Context, ) -> Result<(), RoomError> { let member = self.members.get_member(&member_id)?; @@ -777,6 +778,8 @@ impl Room { member.insert_sink(sink); + self.init_member_connections(&member, ctx); + Ok(()) } @@ -1175,7 +1178,7 @@ impl Handler for Room { fn handle( &mut self, msg: CreateEndpoint, - _: &mut Self::Context, + ctx: &mut Self::Context, ) -> Self::Result { match msg.spec { EndpointSpec::WebRtcPlay(endpoint) => { @@ -1183,6 +1186,7 @@ impl Handler for Room { &msg.member_id, msg.endpoint_id.into(), endpoint, + ctx, )?; } EndpointSpec::WebRtcPublish(endpoint) => { From d572220b0eef0ebf8d1e9b07a7d468cfcd1884bc Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 30 Sep 2019 01:49:12 +0300 Subject: [PATCH 679/735] Increase timeout for Member disconnection in test, update deps [run ci] --- Cargo.lock | 196 +++++++++++++----------- tests/e2e/grpc_control_api/signaling.rs | 2 +- 2 files changed, 108 insertions(+), 90 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 62304c923..a638eb536 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -17,7 +17,7 @@ dependencies = [ "actix-http 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "actix-rt 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "actix_derive 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-channel 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -78,7 +78,7 @@ dependencies = [ "actix-threadpool 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "actix-utils 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", - "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "brotli2 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -121,10 +121,10 @@ dependencies = [ "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "actix-connect 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "actix-rt 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-server 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-server 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "actix-service 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "actix-utils 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "awc 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "awc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -171,7 +171,7 @@ dependencies = [ [[package]] name = "actix-server" -version = "0.6.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "actix-rt 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -208,6 +208,22 @@ dependencies = [ "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "actix-testing" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "actix-rt 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-server 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-server-config 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-service 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "actix-threadpool" version = "0.1.2" @@ -239,20 +255,21 @@ dependencies = [ [[package]] name = "actix-web" -version = "1.0.7" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "actix-http 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "actix-router 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "actix-rt 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-server 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-server 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "actix-server-config 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "actix-service 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-testing 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "actix-threadpool 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "actix-utils 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "actix-web-codegen 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "awc 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "awc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", "encoding_rs 0.8.20 (registry+https://github.com/rust-lang/crates.io-index)", @@ -278,7 +295,7 @@ dependencies = [ "actix 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)", "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "actix-http 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-web 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-web 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -359,7 +376,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "awc" -version = "0.2.6" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -381,11 +398,11 @@ dependencies = [ [[package]] name = "backtrace" -version = "0.3.37" +version = "0.3.38" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "backtrace-sys 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -430,7 +447,7 @@ dependencies = [ [[package]] name = "bitflags" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -496,7 +513,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cfg-if" -version = "0.1.9" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -515,7 +532,7 @@ name = "cloudabi" version = "0.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -558,8 +575,8 @@ name = "console_error_panic_hook" version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -577,7 +594,7 @@ name = "crc32fast" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -585,7 +602,7 @@ name = "crossbeam" version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-channel 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-deque 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-epoch 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -616,7 +633,7 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "memoffset 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -636,7 +653,7 @@ name = "crossbeam-utils" version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -719,7 +736,7 @@ name = "encoding_rs" version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -749,7 +766,7 @@ name = "failure" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "backtrace 0.3.37 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace 0.3.38 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -803,7 +820,7 @@ name = "fuchsia-zircon" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -827,18 +844,18 @@ name = "getrandom" version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", "wasi 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "grpcio" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "grpcio-sys 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "grpcio-sys 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.8.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -857,7 +874,7 @@ dependencies = [ [[package]] name = "grpcio-sys" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)", @@ -994,10 +1011,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "js-sys" -version = "0.3.27" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "wasm-bindgen 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1073,7 +1090,7 @@ name = "log" version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1102,9 +1119,9 @@ dependencies = [ "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "actix-http 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "actix-http-test 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-web 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-web 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", "actix-web-actors 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "awc 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "awc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", "bb8 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "bb8-redis 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1113,7 +1130,7 @@ dependencies = [ "dotenv 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "grpcio 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "grpcio 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "humantime-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "medea-client-api-proto 0.1.1-dev", @@ -1157,9 +1174,9 @@ name = "medea-control-api-proto" version = "0.1.0-dev" dependencies = [ "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "grpcio 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "grpcio 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "protoc-grpcio 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "protoc-grpcio 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1170,7 +1187,7 @@ dependencies = [ "downcast 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "fragile 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "js-sys 0.3.27 (registry+https://github.com/rust-lang/crates.io-index)", + "js-sys 0.3.28 (registry+https://github.com/rust-lang/crates.io-index)", "macro-attr 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "medea-client-api-proto 0.1.1-dev", "medea-macro 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1179,10 +1196,10 @@ dependencies = [ "predicates-tree 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-futures 0.3.27 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-test 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", - "web-sys 0.3.27 (registry+https://github.com/rust-lang/crates.io-index)", + "web-sys 0.3.28 (registry+https://github.com/rust-lang/crates.io-index)", "wee_alloc 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1290,7 +1307,7 @@ name = "mockall" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "downcast 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "fragile 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1304,7 +1321,7 @@ name = "mockall_derive" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1315,7 +1332,7 @@ name = "net2" version = "0.2.33" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1434,7 +1451,7 @@ name = "parking_lot_core" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1449,7 +1466,7 @@ name = "parking_lot_core" version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1543,7 +1560,7 @@ dependencies = [ [[package]] name = "protoc-grpcio" -version = "1.0.2" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2110,7 +2127,7 @@ name = "socket2" version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2175,7 +2192,7 @@ name = "tempfile" version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2462,7 +2479,7 @@ name = "trust-dns-resolver" version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "ipconfig 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2551,18 +2568,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "wasm-bindgen" -version = "0.2.50" +version = "0.2.51" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-macro 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-macro 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.50" +version = "0.2.51" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bumpalo 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2571,7 +2588,7 @@ dependencies = [ "proc-macro2 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-shared 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-shared 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2579,37 +2596,37 @@ name = "wasm-bindgen-futures" version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "js-sys 0.3.27 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", - "web-sys 0.3.27 (registry+https://github.com/rust-lang/crates.io-index)", + "js-sys 0.3.28 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "web-sys 0.3.28 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.50" +version = "0.2.51" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-macro-support 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-macro-support 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.50" +version = "0.2.51" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-backend 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-shared 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-backend 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-shared 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.50" +version = "0.2.51" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -2619,9 +2636,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "console_error_panic_hook 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "js-sys 0.3.27 (registry+https://github.com/rust-lang/crates.io-index)", + "js-sys 0.3.28 (registry+https://github.com/rust-lang/crates.io-index)", "scoped-tls 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-futures 0.3.27 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-test-macro 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2637,7 +2654,7 @@ dependencies = [ [[package]] name = "wasm-bindgen-webidl" -version = "0.2.50" +version = "0.2.51" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2646,20 +2663,20 @@ dependencies = [ "proc-macro2 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-backend 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-backend 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", "weedle 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "web-sys" -version = "0.3.27" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "js-sys 0.3.27 (registry+https://github.com/rust-lang/crates.io-index)", + "js-sys 0.3.28 (registry+https://github.com/rust-lang/crates.io-index)", "sourcefile 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-webidl 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-webidl 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2667,7 +2684,7 @@ name = "wee_alloc" version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", "memory_units 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2774,12 +2791,13 @@ dependencies = [ "checksum actix-http-test 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "4c29c11568a1fd24163f7757aea88737082c1b8317f550262f9a1f47e9832f54" "checksum actix-router 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "23224bb527e204261d0291102cb9b52713084def67d94f7874923baefe04ccf7" "checksum actix-rt 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "168620aaf00fcd2a16e621790abaf180ef7377c2f8355b4ca5775d6afc778ed8" -"checksum actix-server 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fb3038e9e457e0a498ea682723e0f4e6cc2c4f362a1868d749808355275ad959" +"checksum actix-server 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dd626534af8d0a738e5f74901fe603af0445708f91b86a7d763d80df10d562a5" "checksum actix-server-config 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "483a34989c682d93142bacad6300375bb6ad8002d2e0bb249dbad86128b9ff30" "checksum actix-service 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bca5b48e928841ff7e7dce1fdb5b0d4582f6b1b976e08f4bac3f640643e0773f" +"checksum actix-testing 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "af001e97ac6750994824d400a1b7087055aab14317aa012f528d0b2b363f37f1" "checksum actix-threadpool 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6b5ae85d13da7e6fb86b1b7bc83185e0e3bd4cc5f421c887e1803796c034d35d" "checksum actix-utils 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6ea501068a0173533704be321f149853f702d9e3c3ce9d57e7a96d94b1ab5aca" -"checksum actix-web 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "8ced216f53d465f9d6478454b2b994d1fe91ec203ac9d056837cbe07e823cb83" +"checksum actix-web 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "36e59485f007a4be3df228791ff6c4aedcbe7bb09bd9225c3554f538aca4a584" "checksum actix-web-actors 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "008c1b686048a16fef4ef2fc6b6e5fcf5f29829891ad87fc0848ade26b285627" "checksum actix-web-codegen 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3fe9e3cdec1e645b675f354766e0688c5705021c85ab3cf739be1c8999b91c76" "checksum actix_derive 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0bf5f6d7bf2d220ae8b4a7ae02a572bb35b7c4806b24049af905ab8110de156c" @@ -2792,13 +2810,13 @@ dependencies = [ "checksum ascii 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "eab1c04a571841102f5345a8fc0f6bb3d31c315dec879b5c6e42e40ce7ffa34e" "checksum atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1803c647a3ec87095e7ae7acfca019e98de5ec9a7d01343f611cf3152ed71a90" "checksum autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "b671c8fb71b457dd4ae18c4ba1e59aa81793daacc361d82fcd410cef0d491875" -"checksum awc 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "78c9c1e32d6084343b3857eacb1f43aaefb93a816e15aae4685bc3c0a9052964" -"checksum backtrace 0.3.37 (registry+https://github.com/rust-lang/crates.io-index)" = "5180c5a20655b14a819b652fd2378fa5f1697b6c9ddad3e695c2f9cedf6df4e2" +"checksum awc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "364537de6ac9f996780f9dd097d6c4ca7c91dd5735153e9fb545037479becd10" +"checksum backtrace 0.3.38 (registry+https://github.com/rust-lang/crates.io-index)" = "690a62be8920ccf773ee00ef0968649b0e724cda8bd5b12286302b4ae955fdf5" "checksum backtrace-sys 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)" = "82a830b4ef2d1124a711c71d263c5abdc710ef8e907bd508c88be475cebc422b" "checksum base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" "checksum bb8 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0ac73ee3406f475415bba792942016291b87bac08839c38a032de56085a73b2c" "checksum bb8-redis 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "39945a33c03edfba8c353d330b921961e2137d4fc4215331c1b2397f32acff80" -"checksum bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3d155346769a6855b86399e9bc3814ab343cd3d62c7e985113d46a0ec3c281fd" +"checksum bitflags 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8a606a02debe2813760609f57a64a2ffd27d9fdf5b2f133eaca0b248dd92cdd2" "checksum blake2b_simd 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)" = "5850aeee1552f495dd0250014cf64b82b7c8879a89d83b33bbdace2cc4f63182" "checksum brotli-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4445dea95f4c2b41cde57cc9fee236ae4dbae88d8fcbdb4750fc1bb5d86aaecd" "checksum brotli2 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0cb036c3eade309815c15ddbacec5b22c4d1f3983a774ab2eac2e3e9ea85568e" @@ -2807,7 +2825,7 @@ dependencies = [ "checksum bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" "checksum c2-chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7d64d04786e0f528460fc884753cf8dddcc466be308f6026f8e355c41a0e4101" "checksum cc 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)" = "4fc9a35e1f4290eb9e5fc54ba6cf40671ed2a2514c3eeb2b2a908dda2ea5a1be" -"checksum cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b486ce3ccf7ffd79fdeb678eac06a9e6c09fc88d33836340becb8fffe87c5e33" +"checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" "checksum chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e8493056968583b0193c1bb04d6f7684586f3726992d6c573261941a895dbd68" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" "checksum cmake 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "81fb25b677f8bf1eb325017cb6bb8452f87969db0fedb4f757b297bee78a7c62" @@ -2847,9 +2865,9 @@ dependencies = [ "checksum futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)" = "1b980f2816d6ee8673b6517b52cb0e808a180efc92e5c19d02cdda79066703ef" "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" "checksum getrandom 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "473a1265acc8ff1e808cd0a1af8cee3c2ee5200916058a2ca113c29f2d903571" -"checksum grpcio 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c02fb3c9c44615973814c838f75d7898695d4d4b97a3e8cf52e9ccca30664b6f" +"checksum grpcio 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "cf45c98940795d83354880f073f3a2a2a995f50d3a3e43247ea23eca978d6574" "checksum grpcio-compiler 0.5.0-alpha.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dd8b3213a332a2865a307e553f43d632bc4a81f0e0f5a90d194dee5b9c02d8a7" -"checksum grpcio-sys 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "9d8d3b6d1a70b9dcb2545d1aff5b2c74652cb635f6ab6426be8fd201e9566b7e" +"checksum grpcio-sys 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f6a31d8b4769d18e20de167e3c0ccae6b7dd506dfff78d323c2166e76efbe408" "checksum h2 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)" = "a5b34c246847f938a410a03c5458c7fee2274436675e76d8b903c08efc29c462" "checksum hashbrown 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "29fba9abe4742d586dfd0c06ae4f7e73a1c2d86b856933509b269d82cdf06e18" "checksum hashbrown 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e1de41fb8dba9714efd92241565cdff73f78508c95697dd56787d3cba27e2353" @@ -2865,7 +2883,7 @@ dependencies = [ "checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08" "checksum ipconfig 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "aa79fa216fbe60834a9c0737d7fcd30425b32d1c58854663e24d4c4b328ed83f" "checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" -"checksum js-sys 0.3.27 (registry+https://github.com/rust-lang/crates.io-index)" = "1efc4f2a556c58e79c5500912e221dd826bec64ff4aabd8ce71ccef6da02d7d4" +"checksum js-sys 0.3.28 (registry+https://github.com/rust-lang/crates.io-index)" = "2cc9a97d7cec30128fd8b28a7c1f9df1c001ceb9b441e2b755e24130a6b43c79" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a91d884b6667cd606bb5a69aa0c99ba811a115fc68915e7056ec08a46e93199a" "checksum lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "76f033c7ad61445c5b347c7382dd1237847eb1bce590fe50365dcb33d546be73" @@ -2920,7 +2938,7 @@ dependencies = [ "checksum protobuf 2.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "40361836defdd5871ff7e84096c6f6444af7fc157f8ef1789f54f147687caa20" "checksum protobuf-codegen 2.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "12c6abd78435445fc86898ebbd0521a68438063d4a73e23527b7134e6bf58b4a" "checksum protoc 2.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3998c4bc0af8ccbd3cc68245ee9f72663c5ae2fb78bc48ff7719aef11562edea" -"checksum protoc-grpcio 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "da4389258ed4b768438edec1e1e813cc7fa29e70c1b1cb4eb2f8fc341dc562dd" +"checksum protoc-grpcio 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e7bb9b76be44d96453f528030c03713f57fa725565036cc9d72037ad75babadf" "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" "checksum quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" "checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" @@ -3029,16 +3047,16 @@ dependencies = [ "checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" "checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" "checksum wasi 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b89c3ce4ce14bdc6fb6beaf9ec7928ca331de5df7e5ea278375642a2f478570d" -"checksum wasm-bindgen 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)" = "dcddca308b16cd93c2b67b126c688e5467e4ef2e28200dc7dfe4ae284f2faefc" -"checksum wasm-bindgen-backend 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)" = "f805d9328b5fc7e5c6399960fd1889271b9b58ae17bdb2417472156cc9fafdd0" +"checksum wasm-bindgen 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)" = "cd34c5ba0d228317ce388e87724633c57edca3e7531feb4e25e35aaa07a656af" +"checksum wasm-bindgen-backend 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)" = "927196b315c23eed2748442ba675a4c54a1a079d90d9bdc5ad16ce31cf90b15b" "checksum wasm-bindgen-futures 0.3.27 (registry+https://github.com/rust-lang/crates.io-index)" = "83420b37346c311b9ed822af41ec2e82839bfe99867ec6c54e2da43b7538771c" -"checksum wasm-bindgen-macro 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)" = "3ff88201a482abfc63921621f6cb18eb1efd74f136b05e5841e7f8ca434539e9" -"checksum wasm-bindgen-macro-support 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)" = "6a433d89ecdb9f77d46fcf00c8cf9f3467b7de9954d8710c175f61e2e245bb0e" -"checksum wasm-bindgen-shared 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)" = "d41fc1bc3570cdf8d108c15e014045fd45a95bb5eb36605f96a90461fc34027d" +"checksum wasm-bindgen-macro 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)" = "92c2442bf04d89792816650820c3fb407af8da987a9f10028d5317f5b04c2b4a" +"checksum wasm-bindgen-macro-support 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)" = "9c075d27b7991c68ca0f77fe628c3513e64f8c477d422b859e03f28751b46fc5" +"checksum wasm-bindgen-shared 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)" = "83d61fe986a7af038dd8b5ec660e5849cbd9f38e7492b9404cc48b2b4df731d1" "checksum wasm-bindgen-test 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)" = "a2d9693b63a742d481c7f80587e057920e568317b2806988c59cd71618bc26c1" "checksum wasm-bindgen-test-macro 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)" = "0789dac148a8840bbcf9efe13905463b733fa96543bfbf263790535c11af7ba5" -"checksum wasm-bindgen-webidl 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)" = "be53d289bf2fa7645a089cfd5c7a34bf4fe94221f58cf86ee42a7b4bc854ff14" -"checksum web-sys 0.3.27 (registry+https://github.com/rust-lang/crates.io-index)" = "6435c477200ad486089a7a72c2bd6c9bdf9740bd7fff868806076218076d8c51" +"checksum wasm-bindgen-webidl 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)" = "9b979afb0535fe4749906a674082db1211de8aef466331d43232f63accb7c07c" +"checksum web-sys 0.3.28 (registry+https://github.com/rust-lang/crates.io-index)" = "c84440699cd02ca23bed6f045ffb1497bc18a3c2628bd13e2093186faaaacf6b" "checksum wee_alloc 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "dbb3b5a6b2bb17cb6ad44a2e68a43e8d2722c997da10e928665c72ec6c0a0b8e" "checksum weedle 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3bb43f70885151e629e2a19ce9e50bd730fd436cfd4b666894c9ce4de9141164" "checksum widestring 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "effc0e4ff8085673ea7b9b2e3c73f6bd4d118810c9009ed8f1e16bd96c331db6" diff --git a/tests/e2e/grpc_control_api/signaling.rs b/tests/e2e/grpc_control_api/signaling.rs index a767806e2..6f3ca6bbb 100644 --- a/tests/e2e/grpc_control_api/signaling.rs +++ b/tests/e2e/grpc_control_api/signaling.rs @@ -226,7 +226,7 @@ fn delete_member_check_peers_removed() { } } Event::PeersRemoved { .. } => { - ctx.run_later(Duration::from_secs(1), |_, _| { + ctx.run_later(Duration::from_secs(3), |_, _| { actix::System::current().stop(); }); } From 6f1957a5e9a1294ae5b576fc1fb3ae04edbc94c4 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 30 Sep 2019 12:37:35 +0300 Subject: [PATCH 680/735] Better fix for signaling e2e [run ci] --- src/signalling/room.rs | 55 +++++++++++++------------ tests/e2e/grpc_control_api/signaling.rs | 6 +-- tests/e2e/signalling/mod.rs | 6 +-- 3 files changed, 34 insertions(+), 33 deletions(-) diff --git a/src/signalling/room.rs b/src/signalling/room.rs index d35a2bd21..833eed173 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -482,30 +482,31 @@ impl Room { first_peer: PeerId, second_peer: PeerId, ) { - let fut: ActFuture<(), ()> = match self - .send_peer_created(first_peer, second_peer) - { - Ok(res) => { - Box::new(res.then(|res, room, ctx| -> ActFuture<(), ()> { - if res.is_ok() { - return Box::new(future::ok(()).into_actor(room)); - } + let fut: ActFuture<(), ()> = + match self.send_peer_created(first_peer, second_peer) { + Ok(res) => { + Box::new(res.then(|res, room, ctx| -> ActFuture<(), ()> { + if res.is_ok() { + return Box::new(future::ok(()).into_actor(room)); + } + error!( + "Failed connect peers, because {}. Room [id = {}] \ + will be stopped.", + res.unwrap_err(), + room.id, + ); + room.close_gracefully(ctx) + })) + } + Err(err) => { error!( - "Failed handle command, because {}. Room will be \ - stopped.", - res.unwrap_err(), + "Failed connect peers, because {}. Room [id = {}] \ + will be stopped.", + err, self.id, ); - room.close_gracefully(ctx) - })) - } - Err(err) => { - error!( - "Failed handle command, because {}. Room will be stopped.", - err - ); - self.close_gracefully(ctx) - } - }; + self.close_gracefully(ctx) + } + }; ctx.spawn(fut); } @@ -985,17 +986,19 @@ impl Handler for Room { return Box::new(future::ok(()).into_actor(room)); } error!( - "Failed handle command, because {}. Room will be \ - stopped.", + "Failed handle command, because {}. Room [id = {}] \ + will be stopped.", res.unwrap_err(), + room.id, ); room.close_gracefully(ctx) })) } Err(err) => { error!( - "Failed handle command, because {}. Room will be stopped.", - err + "Failed handle command, because {}. Room [id = {}] will \ + be stopped.", + err, self.id, ); self.close_gracefully(ctx) } diff --git a/tests/e2e/grpc_control_api/signaling.rs b/tests/e2e/grpc_control_api/signaling.rs index 6f3ca6bbb..3e4e10f9f 100644 --- a/tests/e2e/grpc_control_api/signaling.rs +++ b/tests/e2e/grpc_control_api/signaling.rs @@ -216,7 +216,7 @@ fn delete_member_check_peers_removed() { let peers_created = Rc::new(Cell::new(0)); let on_event = - move |event: &Event, ctx: &mut Context, _: Vec<&Event>| { + move |event: &Event, _: &mut Context, _: Vec<&Event>| { match event { Event::PeerCreated { .. } => { peers_created.set(peers_created.get() + 1); @@ -226,9 +226,7 @@ fn delete_member_check_peers_removed() { } } Event::PeersRemoved { .. } => { - ctx.run_later(Duration::from_secs(3), |_, _| { - actix::System::current().stop(); - }); + actix::System::current().stop(); } _ => {} } diff --git a/tests/e2e/signalling/mod.rs b/tests/e2e/signalling/mod.rs index 0b4995526..752146ee5 100644 --- a/tests/e2e/signalling/mod.rs +++ b/tests/e2e/signalling/mod.rs @@ -147,10 +147,7 @@ impl StreamHandler for TestMember { let txt = String::from_utf8(txt.unwrap().to_vec()).unwrap(); let event: Result = serde_json::from_str(&txt); if let Ok(event) = event { - let mut events: Vec<&Event> = self.events.iter().collect(); - events.push(&event); // Test function call - (self.on_message)(&event, ctx, events); if let Event::PeerCreated { peer_id, @@ -185,6 +182,9 @@ impl StreamHandler for TestMember { }, }); } + let mut events: Vec<&Event> = self.events.iter().collect(); + events.push(&event); + (self.on_message)(&event, ctx, events); self.events.push(event); } } From cbdda9d994cb882a8f0d3e5eb0a296b882056b16 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 30 Sep 2019 18:52:40 +0300 Subject: [PATCH 681/735] Try geckodriver on CI [run ci] --- Makefile | 35 +++++++++++++++++++++++++++-------- _build/geckodriver/Dockerfile | 23 +++++++++++++++++++++++ jason/webdriver.json | 20 ++++++++++++++++++++ 3 files changed, 70 insertions(+), 8 deletions(-) create mode 100644 _build/geckodriver/Dockerfile create mode 100644 jason/webdriver.json diff --git a/Makefile b/Makefile index 9536239e6..e884a0760 100644 --- a/Makefile +++ b/Makefile @@ -294,12 +294,10 @@ endif # Run Rust unit tests of project. # # Usage: -# make test.unit [crate=(@all|medea|jason|)] - -CHROMEDRIVER_CLIENT_ARGS := $(strip \ - $(shell grep 'CHROMEDRIVER_CLIENT_ARGS=' .env | cut -d '=' -f2)) +# make test.unit [crate=(@all|medea|jason|)] webdriver=(chromedriver|geckodriver) test-unit-crate = $(if $(call eq,$(crate),),@all,$(crate)) +webdriver-env = $(if $(call eq,$(webdriver),geckodriver),GECKODRIVER_REMOTE,CHROMEDRIVER_REMOTE) test.unit: ifeq ($(test-unit-crate),@all) @@ -312,12 +310,12 @@ ifeq ($(test-unit-crate),medea) cargo test --lib --bin medea else ifeq ($(crate),medea-jason) + @make docker.up.webdriver + sleep 10 cd $(crate-dir)/ && \ - CHROMEDRIVER_CLIENT_ARGS="$(CHROMEDRIVER_CLIENT_ARGS)" \ + $(webdriver-env)="http://127.0.0.1:4444" \ cargo test --target wasm32-unknown-unknown --features mockable -else - cd $(crate-dir)/ && \ - cargo test -p $(test-unit-crate) + @make docker.down.webdriver endif endif endif @@ -524,6 +522,16 @@ else endif +docker.down.webdriver: +ifeq ($(webdriver),geckodriver) + docker container kill $$(cat /tmp/geckodriver.docker.uid) + rm -f /tmp/geckodriver.docker.uid +else + docker container kill $$(cat /tmp/chromedriver.docker.uid) + rm -f /tmp/chromedriver.docker.uid +endif + + # Pull project Docker images from Container Registry. # # Usage: @@ -623,6 +631,15 @@ else endif +docker.up.webdriver: +ifeq ($(webdriver),geckodriver) + docker build -t instrumentisto/medea-geckodriver:dev -f _build/geckodriver/Dockerfile . + docker run --rm -d --network=host instrumentisto/medea-geckodriver:dev > /tmp/geckodriver.docker.uid +else + docker run --rm -d --network=host selenoid/chrome:latest > /tmp/chromedriver.docker.uid +endif + + ############################## @@ -824,8 +841,10 @@ protoc.rebuild: cargo cargo.build cargo.fmt cargo.lint \ docker.auth docker.build.demo docker.build.medea \ docker.down.coturn docker.down.demo docker.down.medea \ + docker.down.webdriver \ docker.pull docker.push \ docker.up.coturn docker.up.demo docker.up.medea \ + docker.up.webdriver \ docs docs.rust \ down down.coturn down.demo down.dev down.medea \ helm helm.down helm.init helm.lint helm.list \ diff --git a/_build/geckodriver/Dockerfile b/_build/geckodriver/Dockerfile new file mode 100644 index 000000000..21552669a --- /dev/null +++ b/_build/geckodriver/Dockerfile @@ -0,0 +1,23 @@ +FROM debian:stretch-slim + +ARG firefox_ver=latest +ARG geckodriver_ver=v0.24.0 + +RUN apt-get update && apt-get install -y wget tar bzip2 + +# Install dependencies for firefox binary +RUN apt-get install -y `apt-cache depends firefox-esr | awk '/Depends:/{print$2}'` +# Install firefox +RUN wget -O FirefoxSetup.tar.bz2 "https://download.mozilla.org/?product=firefox-${firefox_ver}&os=linux64&lang=en-US" +RUN tar xjf FirefoxSetup.tar.bz2 +RUN mv firefox /opt/firefox + +# Install geckodriver +RUN wget https://github.com/mozilla/geckodriver/releases/download/${geckodriver_ver}/geckodriver-${geckodriver_ver}-linux64.tar.gz +RUN tar -xvzf geckodriver* +RUN chmod +x geckodriver +RUN mv geckodriver /usr/bin + +EXPOSE 4444 + +ENTRYPOINT ["geckodriver", "-b", "/opt/firefox/firefox", "--log", "debug"] diff --git a/jason/webdriver.json b/jason/webdriver.json new file mode 100644 index 000000000..bb697d2b2 --- /dev/null +++ b/jason/webdriver.json @@ -0,0 +1,20 @@ +{ + "moz:firefoxOptions": { + "prefs": { + "security.fileuri.strict_origin_policy": false, + "security.certerrors.mitm.priming.enabled": false, + "media.navigator.permission.disabled": true, + "media.autoplay.enabled": true, + "media.autoplay.enabled.user-gestures-needed ": false, + "media.autoplay.ask-permission": false, + "media.autoplay.default": 0, + "media.navigator.streams.fake": true + } + }, + "goog:chromeOptions": { + "args": [ + "--use-fake-device-for-media-stream", + "--use-fake-ui-for-media-stream" + ] + } +} \ No newline at end of file From dc1578944212fb4e25d8808dde288f68cc1d13c2 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 30 Sep 2019 18:54:15 +0300 Subject: [PATCH 682/735] Run on geckodriver [run ci] --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index df6255778..553afd729 100644 --- a/.travis.yml +++ b/.travis.yml @@ -106,7 +106,7 @@ jobs: before_script: - cargo +nightly install wasm-bindgen-cli -Z install-upgrade - rustup target add wasm32-unknown-unknown - script: make test.unit crate=medea-jason + script: make test.unit crate=medea-jason webdriver=geckodriver - name: E2E signalling (stable) stage: test From ffd142fc76b7831a59b197ad1f3d0c7fa96b3eb1 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Mon, 30 Sep 2019 19:20:36 +0300 Subject: [PATCH 683/735] At least chromedriver? [run ci] --- Cargo.lock | 3073 ---------------------------------------------- jason/Cargo.toml | 4 +- 2 files changed, 2 insertions(+), 3075 deletions(-) delete mode 100644 Cargo.lock diff --git a/Cargo.lock b/Cargo.lock deleted file mode 100644 index a638eb536..000000000 --- a/Cargo.lock +++ /dev/null @@ -1,3073 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -[[package]] -name = "Inflector" -version = "0.11.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "actix" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "actix-http 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-rt 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", - "actix_derive 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "bitflags 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-channel 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "hashbrown 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "trust-dns-resolver 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "actix-codec" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "actix-connect" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-rt 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-service 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-utils 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", - "either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "http 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-current-thread 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "trust-dns-resolver 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "actix-http" -version = "0.2.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-connect 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-server-config 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-service 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-threadpool 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-utils 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", - "bitflags 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "brotli2 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", - "copyless 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", - "either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "encoding_rs 0.8.20 (registry+https://github.com/rust-lang/crates.io-index)", - "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "flate2 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "h2 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", - "hashbrown 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "http 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", - "httparse 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "indexmap 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "mime 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", - "percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_urlencoded 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-current-thread 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "trust-dns-resolver 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "actix-http-test" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-connect 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-rt 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-server 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-service 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-utils 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "awc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", - "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "http 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_urlencoded 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "actix-router" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "http 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", - "string 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "actix-rt" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "actix-threadpool 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "copyless 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-current-thread 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "actix-server" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "actix-rt 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-server-config 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-service 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", - "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", - "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-signal 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "actix-server-config" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "actix-service" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "actix-testing" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "actix-rt 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-server 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-server-config 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-service 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "actix-threadpool" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "threadpool 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "actix-utils" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-service 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-current-thread 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "actix-web" -version = "1.0.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-http 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-router 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-rt 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-server 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-server-config 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-service 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-testing 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-threadpool 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-utils 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-web-codegen 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "awc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", - "encoding_rs 0.8.20 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "hashbrown 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "mime 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", - "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_urlencoded 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", - "url 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "actix-web-actors" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "actix 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-http 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-web 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "actix-web-codegen" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "actix_derive" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "adler32" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "aho-corasick" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "arc-swap" -version = "0.3.11" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "arc-swap" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "arrayref" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "arrayvec" -version = "0.4.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "ascii" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "atty" -version = "0.2.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "autocfg" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "awc" -version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-http 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-service 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", - "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "mime 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", - "percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_urlencoded 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "backtrace" -version = "0.3.38" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "backtrace-sys 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "backtrace-sys" -version = "0.1.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cc 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "base64" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "bb8" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "bb8-redis" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bb8 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "redis 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "bitflags" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "blake2b_simd" -version = "0.5.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", - "arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", - "constant_time_eq 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "brotli-sys" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cc 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "brotli2" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "brotli-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "bumpalo" -version = "2.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "byteorder" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "bytes" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "c2-chacha" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ppv-lite86 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "cc" -version = "1.0.45" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "cfg-if" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "chrono" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", - "num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "cloudabi" -version = "0.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bitflags 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "cmake" -version = "0.1.42" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cc 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "combine" -version = "3.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "ascii 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", - "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "config" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "nom 4.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "rust-ini 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", - "serde-hjson 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", - "toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", - "yaml-rust 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "console_error_panic_hook" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "constant_time_eq" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "copyless" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "crc32fast" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "crossbeam" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-channel 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-deque 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-epoch 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "crossbeam-channel" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "crossbeam-deque" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "crossbeam-epoch 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "crossbeam-epoch" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "memoffset 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "crossbeam-queue" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "crossbeam-utils" -version = "0.6.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "derive-new" -version = "0.5.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "derive_more" -version = "0.14.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "derive_more" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "difference" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "dirs" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_users 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "dotenv" -version = "0.14.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "downcast" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "dtoa" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "either" -version = "1.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "encoding_rs" -version = "0.8.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "enum-as-inner" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "env_logger" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", - "humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "failure" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "backtrace 0.3.38 (registry+https://github.com/rust-lang/crates.io-index)", - "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "failure_derive" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)", - "synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "flate2" -version = "1.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", - "miniz-sys 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "miniz_oxide 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "float-cmp" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "fnv" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "fragile" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "fuchsia-cprng" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "fuchsia-zircon" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bitflags 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "fuchsia-zircon-sys" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "futures" -version = "0.1.29" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "gcc" -version = "0.3.55" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "getrandom" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", - "wasi 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "grpcio" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "grpcio-sys 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "protobuf 2.8.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "grpcio-compiler" -version = "0.5.0-alpha.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "derive-new 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", - "protobuf 2.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "protobuf-codegen 2.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "grpcio-sys" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cc 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)", - "cmake 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "h2" -version = "0.1.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "http 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", - "indexmap 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "string 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "hashbrown" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "hashbrown" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "heck" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "unicode-segmentation 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "hostname" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", - "winutil 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "http" -version = "0.1.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "httparse" -version = "1.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "humantime" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "humantime-serde" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "idna" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-normalization 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "idna" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-normalization 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "indexmap" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "iovec" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "ipconfig" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "socket2 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)", - "widestring 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "winreg 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "itoa" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "js-sys" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "wasm-bindgen 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "kernel32-sys" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "language-tags" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "lazy_static" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "libc" -version = "0.2.62" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "linked-hash-map" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "serde 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_test 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "linked-hash-map" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "lock_api" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "owning_ref 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "lock_api" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "lock_api" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "log" -version = "0.4.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "lru-cache" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "macro-attr" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "matches" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "medea" -version = "0.2.0-dev" -dependencies = [ - "actix 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-http 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-http-test 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-web 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-web-actors 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "awc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "bb8 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "bb8-redis 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", - "config 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", - "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", - "dotenv 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", - "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "grpcio 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "humantime-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "medea-client-api-proto 0.1.1-dev", - "medea-control-api-proto 0.1.0-dev", - "medea-macro 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "protobuf 2.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "redis 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_yaml 0.8.9 (registry+https://github.com/rust-lang/crates.io-index)", - "serial_test 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serial_test_derive 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "slog-async 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "slog-envlogger 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "slog-json 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "slog-scope 4.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "slog-stdlog 4.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "smart-default 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-signal 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "toml 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "url 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "medea-client-api-proto" -version = "0.1.1-dev" -dependencies = [ - "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", - "medea-macro 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "medea-control-api-proto" -version = "0.1.0-dev" -dependencies = [ - "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "grpcio 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "protobuf 2.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "protoc-grpcio 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "medea-jason" -version = "0.2.0-dev" -dependencies = [ - "console_error_panic_hook 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "downcast 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", - "fragile 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "js-sys 0.3.28 (registry+https://github.com/rust-lang/crates.io-index)", - "macro-attr 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "medea-client-api-proto 0.1.1-dev", - "medea-macro 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "mockall 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "newtype_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "predicates-tree 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-futures 0.3.27 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-test 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", - "web-sys 0.3.28 (registry+https://github.com/rust-lang/crates.io-index)", - "wee_alloc 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "medea-macro" -version = "0.1.0" -dependencies = [ - "Inflector 0.11.4 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "medea-macro" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "Inflector 0.11.4 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "memchr" -version = "2.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "memoffset" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "memory_units" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "mime" -version = "0.3.14" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "miniz-sys" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cc 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "miniz_oxide" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "adler32 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "mio" -version = "0.6.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", - "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "mio-uds" -version = "0.6.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "miow" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "mockall" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "downcast 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", - "fragile 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "mockall_derive 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "predicates 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "predicates-tree 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "mockall_derive" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "net2" -version = "0.2.33" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "newtype_derive" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "nodrop" -version = "0.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "nom" -version = "4.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "normalize-line-endings" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "num-integer" -version = "0.1.41" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "num-traits" -version = "0.1.43" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "num-traits" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "num_cpus" -version = "1.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "owning_ref" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "parking_lot" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "lock_api 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "parking_lot" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "lock_api 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "parking_lot" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "lock_api 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot_core 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "parking_lot_core" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "parking_lot_core" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "parking_lot_core" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "percent-encoding" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "percent-encoding" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "pkg-config" -version = "0.3.16" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "ppv-lite86" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "predicates" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "float-cmp 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "normalize-line-endings 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "predicates-core 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "predicates-core" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "predicates-tree" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "predicates-core 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "treeline 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "proc-macro2" -version = "0.4.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "proc-macro2" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "protobuf" -version = "2.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "protobuf-codegen" -version = "2.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "protobuf 2.8.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "protoc" -version = "2.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "protoc-grpcio" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "grpcio-compiler 0.5.0-alpha.2 (registry+https://github.com/rust-lang/crates.io-index)", - "protobuf 2.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "protobuf-codegen 2.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "protoc 2.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "quick-error" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "quote" -version = "0.6.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "quote" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand" -version = "0.3.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_jitter 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "getrandom 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand_chacha" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand_chacha" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "c2-chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand_core" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand_core" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "rand_core" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "getrandom 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand_hc" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand_hc" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand_isaac" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand_jitter" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand_os" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand_pcg" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand_xorshift" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rdrand" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "redis" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "combine 3.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "dtoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-sync 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-uds 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", - "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "redox_syscall" -version = "0.1.56" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "redox_users" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", - "rust-argon2 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "regex" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "regex-syntax" -version = "0.6.12" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "remove_dir_all" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "resolv-conf" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "hostname 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rust-argon2" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", - "blake2b_simd 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rust-crypto" -version = "0.2.36" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.3.23 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", - "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rust-ini" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "rustc-demangle" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "rustc-serialize" -version = "0.3.24" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "rustc_version" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "semver 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rustc_version" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "ryu" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "scoped-tls" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "scopeguard" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "scopeguard" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "semver" -version = "0.1.20" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "semver" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "semver-parser" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "serde" -version = "0.8.23" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "serde" -version = "1.0.101" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "serde_derive 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "serde-hjson" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "linked-hash-map 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "serde_derive" -version = "1.0.101" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "serde_json" -version = "1.0.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "serde_test" -version = "0.8.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "serde 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "serde_urlencoded" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "dtoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", - "url 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "serde_yaml" -version = "0.8.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "dtoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", - "yaml-rust 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "serial_test" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "serial_test_derive" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "sha1" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "signal-hook" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", - "signal-hook-registry 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "signal-hook-registry" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "arc-swap 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "slab" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "slog" -version = "2.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "slog-async" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "take_mut 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "slog-envlogger" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "slog-async 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "slog-scope 4.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "slog-stdlog 4.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "slog-term 2.4.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "slog-json" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", - "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "slog-scope" -version = "4.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "arc-swap 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "slog-stdlog" -version = "4.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "crossbeam 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "slog-scope 4.1.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "slog-term" -version = "2.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", - "chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", - "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "term 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "smallvec" -version = "0.6.10" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "smart-default" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "socket2" -version = "0.3.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "sourcefile" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "stable_deref_trait" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "string" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "syn" -version = "0.15.44" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "syn" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "synstructure" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "take_mut" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "tempfile" -version = "3.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", - "remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "term" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "dirs 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "termcolor" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "wincolor 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "thread_local" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "threadpool" -version = "1.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "time" -version = "0.1.42" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "tokio" -version = "0.1.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-current-thread 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-fs 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-sync 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-threadpool 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-udp 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-uds 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "tokio-codec" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "tokio-current-thread" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "tokio-executor" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "tokio-fs" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-threadpool 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "tokio-io" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "tokio-reactor" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-sync 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "tokio-signal" -version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", - "mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", - "signal-hook 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "tokio-sync" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "tokio-tcp" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "tokio-threadpool" -version = "0.1.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "crossbeam-deque 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "tokio-timer" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "tokio-udp" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "tokio-uds" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", - "mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "toml" -version = "0.4.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "toml" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "treeline" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "trust-dns-proto" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "enum-as-inner 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", - "socket2 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-udp 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "trust-dns-resolver" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "ipconfig 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "lru-cache 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "resolv-conf 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "trust-dns-proto 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "unicode-bidi" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "unicode-normalization" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "unicode-segmentation" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "unicode-xid" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "unicode-xid" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "unreachable" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "url" -version = "1.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "url" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "idna 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "version_check" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "void" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "wasi" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "wasm-bindgen" -version = "0.2.51" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-macro 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.51" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bumpalo 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-shared 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "wasm-bindgen-futures" -version = "0.3.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "js-sys 0.3.28 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", - "web-sys 0.3.28 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.51" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-macro-support 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.51" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-backend 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-shared 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.51" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "wasm-bindgen-test" -version = "0.2.50" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "console_error_panic_hook 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "js-sys 0.3.28 (registry+https://github.com/rust-lang/crates.io-index)", - "scoped-tls 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-futures 0.3.27 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-test-macro 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "wasm-bindgen-test-macro" -version = "0.2.50" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "wasm-bindgen-webidl" -version = "0.2.51" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-backend 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", - "weedle 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "web-sys" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "js-sys 0.3.28 (registry+https://github.com/rust-lang/crates.io-index)", - "sourcefile 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-webidl 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "wee_alloc" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", - "memory_units 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "weedle" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "nom 4.2.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "widestring" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "winapi" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "winapi" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "winapi-build" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "winapi-util" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "wincolor" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "winreg" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "winutil" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "ws2_32-sys" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "yaml-rust" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[metadata] -"checksum Inflector 0.11.4 (registry+https://github.com/rust-lang/crates.io-index)" = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" -"checksum actix 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)" = "671ce3d27313f236827a5dd153a1073ad03ef31fc77f562020263e7830cf1ef7" -"checksum actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9f2c11af4b06dc935d8e1b1491dad56bfb32febc49096a91e773f8535c176453" -"checksum actix-connect 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "9fade9bd4bb46bacde89f1e726c7a3dd230536092712f5d94d77ca57c087fca0" -"checksum actix-http 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "cdf758ebbc4abfecbdc1ce7408601b2d7e0cd7e4766ef61183cd8ce16c194d64" -"checksum actix-http-test 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "4c29c11568a1fd24163f7757aea88737082c1b8317f550262f9a1f47e9832f54" -"checksum actix-router 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "23224bb527e204261d0291102cb9b52713084def67d94f7874923baefe04ccf7" -"checksum actix-rt 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "168620aaf00fcd2a16e621790abaf180ef7377c2f8355b4ca5775d6afc778ed8" -"checksum actix-server 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dd626534af8d0a738e5f74901fe603af0445708f91b86a7d763d80df10d562a5" -"checksum actix-server-config 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "483a34989c682d93142bacad6300375bb6ad8002d2e0bb249dbad86128b9ff30" -"checksum actix-service 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bca5b48e928841ff7e7dce1fdb5b0d4582f6b1b976e08f4bac3f640643e0773f" -"checksum actix-testing 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "af001e97ac6750994824d400a1b7087055aab14317aa012f528d0b2b363f37f1" -"checksum actix-threadpool 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6b5ae85d13da7e6fb86b1b7bc83185e0e3bd4cc5f421c887e1803796c034d35d" -"checksum actix-utils 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6ea501068a0173533704be321f149853f702d9e3c3ce9d57e7a96d94b1ab5aca" -"checksum actix-web 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "36e59485f007a4be3df228791ff6c4aedcbe7bb09bd9225c3554f538aca4a584" -"checksum actix-web-actors 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "008c1b686048a16fef4ef2fc6b6e5fcf5f29829891ad87fc0848ade26b285627" -"checksum actix-web-codegen 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3fe9e3cdec1e645b675f354766e0688c5705021c85ab3cf739be1c8999b91c76" -"checksum actix_derive 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0bf5f6d7bf2d220ae8b4a7ae02a572bb35b7c4806b24049af905ab8110de156c" -"checksum adler32 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5d2e7343e7fc9de883d1b0341e0b13970f764c14101234857d2ddafa1cb1cac2" -"checksum aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "58fb5e95d83b38284460a5fda7d6470aa0b8844d283a0b614b8535e880800d2d" -"checksum arc-swap 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)" = "bc4662175ead9cd84451d5c35070517777949a2ed84551764129cedb88384841" -"checksum arc-swap 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "f1a1eca3195b729bbd64e292ef2f5fff6b1c28504fed762ce2b1013dde4d8e92" -"checksum arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0d382e583f07208808f6b1249e60848879ba3543f57c32277bf52d69c2f0f0ee" -"checksum arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)" = "b8d73f9beda665eaa98ab9e4f7442bd4e7de6652587de55b2525e52e29c1b0ba" -"checksum ascii 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "eab1c04a571841102f5345a8fc0f6bb3d31c315dec879b5c6e42e40ce7ffa34e" -"checksum atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1803c647a3ec87095e7ae7acfca019e98de5ec9a7d01343f611cf3152ed71a90" -"checksum autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "b671c8fb71b457dd4ae18c4ba1e59aa81793daacc361d82fcd410cef0d491875" -"checksum awc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "364537de6ac9f996780f9dd097d6c4ca7c91dd5735153e9fb545037479becd10" -"checksum backtrace 0.3.38 (registry+https://github.com/rust-lang/crates.io-index)" = "690a62be8920ccf773ee00ef0968649b0e724cda8bd5b12286302b4ae955fdf5" -"checksum backtrace-sys 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)" = "82a830b4ef2d1124a711c71d263c5abdc710ef8e907bd508c88be475cebc422b" -"checksum base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" -"checksum bb8 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0ac73ee3406f475415bba792942016291b87bac08839c38a032de56085a73b2c" -"checksum bb8-redis 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "39945a33c03edfba8c353d330b921961e2137d4fc4215331c1b2397f32acff80" -"checksum bitflags 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8a606a02debe2813760609f57a64a2ffd27d9fdf5b2f133eaca0b248dd92cdd2" -"checksum blake2b_simd 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)" = "5850aeee1552f495dd0250014cf64b82b7c8879a89d83b33bbdace2cc4f63182" -"checksum brotli-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4445dea95f4c2b41cde57cc9fee236ae4dbae88d8fcbdb4750fc1bb5d86aaecd" -"checksum brotli2 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0cb036c3eade309815c15ddbacec5b22c4d1f3983a774ab2eac2e3e9ea85568e" -"checksum bumpalo 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ad807f2fc2bf185eeb98ff3a901bd46dc5ad58163d0fa4577ba0d25674d71708" -"checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" -"checksum bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" -"checksum c2-chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7d64d04786e0f528460fc884753cf8dddcc466be308f6026f8e355c41a0e4101" -"checksum cc 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)" = "4fc9a35e1f4290eb9e5fc54ba6cf40671ed2a2514c3eeb2b2a908dda2ea5a1be" -"checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" -"checksum chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e8493056968583b0193c1bb04d6f7684586f3726992d6c573261941a895dbd68" -"checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" -"checksum cmake 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "81fb25b677f8bf1eb325017cb6bb8452f87969db0fedb4f757b297bee78a7c62" -"checksum combine 3.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "da3da6baa321ec19e1cc41d31bf599f00c783d0517095cdaf0332e3fe8d20680" -"checksum config 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "f9107d78ed62b3fa5a86e7d18e647abed48cfd8f8fab6c72f4cdb982d196f7e6" -"checksum console_error_panic_hook 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "b8d976903543e0c48546a91908f21588a680a8c8f984df9a5d69feccb2b2a211" -"checksum constant_time_eq 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "995a44c877f9212528ccc74b21a232f66ad69001e40ede5bcee2ac9ef2657120" -"checksum copyless 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "6ff9c56c9fb2a49c05ef0e431485a22400af20d33226dc0764d891d09e724127" -"checksum crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" -"checksum crossbeam 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2d818a4990769aac0c7ff1360e233ef3a41adcb009ebb2036bf6915eb0f6b23c" -"checksum crossbeam-channel 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "c8ec7fcd21571dc78f96cc96243cab8d8f035247c3efd16c687be154c3fa9efa" -"checksum crossbeam-deque 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b18cd2e169ad86297e6bc0ad9aa679aee9daa4f19e8163860faf7c164e4f5a71" -"checksum crossbeam-epoch 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "fedcd6772e37f3da2a9af9bf12ebe046c0dfe657992377b4df982a2b54cd37a9" -"checksum crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7c979cd6cfe72335896575c6b5688da489e420d36a27a0b9eb0c73db574b4a4b" -"checksum crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "04973fa96e96579258a5091af6003abde64af786b860f18622b82e026cca60e6" -"checksum derive-new 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)" = "71f31892cd5c62e414316f2963c5689242c43d8e7bbcaaeca97e5e28c95d91d9" -"checksum derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6d944ac6003ed268757ef1ee686753b57efc5fcf0ebe7b64c9fc81e7e32ff839" -"checksum derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a141330240c921ec6d074a3e188a7c7ef95668bb95e7d44fa0e5778ec2a7afe" -"checksum difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198" -"checksum dirs 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3fd78930633bd1c6e35c4b42b1df7b0cbc6bc191146e512bb3bedf243fcc3901" -"checksum dotenv 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4424bad868b0ffe6ae351ee463526ba625bbca817978293bbe6bb7dc1804a175" -"checksum downcast 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4bb454f0228b18c7f4c3b0ebbee346ed9c52e7443b0999cd543ff3571205701d" -"checksum dtoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "ea57b42383d091c85abcc2706240b94ab2a8fa1fc81c10ff23c4de06e2a90b5e" -"checksum either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3" -"checksum encoding_rs 0.8.20 (registry+https://github.com/rust-lang/crates.io-index)" = "87240518927716f79692c2ed85bfe6e98196d18c6401ec75355760233a7e12e9" -"checksum enum-as-inner 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3d58266c97445680766be408285e798d3401c6d4c378ec5552e78737e681e37d" -"checksum env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "aafcde04e90a5226a6443b7aabdb016ba2f8307c847d524724bd9b346dd1a2d3" -"checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" -"checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" -"checksum flate2 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)" = "2adaffba6388640136149e18ed080b77a78611c1e1d6de75aedcdf78df5d4682" -"checksum float-cmp 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "134a8fa843d80a51a5b77d36d42bc2def9edcb0262c914861d08129fd1926600" -"checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" -"checksum fragile 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "05f8140122fa0d5dcb9fc8627cfce2b37cc1500f752636d46ea28bc26785c2f9" -"checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" -"checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" -"checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" -"checksum futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)" = "1b980f2816d6ee8673b6517b52cb0e808a180efc92e5c19d02cdda79066703ef" -"checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" -"checksum getrandom 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "473a1265acc8ff1e808cd0a1af8cee3c2ee5200916058a2ca113c29f2d903571" -"checksum grpcio 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "cf45c98940795d83354880f073f3a2a2a995f50d3a3e43247ea23eca978d6574" -"checksum grpcio-compiler 0.5.0-alpha.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dd8b3213a332a2865a307e553f43d632bc4a81f0e0f5a90d194dee5b9c02d8a7" -"checksum grpcio-sys 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f6a31d8b4769d18e20de167e3c0ccae6b7dd506dfff78d323c2166e76efbe408" -"checksum h2 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)" = "a5b34c246847f938a410a03c5458c7fee2274436675e76d8b903c08efc29c462" -"checksum hashbrown 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "29fba9abe4742d586dfd0c06ae4f7e73a1c2d86b856933509b269d82cdf06e18" -"checksum hashbrown 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e1de41fb8dba9714efd92241565cdff73f78508c95697dd56787d3cba27e2353" -"checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" -"checksum hostname 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "21ceb46a83a85e824ef93669c8b390009623863b5c195d1ba747292c0c72f94e" -"checksum http 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)" = "372bcb56f939e449117fb0869c2e8fd8753a8223d92a172c6e808cf123a5b6e4" -"checksum httparse 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "cd179ae861f0c2e53da70d892f5f3029f9594be0c41dc5269cd371691b1dc2f9" -"checksum humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" -"checksum humantime-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8f59e8a805c18bc9ded3f4e596cb5f0157d88a235e875480a7593b5926f95065" -"checksum idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e" -"checksum idna 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "02e2673c30ee86b5b96a9cb52ad15718aa1f966f5ab9ad54a8b95d5ca33120a9" -"checksum indexmap 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a61202fbe46c4a951e9404a720a0180bcf3212c750d735cb5c4ba4dc551299f3" -"checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08" -"checksum ipconfig 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "aa79fa216fbe60834a9c0737d7fcd30425b32d1c58854663e24d4c4b328ed83f" -"checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" -"checksum js-sys 0.3.28 (registry+https://github.com/rust-lang/crates.io-index)" = "2cc9a97d7cec30128fd8b28a7c1f9df1c001ceb9b441e2b755e24130a6b43c79" -"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" -"checksum language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a91d884b6667cd606bb5a69aa0c99ba811a115fc68915e7056ec08a46e93199a" -"checksum lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "76f033c7ad61445c5b347c7382dd1237847eb1bce590fe50365dcb33d546be73" -"checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" -"checksum libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)" = "34fcd2c08d2f832f376f4173a231990fa5aef4e99fb569867318a227ef4c06ba" -"checksum linked-hash-map 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6d262045c5b87c0861b3f004610afd0e2c851e2908d08b6c870cbb9d5f494ecd" -"checksum linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ae91b68aebc4ddb91978b11a1b02ddd8602a05ec19002801c5666000e05e0f83" -"checksum lock_api 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "62ebf1391f6acad60e5c8b43706dde4582df75c06698ab44511d15016bc2442c" -"checksum lock_api 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ed946d4529956a20f2d63ebe1b69996d5a2137c91913fe3ebbeff957f5bca7ff" -"checksum lock_api 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f8912e782533a93a167888781b836336a6ca5da6175c05944c86cf28c31104dc" -"checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" -"checksum lru-cache 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "31e24f1ad8321ca0e8a1e0ac13f23cb668e6f5466c2c57319f6a5cf1cc8e3b1c" -"checksum macro-attr 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "00e51c6f0e2bf862b01b3d784fc32b02feb248a69062c51fb0b6d14cd526cc2a" -"checksum matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" -"checksum medea-macro 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "70a1d5121ec38c5f20762b4c4e422c755337a0063ecfc26aa51b4e4ed9936c2f" -"checksum memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "88579771288728879b57485cc7d6b07d648c9f0141eb955f8ab7f9d45394468e" -"checksum memoffset 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ce6075db033bbbb7ee5a0bbd3a3186bbae616f57fb001c485c7ff77955f8177f" -"checksum memory_units 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8452105ba047068f40ff7093dd1d9da90898e63dd61736462e9cdda6a90ad3c3" -"checksum mime 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "dd1d63acd1b78403cc0c325605908475dd9b9a3acbf65ed8bcab97e27014afcf" -"checksum miniz-sys 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "1e9e3ae51cea1576ceba0dde3d484d30e6e5b86dee0b2d412fe3a16a15c98202" -"checksum miniz_oxide 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7108aff85b876d06f22503dcce091e29f76733b2bfdd91eebce81f5e68203a10" -"checksum mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)" = "83f51996a3ed004ef184e16818edc51fadffe8e7ca68be67f9dee67d84d0ff23" -"checksum mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)" = "966257a94e196b11bb43aca423754d87429960a768de9414f3691d6957abf125" -"checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" -"checksum mockall 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "607b694715fc3b97960917a342d9105655fb2407cd89be7b2e57b863912212ba" -"checksum mockall_derive 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4ea0691e3157c199a60680c34226c44a87b0914bdd2f5178728195e8429fbbbc" -"checksum net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88" -"checksum newtype_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ac8cd24d9f185bb7223958d8c1ff7a961b74b1953fd05dba7cc568a63b3861ec" -"checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945" -"checksum nom 4.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2ad2a91a8e869eeb30b9cb3119ae87773a8f4ae617f41b1eb9c154b2905f7bd6" -"checksum normalize-line-endings 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2e0a1a39eab95caf4f5556da9289b9e68f0aafac901b2ce80daaf020d3b733a8" -"checksum num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)" = "b85e541ef8255f6cf42bbfe4ef361305c6c135d10919ecc26126c4e5ae94bc09" -"checksum num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)" = "92e5113e9fd4cc14ded8e499429f396a20f98c772a47cc8622a736e1ec843c31" -"checksum num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "6ba9a427cfca2be13aa6f6403b0b7e7368fe982bfa16fccc450ce74c46cd9b32" -"checksum num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bcef43580c035376c0705c42792c294b66974abbfd2789b511784023f71f3273" -"checksum owning_ref 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "49a4b8ea2179e6a2e27411d3bca09ca6dd630821cf6894c6c7c8467a8ee7ef13" -"checksum parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ab41b4aed082705d1056416ae4468b6ea99d52599ecf3169b00088d43113e337" -"checksum parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fa7767817701cce701d5585b9c4db3cdd02086398322c1d7e8bf5094a96a2ce7" -"checksum parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f842b1982eb6c2fe34036a4fbfb06dd185a3f5c8edfaacdf7d1ea10b07de6252" -"checksum parking_lot_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "94c8c7923936b28d546dfd14d4472eaf34c99b14e1c973a32b3e6d4eb04298c9" -"checksum parking_lot_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cb88cb1cb3790baa6776844f968fea3be44956cf184fa1be5a03341f5491278c" -"checksum parking_lot_core 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b876b1b9e7ac6e1a74a6da34d25c42e17e8862aa409cbbbdcfc8d86c6f3bc62b" -"checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" -"checksum percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" -"checksum pkg-config 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)" = "72d5370d90f49f70bd033c3d75e87fc529fbfff9d6f7cccef07d6170079d91ea" -"checksum ppv-lite86 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e3cbf9f658cdb5000fcf6f362b8ea2ba154b9f146a61c7a20d647034c6b6561b" -"checksum predicates 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "53e09015b0d3f5a0ec2d4428f7559bb7b3fff341b4e159fedd1d57fac8b939ff" -"checksum predicates-core 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "06075c3a3e92559ff8929e7a280684489ea27fe44805174c3ebd9328dcb37178" -"checksum predicates-tree 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8e63c4859013b38a76eca2414c64911fba30def9e3202ac461a2d22831220124" -"checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" -"checksum proc-macro2 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "afdc77cc74ec70ed262262942ebb7dac3d479e9e5cfa2da1841c0806f6cdabcc" -"checksum protobuf 2.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "40361836defdd5871ff7e84096c6f6444af7fc157f8ef1789f54f147687caa20" -"checksum protobuf-codegen 2.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "12c6abd78435445fc86898ebbd0521a68438063d4a73e23527b7134e6bf58b4a" -"checksum protoc 2.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3998c4bc0af8ccbd3cc68245ee9f72663c5ae2fb78bc48ff7719aef11562edea" -"checksum protoc-grpcio 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e7bb9b76be44d96453f528030c03713f57fa725565036cc9d72037ad75babadf" -"checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" -"checksum quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" -"checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" -"checksum rand 0.3.23 (registry+https://github.com/rust-lang/crates.io-index)" = "64ac302d8f83c0c1974bf758f6b041c6c8ada916fbb44a609158ca8b064cc76c" -"checksum rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" -"checksum rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" -"checksum rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3ae1b169243eaf61759b8475a998f0a385e42042370f3a7dbaf35246eacc8412" -"checksum rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" -"checksum rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "03a2a90da8c7523f554344f921aa97283eadf6ac484a6d2a7d0212fa7f8d6853" -"checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" -"checksum rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" -"checksum rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" -"checksum rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" -"checksum rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" -"checksum rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" -"checksum rand_jitter 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" -"checksum rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" -"checksum rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" -"checksum rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" -"checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" -"checksum redis 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1b03b599645e2db97724125cdff11196b56a70b21837a6e68f0e55955989e0cc" -"checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" -"checksum redox_users 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4ecedbca3bf205f8d8f5c2b44d83cd0690e39ee84b951ed649e9f1841132b66d" -"checksum regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dc220bd33bdce8f093101afe22a037b8eb0e5af33592e6a9caafff0d4cb81cbd" -"checksum regex-syntax 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)" = "11a7e20d1cce64ef2fed88b66d347f88bd9babb82845b2b858f3edbf59a4f716" -"checksum remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e" -"checksum resolv-conf 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b263b4aa1b5de9ffc0054a2386f96992058bb6870aab516f8cdeb8a667d56dcb" -"checksum rust-argon2 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4ca4eaef519b494d1f2848fc602d18816fed808a981aedf4f1f00ceb7c9d32cf" -"checksum rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)" = "f76d05d3993fd5f4af9434e8e436db163a12a9d40e1a58a726f27a01dfd12a2a" -"checksum rust-ini 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3e52c148ef37f8c375d49d5a73aa70713125b7f19095948a923f80afdeb22ec2" -"checksum rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" -"checksum rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda" -"checksum rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "c5f5376ea5e30ce23c03eb77cbe4962b988deead10910c372b226388b594c084" -"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -"checksum ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c92464b447c0ee8c4fb3824ecc8383b81717b9f1e74ba2e72540aef7b9f82997" -"checksum scoped-tls 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2" -"checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" -"checksum scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b42e15e59b18a828bbf5c58ea01debb36b9b096346de35d941dcb89009f24a0d" -"checksum semver 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)" = "d4f410fedcf71af0345d7607d246e7ad15faaadd49d240ee3b24e5dc21a820ac" -"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum serde 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)" = "9dad3f759919b92c3068c696c15c3d17238234498bbdcc80f2c469606f948ac8" -"checksum serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)" = "9796c9b7ba2ffe7a9ce53c2287dfc48080f4b2b362fcc245a259b3a7201119dd" -"checksum serde-hjson 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0b833c5ad67d52ced5f5938b2980f32a9c1c5ef047f0b4fb3127e7a423c76153" -"checksum serde_derive 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)" = "4b133a43a1ecd55d4086bd5b4dc6c1751c68b1bfbeba7a5040442022c7e7c02e" -"checksum serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)" = "051c49229f282f7c6f3813f8286cc1e3323e8051823fce42c7ea80fe13521704" -"checksum serde_test 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)" = "110b3dbdf8607ec493c22d5d947753282f3bae73c0f56d322af1e8c78e4c23d5" -"checksum serde_urlencoded 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9ec5d77e2d4c73717816afac02670d5c4f534ea95ed430442cad02e7a6e32c97" -"checksum serde_yaml 0.8.9 (registry+https://github.com/rust-lang/crates.io-index)" = "38b08a9a90e5260fe01c6480ec7c811606df6d3a660415808c3c3fa8ed95b582" -"checksum serial_test 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "50bfbc39343545618d97869d77f38ed43e48dd77432717dbc7ed39d797f3ecbe" -"checksum serial_test_derive 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "89dd85be2e2ad75b041c9df2892ac078fa6e0b90024028b2b9fb4125b7530f01" -"checksum sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d" -"checksum signal-hook 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4f61c4d59f3aaa9f61bba6450a9b80ba48362fd7d651689e7a10c453b1f6dc68" -"checksum signal-hook-registry 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1797d48f38f91643908bb14e35e79928f9f4b3cefb2420a564dde0991b4358dc" -"checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" -"checksum slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1cc9c640a4adbfbcc11ffb95efe5aa7af7309e002adab54b185507dbf2377b99" -"checksum slog-async 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e544d16c6b230d84c866662fe55e31aacfca6ae71e6fc49ae9a311cb379bfc2f" -"checksum slog-envlogger 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "906a1a0bc43fed692df4b82a5e2fbfc3733db8dad8bb514ab27a4f23ad04f5c0" -"checksum slog-json 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ddc0d2aff1f8f325ef660d9a0eb6e6dcd20b30b3f581a5897f58bf42d061c37a" -"checksum slog-scope 4.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d1d3ec6214d46e57a7ec87c1972bbca66c59172a0cfffa5233c54726afb946bf" -"checksum slog-stdlog 4.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "be4d87903baf655da2d82bc3ac3f7ef43868c58bf712b3a661fda72009304c23" -"checksum slog-term 2.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cb9b3fd9a3c2c86580fce3558a98ed7c69039da0288b08a3f15b371635254e08" -"checksum smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "ab606a9c5e214920bb66c458cd7be8ef094f813f20fe77a54cc7dbfff220d4b7" -"checksum smart-default 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5a9dbd5f03d04e80355cbbe3ce5cf1f65c421eac575402e3d4d6e95d5a44edaa" -"checksum socket2 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)" = "e8b74de517221a2cb01a53349cf54182acdc31a074727d3079068448c0676d85" -"checksum sourcefile 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4bf77cb82ba8453b42b6ae1d692e4cdc92f9a47beaf89a847c8be83f4e328ad3" -"checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" -"checksum string 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d24114bfcceb867ca7f71a0d3fe45d45619ec47a6fbfa98cb14e14250bfa5d6d" -"checksum syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)" = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" -"checksum syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "66850e97125af79138385e9b88339cbcd037e3f28ceab8c5ad98e64f0f1f80bf" -"checksum synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f" -"checksum take_mut 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f764005d11ee5f36500a149ace24e00e3da98b0158b3e2d53a7495660d3f4d60" -"checksum tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" -"checksum term 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "edd106a334b7657c10b7c540a0106114feadeb4dc314513e97df481d5d966f42" -"checksum termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "96d6098003bde162e4277c70665bd87c326f5a0c3f3fbfb285787fa482d54e6e" -"checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" -"checksum threadpool 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e2f0c90a5f3459330ac8bc0d2f879c693bb7a2f59689c1083fc4ef83834da865" -"checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" -"checksum tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)" = "5a09c0b5bb588872ab2f09afa13ee6e9dac11e10a0ec9e8e3ba39a5a5d530af6" -"checksum tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5c501eceaf96f0e1793cf26beb63da3d11c738c4a943fdf3746d81d64684c39f" -"checksum tokio-current-thread 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "d16217cad7f1b840c5a97dfb3c43b0c871fef423a6e8d2118c604e843662a443" -"checksum tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "0f27ee0e6db01c5f0b2973824547ce7e637b2ed79b891a9677b0de9bd532b6ac" -"checksum tokio-fs 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "3fe6dc22b08d6993916647d108a1a7d15b9cd29c4f4496c62b92c45b5041b7af" -"checksum tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "5090db468dad16e1a7a54c8c67280c5e4b544f3d3e018f0b913b400261f85926" -"checksum tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "6af16bfac7e112bea8b0442542161bfc41cbfa4466b580bdda7d18cb88b911ce" -"checksum tokio-signal 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "dd6dc5276ea05ce379a16de90083ec80836440d5ef8a6a39545a3207373b8296" -"checksum tokio-sync 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2162248ff317e2bc713b261f242b69dbb838b85248ed20bb21df56d60ea4cae7" -"checksum tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1d14b10654be682ac43efee27401d792507e30fd8d26389e1da3b185de2e4119" -"checksum tokio-threadpool 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "90ca01319dea1e376a001e8dc192d42ebde6dd532532a5bad988ac37db365b19" -"checksum tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "f2106812d500ed25a4f38235b9cae8f78a09edf43203e16e59c3b769a342a60e" -"checksum tokio-udp 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f02298505547f73e60f568359ef0d016d5acd6e830ab9bc7c4a5b3403440121b" -"checksum tokio-uds 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "037ffc3ba0e12a0ab4aca92e5234e0dedeb48fddf6ccd260f1f150a36a9f2445" -"checksum toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "758664fc71a3a69038656bee8b6be6477d2a6c315a6b81f7081f591bffa4111f" -"checksum toml 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c7aabe75941d914b72bf3e5d3932ed92ce0664d49d8432305a8b547c37227724" -"checksum treeline 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a7f741b240f1a48843f9b8e0444fb55fb2a4ff67293b50a9179dfd5ea67f8d41" -"checksum trust-dns-proto 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5559ebdf6c2368ddd11e20b11d6bbaf9e46deb803acd7815e93f5a7b4a6d2901" -"checksum trust-dns-resolver 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6c9992e58dba365798803c0b91018ff6c8d3fc77e06977c4539af2a6bfe0a039" -"checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" -"checksum unicode-normalization 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "141339a08b982d942be2ca06ff8b076563cbe223d1befd5450716790d44e2426" -"checksum unicode-segmentation 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1967f4cdfc355b37fd76d2a954fb2ed3871034eb4f26d60537d88795cfc332a9" -"checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" -"checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" -"checksum unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56" -"checksum url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dd4e7c0d531266369519a4aa4f399d748bd37043b00bde1e4ff1f60a120b355a" -"checksum url 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "75b414f6c464c879d7f9babf951f23bc3743fb7313c081b2e6ca719067ea9d61" -"checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" -"checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" -"checksum wasi 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b89c3ce4ce14bdc6fb6beaf9ec7928ca331de5df7e5ea278375642a2f478570d" -"checksum wasm-bindgen 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)" = "cd34c5ba0d228317ce388e87724633c57edca3e7531feb4e25e35aaa07a656af" -"checksum wasm-bindgen-backend 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)" = "927196b315c23eed2748442ba675a4c54a1a079d90d9bdc5ad16ce31cf90b15b" -"checksum wasm-bindgen-futures 0.3.27 (registry+https://github.com/rust-lang/crates.io-index)" = "83420b37346c311b9ed822af41ec2e82839bfe99867ec6c54e2da43b7538771c" -"checksum wasm-bindgen-macro 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)" = "92c2442bf04d89792816650820c3fb407af8da987a9f10028d5317f5b04c2b4a" -"checksum wasm-bindgen-macro-support 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)" = "9c075d27b7991c68ca0f77fe628c3513e64f8c477d422b859e03f28751b46fc5" -"checksum wasm-bindgen-shared 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)" = "83d61fe986a7af038dd8b5ec660e5849cbd9f38e7492b9404cc48b2b4df731d1" -"checksum wasm-bindgen-test 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)" = "a2d9693b63a742d481c7f80587e057920e568317b2806988c59cd71618bc26c1" -"checksum wasm-bindgen-test-macro 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)" = "0789dac148a8840bbcf9efe13905463b733fa96543bfbf263790535c11af7ba5" -"checksum wasm-bindgen-webidl 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)" = "9b979afb0535fe4749906a674082db1211de8aef466331d43232f63accb7c07c" -"checksum web-sys 0.3.28 (registry+https://github.com/rust-lang/crates.io-index)" = "c84440699cd02ca23bed6f045ffb1497bc18a3c2628bd13e2093186faaaacf6b" -"checksum wee_alloc 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "dbb3b5a6b2bb17cb6ad44a2e68a43e8d2722c997da10e928665c72ec6c0a0b8e" -"checksum weedle 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3bb43f70885151e629e2a19ce9e50bd730fd436cfd4b666894c9ce4de9141164" -"checksum widestring 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "effc0e4ff8085673ea7b9b2e3c73f6bd4d118810c9009ed8f1e16bd96c331db6" -"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" -"checksum winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" -"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" -"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" -"checksum winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7168bab6e1daee33b4557efd0e95d5ca70a03706d39fa5f3fe7a236f584b03c9" -"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -"checksum wincolor 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "96f5016b18804d24db43cebf3c77269e7569b8954a8464501c216cc5e070eaa9" -"checksum winreg 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b2986deb581c4fe11b621998a5e53361efe6b48a151178d0cd9eeffa4dc6acc9" -"checksum winutil 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7daf138b6b14196e3830a588acf1e86966c694d3e8fb026fb105b8b5dca07e6e" -"checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" -"checksum yaml-rust 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "65923dd1784f44da1d2c3dbbc5e822045628c590ba72123e1c73d3c230c4434d" diff --git a/jason/Cargo.toml b/jason/Cargo.toml index 0cae78712..113fe32d2 100644 --- a/jason/Cargo.toml +++ b/jason/Cargo.toml @@ -37,7 +37,7 @@ newtype_derive = "0.1" predicates-tree = { version = "1.0", optional = true } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" -wasm-bindgen = { version = "0.2", features = ["serde-serialize"] } +wasm-bindgen = { version = "=0.2.51", features = ["serde-serialize"] } wasm-bindgen-futures = "0.3" wee_alloc = { version = "0.4", optional = true } [dependencies.web-sys] @@ -55,4 +55,4 @@ wee_alloc = { version = "0.4", optional = true } ] [dev-dependencies] -wasm-bindgen-test = "0.2" +wasm-bindgen-test = "=0.2" From ac978465a90efd73238df5326852ba5699c282da Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 1 Oct 2019 12:05:54 +0300 Subject: [PATCH 684/735] Run jason tests on chrome and firefox [run ci] --- .travis.yml | 16 +- Cargo.lock | 3019 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 3030 insertions(+), 5 deletions(-) create mode 100644 Cargo.lock diff --git a/.travis.yml b/.travis.yml index 553afd729..dc0e811c7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -94,20 +94,26 @@ jobs: rust: stable script: make test.unit crate=medea - - name: unit medea-jason (nightly) + - name: unit medea-jason (nightly, Firefox) stage: test # TODO: Run on stable when -Z install-upgrade is out, # see: https://github.com/rust-lang/cargo/issues/6797 rust: nightly - addons: - chrome: stable - apt: - packages: ["chromium-chromedriver"] before_script: - cargo +nightly install wasm-bindgen-cli -Z install-upgrade - rustup target add wasm32-unknown-unknown script: make test.unit crate=medea-jason webdriver=geckodriver + - name: unit medea-jason (nightly, Chrome) + stage: test + # TODO: Run on stable when -Z install-upgrade is out, + # see: https://github.com/rust-lang/cargo/issues/6797 + rust: nightly + before_script: + - cargo +nightly install wasm-bindgen-cli -Z install-upgrade + - rustup target add wasm32-unknown-unknown + script: make test.unit crate=medea-jason webdriver=chromedriver + - name: E2E signalling (stable) stage: test rust: stable diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 000000000..a471fa8a4 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,3019 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "Inflector" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "actix" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "actix-http 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-rt 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", + "actix_derive 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-channel 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "hashbrown 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "trust-dns-resolver 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "actix-codec" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "actix-connect" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-rt 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-service 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-utils 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "http 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-current-thread 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "trust-dns-resolver 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "actix-http" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-connect 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-server-config 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-service 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-threadpool 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-utils 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", + "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "brotli2 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", + "copyless 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)", + "encoding_rs 0.8.20 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "flate2 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "h2 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "hashbrown 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "http 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", + "httparse 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "indexmap 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "mime 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", + "percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_urlencoded 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-current-thread 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "trust-dns-resolver 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "actix-http-test" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-connect 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-rt 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-server 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-service 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-utils 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", + "awc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", + "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "http 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_urlencoded 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "actix-router" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "http 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", + "string 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "actix-rt" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "actix-threadpool 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "copyless 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-current-thread 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-reactor 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "actix-server" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "actix-rt 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-server-config 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-service 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", + "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-reactor 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-signal 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "actix-server-config" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "actix-service" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "actix-testing" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "actix-rt 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-server 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-server-config 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-service 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-reactor 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "actix-threadpool" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "threadpool 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "actix-utils" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-service 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-current-thread 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "actix-web" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-http 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-router 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-rt 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-server 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-server-config 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-service 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-testing 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-threadpool 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-utils 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-web-codegen 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "awc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "encoding_rs 0.8.20 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "hashbrown 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "mime 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", + "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_urlencoded 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", + "url 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "actix-web-actors" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "actix 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-http 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-web 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "actix-web-codegen" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "actix_derive" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "adler32" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "aho-corasick" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "arc-swap" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "arc-swap" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "arrayref" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "arrayvec" +version = "0.4.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "ascii" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "atty" +version = "0.2.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "autocfg" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "awc" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-http 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-service 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "mime 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", + "percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_urlencoded 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "backtrace" +version = "0.3.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "backtrace-sys 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "backtrace-sys" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cc 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "base64" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "bb8" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "bb8-redis" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bb8 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "redis 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "bitflags" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "blake2b_simd" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", + "constant_time_eq 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "brotli-sys" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cc 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "brotli2" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "brotli-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "bumpalo" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "byteorder" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "bytes" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "c2-chacha" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ppv-lite86 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "cc" +version = "1.0.45" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "cfg-if" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "chrono" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "cloudabi" +version = "0.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "cmake" +version = "0.1.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cc 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "combine" +version = "3.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "ascii 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "config" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "nom 4.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "rust-ini 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", + "serde-hjson 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", + "toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", + "yaml-rust 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "console_error_panic_hook" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "constant_time_eq" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "copyless" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "crc32fast" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "crossbeam" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-channel 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-deque 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-epoch 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "crossbeam-channel" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "crossbeam-deque" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "crossbeam-epoch 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "memoffset 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "crossbeam-queue" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "crossbeam-utils" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "derive-new" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "derive_more" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "derive_more" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "difference" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "dirs" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_users 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "dotenv" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "downcast" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "dtoa" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "either" +version = "1.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "encoding_rs" +version = "0.8.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "enum-as-inner" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "env_logger" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", + "humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "failure" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "backtrace 0.3.38 (registry+https://github.com/rust-lang/crates.io-index)", + "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "failure_derive" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)", + "synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "flate2" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "miniz-sys 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "miniz_oxide 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "float-cmp" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "fnv" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "fragile" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "fuchsia-cprng" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "fuchsia-zircon" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "fuchsia-zircon-sys" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "futures" +version = "0.1.29" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "gcc" +version = "0.3.55" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "getrandom" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "wasi 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "grpcio" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "grpcio-sys 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf 2.8.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "grpcio-compiler" +version = "0.5.0-alpha.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "derive-new 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf 2.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf-codegen 2.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "grpcio-sys" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cc 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)", + "cmake 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "h2" +version = "0.1.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "http 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", + "indexmap 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "string 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "hashbrown" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "hashbrown" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "heck" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "unicode-segmentation 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "hostname" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "winutil 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "http" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "httparse" +version = "1.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "humantime" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "humantime-serde" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "idna" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-normalization 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "idna" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-normalization 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "indexmap" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "iovec" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "ipconfig" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "socket2 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)", + "widestring 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "winreg 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "itoa" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "js-sys" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "wasm-bindgen 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "kernel32-sys" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "language-tags" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "lazy_static" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "libc" +version = "0.2.62" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "linked-hash-map" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "serde 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_test 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "linked-hash-map" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "lock_api" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "lock_api" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "log" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "lru-cache" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "macro-attr" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "matches" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "medea" +version = "0.2.0-dev" +dependencies = [ + "actix 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-http 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-http-test 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-web 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-web-actors 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "awc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", + "bb8 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "bb8-redis 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", + "config 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "dotenv 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "grpcio 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", + "humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "humantime-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "medea-client-api-proto 0.1.1-dev", + "medea-control-api-proto 0.1.0-dev", + "medea-macro 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf 2.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "redis 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_yaml 0.8.9 (registry+https://github.com/rust-lang/crates.io-index)", + "serial_test 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serial_test_derive 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "slog-async 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "slog-envlogger 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "slog-json 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "slog-scope 4.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "slog-stdlog 4.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "smart-default 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-signal 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", + "toml 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", + "url 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "medea-client-api-proto" +version = "0.1.1-dev" +dependencies = [ + "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "medea-macro 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "medea-control-api-proto" +version = "0.1.0-dev" +dependencies = [ + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "grpcio 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf 2.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "protoc-grpcio 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "medea-jason" +version = "0.2.0-dev" +dependencies = [ + "console_error_panic_hook 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "downcast 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fragile 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "js-sys 0.3.28 (registry+https://github.com/rust-lang/crates.io-index)", + "macro-attr 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "medea-client-api-proto 0.1.1-dev", + "medea-macro 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "mockall 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "newtype_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "predicates-tree 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-futures 0.3.27 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-test 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "web-sys 0.3.28 (registry+https://github.com/rust-lang/crates.io-index)", + "wee_alloc 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "medea-macro" +version = "0.1.0" +dependencies = [ + "Inflector 0.11.4 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "medea-macro" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "Inflector 0.11.4 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "memchr" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "memoffset" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "memory_units" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "mime" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "miniz-sys" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cc 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "miniz_oxide" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "adler32 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "mio" +version = "0.6.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", + "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "mio-uds" +version = "0.6.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "miow" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "mockall" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "downcast 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fragile 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "mockall_derive 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "predicates 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "predicates-tree 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "mockall_derive" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "net2" +version = "0.2.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "newtype_derive" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "nodrop" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "nom" +version = "4.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "normalize-line-endings" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "num-integer" +version = "0.1.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "num-traits" +version = "0.1.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "num-traits" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "num_cpus" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "parking_lot" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lock_api 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "parking_lot" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lock_api 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot_core 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "parking_lot_core" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "parking_lot_core" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "percent-encoding" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "percent-encoding" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "pkg-config" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "ppv-lite86" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "predicates" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "float-cmp 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "normalize-line-endings 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "predicates-core 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "predicates-core" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "predicates-tree" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "predicates-core 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "treeline 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "proc-macro2" +version = "0.4.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "proc-macro2" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "protobuf" +version = "2.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "protobuf-codegen" +version = "2.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "protobuf 2.8.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "protoc" +version = "2.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "protoc-grpcio" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "grpcio-compiler 0.5.0-alpha.2 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf 2.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf-codegen 2.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "protoc 2.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "quick-error" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "quote" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "quote" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand" +version = "0.3.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_jitter 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "getrandom 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand_chacha" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand_chacha" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "c2-chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand_core" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand_core" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "getrandom 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand_hc" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand_isaac" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand_jitter" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand_os" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand_pcg" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand_xorshift" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rdrand" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "redis" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "combine 3.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "dtoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-sync 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-uds 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", + "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "redox_syscall" +version = "0.1.56" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "redox_users" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", + "rust-argon2 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "regex" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", + "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "regex-syntax" +version = "0.6.12" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "remove_dir_all" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "resolv-conf" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "hostname 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rust-argon2" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "blake2b_simd 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rust-crypto" +version = "0.2.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.3.23 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", + "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rust-ini" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "rustc-demangle" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "rustc-serialize" +version = "0.3.24" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "rustc_version" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "semver 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rustc_version" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "ryu" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "scoped-tls" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "scopeguard" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "semver" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "semver" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "semver-parser" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "serde" +version = "0.8.23" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "serde" +version = "1.0.101" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "serde_derive 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "serde-hjson" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "linked-hash-map 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "serde_derive" +version = "1.0.101" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "serde_json" +version = "1.0.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "serde_test" +version = "0.8.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "serde 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "serde_urlencoded" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "dtoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", + "url 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "serde_yaml" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "dtoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", + "yaml-rust 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "serial_test" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "serial_test_derive" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "sha1" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "signal-hook" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "signal-hook-registry 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "signal-hook-registry" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "arc-swap 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "slab" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "slog" +version = "2.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "slog-async" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "take_mut 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "slog-envlogger" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "slog-async 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "slog-scope 4.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "slog-stdlog 4.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "slog-term 2.4.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "slog-json" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", + "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "slog-scope" +version = "4.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "arc-swap 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "slog-stdlog" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "crossbeam 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "slog-scope 4.1.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "slog-term" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", + "chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", + "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "term 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "smallvec" +version = "0.6.10" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "smart-default" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "socket2" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "sourcefile" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "string" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "syn" +version = "0.15.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "syn" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "synstructure" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "take_mut" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "tempfile" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", + "remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "term" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "dirs 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "termcolor" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "wincolor 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "thread_local" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "threadpool" +version = "1.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "time" +version = "0.1.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "tokio" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-current-thread 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-fs 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-reactor 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-sync 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-threadpool 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-udp 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-uds 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "tokio-codec" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "tokio-current-thread" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "tokio-executor" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "tokio-fs" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-threadpool 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "tokio-io" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "tokio-reactor" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-sync 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "tokio-signal" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", + "mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", + "signal-hook 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-reactor 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "tokio-sync" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "tokio-tcp" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-reactor 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "tokio-threadpool" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "crossbeam-deque 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "tokio-timer" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "tokio-udp" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-reactor 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "tokio-uds" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", + "mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-reactor 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "toml" +version = "0.4.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "toml" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "treeline" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "trust-dns-proto" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "enum-as-inner 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", + "socket2 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-reactor 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-udp 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "trust-dns-resolver" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "ipconfig 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "lru-cache 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "resolv-conf 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "trust-dns-proto 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "unicode-bidi" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "unicode-normalization" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "unicode-segmentation" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "unicode-xid" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "unicode-xid" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "unreachable" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "url" +version = "1.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "url" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "idna 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "version_check" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "void" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "wasi" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "wasm-bindgen" +version = "0.2.51" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-macro 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.51" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bumpalo 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-shared 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.3.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "js-sys 0.3.28 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "web-sys 0.3.28 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.51" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-macro-support 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.51" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-backend 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-shared 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.51" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "wasm-bindgen-test" +version = "0.2.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "console_error_panic_hook 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "js-sys 0.3.28 (registry+https://github.com/rust-lang/crates.io-index)", + "scoped-tls 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-futures 0.3.27 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-test-macro 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "wasm-bindgen-test-macro" +version = "0.2.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "wasm-bindgen-webidl" +version = "0.2.51" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-backend 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "weedle 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "web-sys" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "js-sys 0.3.28 (registry+https://github.com/rust-lang/crates.io-index)", + "sourcefile 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-webidl 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "wee_alloc" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "memory_units 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "weedle" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "nom 4.2.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "widestring" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "winapi" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "winapi" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "winapi-build" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "winapi-util" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "wincolor" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "winreg" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "winutil" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "ws2_32-sys" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "yaml-rust" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[metadata] +"checksum Inflector 0.11.4 (registry+https://github.com/rust-lang/crates.io-index)" = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" +"checksum actix 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)" = "671ce3d27313f236827a5dd153a1073ad03ef31fc77f562020263e7830cf1ef7" +"checksum actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9f2c11af4b06dc935d8e1b1491dad56bfb32febc49096a91e773f8535c176453" +"checksum actix-connect 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "9fade9bd4bb46bacde89f1e726c7a3dd230536092712f5d94d77ca57c087fca0" +"checksum actix-http 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "cdf758ebbc4abfecbdc1ce7408601b2d7e0cd7e4766ef61183cd8ce16c194d64" +"checksum actix-http-test 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "4c29c11568a1fd24163f7757aea88737082c1b8317f550262f9a1f47e9832f54" +"checksum actix-router 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "23224bb527e204261d0291102cb9b52713084def67d94f7874923baefe04ccf7" +"checksum actix-rt 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "168620aaf00fcd2a16e621790abaf180ef7377c2f8355b4ca5775d6afc778ed8" +"checksum actix-server 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dd626534af8d0a738e5f74901fe603af0445708f91b86a7d763d80df10d562a5" +"checksum actix-server-config 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "483a34989c682d93142bacad6300375bb6ad8002d2e0bb249dbad86128b9ff30" +"checksum actix-service 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bca5b48e928841ff7e7dce1fdb5b0d4582f6b1b976e08f4bac3f640643e0773f" +"checksum actix-testing 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "af001e97ac6750994824d400a1b7087055aab14317aa012f528d0b2b363f37f1" +"checksum actix-threadpool 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6b5ae85d13da7e6fb86b1b7bc83185e0e3bd4cc5f421c887e1803796c034d35d" +"checksum actix-utils 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6ea501068a0173533704be321f149853f702d9e3c3ce9d57e7a96d94b1ab5aca" +"checksum actix-web 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "36e59485f007a4be3df228791ff6c4aedcbe7bb09bd9225c3554f538aca4a584" +"checksum actix-web-actors 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "008c1b686048a16fef4ef2fc6b6e5fcf5f29829891ad87fc0848ade26b285627" +"checksum actix-web-codegen 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3fe9e3cdec1e645b675f354766e0688c5705021c85ab3cf739be1c8999b91c76" +"checksum actix_derive 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0bf5f6d7bf2d220ae8b4a7ae02a572bb35b7c4806b24049af905ab8110de156c" +"checksum adler32 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5d2e7343e7fc9de883d1b0341e0b13970f764c14101234857d2ddafa1cb1cac2" +"checksum aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "58fb5e95d83b38284460a5fda7d6470aa0b8844d283a0b614b8535e880800d2d" +"checksum arc-swap 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)" = "bc4662175ead9cd84451d5c35070517777949a2ed84551764129cedb88384841" +"checksum arc-swap 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "f1a1eca3195b729bbd64e292ef2f5fff6b1c28504fed762ce2b1013dde4d8e92" +"checksum arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0d382e583f07208808f6b1249e60848879ba3543f57c32277bf52d69c2f0f0ee" +"checksum arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)" = "b8d73f9beda665eaa98ab9e4f7442bd4e7de6652587de55b2525e52e29c1b0ba" +"checksum ascii 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "eab1c04a571841102f5345a8fc0f6bb3d31c315dec879b5c6e42e40ce7ffa34e" +"checksum atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1803c647a3ec87095e7ae7acfca019e98de5ec9a7d01343f611cf3152ed71a90" +"checksum autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "b671c8fb71b457dd4ae18c4ba1e59aa81793daacc361d82fcd410cef0d491875" +"checksum awc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "364537de6ac9f996780f9dd097d6c4ca7c91dd5735153e9fb545037479becd10" +"checksum backtrace 0.3.38 (registry+https://github.com/rust-lang/crates.io-index)" = "690a62be8920ccf773ee00ef0968649b0e724cda8bd5b12286302b4ae955fdf5" +"checksum backtrace-sys 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)" = "82a830b4ef2d1124a711c71d263c5abdc710ef8e907bd508c88be475cebc422b" +"checksum base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" +"checksum bb8 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0ac73ee3406f475415bba792942016291b87bac08839c38a032de56085a73b2c" +"checksum bb8-redis 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "39945a33c03edfba8c353d330b921961e2137d4fc4215331c1b2397f32acff80" +"checksum bitflags 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8a606a02debe2813760609f57a64a2ffd27d9fdf5b2f133eaca0b248dd92cdd2" +"checksum blake2b_simd 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)" = "5850aeee1552f495dd0250014cf64b82b7c8879a89d83b33bbdace2cc4f63182" +"checksum brotli-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4445dea95f4c2b41cde57cc9fee236ae4dbae88d8fcbdb4750fc1bb5d86aaecd" +"checksum brotli2 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0cb036c3eade309815c15ddbacec5b22c4d1f3983a774ab2eac2e3e9ea85568e" +"checksum bumpalo 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ad807f2fc2bf185eeb98ff3a901bd46dc5ad58163d0fa4577ba0d25674d71708" +"checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" +"checksum bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" +"checksum c2-chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7d64d04786e0f528460fc884753cf8dddcc466be308f6026f8e355c41a0e4101" +"checksum cc 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)" = "4fc9a35e1f4290eb9e5fc54ba6cf40671ed2a2514c3eeb2b2a908dda2ea5a1be" +"checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" +"checksum chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e8493056968583b0193c1bb04d6f7684586f3726992d6c573261941a895dbd68" +"checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" +"checksum cmake 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "81fb25b677f8bf1eb325017cb6bb8452f87969db0fedb4f757b297bee78a7c62" +"checksum combine 3.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "da3da6baa321ec19e1cc41d31bf599f00c783d0517095cdaf0332e3fe8d20680" +"checksum config 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "f9107d78ed62b3fa5a86e7d18e647abed48cfd8f8fab6c72f4cdb982d196f7e6" +"checksum console_error_panic_hook 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "b8d976903543e0c48546a91908f21588a680a8c8f984df9a5d69feccb2b2a211" +"checksum constant_time_eq 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "995a44c877f9212528ccc74b21a232f66ad69001e40ede5bcee2ac9ef2657120" +"checksum copyless 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "6ff9c56c9fb2a49c05ef0e431485a22400af20d33226dc0764d891d09e724127" +"checksum crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" +"checksum crossbeam 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2d818a4990769aac0c7ff1360e233ef3a41adcb009ebb2036bf6915eb0f6b23c" +"checksum crossbeam-channel 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "c8ec7fcd21571dc78f96cc96243cab8d8f035247c3efd16c687be154c3fa9efa" +"checksum crossbeam-deque 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b18cd2e169ad86297e6bc0ad9aa679aee9daa4f19e8163860faf7c164e4f5a71" +"checksum crossbeam-epoch 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "fedcd6772e37f3da2a9af9bf12ebe046c0dfe657992377b4df982a2b54cd37a9" +"checksum crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7c979cd6cfe72335896575c6b5688da489e420d36a27a0b9eb0c73db574b4a4b" +"checksum crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "04973fa96e96579258a5091af6003abde64af786b860f18622b82e026cca60e6" +"checksum derive-new 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)" = "71f31892cd5c62e414316f2963c5689242c43d8e7bbcaaeca97e5e28c95d91d9" +"checksum derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6d944ac6003ed268757ef1ee686753b57efc5fcf0ebe7b64c9fc81e7e32ff839" +"checksum derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a141330240c921ec6d074a3e188a7c7ef95668bb95e7d44fa0e5778ec2a7afe" +"checksum difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198" +"checksum dirs 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3fd78930633bd1c6e35c4b42b1df7b0cbc6bc191146e512bb3bedf243fcc3901" +"checksum dotenv 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4424bad868b0ffe6ae351ee463526ba625bbca817978293bbe6bb7dc1804a175" +"checksum downcast 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4bb454f0228b18c7f4c3b0ebbee346ed9c52e7443b0999cd543ff3571205701d" +"checksum dtoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "ea57b42383d091c85abcc2706240b94ab2a8fa1fc81c10ff23c4de06e2a90b5e" +"checksum either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3" +"checksum encoding_rs 0.8.20 (registry+https://github.com/rust-lang/crates.io-index)" = "87240518927716f79692c2ed85bfe6e98196d18c6401ec75355760233a7e12e9" +"checksum enum-as-inner 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3d58266c97445680766be408285e798d3401c6d4c378ec5552e78737e681e37d" +"checksum env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "aafcde04e90a5226a6443b7aabdb016ba2f8307c847d524724bd9b346dd1a2d3" +"checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" +"checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" +"checksum flate2 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)" = "2adaffba6388640136149e18ed080b77a78611c1e1d6de75aedcdf78df5d4682" +"checksum float-cmp 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "134a8fa843d80a51a5b77d36d42bc2def9edcb0262c914861d08129fd1926600" +"checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" +"checksum fragile 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "05f8140122fa0d5dcb9fc8627cfce2b37cc1500f752636d46ea28bc26785c2f9" +"checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" +"checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" +"checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" +"checksum futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)" = "1b980f2816d6ee8673b6517b52cb0e808a180efc92e5c19d02cdda79066703ef" +"checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" +"checksum getrandom 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "473a1265acc8ff1e808cd0a1af8cee3c2ee5200916058a2ca113c29f2d903571" +"checksum grpcio 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "cf45c98940795d83354880f073f3a2a2a995f50d3a3e43247ea23eca978d6574" +"checksum grpcio-compiler 0.5.0-alpha.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dd8b3213a332a2865a307e553f43d632bc4a81f0e0f5a90d194dee5b9c02d8a7" +"checksum grpcio-sys 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f6a31d8b4769d18e20de167e3c0ccae6b7dd506dfff78d323c2166e76efbe408" +"checksum h2 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)" = "a5b34c246847f938a410a03c5458c7fee2274436675e76d8b903c08efc29c462" +"checksum hashbrown 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "29fba9abe4742d586dfd0c06ae4f7e73a1c2d86b856933509b269d82cdf06e18" +"checksum hashbrown 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e1de41fb8dba9714efd92241565cdff73f78508c95697dd56787d3cba27e2353" +"checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" +"checksum hostname 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "21ceb46a83a85e824ef93669c8b390009623863b5c195d1ba747292c0c72f94e" +"checksum http 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)" = "372bcb56f939e449117fb0869c2e8fd8753a8223d92a172c6e808cf123a5b6e4" +"checksum httparse 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "cd179ae861f0c2e53da70d892f5f3029f9594be0c41dc5269cd371691b1dc2f9" +"checksum humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" +"checksum humantime-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8f59e8a805c18bc9ded3f4e596cb5f0157d88a235e875480a7593b5926f95065" +"checksum idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e" +"checksum idna 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "02e2673c30ee86b5b96a9cb52ad15718aa1f966f5ab9ad54a8b95d5ca33120a9" +"checksum indexmap 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a61202fbe46c4a951e9404a720a0180bcf3212c750d735cb5c4ba4dc551299f3" +"checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08" +"checksum ipconfig 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "aa79fa216fbe60834a9c0737d7fcd30425b32d1c58854663e24d4c4b328ed83f" +"checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" +"checksum js-sys 0.3.28 (registry+https://github.com/rust-lang/crates.io-index)" = "2cc9a97d7cec30128fd8b28a7c1f9df1c001ceb9b441e2b755e24130a6b43c79" +"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" +"checksum language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a91d884b6667cd606bb5a69aa0c99ba811a115fc68915e7056ec08a46e93199a" +"checksum lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "76f033c7ad61445c5b347c7382dd1237847eb1bce590fe50365dcb33d546be73" +"checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +"checksum libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)" = "34fcd2c08d2f832f376f4173a231990fa5aef4e99fb569867318a227ef4c06ba" +"checksum linked-hash-map 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6d262045c5b87c0861b3f004610afd0e2c851e2908d08b6c870cbb9d5f494ecd" +"checksum linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ae91b68aebc4ddb91978b11a1b02ddd8602a05ec19002801c5666000e05e0f83" +"checksum lock_api 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ed946d4529956a20f2d63ebe1b69996d5a2137c91913fe3ebbeff957f5bca7ff" +"checksum lock_api 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f8912e782533a93a167888781b836336a6ca5da6175c05944c86cf28c31104dc" +"checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" +"checksum lru-cache 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "31e24f1ad8321ca0e8a1e0ac13f23cb668e6f5466c2c57319f6a5cf1cc8e3b1c" +"checksum macro-attr 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "00e51c6f0e2bf862b01b3d784fc32b02feb248a69062c51fb0b6d14cd526cc2a" +"checksum matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" +"checksum medea-macro 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "70a1d5121ec38c5f20762b4c4e422c755337a0063ecfc26aa51b4e4ed9936c2f" +"checksum memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "88579771288728879b57485cc7d6b07d648c9f0141eb955f8ab7f9d45394468e" +"checksum memoffset 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ce6075db033bbbb7ee5a0bbd3a3186bbae616f57fb001c485c7ff77955f8177f" +"checksum memory_units 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8452105ba047068f40ff7093dd1d9da90898e63dd61736462e9cdda6a90ad3c3" +"checksum mime 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "dd1d63acd1b78403cc0c325605908475dd9b9a3acbf65ed8bcab97e27014afcf" +"checksum miniz-sys 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "1e9e3ae51cea1576ceba0dde3d484d30e6e5b86dee0b2d412fe3a16a15c98202" +"checksum miniz_oxide 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7108aff85b876d06f22503dcce091e29f76733b2bfdd91eebce81f5e68203a10" +"checksum mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)" = "83f51996a3ed004ef184e16818edc51fadffe8e7ca68be67f9dee67d84d0ff23" +"checksum mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)" = "966257a94e196b11bb43aca423754d87429960a768de9414f3691d6957abf125" +"checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" +"checksum mockall 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "607b694715fc3b97960917a342d9105655fb2407cd89be7b2e57b863912212ba" +"checksum mockall_derive 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4ea0691e3157c199a60680c34226c44a87b0914bdd2f5178728195e8429fbbbc" +"checksum net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88" +"checksum newtype_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ac8cd24d9f185bb7223958d8c1ff7a961b74b1953fd05dba7cc568a63b3861ec" +"checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945" +"checksum nom 4.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2ad2a91a8e869eeb30b9cb3119ae87773a8f4ae617f41b1eb9c154b2905f7bd6" +"checksum normalize-line-endings 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2e0a1a39eab95caf4f5556da9289b9e68f0aafac901b2ce80daaf020d3b733a8" +"checksum num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)" = "b85e541ef8255f6cf42bbfe4ef361305c6c135d10919ecc26126c4e5ae94bc09" +"checksum num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)" = "92e5113e9fd4cc14ded8e499429f396a20f98c772a47cc8622a736e1ec843c31" +"checksum num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "6ba9a427cfca2be13aa6f6403b0b7e7368fe982bfa16fccc450ce74c46cd9b32" +"checksum num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bcef43580c035376c0705c42792c294b66974abbfd2789b511784023f71f3273" +"checksum parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fa7767817701cce701d5585b9c4db3cdd02086398322c1d7e8bf5094a96a2ce7" +"checksum parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f842b1982eb6c2fe34036a4fbfb06dd185a3f5c8edfaacdf7d1ea10b07de6252" +"checksum parking_lot_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cb88cb1cb3790baa6776844f968fea3be44956cf184fa1be5a03341f5491278c" +"checksum parking_lot_core 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b876b1b9e7ac6e1a74a6da34d25c42e17e8862aa409cbbbdcfc8d86c6f3bc62b" +"checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" +"checksum percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" +"checksum pkg-config 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)" = "72d5370d90f49f70bd033c3d75e87fc529fbfff9d6f7cccef07d6170079d91ea" +"checksum ppv-lite86 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e3cbf9f658cdb5000fcf6f362b8ea2ba154b9f146a61c7a20d647034c6b6561b" +"checksum predicates 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "53e09015b0d3f5a0ec2d4428f7559bb7b3fff341b4e159fedd1d57fac8b939ff" +"checksum predicates-core 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "06075c3a3e92559ff8929e7a280684489ea27fe44805174c3ebd9328dcb37178" +"checksum predicates-tree 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8e63c4859013b38a76eca2414c64911fba30def9e3202ac461a2d22831220124" +"checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" +"checksum proc-macro2 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "afdc77cc74ec70ed262262942ebb7dac3d479e9e5cfa2da1841c0806f6cdabcc" +"checksum protobuf 2.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "40361836defdd5871ff7e84096c6f6444af7fc157f8ef1789f54f147687caa20" +"checksum protobuf-codegen 2.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "12c6abd78435445fc86898ebbd0521a68438063d4a73e23527b7134e6bf58b4a" +"checksum protoc 2.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3998c4bc0af8ccbd3cc68245ee9f72663c5ae2fb78bc48ff7719aef11562edea" +"checksum protoc-grpcio 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e7bb9b76be44d96453f528030c03713f57fa725565036cc9d72037ad75babadf" +"checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" +"checksum quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" +"checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" +"checksum rand 0.3.23 (registry+https://github.com/rust-lang/crates.io-index)" = "64ac302d8f83c0c1974bf758f6b041c6c8ada916fbb44a609158ca8b064cc76c" +"checksum rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" +"checksum rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" +"checksum rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3ae1b169243eaf61759b8475a998f0a385e42042370f3a7dbaf35246eacc8412" +"checksum rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" +"checksum rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "03a2a90da8c7523f554344f921aa97283eadf6ac484a6d2a7d0212fa7f8d6853" +"checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" +"checksum rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" +"checksum rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +"checksum rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" +"checksum rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +"checksum rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" +"checksum rand_jitter 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" +"checksum rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" +"checksum rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" +"checksum rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" +"checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" +"checksum redis 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1b03b599645e2db97724125cdff11196b56a70b21837a6e68f0e55955989e0cc" +"checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" +"checksum redox_users 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4ecedbca3bf205f8d8f5c2b44d83cd0690e39ee84b951ed649e9f1841132b66d" +"checksum regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dc220bd33bdce8f093101afe22a037b8eb0e5af33592e6a9caafff0d4cb81cbd" +"checksum regex-syntax 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)" = "11a7e20d1cce64ef2fed88b66d347f88bd9babb82845b2b858f3edbf59a4f716" +"checksum remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e" +"checksum resolv-conf 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b263b4aa1b5de9ffc0054a2386f96992058bb6870aab516f8cdeb8a667d56dcb" +"checksum rust-argon2 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4ca4eaef519b494d1f2848fc602d18816fed808a981aedf4f1f00ceb7c9d32cf" +"checksum rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)" = "f76d05d3993fd5f4af9434e8e436db163a12a9d40e1a58a726f27a01dfd12a2a" +"checksum rust-ini 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3e52c148ef37f8c375d49d5a73aa70713125b7f19095948a923f80afdeb22ec2" +"checksum rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" +"checksum rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda" +"checksum rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "c5f5376ea5e30ce23c03eb77cbe4962b988deead10910c372b226388b594c084" +"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +"checksum ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c92464b447c0ee8c4fb3824ecc8383b81717b9f1e74ba2e72540aef7b9f82997" +"checksum scoped-tls 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2" +"checksum scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b42e15e59b18a828bbf5c58ea01debb36b9b096346de35d941dcb89009f24a0d" +"checksum semver 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)" = "d4f410fedcf71af0345d7607d246e7ad15faaadd49d240ee3b24e5dc21a820ac" +"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" +"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" +"checksum serde 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)" = "9dad3f759919b92c3068c696c15c3d17238234498bbdcc80f2c469606f948ac8" +"checksum serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)" = "9796c9b7ba2ffe7a9ce53c2287dfc48080f4b2b362fcc245a259b3a7201119dd" +"checksum serde-hjson 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0b833c5ad67d52ced5f5938b2980f32a9c1c5ef047f0b4fb3127e7a423c76153" +"checksum serde_derive 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)" = "4b133a43a1ecd55d4086bd5b4dc6c1751c68b1bfbeba7a5040442022c7e7c02e" +"checksum serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)" = "051c49229f282f7c6f3813f8286cc1e3323e8051823fce42c7ea80fe13521704" +"checksum serde_test 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)" = "110b3dbdf8607ec493c22d5d947753282f3bae73c0f56d322af1e8c78e4c23d5" +"checksum serde_urlencoded 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9ec5d77e2d4c73717816afac02670d5c4f534ea95ed430442cad02e7a6e32c97" +"checksum serde_yaml 0.8.9 (registry+https://github.com/rust-lang/crates.io-index)" = "38b08a9a90e5260fe01c6480ec7c811606df6d3a660415808c3c3fa8ed95b582" +"checksum serial_test 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "50bfbc39343545618d97869d77f38ed43e48dd77432717dbc7ed39d797f3ecbe" +"checksum serial_test_derive 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "89dd85be2e2ad75b041c9df2892ac078fa6e0b90024028b2b9fb4125b7530f01" +"checksum sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d" +"checksum signal-hook 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4f61c4d59f3aaa9f61bba6450a9b80ba48362fd7d651689e7a10c453b1f6dc68" +"checksum signal-hook-registry 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1797d48f38f91643908bb14e35e79928f9f4b3cefb2420a564dde0991b4358dc" +"checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" +"checksum slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1cc9c640a4adbfbcc11ffb95efe5aa7af7309e002adab54b185507dbf2377b99" +"checksum slog-async 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e544d16c6b230d84c866662fe55e31aacfca6ae71e6fc49ae9a311cb379bfc2f" +"checksum slog-envlogger 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "906a1a0bc43fed692df4b82a5e2fbfc3733db8dad8bb514ab27a4f23ad04f5c0" +"checksum slog-json 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ddc0d2aff1f8f325ef660d9a0eb6e6dcd20b30b3f581a5897f58bf42d061c37a" +"checksum slog-scope 4.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d1d3ec6214d46e57a7ec87c1972bbca66c59172a0cfffa5233c54726afb946bf" +"checksum slog-stdlog 4.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "be4d87903baf655da2d82bc3ac3f7ef43868c58bf712b3a661fda72009304c23" +"checksum slog-term 2.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cb9b3fd9a3c2c86580fce3558a98ed7c69039da0288b08a3f15b371635254e08" +"checksum smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "ab606a9c5e214920bb66c458cd7be8ef094f813f20fe77a54cc7dbfff220d4b7" +"checksum smart-default 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5a9dbd5f03d04e80355cbbe3ce5cf1f65c421eac575402e3d4d6e95d5a44edaa" +"checksum socket2 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)" = "e8b74de517221a2cb01a53349cf54182acdc31a074727d3079068448c0676d85" +"checksum sourcefile 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4bf77cb82ba8453b42b6ae1d692e4cdc92f9a47beaf89a847c8be83f4e328ad3" +"checksum string 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d24114bfcceb867ca7f71a0d3fe45d45619ec47a6fbfa98cb14e14250bfa5d6d" +"checksum syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)" = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" +"checksum syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "66850e97125af79138385e9b88339cbcd037e3f28ceab8c5ad98e64f0f1f80bf" +"checksum synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f" +"checksum take_mut 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f764005d11ee5f36500a149ace24e00e3da98b0158b3e2d53a7495660d3f4d60" +"checksum tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" +"checksum term 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "edd106a334b7657c10b7c540a0106114feadeb4dc314513e97df481d5d966f42" +"checksum termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "96d6098003bde162e4277c70665bd87c326f5a0c3f3fbfb285787fa482d54e6e" +"checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" +"checksum threadpool 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e2f0c90a5f3459330ac8bc0d2f879c693bb7a2f59689c1083fc4ef83834da865" +"checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" +"checksum tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)" = "5a09c0b5bb588872ab2f09afa13ee6e9dac11e10a0ec9e8e3ba39a5a5d530af6" +"checksum tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5c501eceaf96f0e1793cf26beb63da3d11c738c4a943fdf3746d81d64684c39f" +"checksum tokio-current-thread 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "d16217cad7f1b840c5a97dfb3c43b0c871fef423a6e8d2118c604e843662a443" +"checksum tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "0f27ee0e6db01c5f0b2973824547ce7e637b2ed79b891a9677b0de9bd532b6ac" +"checksum tokio-fs 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "3fe6dc22b08d6993916647d108a1a7d15b9cd29c4f4496c62b92c45b5041b7af" +"checksum tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "5090db468dad16e1a7a54c8c67280c5e4b544f3d3e018f0b913b400261f85926" +"checksum tokio-reactor 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "c56391be9805bc80163151c0b9e5164ee64f4b0200962c346fea12773158f22d" +"checksum tokio-signal 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "dd6dc5276ea05ce379a16de90083ec80836440d5ef8a6a39545a3207373b8296" +"checksum tokio-sync 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2162248ff317e2bc713b261f242b69dbb838b85248ed20bb21df56d60ea4cae7" +"checksum tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1d14b10654be682ac43efee27401d792507e30fd8d26389e1da3b185de2e4119" +"checksum tokio-threadpool 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "2bd2c6a3885302581f4401c82af70d792bb9df1700e7437b0aeb4ada94d5388c" +"checksum tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "f2106812d500ed25a4f38235b9cae8f78a09edf43203e16e59c3b769a342a60e" +"checksum tokio-udp 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f02298505547f73e60f568359ef0d016d5acd6e830ab9bc7c4a5b3403440121b" +"checksum tokio-uds 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "037ffc3ba0e12a0ab4aca92e5234e0dedeb48fddf6ccd260f1f150a36a9f2445" +"checksum toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "758664fc71a3a69038656bee8b6be6477d2a6c315a6b81f7081f591bffa4111f" +"checksum toml 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c7aabe75941d914b72bf3e5d3932ed92ce0664d49d8432305a8b547c37227724" +"checksum treeline 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a7f741b240f1a48843f9b8e0444fb55fb2a4ff67293b50a9179dfd5ea67f8d41" +"checksum trust-dns-proto 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5559ebdf6c2368ddd11e20b11d6bbaf9e46deb803acd7815e93f5a7b4a6d2901" +"checksum trust-dns-resolver 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6c9992e58dba365798803c0b91018ff6c8d3fc77e06977c4539af2a6bfe0a039" +"checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" +"checksum unicode-normalization 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "141339a08b982d942be2ca06ff8b076563cbe223d1befd5450716790d44e2426" +"checksum unicode-segmentation 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1967f4cdfc355b37fd76d2a954fb2ed3871034eb4f26d60537d88795cfc332a9" +"checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" +"checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" +"checksum unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56" +"checksum url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dd4e7c0d531266369519a4aa4f399d748bd37043b00bde1e4ff1f60a120b355a" +"checksum url 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "75b414f6c464c879d7f9babf951f23bc3743fb7313c081b2e6ca719067ea9d61" +"checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" +"checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" +"checksum wasi 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b89c3ce4ce14bdc6fb6beaf9ec7928ca331de5df7e5ea278375642a2f478570d" +"checksum wasm-bindgen 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)" = "cd34c5ba0d228317ce388e87724633c57edca3e7531feb4e25e35aaa07a656af" +"checksum wasm-bindgen-backend 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)" = "927196b315c23eed2748442ba675a4c54a1a079d90d9bdc5ad16ce31cf90b15b" +"checksum wasm-bindgen-futures 0.3.27 (registry+https://github.com/rust-lang/crates.io-index)" = "83420b37346c311b9ed822af41ec2e82839bfe99867ec6c54e2da43b7538771c" +"checksum wasm-bindgen-macro 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)" = "92c2442bf04d89792816650820c3fb407af8da987a9f10028d5317f5b04c2b4a" +"checksum wasm-bindgen-macro-support 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)" = "9c075d27b7991c68ca0f77fe628c3513e64f8c477d422b859e03f28751b46fc5" +"checksum wasm-bindgen-shared 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)" = "83d61fe986a7af038dd8b5ec660e5849cbd9f38e7492b9404cc48b2b4df731d1" +"checksum wasm-bindgen-test 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)" = "a2d9693b63a742d481c7f80587e057920e568317b2806988c59cd71618bc26c1" +"checksum wasm-bindgen-test-macro 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)" = "0789dac148a8840bbcf9efe13905463b733fa96543bfbf263790535c11af7ba5" +"checksum wasm-bindgen-webidl 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)" = "9b979afb0535fe4749906a674082db1211de8aef466331d43232f63accb7c07c" +"checksum web-sys 0.3.28 (registry+https://github.com/rust-lang/crates.io-index)" = "c84440699cd02ca23bed6f045ffb1497bc18a3c2628bd13e2093186faaaacf6b" +"checksum wee_alloc 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "dbb3b5a6b2bb17cb6ad44a2e68a43e8d2722c997da10e928665c72ec6c0a0b8e" +"checksum weedle 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3bb43f70885151e629e2a19ce9e50bd730fd436cfd4b666894c9ce4de9141164" +"checksum widestring 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "effc0e4ff8085673ea7b9b2e3c73f6bd4d118810c9009ed8f1e16bd96c331db6" +"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" +"checksum winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" +"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" +"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +"checksum winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7168bab6e1daee33b4557efd0e95d5ca70a03706d39fa5f3fe7a236f584b03c9" +"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +"checksum wincolor 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "96f5016b18804d24db43cebf3c77269e7569b8954a8464501c216cc5e070eaa9" +"checksum winreg 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b2986deb581c4fe11b621998a5e53361efe6b48a151178d0cd9eeffa4dc6acc9" +"checksum winutil 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7daf138b6b14196e3830a588acf1e86966c694d3e8fb026fb105b8b5dca07e6e" +"checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" +"checksum yaml-rust 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "65923dd1784f44da1d2c3dbbc5e822045628c590ba72123e1c73d3c230c4434d" From f281dee24588abf81e0c17301d08c7fc2a542d35 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 1 Oct 2019 12:28:36 +0300 Subject: [PATCH 685/735] RUN with and in Dockerfile and try tests on stable [run ci] --- .travis.yml | 14 ++++++-------- _build/geckodriver/Dockerfile | 28 ++++++++++++++-------------- 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/.travis.yml b/.travis.yml index dc0e811c7..b3f95d065 100644 --- a/.travis.yml +++ b/.travis.yml @@ -96,21 +96,19 @@ jobs: - name: unit medea-jason (nightly, Firefox) stage: test - # TODO: Run on stable when -Z install-upgrade is out, - # see: https://github.com/rust-lang/cargo/issues/6797 - rust: nightly + rust: stable before_script: - - cargo +nightly install wasm-bindgen-cli -Z install-upgrade + - cargo uninstall wasm-bindgen-cli + - cargo install wasm-bindgen-cli - rustup target add wasm32-unknown-unknown script: make test.unit crate=medea-jason webdriver=geckodriver - name: unit medea-jason (nightly, Chrome) stage: test - # TODO: Run on stable when -Z install-upgrade is out, - # see: https://github.com/rust-lang/cargo/issues/6797 - rust: nightly + rust: stable before_script: - - cargo +nightly install wasm-bindgen-cli -Z install-upgrade + - cargo uninstall wasm-bindgen-cli + - cargo install wasm-bindgen-cli - rustup target add wasm32-unknown-unknown script: make test.unit crate=medea-jason webdriver=chromedriver diff --git a/_build/geckodriver/Dockerfile b/_build/geckodriver/Dockerfile index 21552669a..d0af1ad42 100644 --- a/_build/geckodriver/Dockerfile +++ b/_build/geckodriver/Dockerfile @@ -3,20 +3,20 @@ FROM debian:stretch-slim ARG firefox_ver=latest ARG geckodriver_ver=v0.24.0 -RUN apt-get update && apt-get install -y wget tar bzip2 - -# Install dependencies for firefox binary -RUN apt-get install -y `apt-cache depends firefox-esr | awk '/Depends:/{print$2}'` -# Install firefox -RUN wget -O FirefoxSetup.tar.bz2 "https://download.mozilla.org/?product=firefox-${firefox_ver}&os=linux64&lang=en-US" -RUN tar xjf FirefoxSetup.tar.bz2 -RUN mv firefox /opt/firefox - -# Install geckodriver -RUN wget https://github.com/mozilla/geckodriver/releases/download/${geckodriver_ver}/geckodriver-${geckodriver_ver}-linux64.tar.gz -RUN tar -xvzf geckodriver* -RUN chmod +x geckodriver -RUN mv geckodriver /usr/bin +RUN apt-get update \ + && apt-get install -y \ + wget tar bzip2 \ + # Install dependencies for firefox binary + `apt-cache depends firefox-esr | awk '/Depends:/{print$2}'` \ + # Install firefox + && wget -O FirefoxSetup.tar.bz2 "https://download.mozilla.org/?product=firefox-${firefox_ver}&os=linux64&lang=en-US" \ + && tar xjf FirefoxSetup.tar.bz2 \ + && mv firefox /opt/firefox \ + # Install geckodriver + && wget https://github.com/mozilla/geckodriver/releases/download/${geckodriver_ver}/geckodriver-${geckodriver_ver}-linux64.tar.gz \ + && tar -xvzf geckodriver* \ + && chmod +x geckodriver \ + && mv geckodriver /usr/bin EXPOSE 4444 From f468d94a407965cd228fa3632bc0e518e4dc804c Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 1 Oct 2019 12:39:14 +0300 Subject: [PATCH 686/735] Don't return not 0 status code from uninstall [run ci] --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index b3f95d065..fb38de4c5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -98,7 +98,7 @@ jobs: stage: test rust: stable before_script: - - cargo uninstall wasm-bindgen-cli + - cargo uninstall wasm-bindgen-cli || echo > /dev/null - cargo install wasm-bindgen-cli - rustup target add wasm32-unknown-unknown script: make test.unit crate=medea-jason webdriver=geckodriver @@ -107,7 +107,7 @@ jobs: stage: test rust: stable before_script: - - cargo uninstall wasm-bindgen-cli + - cargo uninstall wasm-bindgen-cli || echo > /dev/null - cargo install wasm-bindgen-cli - rustup target add wasm32-unknown-unknown script: make test.unit crate=medea-jason webdriver=chromedriver From cce3adca2d87432171112179cd004d3f6ea5e281 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 1 Oct 2019 13:29:52 +0300 Subject: [PATCH 687/735] Ok, test only on chromedriver [run ci] --- .travis.yml | 9 --------- Makefile | 5 +++-- _build/geckodriver/Dockerfile | 6 +++--- 3 files changed, 6 insertions(+), 14 deletions(-) diff --git a/.travis.yml b/.travis.yml index fb38de4c5..50710e479 100644 --- a/.travis.yml +++ b/.travis.yml @@ -94,15 +94,6 @@ jobs: rust: stable script: make test.unit crate=medea - - name: unit medea-jason (nightly, Firefox) - stage: test - rust: stable - before_script: - - cargo uninstall wasm-bindgen-cli || echo > /dev/null - - cargo install wasm-bindgen-cli - - rustup target add wasm32-unknown-unknown - script: make test.unit crate=medea-jason webdriver=geckodriver - - name: unit medea-jason (nightly, Chrome) stage: test rust: stable diff --git a/Makefile b/Makefile index e884a0760..f6caeb2c6 100644 --- a/Makefile +++ b/Makefile @@ -294,7 +294,8 @@ endif # Run Rust unit tests of project. # # Usage: -# make test.unit [crate=(@all|medea|jason|)] webdriver=(chromedriver|geckodriver) +# make test.unit [crate=(@all|medea|jason|)] +# [webdriver=(chromedriver|geckodriver)] test-unit-crate = $(if $(call eq,$(crate),),@all,$(crate)) webdriver-env = $(if $(call eq,$(webdriver),geckodriver),GECKODRIVER_REMOTE,CHROMEDRIVER_REMOTE) @@ -313,7 +314,7 @@ ifeq ($(crate),medea-jason) @make docker.up.webdriver sleep 10 cd $(crate-dir)/ && \ - $(webdriver-env)="http://127.0.0.1:4444" \ + $(webdriver-env)="http://0.0.0.0:4444" \ cargo test --target wasm32-unknown-unknown --features mockable @make docker.down.webdriver endif diff --git a/_build/geckodriver/Dockerfile b/_build/geckodriver/Dockerfile index d0af1ad42..aa068b283 100644 --- a/_build/geckodriver/Dockerfile +++ b/_build/geckodriver/Dockerfile @@ -1,7 +1,7 @@ FROM debian:stretch-slim ARG firefox_ver=latest -ARG geckodriver_ver=v0.24.0 +ARG geckodriver_ver=v0.25.0 RUN apt-get update \ && apt-get install -y \ @@ -18,6 +18,6 @@ RUN apt-get update \ && chmod +x geckodriver \ && mv geckodriver /usr/bin -EXPOSE 4444 +ENTRYPOINT ["geckodriver", "-b", "/opt/firefox/firefox", "--log", "debug", "--host", "0.0.0.0"] -ENTRYPOINT ["geckodriver", "-b", "/opt/firefox/firefox", "--log", "debug"] +EXPOSE 4444 From 000630e2111ec6c9d0b8fd843c739ebab0caf45b Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 1 Oct 2019 13:31:26 +0300 Subject: [PATCH 688/735] Fix job name [run ci] --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 50710e479..6d62dc370 100644 --- a/.travis.yml +++ b/.travis.yml @@ -94,9 +94,10 @@ jobs: rust: stable script: make test.unit crate=medea - - name: unit medea-jason (nightly, Chrome) + - name: unit medea-jason (stable, Chrome) stage: test rust: stable + services: ["docker"] before_script: - cargo uninstall wasm-bindgen-cli || echo > /dev/null - cargo install wasm-bindgen-cli From 4e35407686aa8e1eaff9119df8960de9dd89b08b Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 1 Oct 2019 13:38:25 +0300 Subject: [PATCH 689/735] Fix running unit tests for other crates [run ci] --- Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile b/Makefile index f6caeb2c6..f77af5f2c 100644 --- a/Makefile +++ b/Makefile @@ -317,6 +317,9 @@ ifeq ($(crate),medea-jason) $(webdriver-env)="http://0.0.0.0:4444" \ cargo test --target wasm32-unknown-unknown --features mockable @make docker.down.webdriver +else + cd $(crate-dir)/ && \ + cargo test -p $(test-unit-crate) endif endif endif From 4c8e5e5bf6ff406ea15621ad7bb28df4bc67e239 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 1 Oct 2019 15:12:58 +0300 Subject: [PATCH 690/735] Add docs for docker.up.webdriver and docker.down.webdriver --- Makefile | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Makefile b/Makefile index f77af5f2c..c428bcc52 100644 --- a/Makefile +++ b/Makefile @@ -526,6 +526,11 @@ else endif +# Down dockerized webdriver. +# +# Usage: +# make docker.down.webdriver [webdriver=(chromedriver|geckodriver)] + docker.down.webdriver: ifeq ($(webdriver),geckodriver) docker container kill $$(cat /tmp/geckodriver.docker.uid) @@ -635,6 +640,11 @@ else endif +# Up dockerized webdriver. +# +# Usage: +# make docker.up.webdriver [webdriver=(chromedriver|geckodriver)] + docker.up.webdriver: ifeq ($(webdriver),geckodriver) docker build -t instrumentisto/medea-geckodriver:dev -f _build/geckodriver/Dockerfile . From c3a950dbbb4fa999808242e6bda4d0371321a32f Mon Sep 17 00:00:00 2001 From: alexlapa Date: Thu, 3 Oct 2019 02:42:49 +0300 Subject: [PATCH 691/735] refactor [run ci] --- .travis.yml | 7 ++-- Dockerfile | 28 +++++++++---- Makefile | 76 +++++++++++++---------------------- _build/geckodriver/Dockerfile | 23 ----------- _build/medea-build/Dockerfile | 7 ---- jason/Cargo.toml | 4 +- jason/tests/peer/mod.rs | 20 --------- proto/client-api/src/lib.rs | 2 +- 8 files changed, 56 insertions(+), 111 deletions(-) delete mode 100644 _build/geckodriver/Dockerfile delete mode 100644 _build/medea-build/Dockerfile diff --git a/.travis.yml b/.travis.yml index 6d62dc370..6b1d84c2e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -51,7 +51,6 @@ jobs: stage: build rust: stable services: ["docker"] - before_script: make docker.build.medea-build script: make docker.build.medea debug=no TAG=build-${TRAVIS_BUILD_ID} registry=quay.io before_deploy: echo "$QUAYIO_PASS" @@ -94,7 +93,7 @@ jobs: rust: stable script: make test.unit crate=medea - - name: unit medea-jason (stable, Chrome) + - name: unit medea-jason (stable, Chrome, Firefox) stage: test rust: stable services: ["docker"] @@ -102,7 +101,9 @@ jobs: - cargo uninstall wasm-bindgen-cli || echo > /dev/null - cargo install wasm-bindgen-cli - rustup target add wasm32-unknown-unknown - script: make test.unit crate=medea-jason webdriver=chromedriver + script: + - make test.unit crate=medea-jason browser=chrome + - make test.unit crate=medea-jason browser=firefox - name: E2E signalling (stable) stage: test diff --git a/Dockerfile b/Dockerfile index 99cdc1467..f9affeb0c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,11 +8,10 @@ # # https://hub.docker.com/_/rust -ARG medea_build_image=instrumentisto/medea-build:latest -FROM ${medea_build_image} AS dist +ARG rust_ver=latest +FROM rust:${rust_ver} AS dist ARG rustc_mode=release ARG rustc_opts=--release -ARG cargo_home=/usr/local/cargo # Create user and group files, which will be used in a running container to # run the process as an unprivileged user. @@ -20,15 +19,28 @@ RUN mkdir -p /out/etc/ \ && echo 'nobody:x:65534:65534:nobody:/:' > /out/etc/passwd \ && echo 'nobody:x:65534:' > /out/etc/group -COPY / /app/ +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + cmake -# Build project distribution. +COPY crates /app/crates/ +COPY proto /app/proto/ +COPY jason/Cargo.toml /app/jason/ +COPY Cargo.toml Cargo.lock /app/ + +RUN cd /app \ + && mkdir -p src && touch src/lib.rs \ + && mkdir -p jason/src && touch jason/src/lib.rs \ + && cargo fetch + +COPY src app/src + +## Build project distribution. RUN cd /app \ - # Compile project. - && CARGO_HOME="${cargo_home}" \ + # Compile project. # TODO: use --out-dir once stabilized # TODO: https://github.com/rust-lang/cargo/issues/6790 - cargo build --bin=medea ${rustc_opts} \ + && cargo build --bin=medea ${rustc_opts} \ # Prepare the binary and all dependent dynamic libraries. && cp /app/target/${rustc_mode}/medea /out/medea \ && ldd /out/medea \ diff --git a/Makefile b/Makefile index c428bcc52..5056402d7 100644 --- a/Makefile +++ b/Makefile @@ -18,10 +18,10 @@ eq = $(if $(or $(1),$(2)),$(and $(findstring $(1),$(2)),\ MEDEA_IMAGE_NAME := $(strip \ $(shell grep 'COMPOSE_IMAGE_NAME=' .env | cut -d '=' -f2)) DEMO_IMAGE_NAME := instrumentisto/medea-demo -MEDEA_BUILD_IMAGE_NAME := alexlapa/medea-build -MEDEA_BUILD_IMAGE_VER := latest RUST_VER := 1.37 +CHROME_VERSION := 77.0 +FIREFOX_VERSION := 69.0 CURRENT_BRANCH := $(strip $(shell git branch | grep \* | cut -d ' ' -f2)) @@ -177,7 +177,6 @@ cargo: # [dockerized=(no|yes)] cargo-build-crate = $(if $(call eq,$(crate),),@all,$(crate)) -medea-build-image = $(MEDEA_BUILD_IMAGE_NAME):$(MEDEA_BUILD_IMAGE_VER) cargo.build: ifeq ($(cargo-build-crate),@all) @@ -189,7 +188,7 @@ ifeq ($(dockerized),yes) docker run --rm -v "$(PWD)":/app -w /app \ -u $(shell id -u):$(shell id -g) \ -v "$(HOME)/.cargo/registry":/usr/local/cargo/registry \ - $(medea-build-image) \ + rust:$(RUST_VER) \ make cargo.build crate=$(cargo-build-crate) \ debug=$(debug) dockerized=no else @@ -203,10 +202,14 @@ ifeq ($(dockerized),yes) -v "$(HOME)/.cargo/registry":/usr/local/cargo/registry \ -v "$(HOME):$(HOME)" \ -e XDG_CACHE_HOME=$(HOME) \ - $(medea-build-image) \ + rust:$(RUST_VER) \ make cargo.build crate=$(cargo-build-crate) \ - debug=$(debug) dockerized=no + debug=$(debug) dockerized=no \ + pre-install=yes else +ifeq ($(pre-install),yes) + curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh +endif @rm -rf $(crate-dir)/pkg/ wasm-pack build -t web $(crate-dir)/ endif @@ -294,11 +297,11 @@ endif # Run Rust unit tests of project. # # Usage: -# make test.unit [crate=(@all|medea|jason|)] -# [webdriver=(chromedriver|geckodriver)] +# make test.unit [crate=(@all|medea|medea-jason|)] +# [browser=(chrome|firefox)] test-unit-crate = $(if $(call eq,$(crate),),@all,$(crate)) -webdriver-env = $(if $(call eq,$(webdriver),geckodriver),GECKODRIVER_REMOTE,CHROMEDRIVER_REMOTE) +driver-env = $(if $(call eq,$(browser),firefox),GECKODRIVER_REMOTE,CHROMEDRIVER_REMOTE) test.unit: ifeq ($(test-unit-crate),@all) @@ -314,7 +317,7 @@ ifeq ($(crate),medea-jason) @make docker.up.webdriver sleep 10 cd $(crate-dir)/ && \ - $(webdriver-env)="http://0.0.0.0:4444" \ + $(driver-env)="http://0.0.0.0:4444" \ cargo test --target wasm32-unknown-unknown --features mockable @make docker.down.webdriver else @@ -439,19 +442,6 @@ else endif -# Build Docker image for medea building. -# -# Usage: -# make docker.build.medea-build [TAG=(dev|)] - -docker.build.medea-build: - docker build \ - --build-arg rust_ver=$(RUST_VER) \ - -t $(MEDEA_BUILD_IMAGE_NAME):$(if $(call eq,$(TAG),),dev,$(TAG)) \ - - < _build/medea-build/Dockerfile - - - # Build medea project Docker image. # # Usage: @@ -462,17 +452,8 @@ docker.build.medea-build: docker-build-medea-image-name = $(strip \ $(if $(call eq,$(registry),),,$(registry)/)$(MEDEA_IMAGE_NAME)) -medea-build-image = $(MEDEA_BUILD_IMAGE_NAME):$(MEDEA_BUILD_IMAGE_VER) docker.build.medea: -ifneq ($(no-cache),yes) - docker run --rm --network=host -v "$(PWD)":/app -w /app \ - -u $(shell id -u):$(shell id -g) \ - -e CARGO_HOME=.cache/cargo \ - $(medea-build-image) \ - cargo build --bin=medea \ - $(if $(call eq,$(debug),no),--release,) -endif $(call docker.build.clean.ignore) @echo "!target/$(if $(call eq,$(debug),no),release,debug)/" >> .dockerignore $(docker-env) \ @@ -480,10 +461,11 @@ endif $(if $(call eq,$(no-cache),yes),\ --no-cache --pull,) \ $(if $(call eq,$(IMAGE),),\ - --build-arg rustc_mode=$(if $(call eq,$(debug),no),release,debug) \ - --build-arg rustc_opts=$(if $(call eq,$(debug),no),--release,) \ - --build-arg cargo_home=.cache/cargo,) \ - --build-arg medea_build_image=$(medea-build-image) \ + --build-arg rust_ver=$(RUST_VER) \ + --build-arg rustc_mode=$(if \ + $(call eq,$(debug),no),release,debug) \ + --build-arg rustc_opts=$(if \ + $(call eq,$(debug),no),--release,)) \ -t $(docker-build-medea-image-name):$(if $(call eq,$(TAG),),dev,$(TAG)) . $(call docker.build.clean.ignore) define docker.build.clean.ignore @@ -529,15 +511,13 @@ endif # Down dockerized webdriver. # # Usage: -# make docker.down.webdriver [webdriver=(chromedriver|geckodriver)] +# make docker.down.webdriver [browser=(chrome|firefox)] docker.down.webdriver: -ifeq ($(webdriver),geckodriver) - docker container kill $$(cat /tmp/geckodriver.docker.uid) - rm -f /tmp/geckodriver.docker.uid +ifeq ($(browser),firefox) + -docker stop medea-test-ff else - docker container kill $$(cat /tmp/chromedriver.docker.uid) - rm -f /tmp/chromedriver.docker.uid + -docker stop medea-test-chrome endif @@ -643,14 +623,16 @@ endif # Up dockerized webdriver. # # Usage: -# make docker.up.webdriver [webdriver=(chromedriver|geckodriver)] +# make docker.up.webdriver [browser=(chrome|firefox)] docker.up.webdriver: -ifeq ($(webdriver),geckodriver) - docker build -t instrumentisto/medea-geckodriver:dev -f _build/geckodriver/Dockerfile . - docker run --rm -d --network=host instrumentisto/medea-geckodriver:dev > /tmp/geckodriver.docker.uid + @make docker.down.webdriver browser=$(browser) +ifeq ($(browser),firefox) + docker run --rm -d --shm-size 128m --name medea-test-ff \ + --network=host alexlapa/geckodriver:${FIREFOX_VERSION} else - docker run --rm -d --network=host selenoid/chrome:latest > /tmp/chromedriver.docker.uid + docker run --rm -d --name medea-test-chrome \ + --network=host selenoid/chrome:$(CHROME_VERSION) endif diff --git a/_build/geckodriver/Dockerfile b/_build/geckodriver/Dockerfile deleted file mode 100644 index aa068b283..000000000 --- a/_build/geckodriver/Dockerfile +++ /dev/null @@ -1,23 +0,0 @@ -FROM debian:stretch-slim - -ARG firefox_ver=latest -ARG geckodriver_ver=v0.25.0 - -RUN apt-get update \ - && apt-get install -y \ - wget tar bzip2 \ - # Install dependencies for firefox binary - `apt-cache depends firefox-esr | awk '/Depends:/{print$2}'` \ - # Install firefox - && wget -O FirefoxSetup.tar.bz2 "https://download.mozilla.org/?product=firefox-${firefox_ver}&os=linux64&lang=en-US" \ - && tar xjf FirefoxSetup.tar.bz2 \ - && mv firefox /opt/firefox \ - # Install geckodriver - && wget https://github.com/mozilla/geckodriver/releases/download/${geckodriver_ver}/geckodriver-${geckodriver_ver}-linux64.tar.gz \ - && tar -xvzf geckodriver* \ - && chmod +x geckodriver \ - && mv geckodriver /usr/bin - -ENTRYPOINT ["geckodriver", "-b", "/opt/firefox/firefox", "--log", "debug", "--host", "0.0.0.0"] - -EXPOSE 4444 diff --git a/_build/medea-build/Dockerfile b/_build/medea-build/Dockerfile deleted file mode 100644 index 96cdab1cc..000000000 --- a/_build/medea-build/Dockerfile +++ /dev/null @@ -1,7 +0,0 @@ -# https://hub.docker.com/_/rust -ARG rust_ver=latest -FROM rust:${rust_ver} AS dist - -RUN apt-get update \ - && apt-get install -y cmake \ - && curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh diff --git a/jason/Cargo.toml b/jason/Cargo.toml index 113fe32d2..0cae78712 100644 --- a/jason/Cargo.toml +++ b/jason/Cargo.toml @@ -37,7 +37,7 @@ newtype_derive = "0.1" predicates-tree = { version = "1.0", optional = true } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" -wasm-bindgen = { version = "=0.2.51", features = ["serde-serialize"] } +wasm-bindgen = { version = "0.2", features = ["serde-serialize"] } wasm-bindgen-futures = "0.3" wee_alloc = { version = "0.4", optional = true } [dependencies.web-sys] @@ -55,4 +55,4 @@ wee_alloc = { version = "0.4", optional = true } ] [dev-dependencies] -wasm-bindgen-test = "=0.2" +wasm-bindgen-test = "0.2" diff --git a/jason/tests/peer/mod.rs b/jason/tests/peer/mod.rs index b7742072a..fc5c4c9aa 100644 --- a/jason/tests/peer/mod.rs +++ b/jason/tests/peer/mod.rs @@ -23,26 +23,6 @@ use crate::{get_test_tracks, resolve_after}; wasm_bindgen_test_configure!(run_in_browser); -/// TODO: enable tests in firefox, PR: rustwasm/wasm-bindgen#1744 -// firefoxOptions.prefs: -// let request = json!({ -// "capabilities": { -// "alwaysMatch": { -// "moz:firefoxOptions": { -// "prefs": { -// "media.navigator.streams.fake": true, -// "media.navigator.permission.disabled": true, -// "media.autoplay.enabled": true, -// "media.autoplay.enabled.user-gestures-needed ": false, -// "media.autoplay.ask-permission": false, -// "media.autoplay.default": 0, -// }, -// "args": args, -// } -// } -// } -// }); - #[wasm_bindgen_test(async)] fn mute_unmute_audio() -> impl Future { let (tx, _rx) = mpsc::unbounded(); diff --git a/proto/client-api/src/lib.rs b/proto/client-api/src/lib.rs index 6056e5888..654a7bad2 100644 --- a/proto/client-api/src/lib.rs +++ b/proto/client-api/src/lib.rs @@ -140,7 +140,7 @@ pub enum RpcConnectionCloseReason { Evicted, /// Member reconnects and old connection was closed. - ConnectionSwapped, + NewConnection, } /// Description which will be sent in Close WebSocket frame. From 68dc6f174f571dfef14749070ad190239beac1e1 Mon Sep 17 00:00:00 2001 From: alexlapa Date: Thu, 3 Oct 2019 14:48:55 +0300 Subject: [PATCH 692/735] alexlapa/geckodriver => instrumentisto/geckodriver --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 5056402d7..15b5ffa48 100644 --- a/Makefile +++ b/Makefile @@ -629,7 +629,7 @@ docker.up.webdriver: @make docker.down.webdriver browser=$(browser) ifeq ($(browser),firefox) docker run --rm -d --shm-size 128m --name medea-test-ff \ - --network=host alexlapa/geckodriver:${FIREFOX_VERSION} + --network=host instrumentisto/geckodriver:${FIREFOX_VERSION} else docker run --rm -d --name medea-test-chrome \ --network=host selenoid/chrome:$(CHROME_VERSION) From ee75e3f993d5d2831b39a97efb0a39d0bc251638 Mon Sep 17 00:00:00 2001 From: alexlapa Date: Thu, 3 Oct 2019 15:02:12 +0300 Subject: [PATCH 693/735] alexlapa/geckodriver => instrumentisto/geckodriver --- Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 15b5ffa48..3fc762bfa 100644 --- a/Makefile +++ b/Makefile @@ -625,8 +625,7 @@ endif # Usage: # make docker.up.webdriver [browser=(chrome|firefox)] -docker.up.webdriver: - @make docker.down.webdriver browser=$(browser) +docker.up.webdriver: docker.down.webdriver ifeq ($(browser),firefox) docker run --rm -d --shm-size 128m --name medea-test-ff \ --network=host instrumentisto/geckodriver:${FIREFOX_VERSION} From e2ca89a9efa03f37f2b1ba9848ed75b1b8ecb83f Mon Sep 17 00:00:00 2001 From: alexlapa Date: Thu, 3 Oct 2019 15:05:52 +0300 Subject: [PATCH 694/735] instrumentisto/geckodriver shm = 512 --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 3fc762bfa..81af3b72f 100644 --- a/Makefile +++ b/Makefile @@ -627,7 +627,7 @@ endif docker.up.webdriver: docker.down.webdriver ifeq ($(browser),firefox) - docker run --rm -d --shm-size 128m --name medea-test-ff \ + docker run --rm -d --shm-size 512m --name medea-test-ff \ --network=host instrumentisto/geckodriver:${FIREFOX_VERSION} else docker run --rm -d --name medea-test-chrome \ From 3c5bc6c227b40c676b7a1d325c2723368d9d63a1 Mon Sep 17 00:00:00 2001 From: tyranron Date: Tue, 8 Oct 2019 10:07:55 +0200 Subject: [PATCH 695/735] Toolchain corrections --- .clippy.toml | 3 +- .dockerignore | 2 - .env | 2 +- .rustfmt.toml | 2 - CHANGELOG.md | 5 +- CONTRIBUTING.md | 8 +- Dockerfile | 57 ++++--- Makefile | 75 ++++----- _dev/config.toml | 2 +- config.toml | 87 ++++------ docker-compose.medea.yml | 4 +- .../demo/chart/medea-demo/conf/nginx.vh.conf | 8 +- .../templates/deployment.server.yaml | 2 - jason/demo/chart/medea-demo/values.yaml | 2 +- jason/demo/minikube.vals.yaml | 2 +- jason/demo/staging.vals.yaml | 2 +- proto/client-api/CHANGELOG.md | 2 +- proto/client-api/src/lib.rs | 12 +- proto/control-api/CHANGELOG.md | 27 +-- proto/control-api/Cargo.toml | 7 +- proto/control-api/README.md | 13 +- proto/control-api/build.rs | 14 +- .../src/grpc/{control_api.proto => api.proto} | 0 .../src/grpc/{control_api.rs => api.rs} | 158 +++++++++--------- .../grpc/{control_api_grpc.rs => api_grpc.rs} | 48 +++--- proto/control-api/src/grpc/mod.rs | 4 +- proto/control-api/src/lib.rs | 1 + src/api/control/endpoints/mod.rs | 4 +- .../control/endpoints/webrtc_play_endpoint.rs | 4 +- .../endpoints/webrtc_publish_endpoint.rs | 2 +- src/api/control/error_codes.rs | 2 +- src/api/control/grpc/server.rs | 4 +- src/api/control/member.rs | 2 +- src/api/control/room.rs | 2 +- src/signalling/elements/endpoints/mod.rs | 2 +- .../endpoints/webrtc/play_endpoint.rs | 2 +- .../endpoints/webrtc/publish_endpoint.rs | 2 +- src/signalling/elements/member.rs | 2 +- src/signalling/participants.rs | 2 +- src/signalling/room.rs | 2 +- src/signalling/room_service.rs | 2 +- tests/e2e/grpc_control_api/create.rs | 2 +- tests/e2e/grpc_control_api/signaling.rs | 2 +- 43 files changed, 288 insertions(+), 299 deletions(-) rename proto/control-api/src/grpc/{control_api.proto => api.proto} (100%) rename proto/control-api/src/grpc/{control_api.rs => api.rs} (97%) rename proto/control-api/src/grpc/{control_api_grpc.rs => api_grpc.rs} (54%) diff --git a/.clippy.toml b/.clippy.toml index 34d811afe..63a37652e 100644 --- a/.clippy.toml +++ b/.clippy.toml @@ -8,11 +8,12 @@ doc-valid-idents = [ "IPv4", "IPv6", "JavaScript", "NaN", "NaNs", "OAuth", "OpenGL", "OpenSSH", "OpenSSL", "OpenStreetMap", "TrueType", "iOS", "macOS", "TeX", "LaTeX", "BibTeX", "BibLaTeX", "MinGW", - "gRPC", "WebRTC", "WebSocket", + "gRPC", "MediaStream", "MediaStreamConstraints", "MediaStreamTrack", "RTCConfiguration", "RTCIceCandidate", "RTCIceCandidateInit", "RTCIceServer", "RTCPeerConnection", "RTCPeerConnectionIceEvent", "RTCRtpTransceiver", "RTCRtpTransceiverDirection", "RTCSdpType", + "WebRTC", "WebSocket", ] diff --git a/.dockerignore b/.dockerignore index efcb829f2..cd76adbc7 100644 --- a/.dockerignore +++ b/.dockerignore @@ -21,5 +21,3 @@ # Makefile may be used in Dockerfile's. !Makefile - -# !target/{mode} is added and removed dynamically to reduce image build times. diff --git a/.env b/.env index 353dbda31..239083bed 100644 --- a/.env +++ b/.env @@ -1,7 +1,7 @@ RUST_LOG=debug MEDEA_CONF=_dev/config.toml -MEDEA_CONTROL_API__STATIC_SPECS_DIR=_dev/specs/ +MEDEA_CONTROL_STATIC_SPECS_DIR=_dev/specs/ COMPOSE_PROJECT_NAME=medea COMPOSE_IMAGE_NAME=instrumentisto/medea diff --git a/.rustfmt.toml b/.rustfmt.toml index 036432c26..2051bcb37 100644 --- a/.rustfmt.toml +++ b/.rustfmt.toml @@ -1,8 +1,6 @@ # See full list at: # https://github.com/rust-lang-nursery/rustfmt/blob/master/Configurations.md -ignore = ["proto/control-api/src/grpc"] - max_width = 80 format_strings = true merge_imports = true diff --git a/CHANGELOG.md b/CHANGELOG.md index c29115205..42a8d8e7c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,7 +15,7 @@ All user visible changes to this project will be documented in this file. This p - Control API: - Support for static Сontrol API specs ([#28]). - - Dynamic Control API exposed via gRPC ([#33](/../../pull/33)): + - Dynamic Control API exposed via gRPC ([#33]): - `Create` method for `Room`, `Member`, `Endpoint`; - `Get` method for `Room`, `Member`, `Endpoint`; - `Delete` method for `Room`, `Member`, `Endpoint`. @@ -23,11 +23,12 @@ All user visible changes to this project will be documented in this file. This p - Dynamic `Peer`s creation when client connects ([#28]); - Auto-removing `Peer`s when `Member` disconnects ([#28]); - Filter `SetIceCandidate` messages without `candidate` ([#50](/../../pull/50)); - - Send reason of WebSocket close by server as close frame's description. + - Reason of WebSocket closing by server as `Close` frame's description ([#33]). - Testing: - E2E tests for signalling ([#28]). [#28]: /../../pull/28 +[#33]: /../../pull/33 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 986aaf196..b7700d2ff 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -18,7 +18,7 @@ Also, you need install [wasm-pack] for [Jason] building and testing: $ curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sudo sh ``` -[Protoc] if you want to rebuild protobuf specs for [Medea]'s gRPC Control API. +Also, you need install `protoc` if you want to rebuild [protobuf] specs for [Medea] gRPC Control API. @@ -66,9 +66,9 @@ $ make build.jason $ make build.jason dockerized=yes ``` -To rebuild protobuf specs for [Medea]'s gRPC Control API: +To rebuild [protobuf] specs for [Medea] gRPC Control API: ```bash -$ make protoc.rebuild +$ make cargo.gen crate=medea-control-api-proto ``` @@ -133,7 +133,7 @@ Add `[run ci]` mark to your commit message for triggering CI build. [Clippy]: https://github.com/rust-lang/rust-clippy [Jason]: https://github.com/instrumentisto/medea/tree/master/jason [Medea]: https://github.com/instrumentisto/medea +[protobuf]: https://github.com/protocolbuffers/protobuf [Rust]: https://www.rust-lang.org [rustfmt]: https://github.com/rust-lang/rustfmt [wasm-pack]: https://github.com/rustwasm/wasm-pack -[Protoc]: https://github.com/protocolbuffers/protobuf diff --git a/Dockerfile b/Dockerfile index f9affeb0c..37435f4f3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,30 +19,47 @@ RUN mkdir -p /out/etc/ \ && echo 'nobody:x:65534:65534:nobody:/:' > /out/etc/passwd \ && echo 'nobody:x:65534:' > /out/etc/group +# Install required system packages for building. RUN apt-get update \ && apt-get install -y --no-install-recommends \ - cmake - -COPY crates /app/crates/ -COPY proto /app/proto/ + cmake + +# Prepare Cargo workspace for building dependencies only. +COPY crates/medea-macro/Cargo.toml /app/crates/medea-macro/ +COPY proto/client-api/Cargo.toml /app/proto/client-api/ +COPY proto/control-api/Cargo.toml /app/proto/control-api/ +# Required to omit triggering re-compilation for build.rs. +COPY proto/control-api/build.rs /app/proto/control-api/ +COPY proto/control-api/src/grpc/api.proto \ + proto/control-api/src/grpc/api*.rs \ + /app/proto/control-api/src/grpc/ COPY jason/Cargo.toml /app/jason/ COPY Cargo.toml Cargo.lock /app/ - -RUN cd /app \ - && mkdir -p src && touch src/lib.rs \ - && mkdir -p jason/src && touch jason/src/lib.rs \ - && cargo fetch - -COPY src app/src - -## Build project distribution. -RUN cd /app \ - # Compile project. - # TODO: use --out-dir once stabilized - # TODO: https://github.com/rust-lang/cargo/issues/6790 - && cargo build --bin=medea ${rustc_opts} \ - # Prepare the binary and all dependent dynamic libraries. - && cp /app/target/${rustc_mode}/medea /out/medea \ +WORKDIR /app/ +RUN mkdir -p crates/medea-macro/src/ && touch crates/medea-macro/src/lib.rs \ + && mkdir -p proto/client-api/src/ && touch proto/client-api/src/lib.rs \ + && mkdir -p proto/control-api/src/ && touch proto/control-api/src/lib.rs \ + && mkdir -p jason/src/ && touch jason/src/lib.rs \ + && mkdir -p src/ && touch src/lib.rs + +# Build dependencies only. +RUN cargo build --lib ${rustc_opts} +# Remove fingreprints of pre-built empty project sub-crates +# to rebuild them correctly later. +RUN rm -rf /app/target/${rustc_mode}/.fingerprint/medea* + +# Prepare project sources for building. +COPY crates/ /app/crates/ +COPY proto/ /app/proto/ +COPY src/ /app/src/ + +# Build project distribution binary. +# TODO: use --out-dir once stabilized +# TODO: https://github.com/rust-lang/cargo/issues/6790 +RUN cargo build --bin=medea ${rustc_opts} + +# Prepare project distribution binary and all dependent dynamic libraries. +RUN cp /app/target/${rustc_mode}/medea /out/medea \ && ldd /out/medea \ | awk 'BEGIN{ORS=" "}$1~/^\//{print $1}$3~/^\//{print $3}' \ | sed 's/,$/\n/' \ diff --git a/Makefile b/Makefile index 81af3b72f..3accf3be4 100644 --- a/Makefile +++ b/Makefile @@ -23,7 +23,7 @@ RUST_VER := 1.37 CHROME_VERSION := 77.0 FIREFOX_VERSION := 69.0 -CURRENT_BRANCH := $(strip $(shell git branch | grep \* | cut -d ' ' -f2)) +CURRENT_GIT_BRANCH := $(strip $(shell git branch | grep \* | cut -d ' ' -f2)) crate-dir = . ifeq ($(crate),medea-jason) @@ -32,6 +32,9 @@ endif ifeq ($(crate),medea-client-api-proto) crate-dir = proto/client-api endif +ifeq ($(crate),medea-control-api-proto) +crate-dir = proto/control-api +endif ifeq ($(crate),medea-macro) crate-dir = crates/medea-macro endif @@ -225,6 +228,19 @@ cargo.fmt: cargo +nightly fmt --all $(if $(call eq,$(check),yes),-- --check,) +# Generate Rust sources with Cargo's build.rs script. +# +# Usage: +# make cargo.gen crate=medea-control-api-proto + +cargo.gen: +ifeq ($(crate),medea-control-api-proto) + rm -rf $(crate-dir)/src/grpc/api*.rs + cd $(crate-dir)/ && \ + cargo build +endif + + # Lint Rust sources with clippy. # # Usage: @@ -297,11 +313,11 @@ endif # Run Rust unit tests of project. # # Usage: -# make test.unit [crate=(@all|medea|medea-jason|)] -# [browser=(chrome|firefox)] +# make test.unit [crate=(@all|medea|)] +# [crate=medea-jason [browser=(chrome|firefox)]] test-unit-crate = $(if $(call eq,$(crate),),@all,$(crate)) -driver-env = $(if $(call eq,$(browser),firefox),GECKODRIVER_REMOTE,CHROMEDRIVER_REMOTE) +webdriver-env = $(if $(call eq,$(browser),firefox),GECKO,CHROME)DRIVER_REMOTE test.unit: ifeq ($(test-unit-crate),@all) @@ -317,8 +333,8 @@ ifeq ($(crate),medea-jason) @make docker.up.webdriver sleep 10 cd $(crate-dir)/ && \ - $(driver-env)="http://0.0.0.0:4444" \ - cargo test --target wasm32-unknown-unknown --features mockable + $(webdriver-env)="http://0.0.0.0:4444" \ + cargo test --target wasm32-unknown-unknown --features mockable @make docker.down.webdriver else cd $(crate-dir)/ && \ @@ -340,7 +356,7 @@ endif test-e2e-env = RUST_BACKTRACE=1 \ $(if $(call eq,$(log),yes),,RUST_LOG=warn) \ - MEDEA_CONTROL_API__STATIC_SPECS_DIR=tests/specs/ + MEDEA_CONTROL__STATIC_SPECS_DIR=tests/specs/ test.e2e: ifeq ($(up),yes) @@ -454,8 +470,6 @@ docker-build-medea-image-name = $(strip \ $(if $(call eq,$(registry),),,$(registry)/)$(MEDEA_IMAGE_NAME)) docker.build.medea: - $(call docker.build.clean.ignore) - @echo "!target/$(if $(call eq,$(debug),no),release,debug)/" >> .dockerignore $(docker-env) \ docker build $(if $(call eq,$(minikube),yes),,--network=host) --force-rm \ $(if $(call eq,$(no-cache),yes),\ @@ -465,13 +479,9 @@ docker.build.medea: --build-arg rustc_mode=$(if \ $(call eq,$(debug),no),release,debug) \ --build-arg rustc_opts=$(if \ - $(call eq,$(debug),no),--release,)) \ + $(call eq,$(debug),no),--release,),) \ -t $(docker-build-medea-image-name):$(if $(call eq,$(TAG),),dev,$(TAG)) . $(call docker.build.clean.ignore) -define docker.build.clean.ignore - @sed -i $(if $(call eq,$(shell uname -s),Darwin),'',) \ - /^!target\/d .dockerignore -endef # Stop Coturn STUN/TURN server in Docker Compose environment @@ -508,17 +518,14 @@ else endif -# Down dockerized webdriver. +# Stop dockerized WebDriver and remove all related containers. # # Usage: # make docker.down.webdriver [browser=(chrome|firefox)] docker.down.webdriver: -ifeq ($(browser),firefox) - -docker stop medea-test-ff -else - -docker stop medea-test-chrome -endif + -docker stop medea-webdriver-$(if $(call eq,$(browser),)chrome,$(browser)) + -docker rm medea-webdriver-$(if $(call eq,$(browser),)chrome,$(browser)) # Pull project Docker images from Container Registry. @@ -620,17 +627,17 @@ else endif -# Up dockerized webdriver. +# Run dockerized WebDriver. # # Usage: # make docker.up.webdriver [browser=(chrome|firefox)] docker.up.webdriver: docker.down.webdriver ifeq ($(browser),firefox) - docker run --rm -d --shm-size 512m --name medea-test-ff \ - --network=host instrumentisto/geckodriver:${FIREFOX_VERSION} + docker run --rm -d --shm-size 512m --name medea-webdriver-firefox \ + --network=host instrumentisto/geckodriver:$(FIREFOX_VERSION) else - docker run --rm -d --name medea-test-chrome \ + docker run --rm -d --name medea-webdriver-chrome \ --network=host selenoid/chrome:$(CHROME_VERSION) endif @@ -741,7 +748,7 @@ endif git add -v charts/ ; \ git commit -m "Release '$(helm-chart)' Helm chart" ; \ fi - git checkout $(CURRENT_BRANCH) + git checkout $(CURRENT_GIT_BRANCH) git push origin gh-pages @@ -813,27 +820,12 @@ endef -################### -# Protoc commands # -################### - -# Rebuild gRPC protobuf specs for medea-control-api-proto. -# -# Usage: -# make protoc.rebuild - -protoc.rebuild: - rm -f proto/control-api/src/grpc/control_api*.rs - cargo build -p medea-control-api-proto - - - ################## # .PHONY section # ################## .PHONY: build build.jason build.medea \ - cargo cargo.build cargo.fmt cargo.lint \ + cargo cargo.build cargo.fmt cargo.gen cargo.lint \ docker.auth docker.build.demo docker.build.medea \ docker.down.coturn docker.down.demo docker.down.medea \ docker.down.webdriver \ @@ -845,7 +837,6 @@ protoc.rebuild: helm helm.down helm.init helm.lint helm.list \ helm.package helm.package.release helm.up \ minikube.boot \ - protoc.rebuild \ release release.crates release.helm release.npm \ test test.e2e test.unit \ up up.coturn up.demo up.dev up.jason up.medea \ diff --git a/_dev/config.toml b/_dev/config.toml index c0cb3272d..95a873013 100644 --- a/_dev/config.toml +++ b/_dev/config.toml @@ -1,2 +1,2 @@ -[control_api] +[control] static_specs_dir = "_dev/specs/" diff --git a/config.toml b/config.toml index d3b591a78..c68f5621c 100644 --- a/config.toml +++ b/config.toml @@ -1,54 +1,45 @@ [server.client] -# Server's public URL. -# -# Environment variable: MEDEA_SERVER__CLIENT__PUBLIC_URL +# Client API server's public URL. +# It's assumed that severs can be reached via this URL externally. # +# Env var: MEDEA_SERVER__CLIENT__PUBLIC_URL # Default: -# public_url = "ws://0.0.0.0:8080" +# public_url = "ws://127.0.0.1:8080" [server.client.http] -# IP address to bind HTTP server to. -# -# Environment variable: MEDEA_SERVER__CLIENT__HTTP__BIND_IP +# IP address to bind Client API HTTP server to. # +# Env var: MEDEA_SERVER__CLIENT__HTTP__BIND_IP # Default: # bind_ip = "0.0.0.0" -# Port to bind HTTP server to. -# -# Environment variable: MEDEA_SERVER__CLIENT__HTTP__BIND_PORT +# Port to bind Client API HTTP server to. # +# Env var: MEDEA_SERVER__CLIENT__HTTP__BIND_PORT # Default: # bind_port = 8080 + [server.control.grpc] -# IP address to bind gRPC server to. -# -# Environment variable: MEDEA_SERVER__CONTROL__GRPC__BIND_IP +# IP address to bind Control API gRPC server to. # +# Env var: MEDEA_SERVER__CONTROL__GRPC__BIND_IP # Default: # bind_ip = "0.0.0.0" -# Port to bind gRPC server to. -# -# Environment variable: MEDEA_SERVER__CONTROL__GRPC__BIND_PORT +# Port to bind Control API gRPC server to. # +# Env var: MEDEA_SERVER__CONTROL__GRPC__BIND_PORT # Default: # bind_port = 6565 -# Completion queue count of gRPC server. -# -# Environment variable: MEDEA_SERVER__CONTROL__GRPC__COMPLETION_QUEUE_COUNT -# -# Default: -# completion_queue_count = 2 -[control_api] + +[control] # Path to directory with static Сontrol API specs. # -# Environment variable: MEDEA_CONTROL_API__STATIC_SPECS_DIR -# +# Env var: MEDEA_CONTROL__STATIC_SPECS_DIR # Default: # static_specs_dir = "specs/" @@ -59,16 +50,14 @@ # Duration, after which remote RPC client will be considered idle if no # heartbeat messages received. # -# Environment variable: MEDEA_RPC__IDLE_TIMEOUT -# +# Env var: MEDEA_RPC__IDLE_TIMEOUT # Default: # idle_timeout = "10s" -# Duration, after which the server deletes the client session if -# the remote RPC client does not reconnect after it is idle. -# -# Environment variable: MEDEA_RPC__RECONNECT_TIMEOUT +# Duration, after which the server deletes client session if remote RPC client +# does not reconnect after it is idle. # +# Env var: MEDEA_RPC__RECONNECT_TIMEOUT # Default: # reconnect_timeout = "10s" @@ -78,65 +67,56 @@ [turn] # Turn server host. # -# Environment variable: MEDEA_TURN__HOST -# +# Env var: MEDEA_TURN__HOST # Default: # host = "localhost" # Turn server port. # -# Environment variable: MEDEA_TURN__PORT -# +# Env var: MEDEA_TURN__PORT # Default: # port = 3478 # Static user on Turn server. # -# Environment variable: MEDEA_TURN__USER -# +# Env var: MEDEA_TURN__USER # Default: # user = "USER" # Static user password on Turn server. # -# Environment variable: MEDEA_TURN__PASS -# +# Env var: MEDEA_TURN__PASS # Default: # pass = "PASS" [turn.db.redis] # Host of Coturn's Redis database. # -# Environment variable: MEDEA_TURN__DB__REDIS__IP -# +# Env var: MEDEA_TURN__DB__REDIS__HOST # Default: -# ip = "127.0.0.1" +# host = "127.0.0.1" # Port of Coturn's Redis database for client connections. # -# Environment variable: MEDEA_TURN__DB__REDIS__PORT -# +# Env var: MEDEA_TURN__DB__REDIS__PORT # Default: # port = 6379 # Password to connect to Coturn's Redis database with. # -# Environment variable: MEDEA_TURN__DB__REDIS__PASS -# +# Env var: MEDEA_TURN__DB__REDIS__PASS # Default: # pass = "turn" # Number of Coturn's database in Redis. # -# Environment variable: MEDEA_TURN__DB__REDIS__DB_NUMBER -# +# Env var: MEDEA_TURN__DB__REDIS__DB_NUMBER # Default: # db_number = 0 # Timeout for establishing connection with Coturn's Redis database. # -# Environment variable: MEDEA_TURN__DB__REDIS__CONNECTION_TIMEOUT -# +# Env var: MEDEA_TURN__DB__REDIS__CONNECTION_TIMEOUT # Default: # connection_timeout = "5s" @@ -146,11 +126,9 @@ [log] # Maximum allowed level of application log entries. # -# Environment variable: MEDEA_LOG__LEVEL -# +# Env var: MEDEA_LOG__LEVEL # Possible values: # "OFF", "CRITICAL", "ERROR", "WARN", "INFO", "DEBUG", "TRACE" -# # Default: # level = "INFO" @@ -160,7 +138,6 @@ [shutdown] # Maximum duration given to shutdown the whole application gracefully. # -# Environment variable: MEDEA_SHUTDOWN__TIMEOUT -# +# Env var: MEDEA_SHUTDOWN__TIMEOUT # Default: # timeout = "5s" diff --git a/docker-compose.medea.yml b/docker-compose.medea.yml index 865ed7457..ed15ce61b 100644 --- a/docker-compose.medea.yml +++ b/docker-compose.medea.yml @@ -7,10 +7,10 @@ services: environment: RUST_LOG: ${RUST_LOG} MEDEA_CONF: ${MEDEA_CONF} - MEDEA_CONTROL_API__STATIC_SPECS_DIR: ${MEDEA_CONTROL_API__STATIC_SPECS_DIR} + MEDEA_CONTROL__STATIC_SPECS_DIR: ${MEDEA_CONTROL__STATIC_SPECS_DIR} ports: - "8080:8080" volumes: - ./${MEDEA_CONF}:/${MEDEA_CONF}:ro - - ./${MEDEA_CONTROL_API__STATIC_SPECS_DIR}:/${MEDEA_CONTROL_API__STATIC_SPECS_DIR}:ro + - ./${MEDEA_CONTROL__STATIC_SPECS_DIR}:/${MEDEA_CONTROL__STATIC_SPECS_DIR}:ro network_mode: host diff --git a/jason/demo/chart/medea-demo/conf/nginx.vh.conf b/jason/demo/chart/medea-demo/conf/nginx.vh.conf index b1d9435f4..065fbd39e 100644 --- a/jason/demo/chart/medea-demo/conf/nginx.vh.conf +++ b/jason/demo/chart/medea-demo/conf/nginx.vh.conf @@ -11,10 +11,10 @@ server { } location ^~ /ws/ { - proxy_pass http://127.0.0.1:8080/ws/; - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "Upgrade"; + proxy_pass http://127.0.0.1:8080/ws/; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "Upgrade"; } # Disable unnecessary access logs. diff --git a/jason/demo/chart/medea-demo/templates/deployment.server.yaml b/jason/demo/chart/medea-demo/templates/deployment.server.yaml index 42e5fdfc8..d7b45024f 100644 --- a/jason/demo/chart/medea-demo/templates/deployment.server.yaml +++ b/jason/demo/chart/medea-demo/templates/deployment.server.yaml @@ -64,8 +64,6 @@ spec: value: {{ $coturn.conf.listening_port | quote }} - name: MEDEA_TURN__DB__REDIS__PORT value: {{ $coturnDb.conf.port | quote }} - - name: MEDEA_SERVER.CLIENT.PUBLIC_URL - value: {{ .Values.server.conf.server.client.public_url }} envFrom: - secretRef: name: {{ template "medea-demo.fullname" . }}.server.cred diff --git a/jason/demo/chart/medea-demo/values.yaml b/jason/demo/chart/medea-demo/values.yaml index 720a98687..5a82301aa 100644 --- a/jason/demo/chart/medea-demo/values.yaml +++ b/jason/demo/chart/medea-demo/values.yaml @@ -17,7 +17,7 @@ server: conf: server: client: - public_url: "" + public_url: ws://127.0.0.1:8080 http: bind_port: 8080 turn: diff --git a/jason/demo/minikube.vals.yaml b/jason/demo/minikube.vals.yaml index ff68bf230..bd5af3bbd 100644 --- a/jason/demo/minikube.vals.yaml +++ b/jason/demo/minikube.vals.yaml @@ -10,7 +10,7 @@ server: conf: server: client: - public_url: "wss://medea-demo.test" + public_url: wss://medea-demo.test turn: host: medea-demo.test diff --git a/jason/demo/staging.vals.yaml b/jason/demo/staging.vals.yaml index bd3ed841b..447aacd57 100644 --- a/jason/demo/staging.vals.yaml +++ b/jason/demo/staging.vals.yaml @@ -10,7 +10,7 @@ server: conf: server: client: - public_url: "wss://demo.medea.stg.t11913.org" + public_url: wss://demo.medea.stg.t11913.org http: bind_port: 9980 turn: diff --git a/proto/client-api/CHANGELOG.md b/proto/client-api/CHANGELOG.md index 49180968f..91c331190 100644 --- a/proto/client-api/CHANGELOG.md +++ b/proto/client-api/CHANGELOG.md @@ -13,7 +13,7 @@ All user visible changes to this project will be documented in this file. This p - `TrackId` and `PeerId` types ([#28]); - `Incrementable` trait ([#28]); -- `RpcConnectionClosed` and `CloseDescription` ([#33](/../../pull/28)). +- `RpcConnectionClosed` and `CloseDescription` types ([#33](/../../pull/28)). [#28]: /../../pull/28 diff --git a/proto/client-api/src/lib.rs b/proto/client-api/src/lib.rs index 654a7bad2..1ffba26e2 100644 --- a/proto/client-api/src/lib.rs +++ b/proto/client-api/src/lib.rs @@ -133,17 +133,19 @@ pub enum Event { #[derive(Debug, Deserialize, Serialize)] /// Reason of disconnecting client from the server. pub enum RpcConnectionCloseReason { - /// `Room` in which client presented was closed. - RoomClosed, + /// Client session was finished on the server side. + Finished, - /// Member deleted from `Room`. + /// Client was evicted on the server side. Evicted, - /// Member reconnects and old connection was closed. + /// Old connection was closed due to client reconnection. NewConnection, } -/// Description which will be sent in Close WebSocket frame. +/// Description which will be sent in [Close] WebSocket frame. +/// +/// [Close]: https://tools.ietf.org/html/rfc6455#section-5.5.1 #[derive(Constructor, Debug, Deserialize, Serialize)] pub struct CloseDescription { /// Reason of why connection was closed. diff --git a/proto/control-api/CHANGELOG.md b/proto/control-api/CHANGELOG.md index 0342c97eb..2003d8cc4 100644 --- a/proto/control-api/CHANGELOG.md +++ b/proto/control-api/CHANGELOG.md @@ -1,5 +1,5 @@ `medea-control-api-proto` changelog -================================== +=================================== All user visible changes to this project will be documented in this file. This project uses [Semantic Versioning 2.0.0]. @@ -13,20 +13,23 @@ All user visible changes to this project will be documented in this file. This p ### Added -- Methods ([#33](/../../pull/33)): - - `Create`, - - `Get`, - - `Apply`, +- Methods ([#33]): + - `Create`; + - `Get`; + - `Apply`; - `Delete`. -- Elements ([#33](/../../pull/33)): - - `Room`, - - `Member`, - - `WebRtcPlayEndpoint`, - - `WebRtcPublishEndpoint` - - `Hub`, - - `FileRecorder`, +- Elements ([#33]): + - `Room`; + - `Member`; + - `WebRtcPlayEndpoint`; + - `WebRtcPublishEndpoint`; + - `Hub`; + - `FileRecorder`; - `Relay`. +[#33]: /../../pull/33 + + diff --git a/proto/control-api/Cargo.toml b/proto/control-api/Cargo.toml index 6ffc4d9a8..e5ac61934 100644 --- a/proto/control-api/Cargo.toml +++ b/proto/control-api/Cargo.toml @@ -5,10 +5,11 @@ edition = "2018" description = "Control API protocol implementation for Medea media server" authors = ["Instrumentisto Team "] license = "MIT/Apache-2.0" -homepage = "https://github.com/instrumentisto/medea/tree/master/proto/grpc" -repository = "https://github.com/instrumentisto/medea/tree/master/proto/grpc" +documentation = "https://docs.rs/medea-control-api-proto" +homepage = "https://github.com/instrumentisto/medea/tree/master/proto/control-api" +repository = "https://github.com/instrumentisto/medea/tree/master/proto/control-api" readme = "README.md" -keywords = ["medea", "grpc", "control", "api"] +keywords = ["medea", "grpc", "control-api"] categories = ["api-bindings", "web-programming"] [features] diff --git a/proto/control-api/README.md b/proto/control-api/README.md index 3a2caee60..bcb6cf191 100644 --- a/proto/control-api/README.md +++ b/proto/control-api/README.md @@ -1,9 +1,10 @@ Medea Control API protocol -========================= +========================== -[![Crates.io](https://img.shields.io/crates/v/medea-control-api-proto)](https://crates.io/crates/medea-grpc-proto) +[![Crates.io](https://img.shields.io/crates/v/medea-control-api-proto)](https://crates.io/crates/medea-control-api-proto) ![Crates.io license](https://img.shields.io/crates/l/medea-control-api-proto) +[API Docs](https://docs.rs/medea-control-api-proto) | [Changelog](https://github.com/instrumentisto/medea/blob/master/proto/control-api/CHANGELOG.md) Control API protocol implementation for [Medea] media server. @@ -14,14 +15,12 @@ __Currently, in early development phase.__ ## Prerequisites + - CMake >= 3.8.0 - Rust >= 1.19.0 - binutils >= 2.22 - LLVM and Clang >= 3.9 - -### For rebuilding protobuf specs - -- [protoc](https://github.com/protocolbuffers/protobuf)>=3.7.0 +- protoc >= 3.7 (for rebuilding [protobuf] specs) @@ -45,4 +44,4 @@ Unless you explicitly state otherwise, any contribution intentionally submitted [Medea]: https://github.com/instrumentisto/medea -[Control API]: https://github.com/instrumentisto/medea/blob/master/docs/rfc/0001-control-api.md +[protobuf]: https://github.com/protocolbuffers/protobuf diff --git a/proto/control-api/build.rs b/proto/control-api/build.rs index e1b6488db..0f46673e6 100644 --- a/proto/control-api/build.rs +++ b/proto/control-api/build.rs @@ -3,11 +3,13 @@ use std::{error::Error, fs::File, io::ErrorKind}; #[cfg(feature = "grpc")] fn main() -> Result<(), Box> { const GRPC_DIR: &str = "src/grpc/"; - const GRPC_SPEC_FILE: &str = "src/grpc/control_api.proto"; - const OUT_FILES: [&str; 2] = - ["src/grpc/control_api.rs", "src/grpc/control_api_grpc.rs"]; + const GRPC_SPEC_FILE: &str = "src/grpc/api.proto"; + const OUT_FILES: [&str; 2] = ["src/grpc/api.rs", "src/grpc/api_grpc.rs"]; - println!("cargo:rerun-if-changed={}", GRPC_DIR); + println!("cargo:rerun-if-changed={}", GRPC_SPEC_FILE); + for filename in &OUT_FILES { + println!("cargo:rerun-if-changed={}", filename); + } for filename in &OUT_FILES { if let Err(e) = File::open(filename) { @@ -18,10 +20,10 @@ fn main() -> Result<(), Box> { &GRPC_DIR, None, ) - .expect("Failed to compile gRPC definitions!"); + .expect("Failed to compile gRPC definitions"); break; } else { - panic!("{:?}", e); + panic!("{}", e); } } } diff --git a/proto/control-api/src/grpc/control_api.proto b/proto/control-api/src/grpc/api.proto similarity index 100% rename from proto/control-api/src/grpc/control_api.proto rename to proto/control-api/src/grpc/api.proto diff --git a/proto/control-api/src/grpc/control_api.rs b/proto/control-api/src/grpc/api.rs similarity index 97% rename from proto/control-api/src/grpc/control_api.rs rename to proto/control-api/src/grpc/api.rs index 5673c4d58..1e13fc3f7 100644 --- a/proto/control-api/src/grpc/control_api.rs +++ b/proto/control-api/src/grpc/api.rs @@ -17,7 +17,7 @@ #![allow(unsafe_code)] #![allow(unused_imports)] #![allow(unused_results)] -//! Generated file from `control_api.proto` +//! Generated file from `api.proto` use protobuf::Message as Message_imported_for_functions; use protobuf::ProtobufEnum as ProtobufEnum_imported_for_functions; @@ -6052,85 +6052,85 @@ impl ::protobuf::reflect::ProtobufValue for Relay { } static file_descriptor_proto_data: &'static [u8] = b"\ - \n\x11control_api.proto\x12\x05medea\"\xf0\x02\n\rCreateRequest\x12\x0e\ - \n\x02id\x18\x01\x20\x01(\tR\x02id\x12\x1e\n\x03hub\x18\x02\x20\x01(\x0b\ - 2\n.medea.HubH\0R\x03hub\x12:\n\rfile_recorder\x18\x03\x20\x01(\x0b2\x13\ - .medea.FileRecorderH\0R\x0cfileRecorder\x12'\n\x06member\x18\x04\x20\x01\ - (\x0b2\r.medea.MemberH\0R\x06member\x12$\n\x05relay\x18\x05\x20\x01(\x0b\ - 2\x0c.medea.RelayH\0R\x05relay\x12!\n\x04room\x18\x06\x20\x01(\x0b2\x0b.\ - medea.RoomH\0R\x04room\x12<\n\x0bwebrtc_play\x18\x07\x20\x01(\x0b2\x19.m\ - edea.WebRtcPlayEndpointH\0R\nwebrtcPlay\x12=\n\nwebrtc_pub\x18\x08\x20\ - \x01(\x0b2\x1c.medea.WebRtcPublishEndpointH\0R\twebrtcPubB\x04\n\x02el\"\ - \xc4\x03\n\x0cApplyRequest\x12\x0e\n\x02id\x18\x01\x20\x01(\tR\x02id\x12\ - \x1e\n\x03hub\x18\x02\x20\x01(\x0b2\n.medea.HubH\0R\x03hub\x12:\n\rfile_\ - recorder\x18\x03\x20\x01(\x0b2\x13.medea.FileRecorderH\0R\x0cfileRecorde\ - r\x12'\n\x06member\x18\x04\x20\x01(\x0b2\r.medea.MemberH\0R\x06member\ - \x12$\n\x05relay\x18\x05\x20\x01(\x0b2\x0c.medea.RelayH\0R\x05relay\x12!\ - \n\x04room\x18\x06\x20\x01(\x0b2\x0b.medea.RoomH\0R\x04room\x12<\n\x0bwe\ - brtc_play\x18\x07\x20\x01(\x0b2\x19.medea.WebRtcPlayEndpointH\0R\nwebrtc\ - Play\x12=\n\nwebrtc_pub\x18\x08\x20\x01(\x0b2\x1c.medea.WebRtcPublishEnd\ - pointH\0R\twebrtcPub\x122\n\x06policy\x18\t\x20\x01(\x0e2\x1a.medea.Appl\ - yRequest.PolicyR\x06policy\"\x1f\n\x06Policy\x12\t\n\x05APPLY\x10\0\x12\ - \n\n\x06APPEND\x10\x01B\x04\n\x02el\"\x1b\n\tIdRequest\x12\x0e\n\x02id\ - \x18\x01\x20\x03(\tR\x02id\".\n\x08Response\x12\"\n\x05error\x18\x01\x20\ - \x01(\x0b2\x0c.medea.ErrorR\x05error\"\x9e\x01\n\x0eCreateResponse\x120\ - \n\x03sid\x18\x01\x20\x03(\x0b2\x1e.medea.CreateResponse.SidEntryR\x03si\ - d\x12\"\n\x05error\x18\x02\x20\x01(\x0b2\x0c.medea.ErrorR\x05error\x1a6\ - \n\x08SidEntry\x12\x10\n\x03key\x18\x01\x20\x01(\tR\x03key\x12\x14\n\x05\ - value\x18\x02\x20\x01(\tR\x05value:\x028\x01\"\xbc\x01\n\x0bGetResponse\ - \x12<\n\x08elements\x18\x01\x20\x03(\x0b2\x20.medea.GetResponse.Elements\ - EntryR\x08elements\x12\"\n\x05error\x18\x02\x20\x01(\x0b2\x0c.medea.Erro\ - rR\x05error\x1aK\n\rElementsEntry\x12\x10\n\x03key\x18\x01\x20\x01(\tR\ - \x03key\x12$\n\x05value\x18\x02\x20\x01(\x0b2\x0e.medea.ElementR\x05valu\ - e:\x028\x01\"[\n\x05Error\x12\x12\n\x04code\x18\x02\x20\x01(\rR\x04code\ - \x12\x12\n\x04text\x18\x03\x20\x01(\tR\x04text\x12\x10\n\x03doc\x18\x04\ - \x20\x01(\tR\x03doc\x12\x18\n\x07element\x18\x05\x20\x01(\tR\x07element\ - \"\xda\x02\n\x07Element\x12\x1e\n\x03hub\x18\x02\x20\x01(\x0b2\n.medea.H\ - ubH\0R\x03hub\x12:\n\rfile_recorder\x18\x03\x20\x01(\x0b2\x13.medea.File\ - RecorderH\0R\x0cfileRecorder\x12'\n\x06member\x18\x04\x20\x01(\x0b2\r.me\ - dea.MemberH\0R\x06member\x12$\n\x05relay\x18\x05\x20\x01(\x0b2\x0c.medea\ - .RelayH\0R\x05relay\x12!\n\x04room\x18\x06\x20\x01(\x0b2\x0b.medea.RoomH\ - \0R\x04room\x12<\n\x0bwebrtc_play\x18\x07\x20\x01(\x0b2\x19.medea.WebRtc\ - PlayEndpointH\0R\nwebrtcPlay\x12=\n\nwebrtc_pub\x18\x08\x20\x01(\x0b2\ - \x1c.medea.WebRtcPublishEndpointH\0R\twebrtcPubB\x04\n\x02el\"\xc9\x03\n\ - \x04Room\x125\n\x08pipeline\x18\x01\x20\x03(\x0b2\x19.medea.Room.Pipelin\ - eEntryR\x08pipeline\x1aP\n\rPipelineEntry\x12\x10\n\x03key\x18\x01\x20\ - \x01(\tR\x03key\x12)\n\x05value\x18\x02\x20\x01(\x0b2\x13.medea.Room.Ele\ - mentR\x05value:\x028\x01\x1a\xb7\x02\n\x07Element\x12\x1e\n\x03hub\x18\ - \x01\x20\x01(\x0b2\n.medea.HubH\0R\x03hub\x12:\n\rfile_recorder\x18\x02\ - \x20\x01(\x0b2\x13.medea.FileRecorderH\0R\x0cfileRecorder\x12'\n\x06memb\ - er\x18\x03\x20\x01(\x0b2\r.medea.MemberH\0R\x06member\x12$\n\x05relay\ - \x18\x04\x20\x01(\x0b2\x0c.medea.RelayH\0R\x05relay\x12<\n\x0bwebrtc_pla\ - y\x18\x05\x20\x01(\x0b2\x19.medea.WebRtcPlayEndpointH\0R\nwebrtcPlay\x12\ - =\n\nwebrtc_pub\x18\x06\x20\x01(\x0b2\x1c.medea.WebRtcPublishEndpointH\0\ - R\twebrtcPubB\x04\n\x02el\"\xfc\x03\n\x06Member\x12\x17\n\x07on_join\x18\ - \x01\x20\x01(\tR\x06onJoin\x12\x19\n\x08on_leave\x18\x02\x20\x01(\tR\x07\ - onLeave\x12\x20\n\x0bcredentials\x18\x03\x20\x01(\tR\x0bcredentials\x127\ - \n\x08pipeline\x18\x04\x20\x03(\x0b2\x1b.medea.Member.PipelineEntryR\x08\ - pipeline\x1aR\n\rPipelineEntry\x12\x10\n\x03key\x18\x01\x20\x01(\tR\x03k\ - ey\x12+\n\x05value\x18\x02\x20\x01(\x0b2\x15.medea.Member.ElementR\x05va\ - lue:\x028\x01\x1a\x8e\x02\n\x07Element\x12\x1e\n\x03hub\x18\x01\x20\x01(\ + \n\tapi.proto\x12\x05medea\"\xf0\x02\n\rCreateRequest\x12\x0e\n\x02id\ + \x18\x01\x20\x01(\tR\x02id\x12\x1e\n\x03hub\x18\x02\x20\x01(\x0b2\n.mede\ + a.HubH\0R\x03hub\x12:\n\rfile_recorder\x18\x03\x20\x01(\x0b2\x13.medea.F\ + ileRecorderH\0R\x0cfileRecorder\x12'\n\x06member\x18\x04\x20\x01(\x0b2\r\ + .medea.MemberH\0R\x06member\x12$\n\x05relay\x18\x05\x20\x01(\x0b2\x0c.me\ + dea.RelayH\0R\x05relay\x12!\n\x04room\x18\x06\x20\x01(\x0b2\x0b.medea.Ro\ + omH\0R\x04room\x12<\n\x0bwebrtc_play\x18\x07\x20\x01(\x0b2\x19.medea.Web\ + RtcPlayEndpointH\0R\nwebrtcPlay\x12=\n\nwebrtc_pub\x18\x08\x20\x01(\x0b2\ + \x1c.medea.WebRtcPublishEndpointH\0R\twebrtcPubB\x04\n\x02el\"\xc4\x03\n\ + \x0cApplyRequest\x12\x0e\n\x02id\x18\x01\x20\x01(\tR\x02id\x12\x1e\n\x03\ + hub\x18\x02\x20\x01(\x0b2\n.medea.HubH\0R\x03hub\x12:\n\rfile_recorder\ + \x18\x03\x20\x01(\x0b2\x13.medea.FileRecorderH\0R\x0cfileRecorder\x12'\n\ + \x06member\x18\x04\x20\x01(\x0b2\r.medea.MemberH\0R\x06member\x12$\n\x05\ + relay\x18\x05\x20\x01(\x0b2\x0c.medea.RelayH\0R\x05relay\x12!\n\x04room\ + \x18\x06\x20\x01(\x0b2\x0b.medea.RoomH\0R\x04room\x12<\n\x0bwebrtc_play\ + \x18\x07\x20\x01(\x0b2\x19.medea.WebRtcPlayEndpointH\0R\nwebrtcPlay\x12=\ + \n\nwebrtc_pub\x18\x08\x20\x01(\x0b2\x1c.medea.WebRtcPublishEndpointH\0R\ + \twebrtcPub\x122\n\x06policy\x18\t\x20\x01(\x0e2\x1a.medea.ApplyRequest.\ + PolicyR\x06policy\"\x1f\n\x06Policy\x12\t\n\x05APPLY\x10\0\x12\n\n\x06AP\ + PEND\x10\x01B\x04\n\x02el\"\x1b\n\tIdRequest\x12\x0e\n\x02id\x18\x01\x20\ + \x03(\tR\x02id\".\n\x08Response\x12\"\n\x05error\x18\x01\x20\x01(\x0b2\ + \x0c.medea.ErrorR\x05error\"\x9e\x01\n\x0eCreateResponse\x120\n\x03sid\ + \x18\x01\x20\x03(\x0b2\x1e.medea.CreateResponse.SidEntryR\x03sid\x12\"\n\ + \x05error\x18\x02\x20\x01(\x0b2\x0c.medea.ErrorR\x05error\x1a6\n\x08SidE\ + ntry\x12\x10\n\x03key\x18\x01\x20\x01(\tR\x03key\x12\x14\n\x05value\x18\ + \x02\x20\x01(\tR\x05value:\x028\x01\"\xbc\x01\n\x0bGetResponse\x12<\n\ + \x08elements\x18\x01\x20\x03(\x0b2\x20.medea.GetResponse.ElementsEntryR\ + \x08elements\x12\"\n\x05error\x18\x02\x20\x01(\x0b2\x0c.medea.ErrorR\x05\ + error\x1aK\n\rElementsEntry\x12\x10\n\x03key\x18\x01\x20\x01(\tR\x03key\ + \x12$\n\x05value\x18\x02\x20\x01(\x0b2\x0e.medea.ElementR\x05value:\x028\ + \x01\"[\n\x05Error\x12\x12\n\x04code\x18\x02\x20\x01(\rR\x04code\x12\x12\ + \n\x04text\x18\x03\x20\x01(\tR\x04text\x12\x10\n\x03doc\x18\x04\x20\x01(\ + \tR\x03doc\x12\x18\n\x07element\x18\x05\x20\x01(\tR\x07element\"\xda\x02\ + \n\x07Element\x12\x1e\n\x03hub\x18\x02\x20\x01(\x0b2\n.medea.HubH\0R\x03\ + hub\x12:\n\rfile_recorder\x18\x03\x20\x01(\x0b2\x13.medea.FileRecorderH\ + \0R\x0cfileRecorder\x12'\n\x06member\x18\x04\x20\x01(\x0b2\r.medea.Membe\ + rH\0R\x06member\x12$\n\x05relay\x18\x05\x20\x01(\x0b2\x0c.medea.RelayH\0\ + R\x05relay\x12!\n\x04room\x18\x06\x20\x01(\x0b2\x0b.medea.RoomH\0R\x04ro\ + om\x12<\n\x0bwebrtc_play\x18\x07\x20\x01(\x0b2\x19.medea.WebRtcPlayEndpo\ + intH\0R\nwebrtcPlay\x12=\n\nwebrtc_pub\x18\x08\x20\x01(\x0b2\x1c.medea.W\ + ebRtcPublishEndpointH\0R\twebrtcPubB\x04\n\x02el\"\xc9\x03\n\x04Room\x12\ + 5\n\x08pipeline\x18\x01\x20\x03(\x0b2\x19.medea.Room.PipelineEntryR\x08p\ + ipeline\x1aP\n\rPipelineEntry\x12\x10\n\x03key\x18\x01\x20\x01(\tR\x03ke\ + y\x12)\n\x05value\x18\x02\x20\x01(\x0b2\x13.medea.Room.ElementR\x05value\ + :\x028\x01\x1a\xb7\x02\n\x07Element\x12\x1e\n\x03hub\x18\x01\x20\x01(\ \x0b2\n.medea.HubH\0R\x03hub\x12:\n\rfile_recorder\x18\x02\x20\x01(\x0b2\ - \x13.medea.FileRecorderH\0R\x0cfileRecorder\x12$\n\x05relay\x18\x03\x20\ - \x01(\x0b2\x0c.medea.RelayH\0R\x05relay\x12<\n\x0bwebrtc_play\x18\x04\ - \x20\x01(\x0b2\x19.medea.WebRtcPlayEndpointH\0R\nwebrtcPlay\x12=\n\nwebr\ - tc_pub\x18\x05\x20\x01(\x0b2\x1c.medea.WebRtcPublishEndpointH\0R\twebrtc\ - PubB\x04\n\x02el\"\xae\x01\n\x15WebRtcPublishEndpoint\x122\n\x03p2p\x18\ - \x01\x20\x01(\x0e2\x20.medea.WebRtcPublishEndpoint.P2PR\x03p2p\x12\x19\n\ - \x08on_start\x18\x03\x20\x01(\tR\x07onStart\x12\x17\n\x07on_stop\x18\x04\ - \x20\x01(\tR\x06onStop\"-\n\x03P2P\x12\t\n\x05NEVER\x10\0\x12\x0f\n\x0bI\ - F_POSSIBLE\x10\x01\x12\n\n\x06ALWAYS\x10\x02\"Z\n\x12WebRtcPlayEndpoint\ - \x12\x10\n\x03src\x18\x01\x20\x01(\tR\x03src\x12\x19\n\x08on_start\x18\ - \x02\x20\x01(\tR\x07onStart\x12\x17\n\x07on_stop\x18\x03\x20\x01(\tR\x06\ - onStop\"\x05\n\x03Hub\"f\n\x0cFileRecorder\x12\x10\n\x03src\x18\x01\x20\ - \x01(\tR\x03src\x12\x10\n\x03dst\x18\x02\x20\x01(\tR\x03dst\x12\x19\n\ - \x08on_start\x18\x03\x20\x01(\tR\x07onStart\x12\x17\n\x07on_stop\x18\x04\ - \x20\x01(\tR\x06onStop\"+\n\x05Relay\x12\x10\n\x03src\x18\x01\x20\x01(\t\ - R\x03src\x12\x10\n\x03dst\x18\x02\x20\x01(\tR\x03dst2\xcc\x01\n\nControl\ - Api\x125\n\x06Create\x12\x14.medea.CreateRequest\x1a\x15.medea.CreateRes\ - ponse\x12-\n\x05Apply\x12\x13.medea.ApplyRequest\x1a\x0f.medea.Response\ - \x12+\n\x06Delete\x12\x10.medea.IdRequest\x1a\x0f.medea.Response\x12+\n\ - \x03Get\x12\x10.medea.IdRequest\x1a\x12.medea.GetResponseb\x06proto3\ + \x13.medea.FileRecorderH\0R\x0cfileRecorder\x12'\n\x06member\x18\x03\x20\ + \x01(\x0b2\r.medea.MemberH\0R\x06member\x12$\n\x05relay\x18\x04\x20\x01(\ + \x0b2\x0c.medea.RelayH\0R\x05relay\x12<\n\x0bwebrtc_play\x18\x05\x20\x01\ + (\x0b2\x19.medea.WebRtcPlayEndpointH\0R\nwebrtcPlay\x12=\n\nwebrtc_pub\ + \x18\x06\x20\x01(\x0b2\x1c.medea.WebRtcPublishEndpointH\0R\twebrtcPubB\ + \x04\n\x02el\"\xfc\x03\n\x06Member\x12\x17\n\x07on_join\x18\x01\x20\x01(\ + \tR\x06onJoin\x12\x19\n\x08on_leave\x18\x02\x20\x01(\tR\x07onLeave\x12\ + \x20\n\x0bcredentials\x18\x03\x20\x01(\tR\x0bcredentials\x127\n\x08pipel\ + ine\x18\x04\x20\x03(\x0b2\x1b.medea.Member.PipelineEntryR\x08pipeline\ + \x1aR\n\rPipelineEntry\x12\x10\n\x03key\x18\x01\x20\x01(\tR\x03key\x12+\ + \n\x05value\x18\x02\x20\x01(\x0b2\x15.medea.Member.ElementR\x05value:\ + \x028\x01\x1a\x8e\x02\n\x07Element\x12\x1e\n\x03hub\x18\x01\x20\x01(\x0b\ + 2\n.medea.HubH\0R\x03hub\x12:\n\rfile_recorder\x18\x02\x20\x01(\x0b2\x13\ + .medea.FileRecorderH\0R\x0cfileRecorder\x12$\n\x05relay\x18\x03\x20\x01(\ + \x0b2\x0c.medea.RelayH\0R\x05relay\x12<\n\x0bwebrtc_play\x18\x04\x20\x01\ + (\x0b2\x19.medea.WebRtcPlayEndpointH\0R\nwebrtcPlay\x12=\n\nwebrtc_pub\ + \x18\x05\x20\x01(\x0b2\x1c.medea.WebRtcPublishEndpointH\0R\twebrtcPubB\ + \x04\n\x02el\"\xae\x01\n\x15WebRtcPublishEndpoint\x122\n\x03p2p\x18\x01\ + \x20\x01(\x0e2\x20.medea.WebRtcPublishEndpoint.P2PR\x03p2p\x12\x19\n\x08\ + on_start\x18\x03\x20\x01(\tR\x07onStart\x12\x17\n\x07on_stop\x18\x04\x20\ + \x01(\tR\x06onStop\"-\n\x03P2P\x12\t\n\x05NEVER\x10\0\x12\x0f\n\x0bIF_PO\ + SSIBLE\x10\x01\x12\n\n\x06ALWAYS\x10\x02\"Z\n\x12WebRtcPlayEndpoint\x12\ + \x10\n\x03src\x18\x01\x20\x01(\tR\x03src\x12\x19\n\x08on_start\x18\x02\ + \x20\x01(\tR\x07onStart\x12\x17\n\x07on_stop\x18\x03\x20\x01(\tR\x06onSt\ + op\"\x05\n\x03Hub\"f\n\x0cFileRecorder\x12\x10\n\x03src\x18\x01\x20\x01(\ + \tR\x03src\x12\x10\n\x03dst\x18\x02\x20\x01(\tR\x03dst\x12\x19\n\x08on_s\ + tart\x18\x03\x20\x01(\tR\x07onStart\x12\x17\n\x07on_stop\x18\x04\x20\x01\ + (\tR\x06onStop\"+\n\x05Relay\x12\x10\n\x03src\x18\x01\x20\x01(\tR\x03src\ + \x12\x10\n\x03dst\x18\x02\x20\x01(\tR\x03dst2\xcc\x01\n\nControlApi\x125\ + \n\x06Create\x12\x14.medea.CreateRequest\x1a\x15.medea.CreateResponse\ + \x12-\n\x05Apply\x12\x13.medea.ApplyRequest\x1a\x0f.medea.Response\x12+\ + \n\x06Delete\x12\x10.medea.IdRequest\x1a\x0f.medea.Response\x12+\n\x03Ge\ + t\x12\x10.medea.IdRequest\x1a\x12.medea.GetResponseb\x06proto3\ "; static mut file_descriptor_proto_lazy: ::protobuf::lazy::Lazy<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::lazy::Lazy { diff --git a/proto/control-api/src/grpc/control_api_grpc.rs b/proto/control-api/src/grpc/api_grpc.rs similarity index 54% rename from proto/control-api/src/grpc/control_api_grpc.rs rename to proto/control-api/src/grpc/api_grpc.rs index 7445b78ef..f4657cdaa 100644 --- a/proto/control-api/src/grpc/control_api_grpc.rs +++ b/proto/control-api/src/grpc/api_grpc.rs @@ -18,28 +18,28 @@ #![allow(unused_imports)] #![allow(unused_results)] -const METHOD_CONTROL_API_CREATE: ::grpcio::Method = ::grpcio::Method { +const METHOD_CONTROL_API_CREATE: ::grpcio::Method = ::grpcio::Method { ty: ::grpcio::MethodType::Unary, name: "/medea.ControlApi/Create", req_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, resp_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, }; -const METHOD_CONTROL_API_APPLY: ::grpcio::Method = ::grpcio::Method { +const METHOD_CONTROL_API_APPLY: ::grpcio::Method = ::grpcio::Method { ty: ::grpcio::MethodType::Unary, name: "/medea.ControlApi/Apply", req_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, resp_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, }; -const METHOD_CONTROL_API_DELETE: ::grpcio::Method = ::grpcio::Method { +const METHOD_CONTROL_API_DELETE: ::grpcio::Method = ::grpcio::Method { ty: ::grpcio::MethodType::Unary, name: "/medea.ControlApi/Delete", req_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, resp_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, }; -const METHOD_CONTROL_API_GET: ::grpcio::Method = ::grpcio::Method { +const METHOD_CONTROL_API_GET: ::grpcio::Method = ::grpcio::Method { ty: ::grpcio::MethodType::Unary, name: "/medea.ControlApi/Get", req_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, @@ -58,67 +58,67 @@ impl ControlApiClient { } } - pub fn create_opt(&self, req: &super::control_api::CreateRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result { + pub fn create_opt(&self, req: &super::api::CreateRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result { self.client.unary_call(&METHOD_CONTROL_API_CREATE, req, opt) } - pub fn create(&self, req: &super::control_api::CreateRequest) -> ::grpcio::Result { + pub fn create(&self, req: &super::api::CreateRequest) -> ::grpcio::Result { self.create_opt(req, ::grpcio::CallOption::default()) } - pub fn create_async_opt(&self, req: &super::control_api::CreateRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { + pub fn create_async_opt(&self, req: &super::api::CreateRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { self.client.unary_call_async(&METHOD_CONTROL_API_CREATE, req, opt) } - pub fn create_async(&self, req: &super::control_api::CreateRequest) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { + pub fn create_async(&self, req: &super::api::CreateRequest) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { self.create_async_opt(req, ::grpcio::CallOption::default()) } - pub fn apply_opt(&self, req: &super::control_api::ApplyRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result { + pub fn apply_opt(&self, req: &super::api::ApplyRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result { self.client.unary_call(&METHOD_CONTROL_API_APPLY, req, opt) } - pub fn apply(&self, req: &super::control_api::ApplyRequest) -> ::grpcio::Result { + pub fn apply(&self, req: &super::api::ApplyRequest) -> ::grpcio::Result { self.apply_opt(req, ::grpcio::CallOption::default()) } - pub fn apply_async_opt(&self, req: &super::control_api::ApplyRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { + pub fn apply_async_opt(&self, req: &super::api::ApplyRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { self.client.unary_call_async(&METHOD_CONTROL_API_APPLY, req, opt) } - pub fn apply_async(&self, req: &super::control_api::ApplyRequest) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { + pub fn apply_async(&self, req: &super::api::ApplyRequest) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { self.apply_async_opt(req, ::grpcio::CallOption::default()) } - pub fn delete_opt(&self, req: &super::control_api::IdRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result { + pub fn delete_opt(&self, req: &super::api::IdRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result { self.client.unary_call(&METHOD_CONTROL_API_DELETE, req, opt) } - pub fn delete(&self, req: &super::control_api::IdRequest) -> ::grpcio::Result { + pub fn delete(&self, req: &super::api::IdRequest) -> ::grpcio::Result { self.delete_opt(req, ::grpcio::CallOption::default()) } - pub fn delete_async_opt(&self, req: &super::control_api::IdRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { + pub fn delete_async_opt(&self, req: &super::api::IdRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { self.client.unary_call_async(&METHOD_CONTROL_API_DELETE, req, opt) } - pub fn delete_async(&self, req: &super::control_api::IdRequest) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { + pub fn delete_async(&self, req: &super::api::IdRequest) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { self.delete_async_opt(req, ::grpcio::CallOption::default()) } - pub fn get_opt(&self, req: &super::control_api::IdRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result { + pub fn get_opt(&self, req: &super::api::IdRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result { self.client.unary_call(&METHOD_CONTROL_API_GET, req, opt) } - pub fn get(&self, req: &super::control_api::IdRequest) -> ::grpcio::Result { + pub fn get(&self, req: &super::api::IdRequest) -> ::grpcio::Result { self.get_opt(req, ::grpcio::CallOption::default()) } - pub fn get_async_opt(&self, req: &super::control_api::IdRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { + pub fn get_async_opt(&self, req: &super::api::IdRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { self.client.unary_call_async(&METHOD_CONTROL_API_GET, req, opt) } - pub fn get_async(&self, req: &super::control_api::IdRequest) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { + pub fn get_async(&self, req: &super::api::IdRequest) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { self.get_async_opt(req, ::grpcio::CallOption::default()) } pub fn spawn(&self, f: F) where F: ::futures::Future + Send + 'static { @@ -127,10 +127,10 @@ impl ControlApiClient { } pub trait ControlApi { - fn create(&mut self, ctx: ::grpcio::RpcContext, req: super::control_api::CreateRequest, sink: ::grpcio::UnarySink); - fn apply(&mut self, ctx: ::grpcio::RpcContext, req: super::control_api::ApplyRequest, sink: ::grpcio::UnarySink); - fn delete(&mut self, ctx: ::grpcio::RpcContext, req: super::control_api::IdRequest, sink: ::grpcio::UnarySink); - fn get(&mut self, ctx: ::grpcio::RpcContext, req: super::control_api::IdRequest, sink: ::grpcio::UnarySink); + fn create(&mut self, ctx: ::grpcio::RpcContext, req: super::api::CreateRequest, sink: ::grpcio::UnarySink); + fn apply(&mut self, ctx: ::grpcio::RpcContext, req: super::api::ApplyRequest, sink: ::grpcio::UnarySink); + fn delete(&mut self, ctx: ::grpcio::RpcContext, req: super::api::IdRequest, sink: ::grpcio::UnarySink); + fn get(&mut self, ctx: ::grpcio::RpcContext, req: super::api::IdRequest, sink: ::grpcio::UnarySink); } pub fn create_control_api(s: S) -> ::grpcio::Service { diff --git a/proto/control-api/src/grpc/mod.rs b/proto/control-api/src/grpc/mod.rs index ba68b1e7c..485620653 100644 --- a/proto/control-api/src/grpc/mod.rs +++ b/proto/control-api/src/grpc/mod.rs @@ -5,5 +5,5 @@ clippy::pedantic, )] -pub mod control_api; -pub mod control_api_grpc; +pub mod api; +pub mod api_grpc; diff --git a/proto/control-api/src/lib.rs b/proto/control-api/src/lib.rs index 5a578d432..8e2613ca7 100644 --- a/proto/control-api/src/lib.rs +++ b/proto/control-api/src/lib.rs @@ -3,5 +3,6 @@ //! [Medea]: https://github.com/instrumentisto/medea //! [Control API]: https://tinyurl.com/yxsqplq7 +#[rustfmt::skip] #[cfg(feature = "grpc")] pub mod grpc; diff --git a/src/api/control/endpoints/mod.rs b/src/api/control/endpoints/mod.rs index 36d2449f8..7aa914f25 100644 --- a/src/api/control/endpoints/mod.rs +++ b/src/api/control/endpoints/mod.rs @@ -10,7 +10,7 @@ use std::convert::TryFrom; use derive_more::{Display, From, Into}; use serde::Deserialize; -use medea_control_api_proto::grpc::control_api::{ +use medea_control_api_proto::grpc::api::{ CreateRequest_oneof_el as ElementProto, Member_Element_oneof_el as MemberElementProto, }; @@ -24,7 +24,7 @@ pub use webrtc_publish_endpoint::{WebRtcPublishEndpoint, WebRtcPublishId}; /// ID of `Endpoint`. #[derive( - Clone, Debug, Eq, Hash, Deserialize, PartialEq, From, Display, Into, + Clone, Debug, Deserialize, Display, Eq, From, Hash, Into, PartialEq, )] pub struct Id(pub String); diff --git a/src/api/control/endpoints/webrtc_play_endpoint.rs b/src/api/control/endpoints/webrtc_play_endpoint.rs index ac2f2e20a..21974f0b8 100644 --- a/src/api/control/endpoints/webrtc_play_endpoint.rs +++ b/src/api/control/endpoints/webrtc_play_endpoint.rs @@ -6,8 +6,8 @@ use std::{convert::TryFrom, fmt}; use derive_more::{Display, From, Into}; use failure::Fail; -use medea_control_api_proto::grpc as medea_grpc; -use medea_grpc::control_api::WebRtcPlayEndpoint as WebRtcPlayEndpointProto; +use medea_control_api_proto::grpc::api as medea_grpc_control_api; +use medea_grpc_control_api::WebRtcPlayEndpoint as WebRtcPlayEndpointProto; use serde::{ de::{self, Deserializer, Error, Visitor}, Deserialize, diff --git a/src/api/control/endpoints/webrtc_publish_endpoint.rs b/src/api/control/endpoints/webrtc_publish_endpoint.rs index 5b56d25a9..475a3af25 100644 --- a/src/api/control/endpoints/webrtc_publish_endpoint.rs +++ b/src/api/control/endpoints/webrtc_publish_endpoint.rs @@ -5,7 +5,7 @@ use derive_more::{Display, From, Into}; use serde::Deserialize; -use medea_control_api_proto::grpc::control_api::{ +use medea_control_api_proto::grpc::api::{ WebRtcPublishEndpoint as WebRtcPublishEndpointProto, WebRtcPublishEndpoint_P2P as WebRtcPublishEndpointP2pProto, }; diff --git a/src/api/control/error_codes.rs b/src/api/control/error_codes.rs index b4029537a..4829f90d6 100644 --- a/src/api/control/error_codes.rs +++ b/src/api/control/error_codes.rs @@ -7,7 +7,7 @@ use std::string::ToString; use derive_more::Display; -use medea_control_api_proto::grpc::control_api::Error as ErrorProto; +use medea_control_api_proto::grpc::api::Error as ErrorProto; use crate::{ api::control::{ diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index e4739f795..44aa6d5a0 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -15,11 +15,11 @@ use grpcio::{ UnarySink, }; use medea_control_api_proto::grpc::{ - control_api::{ + api::{ ApplyRequest, CreateRequest, CreateResponse, Element, GetResponse, IdRequest, Response, }, - control_api_grpc::{create_control_api, ControlApi}, + api_grpc::{create_control_api, ControlApi}, }; use crate::{ diff --git a/src/api/control/member.rs b/src/api/control/member.rs index 737b9f8d0..dbec39202 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -5,7 +5,7 @@ use std::{collections::HashMap, convert::TryFrom}; use derive_more::{Display, From}; -use medea_control_api_proto::grpc::control_api::{ +use medea_control_api_proto::grpc::api::{ CreateRequest_oneof_el as ElementProto, Room_Element_oneof_el as RoomElementProto, }; diff --git a/src/api/control/room.rs b/src/api/control/room.rs index e3eb311fa..3adb82f73 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -6,7 +6,7 @@ use std::{collections::HashMap, convert::TryFrom}; use derive_more::{Display, From}; #[rustfmt::skip] -use medea_control_api_proto::grpc::control_api::{ +use medea_control_api_proto::grpc::api::{ CreateRequest_oneof_el as ElementProto }; use serde::Deserialize; diff --git a/src/signalling/elements/endpoints/mod.rs b/src/signalling/elements/endpoints/mod.rs index 3783daca2..9e27c655a 100644 --- a/src/signalling/elements/endpoints/mod.rs +++ b/src/signalling/elements/endpoints/mod.rs @@ -5,7 +5,7 @@ pub mod webrtc; use derive_more::From; -use medea_control_api_proto::grpc::control_api::Element as RootElementProto; +use medea_control_api_proto::grpc::api::Element as RootElementProto; /// Enum which can store all kinds of [Medea] endpoints. /// diff --git a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs index eee08a509..d014e566f 100644 --- a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs @@ -6,7 +6,7 @@ use std::{ }; use medea_client_api_proto::PeerId; -use medea_control_api_proto::grpc::control_api::{ +use medea_control_api_proto::grpc::api::{ Element as RootElementProto, Member_Element as ElementProto, WebRtcPlayEndpoint as WebRtcPlayEndpointProto, }; diff --git a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs index dfe3e5ad2..0b04a8891 100644 --- a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs @@ -7,7 +7,7 @@ use std::{ }; use medea_client_api_proto::PeerId; -use medea_control_api_proto::grpc::control_api::{ +use medea_control_api_proto::grpc::api::{ Element as RootElementProto, Member_Element as ElementProto, WebRtcPublishEndpoint as WebRtcPublishEndpointProto, }; diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index d86165299..bcfb29055 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -12,7 +12,7 @@ use std::{ use derive_more::Display; use failure::Fail; use medea_client_api_proto::{IceServer, PeerId}; -use medea_control_api_proto::grpc::control_api::{ +use medea_control_api_proto::grpc::api::{ Element as RootElementProto, Member as MemberProto, Room_Element as ElementProto, }; diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index d8d142953..c3b26a0de 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -368,7 +368,7 @@ impl ParticipantService { vec![], |mut futures, (_, mut connection)| { futures.push(connection.close(CloseDescription::new( - RpcConnectionCloseReason::RoomClosed, + RpcConnectionCloseReason::Finished, ))); futures }, diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 833eed173..70e743c6e 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -13,7 +13,7 @@ use derive_more::Display; use failure::Fail; use futures::future; use medea_client_api_proto::{Command, Event, IceCandidate, PeerId, TrackId}; -use medea_control_api_proto::grpc::control_api::{ +use medea_control_api_proto::grpc::api::{ Element as ElementProto, Room as RoomProto, }; diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index b636b786f..2aa4a90db 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -8,7 +8,7 @@ use actix::{ use derive_more::Display; use failure::Fail; use futures::future::{self, Future}; -use medea_control_api_proto::grpc::control_api::Element as ElementProto; +use medea_control_api_proto::grpc::api::Element as ElementProto; use crate::{ api::control::{ diff --git a/tests/e2e/grpc_control_api/create.rs b/tests/e2e/grpc_control_api/create.rs index 8454da45b..c25fcf5f5 100644 --- a/tests/e2e/grpc_control_api/create.rs +++ b/tests/e2e/grpc_control_api/create.rs @@ -7,7 +7,7 @@ use std::collections::HashMap; -use medea_control_api_proto::grpc::control_api::{ +use medea_control_api_proto::grpc::api::{ CreateRequest, Member, Member_Element, WebRtcPlayEndpoint, WebRtcPublishEndpoint, WebRtcPublishEndpoint_P2P, }; diff --git a/tests/e2e/grpc_control_api/signaling.rs b/tests/e2e/grpc_control_api/signaling.rs index 3e4e10f9f..18a0993f9 100644 --- a/tests/e2e/grpc_control_api/signaling.rs +++ b/tests/e2e/grpc_control_api/signaling.rs @@ -7,7 +7,7 @@ use std::{cell::Cell, collections::HashMap, rc::Rc, time::Duration}; use actix::{Arbiter, AsyncContext, Context, System}; use futures::future::Future as _; use medea_client_api_proto::Event; -use medea_control_api_proto::grpc::control_api::{ +use medea_control_api_proto::grpc::api::{ CreateRequest, Member, Member_Element, Room, Room_Element, WebRtcPlayEndpoint, WebRtcPublishEndpoint, WebRtcPublishEndpoint_P2P, }; From d38bb2528c944e70ea1db446b027cd86024dfdfa Mon Sep 17 00:00:00 2001 From: tyranron Date: Tue, 8 Oct 2019 12:46:35 +0200 Subject: [PATCH 696/735] Corrections --- .dockerignore | 10 +- CHANGELOG.md | 8 + config.toml | 9 +- jason/demo/chart/medea-demo/values.yaml | 2 +- jason/demo/minikube.vals.yaml | 3 +- jason/demo/staging.vals.yaml | 2 +- proto/client-api/CHANGELOG.md | 2 +- proto/control-api/src/grpc/api.proto | 243 +-- proto/control-api/src/grpc/api.rs | 2447 +++-------------------- src/api/control/endpoints/mod.rs | 15 +- src/conf/{control_api.rs => control.rs} | 13 +- src/conf/grpc_listener.rs | 24 - src/conf/http_listener.rs | 32 - src/conf/log.rs | 2 +- src/conf/mod.rs | 15 +- src/conf/rpc.rs | 2 +- src/conf/server.rs | 80 +- src/conf/shutdown.rs | 2 +- src/conf/turn.rs | 2 +- 19 files changed, 533 insertions(+), 2380 deletions(-) rename src/conf/{control_api.rs => control.rs} (69%) delete mode 100644 src/conf/grpc_listener.rs delete mode 100644 src/conf/http_listener.rs diff --git a/.dockerignore b/.dockerignore index cd76adbc7..d1729ac8b 100644 --- a/.dockerignore +++ b/.dockerignore @@ -5,19 +5,15 @@ !Cargo.lock !src/ -# Medea uses this sub-crates. +# Project sub-crates. !crates/ !proto/ -# We don't need Jason while building Medea, but since it's in Medea's workspace, -# Cargo should be able to see these files. +# Jason sources, assets and manifest. !jason/Cargo.toml !jason/src/ !jason/demo/chart/medea-demo/conf/ !jason/demo/index.html -# Medea dependencies cache. -!.cache/cargo/ - -# Makefile may be used in Dockerfile's. +# Makefile may be used in Dockerfiles. !Makefile diff --git a/CHANGELOG.md b/CHANGELOG.md index 42a8d8e7c..8c558e2df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,11 @@ All user visible changes to this project will be documented in this file. This p [Milestone](/../../milestone/2) | [Roadmap](/../../issues/27) +### BC Breaks + +- Configuration: + - Rename `[server]` section of Client API HTTP server as `[server.client.http]` ([#33]). + ### Added - Control API: @@ -24,6 +29,9 @@ All user visible changes to this project will be documented in this file. This p - Auto-removing `Peer`s when `Member` disconnects ([#28]); - Filter `SetIceCandidate` messages without `candidate` ([#50](/../../pull/50)); - Reason of WebSocket closing by server as `Close` frame's description ([#33]). +- Configuration: + - `[server.control.grpc]` section to configure Control API gRPC server ([#33]); + - `server.client.http.public_url` option to configure public URL of Client API HTTP server ([#33]). - Testing: - E2E tests for signalling ([#28]). diff --git a/config.toml b/config.toml index c68f5621c..9b714a962 100644 --- a/config.toml +++ b/config.toml @@ -1,12 +1,11 @@ -[server.client] -# Client API server's public URL. -# It's assumed that severs can be reached via this URL externally. +[server.client.http] +# Client API HTTP server's public URL. +# It's assumed that HTTP server can be reached via this URL externally. # -# Env var: MEDEA_SERVER__CLIENT__PUBLIC_URL +# Env var: MEDEA_SERVER__CLIENT__HTTP__PUBLIC_URL # Default: # public_url = "ws://127.0.0.1:8080" -[server.client.http] # IP address to bind Client API HTTP server to. # # Env var: MEDEA_SERVER__CLIENT__HTTP__BIND_IP diff --git a/jason/demo/chart/medea-demo/values.yaml b/jason/demo/chart/medea-demo/values.yaml index 5a82301aa..154d39a40 100644 --- a/jason/demo/chart/medea-demo/values.yaml +++ b/jason/demo/chart/medea-demo/values.yaml @@ -17,8 +17,8 @@ server: conf: server: client: - public_url: ws://127.0.0.1:8080 http: + public_url: ws://127.0.0.1:8080 bind_port: 8080 turn: user: USER diff --git a/jason/demo/minikube.vals.yaml b/jason/demo/minikube.vals.yaml index bd5af3bbd..ea3b32354 100644 --- a/jason/demo/minikube.vals.yaml +++ b/jason/demo/minikube.vals.yaml @@ -10,7 +10,8 @@ server: conf: server: client: - public_url: wss://medea-demo.test + http: + public_url: wss://medea-demo.test turn: host: medea-demo.test diff --git a/jason/demo/staging.vals.yaml b/jason/demo/staging.vals.yaml index 447aacd57..e5775504b 100644 --- a/jason/demo/staging.vals.yaml +++ b/jason/demo/staging.vals.yaml @@ -10,8 +10,8 @@ server: conf: server: client: - public_url: wss://demo.medea.stg.t11913.org http: + public_url: wss://demo.medea.stg.t11913.org bind_port: 9980 turn: host: demo.medea.stg.t11913.org diff --git a/proto/client-api/CHANGELOG.md b/proto/client-api/CHANGELOG.md index 91c331190..778d2cd39 100644 --- a/proto/client-api/CHANGELOG.md +++ b/proto/client-api/CHANGELOG.md @@ -13,7 +13,7 @@ All user visible changes to this project will be documented in this file. This p - `TrackId` and `PeerId` types ([#28]); - `Incrementable` trait ([#28]); -- `RpcConnectionClosed` and `CloseDescription` types ([#33](/../../pull/28)). +- `RpcConnectionClosed` and `CloseDescription` types ([#33](/../../pull/33)). [#28]: /../../pull/28 diff --git a/proto/control-api/src/grpc/api.proto b/proto/control-api/src/grpc/api.proto index ba7c666e0..d5566e792 100644 --- a/proto/control-api/src/grpc/api.proto +++ b/proto/control-api/src/grpc/api.proto @@ -1,255 +1,212 @@ -// File which describes Medea's Control API. +// Medea's Control API gRPC schema. syntax = "proto3"; package medea; -// Service for handling Control API requests. +// Media server's Control API service. service ControlApi { - // Creates new Element with given ID. + // Creates new Element with a given ID. // - // Not idempotent. Errors if Element with the same ID already exists. + // Not idempotent. Errors if an Element with the same ID already exists. rpc Create (CreateRequest) returns (CreateResponse); - // Applies given spec to Element by its ID. + // Applies given spec to an Element by its ID. // - // Idempotent. If no Element with such ID exists, - // then it will be created, otherwise it will be reconfigured. + // Idempotent. If no Element with such ID exists, then it will be created, + // otherwise it will be reconfigured. rpc Apply (ApplyRequest) returns (Response); // Removes Element by its ID. // Allows referring multiple Elements on the last two levels. // - // Idempotent. + // Idempotent. If no Elements with such IDs exist, then succeeds. rpc Delete (IdRequest) returns (Response); - // Returns Element by its ID. Allows referring multiple Elements. + // Returns Element by its ID. + // Allows referring multiple Elements. // If no ID specified, returns all Elements declared. rpc Get (IdRequest) returns (GetResponse); } -// Creates new Element with given ID. -// -// Not idempotent. Errors if Element with the same ID already exists. +// Request of creating new Element with a given ID. message CreateRequest { - // ID with which new Control API element will be created. - // - // Not idempotent. Errors if Element with the same ID already exists. + // ID of the Element to be created.. string id = 1; - // Spec of element to create. + // Spec of the created Element. oneof el { - Hub hub = 2; - FileRecorder file_recorder = 3; - Member member = 4; - Relay relay = 5; - Room room = 6; - WebRtcPlayEndpoint webrtc_play = 7; - WebRtcPublishEndpoint webrtc_pub = 8; + Member member = 2; + Room room = 3; + WebRtcPlayEndpoint webrtc_play = 4; + WebRtcPublishEndpoint webrtc_pub = 5; } } -// Applies given spec to Element by its ID. -// -// Idempotent. If no Element with such ID exists, -// then it will be created, otherwise it will be reconfigured. +// Request of applying given spec to an Element by its ID. message ApplyRequest { - // ID of Control API element which you want update. + // ID of an Element to apply changes on. string id = 1; - // Control API element spec to which this element should be updated. + // Element's spec to be applied. oneof el { - Hub hub = 2; - FileRecorder file_recorder = 3; - Member member = 4; - Relay relay = 5; - Room room = 6; - WebRtcPlayEndpoint webrtc_play = 7; - WebRtcPublishEndpoint webrtc_pub = 8; + Member member = 2; + Room room = 3; + WebRtcPlayEndpoint webrtc_play = 4; + WebRtcPublishEndpoint webrtc_pub = 5; } - // Updating policy. - Policy policy = 9; + // Policy to apply changes with. + Policy policy = 6; + // Policy of applying Element's spec changes. enum Policy { - // Elements that exist, but are not - // specified in provided pipeline - // will be removed. + // Apply provided changes and remove any unspecified Elements. APPLY = 0; - // Elements that exists, but are not - // specified in provided pipeline - // NOT will be removed. + // Append provided changes to existing Elements without removing them. APPEND = 1; } } -// Request with many elements IDs. +// Request with many Elements IDs. message IdRequest { - // Vector of elements IDs. + // List of Elements IDs. repeated string id = 1; } -// Response for requests which don't -// return anything on successful -// result, but can return Error. +// Response which doesn't return anything on successful result, +// but is fallible with an Error. // -// If request fails, then an error field will be returned. -// The request should be considered successful only -// if its response does not contain error. +// If operation fails then an Error will be returned. +// The response is considered successful only if it does not contain Error. message Response { - // Error which can be returned if request fails. + // Error of the Response. Error error = 1; } -// Response for Create request. +// Response of Create RPC method. // -// If request fails, then an error field will be returned. -// The request should be considered successful only -// if its response does not contain error. +// If operation fails then an Error will be returned. +// The response is considered successful only if it does not contain Error. message CreateResponse { - // Hashmap with IDs (key) and URIs (value) of elements - // with which Jason can connect to the Medea media server. - // Returns only if request was fully successful. + // Hashmap with IDs (key) and URIs (value) of Elements, which should be used + // by clients to connect to a media server via Client API. + // + // Returned only if CreateResponse is successful. map sid = 1; - // Error which can be returned if request fails. + // Error of the CreateResponse. Error error = 2; } -// Response for Get request. +// Response of Get RPC method. // -// If request fails, then an error field will be returned. -// The request should be considered successful only -// if its response does not contain error. +// If operation fails then an Error will be returned. +// The response is considered successful only if it does not contain Error. message GetResponse { - // Hashmap with IDs (key) and Control API elements specs (value). + // Hashmap with IDs (key) and specs (value) of the requested Elements. // - // Returns only if request was fully successful. + // Returned only if GetResponse is successful. map elements = 1; - // Error which can be returned if request fails. + // Error of the GetResponse. Error error = 2; } -// Error which can be returned if request fails. +// Error of failed request. // -// If this Error not returned then request should -// be considered as successful. +// If the Error is not returned then request is considered as successful. message Error { - // Concrete unique code of error. - uint32 code = 2; - // Human-readable text description of error. - string text = 3; - // Link to online documentation of error. + // Concrete unique code of the Error. + uint32 code = 1; + // Human-readable text description of the Error. + string text = 2; + // Link to online documentation of the Error. // // Optional field. - string doc = 4; - // Full ID of Element that error is related to. - // Some error doesn't relates to element ID and - // in this case element can be empty. + string doc = 3; + // Full ID of Element that the Error is related to. + // Some Errors are not related to any Element and in such case + // this field is empty. // // Optional field. - string element = 5; + string element = 4; } -// Control API spec element. +// Media element which can be used in a media pipeline. message Element { oneof el { - Hub hub = 2; - FileRecorder file_recorder = 3; - Member member = 4; - Relay relay = 5; - Room room = 6; - WebRtcPlayEndpoint webrtc_play = 7; - WebRtcPublishEndpoint webrtc_pub = 8; + Member member = 1; + Room room = 2; + WebRtcPlayEndpoint webrtc_play = 3; + WebRtcPublishEndpoint webrtc_pub = 4; } } -// Control API spec Room element. +// Media element which represents a single space where multiple Members can +// interact with each other. message Room { - // Pipeline of Room element. + // Pipeline of this Room. map pipeline = 1; // Elements which Room's pipeline can contain. message Element { oneof el { - Hub hub = 1; - FileRecorder file_recorder = 2; - Member member = 3; - Relay relay = 4; - WebRtcPlayEndpoint webrtc_play = 5; - WebRtcPublishEndpoint webrtc_pub = 6; + Member member = 1; + WebRtcPlayEndpoint webrtc_play = 2; + WebRtcPublishEndpoint webrtc_pub = 3; } } } -// Member element of Control API spec. +// Media element which represents a client authorized to participate +// in a some bigger media pipeline. message Member { - // Callback which fires when this Member - // connects to media server via WebSocket - // for WebRTC negotiation. + // Callback which fires when the Member establishes persistent connection + // with a media server via Client API. string on_join = 1; - // Callback which fires when this Member - // disconnects from media server via WebSocket. + // Callback which fires when the Member finishes persistent connection + // with a media server via Client API. string on_leave = 2; - // Credentials with which this Member can - // connect to media server via WebSocket. + // Credentials of the Member to authorize via Client API with. string credentials = 3; - // Pipeline of Member element. + // Pipeline of this Member. map pipeline = 4; // Elements which Member's pipeline can contain. message Element { oneof el { - Hub hub = 1; - FileRecorder file_recorder = 2; - Relay relay = 3; - WebRtcPlayEndpoint webrtc_play = 4; - WebRtcPublishEndpoint webrtc_pub = 5; + WebRtcPlayEndpoint webrtc_play = 1; + WebRtcPublishEndpoint webrtc_pub = 2; } } } -// Media element which is able to receive -// media data from client via WebRTC. +// Media element which is able to receive media data from a client via WebRTC +// (allows to publish media data). message WebRtcPublishEndpoint { - // P2P mode of WebRtc connection. + // P2P mode for this element. P2P p2p = 1; - // Callback which fires when Member client - // starts publishing media data. - string on_start = 3; - // Callback which fires when Member client - // stops publishing media data. - string on_stop = 4; + // Callback which fires when a client starts publishing media data. + string on_start = 2; + // Callback which fires when a client stops publishing media data. + string on_stop = 3; + // P2P mode of WebRTC interaction. enum P2P { - // Always connect through media server. + // Always send media data through a media server. NEVER = 0; - // Connect P2P if it possible. + // Send media data peer-to-peer directly if it's possible, + // otherwise through a media server. IF_POSSIBLE = 1; - // Always connect P2P. + // Send media data peer-to-peer only without a media server. ALWAYS = 2; } } -// Media element which is able to play -// media data for client via WebRTC. +// Media element which is able to play media data for a client via WebRTC. message WebRtcPlayEndpoint { // The source to get media data from. string src = 1; - // Callback which fires when Member client - // starts playing media data of source client. + // Callback which fires when a client starts playing media data + // from the source. string on_start = 2; - // Callback which fires when Member client - // stops playing media data of source client. + // Callback which fires when a client stops playing media data + // from the source. string on_stop = 3; } - -message Hub {} - -message FileRecorder { - string src = 1; - string dst = 2; - string on_start = 3; - string on_stop = 4; -} - -message Relay { - string src = 1; - string dst = 2; -} diff --git a/proto/control-api/src/grpc/api.rs b/proto/control-api/src/grpc/api.rs index 1e13fc3f7..be766bd10 100644 --- a/proto/control-api/src/grpc/api.rs +++ b/proto/control-api/src/grpc/api.rs @@ -45,10 +45,7 @@ impl<'a> ::std::default::Default for &'a CreateRequest { #[derive(Clone,PartialEq,Debug)] pub enum CreateRequest_oneof_el { - hub(Hub), - file_recorder(FileRecorder), member(Member), - relay(Relay), room(Room), webrtc_play(WebRtcPlayEndpoint), webrtc_pub(WebRtcPublishEndpoint), @@ -85,105 +82,7 @@ impl CreateRequest { ::std::mem::replace(&mut self.id, ::std::string::String::new()) } - // .medea.Hub hub = 2; - - - pub fn get_hub(&self) -> &Hub { - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::hub(ref v)) => v, - _ => Hub::default_instance(), - } - } - pub fn clear_hub(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_hub(&self) -> bool { - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::hub(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_hub(&mut self, v: Hub) { - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::hub(v)) - } - - // Mutable pointer to the field. - pub fn mut_hub(&mut self) -> &mut Hub { - if let ::std::option::Option::Some(CreateRequest_oneof_el::hub(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::hub(Hub::new())); - } - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::hub(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_hub(&mut self) -> Hub { - if self.has_hub() { - match self.el.take() { - ::std::option::Option::Some(CreateRequest_oneof_el::hub(v)) => v, - _ => panic!(), - } - } else { - Hub::new() - } - } - - // .medea.FileRecorder file_recorder = 3; - - - pub fn get_file_recorder(&self) -> &FileRecorder { - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::file_recorder(ref v)) => v, - _ => FileRecorder::default_instance(), - } - } - pub fn clear_file_recorder(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_file_recorder(&self) -> bool { - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::file_recorder(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_file_recorder(&mut self, v: FileRecorder) { - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::file_recorder(v)) - } - - // Mutable pointer to the field. - pub fn mut_file_recorder(&mut self) -> &mut FileRecorder { - if let ::std::option::Option::Some(CreateRequest_oneof_el::file_recorder(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::file_recorder(FileRecorder::new())); - } - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::file_recorder(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_file_recorder(&mut self) -> FileRecorder { - if self.has_file_recorder() { - match self.el.take() { - ::std::option::Option::Some(CreateRequest_oneof_el::file_recorder(v)) => v, - _ => panic!(), - } - } else { - FileRecorder::new() - } - } - - // .medea.Member member = 4; + // .medea.Member member = 2; pub fn get_member(&self) -> &Member { @@ -232,56 +131,7 @@ impl CreateRequest { } } - // .medea.Relay relay = 5; - - - pub fn get_relay(&self) -> &Relay { - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::relay(ref v)) => v, - _ => Relay::default_instance(), - } - } - pub fn clear_relay(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_relay(&self) -> bool { - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::relay(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_relay(&mut self, v: Relay) { - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::relay(v)) - } - - // Mutable pointer to the field. - pub fn mut_relay(&mut self) -> &mut Relay { - if let ::std::option::Option::Some(CreateRequest_oneof_el::relay(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::relay(Relay::new())); - } - match self.el { - ::std::option::Option::Some(CreateRequest_oneof_el::relay(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_relay(&mut self) -> Relay { - if self.has_relay() { - match self.el.take() { - ::std::option::Option::Some(CreateRequest_oneof_el::relay(v)) => v, - _ => panic!(), - } - } else { - Relay::new() - } - } - - // .medea.Room room = 6; + // .medea.Room room = 3; pub fn get_room(&self) -> &Room { @@ -330,7 +180,7 @@ impl CreateRequest { } } - // .medea.WebRtcPlayEndpoint webrtc_play = 7; + // .medea.WebRtcPlayEndpoint webrtc_play = 4; pub fn get_webrtc_play(&self) -> &WebRtcPlayEndpoint { @@ -379,7 +229,7 @@ impl CreateRequest { } } - // .medea.WebRtcPublishEndpoint webrtc_pub = 8; + // .medea.WebRtcPublishEndpoint webrtc_pub = 5; pub fn get_webrtc_pub(&self) -> &WebRtcPublishEndpoint { @@ -431,26 +281,11 @@ impl CreateRequest { impl ::protobuf::Message for CreateRequest { fn is_initialized(&self) -> bool { - if let Some(CreateRequest_oneof_el::hub(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(CreateRequest_oneof_el::file_recorder(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } if let Some(CreateRequest_oneof_el::member(ref v)) = self.el { if !v.is_initialized() { return false; } } - if let Some(CreateRequest_oneof_el::relay(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } if let Some(CreateRequest_oneof_el::room(ref v)) = self.el { if !v.is_initialized() { return false; @@ -477,42 +312,24 @@ impl ::protobuf::Message for CreateRequest { ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.id)?; }, 2 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::hub(is.read_message()?)); - }, - 3 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::file_recorder(is.read_message()?)); - }, - 4 => { if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); } self.el = ::std::option::Option::Some(CreateRequest_oneof_el::member(is.read_message()?)); }, - 5 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(CreateRequest_oneof_el::relay(is.read_message()?)); - }, - 6 => { + 3 => { if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); } self.el = ::std::option::Option::Some(CreateRequest_oneof_el::room(is.read_message()?)); }, - 7 => { + 4 => { if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); } self.el = ::std::option::Option::Some(CreateRequest_oneof_el::webrtc_play(is.read_message()?)); }, - 8 => { + 5 => { if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); } @@ -535,22 +352,10 @@ impl ::protobuf::Message for CreateRequest { } if let ::std::option::Option::Some(ref v) = self.el { match v { - &CreateRequest_oneof_el::hub(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &CreateRequest_oneof_el::file_recorder(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, &CreateRequest_oneof_el::member(ref v) => { let len = v.compute_size(); my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; }, - &CreateRequest_oneof_el::relay(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, &CreateRequest_oneof_el::room(ref v) => { let len = v.compute_size(); my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; @@ -576,38 +381,23 @@ impl ::protobuf::Message for CreateRequest { } if let ::std::option::Option::Some(ref v) = self.el { match v { - &CreateRequest_oneof_el::hub(ref v) => { - os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &CreateRequest_oneof_el::file_recorder(ref v) => { - os.write_tag(3, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, &CreateRequest_oneof_el::member(ref v) => { - os.write_tag(4, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &CreateRequest_oneof_el::relay(ref v) => { - os.write_tag(5, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; os.write_raw_varint32(v.get_cached_size())?; v.write_to_with_cached_sizes(os)?; }, &CreateRequest_oneof_el::room(ref v) => { - os.write_tag(6, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_tag(3, ::protobuf::wire_format::WireTypeLengthDelimited)?; os.write_raw_varint32(v.get_cached_size())?; v.write_to_with_cached_sizes(os)?; }, &CreateRequest_oneof_el::webrtc_play(ref v) => { - os.write_tag(7, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_tag(4, ::protobuf::wire_format::WireTypeLengthDelimited)?; os.write_raw_varint32(v.get_cached_size())?; v.write_to_with_cached_sizes(os)?; }, &CreateRequest_oneof_el::webrtc_pub(ref v) => { - os.write_tag(8, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_tag(5, ::protobuf::wire_format::WireTypeLengthDelimited)?; os.write_raw_varint32(v.get_cached_size())?; v.write_to_with_cached_sizes(os)?; }, @@ -660,26 +450,11 @@ impl ::protobuf::Message for CreateRequest { |m: &CreateRequest| { &m.id }, |m: &mut CreateRequest| { &mut m.id }, )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Hub>( - "hub", - CreateRequest::has_hub, - CreateRequest::get_hub, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, FileRecorder>( - "file_recorder", - CreateRequest::has_file_recorder, - CreateRequest::get_file_recorder, - )); fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Member>( "member", CreateRequest::has_member, CreateRequest::get_member, )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Relay>( - "relay", - CreateRequest::has_relay, - CreateRequest::get_relay, - )); fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Room>( "room", CreateRequest::has_room, @@ -722,9 +497,6 @@ impl ::protobuf::Clear for CreateRequest { self.el = ::std::option::Option::None; self.el = ::std::option::Option::None; self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; self.unknown_fields.clear(); } } @@ -761,10 +533,7 @@ impl<'a> ::std::default::Default for &'a ApplyRequest { #[derive(Clone,PartialEq,Debug)] pub enum ApplyRequest_oneof_el { - hub(Hub), - file_recorder(FileRecorder), member(Member), - relay(Relay), room(Room), webrtc_play(WebRtcPlayEndpoint), webrtc_pub(WebRtcPublishEndpoint), @@ -801,357 +570,210 @@ impl ApplyRequest { ::std::mem::replace(&mut self.id, ::std::string::String::new()) } - // .medea.Hub hub = 2; + // .medea.Member member = 2; - pub fn get_hub(&self) -> &Hub { + pub fn get_member(&self) -> &Member { match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::hub(ref v)) => v, - _ => Hub::default_instance(), + ::std::option::Option::Some(ApplyRequest_oneof_el::member(ref v)) => v, + _ => Member::default_instance(), } } - pub fn clear_hub(&mut self) { + pub fn clear_member(&mut self) { self.el = ::std::option::Option::None; } - pub fn has_hub(&self) -> bool { + pub fn has_member(&self) -> bool { match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::hub(..)) => true, + ::std::option::Option::Some(ApplyRequest_oneof_el::member(..)) => true, _ => false, } } // Param is passed by value, moved - pub fn set_hub(&mut self, v: Hub) { - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::hub(v)) + pub fn set_member(&mut self, v: Member) { + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::member(v)) } // Mutable pointer to the field. - pub fn mut_hub(&mut self) -> &mut Hub { - if let ::std::option::Option::Some(ApplyRequest_oneof_el::hub(_)) = self.el { + pub fn mut_member(&mut self) -> &mut Member { + if let ::std::option::Option::Some(ApplyRequest_oneof_el::member(_)) = self.el { } else { - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::hub(Hub::new())); + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::member(Member::new())); } match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::hub(ref mut v)) => v, + ::std::option::Option::Some(ApplyRequest_oneof_el::member(ref mut v)) => v, _ => panic!(), } } // Take field - pub fn take_hub(&mut self) -> Hub { - if self.has_hub() { + pub fn take_member(&mut self) -> Member { + if self.has_member() { match self.el.take() { - ::std::option::Option::Some(ApplyRequest_oneof_el::hub(v)) => v, + ::std::option::Option::Some(ApplyRequest_oneof_el::member(v)) => v, _ => panic!(), } } else { - Hub::new() + Member::new() } } - // .medea.FileRecorder file_recorder = 3; + // .medea.Room room = 3; - pub fn get_file_recorder(&self) -> &FileRecorder { + pub fn get_room(&self) -> &Room { match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::file_recorder(ref v)) => v, - _ => FileRecorder::default_instance(), + ::std::option::Option::Some(ApplyRequest_oneof_el::room(ref v)) => v, + _ => Room::default_instance(), } } - pub fn clear_file_recorder(&mut self) { + pub fn clear_room(&mut self) { self.el = ::std::option::Option::None; } - pub fn has_file_recorder(&self) -> bool { + pub fn has_room(&self) -> bool { match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::file_recorder(..)) => true, + ::std::option::Option::Some(ApplyRequest_oneof_el::room(..)) => true, _ => false, } } // Param is passed by value, moved - pub fn set_file_recorder(&mut self, v: FileRecorder) { - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::file_recorder(v)) + pub fn set_room(&mut self, v: Room) { + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::room(v)) } // Mutable pointer to the field. - pub fn mut_file_recorder(&mut self) -> &mut FileRecorder { - if let ::std::option::Option::Some(ApplyRequest_oneof_el::file_recorder(_)) = self.el { + pub fn mut_room(&mut self) -> &mut Room { + if let ::std::option::Option::Some(ApplyRequest_oneof_el::room(_)) = self.el { } else { - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::file_recorder(FileRecorder::new())); + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::room(Room::new())); } match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::file_recorder(ref mut v)) => v, + ::std::option::Option::Some(ApplyRequest_oneof_el::room(ref mut v)) => v, _ => panic!(), } } // Take field - pub fn take_file_recorder(&mut self) -> FileRecorder { - if self.has_file_recorder() { + pub fn take_room(&mut self) -> Room { + if self.has_room() { match self.el.take() { - ::std::option::Option::Some(ApplyRequest_oneof_el::file_recorder(v)) => v, + ::std::option::Option::Some(ApplyRequest_oneof_el::room(v)) => v, _ => panic!(), } } else { - FileRecorder::new() + Room::new() } } - // .medea.Member member = 4; + // .medea.WebRtcPlayEndpoint webrtc_play = 4; - pub fn get_member(&self) -> &Member { + pub fn get_webrtc_play(&self) -> &WebRtcPlayEndpoint { match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::member(ref v)) => v, - _ => Member::default_instance(), + ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(ref v)) => v, + _ => WebRtcPlayEndpoint::default_instance(), } } - pub fn clear_member(&mut self) { + pub fn clear_webrtc_play(&mut self) { self.el = ::std::option::Option::None; } - pub fn has_member(&self) -> bool { + pub fn has_webrtc_play(&self) -> bool { match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::member(..)) => true, + ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(..)) => true, _ => false, } } // Param is passed by value, moved - pub fn set_member(&mut self, v: Member) { - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::member(v)) + pub fn set_webrtc_play(&mut self, v: WebRtcPlayEndpoint) { + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(v)) } // Mutable pointer to the field. - pub fn mut_member(&mut self) -> &mut Member { - if let ::std::option::Option::Some(ApplyRequest_oneof_el::member(_)) = self.el { + pub fn mut_webrtc_play(&mut self) -> &mut WebRtcPlayEndpoint { + if let ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(_)) = self.el { } else { - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::member(Member::new())); + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(WebRtcPlayEndpoint::new())); } match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::member(ref mut v)) => v, + ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(ref mut v)) => v, _ => panic!(), } } // Take field - pub fn take_member(&mut self) -> Member { - if self.has_member() { + pub fn take_webrtc_play(&mut self) -> WebRtcPlayEndpoint { + if self.has_webrtc_play() { match self.el.take() { - ::std::option::Option::Some(ApplyRequest_oneof_el::member(v)) => v, + ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(v)) => v, _ => panic!(), } } else { - Member::new() + WebRtcPlayEndpoint::new() } } - // .medea.Relay relay = 5; + // .medea.WebRtcPublishEndpoint webrtc_pub = 5; - pub fn get_relay(&self) -> &Relay { + pub fn get_webrtc_pub(&self) -> &WebRtcPublishEndpoint { match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::relay(ref v)) => v, - _ => Relay::default_instance(), + ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(ref v)) => v, + _ => WebRtcPublishEndpoint::default_instance(), } } - pub fn clear_relay(&mut self) { + pub fn clear_webrtc_pub(&mut self) { self.el = ::std::option::Option::None; } - pub fn has_relay(&self) -> bool { + pub fn has_webrtc_pub(&self) -> bool { match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::relay(..)) => true, + ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(..)) => true, _ => false, } } // Param is passed by value, moved - pub fn set_relay(&mut self, v: Relay) { - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::relay(v)) + pub fn set_webrtc_pub(&mut self, v: WebRtcPublishEndpoint) { + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(v)) } // Mutable pointer to the field. - pub fn mut_relay(&mut self) -> &mut Relay { - if let ::std::option::Option::Some(ApplyRequest_oneof_el::relay(_)) = self.el { + pub fn mut_webrtc_pub(&mut self) -> &mut WebRtcPublishEndpoint { + if let ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(_)) = self.el { } else { - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::relay(Relay::new())); + self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(WebRtcPublishEndpoint::new())); } match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::relay(ref mut v)) => v, + ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(ref mut v)) => v, _ => panic!(), } } // Take field - pub fn take_relay(&mut self) -> Relay { - if self.has_relay() { + pub fn take_webrtc_pub(&mut self) -> WebRtcPublishEndpoint { + if self.has_webrtc_pub() { match self.el.take() { - ::std::option::Option::Some(ApplyRequest_oneof_el::relay(v)) => v, + ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(v)) => v, _ => panic!(), } } else { - Relay::new() + WebRtcPublishEndpoint::new() } } - // .medea.Room room = 6; + // .medea.ApplyRequest.Policy policy = 6; - pub fn get_room(&self) -> &Room { - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::room(ref v)) => v, - _ => Room::default_instance(), - } + pub fn get_policy(&self) -> ApplyRequest_Policy { + self.policy } - pub fn clear_room(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_room(&self) -> bool { - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::room(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_room(&mut self, v: Room) { - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::room(v)) - } - - // Mutable pointer to the field. - pub fn mut_room(&mut self) -> &mut Room { - if let ::std::option::Option::Some(ApplyRequest_oneof_el::room(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::room(Room::new())); - } - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::room(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_room(&mut self) -> Room { - if self.has_room() { - match self.el.take() { - ::std::option::Option::Some(ApplyRequest_oneof_el::room(v)) => v, - _ => panic!(), - } - } else { - Room::new() - } - } - - // .medea.WebRtcPlayEndpoint webrtc_play = 7; - - - pub fn get_webrtc_play(&self) -> &WebRtcPlayEndpoint { - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(ref v)) => v, - _ => WebRtcPlayEndpoint::default_instance(), - } - } - pub fn clear_webrtc_play(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_webrtc_play(&self) -> bool { - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_webrtc_play(&mut self, v: WebRtcPlayEndpoint) { - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(v)) - } - - // Mutable pointer to the field. - pub fn mut_webrtc_play(&mut self) -> &mut WebRtcPlayEndpoint { - if let ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(WebRtcPlayEndpoint::new())); - } - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_webrtc_play(&mut self) -> WebRtcPlayEndpoint { - if self.has_webrtc_play() { - match self.el.take() { - ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(v)) => v, - _ => panic!(), - } - } else { - WebRtcPlayEndpoint::new() - } - } - - // .medea.WebRtcPublishEndpoint webrtc_pub = 8; - - - pub fn get_webrtc_pub(&self) -> &WebRtcPublishEndpoint { - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(ref v)) => v, - _ => WebRtcPublishEndpoint::default_instance(), - } - } - pub fn clear_webrtc_pub(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_webrtc_pub(&self) -> bool { - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_webrtc_pub(&mut self, v: WebRtcPublishEndpoint) { - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(v)) - } - - // Mutable pointer to the field. - pub fn mut_webrtc_pub(&mut self) -> &mut WebRtcPublishEndpoint { - if let ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(WebRtcPublishEndpoint::new())); - } - match self.el { - ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_webrtc_pub(&mut self) -> WebRtcPublishEndpoint { - if self.has_webrtc_pub() { - match self.el.take() { - ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(v)) => v, - _ => panic!(), - } - } else { - WebRtcPublishEndpoint::new() - } - } - - // .medea.ApplyRequest.Policy policy = 9; - - - pub fn get_policy(&self) -> ApplyRequest_Policy { - self.policy - } - pub fn clear_policy(&mut self) { - self.policy = ApplyRequest_Policy::APPLY; + pub fn clear_policy(&mut self) { + self.policy = ApplyRequest_Policy::APPLY; } // Param is passed by value, moved @@ -1162,26 +784,11 @@ impl ApplyRequest { impl ::protobuf::Message for ApplyRequest { fn is_initialized(&self) -> bool { - if let Some(ApplyRequest_oneof_el::hub(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(ApplyRequest_oneof_el::file_recorder(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } if let Some(ApplyRequest_oneof_el::member(ref v)) = self.el { if !v.is_initialized() { return false; } } - if let Some(ApplyRequest_oneof_el::relay(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } if let Some(ApplyRequest_oneof_el::room(ref v)) = self.el { if !v.is_initialized() { return false; @@ -1208,49 +815,31 @@ impl ::protobuf::Message for ApplyRequest { ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.id)?; }, 2 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::hub(is.read_message()?)); - }, - 3 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::file_recorder(is.read_message()?)); - }, - 4 => { if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); } self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::member(is.read_message()?)); }, - 5 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::relay(is.read_message()?)); - }, - 6 => { + 3 => { if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); } self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::room(is.read_message()?)); }, - 7 => { + 4 => { if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); } self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_play(is.read_message()?)); }, - 8 => { + 5 => { if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); } self.el = ::std::option::Option::Some(ApplyRequest_oneof_el::webrtc_pub(is.read_message()?)); }, - 9 => { - ::protobuf::rt::read_proto3_enum_with_unknown_fields_into(wire_type, is, &mut self.policy, 9, &mut self.unknown_fields)? + 6 => { + ::protobuf::rt::read_proto3_enum_with_unknown_fields_into(wire_type, is, &mut self.policy, 6, &mut self.unknown_fields)? }, _ => { ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; @@ -1268,26 +857,14 @@ impl ::protobuf::Message for ApplyRequest { my_size += ::protobuf::rt::string_size(1, &self.id); } if self.policy != ApplyRequest_Policy::APPLY { - my_size += ::protobuf::rt::enum_size(9, self.policy); + my_size += ::protobuf::rt::enum_size(6, self.policy); } if let ::std::option::Option::Some(ref v) = self.el { match v { - &ApplyRequest_oneof_el::hub(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &ApplyRequest_oneof_el::file_recorder(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, &ApplyRequest_oneof_el::member(ref v) => { let len = v.compute_size(); my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; }, - &ApplyRequest_oneof_el::relay(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, &ApplyRequest_oneof_el::room(ref v) => { let len = v.compute_size(); my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; @@ -1312,42 +889,27 @@ impl ::protobuf::Message for ApplyRequest { os.write_string(1, &self.id)?; } if self.policy != ApplyRequest_Policy::APPLY { - os.write_enum(9, self.policy.value())?; + os.write_enum(6, self.policy.value())?; } if let ::std::option::Option::Some(ref v) = self.el { match v { - &ApplyRequest_oneof_el::hub(ref v) => { - os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &ApplyRequest_oneof_el::file_recorder(ref v) => { - os.write_tag(3, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, &ApplyRequest_oneof_el::member(ref v) => { - os.write_tag(4, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &ApplyRequest_oneof_el::relay(ref v) => { - os.write_tag(5, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; os.write_raw_varint32(v.get_cached_size())?; v.write_to_with_cached_sizes(os)?; }, &ApplyRequest_oneof_el::room(ref v) => { - os.write_tag(6, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_tag(3, ::protobuf::wire_format::WireTypeLengthDelimited)?; os.write_raw_varint32(v.get_cached_size())?; v.write_to_with_cached_sizes(os)?; }, &ApplyRequest_oneof_el::webrtc_play(ref v) => { - os.write_tag(7, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_tag(4, ::protobuf::wire_format::WireTypeLengthDelimited)?; os.write_raw_varint32(v.get_cached_size())?; v.write_to_with_cached_sizes(os)?; }, &ApplyRequest_oneof_el::webrtc_pub(ref v) => { - os.write_tag(8, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_tag(5, ::protobuf::wire_format::WireTypeLengthDelimited)?; os.write_raw_varint32(v.get_cached_size())?; v.write_to_with_cached_sizes(os)?; }, @@ -1400,26 +962,11 @@ impl ::protobuf::Message for ApplyRequest { |m: &ApplyRequest| { &m.id }, |m: &mut ApplyRequest| { &mut m.id }, )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Hub>( - "hub", - ApplyRequest::has_hub, - ApplyRequest::get_hub, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, FileRecorder>( - "file_recorder", - ApplyRequest::has_file_recorder, - ApplyRequest::get_file_recorder, - )); fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Member>( "member", ApplyRequest::has_member, ApplyRequest::get_member, )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Relay>( - "relay", - ApplyRequest::has_relay, - ApplyRequest::get_relay, - )); fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Room>( "room", ApplyRequest::has_room, @@ -1467,9 +1014,6 @@ impl ::protobuf::Clear for ApplyRequest { self.el = ::std::option::Option::None; self.el = ::std::option::Option::None; self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; self.policy = ApplyRequest_Policy::APPLY; self.unknown_fields.clear(); } @@ -2359,7 +1903,7 @@ impl Error { ::std::default::Default::default() } - // uint32 code = 2; + // uint32 code = 1; pub fn get_code(&self) -> u32 { @@ -2374,7 +1918,7 @@ impl Error { self.code = v; } - // string text = 3; + // string text = 2; pub fn get_text(&self) -> &str { @@ -2400,7 +1944,7 @@ impl Error { ::std::mem::replace(&mut self.text, ::std::string::String::new()) } - // string doc = 4; + // string doc = 3; pub fn get_doc(&self) -> &str { @@ -2426,7 +1970,7 @@ impl Error { ::std::mem::replace(&mut self.doc, ::std::string::String::new()) } - // string element = 5; + // string element = 4; pub fn get_element(&self) -> &str { @@ -2462,20 +2006,20 @@ impl ::protobuf::Message for Error { while !is.eof()? { let (field_number, wire_type) = is.read_tag_unpack()?; match field_number { - 2 => { + 1 => { if wire_type != ::protobuf::wire_format::WireTypeVarint { return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); } let tmp = is.read_uint32()?; self.code = tmp; }, - 3 => { + 2 => { ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.text)?; }, - 4 => { + 3 => { ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.doc)?; }, - 5 => { + 4 => { ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.element)?; }, _ => { @@ -2491,16 +2035,16 @@ impl ::protobuf::Message for Error { fn compute_size(&self) -> u32 { let mut my_size = 0; if self.code != 0 { - my_size += ::protobuf::rt::value_size(2, self.code, ::protobuf::wire_format::WireTypeVarint); + my_size += ::protobuf::rt::value_size(1, self.code, ::protobuf::wire_format::WireTypeVarint); } if !self.text.is_empty() { - my_size += ::protobuf::rt::string_size(3, &self.text); + my_size += ::protobuf::rt::string_size(2, &self.text); } if !self.doc.is_empty() { - my_size += ::protobuf::rt::string_size(4, &self.doc); + my_size += ::protobuf::rt::string_size(3, &self.doc); } if !self.element.is_empty() { - my_size += ::protobuf::rt::string_size(5, &self.element); + my_size += ::protobuf::rt::string_size(4, &self.element); } my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); self.cached_size.set(my_size); @@ -2509,16 +2053,16 @@ impl ::protobuf::Message for Error { fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { if self.code != 0 { - os.write_uint32(2, self.code)?; + os.write_uint32(1, self.code)?; } if !self.text.is_empty() { - os.write_string(3, &self.text)?; + os.write_string(2, &self.text)?; } if !self.doc.is_empty() { - os.write_string(4, &self.doc)?; + os.write_string(3, &self.doc)?; } if !self.element.is_empty() { - os.write_string(5, &self.element)?; + os.write_string(4, &self.element)?; } os.write_unknown_fields(self.get_unknown_fields())?; ::std::result::Result::Ok(()) @@ -2641,10 +2185,7 @@ impl<'a> ::std::default::Default for &'a Element { #[derive(Clone,PartialEq,Debug)] pub enum Element_oneof_el { - hub(Hub), - file_recorder(FileRecorder), member(Member), - relay(Relay), room(Room), webrtc_play(WebRtcPlayEndpoint), webrtc_pub(WebRtcPublishEndpoint), @@ -2655,267 +2196,120 @@ impl Element { ::std::default::Default::default() } - // .medea.Hub hub = 2; + // .medea.Member member = 1; - pub fn get_hub(&self) -> &Hub { + pub fn get_member(&self) -> &Member { match self.el { - ::std::option::Option::Some(Element_oneof_el::hub(ref v)) => v, - _ => Hub::default_instance(), + ::std::option::Option::Some(Element_oneof_el::member(ref v)) => v, + _ => Member::default_instance(), } } - pub fn clear_hub(&mut self) { + pub fn clear_member(&mut self) { self.el = ::std::option::Option::None; } - pub fn has_hub(&self) -> bool { + pub fn has_member(&self) -> bool { match self.el { - ::std::option::Option::Some(Element_oneof_el::hub(..)) => true, + ::std::option::Option::Some(Element_oneof_el::member(..)) => true, _ => false, } } // Param is passed by value, moved - pub fn set_hub(&mut self, v: Hub) { - self.el = ::std::option::Option::Some(Element_oneof_el::hub(v)) + pub fn set_member(&mut self, v: Member) { + self.el = ::std::option::Option::Some(Element_oneof_el::member(v)) } // Mutable pointer to the field. - pub fn mut_hub(&mut self) -> &mut Hub { - if let ::std::option::Option::Some(Element_oneof_el::hub(_)) = self.el { + pub fn mut_member(&mut self) -> &mut Member { + if let ::std::option::Option::Some(Element_oneof_el::member(_)) = self.el { } else { - self.el = ::std::option::Option::Some(Element_oneof_el::hub(Hub::new())); + self.el = ::std::option::Option::Some(Element_oneof_el::member(Member::new())); } match self.el { - ::std::option::Option::Some(Element_oneof_el::hub(ref mut v)) => v, + ::std::option::Option::Some(Element_oneof_el::member(ref mut v)) => v, _ => panic!(), } } // Take field - pub fn take_hub(&mut self) -> Hub { - if self.has_hub() { + pub fn take_member(&mut self) -> Member { + if self.has_member() { match self.el.take() { - ::std::option::Option::Some(Element_oneof_el::hub(v)) => v, + ::std::option::Option::Some(Element_oneof_el::member(v)) => v, _ => panic!(), } } else { - Hub::new() + Member::new() } } - // .medea.FileRecorder file_recorder = 3; + // .medea.Room room = 2; - pub fn get_file_recorder(&self) -> &FileRecorder { + pub fn get_room(&self) -> &Room { match self.el { - ::std::option::Option::Some(Element_oneof_el::file_recorder(ref v)) => v, - _ => FileRecorder::default_instance(), + ::std::option::Option::Some(Element_oneof_el::room(ref v)) => v, + _ => Room::default_instance(), } } - pub fn clear_file_recorder(&mut self) { + pub fn clear_room(&mut self) { self.el = ::std::option::Option::None; } - pub fn has_file_recorder(&self) -> bool { + pub fn has_room(&self) -> bool { match self.el { - ::std::option::Option::Some(Element_oneof_el::file_recorder(..)) => true, + ::std::option::Option::Some(Element_oneof_el::room(..)) => true, _ => false, } } // Param is passed by value, moved - pub fn set_file_recorder(&mut self, v: FileRecorder) { - self.el = ::std::option::Option::Some(Element_oneof_el::file_recorder(v)) + pub fn set_room(&mut self, v: Room) { + self.el = ::std::option::Option::Some(Element_oneof_el::room(v)) } // Mutable pointer to the field. - pub fn mut_file_recorder(&mut self) -> &mut FileRecorder { - if let ::std::option::Option::Some(Element_oneof_el::file_recorder(_)) = self.el { + pub fn mut_room(&mut self) -> &mut Room { + if let ::std::option::Option::Some(Element_oneof_el::room(_)) = self.el { } else { - self.el = ::std::option::Option::Some(Element_oneof_el::file_recorder(FileRecorder::new())); + self.el = ::std::option::Option::Some(Element_oneof_el::room(Room::new())); } match self.el { - ::std::option::Option::Some(Element_oneof_el::file_recorder(ref mut v)) => v, + ::std::option::Option::Some(Element_oneof_el::room(ref mut v)) => v, _ => panic!(), } } // Take field - pub fn take_file_recorder(&mut self) -> FileRecorder { - if self.has_file_recorder() { + pub fn take_room(&mut self) -> Room { + if self.has_room() { match self.el.take() { - ::std::option::Option::Some(Element_oneof_el::file_recorder(v)) => v, + ::std::option::Option::Some(Element_oneof_el::room(v)) => v, _ => panic!(), } } else { - FileRecorder::new() + Room::new() } } - // .medea.Member member = 4; + // .medea.WebRtcPlayEndpoint webrtc_play = 3; - pub fn get_member(&self) -> &Member { + pub fn get_webrtc_play(&self) -> &WebRtcPlayEndpoint { match self.el { - ::std::option::Option::Some(Element_oneof_el::member(ref v)) => v, - _ => Member::default_instance(), + ::std::option::Option::Some(Element_oneof_el::webrtc_play(ref v)) => v, + _ => WebRtcPlayEndpoint::default_instance(), } } - pub fn clear_member(&mut self) { + pub fn clear_webrtc_play(&mut self) { self.el = ::std::option::Option::None; } - pub fn has_member(&self) -> bool { + pub fn has_webrtc_play(&self) -> bool { match self.el { - ::std::option::Option::Some(Element_oneof_el::member(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_member(&mut self, v: Member) { - self.el = ::std::option::Option::Some(Element_oneof_el::member(v)) - } - - // Mutable pointer to the field. - pub fn mut_member(&mut self) -> &mut Member { - if let ::std::option::Option::Some(Element_oneof_el::member(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(Element_oneof_el::member(Member::new())); - } - match self.el { - ::std::option::Option::Some(Element_oneof_el::member(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_member(&mut self) -> Member { - if self.has_member() { - match self.el.take() { - ::std::option::Option::Some(Element_oneof_el::member(v)) => v, - _ => panic!(), - } - } else { - Member::new() - } - } - - // .medea.Relay relay = 5; - - - pub fn get_relay(&self) -> &Relay { - match self.el { - ::std::option::Option::Some(Element_oneof_el::relay(ref v)) => v, - _ => Relay::default_instance(), - } - } - pub fn clear_relay(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_relay(&self) -> bool { - match self.el { - ::std::option::Option::Some(Element_oneof_el::relay(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_relay(&mut self, v: Relay) { - self.el = ::std::option::Option::Some(Element_oneof_el::relay(v)) - } - - // Mutable pointer to the field. - pub fn mut_relay(&mut self) -> &mut Relay { - if let ::std::option::Option::Some(Element_oneof_el::relay(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(Element_oneof_el::relay(Relay::new())); - } - match self.el { - ::std::option::Option::Some(Element_oneof_el::relay(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_relay(&mut self) -> Relay { - if self.has_relay() { - match self.el.take() { - ::std::option::Option::Some(Element_oneof_el::relay(v)) => v, - _ => panic!(), - } - } else { - Relay::new() - } - } - - // .medea.Room room = 6; - - - pub fn get_room(&self) -> &Room { - match self.el { - ::std::option::Option::Some(Element_oneof_el::room(ref v)) => v, - _ => Room::default_instance(), - } - } - pub fn clear_room(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_room(&self) -> bool { - match self.el { - ::std::option::Option::Some(Element_oneof_el::room(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_room(&mut self, v: Room) { - self.el = ::std::option::Option::Some(Element_oneof_el::room(v)) - } - - // Mutable pointer to the field. - pub fn mut_room(&mut self) -> &mut Room { - if let ::std::option::Option::Some(Element_oneof_el::room(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(Element_oneof_el::room(Room::new())); - } - match self.el { - ::std::option::Option::Some(Element_oneof_el::room(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_room(&mut self) -> Room { - if self.has_room() { - match self.el.take() { - ::std::option::Option::Some(Element_oneof_el::room(v)) => v, - _ => panic!(), - } - } else { - Room::new() - } - } - - // .medea.WebRtcPlayEndpoint webrtc_play = 7; - - - pub fn get_webrtc_play(&self) -> &WebRtcPlayEndpoint { - match self.el { - ::std::option::Option::Some(Element_oneof_el::webrtc_play(ref v)) => v, - _ => WebRtcPlayEndpoint::default_instance(), - } - } - pub fn clear_webrtc_play(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_webrtc_play(&self) -> bool { - match self.el { - ::std::option::Option::Some(Element_oneof_el::webrtc_play(..)) => true, + ::std::option::Option::Some(Element_oneof_el::webrtc_play(..)) => true, _ => false, } } @@ -2949,7 +2343,7 @@ impl Element { } } - // .medea.WebRtcPublishEndpoint webrtc_pub = 8; + // .medea.WebRtcPublishEndpoint webrtc_pub = 4; pub fn get_webrtc_pub(&self) -> &WebRtcPublishEndpoint { @@ -3001,26 +2395,11 @@ impl Element { impl ::protobuf::Message for Element { fn is_initialized(&self) -> bool { - if let Some(Element_oneof_el::hub(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(Element_oneof_el::file_recorder(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } if let Some(Element_oneof_el::member(ref v)) = self.el { if !v.is_initialized() { return false; } } - if let Some(Element_oneof_el::relay(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } if let Some(Element_oneof_el::room(ref v)) = self.el { if !v.is_initialized() { return false; @@ -3043,43 +2422,25 @@ impl ::protobuf::Message for Element { while !is.eof()? { let (field_number, wire_type) = is.read_tag_unpack()?; match field_number { - 2 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(Element_oneof_el::hub(is.read_message()?)); - }, - 3 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(Element_oneof_el::file_recorder(is.read_message()?)); - }, - 4 => { + 1 => { if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); } self.el = ::std::option::Option::Some(Element_oneof_el::member(is.read_message()?)); }, - 5 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(Element_oneof_el::relay(is.read_message()?)); - }, - 6 => { + 2 => { if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); } self.el = ::std::option::Option::Some(Element_oneof_el::room(is.read_message()?)); }, - 7 => { + 3 => { if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); } self.el = ::std::option::Option::Some(Element_oneof_el::webrtc_play(is.read_message()?)); }, - 8 => { + 4 => { if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); } @@ -3099,22 +2460,10 @@ impl ::protobuf::Message for Element { let mut my_size = 0; if let ::std::option::Option::Some(ref v) = self.el { match v { - &Element_oneof_el::hub(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &Element_oneof_el::file_recorder(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, &Element_oneof_el::member(ref v) => { let len = v.compute_size(); my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; }, - &Element_oneof_el::relay(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, &Element_oneof_el::room(ref v) => { let len = v.compute_size(); my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; @@ -3137,38 +2486,23 @@ impl ::protobuf::Message for Element { fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { if let ::std::option::Option::Some(ref v) = self.el { match v { - &Element_oneof_el::hub(ref v) => { - os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &Element_oneof_el::file_recorder(ref v) => { - os.write_tag(3, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, &Element_oneof_el::member(ref v) => { - os.write_tag(4, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &Element_oneof_el::relay(ref v) => { - os.write_tag(5, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_tag(1, ::protobuf::wire_format::WireTypeLengthDelimited)?; os.write_raw_varint32(v.get_cached_size())?; v.write_to_with_cached_sizes(os)?; }, &Element_oneof_el::room(ref v) => { - os.write_tag(6, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; os.write_raw_varint32(v.get_cached_size())?; v.write_to_with_cached_sizes(os)?; }, &Element_oneof_el::webrtc_play(ref v) => { - os.write_tag(7, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_tag(3, ::protobuf::wire_format::WireTypeLengthDelimited)?; os.write_raw_varint32(v.get_cached_size())?; v.write_to_with_cached_sizes(os)?; }, &Element_oneof_el::webrtc_pub(ref v) => { - os.write_tag(8, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_tag(4, ::protobuf::wire_format::WireTypeLengthDelimited)?; os.write_raw_varint32(v.get_cached_size())?; v.write_to_with_cached_sizes(os)?; }, @@ -3216,26 +2550,11 @@ impl ::protobuf::Message for Element { unsafe { descriptor.get(|| { let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Hub>( - "hub", - Element::has_hub, - Element::get_hub, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, FileRecorder>( - "file_recorder", - Element::has_file_recorder, - Element::get_file_recorder, - )); fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Member>( "member", Element::has_member, Element::get_member, )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Relay>( - "relay", - Element::has_relay, - Element::get_relay, - )); fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Room>( "room", Element::has_room, @@ -3273,9 +2592,6 @@ impl ::protobuf::Message for Element { impl ::protobuf::Clear for Element { fn clear(&mut self) { - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; self.el = ::std::option::Option::None; self.el = ::std::option::Option::None; self.el = ::std::option::Option::None; @@ -3477,10 +2793,7 @@ impl<'a> ::std::default::Default for &'a Room_Element { #[derive(Clone,PartialEq,Debug)] pub enum Room_Element_oneof_el { - hub(Hub), - file_recorder(FileRecorder), member(Member), - relay(Relay), webrtc_play(WebRtcPlayEndpoint), webrtc_pub(WebRtcPublishEndpoint), } @@ -3490,323 +2803,161 @@ impl Room_Element { ::std::default::Default::default() } - // .medea.Hub hub = 1; + // .medea.Member member = 1; - pub fn get_hub(&self) -> &Hub { + pub fn get_member(&self) -> &Member { match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::hub(ref v)) => v, - _ => Hub::default_instance(), + ::std::option::Option::Some(Room_Element_oneof_el::member(ref v)) => v, + _ => Member::default_instance(), } } - pub fn clear_hub(&mut self) { + pub fn clear_member(&mut self) { self.el = ::std::option::Option::None; } - pub fn has_hub(&self) -> bool { + pub fn has_member(&self) -> bool { match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::hub(..)) => true, + ::std::option::Option::Some(Room_Element_oneof_el::member(..)) => true, _ => false, } } // Param is passed by value, moved - pub fn set_hub(&mut self, v: Hub) { - self.el = ::std::option::Option::Some(Room_Element_oneof_el::hub(v)) + pub fn set_member(&mut self, v: Member) { + self.el = ::std::option::Option::Some(Room_Element_oneof_el::member(v)) } // Mutable pointer to the field. - pub fn mut_hub(&mut self) -> &mut Hub { - if let ::std::option::Option::Some(Room_Element_oneof_el::hub(_)) = self.el { + pub fn mut_member(&mut self) -> &mut Member { + if let ::std::option::Option::Some(Room_Element_oneof_el::member(_)) = self.el { } else { - self.el = ::std::option::Option::Some(Room_Element_oneof_el::hub(Hub::new())); + self.el = ::std::option::Option::Some(Room_Element_oneof_el::member(Member::new())); } match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::hub(ref mut v)) => v, + ::std::option::Option::Some(Room_Element_oneof_el::member(ref mut v)) => v, _ => panic!(), } } // Take field - pub fn take_hub(&mut self) -> Hub { - if self.has_hub() { + pub fn take_member(&mut self) -> Member { + if self.has_member() { match self.el.take() { - ::std::option::Option::Some(Room_Element_oneof_el::hub(v)) => v, + ::std::option::Option::Some(Room_Element_oneof_el::member(v)) => v, _ => panic!(), } } else { - Hub::new() + Member::new() } } - // .medea.FileRecorder file_recorder = 2; + // .medea.WebRtcPlayEndpoint webrtc_play = 2; - pub fn get_file_recorder(&self) -> &FileRecorder { + pub fn get_webrtc_play(&self) -> &WebRtcPlayEndpoint { match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::file_recorder(ref v)) => v, - _ => FileRecorder::default_instance(), + ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(ref v)) => v, + _ => WebRtcPlayEndpoint::default_instance(), } } - pub fn clear_file_recorder(&mut self) { + pub fn clear_webrtc_play(&mut self) { self.el = ::std::option::Option::None; } - pub fn has_file_recorder(&self) -> bool { + pub fn has_webrtc_play(&self) -> bool { match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::file_recorder(..)) => true, + ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(..)) => true, _ => false, } } // Param is passed by value, moved - pub fn set_file_recorder(&mut self, v: FileRecorder) { - self.el = ::std::option::Option::Some(Room_Element_oneof_el::file_recorder(v)) + pub fn set_webrtc_play(&mut self, v: WebRtcPlayEndpoint) { + self.el = ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(v)) } // Mutable pointer to the field. - pub fn mut_file_recorder(&mut self) -> &mut FileRecorder { - if let ::std::option::Option::Some(Room_Element_oneof_el::file_recorder(_)) = self.el { + pub fn mut_webrtc_play(&mut self) -> &mut WebRtcPlayEndpoint { + if let ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(_)) = self.el { } else { - self.el = ::std::option::Option::Some(Room_Element_oneof_el::file_recorder(FileRecorder::new())); + self.el = ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(WebRtcPlayEndpoint::new())); } match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::file_recorder(ref mut v)) => v, + ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(ref mut v)) => v, _ => panic!(), } } // Take field - pub fn take_file_recorder(&mut self) -> FileRecorder { - if self.has_file_recorder() { + pub fn take_webrtc_play(&mut self) -> WebRtcPlayEndpoint { + if self.has_webrtc_play() { match self.el.take() { - ::std::option::Option::Some(Room_Element_oneof_el::file_recorder(v)) => v, + ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(v)) => v, _ => panic!(), } } else { - FileRecorder::new() + WebRtcPlayEndpoint::new() } } - // .medea.Member member = 3; + // .medea.WebRtcPublishEndpoint webrtc_pub = 3; - pub fn get_member(&self) -> &Member { + pub fn get_webrtc_pub(&self) -> &WebRtcPublishEndpoint { match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::member(ref v)) => v, - _ => Member::default_instance(), + ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(ref v)) => v, + _ => WebRtcPublishEndpoint::default_instance(), } } - pub fn clear_member(&mut self) { + pub fn clear_webrtc_pub(&mut self) { self.el = ::std::option::Option::None; } - pub fn has_member(&self) -> bool { + pub fn has_webrtc_pub(&self) -> bool { match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::member(..)) => true, + ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(..)) => true, _ => false, } } // Param is passed by value, moved - pub fn set_member(&mut self, v: Member) { - self.el = ::std::option::Option::Some(Room_Element_oneof_el::member(v)) + pub fn set_webrtc_pub(&mut self, v: WebRtcPublishEndpoint) { + self.el = ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(v)) } // Mutable pointer to the field. - pub fn mut_member(&mut self) -> &mut Member { - if let ::std::option::Option::Some(Room_Element_oneof_el::member(_)) = self.el { + pub fn mut_webrtc_pub(&mut self) -> &mut WebRtcPublishEndpoint { + if let ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(_)) = self.el { } else { - self.el = ::std::option::Option::Some(Room_Element_oneof_el::member(Member::new())); + self.el = ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(WebRtcPublishEndpoint::new())); } match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::member(ref mut v)) => v, + ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(ref mut v)) => v, _ => panic!(), } } // Take field - pub fn take_member(&mut self) -> Member { - if self.has_member() { + pub fn take_webrtc_pub(&mut self) -> WebRtcPublishEndpoint { + if self.has_webrtc_pub() { match self.el.take() { - ::std::option::Option::Some(Room_Element_oneof_el::member(v)) => v, + ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(v)) => v, _ => panic!(), } } else { - Member::new() - } - } - - // .medea.Relay relay = 4; - - - pub fn get_relay(&self) -> &Relay { - match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::relay(ref v)) => v, - _ => Relay::default_instance(), - } - } - pub fn clear_relay(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_relay(&self) -> bool { - match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::relay(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_relay(&mut self, v: Relay) { - self.el = ::std::option::Option::Some(Room_Element_oneof_el::relay(v)) - } - - // Mutable pointer to the field. - pub fn mut_relay(&mut self) -> &mut Relay { - if let ::std::option::Option::Some(Room_Element_oneof_el::relay(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(Room_Element_oneof_el::relay(Relay::new())); - } - match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::relay(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_relay(&mut self) -> Relay { - if self.has_relay() { - match self.el.take() { - ::std::option::Option::Some(Room_Element_oneof_el::relay(v)) => v, - _ => panic!(), - } - } else { - Relay::new() - } - } - - // .medea.WebRtcPlayEndpoint webrtc_play = 5; - - - pub fn get_webrtc_play(&self) -> &WebRtcPlayEndpoint { - match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(ref v)) => v, - _ => WebRtcPlayEndpoint::default_instance(), - } - } - pub fn clear_webrtc_play(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_webrtc_play(&self) -> bool { - match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_webrtc_play(&mut self, v: WebRtcPlayEndpoint) { - self.el = ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(v)) - } - - // Mutable pointer to the field. - pub fn mut_webrtc_play(&mut self) -> &mut WebRtcPlayEndpoint { - if let ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(WebRtcPlayEndpoint::new())); - } - match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_webrtc_play(&mut self) -> WebRtcPlayEndpoint { - if self.has_webrtc_play() { - match self.el.take() { - ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(v)) => v, - _ => panic!(), - } - } else { - WebRtcPlayEndpoint::new() - } - } - - // .medea.WebRtcPublishEndpoint webrtc_pub = 6; - - - pub fn get_webrtc_pub(&self) -> &WebRtcPublishEndpoint { - match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(ref v)) => v, - _ => WebRtcPublishEndpoint::default_instance(), - } - } - pub fn clear_webrtc_pub(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_webrtc_pub(&self) -> bool { - match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_webrtc_pub(&mut self, v: WebRtcPublishEndpoint) { - self.el = ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(v)) - } - - // Mutable pointer to the field. - pub fn mut_webrtc_pub(&mut self) -> &mut WebRtcPublishEndpoint { - if let ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(WebRtcPublishEndpoint::new())); - } - match self.el { - ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_webrtc_pub(&mut self) -> WebRtcPublishEndpoint { - if self.has_webrtc_pub() { - match self.el.take() { - ::std::option::Option::Some(Room_Element_oneof_el::webrtc_pub(v)) => v, - _ => panic!(), - } - } else { - WebRtcPublishEndpoint::new() + WebRtcPublishEndpoint::new() } } } impl ::protobuf::Message for Room_Element { fn is_initialized(&self) -> bool { - if let Some(Room_Element_oneof_el::hub(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(Room_Element_oneof_el::file_recorder(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } if let Some(Room_Element_oneof_el::member(ref v)) = self.el { if !v.is_initialized() { return false; } } - if let Some(Room_Element_oneof_el::relay(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } if let Some(Room_Element_oneof_el::webrtc_play(ref v)) = self.el { if !v.is_initialized() { return false; @@ -3825,36 +2976,18 @@ impl ::protobuf::Message for Room_Element { let (field_number, wire_type) = is.read_tag_unpack()?; match field_number { 1 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(Room_Element_oneof_el::hub(is.read_message()?)); - }, - 2 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(Room_Element_oneof_el::file_recorder(is.read_message()?)); - }, - 3 => { if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); } self.el = ::std::option::Option::Some(Room_Element_oneof_el::member(is.read_message()?)); }, - 4 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(Room_Element_oneof_el::relay(is.read_message()?)); - }, - 5 => { + 2 => { if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); } self.el = ::std::option::Option::Some(Room_Element_oneof_el::webrtc_play(is.read_message()?)); }, - 6 => { + 3 => { if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); } @@ -3874,22 +3007,10 @@ impl ::protobuf::Message for Room_Element { let mut my_size = 0; if let ::std::option::Option::Some(ref v) = self.el { match v { - &Room_Element_oneof_el::hub(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &Room_Element_oneof_el::file_recorder(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, &Room_Element_oneof_el::member(ref v) => { let len = v.compute_size(); my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; }, - &Room_Element_oneof_el::relay(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, &Room_Element_oneof_el::webrtc_play(ref v) => { let len = v.compute_size(); my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; @@ -3908,33 +3029,18 @@ impl ::protobuf::Message for Room_Element { fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { if let ::std::option::Option::Some(ref v) = self.el { match v { - &Room_Element_oneof_el::hub(ref v) => { - os.write_tag(1, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &Room_Element_oneof_el::file_recorder(ref v) => { - os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, &Room_Element_oneof_el::member(ref v) => { - os.write_tag(3, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &Room_Element_oneof_el::relay(ref v) => { - os.write_tag(4, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_tag(1, ::protobuf::wire_format::WireTypeLengthDelimited)?; os.write_raw_varint32(v.get_cached_size())?; v.write_to_with_cached_sizes(os)?; }, &Room_Element_oneof_el::webrtc_play(ref v) => { - os.write_tag(5, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; os.write_raw_varint32(v.get_cached_size())?; v.write_to_with_cached_sizes(os)?; }, &Room_Element_oneof_el::webrtc_pub(ref v) => { - os.write_tag(6, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_tag(3, ::protobuf::wire_format::WireTypeLengthDelimited)?; os.write_raw_varint32(v.get_cached_size())?; v.write_to_with_cached_sizes(os)?; }, @@ -3982,26 +3088,11 @@ impl ::protobuf::Message for Room_Element { unsafe { descriptor.get(|| { let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Hub>( - "hub", - Room_Element::has_hub, - Room_Element::get_hub, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, FileRecorder>( - "file_recorder", - Room_Element::has_file_recorder, - Room_Element::get_file_recorder, - )); fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Member>( "member", Room_Element::has_member, Room_Element::get_member, )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Relay>( - "relay", - Room_Element::has_relay, - Room_Element::get_relay, - )); fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPlayEndpoint>( "webrtc_play", Room_Element::has_webrtc_play, @@ -4034,9 +3125,6 @@ impl ::protobuf::Message for Room_Element { impl ::protobuf::Clear for Room_Element { fn clear(&mut self) { - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; self.el = ::std::option::Option::None; self.el = ::std::option::Option::None; self.el = ::std::option::Option::None; @@ -4363,9 +3451,6 @@ impl<'a> ::std::default::Default for &'a Member_Element { #[derive(Clone,PartialEq,Debug)] pub enum Member_Element_oneof_el { - hub(Hub), - file_recorder(FileRecorder), - relay(Relay), webrtc_play(WebRtcPlayEndpoint), webrtc_pub(WebRtcPublishEndpoint), } @@ -4375,280 +3460,118 @@ impl Member_Element { ::std::default::Default::default() } - // .medea.Hub hub = 1; + // .medea.WebRtcPlayEndpoint webrtc_play = 1; - pub fn get_hub(&self) -> &Hub { + pub fn get_webrtc_play(&self) -> &WebRtcPlayEndpoint { match self.el { - ::std::option::Option::Some(Member_Element_oneof_el::hub(ref v)) => v, - _ => Hub::default_instance(), + ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(ref v)) => v, + _ => WebRtcPlayEndpoint::default_instance(), } } - pub fn clear_hub(&mut self) { + pub fn clear_webrtc_play(&mut self) { self.el = ::std::option::Option::None; } - pub fn has_hub(&self) -> bool { + pub fn has_webrtc_play(&self) -> bool { match self.el { - ::std::option::Option::Some(Member_Element_oneof_el::hub(..)) => true, + ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(..)) => true, _ => false, } } // Param is passed by value, moved - pub fn set_hub(&mut self, v: Hub) { - self.el = ::std::option::Option::Some(Member_Element_oneof_el::hub(v)) + pub fn set_webrtc_play(&mut self, v: WebRtcPlayEndpoint) { + self.el = ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(v)) } // Mutable pointer to the field. - pub fn mut_hub(&mut self) -> &mut Hub { - if let ::std::option::Option::Some(Member_Element_oneof_el::hub(_)) = self.el { + pub fn mut_webrtc_play(&mut self) -> &mut WebRtcPlayEndpoint { + if let ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(_)) = self.el { } else { - self.el = ::std::option::Option::Some(Member_Element_oneof_el::hub(Hub::new())); + self.el = ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(WebRtcPlayEndpoint::new())); } match self.el { - ::std::option::Option::Some(Member_Element_oneof_el::hub(ref mut v)) => v, + ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(ref mut v)) => v, _ => panic!(), } } // Take field - pub fn take_hub(&mut self) -> Hub { - if self.has_hub() { + pub fn take_webrtc_play(&mut self) -> WebRtcPlayEndpoint { + if self.has_webrtc_play() { match self.el.take() { - ::std::option::Option::Some(Member_Element_oneof_el::hub(v)) => v, + ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(v)) => v, _ => panic!(), } } else { - Hub::new() + WebRtcPlayEndpoint::new() } } - // .medea.FileRecorder file_recorder = 2; + // .medea.WebRtcPublishEndpoint webrtc_pub = 2; - pub fn get_file_recorder(&self) -> &FileRecorder { + pub fn get_webrtc_pub(&self) -> &WebRtcPublishEndpoint { match self.el { - ::std::option::Option::Some(Member_Element_oneof_el::file_recorder(ref v)) => v, - _ => FileRecorder::default_instance(), + ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(ref v)) => v, + _ => WebRtcPublishEndpoint::default_instance(), } } - pub fn clear_file_recorder(&mut self) { + pub fn clear_webrtc_pub(&mut self) { self.el = ::std::option::Option::None; } - pub fn has_file_recorder(&self) -> bool { + pub fn has_webrtc_pub(&self) -> bool { match self.el { - ::std::option::Option::Some(Member_Element_oneof_el::file_recorder(..)) => true, + ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(..)) => true, _ => false, } } // Param is passed by value, moved - pub fn set_file_recorder(&mut self, v: FileRecorder) { - self.el = ::std::option::Option::Some(Member_Element_oneof_el::file_recorder(v)) + pub fn set_webrtc_pub(&mut self, v: WebRtcPublishEndpoint) { + self.el = ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(v)) } // Mutable pointer to the field. - pub fn mut_file_recorder(&mut self) -> &mut FileRecorder { - if let ::std::option::Option::Some(Member_Element_oneof_el::file_recorder(_)) = self.el { + pub fn mut_webrtc_pub(&mut self) -> &mut WebRtcPublishEndpoint { + if let ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(_)) = self.el { } else { - self.el = ::std::option::Option::Some(Member_Element_oneof_el::file_recorder(FileRecorder::new())); + self.el = ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(WebRtcPublishEndpoint::new())); } match self.el { - ::std::option::Option::Some(Member_Element_oneof_el::file_recorder(ref mut v)) => v, + ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(ref mut v)) => v, _ => panic!(), } } // Take field - pub fn take_file_recorder(&mut self) -> FileRecorder { - if self.has_file_recorder() { + pub fn take_webrtc_pub(&mut self) -> WebRtcPublishEndpoint { + if self.has_webrtc_pub() { match self.el.take() { - ::std::option::Option::Some(Member_Element_oneof_el::file_recorder(v)) => v, + ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(v)) => v, _ => panic!(), } } else { - FileRecorder::new() - } - } - - // .medea.Relay relay = 3; - - - pub fn get_relay(&self) -> &Relay { - match self.el { - ::std::option::Option::Some(Member_Element_oneof_el::relay(ref v)) => v, - _ => Relay::default_instance(), - } - } - pub fn clear_relay(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_relay(&self) -> bool { - match self.el { - ::std::option::Option::Some(Member_Element_oneof_el::relay(..)) => true, - _ => false, + WebRtcPublishEndpoint::new() } } +} - // Param is passed by value, moved - pub fn set_relay(&mut self, v: Relay) { - self.el = ::std::option::Option::Some(Member_Element_oneof_el::relay(v)) - } - - // Mutable pointer to the field. - pub fn mut_relay(&mut self) -> &mut Relay { - if let ::std::option::Option::Some(Member_Element_oneof_el::relay(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(Member_Element_oneof_el::relay(Relay::new())); +impl ::protobuf::Message for Member_Element { + fn is_initialized(&self) -> bool { + if let Some(Member_Element_oneof_el::webrtc_play(ref v)) = self.el { + if !v.is_initialized() { + return false; + } } - match self.el { - ::std::option::Option::Some(Member_Element_oneof_el::relay(ref mut v)) => v, - _ => panic!(), + if let Some(Member_Element_oneof_el::webrtc_pub(ref v)) = self.el { + if !v.is_initialized() { + return false; + } } - } - - // Take field - pub fn take_relay(&mut self) -> Relay { - if self.has_relay() { - match self.el.take() { - ::std::option::Option::Some(Member_Element_oneof_el::relay(v)) => v, - _ => panic!(), - } - } else { - Relay::new() - } - } - - // .medea.WebRtcPlayEndpoint webrtc_play = 4; - - - pub fn get_webrtc_play(&self) -> &WebRtcPlayEndpoint { - match self.el { - ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(ref v)) => v, - _ => WebRtcPlayEndpoint::default_instance(), - } - } - pub fn clear_webrtc_play(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_webrtc_play(&self) -> bool { - match self.el { - ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_webrtc_play(&mut self, v: WebRtcPlayEndpoint) { - self.el = ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(v)) - } - - // Mutable pointer to the field. - pub fn mut_webrtc_play(&mut self) -> &mut WebRtcPlayEndpoint { - if let ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(WebRtcPlayEndpoint::new())); - } - match self.el { - ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_webrtc_play(&mut self) -> WebRtcPlayEndpoint { - if self.has_webrtc_play() { - match self.el.take() { - ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(v)) => v, - _ => panic!(), - } - } else { - WebRtcPlayEndpoint::new() - } - } - - // .medea.WebRtcPublishEndpoint webrtc_pub = 5; - - - pub fn get_webrtc_pub(&self) -> &WebRtcPublishEndpoint { - match self.el { - ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(ref v)) => v, - _ => WebRtcPublishEndpoint::default_instance(), - } - } - pub fn clear_webrtc_pub(&mut self) { - self.el = ::std::option::Option::None; - } - - pub fn has_webrtc_pub(&self) -> bool { - match self.el { - ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(..)) => true, - _ => false, - } - } - - // Param is passed by value, moved - pub fn set_webrtc_pub(&mut self, v: WebRtcPublishEndpoint) { - self.el = ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(v)) - } - - // Mutable pointer to the field. - pub fn mut_webrtc_pub(&mut self) -> &mut WebRtcPublishEndpoint { - if let ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(_)) = self.el { - } else { - self.el = ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(WebRtcPublishEndpoint::new())); - } - match self.el { - ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(ref mut v)) => v, - _ => panic!(), - } - } - - // Take field - pub fn take_webrtc_pub(&mut self) -> WebRtcPublishEndpoint { - if self.has_webrtc_pub() { - match self.el.take() { - ::std::option::Option::Some(Member_Element_oneof_el::webrtc_pub(v)) => v, - _ => panic!(), - } - } else { - WebRtcPublishEndpoint::new() - } - } -} - -impl ::protobuf::Message for Member_Element { - fn is_initialized(&self) -> bool { - if let Some(Member_Element_oneof_el::hub(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(Member_Element_oneof_el::file_recorder(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(Member_Element_oneof_el::relay(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(Member_Element_oneof_el::webrtc_play(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - if let Some(Member_Element_oneof_el::webrtc_pub(ref v)) = self.el { - if !v.is_initialized() { - return false; - } - } - true + true } fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { @@ -4656,30 +3579,12 @@ impl ::protobuf::Message for Member_Element { let (field_number, wire_type) = is.read_tag_unpack()?; match field_number { 1 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(Member_Element_oneof_el::hub(is.read_message()?)); - }, - 2 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(Member_Element_oneof_el::file_recorder(is.read_message()?)); - }, - 3 => { - if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - } - self.el = ::std::option::Option::Some(Member_Element_oneof_el::relay(is.read_message()?)); - }, - 4 => { if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); } self.el = ::std::option::Option::Some(Member_Element_oneof_el::webrtc_play(is.read_message()?)); }, - 5 => { + 2 => { if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); } @@ -4699,18 +3604,6 @@ impl ::protobuf::Message for Member_Element { let mut my_size = 0; if let ::std::option::Option::Some(ref v) = self.el { match v { - &Member_Element_oneof_el::hub(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &Member_Element_oneof_el::file_recorder(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, - &Member_Element_oneof_el::relay(ref v) => { - let len = v.compute_size(); - my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }, &Member_Element_oneof_el::webrtc_play(ref v) => { let len = v.compute_size(); my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; @@ -4729,28 +3622,13 @@ impl ::protobuf::Message for Member_Element { fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { if let ::std::option::Option::Some(ref v) = self.el { match v { - &Member_Element_oneof_el::hub(ref v) => { - os.write_tag(1, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &Member_Element_oneof_el::file_recorder(ref v) => { - os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, - &Member_Element_oneof_el::relay(ref v) => { - os.write_tag(3, ::protobuf::wire_format::WireTypeLengthDelimited)?; - os.write_raw_varint32(v.get_cached_size())?; - v.write_to_with_cached_sizes(os)?; - }, &Member_Element_oneof_el::webrtc_play(ref v) => { - os.write_tag(4, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_tag(1, ::protobuf::wire_format::WireTypeLengthDelimited)?; os.write_raw_varint32(v.get_cached_size())?; v.write_to_with_cached_sizes(os)?; }, &Member_Element_oneof_el::webrtc_pub(ref v) => { - os.write_tag(5, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; os.write_raw_varint32(v.get_cached_size())?; v.write_to_with_cached_sizes(os)?; }, @@ -4798,21 +3676,6 @@ impl ::protobuf::Message for Member_Element { unsafe { descriptor.get(|| { let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Hub>( - "hub", - Member_Element::has_hub, - Member_Element::get_hub, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, FileRecorder>( - "file_recorder", - Member_Element::has_file_recorder, - Member_Element::get_file_recorder, - )); - fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Relay>( - "relay", - Member_Element::has_relay, - Member_Element::get_relay, - )); fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, WebRtcPlayEndpoint>( "webrtc_play", Member_Element::has_webrtc_play, @@ -4845,9 +3708,6 @@ impl ::protobuf::Message for Member_Element { impl ::protobuf::Clear for Member_Element { fn clear(&mut self) { - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; - self.el = ::std::option::Option::None; self.el = ::std::option::Option::None; self.el = ::std::option::Option::None; self.unknown_fields.clear(); @@ -4903,7 +3763,7 @@ impl WebRtcPublishEndpoint { self.p2p = v; } - // string on_start = 3; + // string on_start = 2; pub fn get_on_start(&self) -> &str { @@ -4929,7 +3789,7 @@ impl WebRtcPublishEndpoint { ::std::mem::replace(&mut self.on_start, ::std::string::String::new()) } - // string on_stop = 4; + // string on_stop = 3; pub fn get_on_stop(&self) -> &str { @@ -4968,10 +3828,10 @@ impl ::protobuf::Message for WebRtcPublishEndpoint { 1 => { ::protobuf::rt::read_proto3_enum_with_unknown_fields_into(wire_type, is, &mut self.p2p, 1, &mut self.unknown_fields)? }, - 3 => { + 2 => { ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.on_start)?; }, - 4 => { + 3 => { ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.on_stop)?; }, _ => { @@ -4990,10 +3850,10 @@ impl ::protobuf::Message for WebRtcPublishEndpoint { my_size += ::protobuf::rt::enum_size(1, self.p2p); } if !self.on_start.is_empty() { - my_size += ::protobuf::rt::string_size(3, &self.on_start); + my_size += ::protobuf::rt::string_size(2, &self.on_start); } if !self.on_stop.is_empty() { - my_size += ::protobuf::rt::string_size(4, &self.on_stop); + my_size += ::protobuf::rt::string_size(3, &self.on_stop); } my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); self.cached_size.set(my_size); @@ -5005,10 +3865,10 @@ impl ::protobuf::Message for WebRtcPublishEndpoint { os.write_enum(1, self.p2p.value())?; } if !self.on_start.is_empty() { - os.write_string(3, &self.on_start)?; + os.write_string(2, &self.on_start)?; } if !self.on_stop.is_empty() { - os.write_string(4, &self.on_stop)?; + os.write_string(3, &self.on_stop)?; } os.write_unknown_fields(self.get_unknown_fields())?; ::std::result::Result::Ok(()) @@ -5419,718 +4279,67 @@ impl ::protobuf::reflect::ProtobufValue for WebRtcPlayEndpoint { } } -#[derive(PartialEq,Clone,Default)] -pub struct Hub { - // special fields - pub unknown_fields: ::protobuf::UnknownFields, - pub cached_size: ::protobuf::CachedSize, -} - -impl<'a> ::std::default::Default for &'a Hub { - fn default() -> &'a Hub { - ::default_instance() - } -} - -impl Hub { - pub fn new() -> Hub { - ::std::default::Default::default() - } -} - -impl ::protobuf::Message for Hub { - fn is_initialized(&self) -> bool { - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - _ => { - ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &dyn (::std::any::Any) { - self as &dyn (::std::any::Any) - } - fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) { - self as &mut dyn (::std::any::Any) - } - fn into_any(self: Box) -> ::std::boxed::Box { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - Self::descriptor_static() - } - - fn new() -> Hub { - Hub::new() - } - - fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let fields = ::std::vec::Vec::new(); - ::protobuf::reflect::MessageDescriptor::new::( - "Hub", - fields, - file_descriptor_proto() - ) - }) - } - } - - fn default_instance() -> &'static Hub { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const Hub, - }; - unsafe { - instance.get(Hub::new) - } - } -} - -impl ::protobuf::Clear for Hub { - fn clear(&mut self) { - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for Hub { - fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for Hub { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) - } -} - -#[derive(PartialEq,Clone,Default)] -pub struct FileRecorder { - // message fields - pub src: ::std::string::String, - pub dst: ::std::string::String, - pub on_start: ::std::string::String, - pub on_stop: ::std::string::String, - // special fields - pub unknown_fields: ::protobuf::UnknownFields, - pub cached_size: ::protobuf::CachedSize, -} - -impl<'a> ::std::default::Default for &'a FileRecorder { - fn default() -> &'a FileRecorder { - ::default_instance() - } -} - -impl FileRecorder { - pub fn new() -> FileRecorder { - ::std::default::Default::default() - } - - // string src = 1; - - - pub fn get_src(&self) -> &str { - &self.src - } - pub fn clear_src(&mut self) { - self.src.clear(); - } - - // Param is passed by value, moved - pub fn set_src(&mut self, v: ::std::string::String) { - self.src = v; - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_src(&mut self) -> &mut ::std::string::String { - &mut self.src - } - - // Take field - pub fn take_src(&mut self) -> ::std::string::String { - ::std::mem::replace(&mut self.src, ::std::string::String::new()) - } - - // string dst = 2; - - - pub fn get_dst(&self) -> &str { - &self.dst - } - pub fn clear_dst(&mut self) { - self.dst.clear(); - } - - // Param is passed by value, moved - pub fn set_dst(&mut self, v: ::std::string::String) { - self.dst = v; - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_dst(&mut self) -> &mut ::std::string::String { - &mut self.dst - } - - // Take field - pub fn take_dst(&mut self) -> ::std::string::String { - ::std::mem::replace(&mut self.dst, ::std::string::String::new()) - } - - // string on_start = 3; - - - pub fn get_on_start(&self) -> &str { - &self.on_start - } - pub fn clear_on_start(&mut self) { - self.on_start.clear(); - } - - // Param is passed by value, moved - pub fn set_on_start(&mut self, v: ::std::string::String) { - self.on_start = v; - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_on_start(&mut self) -> &mut ::std::string::String { - &mut self.on_start - } - - // Take field - pub fn take_on_start(&mut self) -> ::std::string::String { - ::std::mem::replace(&mut self.on_start, ::std::string::String::new()) - } - - // string on_stop = 4; - - - pub fn get_on_stop(&self) -> &str { - &self.on_stop - } - pub fn clear_on_stop(&mut self) { - self.on_stop.clear(); - } - - // Param is passed by value, moved - pub fn set_on_stop(&mut self, v: ::std::string::String) { - self.on_stop = v; - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_on_stop(&mut self) -> &mut ::std::string::String { - &mut self.on_stop - } - - // Take field - pub fn take_on_stop(&mut self) -> ::std::string::String { - ::std::mem::replace(&mut self.on_stop, ::std::string::String::new()) - } -} - -impl ::protobuf::Message for FileRecorder { - fn is_initialized(&self) -> bool { - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - 1 => { - ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.src)?; - }, - 2 => { - ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.dst)?; - }, - 3 => { - ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.on_start)?; - }, - 4 => { - ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.on_stop)?; - }, - _ => { - ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - if !self.src.is_empty() { - my_size += ::protobuf::rt::string_size(1, &self.src); - } - if !self.dst.is_empty() { - my_size += ::protobuf::rt::string_size(2, &self.dst); - } - if !self.on_start.is_empty() { - my_size += ::protobuf::rt::string_size(3, &self.on_start); - } - if !self.on_stop.is_empty() { - my_size += ::protobuf::rt::string_size(4, &self.on_stop); - } - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { - if !self.src.is_empty() { - os.write_string(1, &self.src)?; - } - if !self.dst.is_empty() { - os.write_string(2, &self.dst)?; - } - if !self.on_start.is_empty() { - os.write_string(3, &self.on_start)?; - } - if !self.on_stop.is_empty() { - os.write_string(4, &self.on_stop)?; - } - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &dyn (::std::any::Any) { - self as &dyn (::std::any::Any) - } - fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) { - self as &mut dyn (::std::any::Any) - } - fn into_any(self: Box) -> ::std::boxed::Box { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - Self::descriptor_static() - } - - fn new() -> FileRecorder { - FileRecorder::new() - } - - fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "src", - |m: &FileRecorder| { &m.src }, - |m: &mut FileRecorder| { &mut m.src }, - )); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "dst", - |m: &FileRecorder| { &m.dst }, - |m: &mut FileRecorder| { &mut m.dst }, - )); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "on_start", - |m: &FileRecorder| { &m.on_start }, - |m: &mut FileRecorder| { &mut m.on_start }, - )); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "on_stop", - |m: &FileRecorder| { &m.on_stop }, - |m: &mut FileRecorder| { &mut m.on_stop }, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "FileRecorder", - fields, - file_descriptor_proto() - ) - }) - } - } - - fn default_instance() -> &'static FileRecorder { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const FileRecorder, - }; - unsafe { - instance.get(FileRecorder::new) - } - } -} - -impl ::protobuf::Clear for FileRecorder { - fn clear(&mut self) { - self.src.clear(); - self.dst.clear(); - self.on_start.clear(); - self.on_stop.clear(); - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for FileRecorder { - fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for FileRecorder { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) - } -} - -#[derive(PartialEq,Clone,Default)] -pub struct Relay { - // message fields - pub src: ::std::string::String, - pub dst: ::std::string::String, - // special fields - pub unknown_fields: ::protobuf::UnknownFields, - pub cached_size: ::protobuf::CachedSize, -} - -impl<'a> ::std::default::Default for &'a Relay { - fn default() -> &'a Relay { - ::default_instance() - } -} - -impl Relay { - pub fn new() -> Relay { - ::std::default::Default::default() - } - - // string src = 1; - - - pub fn get_src(&self) -> &str { - &self.src - } - pub fn clear_src(&mut self) { - self.src.clear(); - } - - // Param is passed by value, moved - pub fn set_src(&mut self, v: ::std::string::String) { - self.src = v; - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_src(&mut self) -> &mut ::std::string::String { - &mut self.src - } - - // Take field - pub fn take_src(&mut self) -> ::std::string::String { - ::std::mem::replace(&mut self.src, ::std::string::String::new()) - } - - // string dst = 2; - - - pub fn get_dst(&self) -> &str { - &self.dst - } - pub fn clear_dst(&mut self) { - self.dst.clear(); - } - - // Param is passed by value, moved - pub fn set_dst(&mut self, v: ::std::string::String) { - self.dst = v; - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_dst(&mut self) -> &mut ::std::string::String { - &mut self.dst - } - - // Take field - pub fn take_dst(&mut self) -> ::std::string::String { - ::std::mem::replace(&mut self.dst, ::std::string::String::new()) - } -} - -impl ::protobuf::Message for Relay { - fn is_initialized(&self) -> bool { - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - 1 => { - ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.src)?; - }, - 2 => { - ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.dst)?; - }, - _ => { - ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - if !self.src.is_empty() { - my_size += ::protobuf::rt::string_size(1, &self.src); - } - if !self.dst.is_empty() { - my_size += ::protobuf::rt::string_size(2, &self.dst); - } - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { - if !self.src.is_empty() { - os.write_string(1, &self.src)?; - } - if !self.dst.is_empty() { - os.write_string(2, &self.dst)?; - } - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &dyn (::std::any::Any) { - self as &dyn (::std::any::Any) - } - fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) { - self as &mut dyn (::std::any::Any) - } - fn into_any(self: Box) -> ::std::boxed::Box { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - Self::descriptor_static() - } - - fn new() -> Relay { - Relay::new() - } - - fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "src", - |m: &Relay| { &m.src }, - |m: &mut Relay| { &mut m.src }, - )); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "dst", - |m: &Relay| { &m.dst }, - |m: &mut Relay| { &mut m.dst }, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "Relay", - fields, - file_descriptor_proto() - ) - }) - } - } - - fn default_instance() -> &'static Relay { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const Relay, - }; - unsafe { - instance.get(Relay::new) - } - } -} - -impl ::protobuf::Clear for Relay { - fn clear(&mut self) { - self.src.clear(); - self.dst.clear(); - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for Relay { - fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for Relay { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) - } -} - static file_descriptor_proto_data: &'static [u8] = b"\ - \n\tapi.proto\x12\x05medea\"\xf0\x02\n\rCreateRequest\x12\x0e\n\x02id\ - \x18\x01\x20\x01(\tR\x02id\x12\x1e\n\x03hub\x18\x02\x20\x01(\x0b2\n.mede\ - a.HubH\0R\x03hub\x12:\n\rfile_recorder\x18\x03\x20\x01(\x0b2\x13.medea.F\ - ileRecorderH\0R\x0cfileRecorder\x12'\n\x06member\x18\x04\x20\x01(\x0b2\r\ - .medea.MemberH\0R\x06member\x12$\n\x05relay\x18\x05\x20\x01(\x0b2\x0c.me\ - dea.RelayH\0R\x05relay\x12!\n\x04room\x18\x06\x20\x01(\x0b2\x0b.medea.Ro\ - omH\0R\x04room\x12<\n\x0bwebrtc_play\x18\x07\x20\x01(\x0b2\x19.medea.Web\ - RtcPlayEndpointH\0R\nwebrtcPlay\x12=\n\nwebrtc_pub\x18\x08\x20\x01(\x0b2\ - \x1c.medea.WebRtcPublishEndpointH\0R\twebrtcPubB\x04\n\x02el\"\xc4\x03\n\ - \x0cApplyRequest\x12\x0e\n\x02id\x18\x01\x20\x01(\tR\x02id\x12\x1e\n\x03\ - hub\x18\x02\x20\x01(\x0b2\n.medea.HubH\0R\x03hub\x12:\n\rfile_recorder\ - \x18\x03\x20\x01(\x0b2\x13.medea.FileRecorderH\0R\x0cfileRecorder\x12'\n\ - \x06member\x18\x04\x20\x01(\x0b2\r.medea.MemberH\0R\x06member\x12$\n\x05\ - relay\x18\x05\x20\x01(\x0b2\x0c.medea.RelayH\0R\x05relay\x12!\n\x04room\ - \x18\x06\x20\x01(\x0b2\x0b.medea.RoomH\0R\x04room\x12<\n\x0bwebrtc_play\ - \x18\x07\x20\x01(\x0b2\x19.medea.WebRtcPlayEndpointH\0R\nwebrtcPlay\x12=\ - \n\nwebrtc_pub\x18\x08\x20\x01(\x0b2\x1c.medea.WebRtcPublishEndpointH\0R\ - \twebrtcPub\x122\n\x06policy\x18\t\x20\x01(\x0e2\x1a.medea.ApplyRequest.\ - PolicyR\x06policy\"\x1f\n\x06Policy\x12\t\n\x05APPLY\x10\0\x12\n\n\x06AP\ - PEND\x10\x01B\x04\n\x02el\"\x1b\n\tIdRequest\x12\x0e\n\x02id\x18\x01\x20\ - \x03(\tR\x02id\".\n\x08Response\x12\"\n\x05error\x18\x01\x20\x01(\x0b2\ - \x0c.medea.ErrorR\x05error\"\x9e\x01\n\x0eCreateResponse\x120\n\x03sid\ - \x18\x01\x20\x03(\x0b2\x1e.medea.CreateResponse.SidEntryR\x03sid\x12\"\n\ - \x05error\x18\x02\x20\x01(\x0b2\x0c.medea.ErrorR\x05error\x1a6\n\x08SidE\ - ntry\x12\x10\n\x03key\x18\x01\x20\x01(\tR\x03key\x12\x14\n\x05value\x18\ - \x02\x20\x01(\tR\x05value:\x028\x01\"\xbc\x01\n\x0bGetResponse\x12<\n\ - \x08elements\x18\x01\x20\x03(\x0b2\x20.medea.GetResponse.ElementsEntryR\ - \x08elements\x12\"\n\x05error\x18\x02\x20\x01(\x0b2\x0c.medea.ErrorR\x05\ - error\x1aK\n\rElementsEntry\x12\x10\n\x03key\x18\x01\x20\x01(\tR\x03key\ - \x12$\n\x05value\x18\x02\x20\x01(\x0b2\x0e.medea.ElementR\x05value:\x028\ - \x01\"[\n\x05Error\x12\x12\n\x04code\x18\x02\x20\x01(\rR\x04code\x12\x12\ - \n\x04text\x18\x03\x20\x01(\tR\x04text\x12\x10\n\x03doc\x18\x04\x20\x01(\ - \tR\x03doc\x12\x18\n\x07element\x18\x05\x20\x01(\tR\x07element\"\xda\x02\ - \n\x07Element\x12\x1e\n\x03hub\x18\x02\x20\x01(\x0b2\n.medea.HubH\0R\x03\ - hub\x12:\n\rfile_recorder\x18\x03\x20\x01(\x0b2\x13.medea.FileRecorderH\ - \0R\x0cfileRecorder\x12'\n\x06member\x18\x04\x20\x01(\x0b2\r.medea.Membe\ - rH\0R\x06member\x12$\n\x05relay\x18\x05\x20\x01(\x0b2\x0c.medea.RelayH\0\ - R\x05relay\x12!\n\x04room\x18\x06\x20\x01(\x0b2\x0b.medea.RoomH\0R\x04ro\ - om\x12<\n\x0bwebrtc_play\x18\x07\x20\x01(\x0b2\x19.medea.WebRtcPlayEndpo\ - intH\0R\nwebrtcPlay\x12=\n\nwebrtc_pub\x18\x08\x20\x01(\x0b2\x1c.medea.W\ - ebRtcPublishEndpointH\0R\twebrtcPubB\x04\n\x02el\"\xc9\x03\n\x04Room\x12\ - 5\n\x08pipeline\x18\x01\x20\x03(\x0b2\x19.medea.Room.PipelineEntryR\x08p\ - ipeline\x1aP\n\rPipelineEntry\x12\x10\n\x03key\x18\x01\x20\x01(\tR\x03ke\ - y\x12)\n\x05value\x18\x02\x20\x01(\x0b2\x13.medea.Room.ElementR\x05value\ - :\x028\x01\x1a\xb7\x02\n\x07Element\x12\x1e\n\x03hub\x18\x01\x20\x01(\ - \x0b2\n.medea.HubH\0R\x03hub\x12:\n\rfile_recorder\x18\x02\x20\x01(\x0b2\ - \x13.medea.FileRecorderH\0R\x0cfileRecorder\x12'\n\x06member\x18\x03\x20\ - \x01(\x0b2\r.medea.MemberH\0R\x06member\x12$\n\x05relay\x18\x04\x20\x01(\ - \x0b2\x0c.medea.RelayH\0R\x05relay\x12<\n\x0bwebrtc_play\x18\x05\x20\x01\ - (\x0b2\x19.medea.WebRtcPlayEndpointH\0R\nwebrtcPlay\x12=\n\nwebrtc_pub\ - \x18\x06\x20\x01(\x0b2\x1c.medea.WebRtcPublishEndpointH\0R\twebrtcPubB\ - \x04\n\x02el\"\xfc\x03\n\x06Member\x12\x17\n\x07on_join\x18\x01\x20\x01(\ - \tR\x06onJoin\x12\x19\n\x08on_leave\x18\x02\x20\x01(\tR\x07onLeave\x12\ - \x20\n\x0bcredentials\x18\x03\x20\x01(\tR\x0bcredentials\x127\n\x08pipel\ - ine\x18\x04\x20\x03(\x0b2\x1b.medea.Member.PipelineEntryR\x08pipeline\ - \x1aR\n\rPipelineEntry\x12\x10\n\x03key\x18\x01\x20\x01(\tR\x03key\x12+\ - \n\x05value\x18\x02\x20\x01(\x0b2\x15.medea.Member.ElementR\x05value:\ - \x028\x01\x1a\x8e\x02\n\x07Element\x12\x1e\n\x03hub\x18\x01\x20\x01(\x0b\ - 2\n.medea.HubH\0R\x03hub\x12:\n\rfile_recorder\x18\x02\x20\x01(\x0b2\x13\ - .medea.FileRecorderH\0R\x0cfileRecorder\x12$\n\x05relay\x18\x03\x20\x01(\ - \x0b2\x0c.medea.RelayH\0R\x05relay\x12<\n\x0bwebrtc_play\x18\x04\x20\x01\ - (\x0b2\x19.medea.WebRtcPlayEndpointH\0R\nwebrtcPlay\x12=\n\nwebrtc_pub\ - \x18\x05\x20\x01(\x0b2\x1c.medea.WebRtcPublishEndpointH\0R\twebrtcPubB\ + \n\tapi.proto\x12\x05medea\"\xee\x01\n\rCreateRequest\x12\x0e\n\x02id\ + \x18\x01\x20\x01(\tR\x02id\x12'\n\x06member\x18\x02\x20\x01(\x0b2\r.mede\ + a.MemberH\0R\x06member\x12!\n\x04room\x18\x03\x20\x01(\x0b2\x0b.medea.Ro\ + omH\0R\x04room\x12<\n\x0bwebrtc_play\x18\x04\x20\x01(\x0b2\x19.medea.Web\ + RtcPlayEndpointH\0R\nwebrtcPlay\x12=\n\nwebrtc_pub\x18\x05\x20\x01(\x0b2\ + \x1c.medea.WebRtcPublishEndpointH\0R\twebrtcPubB\x04\n\x02el\"\xc2\x02\n\ + \x0cApplyRequest\x12\x0e\n\x02id\x18\x01\x20\x01(\tR\x02id\x12'\n\x06mem\ + ber\x18\x02\x20\x01(\x0b2\r.medea.MemberH\0R\x06member\x12!\n\x04room\ + \x18\x03\x20\x01(\x0b2\x0b.medea.RoomH\0R\x04room\x12<\n\x0bwebrtc_play\ + \x18\x04\x20\x01(\x0b2\x19.medea.WebRtcPlayEndpointH\0R\nwebrtcPlay\x12=\ + \n\nwebrtc_pub\x18\x05\x20\x01(\x0b2\x1c.medea.WebRtcPublishEndpointH\0R\ + \twebrtcPub\x122\n\x06policy\x18\x06\x20\x01(\x0e2\x1a.medea.ApplyReques\ + t.PolicyR\x06policy\"\x1f\n\x06Policy\x12\t\n\x05APPLY\x10\0\x12\n\n\x06\ + APPEND\x10\x01B\x04\n\x02el\"\x1b\n\tIdRequest\x12\x0e\n\x02id\x18\x01\ + \x20\x03(\tR\x02id\".\n\x08Response\x12\"\n\x05error\x18\x01\x20\x01(\ + \x0b2\x0c.medea.ErrorR\x05error\"\x9e\x01\n\x0eCreateResponse\x120\n\x03\ + sid\x18\x01\x20\x03(\x0b2\x1e.medea.CreateResponse.SidEntryR\x03sid\x12\ + \"\n\x05error\x18\x02\x20\x01(\x0b2\x0c.medea.ErrorR\x05error\x1a6\n\x08\ + SidEntry\x12\x10\n\x03key\x18\x01\x20\x01(\tR\x03key\x12\x14\n\x05value\ + \x18\x02\x20\x01(\tR\x05value:\x028\x01\"\xbc\x01\n\x0bGetResponse\x12<\ + \n\x08elements\x18\x01\x20\x03(\x0b2\x20.medea.GetResponse.ElementsEntry\ + R\x08elements\x12\"\n\x05error\x18\x02\x20\x01(\x0b2\x0c.medea.ErrorR\ + \x05error\x1aK\n\rElementsEntry\x12\x10\n\x03key\x18\x01\x20\x01(\tR\x03\ + key\x12$\n\x05value\x18\x02\x20\x01(\x0b2\x0e.medea.ElementR\x05value:\ + \x028\x01\"[\n\x05Error\x12\x12\n\x04code\x18\x01\x20\x01(\rR\x04code\ + \x12\x12\n\x04text\x18\x02\x20\x01(\tR\x04text\x12\x10\n\x03doc\x18\x03\ + \x20\x01(\tR\x03doc\x12\x18\n\x07element\x18\x04\x20\x01(\tR\x07element\ + \"\xd8\x01\n\x07Element\x12'\n\x06member\x18\x01\x20\x01(\x0b2\r.medea.M\ + emberH\0R\x06member\x12!\n\x04room\x18\x02\x20\x01(\x0b2\x0b.medea.RoomH\ + \0R\x04room\x12<\n\x0bwebrtc_play\x18\x03\x20\x01(\x0b2\x19.medea.WebRtc\ + PlayEndpointH\0R\nwebrtcPlay\x12=\n\nwebrtc_pub\x18\x04\x20\x01(\x0b2\ + \x1c.medea.WebRtcPublishEndpointH\0R\twebrtcPubB\x04\n\x02el\"\xc7\x02\n\ + \x04Room\x125\n\x08pipeline\x18\x01\x20\x03(\x0b2\x19.medea.Room.Pipelin\ + eEntryR\x08pipeline\x1aP\n\rPipelineEntry\x12\x10\n\x03key\x18\x01\x20\ + \x01(\tR\x03key\x12)\n\x05value\x18\x02\x20\x01(\x0b2\x13.medea.Room.Ele\ + mentR\x05value:\x028\x01\x1a\xb5\x01\n\x07Element\x12'\n\x06member\x18\ + \x01\x20\x01(\x0b2\r.medea.MemberH\0R\x06member\x12<\n\x0bwebrtc_play\ + \x18\x02\x20\x01(\x0b2\x19.medea.WebRtcPlayEndpointH\0R\nwebrtcPlay\x12=\ + \n\nwebrtc_pub\x18\x03\x20\x01(\x0b2\x1c.medea.WebRtcPublishEndpointH\0R\ + \twebrtcPubB\x04\n\x02el\"\xfa\x02\n\x06Member\x12\x17\n\x07on_join\x18\ + \x01\x20\x01(\tR\x06onJoin\x12\x19\n\x08on_leave\x18\x02\x20\x01(\tR\x07\ + onLeave\x12\x20\n\x0bcredentials\x18\x03\x20\x01(\tR\x0bcredentials\x127\ + \n\x08pipeline\x18\x04\x20\x03(\x0b2\x1b.medea.Member.PipelineEntryR\x08\ + pipeline\x1aR\n\rPipelineEntry\x12\x10\n\x03key\x18\x01\x20\x01(\tR\x03k\ + ey\x12+\n\x05value\x18\x02\x20\x01(\x0b2\x15.medea.Member.ElementR\x05va\ + lue:\x028\x01\x1a\x8c\x01\n\x07Element\x12<\n\x0bwebrtc_play\x18\x01\x20\ + \x01(\x0b2\x19.medea.WebRtcPlayEndpointH\0R\nwebrtcPlay\x12=\n\nwebrtc_p\ + ub\x18\x02\x20\x01(\x0b2\x1c.medea.WebRtcPublishEndpointH\0R\twebrtcPubB\ \x04\n\x02el\"\xae\x01\n\x15WebRtcPublishEndpoint\x122\n\x03p2p\x18\x01\ \x20\x01(\x0e2\x20.medea.WebRtcPublishEndpoint.P2PR\x03p2p\x12\x19\n\x08\ - on_start\x18\x03\x20\x01(\tR\x07onStart\x12\x17\n\x07on_stop\x18\x04\x20\ + on_start\x18\x02\x20\x01(\tR\x07onStart\x12\x17\n\x07on_stop\x18\x03\x20\ \x01(\tR\x06onStop\"-\n\x03P2P\x12\t\n\x05NEVER\x10\0\x12\x0f\n\x0bIF_PO\ SSIBLE\x10\x01\x12\n\n\x06ALWAYS\x10\x02\"Z\n\x12WebRtcPlayEndpoint\x12\ \x10\n\x03src\x18\x01\x20\x01(\tR\x03src\x12\x19\n\x08on_start\x18\x02\ \x20\x01(\tR\x07onStart\x12\x17\n\x07on_stop\x18\x03\x20\x01(\tR\x06onSt\ - op\"\x05\n\x03Hub\"f\n\x0cFileRecorder\x12\x10\n\x03src\x18\x01\x20\x01(\ - \tR\x03src\x12\x10\n\x03dst\x18\x02\x20\x01(\tR\x03dst\x12\x19\n\x08on_s\ - tart\x18\x03\x20\x01(\tR\x07onStart\x12\x17\n\x07on_stop\x18\x04\x20\x01\ - (\tR\x06onStop\"+\n\x05Relay\x12\x10\n\x03src\x18\x01\x20\x01(\tR\x03src\ - \x12\x10\n\x03dst\x18\x02\x20\x01(\tR\x03dst2\xcc\x01\n\nControlApi\x125\ - \n\x06Create\x12\x14.medea.CreateRequest\x1a\x15.medea.CreateResponse\ - \x12-\n\x05Apply\x12\x13.medea.ApplyRequest\x1a\x0f.medea.Response\x12+\ - \n\x06Delete\x12\x10.medea.IdRequest\x1a\x0f.medea.Response\x12+\n\x03Ge\ - t\x12\x10.medea.IdRequest\x1a\x12.medea.GetResponseb\x06proto3\ + op2\xcc\x01\n\nControlApi\x125\n\x06Create\x12\x14.medea.CreateRequest\ + \x1a\x15.medea.CreateResponse\x12-\n\x05Apply\x12\x13.medea.ApplyRequest\ + \x1a\x0f.medea.Response\x12+\n\x06Delete\x12\x10.medea.IdRequest\x1a\x0f\ + .medea.Response\x12+\n\x03Get\x12\x10.medea.IdRequest\x1a\x12.medea.GetR\ + esponseb\x06proto3\ "; static mut file_descriptor_proto_lazy: ::protobuf::lazy::Lazy<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::lazy::Lazy { diff --git a/src/api/control/endpoints/mod.rs b/src/api/control/endpoints/mod.rs index 7aa914f25..764e757ac 100644 --- a/src/api/control/endpoints/mod.rs +++ b/src/api/control/endpoints/mod.rs @@ -73,12 +73,10 @@ impl Into for EndpointSpec { impl TryFrom<(Id, MemberElementProto)> for EndpointSpec { type Error = TryFromProtobufError; - fn try_from(value: (Id, MemberElementProto)) -> Result { + fn try_from( + (_, proto): (Id, MemberElementProto), + ) -> Result { use MemberElementProto::*; - - let id = value.0; - let proto = value.1; - match proto { webrtc_play(elem) => { let play = WebRtcPlayEndpoint::try_from(&elem)?; @@ -88,9 +86,6 @@ impl TryFrom<(Id, MemberElementProto)> for EndpointSpec { let publish = WebRtcPublishEndpoint::from(&elem); Ok(Self::WebRtcPublish(publish)) } - hub(_) | file_recorder(_) | relay(_) => { - Err(TryFromProtobufError::UnimplementedEndpoint(id.0)) - } } } } @@ -100,7 +95,6 @@ impl TryFrom<(Id, ElementProto)> for EndpointSpec { fn try_from((id, proto): (Id, ElementProto)) -> Result { use ElementProto::*; - match proto { webrtc_play(elem) => { let play = WebRtcPlayEndpoint::try_from(&elem)?; @@ -110,9 +104,6 @@ impl TryFrom<(Id, ElementProto)> for EndpointSpec { let publish = WebRtcPublishEndpoint::from(&elem); Ok(Self::WebRtcPublish(publish)) } - hub(_) | file_recorder(_) | relay(_) => { - Err(TryFromProtobufError::UnimplementedEndpoint(id.0)) - } member(_) | room(_) => { Err(TryFromProtobufError::ExpectedOtherElement( String::from("Endpoint"), diff --git a/src/conf/control_api.rs b/src/conf/control.rs similarity index 69% rename from src/conf/control_api.rs rename to src/conf/control.rs index 6f5f49d55..3500880e5 100644 --- a/src/conf/control_api.rs +++ b/src/conf/control.rs @@ -8,19 +8,18 @@ use smart_default::SmartDefault; /// [Control API] settings. /// /// [Control API]: https://tinyurl.com/yxsqplq7 -#[allow(clippy::module_name_repetitions)] #[derive(Clone, Debug, Deserialize, Serialize, SmartDefault)] #[serde(default)] pub struct ControlApi { /// Path to directory with static [Сontrol API] specs. /// /// [Control API]: https://tinyurl.com/yxsqplq7 - #[default(String::from("specs/"))] + #[default = "specs/"] pub static_specs_dir: String, } #[cfg(test)] -mod control_conf_specs { +mod spec { use serial_test_derive::serial; use crate::{conf::Conf, overrided_by_env_conf}; @@ -30,14 +29,14 @@ mod control_conf_specs { fn overrides_defaults() { let default_conf = Conf::default(); let env_conf = overrided_by_env_conf!( - "MEDEA_CONTROL_API__STATIC_SPECS_DIR" => "test/", + "MEDEA_CONTROL__STATIC_SPECS_DIR" => "test/", ); assert_ne!( - default_conf.control_api.static_specs_dir, - env_conf.control_api.static_specs_dir + default_conf.control.static_specs_dir, + env_conf.control.static_specs_dir ); - assert_eq!(env_conf.control_api.static_specs_dir, "test/"); + assert_eq!(env_conf.control.static_specs_dir, "test/"); } } diff --git a/src/conf/grpc_listener.rs b/src/conf/grpc_listener.rs deleted file mode 100644 index 137e411fa..000000000 --- a/src/conf/grpc_listener.rs +++ /dev/null @@ -1,24 +0,0 @@ -//! gRPC server settings. - -use std::net::{IpAddr, Ipv4Addr}; - -use serde::{Deserialize, Serialize}; -use smart_default::SmartDefault; - -/// gRPC server settings. -#[allow(clippy::module_name_repetitions)] -#[derive(Clone, Debug, Deserialize, Serialize, SmartDefault)] -#[serde(default)] -pub struct GrpcListener { - /// IP address to bind gRPC server to. Defaults to `0.0.0.0`. - #[default(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)))] - pub bind_ip: IpAddr, - - /// Port to bind gRPC server to. Defaults to `6565`. - #[default(6565)] - pub bind_port: u16, - - /// Completion queue count of gRPC server. Defaults to `2`. - #[default(2)] - pub completion_queue_count: usize, -} diff --git a/src/conf/http_listener.rs b/src/conf/http_listener.rs deleted file mode 100644 index 6413f1f2e..000000000 --- a/src/conf/http_listener.rs +++ /dev/null @@ -1,32 +0,0 @@ -//! HTTP server settings. - -use std::net::{IpAddr, Ipv4Addr, SocketAddr, ToSocketAddrs as _}; - -use serde::{Deserialize, Serialize}; -use smart_default::SmartDefault; - -/// HTTP server settings. -#[allow(clippy::module_name_repetitions)] -#[derive(Clone, Debug, Deserialize, Serialize, SmartDefault)] -#[serde(default)] -pub struct HttpListener { - /// IP address to bind HTTP server to. Defaults to `0.0.0.0`. - #[default(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)))] - pub bind_ip: IpAddr, - - /// Port to bind HTTP server to. Defaults to `8080`. - #[default(8080)] - pub bind_port: u16, -} - -impl HttpListener { - /// Builds [`SocketAddr`] from `bind_ip` and `bind_port`. - #[inline] - pub fn bind_addr(&self) -> SocketAddr { - (self.bind_ip, self.bind_port) - .to_socket_addrs() - .unwrap() - .next() - .unwrap() - } -} diff --git a/src/conf/log.rs b/src/conf/log.rs index d7484d154..8f6a34ff6 100644 --- a/src/conf/log.rs +++ b/src/conf/log.rs @@ -11,7 +11,7 @@ use smart_default::SmartDefault; pub struct Log { /// Maximum allowed level of application log entries. /// Defaults to `INFO`. - #[default("INFO")] + #[default = "INFO"] pub level: Cow<'static, str>, } diff --git a/src/conf/mod.rs b/src/conf/mod.rs index eb888b530..f75778624 100644 --- a/src/conf/mod.rs +++ b/src/conf/mod.rs @@ -1,8 +1,6 @@ //! Provides application configuration options. -pub mod control_api; -pub mod grpc_listener; -pub mod http_listener; +pub mod control; pub mod log; pub mod rpc; pub mod server; @@ -17,7 +15,7 @@ use serde::{Deserialize, Serialize}; #[doc(inline)] pub use self::{ - control_api::ControlApi, + control::ControlApi, log::Log, rpc::Rpc, server::Server, @@ -54,7 +52,7 @@ pub struct Conf { /// [Control API] settings. /// /// [Control API]: https://tinyurl.com/yxsqplq7 - pub control_api: ControlApi, + pub control: ControlApi, } impl Conf { @@ -98,14 +96,13 @@ where } #[cfg(test)] -pub mod tests { +pub(crate) mod spec { use serial_test_derive::serial; use super::*; - /// Macro which overrides environment variables - /// with provided values, parses [`Conf`] and - /// finally removes all overrided variables. + /// Macro which overrides environment variables with provided values, + /// parses [`Conf`] and finally removes all the overrided variables. /// /// # Usage /// diff --git a/src/conf/rpc.rs b/src/conf/rpc.rs index 9eb2badba..0d0f26a96 100644 --- a/src/conf/rpc.rs +++ b/src/conf/rpc.rs @@ -23,7 +23,7 @@ pub struct Rpc { } #[cfg(test)] -mod rpc_conf_specs { +mod spec { use std::{fs, time::Duration}; use serial_test_derive::serial; diff --git a/src/conf/server.rs b/src/conf/server.rs index 35362c898..84dc0593a 100644 --- a/src/conf/server.rs +++ b/src/conf/server.rs @@ -1,46 +1,98 @@ //! Settings for application servers. +#![allow(clippy::module_name_repetitions)] + +use std::net::{IpAddr, Ipv4Addr, SocketAddr, ToSocketAddrs as _}; + use serde::{Deserialize, Serialize}; use smart_default::SmartDefault; -use super::{grpc_listener::GrpcListener, http_listener::HttpListener}; - /// [Client API] servers settings. /// /// [Client API]: https://tinyurl.com/yx9thsnr -#[allow(clippy::module_name_repetitions)] #[derive(Clone, Debug, Deserialize, Serialize, SmartDefault)] #[serde(default)] pub struct ClientApiServer { - /// [Client API] server settings. + /// [Client API] HTTP server settings. /// /// [Client API]: https://tinyurl.com/yx9thsnr - pub http: HttpListener, + pub http: ClientApiHttpServer, +} - /// Public URL of server. Address for exposed [Client API]. +/// [Client API] HTTP server settings. +/// +/// [Client API]: https://tinyurl.com/yx9thsnr +#[derive(Clone, Debug, Deserialize, Serialize, SmartDefault)] +#[serde(default)] +pub struct ClientApiHttpServer { + /// Public URL of HTTP server. Address for exposed [Client API]. + /// It's assumed that HTTP server can be reached via this URL externally. /// - /// This address will be returned from [Control API] in `sids` and to - /// this address will connect [Jason] for start session. + /// This address is returned from [Control API] in `sids` field + /// and [Jason] uses this address to start its session. /// - /// Defaults to `ws://0.0.0.0:8080`. + /// Defaults to `ws://127.0.0.1:8080`. /// /// [Client API]: https://tinyurl.com/yx9thsnr + /// [Control API]: https://tinyurl.com/yxsqplq7 /// [Jason]: https://github.com/instrumentisto/medea/tree/master/jason - #[default("ws://0.0.0.0:8080".to_string())] + #[default = "ws://127.0.0.1:8080"] pub public_url: String, + + /// IP address to bind HTTP server to. + /// + /// Defaults to `0.0.0.0`. + #[default(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)))] + pub bind_ip: IpAddr, + + /// Port to bind HTTP server to. + /// + /// Defaults to `8080`. + #[default = 8080] + pub bind_port: u16, +} + +impl ClientApiHttpServer { + /// Builds [`SocketAddr`] from `bind_ip` and `bind_port`. + #[inline] + pub fn bind_addr(&self) -> SocketAddr { + (self.bind_ip, self.bind_port) + .to_socket_addrs() + .unwrap() + .next() + .unwrap() + } } /// [Control API] servers settings. /// /// [Control API]: https://tinyurl.com/yxsqplq7 -#[allow(clippy::module_name_repetitions)] #[derive(Clone, Debug, Deserialize, Serialize, SmartDefault)] #[serde(default)] pub struct ControlApiServer { - /// gRPC [Control API] server settings. + /// [Control API] gRPC server settings. /// /// [Control API]: https://tinyurl.com/yxsqplq7 - pub grpc: GrpcListener, + pub grpc: ControlApiGrpcServer, +} + +/// [Control API] gRPC server settings. +/// +/// [Control API]: https://tinyurl.com/yxsqplq7 +#[derive(Clone, Debug, Deserialize, Serialize, SmartDefault)] +#[serde(default)] +pub struct ControlApiGrpcServer { + /// IP address to bind gRPC server to. + /// + /// Defaults to `0.0.0.0`. + #[default(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)))] + pub bind_ip: IpAddr, + + /// Port to bind gRPC server to. + /// + /// Defaults to `6565`. + #[default = 6565] + pub bind_port: u16, } /// Settings for application servers. @@ -98,7 +150,7 @@ mod server_spec { } #[cfg(test)] -mod control_grpc_conf_specs { +mod control_grpc_spec { use std::net::Ipv4Addr; use serial_test_derive::serial; diff --git a/src/conf/shutdown.rs b/src/conf/shutdown.rs index 99bb44c62..6900500f8 100644 --- a/src/conf/shutdown.rs +++ b/src/conf/shutdown.rs @@ -16,7 +16,7 @@ pub struct Shutdown { } #[cfg(test)] -mod shutdown_conf_specs { +mod spec { use std::time::Duration; use serial_test_derive::serial; diff --git a/src/conf/turn.rs b/src/conf/turn.rs index 9a05d8bf8..836073c60 100644 --- a/src/conf/turn.rs +++ b/src/conf/turn.rs @@ -70,7 +70,7 @@ pub struct Redis { } #[cfg(test)] -mod turn_conf_specs { +mod spec { use std::{net::Ipv4Addr, time::Duration}; use serial_test_derive::serial; From f8a08b73e3edcea9f403b2f1eb5e22305ee1d3e8 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 11 Oct 2019 12:34:34 +0300 Subject: [PATCH 697/735] Return cmake to Dockerfile --- Dockerfile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Dockerfile b/Dockerfile index 410303c66..37435f4f3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,6 +19,11 @@ RUN mkdir -p /out/etc/ \ && echo 'nobody:x:65534:65534:nobody:/:' > /out/etc/passwd \ && echo 'nobody:x:65534:' > /out/etc/group +# Install required system packages for building. +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + cmake + # Prepare Cargo workspace for building dependencies only. COPY crates/medea-macro/Cargo.toml /app/crates/medea-macro/ COPY proto/client-api/Cargo.toml /app/proto/client-api/ From cb9d110b6aefaaba10897b0b20b7466f00e8b2d2 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 11 Oct 2019 13:46:41 +0300 Subject: [PATCH 698/735] Reread [run ci] --- config.toml | 1 + .../control/endpoints/webrtc_play_endpoint.rs | 3 ++- src/api/control/error_codes.rs | 27 ++++++++++--------- src/api/control/grpc/server.rs | 10 +++---- src/api/control/local_uri.rs | 15 ++++++----- src/api/control/member.rs | 2 ++ src/api/control/mod.rs | 2 +- src/conf/control.rs | 1 + src/signalling/participants.rs | 2 +- src/signalling/room.rs | 2 +- src/signalling/room_service.rs | 14 +++------- tests/e2e/grpc_control_api/mod.rs | 2 +- 12 files changed, 41 insertions(+), 40 deletions(-) diff --git a/config.toml b/config.toml index 9b714a962..fcbb18d78 100644 --- a/config.toml +++ b/config.toml @@ -128,6 +128,7 @@ # Env var: MEDEA_LOG__LEVEL # Possible values: # "OFF", "CRITICAL", "ERROR", "WARN", "INFO", "DEBUG", "TRACE" +# # Default: # level = "INFO" diff --git a/src/api/control/endpoints/webrtc_play_endpoint.rs b/src/api/control/endpoints/webrtc_play_endpoint.rs index 21974f0b8..a770778d5 100644 --- a/src/api/control/endpoints/webrtc_play_endpoint.rs +++ b/src/api/control/endpoints/webrtc_play_endpoint.rs @@ -64,7 +64,7 @@ pub enum SrcParseError { /// Note that [`SrcUri`] is parsing with [`LocalUri`] parser. /// Actually difference between [`SrcUri`] and [`LocalUri`] /// in endpoint ID's type. In [`SrcUri`] it [`WebRtcPublishId`], and in -/// [`LocalUri`] it [`String`]. Also [`SrcUri`] can be deserialized with +/// [`LocalUri`] it [`EndpointId`]. Also [`SrcUri`] can be deserialized with /// [`serde`]. /// /// Atm used only in [Control API] specs. @@ -72,6 +72,7 @@ pub enum SrcParseError { /// [`WebRtcPublishEndpoint`]: /// crate::api::control::endpoints::WebRtcPublishEndpoint /// [Control API]: https://tinyurl.com/yxsqplq7 +/// [`EndpointId`]: crate::api::control::EndpointId #[derive(Clone, Debug)] pub struct SrcUri { /// ID of [`Room`]. diff --git a/src/api/control/error_codes.rs b/src/api/control/error_codes.rs index 4829f90d6..7cd1b63ed 100644 --- a/src/api/control/error_codes.rs +++ b/src/api/control/error_codes.rs @@ -1,4 +1,4 @@ -//! All errors which medea can return to control API user. +//! All errors which Medea can return to Control API user. //! //! # Error codes ranges //! - `1000` ... `1999` Client errors @@ -23,7 +23,7 @@ use crate::{ }, }; -/// Medea's control API error response. +/// Medea's Control API error response. pub struct ErrorResponse { /// [`ErrorCode`] which will be returned with code and message. error_code: ErrorCode, @@ -136,16 +136,16 @@ pub enum ErrorCode { #[display(fmt = "Unimplemented API call.")] UnimplementedCall = 1000, - /// Request does not contain any elements. + /// Request doesn't contain any elements. /// /// Code: __1001__. - #[display(fmt = "Request does not contain any elements")] + #[display(fmt = "Request doesn't contain any elements")] NoElement = 1001, - /// Provided uri can not point to provided element. + /// Provided uri can't point to provided element. /// /// Code: __1002__. - #[display(fmt = "Provided uri can not point to provided element")] + #[display(fmt = "Provided uri can't point to provided element")] ElementIdMismatch = 1002, /// Room not found. @@ -178,10 +178,10 @@ pub enum ErrorCode { #[display(fmt = "Expected Member element but it's not.")] NotMemberInSpec = 1007, - /// Invalid source URI in play endpoint. + /// Invalid source URI in [`WebRtcPlayEndpoint`]. /// /// Code: __1008__. - #[display(fmt = "Invalid source ID in publish endpoint spec.")] + #[display(fmt = "Invalid source URI in 'WebRtcPlayEndpoint'.")] InvalidSrcUri = 1008, /// Provided not source URI in [`WebRtcPlayEndpoint`]. @@ -190,13 +190,13 @@ pub enum ErrorCode { /// /// [`WebRtcPlayEndpoint`]: /// crate::signalling::elements::endpoints::webrtc::WebRtcPlayEndpoint - #[display(fmt = "Provided not source URI.")] + #[display(fmt = "Provided not source URI in 'WebRtcPlayEndpoint'.")] NotSourceUri = 1009, - /// Element's ID don't have "local://" prefix. + /// Element's URI don't have `local://` prefix. /// /// Code: __1010__. - #[display(fmt = "Element's ID's URI not have 'local://' protocol.")] + #[display(fmt = "Element's URI don't have 'local://' prefix.")] ElementIdIsNotLocal = 1010, /// Provided element's URI with too many paths. @@ -226,13 +226,13 @@ pub enum ErrorCode { EmptyElementsList = 1014, /// Provided not the same Room IDs in elements IDs. Probably you try use - /// Delete method for elements with different Room IDs + /// `Delete` method for elements with different Room IDs /// /// Code: __1015__. /// /// [`RoomId`]: crate::api::control::room::Id #[display(fmt = "Provided not the same Room IDs in elements IDs. \ - Probably you try use Delete method for elements with \ + Probably you try use 'Delete' method for elements with \ different Room IDs")] ProvidedNotSameRoomIds = 1015, @@ -247,6 +247,7 @@ pub enum ErrorCode { /// Code: __1017__. #[display(fmt = "Member with provided URI already exists.")] MemberAlreadyExists = 1017, + /// Endpoint with provided URI already exists. /// /// Code: __1018__. diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index d5433afa7..523a793d8 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -85,7 +85,7 @@ struct ControlApiService { impl ControlApiService { /// Returns [Control API] sid based on provided arguments and - /// `MEDEA_CLIENT.PUBLIC_URL` config value. + /// `MEDEA_SERVER__CLIENT__HTTP__PUBLIC_URL` config value. fn get_sid( &self, room_id: &RoomId, @@ -149,7 +149,7 @@ impl ControlApiService { .and_then(|r| r.map_err(GrpcControlApiError::from).map(|_| sids)) } - /// Implementation of `Create` method for [`Endpoint`] elements. + /// Implementation of `Create` method for [`Endpoint`] element. fn create_endpoint( &self, uri: LocalUri, @@ -336,7 +336,7 @@ impl ControlApi for ControlApiService { }) .map_err(|e| { warn!( - "Error while sending response on Delete request by \ + "Error while sending response on 'Delete' request by \ gRPC: {:?}", e ) @@ -374,8 +374,8 @@ impl ControlApi for ControlApiService { }) .map_err(|e| { warn!( - "Error while sending response on Get request by gRPC: \ - {:?}", + "Error while sending response on 'Get' request by \ + gRPC: {:?}", e ) }), diff --git a/src/api/control/local_uri.rs b/src/api/control/local_uri.rs index 631a15205..a28a3bf42 100644 --- a/src/api/control/local_uri.rs +++ b/src/api/control/local_uri.rs @@ -1,4 +1,4 @@ -//! URI for pointing to some medea element. +//! URI for pointing to some Medea element. // Fix clippy's wrong errors for `Self` in `LocalUri`s with states as generics. #![allow(clippy::use_self)] @@ -48,11 +48,11 @@ pub struct ToEndpoint(LocalUri, EndpointId); /// /// ``` /// # use crate::api::control::local_uri::{LocalUri, ToEndpoint}; -/// # use crate::api::control::{RoomId, MemberId}; +/// # use crate::api::control::{RoomId, MemberId, EndpointId}; /// # /// let orig_room_id = RoomId("room".to_string()); /// let orig_member_id = MemberId("member".to_string()); -/// let orig_endpoint_id = "endpoint".to_string(); +/// let orig_endpoint_id = EndpointId("endpoint".to_string()); /// /// // Create new LocalUri for endpoint. /// let local_uri = LocalUri::::new( @@ -60,13 +60,14 @@ pub struct ToEndpoint(LocalUri, EndpointId); /// orig_member_id.clone(), /// orig_endpoint_id.clone() /// ); +/// let local_uri_clone = local_uri.clone(); /// /// // We can get reference to room_id from this LocalUri /// // without taking ownership: /// assert_eq!(local_uri.room_id(), &orig_room_id); /// /// // If you want to take all IDs ownership, you should do this steps: -/// let (endpoint_id, member_uri) = local_uri.clone().take_endpoint_id(); +/// let (endpoint_id, member_uri) = local_uri.take_endpoint_id(); /// assert_eq!(endpoint_id, orig_endpoint_id); /// /// let (member_id, room_uri) = member_uri.take_member_id(); @@ -76,7 +77,7 @@ pub struct ToEndpoint(LocalUri, EndpointId); /// assert_eq!(room_id, orig_room_id); /// /// // Or simply -/// let (room_id, member_id, endpoint_id) = local_uri.take_all(); +/// let (room_id, member_id, endpoint_id) = local_uri_clone.take_all(); /// ``` /// /// This is necessary so that it is not possible to get the address in the @@ -95,7 +96,7 @@ pub struct LocalUri { } impl LocalUri { - /// Create new [`LocalUri`] in [`ToRoom`] state. + /// Creates new [`LocalUri`] in [`ToRoom`] state. pub fn new(room_id: RoomId) -> Self { Self { state: ToRoom(room_id), @@ -112,7 +113,7 @@ impl LocalUri { self.state.0 } - /// Push [`MemberId`] to the end of URI and returns + /// Pushes [`MemberId`] to the end of URI and returns /// [`LocalUri`] in [`ToMember`] state. pub fn push_member_id(self, member_id: MemberId) -> LocalUri { LocalUri::::new(self.state.0, member_id) diff --git a/src/api/control/member.rs b/src/api/control/member.rs index dbec39202..d2a80bc7f 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -119,6 +119,8 @@ impl MemberSpec { /// This credentials will be generated if in dynamic [Control API] spec not /// provided credentials for [`Member`]. This logic you can find in [`TryFrom`] /// [`MemberProto`] implemented for [`MemberSpec`]. +/// +/// [Control API]: https://tinyurl.com/yxsqplq7 fn generate_member_credentials() -> String { rand::thread_rng() .sample_iter(&Alphanumeric) diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index 1e9ac94ec..98dda42a5 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -113,7 +113,7 @@ pub enum TryFromElementError { /// /// [Control API]: https://tinyurl.com/yxsqplq7 #[allow(clippy::pub_enum_variant_names)] -#[derive(Debug, Fail, Display)] +#[derive(Debug, Display, Fail)] pub enum LoadStaticControlSpecsError { /// Error while reading default or provided in config /// (`MEDEA_CONTROL_API.STATIC_SPECS_DIR` environment variable) static diff --git a/src/conf/control.rs b/src/conf/control.rs index 3500880e5..d787337c1 100644 --- a/src/conf/control.rs +++ b/src/conf/control.rs @@ -8,6 +8,7 @@ use smart_default::SmartDefault; /// [Control API] settings. /// /// [Control API]: https://tinyurl.com/yxsqplq7 +#[allow(clippy::module_name_repetitions)] #[derive(Clone, Debug, Deserialize, Serialize, SmartDefault)] #[serde(default)] pub struct ControlApi { diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 62ba9cca8..245d2ab66 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -419,7 +419,7 @@ impl ParticipantService { } } - pub fn create_membe(&mut self, id: MemberId, member: Member) { + pub fn create_member(&mut self, id: MemberId, member: Member) { self.members.insert(id, member); } } diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 70e743c6e..7c77d07a9 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -845,7 +845,7 @@ impl Room { src.add_sink(sink.downgrade()); } - self.members.create_membe(id, signalling_member); + self.members.create_member(id, signalling_member); Ok(()) } diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index b551a17c1..a785bd69c 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -267,11 +267,8 @@ impl Handler for RoomService { .and_then(|r| r.map_err(RoomServiceError::from)), ) } else { - Box::new(future::err(RoomServiceError::RoomNotFound(LocalUri::< - ToRoom, - >::new( - room_id - )))) + let room_uri = LocalUri::::new(room_id); + Box::new(future::err(RoomServiceError::RoomNotFound(room_uri))) } } } @@ -307,11 +304,8 @@ impl Handler for RoomService { .and_then(|r| r.map_err(RoomServiceError::from)), ) } else { - Box::new(future::err(RoomServiceError::RoomNotFound(LocalUri::< - ToRoom, - >::new( - room_id - )))) + let room_uri = LocalUri::::new(room_id); + Box::new(future::err(RoomServiceError::RoomNotFound(room_uri))) } } } diff --git a/tests/e2e/grpc_control_api/mod.rs b/tests/e2e/grpc_control_api/mod.rs index 3d4340479..fbfaaf318 100644 --- a/tests/e2e/grpc_control_api/mod.rs +++ b/tests/e2e/grpc_control_api/mod.rs @@ -36,7 +36,7 @@ impl ControlClient { /// don't know it until try to send something with this client. pub fn new() -> Self { let env = Arc::new(EnvBuilder::new().build()); - let ch = ChannelBuilder::new(env).connect("localhost:6565"); + let ch = ChannelBuilder::new(env).connect("127.0.0.1:6565"); ControlClient(ControlApiClient::new(ch)) } From 80f5974b923ab1662b26a97279818ccf2ae8250a Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 11 Oct 2019 15:18:10 +0300 Subject: [PATCH 699/735] Fix tests [run ci] --- src/conf/server.rs | 7 ------- tests/e2e/grpc_control_api/mod.rs | 4 ++-- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/src/conf/server.rs b/src/conf/server.rs index 84dc0593a..d03fb7b04 100644 --- a/src/conf/server.rs +++ b/src/conf/server.rs @@ -164,7 +164,6 @@ mod control_grpc_spec { let env_conf = overrided_by_env_conf!( "MEDEA_SERVER__CONTROL__GRPC__BIND_IP" => "182.98.12.48", "MEDEA_SERVER__CONTROL__GRPC__BIND_PORT" => "44444", - "MEDEA_SERVER__CONTROL__GRPC__COMPLETION_QUEUE_COUNT" => "10", ); assert_ne!( @@ -175,12 +174,6 @@ mod control_grpc_spec { default_conf.server.control.grpc.bind_port, env_conf.server.control.grpc.bind_port ); - assert_ne!( - default_conf.server.control.grpc.completion_queue_count, - env_conf.server.control.grpc.completion_queue_count - ); - - assert_eq!(env_conf.server.control.grpc.completion_queue_count, 10); assert_eq!(env_conf.server.control.grpc.bind_port, 44444); assert_eq!( env_conf.server.control.grpc.bind_ip, diff --git a/tests/e2e/grpc_control_api/mod.rs b/tests/e2e/grpc_control_api/mod.rs index fbfaaf318..815c53e9c 100644 --- a/tests/e2e/grpc_control_api/mod.rs +++ b/tests/e2e/grpc_control_api/mod.rs @@ -11,12 +11,12 @@ use std::{collections::HashMap, sync::Arc}; use grpcio::{ChannelBuilder, EnvBuilder}; use medea_control_api_proto::grpc::{ - control_api::{ + api::{ CreateRequest, Element, Error, IdRequest, Member, Member_Element, Room, Room_Element, WebRtcPlayEndpoint, WebRtcPublishEndpoint, WebRtcPublishEndpoint_P2P, }, - control_api_grpc::ControlApiClient, + api_grpc::ControlApiClient, }; use protobuf::RepeatedField; From 80c11a353f57efc4a46b8f3f44cb0229b4b346aa Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 11 Oct 2019 16:50:31 +0300 Subject: [PATCH 700/735] Fix [run ci] --- tests/e2e/grpc_control_api/create.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/e2e/grpc_control_api/create.rs b/tests/e2e/grpc_control_api/create.rs index c25fcf5f5..2d4f9f9b5 100644 --- a/tests/e2e/grpc_control_api/create.rs +++ b/tests/e2e/grpc_control_api/create.rs @@ -27,7 +27,7 @@ fn room() { let responder_sid = sids.get(&"responder".to_string()).unwrap().as_str(); assert_eq!( responder_sid, - &format_name!("ws://0.0.0.0:8080/{}/responder/test") + &format_name!("ws://127.0.0.1:8080/{}/responder/test") ); let mut get_resp = client.get(&format_name!("local://{}")); @@ -92,7 +92,7 @@ fn member() { sids.get(&"test-member".to_string()).unwrap().as_str(); assert_eq!( e2e_test_member_sid, - format_name!("ws://0.0.0.0:8080/{}/test-member/qwerty") + format_name!("ws://127.0.0.1:8080/{}/test-member/qwerty") ); let member = client From 7a51e3f34eefe5d891f891010ab490794b33a7bb Mon Sep 17 00:00:00 2001 From: alexlapa Date: Mon, 14 Oct 2019 22:05:51 +0300 Subject: [PATCH 701/735] refactor tests [run ci] --- Cargo.lock | 163 ++++++++++---- Cargo.toml | 4 +- Makefile | 2 +- tests/e2e/grpc_control_api/create.rs | 108 +++++----- tests/e2e/grpc_control_api/delete.rs | 42 ++-- tests/e2e/grpc_control_api/mod.rs | 268 ++++++++++++++++++++---- tests/e2e/grpc_control_api/signaling.rs | 256 ++++++++-------------- tests/e2e/main.rs | 16 +- 8 files changed, 528 insertions(+), 331 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 009018fbd..66f164c87 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -17,7 +17,7 @@ dependencies = [ "actix-http 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "actix-rt 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "actix_derive 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "bitflags 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-channel 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -55,7 +55,7 @@ dependencies = [ "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "actix-rt 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "actix-service 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-utils 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-utils 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", "either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", @@ -76,9 +76,9 @@ dependencies = [ "actix-server-config 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "actix-service 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "actix-threadpool 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-utils 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-utils 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", - "bitflags 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "brotli2 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -86,7 +86,7 @@ dependencies = [ "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", "either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "encoding_rs 0.8.20 (registry+https://github.com/rust-lang/crates.io-index)", - "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "flate2 1.0.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "h2 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", @@ -123,7 +123,7 @@ dependencies = [ "actix-rt 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "actix-server 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "actix-service 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-utils 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-utils 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "awc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -240,7 +240,7 @@ dependencies = [ [[package]] name = "actix-utils" -version = "0.4.6" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -267,8 +267,8 @@ dependencies = [ "actix-service 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "actix-testing 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "actix-threadpool 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-utils 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-web-codegen 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-utils 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-web-codegen 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "awc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -302,11 +302,12 @@ dependencies = [ [[package]] name = "actix-web-codegen" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -447,7 +448,7 @@ dependencies = [ [[package]] name = "bitflags" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -532,7 +533,7 @@ name = "cloudabi" version = "0.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bitflags 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -657,6 +658,38 @@ dependencies = [ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "darling" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "darling_core 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "darling_macro 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "darling_core" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "ident_case 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "strsim 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "darling_macro" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "darling_core 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "derive-new" version = "0.5.8" @@ -667,6 +700,29 @@ dependencies = [ "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "derive_builder" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "darling 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_builder_core 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "derive_builder_core" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "darling 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "derive_more" version = "0.14.1" @@ -711,7 +767,7 @@ name = "dotenv" version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -763,22 +819,22 @@ dependencies = [ [[package]] name = "failure" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "backtrace 0.3.38 (registry+https://github.com/rust-lang/crates.io-index)", - "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "failure_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "failure_derive" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)", - "synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "synstructure 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -821,7 +877,7 @@ name = "fuchsia-zircon" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bitflags 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -960,6 +1016,11 @@ dependencies = [ "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "idna" version = "0.1.5" @@ -1117,12 +1178,12 @@ dependencies = [ "bb8-redis 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", "config 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_builder 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", "dotenv 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", - "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "grpcio 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "humantime-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "medea-client-api-proto 0.1.1-dev", "medea-control-api-proto 0.1.0-dev", @@ -1525,7 +1586,7 @@ name = "protoc-grpcio" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "grpcio-compiler 0.5.0-alpha.2 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf-codegen 2.8.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1746,7 +1807,7 @@ name = "redox_users" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", "rust-argon2 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1840,7 +1901,7 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1912,7 +1973,7 @@ version = "1.0.41" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ryu 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2103,6 +2164,11 @@ dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "strsim" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "syn" version = "0.15.44" @@ -2125,13 +2191,13 @@ dependencies = [ [[package]] name = "synstructure" -version = "0.10.2" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2409,7 +2475,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "enum-as-inner 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2432,7 +2498,7 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "ipconfig 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2609,7 +2675,7 @@ name = "wasm-bindgen-webidl" version = "0.2.51" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2624,7 +2690,7 @@ name = "web-sys" version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "js-sys 0.3.28 (registry+https://github.com/rust-lang/crates.io-index)", "sourcefile 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2748,10 +2814,10 @@ dependencies = [ "checksum actix-service 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bca5b48e928841ff7e7dce1fdb5b0d4582f6b1b976e08f4bac3f640643e0773f" "checksum actix-testing 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "af001e97ac6750994824d400a1b7087055aab14317aa012f528d0b2b363f37f1" "checksum actix-threadpool 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6b5ae85d13da7e6fb86b1b7bc83185e0e3bd4cc5f421c887e1803796c034d35d" -"checksum actix-utils 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "5f45e1dfd14be15fc1bf94a575052966775d89c0e206452589f75bb3ae6eb117" +"checksum actix-utils 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "908c3109948f5c37a8b57fd343a37dcad5bb1d90bfd06300ac96b17bbe017b95" "checksum actix-web 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "36e59485f007a4be3df228791ff6c4aedcbe7bb09bd9225c3554f538aca4a584" "checksum actix-web-actors 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "008c1b686048a16fef4ef2fc6b6e5fcf5f29829891ad87fc0848ade26b285627" -"checksum actix-web-codegen 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3fe9e3cdec1e645b675f354766e0688c5705021c85ab3cf739be1c8999b91c76" +"checksum actix-web-codegen 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "068a33520e21c1eea89726be4d6b3ce2e6b81046904367e1677287695a043abb" "checksum actix_derive 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0bf5f6d7bf2d220ae8b4a7ae02a572bb35b7c4806b24049af905ab8110de156c" "checksum adler32 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5d2e7343e7fc9de883d1b0341e0b13970f764c14101234857d2ddafa1cb1cac2" "checksum aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "58fb5e95d83b38284460a5fda7d6470aa0b8844d283a0b614b8535e880800d2d" @@ -2768,7 +2834,7 @@ dependencies = [ "checksum base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" "checksum bb8 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0ac73ee3406f475415bba792942016291b87bac08839c38a032de56085a73b2c" "checksum bb8-redis 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "39945a33c03edfba8c353d330b921961e2137d4fc4215331c1b2397f32acff80" -"checksum bitflags 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8a606a02debe2813760609f57a64a2ffd27d9fdf5b2f133eaca0b248dd92cdd2" +"checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" "checksum blake2b_simd 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)" = "5850aeee1552f495dd0250014cf64b82b7c8879a89d83b33bbdace2cc4f63182" "checksum brotli-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4445dea95f4c2b41cde57cc9fee236ae4dbae88d8fcbdb4750fc1bb5d86aaecd" "checksum brotli2 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0cb036c3eade309815c15ddbacec5b22c4d1f3983a774ab2eac2e3e9ea85568e" @@ -2793,7 +2859,12 @@ dependencies = [ "checksum crossbeam-epoch 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "fedcd6772e37f3da2a9af9bf12ebe046c0dfe657992377b4df982a2b54cd37a9" "checksum crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7c979cd6cfe72335896575c6b5688da489e420d36a27a0b9eb0c73db574b4a4b" "checksum crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "04973fa96e96579258a5091af6003abde64af786b860f18622b82e026cca60e6" +"checksum darling 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3fe629a532efad5526454efb0700f86d5ad7ff001acb37e431c8bf017a432a8e" +"checksum darling_core 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ee54512bec54b41cf2337a22ddfadb53c7d4c738494dc2a186d7b037ad683b85" +"checksum darling_macro 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0cd3e432e52c0810b72898296a69d66b1d78d1517dff6cde7a130557a55a62c1" "checksum derive-new 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)" = "71f31892cd5c62e414316f2963c5689242c43d8e7bbcaaeca97e5e28c95d91d9" +"checksum derive_builder 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "dfbc80e9c3b77201f32c9541b13d9678388782272554af7e65103310265462e6" +"checksum derive_builder_core 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8b68a4fe580fdda1bf3860b2360b9020696d42fc58f2343cf4be2faedf74c5a9" "checksum derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6d944ac6003ed268757ef1ee686753b57efc5fcf0ebe7b64c9fc81e7e32ff839" "checksum derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a141330240c921ec6d074a3e188a7c7ef95668bb95e7d44fa0e5778ec2a7afe" "checksum difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198" @@ -2805,8 +2876,8 @@ dependencies = [ "checksum encoding_rs 0.8.20 (registry+https://github.com/rust-lang/crates.io-index)" = "87240518927716f79692c2ed85bfe6e98196d18c6401ec75355760233a7e12e9" "checksum enum-as-inner 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3d58266c97445680766be408285e798d3401c6d4c378ec5552e78737e681e37d" "checksum env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "aafcde04e90a5226a6443b7aabdb016ba2f8307c847d524724bd9b346dd1a2d3" -"checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" -"checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" +"checksum failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "f8273f13c977665c5db7eb2b99ae520952fe5ac831ae4cd09d80c4c7042b5ed9" +"checksum failure_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0bc225b78e0391e4b8683440bf2e63c2deeeb2ce5189eab46e2b68c6d3725d08" "checksum flate2 1.0.12 (registry+https://github.com/rust-lang/crates.io-index)" = "ad3c5233c9a940c8719031b423d7e6c16af66e031cb0420b0896f5245bf181d3" "checksum float-cmp 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "134a8fa843d80a51a5b77d36d42bc2def9edcb0262c914861d08129fd1926600" "checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" @@ -2829,6 +2900,7 @@ dependencies = [ "checksum httparse 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "cd179ae861f0c2e53da70d892f5f3029f9594be0c41dc5269cd371691b1dc2f9" "checksum humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" "checksum humantime-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8f59e8a805c18bc9ded3f4e596cb5f0157d88a235e875480a7593b5926f95065" +"checksum ident_case 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" "checksum idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e" "checksum idna 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "02e2673c30ee86b5b96a9cb52ad15718aa1f966f5ab9ad54a8b95d5ca33120a9" "checksum indexmap 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a61202fbe46c4a951e9404a720a0180bcf3212c750d735cb5c4ba4dc551299f3" @@ -2921,7 +2993,7 @@ dependencies = [ "checksum rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda" "checksum rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "c5f5376ea5e30ce23c03eb77cbe4962b988deead10910c372b226388b594c084" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -"checksum ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c92464b447c0ee8c4fb3824ecc8383b81717b9f1e74ba2e72540aef7b9f82997" +"checksum ryu 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bfa8506c1de11c9c4e4c38863ccbe02a305c8188e85a05a784c9e11e1c3910c8" "checksum scoped-tls 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2" "checksum scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b42e15e59b18a828bbf5c58ea01debb36b9b096346de35d941dcb89009f24a0d" "checksum semver 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)" = "d4f410fedcf71af0345d7607d246e7ad15faaadd49d240ee3b24e5dc21a820ac" @@ -2953,9 +3025,10 @@ dependencies = [ "checksum socket2 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)" = "e8b74de517221a2cb01a53349cf54182acdc31a074727d3079068448c0676d85" "checksum sourcefile 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4bf77cb82ba8453b42b6ae1d692e4cdc92f9a47beaf89a847c8be83f4e328ad3" "checksum string 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d24114bfcceb867ca7f71a0d3fe45d45619ec47a6fbfa98cb14e14250bfa5d6d" +"checksum strsim 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "032c03039aae92b350aad2e3779c352e104d919cb192ba2fabbd7b831ce4f0f6" "checksum syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)" = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" "checksum syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "66850e97125af79138385e9b88339cbcd037e3f28ceab8c5ad98e64f0f1f80bf" -"checksum synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f" +"checksum synstructure 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3f085a5855930c0441ca1288cf044ea4aecf4f43a91668abdb870b4ba546a203" "checksum take_mut 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f764005d11ee5f36500a149ace24e00e3da98b0158b3e2d53a7495660d3f4d60" "checksum tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" "checksum term 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "edd106a334b7657c10b7c540a0106114feadeb4dc314513e97df481d5d966f42" diff --git a/Cargo.toml b/Cargo.toml index a9773d452..28c4d94da 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,12 +32,11 @@ bb8 = "0.3" bb8-redis = "0.3" chrono = "0.4" config = "0.9" -dotenv = "0.14" derive_more = "0.15" +dotenv = "0.14" failure = "0.1" futures = "0.1" grpcio = { version = "0.4", features = ["openssl"] } -humantime = "1.3" humantime-serde = "0.1" medea-client-api-proto = { path = "proto/client-api", features = ["medea"] } medea-control-api-proto = { path = "proto/control-api" } @@ -66,6 +65,7 @@ actix-codec = "0.1" actix-http = "0.2" actix-http-test = "0.2" awc = "0.2" +derive_builder = "0.8" serial_test = "0.2" serial_test_derive = "0.2" tempfile = "3.1" diff --git a/Makefile b/Makefile index 0f20c77ad..818a164b6 100644 --- a/Makefile +++ b/Makefile @@ -333,7 +333,7 @@ ifeq ($(crate),medea-jason) @make docker.up.webdriver browser=$(browser) sleep 10 cd $(crate-dir)/ && \ - $(webdriver-env)="http://0.0.0.0:4444" \ + $(webdriver-env)="http://127.0.0.1:4444" \ cargo test --target wasm32-unknown-unknown --features mockable @make docker.down.webdriver browser=$(browser) else diff --git a/tests/e2e/grpc_control_api/create.rs b/tests/e2e/grpc_control_api/create.rs index 2d4f9f9b5..69c13fc58 100644 --- a/tests/e2e/grpc_control_api/create.rs +++ b/tests/e2e/grpc_control_api/create.rs @@ -5,54 +5,52 @@ //! //! [Control API]: https://tinyurl.com/yxsqplq7 -use std::collections::HashMap; +use medea_control_api_proto::grpc::api::WebRtcPublishEndpoint_P2P; -use medea_control_api_proto::grpc::api::{ - CreateRequest, Member, Member_Element, WebRtcPlayEndpoint, - WebRtcPublishEndpoint, WebRtcPublishEndpoint_P2P, -}; - -use crate::format_name_macro; +use crate::gen_insert_str_macro; -use super::{create_room_req, ControlClient}; +use super::{ + create_room_req, ControlClient, MemberBuilder, WebRtcPlayEndpointBuilder, + WebRtcPublishEndpointBuilder, +}; #[test] fn room() { - format_name_macro!("create-room"); + gen_insert_str_macro!("create-room"); let client = ControlClient::new(); - let sids = client.create(&create_room_req(&format_name!("{}"))); + let sids = client.create(&create_room_req(&insert_str!("{}"))); assert_eq!(sids.len(), 2); sids.get(&"publisher".to_string()).unwrap(); let responder_sid = sids.get(&"responder".to_string()).unwrap().as_str(); assert_eq!( responder_sid, - &format_name!("ws://127.0.0.1:8080/{}/responder/test") + &insert_str!("ws://127.0.0.1:8080/{}/responder/test") ); - let mut get_resp = client.get(&format_name!("local://{}")); + let mut get_resp = client.get(&insert_str!("local://{}")); let room = get_resp.take_room(); let responder = room .get_pipeline() - .get(&format_name!("local://{}/responder")) + .get(&insert_str!("local://{}/responder")) .unwrap() .get_member(); assert_eq!(responder.get_credentials(), "test"); let responder_pipeline = responder.get_pipeline(); assert_eq!(responder_pipeline.len(), 1); let responder_play = responder_pipeline - .get(&format_name!("local://{}/responder/play")) + .get(&insert_str!("local://{}/responder/play")) .unwrap() .get_webrtc_play(); assert_eq!( responder_play.get_src(), - format_name!("local://{}/publisher/publish") + insert_str!("local://{}/publisher/publish") ); let publisher = room .get_pipeline() - .get(&format_name!("local://{}/publisher")) + .get(&insert_str!("local://{}/publisher")) .unwrap() .get_member(); assert_ne!(publisher.get_credentials(), "test"); @@ -63,67 +61,69 @@ fn room() { #[test] fn member() { - format_name_macro!("create-member"); + gen_insert_str_macro!("create-member"); let client = ControlClient::new(); - client.create(&create_room_req(&format_name!("{}"))); - - let create_req = { - let mut create_member_request = CreateRequest::new(); - let mut member = Member::new(); - let mut member_pipeline = HashMap::new(); - - let mut play_endpoint = WebRtcPlayEndpoint::new(); - play_endpoint.set_src(format_name!("local://{}/publisher/publish")); - let mut member_element = Member_Element::new(); - member_element.set_webrtc_play(play_endpoint); - member_pipeline.insert("play".to_string(), member_element); - - member.set_credentials("qwerty".to_string()); - member.set_pipeline(member_pipeline); - create_member_request.set_id(format_name!("local://{}/test-member")); - create_member_request.set_member(member); - - create_member_request - }; + client.create(&create_room_req(&insert_str!("{}"))); + + let add_member = MemberBuilder::default() + .id("member") + .credentials("qwerty") + .add_endpoint( + WebRtcPlayEndpointBuilder::default() + .id("play") + .src(insert_str!("local://{}/publisher/publish")) + .build() + .unwrap(), + ) + .build() + .unwrap() + .build_request(insert_str!("local://{}/test-member")); - let sids = client.create(&create_req); + let sids = client.create(&add_member); let e2e_test_member_sid = sids.get(&"test-member".to_string()).unwrap().as_str(); assert_eq!( e2e_test_member_sid, - format_name!("ws://127.0.0.1:8080/{}/test-member/qwerty") + insert_str!("ws://127.0.0.1:8080/{}/test-member/qwerty") ); let member = client - .get(&format_name!("local://{}/test-member")) + .get(&insert_str!("local://{}/test-member")) .take_member(); assert_eq!(member.get_pipeline().len(), 1); assert_eq!(member.get_credentials(), "qwerty"); } +#[test] +fn asd() { + WebRtcPublishEndpointBuilder::default() + .id("publish") + .p2p_mode(WebRtcPublishEndpoint_P2P::NEVER) + .build() + .unwrap() + .build_request("local://{}/responder/publish"); +} + #[test] fn endpoint() { - format_name_macro!("create-endpoint"); + gen_insert_str_macro!("create-endpoint"); let client = ControlClient::new(); - client.create(&create_room_req(&format_name!("{}"))); - - let create_req = { - let mut create_endpoint_request = CreateRequest::new(); - let mut endpoint = WebRtcPublishEndpoint::new(); - endpoint.set_p2p(WebRtcPublishEndpoint_P2P::NEVER); - create_endpoint_request - .set_id(format_name!("local://{}/responder/publish")); - create_endpoint_request.set_webrtc_pub(endpoint); - - create_endpoint_request - }; + client.create(&create_room_req(&insert_str!("{}"))); + + let create_req = WebRtcPublishEndpointBuilder::default() + .id("publish") + .p2p_mode(WebRtcPublishEndpoint_P2P::NEVER) + .build() + .unwrap() + .build_request(insert_str!("local://{}/responder/publish")); + let sids = client.create(&create_req); assert_eq!(sids.len(), 0); let endpoint = client - .get(&format_name!("local://{}/responder/publish")) + .get(&insert_str!("local://{}/responder/publish")) .take_webrtc_pub(); assert_eq!(endpoint.get_p2p(), WebRtcPublishEndpoint_P2P::NEVER); } diff --git a/tests/e2e/grpc_control_api/delete.rs b/tests/e2e/grpc_control_api/delete.rs index 54808e2a5..7c7d32bbf 100644 --- a/tests/e2e/grpc_control_api/delete.rs +++ b/tests/e2e/grpc_control_api/delete.rs @@ -9,7 +9,7 @@ use medea::api::control::error_codes::{ ErrorCode as MedeaErrorCode, ErrorCode, }; -use crate::format_name_macro; +use crate::gen_insert_str_macro; use super::{create_room_req, ControlClient}; @@ -46,30 +46,30 @@ fn test_for_delete( #[test] fn room() { - format_name_macro!("delete-room"); + gen_insert_str_macro!("delete-room"); test_for_delete( - &format_name!("{}"), - &format_name!("local://{}"), + &insert_str!("{}"), + &insert_str!("local://{}"), ErrorCode::RoomNotFound, ); } #[test] fn member() { - format_name_macro!("delete-member"); + gen_insert_str_macro!("delete-member"); test_for_delete( - &format_name!("{}"), - &format_name!("local://{}/publisher"), + &insert_str!("{}"), + &insert_str!("local://{}/publisher"), ErrorCode::MemberNotFound, ); } #[test] fn endpoint() { - format_name_macro!("delete-endpoint"); + gen_insert_str_macro!("delete-endpoint"); test_for_delete( - &format_name!("{}"), - &format_name!("local://{}/publisher/publish"), + &insert_str!("{}"), + &insert_str!("local://{}/publisher/publish"), ErrorCode::EndpointNotFound, ); } @@ -112,31 +112,31 @@ fn test_for_delete_elements_at_same_time_test( #[test] fn member_and_endpoint_same_time() { - format_name_macro!("member-and-endpoint-same-time"); + gen_insert_str_macro!("member-and-endpoint-same-time"); test_for_delete_elements_at_same_time_test( - &format_name!("{}"), + &insert_str!("{}"), &[ - &format_name!("local://{}/publisher"), - &format_name!("local://{}/publisher/publish"), + &insert_str!("local://{}/publisher"), + &insert_str!("local://{}/publisher/publish"), ], MedeaErrorCode::MemberNotFound, - &format_name!("local://{}/publisher"), + &insert_str!("local://{}/publisher"), ); } #[test] fn room_and_inner_elements_same_time() { - format_name_macro!("room-and-inner-elements-same-time"); + gen_insert_str_macro!("room-and-inner-elements-same-time"); test_for_delete_elements_at_same_time_test( - &format_name!("{}"), + &insert_str!("{}"), &[ - &format_name!("local://{}"), - &format_name!("local://{}/publisher"), - &format_name!("local://{}/publisher/publish"), + &insert_str!("local://{}"), + &insert_str!("local://{}/publisher"), + &insert_str!("local://{}/publisher/publish"), ], MedeaErrorCode::RoomNotFound, - &format_name!("local://{}"), + &insert_str!("local://{}"), ); } diff --git a/tests/e2e/grpc_control_api/mod.rs b/tests/e2e/grpc_control_api/mod.rs index 815c53e9c..838c5b124 100644 --- a/tests/e2e/grpc_control_api/mod.rs +++ b/tests/e2e/grpc_control_api/mod.rs @@ -9,11 +9,14 @@ mod signaling; use std::{collections::HashMap, sync::Arc}; +use derive_builder::*; use grpcio::{ChannelBuilder, EnvBuilder}; use medea_control_api_proto::grpc::{ api::{ - CreateRequest, Element, Error, IdRequest, Member, Member_Element, Room, - Room_Element, WebRtcPlayEndpoint, WebRtcPublishEndpoint, + CreateRequest, Element, Error, IdRequest, Member as GrpcMember, + Member_Element, Room as GrpcRoom, Room_Element, + WebRtcPlayEndpoint as GrpcWebRtcPlayEndpoint, + WebRtcPublishEndpoint as GrpcWebRtcPublishEndpoint, WebRtcPublishEndpoint_P2P, }, api_grpc::ControlApiClient, @@ -112,6 +115,201 @@ impl ControlClient { } } +#[derive(Builder)] +#[builder(setter(into))] +pub struct Room { + id: String, + + #[builder(default = "HashMap::new()")] + members: HashMap, +} + +impl RoomBuilder { + fn add_member>(&mut self, member: T) -> &mut Self { + let member = member.into(); + + self.members + .get_or_insert(HashMap::new()) + .insert(member.id.clone(), member); + + self + } +} + +impl From for CreateRequest { + fn from(room: Room) -> Self { + let mut request = Self::default(); + + let mut grpc_room = GrpcRoom::new(); + let mut members = HashMap::new(); + + for (id, member) in room.members { + let mut room_element = Room_Element::new(); + room_element.set_member(member.into()); + + members.insert(id, room_element); + } + + grpc_room.set_pipeline(members); + + request.set_id(room.id); + request.set_room(grpc_room); + + request + } +} + +#[derive(Builder, Clone)] +#[builder(setter(into))] +pub struct Member { + id: String, + #[builder(default = "None")] + #[builder(setter(strip_option))] + credentials: Option, + #[builder(default = "HashMap::new()")] + endpoints: HashMap, +} + +impl Into for Member { + fn into(self) -> GrpcMember { + let mut grpc_member = GrpcMember::new(); + + let mut pipeline = HashMap::new(); + + for (id, element) in self.endpoints { + pipeline.insert(id, element.into()); + } + + if let Some(credentials) = self.credentials { + grpc_member.set_credentials(credentials) + } + + grpc_member.set_pipeline(pipeline); + + grpc_member + } +} + +impl Member { + fn build_request>(self, url: T) -> CreateRequest { + let mut request = CreateRequest::default(); + + request.set_id(url.into()); + request.set_member(self.into()); + + request + } +} + +impl MemberBuilder { + fn add_endpoint>(&mut self, element: T) -> &mut Self { + let element = element.into(); + + self.endpoints + .get_or_insert(HashMap::new()) + .insert(element.id(), element); + self + } +} + +#[derive(Clone)] +pub enum Endpoint { + WebRtcPlayElement(WebRtcPlayEndpoint), + WebRtcPublishElement(WebRtcPublishEndpoint), +} + +impl Endpoint { + fn id(&self) -> String { + match self { + Self::WebRtcPlayElement(endpoint) => endpoint.id.clone(), + Self::WebRtcPublishElement(endpoint) => endpoint.id.clone(), + } + } +} + +impl Into for Endpoint { + fn into(self) -> Member_Element { + let mut member_elem = Member_Element::new(); + + match self { + Endpoint::WebRtcPlayElement(element) => { + member_elem.set_webrtc_play(element.into()); + } + Endpoint::WebRtcPublishElement(element) => { + member_elem.set_webrtc_pub(element.into()) + } + } + + member_elem + } +} + +#[derive(Builder, Clone)] +#[builder(setter(into))] +pub struct WebRtcPlayEndpoint { + id: String, + src: String, +} + +impl WebRtcPlayEndpoint { + fn _build_request>(self, url: T) -> CreateRequest { + let mut request = CreateRequest::default(); + + request.set_id(url.into()); + request.set_webrtc_play(self.into()); + + request + } +} + +impl Into for WebRtcPlayEndpoint { + fn into(self) -> GrpcWebRtcPlayEndpoint { + let mut endpoint = GrpcWebRtcPlayEndpoint::new(); + endpoint.set_src(self.src); + + endpoint + } +} + +impl Into for WebRtcPlayEndpoint { + fn into(self) -> Endpoint { + Endpoint::WebRtcPlayElement(self) + } +} + +#[derive(Builder, Clone)] +#[builder(setter(into))] +pub struct WebRtcPublishEndpoint { + id: String, + p2p_mode: WebRtcPublishEndpoint_P2P, +} + +impl WebRtcPublishEndpoint { + fn build_request>(self, url: T) -> CreateRequest { + let mut request = CreateRequest::default(); + + request.set_id(url.into()); + request.set_webrtc_pub(self.into()); + + request + } +} + +impl Into for WebRtcPublishEndpoint { + fn into(self) -> GrpcWebRtcPublishEndpoint { + let mut endpoint = GrpcWebRtcPublishEndpoint::new(); + endpoint.set_p2p(self.p2p_mode); + + endpoint + } +} + +impl Into for WebRtcPublishEndpoint { + fn into(self) -> Endpoint { + Endpoint::WebRtcPublishElement(self) + } +} + /// Creates [`CreateRequest`] for creating `Room` element with provided `Room` /// ID. /// @@ -141,38 +339,36 @@ impl ControlClient { /// src: "local://{{ room_id }}/publisher/publish" /// ``` fn create_room_req(room_id: &str) -> CreateRequest { - let mut create_req = CreateRequest::new(); - let mut room = Room::new(); - let mut publisher = Member::new(); - let mut responder = Member::new(); - let mut play_endpoint = WebRtcPlayEndpoint::new(); - let mut publish_endpoint = WebRtcPublishEndpoint::new(); - - play_endpoint.set_src(format!("local://{}/publisher/publish", room_id)); - let mut play_endpoint_element = Member_Element::new(); - play_endpoint_element.set_webrtc_play(play_endpoint); - let mut responder_pipeline = HashMap::new(); - responder_pipeline.insert("play".to_string(), play_endpoint_element); - responder.set_pipeline(responder_pipeline); - responder.set_credentials("test".to_string()); - - publish_endpoint.set_p2p(WebRtcPublishEndpoint_P2P::ALWAYS); - let mut publish_endpoint_element = Member_Element::new(); - publish_endpoint_element.set_webrtc_pub(publish_endpoint); - let mut publisher_pipeline = HashMap::new(); - publisher_pipeline.insert("publish".to_string(), publish_endpoint_element); - publisher.set_pipeline(publisher_pipeline); - - let mut publisher_member_element = Room_Element::new(); - publisher_member_element.set_member(publisher); - let mut responder_member_element = Room_Element::new(); - responder_member_element.set_member(responder); - let mut room_pipeline = HashMap::new(); - room_pipeline.insert("publisher".to_string(), publisher_member_element); - room_pipeline.insert("responder".to_string(), responder_member_element); - room.set_pipeline(room_pipeline); - create_req.set_room(room.clone()); - create_req.set_id(format!("local://{}", room_id)); - - create_req + RoomBuilder::default() + .id(format!("local://{}", room_id)) + .add_member( + MemberBuilder::default() + .id("publisher") + .add_endpoint( + WebRtcPublishEndpointBuilder::default() + .id("publish") + .p2p_mode(WebRtcPublishEndpoint_P2P::ALWAYS) + .build() + .unwrap(), + ) + .build() + .unwrap(), + ) + .add_member( + MemberBuilder::default() + .id("responder") + .credentials("test") + .add_endpoint( + WebRtcPlayEndpointBuilder::default() + .id("play") + .src(format!("local://{}/publisher/publish", room_id)) + .build() + .unwrap(), + ) + .build() + .unwrap(), + ) + .build() + .unwrap() + .into() } diff --git a/tests/e2e/grpc_control_api/signaling.rs b/tests/e2e/grpc_control_api/signaling.rs index 18a0993f9..4d67b4241 100644 --- a/tests/e2e/grpc_control_api/signaling.rs +++ b/tests/e2e/grpc_control_api/signaling.rs @@ -2,172 +2,51 @@ //! //! [Control API]: https://tinyurl.com/yxsqplq7 -use std::{cell::Cell, collections::HashMap, rc::Rc, time::Duration}; +use std::{cell::Cell, rc::Rc, time::Duration}; use actix::{Arbiter, AsyncContext, Context, System}; use futures::future::Future as _; use medea_client_api_proto::Event; -use medea_control_api_proto::grpc::api::{ - CreateRequest, Member, Member_Element, Room, Room_Element, - WebRtcPlayEndpoint, WebRtcPublishEndpoint, WebRtcPublishEndpoint_P2P, -}; +use medea_control_api_proto::grpc::api::WebRtcPublishEndpoint_P2P; use crate::{ - format_name_macro, grpc_control_api::ControlClient, signalling::TestMember, + gen_insert_str_macro, grpc_control_api::ControlClient, + signalling::TestMember, }; -/// Creates [`CreateRequest`] for creating `Room` element with provided room ID -/// and `Member` with `WebRtcPublishEndpoint`. -/// -/// # Spec of `Room` which will be created with this [`CreateRequest`] -/// -/// ```yaml -/// kind: Room -/// id: {{ room_id }} -/// spec: -/// pipeline: -/// publisher: -/// kind: Member -/// credentials: test -/// spec: -/// pipeline: -/// publish: -/// kind: WebRtcPublishEndpoint -/// spec: -/// p2p: Always -/// ``` -fn room_with_one_pub_member_req(room_id: &str) -> CreateRequest { - let mut create_req = CreateRequest::new(); - let mut room = Room::new(); - let mut publisher = Member::new(); - let mut publish_endpoint = WebRtcPublishEndpoint::new(); - - publish_endpoint.set_p2p(WebRtcPublishEndpoint_P2P::ALWAYS); - let mut publish_endpoint_element = Member_Element::new(); - publish_endpoint_element.set_webrtc_pub(publish_endpoint); - let mut publisher_pipeline = HashMap::new(); - publisher_pipeline.insert("publish".to_string(), publish_endpoint_element); - publisher.set_pipeline(publisher_pipeline); - publisher.set_credentials("test".to_string()); - - let mut publisher_member_element = Room_Element::new(); - publisher_member_element.set_member(publisher); - let mut room_pipeline = HashMap::new(); - room_pipeline.insert("publisher".to_string(), publisher_member_element); - room.set_pipeline(room_pipeline); - create_req.set_room(room.clone()); - create_req.set_id(format!("local://{}", room_id)); - - create_req -} - -/// Creates [`CreateRequest`] for creating `Member` element in provided Room ID. -/// -/// # Spec of `Member` which will be created with this [`CreateRequest`] -/// -/// ```yaml -/// kind: Member -/// id: responder -/// credentials: qwerty -/// spec: -/// pipeline: -/// play: -/// kind: WebRtcPlayEndpoint -/// spec: -/// src: "local://{{ room_id }}/publisher/publish -/// ``` -fn create_play_member_req(room_id: &str) -> CreateRequest { - let mut create_member_request = CreateRequest::new(); - let mut member = Member::new(); - let mut member_pipeline = HashMap::new(); - - let mut play_endpoint = WebRtcPlayEndpoint::new(); - play_endpoint.set_src(format!("local://{}/publisher/publish", room_id)); - let mut member_element = Member_Element::new(); - member_element.set_webrtc_play(play_endpoint); - member_pipeline.insert("play".to_string(), member_element); - - member.set_credentials("qwerty".to_string()); - member.set_pipeline(member_pipeline); - create_member_request.set_id(format!("local://{}/responder", room_id)); - create_member_request.set_member(member); - - create_member_request -} - -/// Creates [`CreateRequest`] for creating `Room` element with provided room ID. -/// -/// # Spec of `Room` which will be created with this [`CreateRequest`] -/// -/// ```yaml -/// kind: Room -/// id: {{ room_id }} -/// spec: -/// pipeline: -/// publisher: -/// kind: Member -/// credentials: test -/// spec: -/// pipeline: -/// publish: -/// kind: WebRtcPublishEndpoint -/// spec: -/// p2p: Always -/// responder: -/// kind: Member -/// credentials: test -/// spec: -/// pipeline: -/// play: -/// kind: WebRtcPlayEndpoint -/// spec: -/// src: "local://{{ room_id }}/publisher/publish" -/// ``` -fn create_room_req(room_id: &str) -> CreateRequest { - let mut create_req = CreateRequest::new(); - let mut room = Room::new(); - let mut publisher = Member::new(); - let mut responder = Member::new(); - let mut play_endpoint = WebRtcPlayEndpoint::new(); - let mut publish_endpoint = WebRtcPublishEndpoint::new(); - - play_endpoint.set_src(format!("local://{}/publisher/publish", room_id)); - let mut play_endpoint_element = Member_Element::new(); - play_endpoint_element.set_webrtc_play(play_endpoint); - let mut responder_pipeline = HashMap::new(); - responder_pipeline.insert("play".to_string(), play_endpoint_element); - responder.set_pipeline(responder_pipeline); - responder.set_credentials("test".to_string()); - - publish_endpoint.set_p2p(WebRtcPublishEndpoint_P2P::ALWAYS); - let mut publish_endpoint_element = Member_Element::new(); - publish_endpoint_element.set_webrtc_pub(publish_endpoint); - let mut publisher_pipeline = HashMap::new(); - publisher_pipeline.insert("publish".to_string(), publish_endpoint_element); - publisher.set_pipeline(publisher_pipeline); - publisher.set_credentials("test".to_string()); - - let mut publisher_member_element = Room_Element::new(); - publisher_member_element.set_member(publisher); - let mut responder_member_element = Room_Element::new(); - responder_member_element.set_member(responder); - let mut room_pipeline = HashMap::new(); - room_pipeline.insert("publisher".to_string(), publisher_member_element); - room_pipeline.insert("responder".to_string(), responder_member_element); - room.set_pipeline(room_pipeline); - create_req.set_room(room.clone()); - create_req.set_id(format!("local://{}", room_id)); - - create_req -} +use super::{ + MemberBuilder, RoomBuilder, WebRtcPlayEndpointBuilder, + WebRtcPublishEndpointBuilder, +}; #[test] -fn create_play_member_after_pub_member() { - format_name_macro!("create-play-member-after-pub-member"); - let sys = System::new(format_name!("{}")); +fn signalling_starts_when_create_play_member_after_pub_member() { + gen_insert_str_macro!("create-play-member-after-pub-member"); + let sys = System::new(insert_str!("{}")); let control_client = ControlClient::new(); - control_client.create(&room_with_one_pub_member_req(&format_name!("{}"))); + + let create_room = RoomBuilder::default() + .id(insert_str!("local://{}")) + .add_member( + MemberBuilder::default() + .id("publisher") + .credentials("test") + .add_endpoint( + WebRtcPublishEndpointBuilder::default() + .id("publish") + .p2p_mode(WebRtcPublishEndpoint_P2P::ALWAYS) + .build() + .unwrap(), + ) + .build() + .unwrap(), + ) + .build() + .unwrap() + .into(); + + control_client.create(&create_room); let peers_created = Rc::new(Cell::new(0)); let on_event = @@ -188,14 +67,28 @@ fn create_play_member_after_pub_member() { let deadline = Some(std::time::Duration::from_secs(5)); Arbiter::spawn( TestMember::connect( - &format_name!("ws://127.0.0.1:8080/ws/{}/publisher/test"), + &insert_str!("ws://127.0.0.1:8080/ws/{}/publisher/test"), Box::new(on_event.clone()), deadline, ) .and_then(move |_| { - control_client.create(&create_play_member_req(&format_name!("{}"))); + let create_play_member = MemberBuilder::default() + .id("play") + .credentials("qwerty") + .add_endpoint( + WebRtcPlayEndpointBuilder::default() + .id("play") + .src(insert_str!("local://{}/publisher/publish")) + .build() + .unwrap(), + ) + .build() + .unwrap() + .build_request(insert_str!("local://{}/responder")); + + control_client.create(&create_play_member); TestMember::connect( - &format_name!("ws://127.0.0.1:8080/ws/{}/responder/qwerty"), + &insert_str!("ws://127.0.0.1:8080/ws/{}/responder/qwerty"), Box::new(on_event), deadline, ) @@ -207,12 +100,47 @@ fn create_play_member_after_pub_member() { } #[test] -fn delete_member_check_peers_removed() { - format_name_macro!("delete-member-check-peers-removed"); - let sys = System::new(&format_name!("{}")); +fn peers_removed_on_delete_member() { + gen_insert_str_macro!("delete-member-check-peers-removed"); + let sys = System::new(&insert_str!("{}")); let control_client = ControlClient::new(); - control_client.create(&create_room_req(&format_name!("{}"))); + + let create_room = RoomBuilder::default() + .id(insert_str!("local://{}")) + .add_member( + MemberBuilder::default() + .id("publisher") + .credentials("test") + .add_endpoint( + WebRtcPublishEndpointBuilder::default() + .id("publish") + .p2p_mode(WebRtcPublishEndpoint_P2P::ALWAYS) + .build() + .unwrap(), + ) + .build() + .unwrap(), + ) + .add_member( + MemberBuilder::default() + .id("responder") + .credentials("test") + .add_endpoint( + WebRtcPlayEndpointBuilder::default() + .id("play") + .src(insert_str!("local://{}/publisher/publish")) + .build() + .unwrap(), + ) + .build() + .unwrap(), + ) + .build() + .unwrap() + .into(); + + control_client.create(&create_room); let peers_created = Rc::new(Cell::new(0)); let on_event = @@ -222,7 +150,7 @@ fn delete_member_check_peers_removed() { peers_created.set(peers_created.get() + 1); if peers_created.get() == 2 { control_client - .delete(&[&format_name!("local://{}/responder")]); + .delete(&[&insert_str!("local://{}/responder")]); } } Event::PeersRemoved { .. } => { @@ -234,12 +162,12 @@ fn delete_member_check_peers_removed() { let deadline = Some(Duration::from_secs(5)); TestMember::start( - &format_name!("ws://127.0.0.1:8080/ws/{}/publisher/test"), + &insert_str!("ws://127.0.0.1:8080/ws/{}/publisher/test"), Box::new(on_event.clone()), deadline, ); TestMember::start( - &format_name!("ws://127.0.0.1:8080/ws/{}/responder/test"), + &insert_str!("ws://127.0.0.1:8080/ws/{}/responder/test"), Box::new(on_event), deadline, ); diff --git a/tests/e2e/main.rs b/tests/e2e/main.rs index 7cc210353..a5383d8ec 100644 --- a/tests/e2e/main.rs +++ b/tests/e2e/main.rs @@ -1,23 +1,23 @@ mod grpc_control_api; pub mod signalling; -/// Macro which generates `format_name!` macro which will replaces `{}` with -/// provided to `format_name_macro!` name. +/// Generates `insert_str!` macro, that can be used as `format!` macro with one +/// predefined argument. /// /// # Example usage /// /// ``` /// fn first_test() { -/// format_name_macro!("first-test"); +/// gen_insert_str_macro!("first-test"); /// -/// let addr = format_name!("ws://127.0.0.1:8080/{}/publisher/test"); +/// let addr = insert_str!("ws://127.0.0.1:8080/{}/publisher/test"); /// assert_eq!(addr, "ws://127.0.0.1:8080/first-test/publisher/test"); /// } /// /// fn second_test() { -/// format_name_macro!("second-test"); +/// gen_insert_str_macro!("second-test"); /// -/// let addr = format_name!("local://{}/publisher"); +/// let addr = insert_str!("local://{}/publisher"); /// assert_eq!(addr, "local://second-test/publisher"); /// } /// @@ -25,9 +25,9 @@ pub mod signalling; /// # second_test(); /// ``` #[macro_export] -macro_rules! format_name_macro { +macro_rules! gen_insert_str_macro { ($name:expr) => { - macro_rules! format_name { + macro_rules! insert_str { ($fmt:expr) => { format!($fmt, $name) }; From 20bf0e66ff1981bcbd8887ec1b7008328add598d Mon Sep 17 00:00:00 2001 From: alexlapa Date: Mon, 14 Oct 2019 15:10:27 +0300 Subject: [PATCH 702/735] make clippy --tests happy --- src/api/client/server.rs | 4 ++-- src/signalling/room_service.rs | 6 +++--- tests/e2e/grpc_control_api/delete.rs | 8 ++++---- tests/e2e/grpc_control_api/mod.rs | 9 ++++----- tests/e2e/grpc_control_api/signaling.rs | 15 ++++++--------- tests/e2e/signalling/mod.rs | 18 +++++++++--------- tests/e2e/signalling/three_pubs.rs | 16 ++++++++-------- 7 files changed, 36 insertions(+), 40 deletions(-) diff --git a/src/api/client/server.rs b/src/api/client/server.rs index 8c080f286..ad5bab92f 100644 --- a/src/api/client/server.rs +++ b/src/api/client/server.rs @@ -194,9 +194,9 @@ mod test { let conf = Conf { rpc: Rpc { idle_timeout: Duration::new(2, 0), - ..Default::default() + ..Rpc::default() }, - ..Default::default() + ..Conf::default() }; let mut server = ws_server(conf.clone()); diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index a785bd69c..f530ddd1a 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -515,7 +515,7 @@ mod delete_elements_validation_specs { fn error_if_not_same_room_ids() { let mut elements = DeleteElements::new(); ["local://room_id/member", "local://another_room_id/member"] - .into_iter() + .iter() .map(|uri| StatefulLocalUri::try_from(uri.to_string()).unwrap()) .for_each(|uri| elements.add_uri(uri)); @@ -545,7 +545,7 @@ mod delete_elements_validation_specs { "local://room_id/another_member_id", "local://room_id/member_id/endpoint_id", ] - .into_iter() + .iter() .map(|uri| StatefulLocalUri::try_from(uri.to_string()).unwrap()) .for_each(|uri| elements.add_uri(uri)); @@ -589,7 +589,7 @@ mod room_service_specs { /// Returns [`Addr`] to [`RoomService`]. fn room_service(room_repo: RoomRepository) -> Addr { let conf = Conf::default(); - let shutdown_timeout = conf.shutdown.timeout.clone(); + let shutdown_timeout = conf.shutdown.timeout; let app = app_ctx(); let graceful_shutdown = GracefulShutdown::new(shutdown_timeout).start(); diff --git a/tests/e2e/grpc_control_api/delete.rs b/tests/e2e/grpc_control_api/delete.rs index 7c7d32bbf..f6ccd081c 100644 --- a/tests/e2e/grpc_control_api/delete.rs +++ b/tests/e2e/grpc_control_api/delete.rs @@ -22,8 +22,8 @@ use super::{create_room_req, ControlClient}; /// /// `element_id`: `Element` ID which will be deleted from this `Room`, /// -/// `error_code`: [`ErrorCode`] which should be returned from [ControlAPI] when -/// we tries get deleted `Element`. +/// `error_code`: [`ErrorCode`] which should be returned from [`ControlAPI`] +/// when we tries get deleted `Element`. /// /// [Medea]: https://github.com/instrumentisto/medea /// [Control API]: https://tinyurl.com/yxsqplq7 @@ -84,8 +84,8 @@ fn endpoint() { /// /// `elements_uris`: `Element`s IDs which will be deleted from this `Element`, /// -/// `error_code`: [`ErrorCode`] which should be returned from [ControlAPI] when -/// we tries get deleted `Element`, +/// `error_code`: [`ErrorCode`] which should be returned from [`ControlAPI`] +/// when we tries get deleted `Element`, /// /// `root_elem_uri`: URI to parent `Element`. /// diff --git a/tests/e2e/grpc_control_api/mod.rs b/tests/e2e/grpc_control_api/mod.rs index 838c5b124..1e1ef6af2 100644 --- a/tests/e2e/grpc_control_api/mod.rs +++ b/tests/e2e/grpc_control_api/mod.rs @@ -40,7 +40,7 @@ impl ControlClient { pub fn new() -> Self { let env = Arc::new(EnvBuilder::new().build()); let ch = ChannelBuilder::new(env).connect("127.0.0.1:6565"); - ControlClient(ControlApiClient::new(ch)) + Self(ControlApiClient::new(ch)) } /// Gets some [`Element`] by local URI. @@ -104,8 +104,7 @@ impl ControlClient { pub fn delete(&self, ids: &[&str]) { let mut delete_req = IdRequest::new(); let mut delete_ids = RepeatedField::new(); - ids.into_iter() - .for_each(|id| delete_ids.push(id.to_string())); + ids.iter().for_each(|id| delete_ids.push(id.to_string())); delete_req.set_id(delete_ids); let resp = self.0.delete(&delete_req).unwrap(); @@ -232,10 +231,10 @@ impl Into for Endpoint { let mut member_elem = Member_Element::new(); match self { - Endpoint::WebRtcPlayElement(element) => { + Self::WebRtcPlayElement(element) => { member_elem.set_webrtc_play(element.into()); } - Endpoint::WebRtcPublishElement(element) => { + Self::WebRtcPublishElement(element) => { member_elem.set_webrtc_pub(element.into()) } } diff --git a/tests/e2e/grpc_control_api/signaling.rs b/tests/e2e/grpc_control_api/signaling.rs index 4d67b4241..6a50dd77f 100644 --- a/tests/e2e/grpc_control_api/signaling.rs +++ b/tests/e2e/grpc_control_api/signaling.rs @@ -51,16 +51,13 @@ fn signalling_starts_when_create_play_member_after_pub_member() { let peers_created = Rc::new(Cell::new(0)); let on_event = move |event: &Event, ctx: &mut Context, _: Vec<&Event>| { - match event { - Event::PeerCreated { .. } => { - peers_created.set(peers_created.get() + 1); - if peers_created.get() == 2 { - ctx.run_later(Duration::from_secs(1), |_, _| { - actix::System::current().stop(); - }); - } + if let Event::PeerCreated { .. } = event { + peers_created.set(peers_created.get() + 1); + if peers_created.get() == 2 { + ctx.run_later(Duration::from_secs(1), |_, _| { + actix::System::current().stop(); + }); } - _ => {} } }; diff --git a/tests/e2e/signalling/mod.rs b/tests/e2e/signalling/mod.rs index 752146ee5..3e423b810 100644 --- a/tests/e2e/signalling/mod.rs +++ b/tests/e2e/signalling/mod.rs @@ -56,8 +56,8 @@ impl TestMember { } /// Sends command to the server. - fn send_command(&mut self, msg: Command) { - let json = serde_json::to_string(&msg).unwrap(); + fn send_command(&mut self, msg: &Command) { + let json = serde_json::to_string(msg).unwrap(); self.writer.start_send(ws::Message::Text(json)).ok(); self.writer.poll_complete().ok(); } @@ -68,16 +68,16 @@ impl TestMember { uri: &str, on_message: MessageHandler, deadline: Option, - ) -> impl Future, Error = ()> { + ) -> impl Future, Error = ()> { awc::Client::new() .ws(uri) .connect() .map_err(|e| panic!("Error: {}", e)) .map(move |(_, framed)| { let (sink, stream) = framed.split(); - TestMember::create(move |ctx| { - TestMember::add_stream(stream, ctx); - TestMember { + Self::create(move |ctx| { + Self::add_stream(stream, ctx); + Self { writer: sink, events: Vec::new(), deadline, @@ -157,11 +157,11 @@ impl StreamHandler for TestMember { } = &event { match sdp_offer { - Some(_) => self.send_command(Command::MakeSdpAnswer { + Some(_) => self.send_command(&Command::MakeSdpAnswer { peer_id: *peer_id, sdp_answer: "responder_answer".into(), }), - None => self.send_command(Command::MakeSdpOffer { + None => self.send_command(&Command::MakeSdpOffer { peer_id: *peer_id, sdp_offer: "caller_offer".into(), mids: tracks @@ -173,7 +173,7 @@ impl StreamHandler for TestMember { }), } - self.send_command(Command::SetIceCandidate { + self.send_command(&Command::SetIceCandidate { peer_id: *peer_id, candidate: IceCandidate { candidate: "ice_candidate".to_string(), diff --git a/tests/e2e/signalling/three_pubs.rs b/tests/e2e/signalling/three_pubs.rs index 0f5693e02..75c73a7c5 100644 --- a/tests/e2e/signalling/three_pubs.rs +++ b/tests/e2e/signalling/three_pubs.rs @@ -58,13 +58,11 @@ fn three_members_p2p_video_call() { .iter() .filter_map(|t| match &t.direction { Direction::Recv { sender, .. } => { + assert_ne!(sender, peer_id); Some(sender) } _ => None, }) - .map(|sender| { - assert_ne!(sender, peer_id); - }) .count(); assert_eq!(recv_count, 2); @@ -73,13 +71,15 @@ fn three_members_p2p_video_call() { .filter_map(|t| match &t.direction { Direction::Send { receivers, .. - } => Some(receivers), + } => { + assert!( + !receivers.contains(peer_id) + ); + assert_eq!(receivers.len(), 1); + Some(receivers) + } _ => None, }) - .map(|receivers| { - assert!(!receivers.contains(peer_id)); - assert_eq!(receivers.len(), 1); - }) .count(); assert_eq!(send_count, 2); } From 98a4134d27108b12a32304347947b93c3e60516a Mon Sep 17 00:00:00 2001 From: alexlapa Date: Tue, 15 Oct 2019 00:57:13 +0300 Subject: [PATCH 703/735] extend test [run ci] --- tests/e2e/grpc_control_api/create.rs | 450 ++++++++++++++++++------ tests/e2e/grpc_control_api/delete.rs | 48 ++- tests/e2e/grpc_control_api/mod.rs | 28 +- tests/e2e/grpc_control_api/signaling.rs | 5 +- 4 files changed, 412 insertions(+), 119 deletions(-) diff --git a/tests/e2e/grpc_control_api/create.rs b/tests/e2e/grpc_control_api/create.rs index 69c13fc58..2267b308f 100644 --- a/tests/e2e/grpc_control_api/create.rs +++ b/tests/e2e/grpc_control_api/create.rs @@ -9,121 +9,361 @@ use medea_control_api_proto::grpc::api::WebRtcPublishEndpoint_P2P; use crate::gen_insert_str_macro; +use medea::api::control::error_codes::ErrorCode; + use super::{ - create_room_req, ControlClient, MemberBuilder, WebRtcPlayEndpointBuilder, - WebRtcPublishEndpointBuilder, + create_room_req, ControlClient, MemberBuilder, RoomBuilder, + WebRtcPlayEndpointBuilder, WebRtcPublishEndpointBuilder, }; -#[test] -fn room() { - gen_insert_str_macro!("create-room"); - - let client = ControlClient::new(); - let sids = client.create(&create_room_req(&insert_str!("{}"))); - assert_eq!(sids.len(), 2); - sids.get(&"publisher".to_string()).unwrap(); - let responder_sid = sids.get(&"responder".to_string()).unwrap().as_str(); - assert_eq!( - responder_sid, - &insert_str!("ws://127.0.0.1:8080/{}/responder/test") - ); - - let mut get_resp = client.get(&insert_str!("local://{}")); - let room = get_resp.take_room(); - - let responder = room - .get_pipeline() - .get(&insert_str!("local://{}/responder")) - .unwrap() - .get_member(); - assert_eq!(responder.get_credentials(), "test"); - let responder_pipeline = responder.get_pipeline(); - assert_eq!(responder_pipeline.len(), 1); - let responder_play = responder_pipeline - .get(&insert_str!("local://{}/responder/play")) - .unwrap() - .get_webrtc_play(); - assert_eq!( - responder_play.get_src(), - insert_str!("local://{}/publisher/publish") - ); - - let publisher = room - .get_pipeline() - .get(&insert_str!("local://{}/publisher")) - .unwrap() - .get_member(); - assert_ne!(publisher.get_credentials(), "test"); - assert_ne!(publisher.get_credentials(), ""); - let publisher_pipeline = responder.get_pipeline(); - assert_eq!(publisher_pipeline.len(), 1); -} +mod room { + use super::*; + + #[test] + fn room() { + gen_insert_str_macro!("create-room"); + + let client = ControlClient::new(); + let sids = client.create(&create_room_req(&insert_str!("{}"))); + assert_eq!(sids.len(), 2); + sids.get(&"publisher".to_string()).unwrap(); + let responder_sid = + sids.get(&"responder".to_string()).unwrap().as_str(); + assert_eq!( + responder_sid, + &insert_str!("ws://127.0.0.1:8080/{}/responder/test") + ); + + let mut get_resp = client.get(&insert_str!("local://{}")); + let room = get_resp.take_room(); + + let responder = room + .get_pipeline() + .get(&insert_str!("local://{}/responder")) + .unwrap() + .get_member(); + assert_eq!(responder.get_credentials(), "test"); + let responder_pipeline = responder.get_pipeline(); + assert_eq!(responder_pipeline.len(), 1); + let responder_play = responder_pipeline + .get(&insert_str!("local://{}/responder/play")) + .unwrap() + .get_webrtc_play(); + assert_eq!( + responder_play.get_src(), + insert_str!("local://{}/publisher/publish") + ); + + let publisher = room + .get_pipeline() + .get(&insert_str!("local://{}/publisher")) + .unwrap() + .get_member(); + assert_ne!(publisher.get_credentials(), "test"); + assert_ne!(publisher.get_credentials(), ""); + let publisher_pipeline = responder.get_pipeline(); + assert_eq!(publisher_pipeline.len(), 1); + } + + #[test] + fn cant_create_rooms_with_duplicate_ids() { + gen_insert_str_macro!("cant_create_rooms_with_duplicate_ids"); -#[test] -fn member() { - gen_insert_str_macro!("create-member"); - - let client = ControlClient::new(); - client.create(&create_room_req(&insert_str!("{}"))); - - let add_member = MemberBuilder::default() - .id("member") - .credentials("qwerty") - .add_endpoint( - WebRtcPlayEndpointBuilder::default() - .id("play") - .src(insert_str!("local://{}/publisher/publish")) - .build() - .unwrap(), - ) - .build() - .unwrap() - .build_request(insert_str!("local://{}/test-member")); - - let sids = client.create(&add_member); - let e2e_test_member_sid = - sids.get(&"test-member".to_string()).unwrap().as_str(); - assert_eq!( - e2e_test_member_sid, - insert_str!("ws://127.0.0.1:8080/{}/test-member/qwerty") - ); - - let member = client - .get(&insert_str!("local://{}/test-member")) - .take_member(); - assert_eq!(member.get_pipeline().len(), 1); - assert_eq!(member.get_credentials(), "qwerty"); + let client = ControlClient::new(); + + let create_room = RoomBuilder::default() + .id(insert_str!("local://{}")) + .build() + .unwrap() + .into(); + + client.create(&create_room); + + if let Err(err) = client.try_create(&create_room) { + assert_eq!(err.code, ErrorCode::RoomAlreadyExists as u32) + } else { + panic!("should err") + } + } + + #[test] + fn element_id_mismatch() { + gen_insert_str_macro!("cant_create_rooms_with_non_top_level_uri"); + + let client = ControlClient::new(); + + let create_room = RoomBuilder::default() + .id(insert_str!("local://qwerty/{}")) + .build() + .unwrap() + .into(); + + if let Err(err) = client.try_create(&create_room) { + assert_eq!(err.code, ErrorCode::ElementIdMismatch as u32) + } else { + panic!("should err") + } + } } -#[test] -fn asd() { - WebRtcPublishEndpointBuilder::default() - .id("publish") - .p2p_mode(WebRtcPublishEndpoint_P2P::NEVER) - .build() - .unwrap() - .build_request("local://{}/responder/publish"); +mod member { + + use super::*; + + #[test] + fn member() { + gen_insert_str_macro!("create-member"); + + let client = ControlClient::new(); + client.create(&create_room_req(&insert_str!("{}"))); + + let add_member = MemberBuilder::default() + .id("member") + .credentials("qwerty") + .add_endpoint( + WebRtcPlayEndpointBuilder::default() + .id("play") + .src(insert_str!("local://{}/publisher/publish")) + .build() + .unwrap(), + ) + .build() + .unwrap() + .build_request(insert_str!("local://{}/test-member")); + + let sids = client.create(&add_member); + let e2e_test_member_sid = + sids.get(&"test-member".to_string()).unwrap().as_str(); + assert_eq!( + e2e_test_member_sid, + insert_str!("ws://127.0.0.1:8080/{}/test-member/qwerty") + ); + + let member = client + .get(&insert_str!("local://{}/test-member")) + .take_member(); + assert_eq!(member.get_pipeline().len(), 1); + assert_eq!(member.get_credentials(), "qwerty"); + } + + #[test] + fn cant_create_member_in_non_existent_room() { + gen_insert_str_macro!("cant_create_member_in_non_existent_room"); + + let client = ControlClient::new(); + + let create_member = MemberBuilder::default() + .id("caller") + .build() + .unwrap() + .build_request(insert_str!("local://{}/member")); + + if let Err(err) = client.try_create(&create_member) { + assert_eq!(err.code, ErrorCode::RoomNotFound as u32) + } else { + panic!("should err") + } + } + + #[test] + fn cant_create_members_with_duplicate_ids() { + gen_insert_str_macro!("cant_create_members_with_duplicate_ids"); + + let client = ControlClient::new(); + + let create_room = RoomBuilder::default() + .id(insert_str!("local://{}")) + .build() + .unwrap() + .into(); + + client.create(&create_room); + + let create_member = MemberBuilder::default() + .id("caller") + .build() + .unwrap() + .build_request(insert_str!("local://{}/member")); + + client.create(&create_member); + + if let Err(err) = client.try_create(&create_member) { + assert_eq!(err.code, ErrorCode::MemberAlreadyExists as u32) + } else { + panic!("should err") + } + } + + #[test] + fn element_id_mismatch() { + let client = ControlClient::new(); + + let create_member = MemberBuilder::default() + .id("asd") + .build() + .unwrap() + .build_request("local://qwe"); + + if let Err(err) = client.try_create(&create_member) { + assert_eq!(err.code, ErrorCode::ElementIdMismatch as u32) + } else { + panic!("should err") + } + } } -#[test] -fn endpoint() { - gen_insert_str_macro!("create-endpoint"); +mod endpoint { + + use super::*; + + #[test] + fn endpoint() { + gen_insert_str_macro!("create-endpoint"); + + let client = ControlClient::new(); + client.create(&create_room_req(&insert_str!("{}"))); + + let create_req = WebRtcPublishEndpointBuilder::default() + .id("publish") + .p2p_mode(WebRtcPublishEndpoint_P2P::NEVER) + .build() + .unwrap() + .build_request(insert_str!("local://{}/responder/publish")); + + let sids = client.create(&create_req); + assert_eq!(sids.len(), 0); + + let endpoint = client + .get(&insert_str!("local://{}/responder/publish")) + .take_webrtc_pub(); + assert_eq!(endpoint.get_p2p(), WebRtcPublishEndpoint_P2P::NEVER); + } + + #[test] + fn cant_create_endpoint_in_non_existent_member() { + gen_insert_str_macro!("cant_create_endpoint_in_non_existent_member"); + + let client = ControlClient::new(); + + let create_room = RoomBuilder::default() + .id(insert_str!("local://{}")) + .build() + .unwrap() + .into(); + + client.create(&create_room); + + let create_play = WebRtcPublishEndpointBuilder::default() + .id("publish") + .p2p_mode(WebRtcPublishEndpoint_P2P::ALWAYS) + .build() + .unwrap() + .build_request(insert_str!("local://{}/member/publish")); + + if let Err(err) = client.try_create(&create_play) { + assert_eq!(err.code, ErrorCode::MemberNotFound as u32) + } else { + panic!("should err") + } + } + + #[test] + fn cant_create_endpoint_in_non_existent_room() { + gen_insert_str_macro!("cant_create_endpoint_in_non_existent_room"); + + let client = ControlClient::new(); + + let create_publish = WebRtcPublishEndpointBuilder::default() + .id("publish") + .p2p_mode(WebRtcPublishEndpoint_P2P::ALWAYS) + .build() + .unwrap() + .build_request(insert_str!("local://{}/member/publish")); + + if let Err(err) = client.try_create(&create_publish) { + assert_eq!(err.code, ErrorCode::RoomNotFound as u32) + } else { + panic!("should err") + } + } + + #[test] + fn cant_create_endpoints_with_duplicate_ids() { + gen_insert_str_macro!("cant_create_endpoints_with_duplicate_ids"); + + let client = ControlClient::new(); + + let create_room = RoomBuilder::default() + .id(insert_str!("local://{}")) + .add_member(MemberBuilder::default().id("member").build().unwrap()) + .build() + .unwrap() + .into(); + + client.create(&create_room); + + let create_endpoint = WebRtcPublishEndpointBuilder::default() + .id("publish") + .p2p_mode(WebRtcPublishEndpoint_P2P::ALWAYS) + .build() + .unwrap() + .build_request(insert_str!("local://{}/member/publish")); + + client.create(&create_endpoint); + + if let Err(err) = client.try_create(&create_endpoint) { + assert_eq!(err.code, ErrorCode::EndpointAlreadyExists as u32) + } else { + panic!("should err") + } + } + + #[test] + fn cant_create_play_endpoint_when_no_pusblish_endpoints() { + gen_insert_str_macro!( + "cant_create_play_endpoint_when_no_pusblish_endpoints" + ); + + let client = ControlClient::new(); + + let create_room = RoomBuilder::default() + .id(insert_str!("local://{}")) + .add_member(MemberBuilder::default().id("member").build().unwrap()) + .build() + .unwrap() + .into(); + + client.create(&create_room); + + let create_endpoint = WebRtcPlayEndpointBuilder::default() + .id("play") + .src(insert_str!("local://{}/member/publish")) + .build() + .unwrap() + .build_request(insert_str!("local://{}/member/play")); - let client = ControlClient::new(); - client.create(&create_room_req(&insert_str!("{}"))); + if let Err(err) = client.try_create(&create_endpoint) { + assert_eq!(err.code, ErrorCode::EndpointNotFound as u32) + } else { + panic!("should err") + } + } - let create_req = WebRtcPublishEndpointBuilder::default() - .id("publish") - .p2p_mode(WebRtcPublishEndpoint_P2P::NEVER) - .build() - .unwrap() - .build_request(insert_str!("local://{}/responder/publish")); + #[test] + fn element_id_mismatch() { + let client = ControlClient::new(); - let sids = client.create(&create_req); - assert_eq!(sids.len(), 0); + let create_endpoint = WebRtcPublishEndpointBuilder::default() + .id("asd") + .p2p_mode(WebRtcPublishEndpoint_P2P::ALWAYS) + .build() + .unwrap() + .build_request("local://qwe"); - let endpoint = client - .get(&insert_str!("local://{}/responder/publish")) - .take_webrtc_pub(); - assert_eq!(endpoint.get_p2p(), WebRtcPublishEndpoint_P2P::NEVER); + if let Err(err) = client.try_create(&create_endpoint) { + assert_eq!(err.code, ErrorCode::ElementIdMismatch as u32) + } else { + panic!("should err") + } + } } diff --git a/tests/e2e/grpc_control_api/delete.rs b/tests/e2e/grpc_control_api/delete.rs index f6ccd081c..e9a8da9fa 100644 --- a/tests/e2e/grpc_control_api/delete.rs +++ b/tests/e2e/grpc_control_api/delete.rs @@ -35,7 +35,10 @@ fn test_for_delete( ) { let client = ControlClient::new(); client.create(&create_room_req(room_id)); - client.delete(&[element_id]); + + client.try_get(element_id).unwrap(); + + client.delete(&[element_id]).unwrap(); let get_room_err = match client.try_get(element_id) { Ok(_) => panic!("{} not deleted!", element_id), @@ -74,8 +77,8 @@ fn endpoint() { ); } -/// Tests `Delete` method of [Control API] by trying to delete child `Element` -/// from the also deleting parent `Element`. +/// Tests that `Delete` method on parent element also deletes all nested +/// elements. /// /// # Arguments /// @@ -92,7 +95,7 @@ fn endpoint() { /// [Medea]: https://github.com/instrumentisto/medea /// [Control API]: https://tinyurl.com/yxsqplq7 /// [`ErrorCode`]: medea::api::control::error_codes::ErrorCode -fn test_for_delete_elements_at_same_time_test( +fn test_cascade_delete( room_id: &str, elements_uris: &[&str], code: MedeaErrorCode, @@ -100,7 +103,7 @@ fn test_for_delete_elements_at_same_time_test( ) { let client = ControlClient::new(); client.create(&create_room_req(room_id)); - client.delete(elements_uris); + client.delete(elements_uris).unwrap(); match client.try_get(root_elem_uri) { Ok(_) => panic!("Member not deleted!"), @@ -111,10 +114,10 @@ fn test_for_delete_elements_at_same_time_test( } #[test] -fn member_and_endpoint_same_time() { +fn cascade_delete_endpoints_when_deleting_member() { gen_insert_str_macro!("member-and-endpoint-same-time"); - test_for_delete_elements_at_same_time_test( + test_cascade_delete( &insert_str!("{}"), &[ &insert_str!("local://{}/publisher"), @@ -126,10 +129,10 @@ fn member_and_endpoint_same_time() { } #[test] -fn room_and_inner_elements_same_time() { +fn cascade_delete_everything_when_deleting_room() { gen_insert_str_macro!("room-and-inner-elements-same-time"); - test_for_delete_elements_at_same_time_test( + test_cascade_delete( &insert_str!("{}"), &[ &insert_str!("local://{}"), @@ -140,3 +143,30 @@ fn room_and_inner_elements_same_time() { &insert_str!("local://{}"), ); } + +#[test] +fn cant_delete_members_from_different_rooms_in_single_request() { + let client = ControlClient::new(); + + if let Err(err) = + client.delete(&["local://room1/member1", "local://room2/member1"]) + { + assert_eq!(err.code, MedeaErrorCode::ProvidedNotSameRoomIds as u32); + } else { + panic!("should err") + } +} + +#[test] +fn cant_delete_endpoints_from_different_rooms_in_single_request() { + let client = ControlClient::new(); + + if let Err(err) = client.delete(&[ + "local://room1/member1/endpoint1", + "local://room2/member1/endpoint1", + ]) { + assert_eq!(err.code, MedeaErrorCode::ProvidedNotSameRoomIds as u32); + } else { + panic!("should err") + } +} diff --git a/tests/e2e/grpc_control_api/mod.rs b/tests/e2e/grpc_control_api/mod.rs index 1e1ef6af2..747e30e59 100644 --- a/tests/e2e/grpc_control_api/mod.rs +++ b/tests/e2e/grpc_control_api/mod.rs @@ -95,21 +95,41 @@ impl ControlClient { resp.sid } + /// Tries to create `Element` and returns it sids. + /// + /// # Panics + /// + /// - if connection with server failed. + pub fn try_create( + &self, + req: &CreateRequest, + ) -> Result, Error> { + let mut resp = self.0.create(&req).unwrap(); + + if resp.has_error() { + Err(resp.take_error()) + } else { + Ok(resp.sid) + } + } + /// Deletes `Element`s by local URIs. /// /// # Panics /// /// - if [`Response`] has error /// - if connection with server failed. - pub fn delete(&self, ids: &[&str]) { + pub fn delete(&self, ids: &[&str]) -> Result<(), Error> { let mut delete_req = IdRequest::new(); let mut delete_ids = RepeatedField::new(); ids.iter().for_each(|id| delete_ids.push(id.to_string())); delete_req.set_id(delete_ids); - let resp = self.0.delete(&delete_req).unwrap(); + let mut resp = self.0.delete(&delete_req).unwrap(); if resp.has_error() { - panic!("{:?}", resp.get_error()); + Err(resp.take_error()) + } else { + Ok(()) } } } @@ -251,7 +271,7 @@ pub struct WebRtcPlayEndpoint { } impl WebRtcPlayEndpoint { - fn _build_request>(self, url: T) -> CreateRequest { + fn build_request>(self, url: T) -> CreateRequest { let mut request = CreateRequest::default(); request.set_id(url.into()); diff --git a/tests/e2e/grpc_control_api/signaling.rs b/tests/e2e/grpc_control_api/signaling.rs index 6a50dd77f..288095494 100644 --- a/tests/e2e/grpc_control_api/signaling.rs +++ b/tests/e2e/grpc_control_api/signaling.rs @@ -96,6 +96,8 @@ fn signalling_starts_when_create_play_member_after_pub_member() { sys.run().unwrap(); } +// TODO: add signalling_starts_when_create_play_endpoint_after_pub_endpoint + #[test] fn peers_removed_on_delete_member() { gen_insert_str_macro!("delete-member-check-peers-removed"); @@ -147,7 +149,8 @@ fn peers_removed_on_delete_member() { peers_created.set(peers_created.get() + 1); if peers_created.get() == 2 { control_client - .delete(&[&insert_str!("local://{}/responder")]); + .delete(&[&insert_str!("local://{}/responder")]) + .unwrap(); } } Event::PeersRemoved { .. } => { From f5e5f7d6b0619b7046d602d4b86ad2cb07b99f9a Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 15 Oct 2019 13:24:13 +0300 Subject: [PATCH 704/735] Create refs module --- src/api/control/endpoints/webrtc_play_endpoint.rs | 5 ++++- src/api/control/error_codes.rs | 2 +- src/api/control/grpc/server.rs | 6 +++--- src/api/control/mod.rs | 2 +- src/api/control/{ => refs}/local_uri.rs | 6 +++--- src/api/control/refs/mod.rs | 5 +++++ src/signalling/elements/member.rs | 2 +- src/signalling/participants.rs | 2 +- src/signalling/room.rs | 2 +- src/signalling/room_service.rs | 2 +- 10 files changed, 21 insertions(+), 13 deletions(-) rename src/api/control/{ => refs}/local_uri.rs (99%) create mode 100644 src/api/control/refs/mod.rs diff --git a/src/api/control/endpoints/webrtc_play_endpoint.rs b/src/api/control/endpoints/webrtc_play_endpoint.rs index a770778d5..94835edff 100644 --- a/src/api/control/endpoints/webrtc_play_endpoint.rs +++ b/src/api/control/endpoints/webrtc_play_endpoint.rs @@ -15,7 +15,10 @@ use serde::{ use crate::api::control::{ endpoints::webrtc_publish_endpoint::WebRtcPublishId, - local_uri::{LocalUri, LocalUriParseError, StatefulLocalUri, ToEndpoint}, + refs::{ + local_uri::{LocalUriParseError, StatefulLocalUri}, + LocalUri, ToEndpoint, + }, MemberId, RoomId, TryFromProtobufError, }; diff --git a/src/api/control/error_codes.rs b/src/api/control/error_codes.rs index 7cd1b63ed..0eeef36dc 100644 --- a/src/api/control/error_codes.rs +++ b/src/api/control/error_codes.rs @@ -12,7 +12,7 @@ use medea_control_api_proto::grpc::api::Error as ErrorProto; use crate::{ api::control::{ endpoints::webrtc_play_endpoint::SrcParseError, - grpc::server::GrpcControlApiError, local_uri::LocalUriParseError, + grpc::server::GrpcControlApiError, refs::local_uri::LocalUriParseError, TryFromElementError, TryFromProtobufError, }, signalling::{ diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index 523a793d8..39f210f59 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -22,9 +22,9 @@ use medea_control_api_proto::grpc::{ use crate::{ api::control::{ error_codes::{ErrorCode, ErrorResponse}, - local_uri::{ - LocalUri, LocalUriParseError, StatefulLocalUri, ToEndpoint, - ToMember, + refs::{ + local_uri::LocalUriParseError, LocalUri, StatefulLocalUri, + ToEndpoint, ToMember, }, EndpointSpec, MemberId, MemberSpec, RoomId, RoomSpec, TryFromElementError, TryFromProtobufError, diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index 98dda42a5..99a3f2507 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -5,9 +5,9 @@ pub mod endpoints; pub mod error_codes; pub mod grpc; -pub mod local_uri; pub mod member; pub mod pipeline; +pub mod refs; pub mod room; use std::{convert::TryFrom as _, fs::File, io::Read as _, path::Path}; diff --git a/src/api/control/local_uri.rs b/src/api/control/refs/local_uri.rs similarity index 99% rename from src/api/control/local_uri.rs rename to src/api/control/refs/local_uri.rs index a28a3bf42..4fcae9f80 100644 --- a/src/api/control/local_uri.rs +++ b/src/api/control/refs/local_uri.rs @@ -9,9 +9,9 @@ use derive_more::{Display, From}; use failure::Fail; use url::Url; -use crate::api::control::endpoints::webrtc_play_endpoint::SrcUri; - -use super::{EndpointId, MemberId, RoomId}; +use crate::api::control::{ + endpoints::webrtc_play_endpoint::SrcUri, EndpointId, MemberId, RoomId, +}; /// State of [`LocalUri`] which points to [`Room`]. /// diff --git a/src/api/control/refs/mod.rs b/src/api/control/refs/mod.rs new file mode 100644 index 000000000..bc67919d0 --- /dev/null +++ b/src/api/control/refs/mod.rs @@ -0,0 +1,5 @@ +pub mod local_uri; + +pub use self::local_uri::{ + LocalUri, StatefulLocalUri, ToEndpoint, ToMember, ToRoom, +}; diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index bcfb29055..af77142c8 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -20,7 +20,7 @@ use medea_control_api_proto::grpc::api::{ use crate::{ api::control::{ endpoints::WebRtcPlayEndpoint as WebRtcPlayEndpointSpec, - local_uri::{LocalUri, StatefulLocalUri, ToEndpoint, ToMember, ToRoom}, + refs::{LocalUri, StatefulLocalUri, ToEndpoint, ToMember, ToRoom}, EndpointId, MemberId, MemberSpec, RoomId, RoomSpec, TryFromElementError, WebRtcPlayId, WebRtcPublishId, }, diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 245d2ab66..e590d5596 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -31,7 +31,7 @@ use crate::{ RpcConnectionClosed, }, control::{ - local_uri::{LocalUri, ToEndpoint, ToMember}, + refs::{LocalUri, ToEndpoint, ToMember}, MemberId, RoomId, RoomSpec, }, }, diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 7c77d07a9..a0714cf46 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -28,7 +28,7 @@ use crate::{ WebRtcPlayEndpoint as WebRtcPlayEndpointSpec, WebRtcPublishEndpoint as WebRtcPublishEndpointSpec, }, - local_uri::{LocalUri, StatefulLocalUri, ToEndpoint, ToMember}, + refs::{LocalUri, StatefulLocalUri, ToEndpoint, ToMember}, room::RoomSpec, EndpointId, EndpointSpec, MemberId, MemberSpec, RoomId, TryFromElementError, WebRtcPlayId, WebRtcPublishId, diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index f530ddd1a..84b85e8cf 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -14,7 +14,7 @@ use crate::{ api::control::{ endpoints::EndpointSpec, load_static_specs_from_dir, - local_uri::{LocalUri, StatefulLocalUri, ToEndpoint, ToMember, ToRoom}, + refs::{LocalUri, StatefulLocalUri, ToEndpoint, ToMember, ToRoom}, LoadStaticControlSpecsError, MemberSpec, RoomId, RoomSpec, }, log::prelude::*, From e1ea1d60caac9c896da591e4477e59ab832eacfb Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 15 Oct 2019 14:36:38 +0300 Subject: [PATCH 705/735] Refactor, add Fid --- src/api/control/refs/fid.rs | 90 ++++++++++++++ src/api/control/refs/local_uri.rs | 136 +-------------------- src/api/control/refs/mod.rs | 190 +++++++++++++++++++++++++++++- 3 files changed, 282 insertions(+), 134 deletions(-) create mode 100644 src/api/control/refs/fid.rs diff --git a/src/api/control/refs/fid.rs b/src/api/control/refs/fid.rs new file mode 100644 index 000000000..512722152 --- /dev/null +++ b/src/api/control/refs/fid.rs @@ -0,0 +1,90 @@ +use std::{ + convert::TryFrom, + fmt::{Display, Error, Formatter}, +}; + +use derive_more::{Display, From}; + +use crate::impl_uri; + +use super::{ToEndpoint, ToMember, ToRoom}; + +#[derive(Display)] +pub enum ParseFidError { + #[display(fmt = "Fid is empty.")] + Empty, + + #[display(fmt = "Too many paths.")] + TooManyPaths, +} + +pub struct Fid { + state: T, +} + +impl_uri!(Fid); + +impl Display for Fid { + fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> { + write!(f, "{}", self.state.0) + } +} + +impl Display for Fid { + fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> { + write!(f, "{}/{}", self.state.0, self.state.1) + } +} + +impl Display for Fid { + fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> { + write!(f, "{}/{}/{}", self.state.0, self.state.1, self.state.2) + } +} + +#[derive(From)] +pub enum StatefulFid { + Room(Fid), + Member(Fid), + Endpoint(Fid), +} + +impl TryFrom for StatefulFid { + type Error = ParseFidError; + + fn try_from(value: String) -> Result { + let mut splitted = value.split('/'); + let room_id = if let Some(room_id) = splitted.next() { + room_id + } else { + return Err(ParseFidError::Empty); + }; + + let member_id = if let Some(member_id) = splitted.next() { + member_id + } else { + return Ok(Fid::::new(room_id.to_string().into()).into()); + }; + + let endpoint_id = if let Some(endpoint_id) = splitted.next() { + endpoint_id + } else { + return Ok(Fid::::new( + room_id.to_string().into(), + member_id.to_string().into(), + ) + .into()); + }; + + if let Some(_) = splitted.next() { + Err(ParseFidError::TooManyPaths) + } else { + Ok(Fid::::new( + room_id.to_string().into(), + member_id.to_string().into(), + endpoint_id.to_string().into(), + ) + .into()) + } + } +} diff --git a/src/api/control/refs/local_uri.rs b/src/api/control/refs/local_uri.rs index 4fcae9f80..e31471d7b 100644 --- a/src/api/control/refs/local_uri.rs +++ b/src/api/control/refs/local_uri.rs @@ -9,27 +9,12 @@ use derive_more::{Display, From}; use failure::Fail; use url::Url; -use crate::api::control::{ - endpoints::webrtc_play_endpoint::SrcUri, EndpointId, MemberId, RoomId, +use crate::{ + api::control::{endpoints::webrtc_play_endpoint::SrcUri, MemberId, RoomId}, + impl_uri, }; -/// State of [`LocalUri`] which points to [`Room`]. -/// -/// [`Room`]: crate::signalling::room::Room -#[derive(Clone, Debug, Eq, Hash, PartialEq)] -pub struct ToRoom(RoomId); - -/// State of [`LocalUri`] which points to [`Member`]. -/// -/// [`Member`]: crate::signalling::elements::member::Member -#[derive(Clone, Debug, Eq, Hash, PartialEq)] -pub struct ToMember(LocalUri, MemberId); - -/// State of [`LocalUri`] which points to [`Endpoint`]. -/// -/// [`Endpoint`]: crate::signalling::elements::endpoints::Endpoint -#[derive(Clone, Debug, Eq, Hash, PartialEq)] -pub struct ToEndpoint(LocalUri, EndpointId); +use super::{ToEndpoint, ToMember, ToRoom}; /// URI in format `local://room_id/member_id/endpoint_id`. /// @@ -95,30 +80,7 @@ pub struct LocalUri { state: T, } -impl LocalUri { - /// Creates new [`LocalUri`] in [`ToRoom`] state. - pub fn new(room_id: RoomId) -> Self { - Self { - state: ToRoom(room_id), - } - } - - /// Returns reference to [`RoomId`]. - pub fn room_id(&self) -> &RoomId { - &self.state.0 - } - - /// Returns [`RoomId`]. - pub fn take_room_id(self) -> RoomId { - self.state.0 - } - - /// Pushes [`MemberId`] to the end of URI and returns - /// [`LocalUri`] in [`ToMember`] state. - pub fn push_member_id(self, member_id: MemberId) -> LocalUri { - LocalUri::::new(self.state.0, member_id) - } -} +impl_uri!(LocalUri); impl From for LocalUri { fn from(from: StatefulLocalUri) -> Self { @@ -137,94 +99,6 @@ impl From for LocalUri { } } -impl LocalUri { - /// Create new [`LocalUri`] in [`ToMember`] state. - pub fn new(room_id: RoomId, member_id: MemberId) -> Self { - Self { - state: ToMember(LocalUri::::new(room_id), member_id), - } - } - - /// Returns reference to [`RoomId`]. - pub fn room_id(&self) -> &RoomId { - &self.state.0.room_id() - } - - /// Returns reference to [`MemberId`]. - pub fn member_id(&self) -> &MemberId { - &self.state.1 - } - - /// Return [`MemberId`] and [`LocalUri`] in state [`ToRoom`]. - pub fn take_member_id(self) -> (MemberId, LocalUri) { - (self.state.1, self.state.0) - } - - /// Push endpoint ID to the end of URI and returns - /// [`LocalUri`] in [`ToEndpoint`] state. - pub fn push_endpoint_id( - self, - endpoint_id: EndpointId, - ) -> LocalUri { - let (member_id, room_uri) = self.take_member_id(); - let room_id = room_uri.take_room_id(); - LocalUri::::new(room_id, member_id, endpoint_id) - } - - /// Returns [`RoomId`] and [`MemberId`]. - pub fn take_all(self) -> (RoomId, MemberId) { - let (member_id, room_url) = self.take_member_id(); - - (room_url.take_room_id(), member_id) - } -} - -impl LocalUri { - /// Creates new [`LocalUri`] in [`ToEndpoint`] state. - pub fn new( - room_id: RoomId, - member_id: MemberId, - endpoint_id: EndpointId, - ) -> Self { - Self { - state: ToEndpoint( - LocalUri::::new(room_id, member_id), - endpoint_id, - ), - } - } - - /// Returns reference to [`RoomId`]. - pub fn room_id(&self) -> &RoomId { - &self.state.0.room_id() - } - - /// Returns reference to [`MemberId`]. - pub fn member_id(&self) -> &MemberId { - &self.state.0.member_id() - } - - /// Returns reference to [`EndpointId`]. - pub fn endpoint_id(&self) -> &EndpointId { - &self.state.1 - } - - /// Returns [`Endpoint`] id and [`LocalUri`] in [`ToMember`] state. - /// - /// [`Endpoint`]: crate::signalling::elements::endpoints::Endpoint - pub fn take_endpoint_id(self) -> (EndpointId, LocalUri) { - (self.state.1, self.state.0) - } - - /// Returns [`EndpointId`], [`RoomId`] and [`MemberId`]. - pub fn take_all(self) -> (RoomId, MemberId, EndpointId) { - let (endpoint_id, member_url) = self.take_endpoint_id(); - let (member_id, room_url) = member_url.take_member_id(); - - (room_url.take_room_id(), member_id, endpoint_id) - } -} - impl From for LocalUri { fn from(uri: SrcUri) -> Self { LocalUri::::new( diff --git a/src/api/control/refs/mod.rs b/src/api/control/refs/mod.rs index bc67919d0..8677e2daf 100644 --- a/src/api/control/refs/mod.rs +++ b/src/api/control/refs/mod.rs @@ -1,5 +1,189 @@ +pub mod fid; pub mod local_uri; -pub use self::local_uri::{ - LocalUri, StatefulLocalUri, ToEndpoint, ToMember, ToRoom, -}; +pub use self::local_uri::{LocalUri, StatefulLocalUri}; + +use super::{EndpointId, MemberId, RoomId}; + +/// State of [`LocalUri`] which points to [`Room`]. +/// +/// [`Room`]: crate::signalling::room::Room +#[derive(Clone, Debug, Eq, Hash, PartialEq)] +pub struct ToRoom(RoomId); + +/// State of [`LocalUri`] which points to [`Member`]. +/// +/// [`Member`]: crate::signalling::elements::member::Member +#[derive(Clone, Debug, Eq, Hash, PartialEq)] +pub struct ToMember(RoomId, MemberId); + +/// State of [`LocalUri`] which points to [`Endpoint`]. +/// +/// [`Endpoint`]: crate::signalling::elements::endpoints::Endpoint +#[derive(Clone, Debug, Eq, Hash, PartialEq)] +pub struct ToEndpoint(RoomId, MemberId, EndpointId); + +// TODO: rename +#[macro_export] +macro_rules! impl_uri { + ($container:tt) => { + impl $container { + /// Creates new [`LocalUri`] in [`ToRoom`] state. + pub fn new(room_id: $crate::api::control::RoomId) -> Self { + Self { + state: ToRoom(room_id), + } + } + + /// Returns reference to [`RoomId`]. + pub fn room_id(&self) -> &$crate::api::control::RoomId { + &self.state.0 + } + + /// Returns [`RoomId`]. + pub fn take_room_id(self) -> $crate::api::control::RoomId { + self.state.0 + } + + /// Pushes [`MemberId`] to the end of URI and returns + /// [`LocalUri`] in [`ToMember`] state. + pub fn push_member_id( + self, + member_id: $crate::api::control::MemberId, + ) -> $container { + $container::<$crate::api::control::refs::ToMember>::new( + self.state.0, + member_id, + ) + } + } + + impl $container<$crate::api::control::refs::ToMember> { + /// Create new [`LocalUri`] in [`ToMember`] state. + pub fn new( + room_id: $crate::api::control::RoomId, + member_id: $crate::api::control::MemberId, + ) -> Self { + Self { + state: $crate::api::control::refs::ToMember( + room_id, member_id, + ), + } + } + + /// Returns reference to [`RoomId`]. + pub fn room_id(&self) -> &$crate::api::control::RoomId { + &self.state.0 + } + + /// Returns reference to [`MemberId`]. + pub fn member_id(&self) -> &$crate::api::control::MemberId { + &self.state.1 + } + + /// Return [`MemberId`] and [`LocalUri`] in state [`ToRoom`]. + pub fn take_member_id( + self, + ) -> ( + $crate::api::control::MemberId, + $container<$crate::api::control::refs::ToRoom>, + ) { + ( + self.state.1, + $container::<$crate::api::control::refs::ToRoom>::new( + self.state.0, + ), + ) + } + + /// Push endpoint ID to the end of URI and returns + /// [`LocalUri`] in [`ToEndpoint`] state. + pub fn push_endpoint_id( + self, + endpoint_id: $crate::api::control::EndpointId, + ) -> $container<$crate::api::control::refs::ToEndpoint> { + let (member_id, room_uri) = self.take_member_id(); + let room_id = room_uri.take_room_id(); + $container::<$crate::api::control::refs::ToEndpoint>::new( + room_id, + member_id, + endpoint_id, + ) + } + + /// Returns [`RoomId`] and [`MemberId`]. + pub fn take_all( + self, + ) -> ($crate::api::control::RoomId, $crate::api::control::MemberId) + { + let (member_id, room_url) = self.take_member_id(); + + (room_url.take_room_id(), member_id) + } + } + + impl $container<$crate::api::control::refs::ToEndpoint> { + /// Creates new [`LocalUri`] in [`ToEndpoint`] state. + pub fn new( + room_id: $crate::api::control::RoomId, + member_id: $crate::api::control::MemberId, + endpoint_id: $crate::api::control::EndpointId, + ) -> Self { + Self { + state: $crate::api::control::refs::ToEndpoint( + room_id, + member_id, + endpoint_id, + ), + } + } + + /// Returns reference to [`RoomId`]. + pub fn room_id(&self) -> &$crate::api::control::RoomId { + &self.state.0 + } + + /// Returns reference to [`MemberId`]. + pub fn member_id(&self) -> &$crate::api::control::MemberId { + &self.state.1 + } + + /// Returns reference to [`EndpointId`]. + pub fn endpoint_id(&self) -> &$crate::api::control::EndpointId { + &self.state.2 + } + + /// Returns [`Endpoint`] id and [`LocalUri`] in [`ToMember`] state. + /// + /// [`Endpoint`]: crate::signalling::elements::endpoints::Endpoint + pub fn take_endpoint_id( + self, + ) -> ( + $crate::api::control::EndpointId, + $container<$crate::api::control::refs::ToMember>, + ) { + ( + self.state.2, + $container::<$crate::api::control::refs::ToMember>::new( + self.state.0, + self.state.1, + ), + ) + } + + /// Returns [`EndpointId`], [`RoomId`] and [`MemberId`]. + pub fn take_all( + self, + ) -> ( + $crate::api::control::RoomId, + $crate::api::control::MemberId, + $crate::api::control::EndpointId, + ) { + let (endpoint_id, member_url) = self.take_endpoint_id(); + let (member_id, room_url) = member_url.take_member_id(); + + (room_url.take_room_id(), member_id, endpoint_id) + } + } + }; +} From 1266e8092d198ccc0ce2b87a39164964729963b6 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 15 Oct 2019 15:06:14 +0300 Subject: [PATCH 706/735] Use Fid --- src/api/control/error_codes.rs | 18 +++++- src/api/control/grpc/server.rs | 27 ++++----- src/api/control/refs/fid.rs | 43 ++++++++++++-- src/api/control/refs/mod.rs | 7 ++- src/signalling/elements/member.rs | 35 ++++++----- src/signalling/participants.rs | 21 +++---- src/signalling/room.rs | 43 ++++++-------- src/signalling/room_service.rs | 99 +++++++++++++++---------------- 8 files changed, 163 insertions(+), 130 deletions(-) diff --git a/src/api/control/error_codes.rs b/src/api/control/error_codes.rs index 0eeef36dc..ffbbb6f36 100644 --- a/src/api/control/error_codes.rs +++ b/src/api/control/error_codes.rs @@ -12,7 +12,8 @@ use medea_control_api_proto::grpc::api::Error as ErrorProto; use crate::{ api::control::{ endpoints::webrtc_play_endpoint::SrcParseError, - grpc::server::GrpcControlApiError, refs::local_uri::LocalUriParseError, + grpc::server::GrpcControlApiError, + refs::{fid::ParseFidError, local_uri::LocalUriParseError}, TryFromElementError, TryFromProtobufError, }, signalling::{ @@ -334,6 +335,19 @@ impl From for ErrorResponse { } } +impl From for ErrorResponse { + fn from(err: ParseFidError) -> Self { + use ParseFidError::*; + + match err { + TooManyPaths(text) => { + Self::new(ErrorCode::ElementIdIsTooLong, &text) + } + Empty => Self::without_id(ErrorCode::EmptyElementId), + } + } +} + impl From for ErrorResponse { fn from(err: RoomError) -> Self { use RoomError::*; @@ -434,7 +448,7 @@ impl From for ErrorResponse { use GrpcControlApiError::*; match err { - LocalUri(e) => e.into(), + Fid(e) => e.into(), TryFromProtobuf(e) => e.into(), RoomServiceError(e) => e.into(), RoomServiceMailboxError(_) | TryFromElement(_) => { diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index 39f210f59..b28e2f290 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -22,10 +22,7 @@ use medea_control_api_proto::grpc::{ use crate::{ api::control::{ error_codes::{ErrorCode, ErrorResponse}, - refs::{ - local_uri::LocalUriParseError, LocalUri, StatefulLocalUri, - ToEndpoint, ToMember, - }, + refs::{fid::ParseFidError, Fid, StatefulFid, ToEndpoint, ToMember}, EndpointSpec, MemberId, MemberSpec, RoomId, RoomSpec, TryFromElementError, TryFromProtobufError, }, @@ -43,8 +40,8 @@ use crate::{ /// [Control API]: https://tinyurl.com/yxsqplq7 #[derive(Debug, Display, Fail, From)] pub enum GrpcControlApiError { - /// Error while parsing [`LocalUri`] of element. - LocalUri(LocalUriParseError), + /// Error while parsing [`Fid`] of element. + Fid(ParseFidError), /// Error which can happen while converting protobuf objects into interior /// [medea] [Control API] objects. @@ -135,7 +132,7 @@ impl ControlApiService { /// Implementation of `Create` method for [`Member`] element. fn create_member( &self, - uri: LocalUri, + uri: Fid, spec: MemberSpec, ) -> impl Future { let sid = @@ -152,7 +149,7 @@ impl ControlApiService { /// Implementation of `Create` method for [`Endpoint`] element. fn create_endpoint( &self, - uri: LocalUri, + uri: Fid, spec: EndpointSpec, ) -> impl Future { self.room_service @@ -168,7 +165,7 @@ impl ControlApiService { &self, mut req: CreateRequest, ) -> Box + Send> { - let uri = match StatefulLocalUri::try_from(req.take_id()) { + let uri = match StatefulFid::try_from(req.take_id()) { Ok(uri) => uri, Err(e) => { return Box::new(future::err(e.into())); @@ -185,7 +182,7 @@ impl ControlApiService { }; match uri { - StatefulLocalUri::Room(uri) => Box::new( + StatefulFid::Room(uri) => Box::new( RoomSpec::try_from((uri.take_room_id(), elem)) .map_err(ErrorResponse::from) .map(|spec| { @@ -194,7 +191,7 @@ impl ControlApiService { .into_future() .and_then(|create_result| create_result), ), - StatefulLocalUri::Member(uri) => Box::new( + StatefulFid::Member(uri) => Box::new( MemberSpec::try_from((uri.member_id().clone(), elem)) .map_err(ErrorResponse::from) .map(|spec| { @@ -204,7 +201,7 @@ impl ControlApiService { .into_future() .and_then(|create_result| create_result), ), - StatefulLocalUri::Endpoint(uri) => Box::new( + StatefulFid::Endpoint(uri) => Box::new( EndpointSpec::try_from((uri.endpoint_id().clone(), elem)) .map_err(ErrorResponse::from) .map(|spec| { @@ -224,7 +221,7 @@ impl ControlApiService { ) -> impl Future { let mut delete_elements_msg = DeleteElements::new(); for id in req.take_id().into_iter() { - match StatefulLocalUri::try_from(id) { + match StatefulFid::try_from(id) { Ok(uri) => { delete_elements_msg.add_uri(uri); } @@ -259,7 +256,7 @@ impl ControlApiService { { let mut uris = Vec::new(); for id in req.take_id().into_iter() { - match StatefulLocalUri::try_from(id) { + match StatefulFid::try_from(id) { Ok(uri) => { uris.push(uri); } @@ -274,7 +271,7 @@ impl ControlApiService { .send(Get(uris)) .map_err(GrpcControlApiError::RoomServiceMailboxError) .and_then(|r| r.map_err(GrpcControlApiError::from)) - .map(|elements: HashMap| { + .map(|elements: HashMap| { elements .into_iter() .map(|(id, value)| (id.to_string(), value)) diff --git a/src/api/control/refs/fid.rs b/src/api/control/refs/fid.rs index 512722152..63b924d59 100644 --- a/src/api/control/refs/fid.rs +++ b/src/api/control/refs/fid.rs @@ -8,22 +8,42 @@ use derive_more::{Display, From}; use crate::impl_uri; use super::{ToEndpoint, ToMember, ToRoom}; +use crate::api::control::RoomId; +use std::convert::From; -#[derive(Display)] +#[derive(Display, Debug)] pub enum ParseFidError { #[display(fmt = "Fid is empty.")] Empty, - #[display(fmt = "Too many paths.")] - TooManyPaths, + #[display(fmt = "Too many paths [id = {}].", _0)] + TooManyPaths(String), } +#[derive(Clone, Debug, Eq, Hash, PartialEq)] pub struct Fid { state: T, } impl_uri!(Fid); +impl From for Fid { + fn from(from: StatefulFid) -> Self { + match from { + StatefulFid::Room(uri) => uri, + StatefulFid::Member(uri) => { + let (_, uri) = uri.take_member_id(); + uri + } + StatefulFid::Endpoint(uri) => { + let (_, uri) = uri.take_endpoint_id(); + let (_, uri) = uri.take_member_id(); + uri + } + } + } +} + impl Display for Fid { fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> { write!(f, "{}", self.state.0) @@ -42,13 +62,26 @@ impl Display for Fid { } } -#[derive(From)] +#[derive(Debug, Hash, PartialEq, Eq, Clone, Display, From)] pub enum StatefulFid { Room(Fid), Member(Fid), Endpoint(Fid), } +impl StatefulFid { + /// Returns reference to [`RoomId`]. + /// + /// This is possible in any [`LocalUri`] state. + pub fn room_id(&self) -> &RoomId { + match self { + StatefulFid::Room(uri) => uri.room_id(), + StatefulFid::Member(uri) => uri.room_id(), + StatefulFid::Endpoint(uri) => uri.room_id(), + } + } +} + impl TryFrom for StatefulFid { type Error = ParseFidError; @@ -77,7 +110,7 @@ impl TryFrom for StatefulFid { }; if let Some(_) = splitted.next() { - Err(ParseFidError::TooManyPaths) + Err(ParseFidError::TooManyPaths(value)) } else { Ok(Fid::::new( room_id.to_string().into(), diff --git a/src/api/control/refs/mod.rs b/src/api/control/refs/mod.rs index 8677e2daf..fbfbd4644 100644 --- a/src/api/control/refs/mod.rs +++ b/src/api/control/refs/mod.rs @@ -1,10 +1,13 @@ pub mod fid; pub mod local_uri; -pub use self::local_uri::{LocalUri, StatefulLocalUri}; - use super::{EndpointId, MemberId, RoomId}; +pub use self::{ + fid::{Fid, StatefulFid}, + local_uri::{LocalUri, StatefulLocalUri}, +}; + /// State of [`LocalUri`] which points to [`Room`]. /// /// [`Room`]: crate::signalling::room::Room diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index af77142c8..c3dd827b1 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -20,7 +20,7 @@ use medea_control_api_proto::grpc::api::{ use crate::{ api::control::{ endpoints::WebRtcPlayEndpoint as WebRtcPlayEndpointSpec, - refs::{LocalUri, StatefulLocalUri, ToEndpoint, ToMember, ToRoom}, + refs::{Fid, StatefulFid, ToEndpoint, ToMember, ToRoom}, EndpointId, MemberId, MemberSpec, RoomId, RoomSpec, TryFromElementError, WebRtcPlayId, WebRtcPublishId, }, @@ -38,11 +38,11 @@ use super::endpoints::{ pub enum MembersLoadError { /// Errors that can occur when we try transform some spec from `Element`. #[display(fmt = "TryFromElementError: {}", _0)] - TryFromError(TryFromElementError, StatefulLocalUri), + TryFromError(TryFromElementError, StatefulFid), /// [`Member`] not found. #[display(fmt = "Member [id = {}] not found.", _0)] - MemberNotFound(LocalUri), + MemberNotFound(Fid), /// [`EndpointSpec`] not found. /// @@ -58,7 +58,7 @@ pub enum MembersLoadError { #[derive(Debug, Fail, Display)] pub enum MemberError { #[display(fmt = "Endpoint [id = {}] not found.", _0)] - EndpointNotFound(LocalUri), + EndpointNotFound(Fid), } /// [`Member`] is member of [`Room`]. @@ -117,7 +117,7 @@ impl Member { member_id: &MemberId, ) -> Result { let element = room_spec.pipeline.get(member_id).map_or( - Err(MembersLoadError::MemberNotFound(LocalUri::::new( + Err(MembersLoadError::MemberNotFound(Fid::::new( self.room_id(), member_id.clone(), ))), @@ -127,8 +127,7 @@ impl Member { MemberSpec::try_from(element).map_err(|e| { MembersLoadError::TryFromError( e, - LocalUri::::new(self.room_id(), member_id.clone()) - .into(), + Fid::::new(self.room_id(), member_id.clone()).into(), ) }) } @@ -144,9 +143,9 @@ impl Member { let this_member_spec = self.get_member_from_room_spec(room_spec, &self_id)?; - let this_member = store.get(&self.id()).ok_or_else(|| { - MembersLoadError::MemberNotFound(self.get_local_uri()) - })?; + let this_member = store + .get(&self.id()) + .ok_or_else(|| MembersLoadError::MemberNotFound(self.get_fid()))?; for (spec_play_name, spec_play_endpoint) in this_member_spec.play_endpoints() @@ -155,7 +154,7 @@ impl Member { MemberId(spec_play_endpoint.src.member_id.to_string()); let publisher_member = store.get(&publisher_id).ok_or_else(|| { - MembersLoadError::MemberNotFound(LocalUri::::new( + MembersLoadError::MemberNotFound(Fid::::new( self.room_id(), publisher_id, )) @@ -227,20 +226,20 @@ impl Member { Ok(()) } - /// Returns [`LocalUri`] to this [`Member`]. - fn get_local_uri(&self) -> LocalUri { - LocalUri::::new(self.room_id(), self.id()) + /// Returns [`Fid`] to this [`Member`]. + fn get_fid(&self) -> Fid { + Fid::::new(self.room_id(), self.id()) } - /// Returns [`LocalUri`] to some endpoint from this [`Member`]. + /// Returns [`Fid`] to some endpoint from this [`Member`]. /// /// __Note__ this function don't check presence of `Endpoint` in this /// [`Member`]. pub fn get_local_uri_to_endpoint( &self, endpoint_id: EndpointId, - ) -> LocalUri { - LocalUri::::new(self.room_id(), self.id(), endpoint_id) + ) -> Fid { + Fid::::new(self.room_id(), self.id(), endpoint_id) } /// Notifies [`Member`] that some [`Peer`]s removed. @@ -436,7 +435,7 @@ pub fn parse_members( let members_spec = room_spec.members().map_err(|e| { MembersLoadError::TryFromError( e, - LocalUri::::new(room_spec.id.clone()).into(), + Fid::::new(room_spec.id.clone()).into(), ) })?; diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index e590d5596..3900d0fd3 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -31,7 +31,7 @@ use crate::{ RpcConnectionClosed, }, control::{ - refs::{LocalUri, ToEndpoint, ToMember}, + refs::{Fid, ToEndpoint, ToMember}, MemberId, RoomId, RoomSpec, }, }, @@ -57,15 +57,15 @@ pub enum ParticipantServiceErr { #[display(fmt = "TurnService Error in ParticipantService: {}", _0)] TurnServiceErr(TurnServiceErr), - /// [`Member`] with provided [`LocalUri`] not found. + /// [`Member`] with provided [`Fid`] not found. #[display(fmt = "Participant [id = {}] not found", _0)] - ParticipantNotFound(LocalUri), + ParticipantNotFound(Fid), /// [`Endpoint`] with provided URI not found. /// /// [`Endpoint`]: crate::signalling::elements::endpoints::Endpoint #[display(fmt = "Endpoint [id = {}] not found.", _0)] - EndpointNotFound(LocalUri), + EndpointNotFound(Fid), /// Some error happened in [`Member`]. #[display(fmt = "{}", _0)] @@ -136,16 +136,13 @@ impl ParticipantService { self.members.get(id).cloned() } - /// Generates [`LocalUri`] which point to some [`Member`] in this + /// Generates [`Fid`] which point to some [`Member`] in this /// [`ParticipantService`]'s [`Room`]. /// /// __Note__ this function don't check presence of [`Member`] in /// [`ParticipantService`]. - pub fn get_local_uri_to_member( - &self, - member_id: MemberId, - ) -> LocalUri { - LocalUri::::new(self.room_id.clone(), member_id) + pub fn get_fid_to_member(&self, member_id: MemberId) -> Fid { + Fid::::new(self.room_id.clone(), member_id) } /// Lookups [`Member`] by [`MemberId`]. @@ -158,7 +155,7 @@ impl ParticipantService { ) -> Result { self.members.get(id).cloned().map_or( Err(ParticipantServiceErr::ParticipantNotFound( - self.get_local_uri_to_member(id.clone()), + self.get_fid_to_member(id.clone()), )), Ok, ) @@ -229,7 +226,7 @@ impl ParticipantService { None => { return Box::new(wrap_future(future::err( ParticipantServiceErr::ParticipantNotFound( - self.get_local_uri_to_member(member_id), + self.get_fid_to_member(member_id), ), ))); } diff --git a/src/signalling/room.rs b/src/signalling/room.rs index a0714cf46..4b392de47 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -28,7 +28,7 @@ use crate::{ WebRtcPlayEndpoint as WebRtcPlayEndpointSpec, WebRtcPublishEndpoint as WebRtcPublishEndpointSpec, }, - refs::{LocalUri, StatefulLocalUri, ToEndpoint, ToMember}, + refs::{Fid, StatefulFid, ToEndpoint, ToMember}, room::RoomSpec, EndpointId, EndpointSpec, MemberId, MemberSpec, RoomId, TryFromElementError, WebRtcPlayId, WebRtcPublishId, @@ -83,20 +83,16 @@ pub enum RoomError { ParticipantServiceErr(ParticipantServiceErr), #[display(fmt = "Client error:{}", _0)] ClientError(String), - #[display( - fmt = "Given LocalUri [uri = {}] to wrong room [id = {}]", - _0, - _1 - )] - WrongRoomId(StatefulLocalUri, RoomId), + #[display(fmt = "Given Fid [uri = {}] to wrong room [id = {}]", _0, _1)] + WrongRoomId(StatefulFid, RoomId), /// Try to create [`Member`] with ID which already exists. #[display(fmt = "Member [id = {}] already exists.", _0)] - MemberAlreadyExists(LocalUri), + MemberAlreadyExists(Fid), /// Try to create [`Endpoint`] with ID which already exists. /// /// [`Endpoint`]: crate::signalling::elements::endpoints::Endpoint #[display(fmt = "Endpoint [id = {}] already exists.", _0)] - EndpointAlreadyExists(LocalUri), + EndpointAlreadyExists(Fid), } impl From for RoomError { @@ -798,7 +794,7 @@ impl Room { ) -> Result<(), RoomError> { if self.members.get_member_by_id(&id).is_some() { return Err(RoomError::MemberAlreadyExists( - self.members.get_local_uri_to_member(id), + self.members.get_fid_to_member(id), )); } let signalling_member = Member::new( @@ -871,7 +867,7 @@ impl Into for &mut Room { .members() .into_iter() .map(|(id, member)| { - let local_uri = LocalUri::::new(self.get_id(), id); + let local_uri = Fid::::new(self.get_id(), id); (local_uri.to_string(), member.into()) }) .collect(); @@ -886,22 +882,21 @@ impl Into for &mut Room { /// Message for serializing this [`Room`] and [`Room`]'s elements to protobuf /// spec. #[derive(Message)] -#[rtype(result = "Result, RoomError>")] -pub struct SerializeProto(pub Vec); +#[rtype(result = "Result, RoomError>")] +pub struct SerializeProto(pub Vec); impl Handler for Room { - type Result = Result, RoomError>; + type Result = Result, RoomError>; fn handle( &mut self, msg: SerializeProto, _: &mut Self::Context, ) -> Self::Result { - let mut serialized: HashMap = - HashMap::new(); + let mut serialized: HashMap = HashMap::new(); for uri in msg.0 { match &uri { - StatefulLocalUri::Room(room_uri) => { + StatefulFid::Room(room_uri) => { if room_uri.room_id() == &self.id { let current_room: ElementProto = self.into(); serialized.insert(uri, current_room); @@ -912,12 +907,12 @@ impl Handler for Room { )); } } - StatefulLocalUri::Member(member_uri) => { + StatefulFid::Member(member_uri) => { let member = self.members.get_member(member_uri.member_id())?; serialized.insert(uri, member.into()); } - StatefulLocalUri::Endpoint(endpoint_uri) => { + StatefulFid::Endpoint(endpoint_uri) => { let member = self.members.get_member(endpoint_uri.member_id())?; let endpoint = member.get_endpoint_by_id( @@ -1113,7 +1108,7 @@ impl Handler for Room { /// Signal for delete elements from this [`Room`]. #[derive(Message, Debug)] #[rtype(result = "()")] -pub struct Delete(pub Vec); +pub struct Delete(pub Vec); impl Handler for Room { type Result = (); @@ -1123,15 +1118,13 @@ impl Handler for Room { let mut endpoint_ids = Vec::new(); for id in msg.0 { match id { - StatefulLocalUri::Member(member_uri) => { + StatefulFid::Member(member_uri) => { member_ids.push(member_uri); } - StatefulLocalUri::Endpoint(endpoint_uri) => { + StatefulFid::Endpoint(endpoint_uri) => { endpoint_ids.push(endpoint_uri); } - _ => warn!( - "Found LocalUri while deleting __from__ Room." - ), + _ => warn!("Found Fid while deleting __from__ Room."), } } member_ids.into_iter().for_each(|uri| { diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index 84b85e8cf..2155a7f3f 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -14,7 +14,7 @@ use crate::{ api::control::{ endpoints::EndpointSpec, load_static_specs_from_dir, - refs::{LocalUri, StatefulLocalUri, ToEndpoint, ToMember, ToRoom}, + refs::{Fid, StatefulFid, ToEndpoint, ToMember, ToRoom}, LoadStaticControlSpecsError, MemberSpec, RoomId, RoomSpec, }, log::prelude::*, @@ -36,7 +36,7 @@ use crate::{ pub enum RoomServiceError { /// [`Room`] not found in [`RoomRepository`]. #[display(fmt = "Room [id = {}] not found.", _0)] - RoomNotFound(LocalUri), + RoomNotFound(Fid), /// Wrapper for [`Room`]'s [`MailboxError`]. #[display(fmt = "Room mailbox error: {:?}", _0)] @@ -45,7 +45,7 @@ pub enum RoomServiceError { /// Try to create [`Room`] with [`RoomId`] which already exists in /// [`RoomRepository`]. #[display(fmt = "Room [id = {}] already exists.", _0)] - RoomAlreadyExists(LocalUri), + RoomAlreadyExists(Fid), /// Some error happened in [`Room`]. /// @@ -59,11 +59,11 @@ pub enum RoomServiceError { #[display(fmt = "Failed to load static specs. {:?}", _0)] FailedToLoadStaticSpecs(LoadStaticControlSpecsError), - /// Provided empty [`LocalUri`] list. + /// Provided empty [`Fid`] list. #[display(fmt = "Empty URIs list.")] EmptyUrisList, - /// Provided not the same [`RoomId`]s in [`LocalUri`] list. + /// Provided not the same [`RoomId`]s in [`Fid`] list. /// /// Atm this error can happen in `Delete` method because `Delete` should be /// called only for one [`Room`]. @@ -153,12 +153,14 @@ impl Actor for RoomService { type Context = Context; } -/// Returns [`LocalUri`] pointing to [`Room`]. +// TODO: is this needed?? +// maybe Fid::::new()?? +/// Returns [`Fid`] pointing to [`Room`]. /// /// __Note__ this function don't check presence of [`Room`] in this /// [`RoomService`]. -fn get_local_uri_to_room(room_id: RoomId) -> LocalUri { - LocalUri::::new(room_id) +fn get_fid_to_room(room_id: RoomId) -> Fid { + Fid::::new(room_id) } /// Signal for load all static specs and start [`Room`]s. @@ -179,7 +181,7 @@ impl Handler for RoomService { for spec in room_specs { if self.room_repo.contains_room_with_id(spec.id()) { return Err(RoomServiceError::RoomAlreadyExists( - get_local_uri_to_room(spec.id), + get_fid_to_room(spec.id), )); } @@ -219,9 +221,9 @@ impl Handler for RoomService { let room_spec = msg.spec; if self.room_repo.get(&room_spec.id).is_some() { - return Err(RoomServiceError::RoomAlreadyExists( - get_local_uri_to_room(room_spec.id), - )); + return Err(RoomServiceError::RoomAlreadyExists(get_fid_to_room( + room_spec.id, + ))); } let room = Room::new(&room_spec, &self.app)?; @@ -246,7 +248,7 @@ impl Handler for RoomService { #[derive(Message)] #[rtype(result = "Result<(), RoomServiceError>")] pub struct CreateMemberInRoom { - pub uri: LocalUri, + pub uri: Fid, pub spec: MemberSpec, } @@ -267,7 +269,7 @@ impl Handler for RoomService { .and_then(|r| r.map_err(RoomServiceError::from)), ) } else { - let room_uri = LocalUri::::new(room_id); + let room_uri = Fid::::new(room_id); Box::new(future::err(RoomServiceError::RoomNotFound(room_uri))) } } @@ -279,7 +281,7 @@ impl Handler for RoomService { #[derive(Message)] #[rtype(result = "Result<(), RoomServiceError>")] pub struct CreateEndpointInRoom { - pub uri: LocalUri, + pub uri: Fid, pub spec: EndpointSpec, } @@ -304,7 +306,7 @@ impl Handler for RoomService { .and_then(|r| r.map_err(RoomServiceError::from)), ) } else { - let room_uri = LocalUri::::new(room_id); + let room_uri = Fid::::new(room_id); Box::new(future::err(RoomServiceError::RoomNotFound(room_uri))) } } @@ -331,8 +333,8 @@ impl DeleteElements { } } - /// Adds [`StatefulLocalUri`] to request. - pub fn add_uri(&mut self, uri: StatefulLocalUri) { + /// Adds [`StatefulFid`] to request. + pub fn add_uri(&mut self, uri: StatefulFid) { self.uris.push(uri) } @@ -370,7 +372,7 @@ impl DeleteElements { /// For ability to send this message to [`RoomService`] [`DeleteElements`] /// should be in [`Validated`] state. You can go to [`Validated`] state /// from [`Unvalidated`] with [`DeleteElements::validate`] function -/// which will validate all [`StatefulLocalUri`]s. +/// which will validate all [`StatefulFid`]s. /// /// Validation doesn't guarantee that message can't return [`RoomServiceError`]. /// This is just validation for errors which we can catch before sending @@ -380,7 +382,7 @@ impl DeleteElements { #[derive(Message, Default)] #[rtype(result = "Result<(), RoomServiceError>")] pub struct DeleteElements { - uris: Vec, + uris: Vec, _validation_state: PhantomData, } @@ -395,7 +397,7 @@ impl Handler> for RoomService { msg: DeleteElements, _: &mut Self::Context, ) -> Self::Result { - let mut deletes_from_room: Vec = Vec::new(); + let mut deletes_from_room: Vec = Vec::new(); // TODO: use Vec::drain_filter when it will be in stable let room_messages_futs: Vec< Box>, @@ -403,7 +405,7 @@ impl Handler> for RoomService { .uris .into_iter() .filter_map(|l| { - if let StatefulLocalUri::Room(room_id) = l { + if let StatefulFid::Room(room_id) = l { Some(self.close_room(room_id.take_room_id())) } else { deletes_from_room.push(l); @@ -437,13 +439,13 @@ impl Handler> for RoomService { /// Serialized to protobuf `Element`s which will be returned from [`Get`] on /// success result. -type SerializedElements = HashMap; +type SerializedElements = HashMap; /// Message which returns serialized to protobuf objects by provided -/// [`LocalUri`]. +/// [`Fid`]. #[derive(Message)] #[rtype(result = "Result")] -pub struct Get(pub Vec); +pub struct Get(pub Vec); impl Handler for RoomService { type Result = ResponseFuture; @@ -516,7 +518,7 @@ mod delete_elements_validation_specs { let mut elements = DeleteElements::new(); ["local://room_id/member", "local://another_room_id/member"] .iter() - .map(|uri| StatefulLocalUri::try_from(uri.to_string()).unwrap()) + .map(|uri| StatefulFid::try_from(uri.to_string()).unwrap()) .for_each(|uri| elements.add_uri(uri)); match elements.validate() { @@ -546,7 +548,7 @@ mod delete_elements_validation_specs { "local://room_id/member_id/endpoint_id", ] .iter() - .map(|uri| StatefulLocalUri::try_from(uri.to_string()).unwrap()) + .map(|uri| StatefulFid::try_from(uri.to_string()).unwrap()) .for_each(|uri| elements.add_uri(uri)); assert!(elements.validate().is_ok()); @@ -606,7 +608,7 @@ mod room_service_specs { /// /// `$create_msg` - [`actix::Message`] which will create `Element`, /// - /// `$element_uri` - [`StatefulLocalUri`] to `Element` which you try to + /// `$element_uri` - [`StatefulFid`] to `Element` which you try to /// create, /// /// `$test` - closure in which will be provided created @@ -641,7 +643,7 @@ mod room_service_specs { let room_service = room_service(RoomRepository::new(HashMap::new())); let spec = room_spec(); - let caller_uri = StatefulLocalUri::try_from( + let caller_uri = StatefulFid::try_from( "local://pub-sub-video-call/caller".to_string(), ) .unwrap(); @@ -675,11 +677,9 @@ mod room_service_specs { room_id.clone() => Room::new(&spec, &app_ctx()).unwrap().start(), ))); - let member_uri = LocalUri::::new( - room_id, - "test-member".to_string().into(), - ); - let stateful_member_uri: StatefulLocalUri = member_uri.clone().into(); + let member_uri = + Fid::::new(room_id, "test-member".to_string().into()); + let stateful_member_uri: Fid = member_uri.clone().into(); actix::spawn(test_for_create!( room_service, @@ -718,13 +718,12 @@ mod room_service_specs { room_id.clone() => Room::new(&spec, &app_ctx()).unwrap().start(), ))); - let endpoint_uri = LocalUri::::new( + let endpoint_uri = Fid::::new( room_id, "caller".to_string().into(), "test-publish".to_string().into(), ); - let stateful_endpoint_uri: StatefulLocalUri = - endpoint_uri.clone().into(); + let stateful_endpoint_uri: Fid = endpoint_uri.clone().into(); actix::spawn(test_for_create!( room_service, @@ -748,13 +747,13 @@ mod room_service_specs { /// [`RoomService`]. /// /// This test is simply try to delete element with provided - /// [`StatefulLocalUri`] and the try to get it. If result of getting + /// [`StatefulFid`] and the try to get it. If result of getting /// deleted element is error then test considers successful. /// /// This function automatically stops [`actix::System`] when test completed. fn test_for_delete_and_get( room_service: Addr, - element_stateful_uri: StatefulLocalUri, + element_stateful_uri: StatefulFid, ) -> impl Future { let mut delete_msg = DeleteElements::new(); delete_msg.add_uri(element_stateful_uri.clone()); @@ -779,7 +778,7 @@ mod room_service_specs { let room_id: RoomId = "pub-sub-video-call".to_string().into(); let stateful_room_uri = - StatefulLocalUri::from(LocalUri::::new(room_id.clone())); + StatefulFid::from(Fid::::new(room_id.clone())); let room_service = room_service(RoomRepository::new(hashmap!( room_id => Room::new(&room_spec(), &app_ctx()).unwrap().start(), @@ -795,11 +794,10 @@ mod room_service_specs { let sys = actix::System::new("room-service-tests"); let room_id: RoomId = "pub-sub-video-call".to_string().into(); - let stateful_member_uri = - StatefulLocalUri::from(LocalUri::::new( - room_id.clone(), - "caller".to_string().into(), - )); + let stateful_member_uri = StatefulFid::from(Fid::::new( + room_id.clone(), + "caller".to_string().into(), + )); let room_service = room_service(RoomRepository::new(hashmap!( room_id => Room::new(&room_spec(), &app_ctx()).unwrap().start(), @@ -818,12 +816,11 @@ mod room_service_specs { let sys = actix::System::new("room-service-tests"); let room_id: RoomId = "pub-sub-video-call".to_string().into(); - let stateful_endpoint_uri = - StatefulLocalUri::from(LocalUri::::new( - room_id.clone(), - "caller".to_string().into(), - "publish".to_string().into(), - )); + let stateful_endpoint_uri = StatefulFid::from(Fid::::new( + room_id.clone(), + "caller".to_string().into(), + "publish".to_string().into(), + )); let room_service = room_service(RoomRepository::new(hashmap!( room_id => Room::new(&room_spec(), &app_ctx()).unwrap().start(), From d28ffdb726be26bd7bcf2b20c2752b41778d324d Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 15 Oct 2019 15:25:04 +0300 Subject: [PATCH 707/735] Fix e2e tests --- tests/e2e/grpc_control_api/create.rs | 42 ++++++++++++------------- tests/e2e/grpc_control_api/delete.rs | 26 +++++++-------- tests/e2e/grpc_control_api/mod.rs | 2 +- tests/e2e/grpc_control_api/signaling.rs | 8 ++--- 4 files changed, 39 insertions(+), 39 deletions(-) diff --git a/tests/e2e/grpc_control_api/create.rs b/tests/e2e/grpc_control_api/create.rs index 2267b308f..e0710cc3f 100644 --- a/tests/e2e/grpc_control_api/create.rs +++ b/tests/e2e/grpc_control_api/create.rs @@ -34,19 +34,19 @@ mod room { &insert_str!("ws://127.0.0.1:8080/{}/responder/test") ); - let mut get_resp = client.get(&insert_str!("local://{}")); + let mut get_resp = client.get(&insert_str!("{}")); let room = get_resp.take_room(); let responder = room .get_pipeline() - .get(&insert_str!("local://{}/responder")) + .get(&insert_str!("{}/responder")) .unwrap() .get_member(); assert_eq!(responder.get_credentials(), "test"); let responder_pipeline = responder.get_pipeline(); assert_eq!(responder_pipeline.len(), 1); let responder_play = responder_pipeline - .get(&insert_str!("local://{}/responder/play")) + .get(&insert_str!("{}/responder/play")) .unwrap() .get_webrtc_play(); assert_eq!( @@ -56,7 +56,7 @@ mod room { let publisher = room .get_pipeline() - .get(&insert_str!("local://{}/publisher")) + .get(&insert_str!("{}/publisher")) .unwrap() .get_member(); assert_ne!(publisher.get_credentials(), "test"); @@ -72,7 +72,7 @@ mod room { let client = ControlClient::new(); let create_room = RoomBuilder::default() - .id(insert_str!("local://{}")) + .id(insert_str!("{}")) .build() .unwrap() .into(); @@ -93,7 +93,7 @@ mod room { let client = ControlClient::new(); let create_room = RoomBuilder::default() - .id(insert_str!("local://qwerty/{}")) + .id(insert_str!("qwerty/{}")) .build() .unwrap() .into(); @@ -129,7 +129,7 @@ mod member { ) .build() .unwrap() - .build_request(insert_str!("local://{}/test-member")); + .build_request(insert_str!("{}/test-member")); let sids = client.create(&add_member); let e2e_test_member_sid = @@ -140,7 +140,7 @@ mod member { ); let member = client - .get(&insert_str!("local://{}/test-member")) + .get(&insert_str!("{}/test-member")) .take_member(); assert_eq!(member.get_pipeline().len(), 1); assert_eq!(member.get_credentials(), "qwerty"); @@ -156,7 +156,7 @@ mod member { .id("caller") .build() .unwrap() - .build_request(insert_str!("local://{}/member")); + .build_request(insert_str!("{}/member")); if let Err(err) = client.try_create(&create_member) { assert_eq!(err.code, ErrorCode::RoomNotFound as u32) @@ -172,7 +172,7 @@ mod member { let client = ControlClient::new(); let create_room = RoomBuilder::default() - .id(insert_str!("local://{}")) + .id(insert_str!("{}")) .build() .unwrap() .into(); @@ -183,7 +183,7 @@ mod member { .id("caller") .build() .unwrap() - .build_request(insert_str!("local://{}/member")); + .build_request(insert_str!("{}/member")); client.create(&create_member); @@ -228,13 +228,13 @@ mod endpoint { .p2p_mode(WebRtcPublishEndpoint_P2P::NEVER) .build() .unwrap() - .build_request(insert_str!("local://{}/responder/publish")); + .build_request(insert_str!("{}/responder/publish")); let sids = client.create(&create_req); assert_eq!(sids.len(), 0); let endpoint = client - .get(&insert_str!("local://{}/responder/publish")) + .get(&insert_str!("{}/responder/publish")) .take_webrtc_pub(); assert_eq!(endpoint.get_p2p(), WebRtcPublishEndpoint_P2P::NEVER); } @@ -246,7 +246,7 @@ mod endpoint { let client = ControlClient::new(); let create_room = RoomBuilder::default() - .id(insert_str!("local://{}")) + .id(insert_str!("{}")) .build() .unwrap() .into(); @@ -258,7 +258,7 @@ mod endpoint { .p2p_mode(WebRtcPublishEndpoint_P2P::ALWAYS) .build() .unwrap() - .build_request(insert_str!("local://{}/member/publish")); + .build_request(insert_str!("{}/member/publish")); if let Err(err) = client.try_create(&create_play) { assert_eq!(err.code, ErrorCode::MemberNotFound as u32) @@ -278,7 +278,7 @@ mod endpoint { .p2p_mode(WebRtcPublishEndpoint_P2P::ALWAYS) .build() .unwrap() - .build_request(insert_str!("local://{}/member/publish")); + .build_request(insert_str!("{}/member/publish")); if let Err(err) = client.try_create(&create_publish) { assert_eq!(err.code, ErrorCode::RoomNotFound as u32) @@ -294,7 +294,7 @@ mod endpoint { let client = ControlClient::new(); let create_room = RoomBuilder::default() - .id(insert_str!("local://{}")) + .id(insert_str!("{}")) .add_member(MemberBuilder::default().id("member").build().unwrap()) .build() .unwrap() @@ -307,7 +307,7 @@ mod endpoint { .p2p_mode(WebRtcPublishEndpoint_P2P::ALWAYS) .build() .unwrap() - .build_request(insert_str!("local://{}/member/publish")); + .build_request(insert_str!("{}/member/publish")); client.create(&create_endpoint); @@ -327,7 +327,7 @@ mod endpoint { let client = ControlClient::new(); let create_room = RoomBuilder::default() - .id(insert_str!("local://{}")) + .id(insert_str!("{}")) .add_member(MemberBuilder::default().id("member").build().unwrap()) .build() .unwrap() @@ -340,7 +340,7 @@ mod endpoint { .src(insert_str!("local://{}/member/publish")) .build() .unwrap() - .build_request(insert_str!("local://{}/member/play")); + .build_request(insert_str!("{}/member/play")); if let Err(err) = client.try_create(&create_endpoint) { assert_eq!(err.code, ErrorCode::EndpointNotFound as u32) @@ -358,7 +358,7 @@ mod endpoint { .p2p_mode(WebRtcPublishEndpoint_P2P::ALWAYS) .build() .unwrap() - .build_request("local://qwe"); + .build_request("qwe"); if let Err(err) = client.try_create(&create_endpoint) { assert_eq!(err.code, ErrorCode::ElementIdMismatch as u32) diff --git a/tests/e2e/grpc_control_api/delete.rs b/tests/e2e/grpc_control_api/delete.rs index e9a8da9fa..138f0d01c 100644 --- a/tests/e2e/grpc_control_api/delete.rs +++ b/tests/e2e/grpc_control_api/delete.rs @@ -52,7 +52,7 @@ fn room() { gen_insert_str_macro!("delete-room"); test_for_delete( &insert_str!("{}"), - &insert_str!("local://{}"), + &insert_str!("{}"), ErrorCode::RoomNotFound, ); } @@ -62,7 +62,7 @@ fn member() { gen_insert_str_macro!("delete-member"); test_for_delete( &insert_str!("{}"), - &insert_str!("local://{}/publisher"), + &insert_str!("{}/publisher"), ErrorCode::MemberNotFound, ); } @@ -72,7 +72,7 @@ fn endpoint() { gen_insert_str_macro!("delete-endpoint"); test_for_delete( &insert_str!("{}"), - &insert_str!("local://{}/publisher/publish"), + &insert_str!("{}/publisher/publish"), ErrorCode::EndpointNotFound, ); } @@ -120,11 +120,11 @@ fn cascade_delete_endpoints_when_deleting_member() { test_cascade_delete( &insert_str!("{}"), &[ - &insert_str!("local://{}/publisher"), - &insert_str!("local://{}/publisher/publish"), + &insert_str!("{}/publisher"), + &insert_str!("{}/publisher/publish"), ], MedeaErrorCode::MemberNotFound, - &insert_str!("local://{}/publisher"), + &insert_str!("{}/publisher"), ); } @@ -135,12 +135,12 @@ fn cascade_delete_everything_when_deleting_room() { test_cascade_delete( &insert_str!("{}"), &[ - &insert_str!("local://{}"), - &insert_str!("local://{}/publisher"), - &insert_str!("local://{}/publisher/publish"), + &insert_str!("{}"), + &insert_str!("{}/publisher"), + &insert_str!("{}/publisher/publish"), ], MedeaErrorCode::RoomNotFound, - &insert_str!("local://{}"), + &insert_str!("{}"), ); } @@ -149,7 +149,7 @@ fn cant_delete_members_from_different_rooms_in_single_request() { let client = ControlClient::new(); if let Err(err) = - client.delete(&["local://room1/member1", "local://room2/member1"]) + client.delete(&["room1/member1", "room2/member1"]) { assert_eq!(err.code, MedeaErrorCode::ProvidedNotSameRoomIds as u32); } else { @@ -162,8 +162,8 @@ fn cant_delete_endpoints_from_different_rooms_in_single_request() { let client = ControlClient::new(); if let Err(err) = client.delete(&[ - "local://room1/member1/endpoint1", - "local://room2/member1/endpoint1", + "room1/member1/endpoint1", + "room2/member1/endpoint1", ]) { assert_eq!(err.code, MedeaErrorCode::ProvidedNotSameRoomIds as u32); } else { diff --git a/tests/e2e/grpc_control_api/mod.rs b/tests/e2e/grpc_control_api/mod.rs index 747e30e59..251f0f554 100644 --- a/tests/e2e/grpc_control_api/mod.rs +++ b/tests/e2e/grpc_control_api/mod.rs @@ -359,7 +359,7 @@ impl Into for WebRtcPublishEndpoint { /// ``` fn create_room_req(room_id: &str) -> CreateRequest { RoomBuilder::default() - .id(format!("local://{}", room_id)) + .id(format!("{}", room_id)) .add_member( MemberBuilder::default() .id("publisher") diff --git a/tests/e2e/grpc_control_api/signaling.rs b/tests/e2e/grpc_control_api/signaling.rs index 288095494..79ee6c730 100644 --- a/tests/e2e/grpc_control_api/signaling.rs +++ b/tests/e2e/grpc_control_api/signaling.rs @@ -27,7 +27,7 @@ fn signalling_starts_when_create_play_member_after_pub_member() { let control_client = ControlClient::new(); let create_room = RoomBuilder::default() - .id(insert_str!("local://{}")) + .id(insert_str!("{}")) .add_member( MemberBuilder::default() .id("publisher") @@ -81,7 +81,7 @@ fn signalling_starts_when_create_play_member_after_pub_member() { ) .build() .unwrap() - .build_request(insert_str!("local://{}/responder")); + .build_request(insert_str!("{}/responder")); control_client.create(&create_play_member); TestMember::connect( @@ -106,7 +106,7 @@ fn peers_removed_on_delete_member() { let control_client = ControlClient::new(); let create_room = RoomBuilder::default() - .id(insert_str!("local://{}")) + .id(insert_str!("{}")) .add_member( MemberBuilder::default() .id("publisher") @@ -149,7 +149,7 @@ fn peers_removed_on_delete_member() { peers_created.set(peers_created.get() + 1); if peers_created.get() == 2 { control_client - .delete(&[&insert_str!("local://{}/responder")]) + .delete(&[&insert_str!("{}/responder")]) .unwrap(); } } From 1d19dbd0fb5bcacab9e7ff88461c64782d36f8d8 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 15 Oct 2019 17:32:38 +0300 Subject: [PATCH 708/735] Use fids in protobuf, update tests, impl create room with fid --- proto/control-api/src/grpc/api.proto | 30 +- proto/control-api/src/grpc/api.rs | 433 +++++++++++++++++------- src/api/control/grpc/server.rs | 74 ++-- src/api/control/refs/fid.rs | 10 +- src/api/control/room.rs | 25 +- src/bin/client.rs | 32 +- tests/e2e/grpc_control_api/create.rs | 22 +- tests/e2e/grpc_control_api/delete.rs | 11 +- tests/e2e/grpc_control_api/mod.rs | 51 +-- tests/e2e/grpc_control_api/signaling.rs | 4 +- 10 files changed, 448 insertions(+), 244 deletions(-) diff --git a/proto/control-api/src/grpc/api.proto b/proto/control-api/src/grpc/api.proto index 23308c004..ad4fa95c0 100644 --- a/proto/control-api/src/grpc/api.proto +++ b/proto/control-api/src/grpc/api.proto @@ -26,7 +26,7 @@ service ControlApi { // Request of creating new Element with a given ID. message CreateRequest { // ID of the Element to be created.. - string id = 1; + string parent_fid = 1; // Spec of the created Element. oneof el { Member member = 2; @@ -39,7 +39,7 @@ message CreateRequest { // Request with many Elements IDs. message IdRequest { // List of Elements IDs. - repeated string id = 1; + repeated string fid = 1; } // Response which doesn't return anything on successful result, @@ -112,8 +112,9 @@ message Element { // Media element which represents a single space where multiple Members can // interact with each other. message Room { + string id = 1; // Pipeline of this Room. - map pipeline = 1; + map pipeline = 2; // Elements which Room's pipeline can contain. message Element { @@ -128,16 +129,17 @@ message Room { // Media element which represents a client authorized to participate // in a some bigger media pipeline. message Member { + string id = 1; // Callback which fires when the Member establishes persistent connection // with a media server via Client API. - string on_join = 1; + string on_join = 2; // Callback which fires when the Member finishes persistent connection // with a media server via Client API. - string on_leave = 2; + string on_leave = 3; // Credentials of the Member to authorize via Client API with. - string credentials = 3; + string credentials = 4; // Pipeline of this Member. - map pipeline = 4; + map pipeline = 5; // Elements which Member's pipeline can contain. message Element { @@ -151,12 +153,13 @@ message Member { // Media element which is able to receive media data from a client via WebRTC // (allows to publish media data). message WebRtcPublishEndpoint { + string id = 1; // P2P mode for this element. - P2P p2p = 1; + P2P p2p = 2; // Callback which fires when a client starts publishing media data. - string on_start = 2; + string on_start = 3; // Callback which fires when a client stops publishing media data. - string on_stop = 3; + string on_stop = 4; // P2P mode of WebRTC interaction. enum P2P { @@ -172,12 +175,13 @@ message WebRtcPublishEndpoint { // Media element which is able to play media data for a client via WebRTC. message WebRtcPlayEndpoint { + string id = 1; // The source to get media data from. - string src = 1; + string src = 2; // Callback which fires when a client starts playing media data // from the source. - string on_start = 2; + string on_start = 3; // Callback which fires when a client stops playing media data // from the source. - string on_stop = 3; + string on_stop = 4; } diff --git a/proto/control-api/src/grpc/api.rs b/proto/control-api/src/grpc/api.rs index 1988f92d5..ba225e60a 100644 --- a/proto/control-api/src/grpc/api.rs +++ b/proto/control-api/src/grpc/api.rs @@ -29,7 +29,7 @@ const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_8_1; #[derive(PartialEq,Clone,Default)] pub struct CreateRequest { // message fields - pub id: ::std::string::String, + pub parent_fid: ::std::string::String, // message oneof groups pub el: ::std::option::Option, // special fields @@ -56,30 +56,30 @@ impl CreateRequest { ::std::default::Default::default() } - // string id = 1; + // string parent_fid = 1; - pub fn get_id(&self) -> &str { - &self.id + pub fn get_parent_fid(&self) -> &str { + &self.parent_fid } - pub fn clear_id(&mut self) { - self.id.clear(); + pub fn clear_parent_fid(&mut self) { + self.parent_fid.clear(); } // Param is passed by value, moved - pub fn set_id(&mut self, v: ::std::string::String) { - self.id = v; + pub fn set_parent_fid(&mut self, v: ::std::string::String) { + self.parent_fid = v; } // Mutable pointer to the field. // If field is not initialized, it is initialized with default value first. - pub fn mut_id(&mut self) -> &mut ::std::string::String { - &mut self.id + pub fn mut_parent_fid(&mut self) -> &mut ::std::string::String { + &mut self.parent_fid } // Take field - pub fn take_id(&mut self) -> ::std::string::String { - ::std::mem::replace(&mut self.id, ::std::string::String::new()) + pub fn take_parent_fid(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.parent_fid, ::std::string::String::new()) } // .medea.Member member = 2; @@ -309,7 +309,7 @@ impl ::protobuf::Message for CreateRequest { let (field_number, wire_type) = is.read_tag_unpack()?; match field_number { 1 => { - ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.id)?; + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.parent_fid)?; }, 2 => { if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { @@ -347,8 +347,8 @@ impl ::protobuf::Message for CreateRequest { #[allow(unused_variables)] fn compute_size(&self) -> u32 { let mut my_size = 0; - if !self.id.is_empty() { - my_size += ::protobuf::rt::string_size(1, &self.id); + if !self.parent_fid.is_empty() { + my_size += ::protobuf::rt::string_size(1, &self.parent_fid); } if let ::std::option::Option::Some(ref v) = self.el { match v { @@ -376,8 +376,8 @@ impl ::protobuf::Message for CreateRequest { } fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { - if !self.id.is_empty() { - os.write_string(1, &self.id)?; + if !self.parent_fid.is_empty() { + os.write_string(1, &self.parent_fid)?; } if let ::std::option::Option::Some(ref v) = self.el { match v { @@ -446,9 +446,9 @@ impl ::protobuf::Message for CreateRequest { descriptor.get(|| { let mut fields = ::std::vec::Vec::new(); fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "id", - |m: &CreateRequest| { &m.id }, - |m: &mut CreateRequest| { &mut m.id }, + "parent_fid", + |m: &CreateRequest| { &m.parent_fid }, + |m: &mut CreateRequest| { &mut m.parent_fid }, )); fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Member>( "member", @@ -492,7 +492,7 @@ impl ::protobuf::Message for CreateRequest { impl ::protobuf::Clear for CreateRequest { fn clear(&mut self) { - self.id.clear(); + self.parent_fid.clear(); self.el = ::std::option::Option::None; self.el = ::std::option::Option::None; self.el = ::std::option::Option::None; @@ -516,7 +516,7 @@ impl ::protobuf::reflect::ProtobufValue for CreateRequest { #[derive(PartialEq,Clone,Default)] pub struct IdRequest { // message fields - pub id: ::protobuf::RepeatedField<::std::string::String>, + pub fid: ::protobuf::RepeatedField<::std::string::String>, // special fields pub unknown_fields: ::protobuf::UnknownFields, pub cached_size: ::protobuf::CachedSize, @@ -533,29 +533,29 @@ impl IdRequest { ::std::default::Default::default() } - // repeated string id = 1; + // repeated string fid = 1; - pub fn get_id(&self) -> &[::std::string::String] { - &self.id + pub fn get_fid(&self) -> &[::std::string::String] { + &self.fid } - pub fn clear_id(&mut self) { - self.id.clear(); + pub fn clear_fid(&mut self) { + self.fid.clear(); } // Param is passed by value, moved - pub fn set_id(&mut self, v: ::protobuf::RepeatedField<::std::string::String>) { - self.id = v; + pub fn set_fid(&mut self, v: ::protobuf::RepeatedField<::std::string::String>) { + self.fid = v; } // Mutable pointer to the field. - pub fn mut_id(&mut self) -> &mut ::protobuf::RepeatedField<::std::string::String> { - &mut self.id + pub fn mut_fid(&mut self) -> &mut ::protobuf::RepeatedField<::std::string::String> { + &mut self.fid } // Take field - pub fn take_id(&mut self) -> ::protobuf::RepeatedField<::std::string::String> { - ::std::mem::replace(&mut self.id, ::protobuf::RepeatedField::new()) + pub fn take_fid(&mut self) -> ::protobuf::RepeatedField<::std::string::String> { + ::std::mem::replace(&mut self.fid, ::protobuf::RepeatedField::new()) } } @@ -569,7 +569,7 @@ impl ::protobuf::Message for IdRequest { let (field_number, wire_type) = is.read_tag_unpack()?; match field_number { 1 => { - ::protobuf::rt::read_repeated_string_into(wire_type, is, &mut self.id)?; + ::protobuf::rt::read_repeated_string_into(wire_type, is, &mut self.fid)?; }, _ => { ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; @@ -583,7 +583,7 @@ impl ::protobuf::Message for IdRequest { #[allow(unused_variables)] fn compute_size(&self) -> u32 { let mut my_size = 0; - for value in &self.id { + for value in &self.fid { my_size += ::protobuf::rt::string_size(1, &value); }; my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); @@ -592,7 +592,7 @@ impl ::protobuf::Message for IdRequest { } fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { - for v in &self.id { + for v in &self.fid { os.write_string(1, &v)?; }; os.write_unknown_fields(self.get_unknown_fields())?; @@ -638,9 +638,9 @@ impl ::protobuf::Message for IdRequest { descriptor.get(|| { let mut fields = ::std::vec::Vec::new(); fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "id", - |m: &IdRequest| { &m.id }, - |m: &mut IdRequest| { &mut m.id }, + "fid", + |m: &IdRequest| { &m.fid }, + |m: &mut IdRequest| { &mut m.fid }, )); ::protobuf::reflect::MessageDescriptor::new::( "IdRequest", @@ -664,7 +664,7 @@ impl ::protobuf::Message for IdRequest { impl ::protobuf::Clear for IdRequest { fn clear(&mut self) { - self.id.clear(); + self.fid.clear(); self.unknown_fields.clear(); } } @@ -2042,6 +2042,7 @@ impl ::protobuf::reflect::ProtobufValue for Element { #[derive(PartialEq,Clone,Default)] pub struct Room { // message fields + pub id: ::std::string::String, pub pipeline: ::std::collections::HashMap<::std::string::String, Room_Element>, // special fields pub unknown_fields: ::protobuf::UnknownFields, @@ -2059,7 +2060,33 @@ impl Room { ::std::default::Default::default() } - // repeated .medea.Room.PipelineEntry pipeline = 1; + // string id = 1; + + + pub fn get_id(&self) -> &str { + &self.id + } + pub fn clear_id(&mut self) { + self.id.clear(); + } + + // Param is passed by value, moved + pub fn set_id(&mut self, v: ::std::string::String) { + self.id = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_id(&mut self) -> &mut ::std::string::String { + &mut self.id + } + + // Take field + pub fn take_id(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.id, ::std::string::String::new()) + } + + // repeated .medea.Room.PipelineEntry pipeline = 2; pub fn get_pipeline(&self) -> &::std::collections::HashMap<::std::string::String, Room_Element> { @@ -2095,6 +2122,9 @@ impl ::protobuf::Message for Room { let (field_number, wire_type) = is.read_tag_unpack()?; match field_number { 1 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.id)?; + }, + 2 => { ::protobuf::rt::read_map_into::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(wire_type, is, &mut self.pipeline)?; }, _ => { @@ -2109,14 +2139,20 @@ impl ::protobuf::Message for Room { #[allow(unused_variables)] fn compute_size(&self) -> u32 { let mut my_size = 0; - my_size += ::protobuf::rt::compute_map_size::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(1, &self.pipeline); + if !self.id.is_empty() { + my_size += ::protobuf::rt::string_size(1, &self.id); + } + my_size += ::protobuf::rt::compute_map_size::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(2, &self.pipeline); my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); self.cached_size.set(my_size); my_size } fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { - ::protobuf::rt::write_map_with_cached_sizes::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(1, &self.pipeline, os)?; + if !self.id.is_empty() { + os.write_string(1, &self.id)?; + } + ::protobuf::rt::write_map_with_cached_sizes::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(2, &self.pipeline, os)?; os.write_unknown_fields(self.get_unknown_fields())?; ::std::result::Result::Ok(()) } @@ -2159,6 +2195,11 @@ impl ::protobuf::Message for Room { unsafe { descriptor.get(|| { let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "id", + |m: &Room| { &m.id }, + |m: &mut Room| { &mut m.id }, + )); fields.push(::protobuf::reflect::accessor::make_map_accessor::<_, ::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>( "pipeline", |m: &Room| { &m.pipeline }, @@ -2186,6 +2227,7 @@ impl ::protobuf::Message for Room { impl ::protobuf::Clear for Room { fn clear(&mut self) { + self.id.clear(); self.pipeline.clear(); self.unknown_fields.clear(); } @@ -2574,6 +2616,7 @@ impl ::protobuf::reflect::ProtobufValue for Room_Element { #[derive(PartialEq,Clone,Default)] pub struct Member { // message fields + pub id: ::std::string::String, pub on_join: ::std::string::String, pub on_leave: ::std::string::String, pub credentials: ::std::string::String, @@ -2594,7 +2637,33 @@ impl Member { ::std::default::Default::default() } - // string on_join = 1; + // string id = 1; + + + pub fn get_id(&self) -> &str { + &self.id + } + pub fn clear_id(&mut self) { + self.id.clear(); + } + + // Param is passed by value, moved + pub fn set_id(&mut self, v: ::std::string::String) { + self.id = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_id(&mut self) -> &mut ::std::string::String { + &mut self.id + } + + // Take field + pub fn take_id(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.id, ::std::string::String::new()) + } + + // string on_join = 2; pub fn get_on_join(&self) -> &str { @@ -2620,7 +2689,7 @@ impl Member { ::std::mem::replace(&mut self.on_join, ::std::string::String::new()) } - // string on_leave = 2; + // string on_leave = 3; pub fn get_on_leave(&self) -> &str { @@ -2646,7 +2715,7 @@ impl Member { ::std::mem::replace(&mut self.on_leave, ::std::string::String::new()) } - // string credentials = 3; + // string credentials = 4; pub fn get_credentials(&self) -> &str { @@ -2672,7 +2741,7 @@ impl Member { ::std::mem::replace(&mut self.credentials, ::std::string::String::new()) } - // repeated .medea.Member.PipelineEntry pipeline = 4; + // repeated .medea.Member.PipelineEntry pipeline = 5; pub fn get_pipeline(&self) -> &::std::collections::HashMap<::std::string::String, Member_Element> { @@ -2708,15 +2777,18 @@ impl ::protobuf::Message for Member { let (field_number, wire_type) = is.read_tag_unpack()?; match field_number { 1 => { - ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.on_join)?; + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.id)?; }, 2 => { - ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.on_leave)?; + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.on_join)?; }, 3 => { - ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.credentials)?; + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.on_leave)?; }, 4 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.credentials)?; + }, + 5 => { ::protobuf::rt::read_map_into::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(wire_type, is, &mut self.pipeline)?; }, _ => { @@ -2731,32 +2803,38 @@ impl ::protobuf::Message for Member { #[allow(unused_variables)] fn compute_size(&self) -> u32 { let mut my_size = 0; + if !self.id.is_empty() { + my_size += ::protobuf::rt::string_size(1, &self.id); + } if !self.on_join.is_empty() { - my_size += ::protobuf::rt::string_size(1, &self.on_join); + my_size += ::protobuf::rt::string_size(2, &self.on_join); } if !self.on_leave.is_empty() { - my_size += ::protobuf::rt::string_size(2, &self.on_leave); + my_size += ::protobuf::rt::string_size(3, &self.on_leave); } if !self.credentials.is_empty() { - my_size += ::protobuf::rt::string_size(3, &self.credentials); + my_size += ::protobuf::rt::string_size(4, &self.credentials); } - my_size += ::protobuf::rt::compute_map_size::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(4, &self.pipeline); + my_size += ::protobuf::rt::compute_map_size::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(5, &self.pipeline); my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); self.cached_size.set(my_size); my_size } fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { + if !self.id.is_empty() { + os.write_string(1, &self.id)?; + } if !self.on_join.is_empty() { - os.write_string(1, &self.on_join)?; + os.write_string(2, &self.on_join)?; } if !self.on_leave.is_empty() { - os.write_string(2, &self.on_leave)?; + os.write_string(3, &self.on_leave)?; } if !self.credentials.is_empty() { - os.write_string(3, &self.credentials)?; + os.write_string(4, &self.credentials)?; } - ::protobuf::rt::write_map_with_cached_sizes::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(4, &self.pipeline, os)?; + ::protobuf::rt::write_map_with_cached_sizes::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(5, &self.pipeline, os)?; os.write_unknown_fields(self.get_unknown_fields())?; ::std::result::Result::Ok(()) } @@ -2799,6 +2877,11 @@ impl ::protobuf::Message for Member { unsafe { descriptor.get(|| { let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "id", + |m: &Member| { &m.id }, + |m: &mut Member| { &mut m.id }, + )); fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( "on_join", |m: &Member| { &m.on_join }, @@ -2841,6 +2924,7 @@ impl ::protobuf::Message for Member { impl ::protobuf::Clear for Member { fn clear(&mut self) { + self.id.clear(); self.on_join.clear(); self.on_leave.clear(); self.credentials.clear(); @@ -3156,6 +3240,7 @@ impl ::protobuf::reflect::ProtobufValue for Member_Element { #[derive(PartialEq,Clone,Default)] pub struct WebRtcPublishEndpoint { // message fields + pub id: ::std::string::String, pub p2p: WebRtcPublishEndpoint_P2P, pub on_start: ::std::string::String, pub on_stop: ::std::string::String, @@ -3175,7 +3260,33 @@ impl WebRtcPublishEndpoint { ::std::default::Default::default() } - // .medea.WebRtcPublishEndpoint.P2P p2p = 1; + // string id = 1; + + + pub fn get_id(&self) -> &str { + &self.id + } + pub fn clear_id(&mut self) { + self.id.clear(); + } + + // Param is passed by value, moved + pub fn set_id(&mut self, v: ::std::string::String) { + self.id = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_id(&mut self) -> &mut ::std::string::String { + &mut self.id + } + + // Take field + pub fn take_id(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.id, ::std::string::String::new()) + } + + // .medea.WebRtcPublishEndpoint.P2P p2p = 2; pub fn get_p2p(&self) -> WebRtcPublishEndpoint_P2P { @@ -3190,7 +3301,7 @@ impl WebRtcPublishEndpoint { self.p2p = v; } - // string on_start = 2; + // string on_start = 3; pub fn get_on_start(&self) -> &str { @@ -3216,7 +3327,7 @@ impl WebRtcPublishEndpoint { ::std::mem::replace(&mut self.on_start, ::std::string::String::new()) } - // string on_stop = 3; + // string on_stop = 4; pub fn get_on_stop(&self) -> &str { @@ -3253,12 +3364,15 @@ impl ::protobuf::Message for WebRtcPublishEndpoint { let (field_number, wire_type) = is.read_tag_unpack()?; match field_number { 1 => { - ::protobuf::rt::read_proto3_enum_with_unknown_fields_into(wire_type, is, &mut self.p2p, 1, &mut self.unknown_fields)? + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.id)?; }, 2 => { - ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.on_start)?; + ::protobuf::rt::read_proto3_enum_with_unknown_fields_into(wire_type, is, &mut self.p2p, 2, &mut self.unknown_fields)? }, 3 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.on_start)?; + }, + 4 => { ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.on_stop)?; }, _ => { @@ -3273,14 +3387,17 @@ impl ::protobuf::Message for WebRtcPublishEndpoint { #[allow(unused_variables)] fn compute_size(&self) -> u32 { let mut my_size = 0; + if !self.id.is_empty() { + my_size += ::protobuf::rt::string_size(1, &self.id); + } if self.p2p != WebRtcPublishEndpoint_P2P::NEVER { - my_size += ::protobuf::rt::enum_size(1, self.p2p); + my_size += ::protobuf::rt::enum_size(2, self.p2p); } if !self.on_start.is_empty() { - my_size += ::protobuf::rt::string_size(2, &self.on_start); + my_size += ::protobuf::rt::string_size(3, &self.on_start); } if !self.on_stop.is_empty() { - my_size += ::protobuf::rt::string_size(3, &self.on_stop); + my_size += ::protobuf::rt::string_size(4, &self.on_stop); } my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); self.cached_size.set(my_size); @@ -3288,14 +3405,17 @@ impl ::protobuf::Message for WebRtcPublishEndpoint { } fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { + if !self.id.is_empty() { + os.write_string(1, &self.id)?; + } if self.p2p != WebRtcPublishEndpoint_P2P::NEVER { - os.write_enum(1, self.p2p.value())?; + os.write_enum(2, self.p2p.value())?; } if !self.on_start.is_empty() { - os.write_string(2, &self.on_start)?; + os.write_string(3, &self.on_start)?; } if !self.on_stop.is_empty() { - os.write_string(3, &self.on_stop)?; + os.write_string(4, &self.on_stop)?; } os.write_unknown_fields(self.get_unknown_fields())?; ::std::result::Result::Ok(()) @@ -3339,6 +3459,11 @@ impl ::protobuf::Message for WebRtcPublishEndpoint { unsafe { descriptor.get(|| { let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "id", + |m: &WebRtcPublishEndpoint| { &m.id }, + |m: &mut WebRtcPublishEndpoint| { &mut m.id }, + )); fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeEnum>( "p2p", |m: &WebRtcPublishEndpoint| { &m.p2p }, @@ -3376,6 +3501,7 @@ impl ::protobuf::Message for WebRtcPublishEndpoint { impl ::protobuf::Clear for WebRtcPublishEndpoint { fn clear(&mut self) { + self.id.clear(); self.p2p = WebRtcPublishEndpoint_P2P::NEVER; self.on_start.clear(); self.on_stop.clear(); @@ -3456,6 +3582,7 @@ impl ::protobuf::reflect::ProtobufValue for WebRtcPublishEndpoint_P2P { #[derive(PartialEq,Clone,Default)] pub struct WebRtcPlayEndpoint { // message fields + pub id: ::std::string::String, pub src: ::std::string::String, pub on_start: ::std::string::String, pub on_stop: ::std::string::String, @@ -3475,7 +3602,33 @@ impl WebRtcPlayEndpoint { ::std::default::Default::default() } - // string src = 1; + // string id = 1; + + + pub fn get_id(&self) -> &str { + &self.id + } + pub fn clear_id(&mut self) { + self.id.clear(); + } + + // Param is passed by value, moved + pub fn set_id(&mut self, v: ::std::string::String) { + self.id = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_id(&mut self) -> &mut ::std::string::String { + &mut self.id + } + + // Take field + pub fn take_id(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.id, ::std::string::String::new()) + } + + // string src = 2; pub fn get_src(&self) -> &str { @@ -3501,7 +3654,7 @@ impl WebRtcPlayEndpoint { ::std::mem::replace(&mut self.src, ::std::string::String::new()) } - // string on_start = 2; + // string on_start = 3; pub fn get_on_start(&self) -> &str { @@ -3527,7 +3680,7 @@ impl WebRtcPlayEndpoint { ::std::mem::replace(&mut self.on_start, ::std::string::String::new()) } - // string on_stop = 3; + // string on_stop = 4; pub fn get_on_stop(&self) -> &str { @@ -3564,12 +3717,15 @@ impl ::protobuf::Message for WebRtcPlayEndpoint { let (field_number, wire_type) = is.read_tag_unpack()?; match field_number { 1 => { - ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.src)?; + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.id)?; }, 2 => { - ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.on_start)?; + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.src)?; }, 3 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.on_start)?; + }, + 4 => { ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.on_stop)?; }, _ => { @@ -3584,14 +3740,17 @@ impl ::protobuf::Message for WebRtcPlayEndpoint { #[allow(unused_variables)] fn compute_size(&self) -> u32 { let mut my_size = 0; + if !self.id.is_empty() { + my_size += ::protobuf::rt::string_size(1, &self.id); + } if !self.src.is_empty() { - my_size += ::protobuf::rt::string_size(1, &self.src); + my_size += ::protobuf::rt::string_size(2, &self.src); } if !self.on_start.is_empty() { - my_size += ::protobuf::rt::string_size(2, &self.on_start); + my_size += ::protobuf::rt::string_size(3, &self.on_start); } if !self.on_stop.is_empty() { - my_size += ::protobuf::rt::string_size(3, &self.on_stop); + my_size += ::protobuf::rt::string_size(4, &self.on_stop); } my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); self.cached_size.set(my_size); @@ -3599,14 +3758,17 @@ impl ::protobuf::Message for WebRtcPlayEndpoint { } fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { + if !self.id.is_empty() { + os.write_string(1, &self.id)?; + } if !self.src.is_empty() { - os.write_string(1, &self.src)?; + os.write_string(2, &self.src)?; } if !self.on_start.is_empty() { - os.write_string(2, &self.on_start)?; + os.write_string(3, &self.on_start)?; } if !self.on_stop.is_empty() { - os.write_string(3, &self.on_stop)?; + os.write_string(4, &self.on_stop)?; } os.write_unknown_fields(self.get_unknown_fields())?; ::std::result::Result::Ok(()) @@ -3650,6 +3812,11 @@ impl ::protobuf::Message for WebRtcPlayEndpoint { unsafe { descriptor.get(|| { let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "id", + |m: &WebRtcPlayEndpoint| { &m.id }, + |m: &mut WebRtcPlayEndpoint| { &mut m.id }, + )); fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( "src", |m: &WebRtcPlayEndpoint| { &m.src }, @@ -3687,6 +3854,7 @@ impl ::protobuf::Message for WebRtcPlayEndpoint { impl ::protobuf::Clear for WebRtcPlayEndpoint { fn clear(&mut self) { + self.id.clear(); self.src.clear(); self.on_start.clear(); self.on_stop.clear(); @@ -3707,57 +3875,60 @@ impl ::protobuf::reflect::ProtobufValue for WebRtcPlayEndpoint { } static file_descriptor_proto_data: &'static [u8] = b"\ - \n\tapi.proto\x12\x05medea\"\xee\x01\n\rCreateRequest\x12\x0e\n\x02id\ - \x18\x01\x20\x01(\tR\x02id\x12'\n\x06member\x18\x02\x20\x01(\x0b2\r.mede\ - a.MemberH\0R\x06member\x12!\n\x04room\x18\x03\x20\x01(\x0b2\x0b.medea.Ro\ - omH\0R\x04room\x12<\n\x0bwebrtc_play\x18\x04\x20\x01(\x0b2\x19.medea.Web\ - RtcPlayEndpointH\0R\nwebrtcPlay\x12=\n\nwebrtc_pub\x18\x05\x20\x01(\x0b2\ - \x1c.medea.WebRtcPublishEndpointH\0R\twebrtcPubB\x04\n\x02el\"\x1b\n\tId\ - Request\x12\x0e\n\x02id\x18\x01\x20\x03(\tR\x02id\".\n\x08Response\x12\"\ - \n\x05error\x18\x01\x20\x01(\x0b2\x0c.medea.ErrorR\x05error\"\x9e\x01\n\ - \x0eCreateResponse\x120\n\x03sid\x18\x01\x20\x03(\x0b2\x1e.medea.CreateR\ - esponse.SidEntryR\x03sid\x12\"\n\x05error\x18\x02\x20\x01(\x0b2\x0c.mede\ - a.ErrorR\x05error\x1a6\n\x08SidEntry\x12\x10\n\x03key\x18\x01\x20\x01(\t\ - R\x03key\x12\x14\n\x05value\x18\x02\x20\x01(\tR\x05value:\x028\x01\"\xbc\ - \x01\n\x0bGetResponse\x12<\n\x08elements\x18\x01\x20\x03(\x0b2\x20.medea\ - .GetResponse.ElementsEntryR\x08elements\x12\"\n\x05error\x18\x02\x20\x01\ - (\x0b2\x0c.medea.ErrorR\x05error\x1aK\n\rElementsEntry\x12\x10\n\x03key\ - \x18\x01\x20\x01(\tR\x03key\x12$\n\x05value\x18\x02\x20\x01(\x0b2\x0e.me\ - dea.ElementR\x05value:\x028\x01\"[\n\x05Error\x12\x12\n\x04code\x18\x01\ - \x20\x01(\rR\x04code\x12\x12\n\x04text\x18\x02\x20\x01(\tR\x04text\x12\ - \x10\n\x03doc\x18\x03\x20\x01(\tR\x03doc\x12\x18\n\x07element\x18\x04\ - \x20\x01(\tR\x07element\"\xd8\x01\n\x07Element\x12'\n\x06member\x18\x01\ - \x20\x01(\x0b2\r.medea.MemberH\0R\x06member\x12!\n\x04room\x18\x02\x20\ - \x01(\x0b2\x0b.medea.RoomH\0R\x04room\x12<\n\x0bwebrtc_play\x18\x03\x20\ - \x01(\x0b2\x19.medea.WebRtcPlayEndpointH\0R\nwebrtcPlay\x12=\n\nwebrtc_p\ - ub\x18\x04\x20\x01(\x0b2\x1c.medea.WebRtcPublishEndpointH\0R\twebrtcPubB\ - \x04\n\x02el\"\xc7\x02\n\x04Room\x125\n\x08pipeline\x18\x01\x20\x03(\x0b\ - 2\x19.medea.Room.PipelineEntryR\x08pipeline\x1aP\n\rPipelineEntry\x12\ - \x10\n\x03key\x18\x01\x20\x01(\tR\x03key\x12)\n\x05value\x18\x02\x20\x01\ - (\x0b2\x13.medea.Room.ElementR\x05value:\x028\x01\x1a\xb5\x01\n\x07Eleme\ - nt\x12'\n\x06member\x18\x01\x20\x01(\x0b2\r.medea.MemberH\0R\x06member\ - \x12<\n\x0bwebrtc_play\x18\x02\x20\x01(\x0b2\x19.medea.WebRtcPlayEndpoin\ - tH\0R\nwebrtcPlay\x12=\n\nwebrtc_pub\x18\x03\x20\x01(\x0b2\x1c.medea.Web\ - RtcPublishEndpointH\0R\twebrtcPubB\x04\n\x02el\"\xfa\x02\n\x06Member\x12\ - \x17\n\x07on_join\x18\x01\x20\x01(\tR\x06onJoin\x12\x19\n\x08on_leave\ - \x18\x02\x20\x01(\tR\x07onLeave\x12\x20\n\x0bcredentials\x18\x03\x20\x01\ - (\tR\x0bcredentials\x127\n\x08pipeline\x18\x04\x20\x03(\x0b2\x1b.medea.M\ - ember.PipelineEntryR\x08pipeline\x1aR\n\rPipelineEntry\x12\x10\n\x03key\ - \x18\x01\x20\x01(\tR\x03key\x12+\n\x05value\x18\x02\x20\x01(\x0b2\x15.me\ - dea.Member.ElementR\x05value:\x028\x01\x1a\x8c\x01\n\x07Element\x12<\n\ - \x0bwebrtc_play\x18\x01\x20\x01(\x0b2\x19.medea.WebRtcPlayEndpointH\0R\n\ - webrtcPlay\x12=\n\nwebrtc_pub\x18\x02\x20\x01(\x0b2\x1c.medea.WebRtcPubl\ - ishEndpointH\0R\twebrtcPubB\x04\n\x02el\"\xae\x01\n\x15WebRtcPublishEndp\ - oint\x122\n\x03p2p\x18\x01\x20\x01(\x0e2\x20.medea.WebRtcPublishEndpoint\ - .P2PR\x03p2p\x12\x19\n\x08on_start\x18\x02\x20\x01(\tR\x07onStart\x12\ - \x17\n\x07on_stop\x18\x03\x20\x01(\tR\x06onStop\"-\n\x03P2P\x12\t\n\x05N\ - EVER\x10\0\x12\x0f\n\x0bIF_POSSIBLE\x10\x01\x12\n\n\x06ALWAYS\x10\x02\"Z\ - \n\x12WebRtcPlayEndpoint\x12\x10\n\x03src\x18\x01\x20\x01(\tR\x03src\x12\ - \x19\n\x08on_start\x18\x02\x20\x01(\tR\x07onStart\x12\x17\n\x07on_stop\ - \x18\x03\x20\x01(\tR\x06onStop2\x9d\x01\n\nControlApi\x125\n\x06Create\ - \x12\x14.medea.CreateRequest\x1a\x15.medea.CreateResponse\x12+\n\x06Dele\ - te\x12\x10.medea.IdRequest\x1a\x0f.medea.Response\x12+\n\x03Get\x12\x10.\ - medea.IdRequest\x1a\x12.medea.GetResponseb\x06proto3\ + \n\tapi.proto\x12\x05medea\"\xfd\x01\n\rCreateRequest\x12\x1d\n\nparent_\ + fid\x18\x01\x20\x01(\tR\tparentFid\x12'\n\x06member\x18\x02\x20\x01(\x0b\ + 2\r.medea.MemberH\0R\x06member\x12!\n\x04room\x18\x03\x20\x01(\x0b2\x0b.\ + medea.RoomH\0R\x04room\x12<\n\x0bwebrtc_play\x18\x04\x20\x01(\x0b2\x19.m\ + edea.WebRtcPlayEndpointH\0R\nwebrtcPlay\x12=\n\nwebrtc_pub\x18\x05\x20\ + \x01(\x0b2\x1c.medea.WebRtcPublishEndpointH\0R\twebrtcPubB\x04\n\x02el\"\ + \x1d\n\tIdRequest\x12\x10\n\x03fid\x18\x01\x20\x03(\tR\x03fid\".\n\x08Re\ + sponse\x12\"\n\x05error\x18\x01\x20\x01(\x0b2\x0c.medea.ErrorR\x05error\ + \"\x9e\x01\n\x0eCreateResponse\x120\n\x03sid\x18\x01\x20\x03(\x0b2\x1e.m\ + edea.CreateResponse.SidEntryR\x03sid\x12\"\n\x05error\x18\x02\x20\x01(\ + \x0b2\x0c.medea.ErrorR\x05error\x1a6\n\x08SidEntry\x12\x10\n\x03key\x18\ + \x01\x20\x01(\tR\x03key\x12\x14\n\x05value\x18\x02\x20\x01(\tR\x05value:\ + \x028\x01\"\xbc\x01\n\x0bGetResponse\x12<\n\x08elements\x18\x01\x20\x03(\ + \x0b2\x20.medea.GetResponse.ElementsEntryR\x08elements\x12\"\n\x05error\ + \x18\x02\x20\x01(\x0b2\x0c.medea.ErrorR\x05error\x1aK\n\rElementsEntry\ + \x12\x10\n\x03key\x18\x01\x20\x01(\tR\x03key\x12$\n\x05value\x18\x02\x20\ + \x01(\x0b2\x0e.medea.ElementR\x05value:\x028\x01\"[\n\x05Error\x12\x12\n\ + \x04code\x18\x01\x20\x01(\rR\x04code\x12\x12\n\x04text\x18\x02\x20\x01(\ + \tR\x04text\x12\x10\n\x03doc\x18\x03\x20\x01(\tR\x03doc\x12\x18\n\x07ele\ + ment\x18\x04\x20\x01(\tR\x07element\"\xd8\x01\n\x07Element\x12'\n\x06mem\ + ber\x18\x01\x20\x01(\x0b2\r.medea.MemberH\0R\x06member\x12!\n\x04room\ + \x18\x02\x20\x01(\x0b2\x0b.medea.RoomH\0R\x04room\x12<\n\x0bwebrtc_play\ + \x18\x03\x20\x01(\x0b2\x19.medea.WebRtcPlayEndpointH\0R\nwebrtcPlay\x12=\ + \n\nwebrtc_pub\x18\x04\x20\x01(\x0b2\x1c.medea.WebRtcPublishEndpointH\0R\ + \twebrtcPubB\x04\n\x02el\"\xd7\x02\n\x04Room\x12\x0e\n\x02id\x18\x01\x20\ + \x01(\tR\x02id\x125\n\x08pipeline\x18\x02\x20\x03(\x0b2\x19.medea.Room.P\ + ipelineEntryR\x08pipeline\x1aP\n\rPipelineEntry\x12\x10\n\x03key\x18\x01\ + \x20\x01(\tR\x03key\x12)\n\x05value\x18\x02\x20\x01(\x0b2\x13.medea.Room\ + .ElementR\x05value:\x028\x01\x1a\xb5\x01\n\x07Element\x12'\n\x06member\ + \x18\x01\x20\x01(\x0b2\r.medea.MemberH\0R\x06member\x12<\n\x0bwebrtc_pla\ + y\x18\x02\x20\x01(\x0b2\x19.medea.WebRtcPlayEndpointH\0R\nwebrtcPlay\x12\ + =\n\nwebrtc_pub\x18\x03\x20\x01(\x0b2\x1c.medea.WebRtcPublishEndpointH\0\ + R\twebrtcPubB\x04\n\x02el\"\x8a\x03\n\x06Member\x12\x0e\n\x02id\x18\x01\ + \x20\x01(\tR\x02id\x12\x17\n\x07on_join\x18\x02\x20\x01(\tR\x06onJoin\ + \x12\x19\n\x08on_leave\x18\x03\x20\x01(\tR\x07onLeave\x12\x20\n\x0bcrede\ + ntials\x18\x04\x20\x01(\tR\x0bcredentials\x127\n\x08pipeline\x18\x05\x20\ + \x03(\x0b2\x1b.medea.Member.PipelineEntryR\x08pipeline\x1aR\n\rPipelineE\ + ntry\x12\x10\n\x03key\x18\x01\x20\x01(\tR\x03key\x12+\n\x05value\x18\x02\ + \x20\x01(\x0b2\x15.medea.Member.ElementR\x05value:\x028\x01\x1a\x8c\x01\ + \n\x07Element\x12<\n\x0bwebrtc_play\x18\x01\x20\x01(\x0b2\x19.medea.WebR\ + tcPlayEndpointH\0R\nwebrtcPlay\x12=\n\nwebrtc_pub\x18\x02\x20\x01(\x0b2\ + \x1c.medea.WebRtcPublishEndpointH\0R\twebrtcPubB\x04\n\x02el\"\xbe\x01\n\ + \x15WebRtcPublishEndpoint\x12\x0e\n\x02id\x18\x01\x20\x01(\tR\x02id\x122\ + \n\x03p2p\x18\x02\x20\x01(\x0e2\x20.medea.WebRtcPublishEndpoint.P2PR\x03\ + p2p\x12\x19\n\x08on_start\x18\x03\x20\x01(\tR\x07onStart\x12\x17\n\x07on\ + _stop\x18\x04\x20\x01(\tR\x06onStop\"-\n\x03P2P\x12\t\n\x05NEVER\x10\0\ + \x12\x0f\n\x0bIF_POSSIBLE\x10\x01\x12\n\n\x06ALWAYS\x10\x02\"j\n\x12WebR\ + tcPlayEndpoint\x12\x0e\n\x02id\x18\x01\x20\x01(\tR\x02id\x12\x10\n\x03sr\ + c\x18\x02\x20\x01(\tR\x03src\x12\x19\n\x08on_start\x18\x03\x20\x01(\tR\ + \x07onStart\x12\x17\n\x07on_stop\x18\x04\x20\x01(\tR\x06onStop2\x9d\x01\ + \n\nControlApi\x125\n\x06Create\x12\x14.medea.CreateRequest\x1a\x15.mede\ + a.CreateResponse\x12+\n\x06Delete\x12\x10.medea.IdRequest\x1a\x0f.medea.\ + Response\x12+\n\x03Get\x12\x10.medea.IdRequest\x1a\x12.medea.GetResponse\ + b\x06proto3\ "; static mut file_descriptor_proto_lazy: ::protobuf::lazy::Lazy<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::lazy::Lazy { diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index b28e2f290..933417149 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -21,7 +21,7 @@ use medea_control_api_proto::grpc::{ use crate::{ api::control::{ - error_codes::{ErrorCode, ErrorResponse}, + error_codes::{ErrorCode, ErrorCode::ElementIdMismatch, ErrorResponse}, refs::{fid::ParseFidError, Fid, StatefulFid, ToEndpoint, ToMember}, EndpointSpec, MemberId, MemberSpec, RoomId, RoomSpec, TryFromElementError, TryFromProtobufError, @@ -165,32 +165,53 @@ impl ControlApiService { &self, mut req: CreateRequest, ) -> Box + Send> { - let uri = match StatefulFid::try_from(req.take_id()) { - Ok(uri) => uri, - Err(e) => { - return Box::new(future::err(e.into())); + // let elem = if let Some(elem) = req.el { + // elem + // } else { + // return Box::new(future::err(ErrorResponse::new( + // ErrorCode::NoElement, + // &uri, + // ))); + // }; + + let (uri, elem) = match StatefulFid::try_from(req.take_parent_fid()) { + Ok(uri) => { + if let Some(elem) = req.el { + (uri, elem) + } else { + return Box::new(future::err(ErrorResponse::new( + ErrorCode::NoElement, + &uri, + ))); + } } - }; - - let elem = if let Some(elem) = req.el { - elem - } else { - return Box::new(future::err(ErrorResponse::new( - ErrorCode::NoElement, - &uri, - ))); + Err(e) => match e { + ParseFidError::Empty => { + let elem = if let Some(elem) = req.el { + elem + } else { + return Box::new(future::err( + ErrorResponse::without_id(ErrorCode::NoElement), + )); + }; + return Box::new( + RoomSpec::try_from(elem) + .map_err(ErrorResponse::from) + .map(|spec| { + self.create_room(spec) + .map_err(ErrorResponse::from) + }) + .into_future() + .and_then(|create_result| create_result), + ); + } + _ => { + return Box::new(future::err(e.into())); + } + }, }; match uri { - StatefulFid::Room(uri) => Box::new( - RoomSpec::try_from((uri.take_room_id(), elem)) - .map_err(ErrorResponse::from) - .map(|spec| { - self.create_room(spec).map_err(ErrorResponse::from) - }) - .into_future() - .and_then(|create_result| create_result), - ), StatefulFid::Member(uri) => Box::new( MemberSpec::try_from((uri.member_id().clone(), elem)) .map_err(ErrorResponse::from) @@ -211,6 +232,9 @@ impl ControlApiService { .into_future() .and_then(|create_result| create_result), ), + StatefulFid::Room(uri) => Box::new(future::err( + ErrorResponse::without_id(ElementIdMismatch), + )), } } @@ -220,7 +244,7 @@ impl ControlApiService { mut req: IdRequest, ) -> impl Future { let mut delete_elements_msg = DeleteElements::new(); - for id in req.take_id().into_iter() { + for id in req.take_fid().into_iter() { match StatefulFid::try_from(id) { Ok(uri) => { delete_elements_msg.add_uri(uri); @@ -255,7 +279,7 @@ impl ControlApiService { ) -> impl Future, Error = ErrorResponse> { let mut uris = Vec::new(); - for id in req.take_id().into_iter() { + for id in req.take_fid().into_iter() { match StatefulFid::try_from(id) { Ok(uri) => { uris.push(uri); diff --git a/src/api/control/refs/fid.rs b/src/api/control/refs/fid.rs index 63b924d59..44756e424 100644 --- a/src/api/control/refs/fid.rs +++ b/src/api/control/refs/fid.rs @@ -1,15 +1,13 @@ use std::{ - convert::TryFrom, + convert::{From, TryFrom}, fmt::{Display, Error, Formatter}, }; use derive_more::{Display, From}; -use crate::impl_uri; +use crate::{api::control::RoomId, impl_uri}; use super::{ToEndpoint, ToMember, ToRoom}; -use crate::api::control::RoomId; -use std::convert::From; #[derive(Display, Debug)] pub enum ParseFidError { @@ -86,6 +84,10 @@ impl TryFrom for StatefulFid { type Error = ParseFidError; fn try_from(value: String) -> Result { + if value.is_empty() { + return Err(ParseFidError::Empty); + } + let mut splitted = value.split('/'); let room_id = if let Some(room_id) = splitted.next() { room_id diff --git a/src/api/control/room.rs b/src/api/control/room.rs index 3adb82f73..cca7366b4 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -52,11 +52,11 @@ pub struct RoomSpec { pub pipeline: Pipeline, } -impl TryFrom<(Id, ElementProto)> for RoomSpec { +impl TryFrom for RoomSpec { type Error = TryFromProtobufError; - fn try_from((id, proto): (Id, ElementProto)) -> Result { - match proto { + fn try_from(proto: ElementProto) -> Result { + let id = match proto { ElementProto::room(mut room) => { let mut pipeline = HashMap::new(); for (id, room_element) in room.take_pipeline() { @@ -70,13 +70,20 @@ impl TryFrom<(Id, ElementProto)> for RoomSpec { } let pipeline = Pipeline::new(pipeline); - Ok(Self { id, pipeline }) + return Ok(Self { + id: room.take_id().into(), + pipeline, + }); } - _ => Err(TryFromProtobufError::ExpectedOtherElement( - String::from("Room"), - id.to_string(), - )), - } + ElementProto::member(mut member) => member.take_id(), + ElementProto::webrtc_pub(mut webrtc_pub) => webrtc_pub.take_id(), + ElementProto::webrtc_play(mut webrtc_play) => webrtc_play.take_id(), + }; + + Err(TryFromProtobufError::ExpectedOtherElement( + String::from("Room"), + id, + )) } } diff --git a/src/bin/client.rs b/src/bin/client.rs index 9eec34e74..1a27189bd 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -67,7 +67,7 @@ fn create_room(client: &ControlApiClient) { room_pipeline.insert("responder".to_string(), responder_member_element); room.set_pipeline(room_pipeline); req.set_room(room); - req.set_id("local://grpc-test".to_string()); + req.set_parent_fid("grpc-test".to_string()); let reply = client.create(&req).expect("create room"); println!("{:?}", reply); @@ -86,7 +86,7 @@ fn create_member(client: &ControlApiClient) { member.set_credentials("test".to_string()); member.set_pipeline(member_pipeline); - create_member_request.set_id("local://grpc-test/player/asdsad".to_string()); + create_member_request.set_parent_fid("grpc-test/player/asdsad".to_string()); create_member_request.set_member(member); let reply = client @@ -100,7 +100,7 @@ fn create_endpoint(client: &ControlApiClient) { let mut endpoint = WebRtcPublishEndpoint::new(); endpoint.set_p2p(WebRtcPublishEndpoint_P2P::ALWAYS); create_endpoint_request - .set_id("local://grpc-test/responder/publish".to_string()); + .set_parent_fid("grpc-test/responder/publish".to_string()); create_endpoint_request.set_webrtc_pub(endpoint); let reply = client @@ -112,10 +112,10 @@ fn create_endpoint(client: &ControlApiClient) { fn delete_room(client: &ControlApiClient) { let mut delete_request = IdRequest::new(); let mut rooms = RepeatedField::new(); - rooms.push("local://video-call-1/caller".to_string()); - rooms.push("local://video-call-1".to_string()); - rooms.push("local://pub-pub-video-call/caller".to_string()); - delete_request.set_id(rooms); + rooms.push("video-call-1/caller".to_string()); + rooms.push("video-call-1".to_string()); + rooms.push("pub-pub-video-call/caller".to_string()); + delete_request.set_fid(rooms); let reply = client.delete(&delete_request).expect("delete room"); println!("{:?}", reply); @@ -124,8 +124,8 @@ fn delete_room(client: &ControlApiClient) { fn delete_endpoint(client: &ControlApiClient) { let mut delete_endpoint_req = IdRequest::new(); let mut endpoints = RepeatedField::new(); - endpoints.push("local://video-call-1/caller/publish".to_string()); - delete_endpoint_req.set_id(endpoints); + endpoints.push("video-call-1/caller/publish".to_string()); + delete_endpoint_req.set_fid(endpoints); let reply = client.delete(&delete_endpoint_req).expect("delete member"); println!("{:?}", reply); @@ -134,8 +134,8 @@ fn delete_endpoint(client: &ControlApiClient) { fn delete_member(client: &ControlApiClient) { let mut delete_member_req = IdRequest::new(); let mut members = RepeatedField::new(); - members.push("local://video-call-1/caller".to_string()); - delete_member_req.set_id(members); + members.push("video-call-1/caller".to_string()); + delete_member_req.set_fid(members); let reply = client.delete(&delete_member_req).expect("delete member"); println!("{:?}", reply); @@ -144,11 +144,11 @@ fn delete_member(client: &ControlApiClient) { fn get_room(client: &ControlApiClient) { let mut get_room_request = IdRequest::new(); let mut room = RepeatedField::new(); - room.push("local://grpc-test".to_string()); - room.push("local://video-call-1/responder".to_string()); - room.push("local://grpc-test/publisher/publish".to_string()); - room.push("local://pub-pub-video-call".to_string()); - get_room_request.set_id(room); + room.push("grpc-test".to_string()); + room.push("video-call-1/responder".to_string()); + room.push("grpc-test/publisher/publish".to_string()); + room.push("pub-pub-video-call".to_string()); + get_room_request.set_fid(room); let reply = client.get(&get_room_request).expect("get room"); println!("{:#?}", reply); diff --git a/tests/e2e/grpc_control_api/create.rs b/tests/e2e/grpc_control_api/create.rs index e0710cc3f..48ed4c936 100644 --- a/tests/e2e/grpc_control_api/create.rs +++ b/tests/e2e/grpc_control_api/create.rs @@ -75,7 +75,7 @@ mod room { .id(insert_str!("{}")) .build() .unwrap() - .into(); + .build_request(""); client.create(&create_room); @@ -88,15 +88,15 @@ mod room { #[test] fn element_id_mismatch() { - gen_insert_str_macro!("cant_create_rooms_with_non_top_level_uri"); + gen_insert_str_macro!("element_id_mismatch"); let client = ControlClient::new(); let create_room = RoomBuilder::default() - .id(insert_str!("qwerty/{}")) + .id(insert_str!("{}")) .build() .unwrap() - .into(); + .build_request(insert_str!("{}")); if let Err(err) = client.try_create(&create_room) { assert_eq!(err.code, ErrorCode::ElementIdMismatch as u32) @@ -139,9 +139,7 @@ mod member { insert_str!("ws://127.0.0.1:8080/{}/test-member/qwerty") ); - let member = client - .get(&insert_str!("{}/test-member")) - .take_member(); + let member = client.get(&insert_str!("{}/test-member")).take_member(); assert_eq!(member.get_pipeline().len(), 1); assert_eq!(member.get_credentials(), "qwerty"); } @@ -175,7 +173,7 @@ mod member { .id(insert_str!("{}")) .build() .unwrap() - .into(); + .build_request(""); client.create(&create_room); @@ -202,7 +200,7 @@ mod member { .id("asd") .build() .unwrap() - .build_request("local://qwe"); + .build_request("qwe"); if let Err(err) = client.try_create(&create_member) { assert_eq!(err.code, ErrorCode::ElementIdMismatch as u32) @@ -249,7 +247,7 @@ mod endpoint { .id(insert_str!("{}")) .build() .unwrap() - .into(); + .build_request(""); client.create(&create_room); @@ -298,7 +296,7 @@ mod endpoint { .add_member(MemberBuilder::default().id("member").build().unwrap()) .build() .unwrap() - .into(); + .build_request(""); client.create(&create_room); @@ -331,7 +329,7 @@ mod endpoint { .add_member(MemberBuilder::default().id("member").build().unwrap()) .build() .unwrap() - .into(); + .build_request(""); client.create(&create_room); diff --git a/tests/e2e/grpc_control_api/delete.rs b/tests/e2e/grpc_control_api/delete.rs index 138f0d01c..c6479d67c 100644 --- a/tests/e2e/grpc_control_api/delete.rs +++ b/tests/e2e/grpc_control_api/delete.rs @@ -148,9 +148,7 @@ fn cascade_delete_everything_when_deleting_room() { fn cant_delete_members_from_different_rooms_in_single_request() { let client = ControlClient::new(); - if let Err(err) = - client.delete(&["room1/member1", "room2/member1"]) - { + if let Err(err) = client.delete(&["room1/member1", "room2/member1"]) { assert_eq!(err.code, MedeaErrorCode::ProvidedNotSameRoomIds as u32); } else { panic!("should err") @@ -161,10 +159,9 @@ fn cant_delete_members_from_different_rooms_in_single_request() { fn cant_delete_endpoints_from_different_rooms_in_single_request() { let client = ControlClient::new(); - if let Err(err) = client.delete(&[ - "room1/member1/endpoint1", - "room2/member1/endpoint1", - ]) { + if let Err(err) = + client.delete(&["room1/member1/endpoint1", "room2/member1/endpoint1"]) + { assert_eq!(err.code, MedeaErrorCode::ProvidedNotSameRoomIds as u32); } else { panic!("should err") diff --git a/tests/e2e/grpc_control_api/mod.rs b/tests/e2e/grpc_control_api/mod.rs index 251f0f554..cdcf0bcc7 100644 --- a/tests/e2e/grpc_control_api/mod.rs +++ b/tests/e2e/grpc_control_api/mod.rs @@ -53,7 +53,7 @@ impl ControlClient { let mut get_room_request = IdRequest::new(); let mut room = RepeatedField::new(); room.push(uri.to_string()); - get_room_request.set_id(room); + get_room_request.set_fid(room); let mut resp = self.0.get(&get_room_request).unwrap(); if resp.has_error() { @@ -71,7 +71,7 @@ impl ControlClient { let mut get_room_request = IdRequest::new(); let mut room = RepeatedField::new(); room.push(uri.to_string()); - get_room_request.set_id(room); + get_room_request.set_fid(room); let mut resp = self.0.get(&get_room_request).unwrap(); if resp.has_error() { @@ -123,7 +123,7 @@ impl ControlClient { let mut delete_req = IdRequest::new(); let mut delete_ids = RepeatedField::new(); ids.iter().for_each(|id| delete_ids.push(id.to_string())); - delete_req.set_id(delete_ids); + delete_req.set_fid(delete_ids); let mut resp = self.0.delete(&delete_req).unwrap(); if resp.has_error() { @@ -143,41 +143,42 @@ pub struct Room { members: HashMap, } -impl RoomBuilder { - fn add_member>(&mut self, member: T) -> &mut Self { - let member = member.into(); - - self.members - .get_or_insert(HashMap::new()) - .insert(member.id.clone(), member); - - self - } -} - -impl From for CreateRequest { - fn from(room: Room) -> Self { - let mut request = Self::default(); +impl Room { + pub fn build_request>(self, uri: T) -> CreateRequest { + let mut request = CreateRequest::default(); let mut grpc_room = GrpcRoom::new(); let mut members = HashMap::new(); - for (id, member) in room.members { + for (id, member) in self.members { let mut room_element = Room_Element::new(); room_element.set_member(member.into()); members.insert(id, room_element); } + grpc_room.set_id(self.id); grpc_room.set_pipeline(members); - request.set_id(room.id); + request.set_parent_fid(uri.into()); request.set_room(grpc_room); request } } +impl RoomBuilder { + fn add_member>(&mut self, member: T) -> &mut Self { + let member = member.into(); + + self.members + .get_or_insert(HashMap::new()) + .insert(member.id.clone(), member); + + self + } +} + #[derive(Builder, Clone)] #[builder(setter(into))] pub struct Member { @@ -213,7 +214,7 @@ impl Member { fn build_request>(self, url: T) -> CreateRequest { let mut request = CreateRequest::default(); - request.set_id(url.into()); + request.set_parent_fid(url.into()); request.set_member(self.into()); request @@ -274,7 +275,7 @@ impl WebRtcPlayEndpoint { fn build_request>(self, url: T) -> CreateRequest { let mut request = CreateRequest::default(); - request.set_id(url.into()); + request.set_parent_fid(url.into()); request.set_webrtc_play(self.into()); request @@ -307,7 +308,7 @@ impl WebRtcPublishEndpoint { fn build_request>(self, url: T) -> CreateRequest { let mut request = CreateRequest::default(); - request.set_id(url.into()); + request.set_parent_fid(url.into()); request.set_webrtc_pub(self.into()); request @@ -359,7 +360,7 @@ impl Into for WebRtcPublishEndpoint { /// ``` fn create_room_req(room_id: &str) -> CreateRequest { RoomBuilder::default() - .id(format!("{}", room_id)) + .id(room_id.to_string()) .add_member( MemberBuilder::default() .id("publisher") @@ -389,5 +390,5 @@ fn create_room_req(room_id: &str) -> CreateRequest { ) .build() .unwrap() - .into() + .build_request(String::new()) } diff --git a/tests/e2e/grpc_control_api/signaling.rs b/tests/e2e/grpc_control_api/signaling.rs index 79ee6c730..1ab157746 100644 --- a/tests/e2e/grpc_control_api/signaling.rs +++ b/tests/e2e/grpc_control_api/signaling.rs @@ -44,7 +44,7 @@ fn signalling_starts_when_create_play_member_after_pub_member() { ) .build() .unwrap() - .into(); + .build_request(""); control_client.create(&create_room); @@ -137,7 +137,7 @@ fn peers_removed_on_delete_member() { ) .build() .unwrap() - .into(); + .build_request(""); control_client.create(&create_room); From 5a014c599b22f2db21986374a7b8300de38dcf20 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 15 Oct 2019 19:09:52 +0300 Subject: [PATCH 709/735] Update create logic, upd tests --- src/api/control/grpc/server.rs | 108 +++++++++++++++--------- src/api/control/member.rs | 56 ++++++------ src/signalling/room_service.rs | 16 ++-- tests/e2e/grpc_control_api/create.rs | 20 ++--- tests/e2e/grpc_control_api/mod.rs | 3 + tests/e2e/grpc_control_api/signaling.rs | 4 +- 6 files changed, 123 insertions(+), 84 deletions(-) diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index 933417149..c40b85fea 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -13,17 +13,20 @@ use futures::future::{self, Either, Future, IntoFuture}; use grpcio::{Environment, RpcContext, Server, ServerBuilder, UnarySink}; use medea_control_api_proto::grpc::{ api::{ - CreateRequest, CreateResponse, Element, GetResponse, IdRequest, - Response, + CreateRequest, CreateRequest_oneof_el as CreateRequestOneof, + CreateResponse, Element, GetResponse, IdRequest, Response, }, api_grpc::{create_control_api, ControlApi}, }; use crate::{ api::control::{ + endpoints::{WebRtcPlayEndpoint, WebRtcPublishEndpoint}, error_codes::{ErrorCode, ErrorCode::ElementIdMismatch, ErrorResponse}, - refs::{fid::ParseFidError, Fid, StatefulFid, ToEndpoint, ToMember}, - EndpointSpec, MemberId, MemberSpec, RoomId, RoomSpec, + refs::{ + fid::ParseFidError, Fid, StatefulFid, ToEndpoint, ToMember, ToRoom, + }, + EndpointId, EndpointSpec, MemberId, MemberSpec, RoomId, RoomSpec, TryFromElementError, TryFromProtobufError, }, log::prelude::*, @@ -34,6 +37,8 @@ use crate::{ }, AppContext, }; +use std::convert::From; +use crate::api::control::error_codes::ErrorCode::ElementIdIsTooLong; /// Errors which can happen while processing requests to gRPC [Control API]. /// @@ -132,16 +137,16 @@ impl ControlApiService { /// Implementation of `Create` method for [`Member`] element. fn create_member( &self, - uri: Fid, + id: MemberId, + uri: Fid, spec: MemberSpec, ) -> impl Future { - let sid = - self.get_sid(uri.room_id(), uri.member_id(), spec.credentials()); + let sid = self.get_sid(uri.room_id(), &id, spec.credentials()); let mut sids = HashMap::new(); - sids.insert(uri.member_id().to_string(), sid); + sids.insert(id.to_string(), sid); self.room_service - .send(CreateMemberInRoom { uri, spec }) + .send(CreateMemberInRoom { id, uri, spec }) .map_err(GrpcControlApiError::RoomServiceMailboxError) .and_then(|r| r.map_err(GrpcControlApiError::from).map(|_| sids)) } @@ -149,11 +154,12 @@ impl ControlApiService { /// Implementation of `Create` method for [`Endpoint`] element. fn create_endpoint( &self, - uri: Fid, + id: EndpointId, + uri: Fid, spec: EndpointSpec, ) -> impl Future { self.room_service - .send(CreateEndpointInRoom { uri, spec }) + .send(CreateEndpointInRoom { id, uri, spec }) .map_err(GrpcControlApiError::RoomServiceMailboxError) .and_then(|r| { r.map_err(GrpcControlApiError::from).map(|_| HashMap::new()) @@ -161,19 +167,11 @@ impl ControlApiService { } /// Creates element based on provided [`CreateRequest`]. + // TODO: REFACTOR ME PLEASE pub fn create_element( &self, mut req: CreateRequest, ) -> Box + Send> { - // let elem = if let Some(elem) = req.el { - // elem - // } else { - // return Box::new(future::err(ErrorResponse::new( - // ErrorCode::NoElement, - // &uri, - // ))); - // }; - let (uri, elem) = match StatefulFid::try_from(req.take_parent_fid()) { Ok(uri) => { if let Some(elem) = req.el { @@ -212,28 +210,56 @@ impl ControlApiService { }; match uri { - StatefulFid::Member(uri) => Box::new( - MemberSpec::try_from((uri.member_id().clone(), elem)) - .map_err(ErrorResponse::from) - .map(|spec| { - self.create_member(uri, spec) - .map_err(ErrorResponse::from) - }) - .into_future() - .and_then(|create_result| create_result), - ), - StatefulFid::Endpoint(uri) => Box::new( - EndpointSpec::try_from((uri.endpoint_id().clone(), elem)) - .map_err(ErrorResponse::from) - .map(|spec| { - self.create_endpoint(uri, spec) + StatefulFid::Room(uri) => match elem { + CreateRequestOneof::member(mut member) => { + let id: MemberId = member.take_id().into(); + Box::new( + MemberSpec::try_from((id.clone(), member)) .map_err(ErrorResponse::from) - }) - .into_future() - .and_then(|create_result| create_result), - ), - StatefulFid::Room(uri) => Box::new(future::err( - ErrorResponse::without_id(ElementIdMismatch), + .map(|spec| { + self.create_member(id, uri, spec) + .map_err(ErrorResponse::from) + }) + .into_future() + .and_then(|create_result| create_result), + ) + } + _ => Box::new(future::err(ErrorResponse::without_id( + ElementIdMismatch, + ))), + }, + StatefulFid::Member(uri) => { + let (endpoint, id) = match elem { + CreateRequestOneof::webrtc_play(mut play) => ( + WebRtcPlayEndpoint::try_from(&play) + .map(|r| EndpointSpec::WebRtcPlay(r)), + play.take_id().into(), + ), + CreateRequestOneof::webrtc_pub(mut publish) => ( + Ok(WebRtcPublishEndpoint::from(&publish)) + .map(|r| EndpointSpec::WebRtcPublish(r)), + publish.take_id().into(), + ), + _ => { + return Box::new(future::err( + ErrorResponse::without_id(ElementIdMismatch), + )) + } + }; + Box::new( + endpoint + .map_err(ErrorResponse::from) + .map(move |spec| { + self.create_endpoint(id, uri, spec) + .map_err(ErrorResponse::from) + }) + .into_future() + .and_then(|create_res| create_res), + ) + } + StatefulFid::Endpoint(uri) => Box::new(future::err( + // TODO: changeme + ErrorResponse::without_id(ElementIdIsTooLong), )), } } diff --git a/src/api/control/member.rs b/src/api/control/member.rs index d2a80bc7f..3330952fc 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -6,7 +6,7 @@ use std::{collections::HashMap, convert::TryFrom}; use derive_more::{Display, From}; use medea_control_api_proto::grpc::api::{ - CreateRequest_oneof_el as ElementProto, + CreateRequest_oneof_el as ElementProto, Member as MemberProto, Room_Element_oneof_el as RoomElementProto, }; use rand::{distributions::Alphanumeric, Rng}; @@ -128,6 +128,35 @@ fn generate_member_credentials() -> String { .collect() } +impl TryFrom<(Id, MemberProto)> for MemberSpec { + type Error = TryFromProtobufError; + + fn try_from( + (id, mut member): (Id, MemberProto), + ) -> Result { + let mut pipeline = HashMap::new(); + for (id, member_element) in member.take_pipeline() { + if let Some(elem) = member_element.el { + let endpoint = + EndpointSpec::try_from((EndpointId(id.clone()), elem))?; + pipeline.insert(id.into(), endpoint.into()); + } else { + return Err(TryFromProtobufError::EmptyElement(id)); + } + } + + let mut credentials = member.take_credentials(); + if credentials.is_empty() { + credentials = generate_member_credentials(); + } + + Ok(Self { + pipeline: Pipeline::new(pipeline), + credentials, + }) + } +} + macro_rules! impl_try_from_proto_for_member { ($proto:tt) => { impl TryFrom<(Id, $proto)> for MemberSpec { @@ -138,30 +167,7 @@ macro_rules! impl_try_from_proto_for_member { ) -> Result { match proto { $proto::member(mut member) => { - let mut pipeline = HashMap::new(); - for (id, member_element) in member.take_pipeline() { - if let Some(elem) = member_element.el { - let endpoint = EndpointSpec::try_from(( - EndpointId(id.clone()), - elem, - ))?; - pipeline.insert(id.into(), endpoint.into()); - } else { - return Err( - TryFromProtobufError::EmptyElement(id), - ); - } - } - - let mut credentials = member.take_credentials(); - if credentials.is_empty() { - credentials = generate_member_credentials(); - } - - Ok(Self { - pipeline: Pipeline::new(pipeline), - credentials, - }) + MemberSpec::try_from((id, member)) } _ => Err(TryFromProtobufError::ExpectedOtherElement( String::from("Member"), diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index 2155a7f3f..0ae5f9c48 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -15,7 +15,8 @@ use crate::{ endpoints::EndpointSpec, load_static_specs_from_dir, refs::{Fid, StatefulFid, ToEndpoint, ToMember, ToRoom}, - LoadStaticControlSpecsError, MemberSpec, RoomId, RoomSpec, + EndpointId, LoadStaticControlSpecsError, MemberId, MemberSpec, RoomId, + RoomSpec, }, log::prelude::*, shutdown::{self, GracefulShutdown}, @@ -248,7 +249,8 @@ impl Handler for RoomService { #[derive(Message)] #[rtype(result = "Result<(), RoomServiceError>")] pub struct CreateMemberInRoom { - pub uri: Fid, + pub id: MemberId, + pub uri: Fid, pub spec: MemberSpec, } @@ -260,11 +262,11 @@ impl Handler for RoomService { msg: CreateMemberInRoom, _: &mut Self::Context, ) -> Self::Result { - let (room_id, member_id) = msg.uri.take_all(); + let room_id = msg.uri.take_room_id(); if let Some(room) = self.room_repo.get(&room_id) { Box::new( - room.send(CreateMember(member_id, msg.spec)) + room.send(CreateMember(msg.id, msg.spec)) .map_err(RoomServiceError::RoomMailboxErr) .and_then(|r| r.map_err(RoomServiceError::from)), ) @@ -281,7 +283,8 @@ impl Handler for RoomService { #[derive(Message)] #[rtype(result = "Result<(), RoomServiceError>")] pub struct CreateEndpointInRoom { - pub uri: Fid, + pub id: EndpointId, + pub uri: Fid, pub spec: EndpointSpec, } @@ -293,7 +296,8 @@ impl Handler for RoomService { msg: CreateEndpointInRoom, _: &mut Self::Context, ) -> Self::Result { - let (room_id, member_id, endpoint_id) = msg.uri.take_all(); + let (room_id, member_id) = msg.uri.take_all(); + let endpoint_id = msg.id; if let Some(room) = self.room_repo.get(&room_id) { Box::new( diff --git a/tests/e2e/grpc_control_api/create.rs b/tests/e2e/grpc_control_api/create.rs index 48ed4c936..6d691a3d9 100644 --- a/tests/e2e/grpc_control_api/create.rs +++ b/tests/e2e/grpc_control_api/create.rs @@ -118,7 +118,7 @@ mod member { client.create(&create_room_req(&insert_str!("{}"))); let add_member = MemberBuilder::default() - .id("member") + .id("test-member") .credentials("qwerty") .add_endpoint( WebRtcPlayEndpointBuilder::default() @@ -129,7 +129,7 @@ mod member { ) .build() .unwrap() - .build_request(insert_str!("{}/test-member")); + .build_request(insert_str!("{}")); let sids = client.create(&add_member); let e2e_test_member_sid = @@ -154,7 +154,7 @@ mod member { .id("caller") .build() .unwrap() - .build_request(insert_str!("{}/member")); + .build_request(insert_str!("{}")); if let Err(err) = client.try_create(&create_member) { assert_eq!(err.code, ErrorCode::RoomNotFound as u32) @@ -181,7 +181,7 @@ mod member { .id("caller") .build() .unwrap() - .build_request(insert_str!("{}/member")); + .build_request(insert_str!("{}")); client.create(&create_member); @@ -200,7 +200,7 @@ mod member { .id("asd") .build() .unwrap() - .build_request("qwe"); + .build_request("qwe/qwe"); if let Err(err) = client.try_create(&create_member) { assert_eq!(err.code, ErrorCode::ElementIdMismatch as u32) @@ -226,7 +226,7 @@ mod endpoint { .p2p_mode(WebRtcPublishEndpoint_P2P::NEVER) .build() .unwrap() - .build_request(insert_str!("{}/responder/publish")); + .build_request(insert_str!("{}/responder")); let sids = client.create(&create_req); assert_eq!(sids.len(), 0); @@ -256,7 +256,7 @@ mod endpoint { .p2p_mode(WebRtcPublishEndpoint_P2P::ALWAYS) .build() .unwrap() - .build_request(insert_str!("{}/member/publish")); + .build_request(insert_str!("{}/member")); if let Err(err) = client.try_create(&create_play) { assert_eq!(err.code, ErrorCode::MemberNotFound as u32) @@ -276,7 +276,7 @@ mod endpoint { .p2p_mode(WebRtcPublishEndpoint_P2P::ALWAYS) .build() .unwrap() - .build_request(insert_str!("{}/member/publish")); + .build_request(insert_str!("{}/member")); if let Err(err) = client.try_create(&create_publish) { assert_eq!(err.code, ErrorCode::RoomNotFound as u32) @@ -305,7 +305,7 @@ mod endpoint { .p2p_mode(WebRtcPublishEndpoint_P2P::ALWAYS) .build() .unwrap() - .build_request(insert_str!("{}/member/publish")); + .build_request(insert_str!("{}/member")); client.create(&create_endpoint); @@ -338,7 +338,7 @@ mod endpoint { .src(insert_str!("local://{}/member/publish")) .build() .unwrap() - .build_request(insert_str!("{}/member/play")); + .build_request(insert_str!("{}/member")); if let Err(err) = client.try_create(&create_endpoint) { assert_eq!(err.code, ErrorCode::EndpointNotFound as u32) diff --git a/tests/e2e/grpc_control_api/mod.rs b/tests/e2e/grpc_control_api/mod.rs index cdcf0bcc7..01accab98 100644 --- a/tests/e2e/grpc_control_api/mod.rs +++ b/tests/e2e/grpc_control_api/mod.rs @@ -205,6 +205,7 @@ impl Into for Member { } grpc_member.set_pipeline(pipeline); + grpc_member.set_id(self.id); grpc_member } @@ -286,6 +287,7 @@ impl Into for WebRtcPlayEndpoint { fn into(self) -> GrpcWebRtcPlayEndpoint { let mut endpoint = GrpcWebRtcPlayEndpoint::new(); endpoint.set_src(self.src); + endpoint.set_id(self.id); endpoint } @@ -319,6 +321,7 @@ impl Into for WebRtcPublishEndpoint { fn into(self) -> GrpcWebRtcPublishEndpoint { let mut endpoint = GrpcWebRtcPublishEndpoint::new(); endpoint.set_p2p(self.p2p_mode); + endpoint.set_id(self.id); endpoint } diff --git a/tests/e2e/grpc_control_api/signaling.rs b/tests/e2e/grpc_control_api/signaling.rs index 1ab157746..d8ecafc37 100644 --- a/tests/e2e/grpc_control_api/signaling.rs +++ b/tests/e2e/grpc_control_api/signaling.rs @@ -70,7 +70,7 @@ fn signalling_starts_when_create_play_member_after_pub_member() { ) .and_then(move |_| { let create_play_member = MemberBuilder::default() - .id("play") + .id("responder") .credentials("qwerty") .add_endpoint( WebRtcPlayEndpointBuilder::default() @@ -81,7 +81,7 @@ fn signalling_starts_when_create_play_member_after_pub_member() { ) .build() .unwrap() - .build_request(insert_str!("{}/responder")); + .build_request(insert_str!("{}")); control_client.create(&create_play_member); TestMember::connect( From 146a75ee2afad88e3d8fc48c0b06c5bb1a2d65f5 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 15 Oct 2019 19:30:55 +0300 Subject: [PATCH 710/735] Fix lints, warns --- src/api/control/grpc/server.rs | 26 +++++++++++++------------- src/api/control/member.rs | 10 +++------- src/api/control/refs/fid.rs | 3 ++- src/api/control/refs/mod.rs | 2 ++ src/bin/client.rs | 9 +++++---- src/signalling/room_service.rs | 2 +- 6 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index c40b85fea..77015f388 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -22,10 +22,12 @@ use medea_control_api_proto::grpc::{ use crate::{ api::control::{ endpoints::{WebRtcPlayEndpoint, WebRtcPublishEndpoint}, - error_codes::{ErrorCode, ErrorCode::ElementIdMismatch, ErrorResponse}, - refs::{ - fid::ParseFidError, Fid, StatefulFid, ToEndpoint, ToMember, ToRoom, + error_codes::{ + ErrorCode, + ErrorCode::{ElementIdIsTooLong, ElementIdMismatch}, + ErrorResponse, }, + refs::{fid::ParseFidError, Fid, StatefulFid, ToMember, ToRoom}, EndpointId, EndpointSpec, MemberId, MemberSpec, RoomId, RoomSpec, TryFromElementError, TryFromProtobufError, }, @@ -38,7 +40,6 @@ use crate::{ AppContext, }; use std::convert::From; -use crate::api::control::error_codes::ErrorCode::ElementIdIsTooLong; /// Errors which can happen while processing requests to gRPC [Control API]. /// @@ -183,8 +184,8 @@ impl ControlApiService { ))); } } - Err(e) => match e { - ParseFidError::Empty => { + Err(e) => { + if let ParseFidError::Empty = e { let elem = if let Some(elem) = req.el { elem } else { @@ -202,11 +203,10 @@ impl ControlApiService { .into_future() .and_then(|create_result| create_result), ); - } - _ => { + } else { return Box::new(future::err(e.into())); } - }, + } }; match uri { @@ -214,7 +214,7 @@ impl ControlApiService { CreateRequestOneof::member(mut member) => { let id: MemberId = member.take_id().into(); Box::new( - MemberSpec::try_from((id.clone(), member)) + MemberSpec::try_from(member) .map_err(ErrorResponse::from) .map(|spec| { self.create_member(id, uri, spec) @@ -232,12 +232,12 @@ impl ControlApiService { let (endpoint, id) = match elem { CreateRequestOneof::webrtc_play(mut play) => ( WebRtcPlayEndpoint::try_from(&play) - .map(|r| EndpointSpec::WebRtcPlay(r)), + .map(EndpointSpec::WebRtcPlay), play.take_id().into(), ), CreateRequestOneof::webrtc_pub(mut publish) => ( Ok(WebRtcPublishEndpoint::from(&publish)) - .map(|r| EndpointSpec::WebRtcPublish(r)), + .map(EndpointSpec::WebRtcPublish), publish.take_id().into(), ), _ => { @@ -257,7 +257,7 @@ impl ControlApiService { .and_then(|create_res| create_res), ) } - StatefulFid::Endpoint(uri) => Box::new(future::err( + StatefulFid::Endpoint(_) => Box::new(future::err( // TODO: changeme ErrorResponse::without_id(ElementIdIsTooLong), )), diff --git a/src/api/control/member.rs b/src/api/control/member.rs index 3330952fc..16ff55061 100644 --- a/src/api/control/member.rs +++ b/src/api/control/member.rs @@ -128,12 +128,10 @@ fn generate_member_credentials() -> String { .collect() } -impl TryFrom<(Id, MemberProto)> for MemberSpec { +impl TryFrom for MemberSpec { type Error = TryFromProtobufError; - fn try_from( - (id, mut member): (Id, MemberProto), - ) -> Result { + fn try_from(mut member: MemberProto) -> Result { let mut pipeline = HashMap::new(); for (id, member_element) in member.take_pipeline() { if let Some(elem) = member_element.el { @@ -166,9 +164,7 @@ macro_rules! impl_try_from_proto_for_member { (id, proto): (Id, $proto), ) -> Result { match proto { - $proto::member(mut member) => { - MemberSpec::try_from((id, member)) - } + $proto::member(member) => Self::try_from(member), _ => Err(TryFromProtobufError::ExpectedOtherElement( String::from("Member"), id.to_string(), diff --git a/src/api/control/refs/fid.rs b/src/api/control/refs/fid.rs index 44756e424..25153b52f 100644 --- a/src/api/control/refs/fid.rs +++ b/src/api/control/refs/fid.rs @@ -60,6 +60,7 @@ impl Display for Fid { } } +#[allow(clippy::module_name_repetitions)] #[derive(Debug, Hash, PartialEq, Eq, Clone, Display, From)] pub enum StatefulFid { Room(Fid), @@ -111,7 +112,7 @@ impl TryFrom for StatefulFid { .into()); }; - if let Some(_) = splitted.next() { + if splitted.next().is_some() { Err(ParseFidError::TooManyPaths(value)) } else { Ok(Fid::::new( diff --git a/src/api/control/refs/mod.rs b/src/api/control/refs/mod.rs index fbfbd4644..4cd07b842 100644 --- a/src/api/control/refs/mod.rs +++ b/src/api/control/refs/mod.rs @@ -1,3 +1,5 @@ +#![allow(clippy::use_self)] + pub mod fid; pub mod local_uri; diff --git a/src/bin/client.rs b/src/bin/client.rs index 1a27189bd..d3b1255aa 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -66,8 +66,8 @@ fn create_room(client: &ControlApiClient) { room_pipeline.insert("publisher".to_string(), publisher_member_element); room_pipeline.insert("responder".to_string(), responder_member_element); room.set_pipeline(room_pipeline); + room.set_id("grpc-test".to_string()); req.set_room(room); - req.set_parent_fid("grpc-test".to_string()); let reply = client.create(&req).expect("create room"); println!("{:?}", reply); @@ -86,7 +86,8 @@ fn create_member(client: &ControlApiClient) { member.set_credentials("test".to_string()); member.set_pipeline(member_pipeline); - create_member_request.set_parent_fid("grpc-test/player/asdsad".to_string()); + member.set_id("player".to_string()); + create_member_request.set_parent_fid("grpc-test".to_string()); create_member_request.set_member(member); let reply = client @@ -99,8 +100,8 @@ fn create_endpoint(client: &ControlApiClient) { let mut create_endpoint_request = CreateRequest::new(); let mut endpoint = WebRtcPublishEndpoint::new(); endpoint.set_p2p(WebRtcPublishEndpoint_P2P::ALWAYS); - create_endpoint_request - .set_parent_fid("grpc-test/responder/publish".to_string()); + endpoint.set_id("publish".to_string()); + create_endpoint_request.set_parent_fid("grpc-test/responder".to_string()); create_endpoint_request.set_webrtc_pub(endpoint); let reply = client diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index 0ae5f9c48..4f55829cb 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -14,7 +14,7 @@ use crate::{ api::control::{ endpoints::EndpointSpec, load_static_specs_from_dir, - refs::{Fid, StatefulFid, ToEndpoint, ToMember, ToRoom}, + refs::{Fid, StatefulFid, ToMember, ToRoom}, EndpointId, LoadStaticControlSpecsError, MemberId, MemberSpec, RoomId, RoomSpec, }, From 10357d0bcb23910f52b4406a594d7b82794e44a0 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 15 Oct 2019 19:58:14 +0300 Subject: [PATCH 711/735] Some docs --- src/api/control/refs/fid.rs | 5 +++++ src/api/control/refs/mod.rs | 3 +++ src/signalling/room_service.rs | 14 ++------------ 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/api/control/refs/fid.rs b/src/api/control/refs/fid.rs index 25153b52f..c934e0577 100644 --- a/src/api/control/refs/fid.rs +++ b/src/api/control/refs/fid.rs @@ -1,3 +1,5 @@ +/// Implementation of Full ID (`fid` in dynamic Control API specs). + use std::{ convert::{From, TryFrom}, fmt::{Display, Error, Formatter}, @@ -9,6 +11,7 @@ use crate::{api::control::RoomId, impl_uri}; use super::{ToEndpoint, ToMember, ToRoom}; +/// Errors which can happen while parsing [`Fid`]. #[derive(Display, Debug)] pub enum ParseFidError { #[display(fmt = "Fid is empty.")] @@ -18,6 +21,7 @@ pub enum ParseFidError { TooManyPaths(String), } +/// Full ID (`fid` in dynamic Control API specs). #[derive(Clone, Debug, Eq, Hash, PartialEq)] pub struct Fid { state: T, @@ -60,6 +64,7 @@ impl Display for Fid { } } +/// Enum for storing [`Fid`]s in all states. #[allow(clippy::module_name_repetitions)] #[derive(Debug, Hash, PartialEq, Eq, Clone, Display, From)] pub enum StatefulFid { diff --git a/src/api/control/refs/mod.rs b/src/api/control/refs/mod.rs index 4cd07b842..86d79b0ad 100644 --- a/src/api/control/refs/mod.rs +++ b/src/api/control/refs/mod.rs @@ -1,3 +1,5 @@ +//! Implementation of all kinds of references to some resource used in Medea's Control API specs. + #![allow(clippy::use_self)] pub mod fid; @@ -5,6 +7,7 @@ pub mod local_uri; use super::{EndpointId, MemberId, RoomId}; +#[doc(inline)] pub use self::{ fid::{Fid, StatefulFid}, local_uri::{LocalUri, StatefulLocalUri}, diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index 4f55829cb..cc740af42 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -154,16 +154,6 @@ impl Actor for RoomService { type Context = Context; } -// TODO: is this needed?? -// maybe Fid::::new()?? -/// Returns [`Fid`] pointing to [`Room`]. -/// -/// __Note__ this function don't check presence of [`Room`] in this -/// [`RoomService`]. -fn get_fid_to_room(room_id: RoomId) -> Fid { - Fid::::new(room_id) -} - /// Signal for load all static specs and start [`Room`]s. #[derive(Message)] #[rtype(result = "Result<(), RoomServiceError>")] @@ -182,7 +172,7 @@ impl Handler for RoomService { for spec in room_specs { if self.room_repo.contains_room_with_id(spec.id()) { return Err(RoomServiceError::RoomAlreadyExists( - get_fid_to_room(spec.id), + Fid::::new(spec.id), )); } @@ -222,7 +212,7 @@ impl Handler for RoomService { let room_spec = msg.spec; if self.room_repo.get(&room_spec.id).is_some() { - return Err(RoomServiceError::RoomAlreadyExists(get_fid_to_room( + return Err(RoomServiceError::RoomAlreadyExists(Fid::::new( room_spec.id, ))); } From c17a8a9e955f09102eaeff7a4c3566f2e4d472c7 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Tue, 15 Oct 2019 20:20:23 +0300 Subject: [PATCH 712/735] Fix some unit tests --- src/signalling/room_service.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index cc740af42..41d9dc453 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -556,6 +556,7 @@ mod room_service_specs { use crate::{ api::control::{ endpoints::webrtc_publish_endpoint::P2pMode, RootElement, + refs::{ToEndpoint, Fid}, }, conf::Conf, }; @@ -638,7 +639,7 @@ mod room_service_specs { let room_service = room_service(RoomRepository::new(HashMap::new())); let spec = room_spec(); let caller_uri = StatefulFid::try_from( - "local://pub-sub-video-call/caller".to_string(), + "pub-sub-video-call/caller".to_string(), ) .unwrap(); @@ -672,12 +673,14 @@ mod room_service_specs { ))); let member_uri = - Fid::::new(room_id, "test-member".to_string().into()); - let stateful_member_uri: Fid = member_uri.clone().into(); + Fid::::new(room_id); + let member_id: MemberId = "test-member".to_string().into(); + let stateful_member_uri: StatefulFid = member_uri.clone().push_member_id(member_id.clone()).into(); actix::spawn(test_for_create!( room_service, CreateMemberInRoom { + id: member_id, spec: member_spec, uri: member_uri, }, @@ -712,16 +715,16 @@ mod room_service_specs { room_id.clone() => Room::new(&spec, &app_ctx()).unwrap().start(), ))); - let endpoint_uri = Fid::::new( + let endpoint_uri = Fid::::new( room_id, "caller".to_string().into(), - "test-publish".to_string().into(), ); - let stateful_endpoint_uri: Fid = endpoint_uri.clone().into(); + let stateful_endpoint_uri: StatefulFid = endpoint_uri.clone().into(); actix::spawn(test_for_create!( room_service, CreateEndpointInRoom { + id: "test-publish".to_string().into(), spec: endpoint_spec, uri: endpoint_uri, }, From d57a443f0e011209c593ea6b90f93b18ac07ccb9 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 16 Oct 2019 12:03:28 +0300 Subject: [PATCH 713/735] Fix all tests --- src/api/control/refs/fid.rs | 1 - src/api/control/refs/local_uri.rs | 8 +++++-- src/api/control/refs/mod.rs | 3 ++- src/signalling/room_service.rs | 38 +++++++++++++++---------------- 4 files changed, 26 insertions(+), 24 deletions(-) diff --git a/src/api/control/refs/fid.rs b/src/api/control/refs/fid.rs index c934e0577..d4c681b3f 100644 --- a/src/api/control/refs/fid.rs +++ b/src/api/control/refs/fid.rs @@ -1,5 +1,4 @@ /// Implementation of Full ID (`fid` in dynamic Control API specs). - use std::{ convert::{From, TryFrom}, fmt::{Display, Error, Formatter}, diff --git a/src/api/control/refs/local_uri.rs b/src/api/control/refs/local_uri.rs index e31471d7b..6c1421abf 100644 --- a/src/api/control/refs/local_uri.rs +++ b/src/api/control/refs/local_uri.rs @@ -117,13 +117,17 @@ impl fmt::Display for LocalUri { impl fmt::Display for LocalUri { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "{}/{}", self.state.0, self.state.1) + write!(f, "local://{}/{}", self.state.0, self.state.1) } } impl fmt::Display for LocalUri { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "{}/{}", self.state.0, self.state.1) + write!( + f, + "local://{}/{}/{}", + self.state.0, self.state.1, self.state.2 + ) } } diff --git a/src/api/control/refs/mod.rs b/src/api/control/refs/mod.rs index 86d79b0ad..829dbf254 100644 --- a/src/api/control/refs/mod.rs +++ b/src/api/control/refs/mod.rs @@ -1,4 +1,5 @@ -//! Implementation of all kinds of references to some resource used in Medea's Control API specs. +//! Implementation of all kinds of references to some resource used in Medea's +//! Control API specs. #![allow(clippy::use_self)] diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index 41d9dc453..7a5825f40 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -212,9 +212,9 @@ impl Handler for RoomService { let room_spec = msg.spec; if self.room_repo.get(&room_spec.id).is_some() { - return Err(RoomServiceError::RoomAlreadyExists(Fid::::new( - room_spec.id, - ))); + return Err(RoomServiceError::RoomAlreadyExists( + Fid::::new(room_spec.id), + )); } let room = Room::new(&room_spec, &self.app)?; @@ -510,7 +510,7 @@ mod delete_elements_validation_specs { #[test] fn error_if_not_same_room_ids() { let mut elements = DeleteElements::new(); - ["local://room_id/member", "local://another_room_id/member"] + ["room_id/member", "another_room_id/member"] .iter() .map(|uri| StatefulFid::try_from(uri.to_string()).unwrap()) .for_each(|uri| elements.add_uri(uri)); @@ -537,9 +537,9 @@ mod delete_elements_validation_specs { fn success_if_all_ok() { let mut elements = DeleteElements::new(); [ - "local://room_id/member_id", - "local://room_id/another_member_id", - "local://room_id/member_id/endpoint_id", + "room_id/member_id", + "room_id/another_member_id", + "room_id/member_id/endpoint_id", ] .iter() .map(|uri| StatefulFid::try_from(uri.to_string()).unwrap()) @@ -555,8 +555,9 @@ mod room_service_specs { use crate::{ api::control::{ - endpoints::webrtc_publish_endpoint::P2pMode, RootElement, - refs::{ToEndpoint, Fid}, + endpoints::webrtc_publish_endpoint::P2pMode, + refs::{Fid, ToEndpoint}, + RootElement, }, conf::Conf, }; @@ -638,10 +639,9 @@ mod room_service_specs { let room_service = room_service(RoomRepository::new(HashMap::new())); let spec = room_spec(); - let caller_uri = StatefulFid::try_from( - "pub-sub-video-call/caller".to_string(), - ) - .unwrap(); + let caller_uri = + StatefulFid::try_from("pub-sub-video-call/caller".to_string()) + .unwrap(); actix::spawn(test_for_create!( room_service, @@ -672,10 +672,10 @@ mod room_service_specs { room_id.clone() => Room::new(&spec, &app_ctx()).unwrap().start(), ))); - let member_uri = - Fid::::new(room_id); + let member_uri = Fid::::new(room_id); let member_id: MemberId = "test-member".to_string().into(); - let stateful_member_uri: StatefulFid = member_uri.clone().push_member_id(member_id.clone()).into(); + let stateful_member_uri: StatefulFid = + member_uri.clone().push_member_id(member_id.clone()).into(); actix::spawn(test_for_create!( room_service, @@ -715,10 +715,8 @@ mod room_service_specs { room_id.clone() => Room::new(&spec, &app_ctx()).unwrap().start(), ))); - let endpoint_uri = Fid::::new( - room_id, - "caller".to_string().into(), - ); + let endpoint_uri = + Fid::::new(room_id, "caller".to_string().into()); let stateful_endpoint_uri: StatefulFid = endpoint_uri.clone().into(); actix::spawn(test_for_create!( From 037bc7a0216d7c200230bfbcd09750aa19e5ebb5 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 16 Oct 2019 12:28:06 +0300 Subject: [PATCH 714/735] Refactor --- src/api/control/grpc/server.rs | 38 ++++++++++++++-------------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index 77015f388..101716ba9 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -168,31 +168,26 @@ impl ControlApiService { } /// Creates element based on provided [`CreateRequest`]. - // TODO: REFACTOR ME PLEASE pub fn create_element( &self, mut req: CreateRequest, ) -> Box + Send> { - let (uri, elem) = match StatefulFid::try_from(req.take_parent_fid()) { - Ok(uri) => { - if let Some(elem) = req.el { - (uri, elem) - } else { - return Box::new(future::err(ErrorResponse::new( - ErrorCode::NoElement, - &uri, - ))); - } + let unparsed_parent_fid = req.take_parent_fid(); + let elem = if let Some(elem) = req.el { + elem + } else { + return Box::new(future::err(ErrorResponse::new( + ErrorCode::NoElement, + &unparsed_parent_fid, + ))); + }; + + let parent_fid = match StatefulFid::try_from(unparsed_parent_fid) { + Ok(parent_fid) => { + parent_fid } Err(e) => { if let ParseFidError::Empty = e { - let elem = if let Some(elem) = req.el { - elem - } else { - return Box::new(future::err( - ErrorResponse::without_id(ErrorCode::NoElement), - )); - }; return Box::new( RoomSpec::try_from(elem) .map_err(ErrorResponse::from) @@ -209,7 +204,7 @@ impl ControlApiService { } }; - match uri { + match parent_fid { StatefulFid::Room(uri) => match elem { CreateRequestOneof::member(mut member) => { let id: MemberId = member.take_id().into(); @@ -232,12 +227,12 @@ impl ControlApiService { let (endpoint, id) = match elem { CreateRequestOneof::webrtc_play(mut play) => ( WebRtcPlayEndpoint::try_from(&play) - .map(EndpointSpec::WebRtcPlay), + .map(EndpointSpec::from), play.take_id().into(), ), CreateRequestOneof::webrtc_pub(mut publish) => ( Ok(WebRtcPublishEndpoint::from(&publish)) - .map(EndpointSpec::WebRtcPublish), + .map(EndpointSpec::from), publish.take_id().into(), ), _ => { @@ -258,7 +253,6 @@ impl ControlApiService { ) } StatefulFid::Endpoint(_) => Box::new(future::err( - // TODO: changeme ErrorResponse::without_id(ElementIdIsTooLong), )), } From c43ee08559beaaf50a4ff4b6f74c912eb5d8c7e1 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 16 Oct 2019 13:34:59 +0300 Subject: [PATCH 715/735] Add tests, rename variables as fid --- src/api/control/error_codes.rs | 37 +++++---- src/api/control/grpc/server.rs | 18 +++-- src/api/control/refs/fid.rs | 128 ++++++++++++++++++++++++++++-- src/api/control/refs/local_uri.rs | 20 ++--- src/signalling/elements/member.rs | 12 +-- src/signalling/room.rs | 56 ++++++------- src/signalling/room_service.rs | 117 ++++++++++++++------------- 7 files changed, 259 insertions(+), 129 deletions(-) diff --git a/src/api/control/error_codes.rs b/src/api/control/error_codes.rs index ffbbb6f36..468658a6e 100644 --- a/src/api/control/error_codes.rs +++ b/src/api/control/error_codes.rs @@ -143,10 +143,10 @@ pub enum ErrorCode { #[display(fmt = "Request doesn't contain any elements")] NoElement = 1001, - /// Provided uri can't point to provided element. + /// Provided fid can't point to provided element. /// /// Code: __1002__. - #[display(fmt = "Provided uri can't point to provided element")] + #[display(fmt = "Provided fid can't point to provided element")] ElementIdMismatch = 1002, /// Room not found. @@ -200,10 +200,10 @@ pub enum ErrorCode { #[display(fmt = "Element's URI don't have 'local://' prefix.")] ElementIdIsNotLocal = 1010, - /// Provided element's URI with too many paths. + /// Provided element's FID/URI with too many paths. /// /// Code: __1011__. - #[display(fmt = "You provided element's URI with too many paths.")] + #[display(fmt = "You provided element's FID/URI with too many paths.")] ElementIdIsTooLong = 1011, /// Missing some fields in source URI of WebRtcPublishEndpoint. @@ -217,13 +217,13 @@ pub enum ErrorCode { /// Empty element ID. /// /// Code: __1013__. - #[display(fmt = "Provided empty element URI.")] + #[display(fmt = "Provided empty element ID.")] EmptyElementId = 1013, - /// Provided empty elements URIs list. + /// Provided empty elements FIDs list. /// /// Code: __1014__. - #[display(fmt = "Provided empty elements URIs list.")] + #[display(fmt = "Provided empty elements FIDs list.")] EmptyElementsList = 1014, /// Provided not the same Room IDs in elements IDs. Probably you try use @@ -237,24 +237,30 @@ pub enum ErrorCode { different Room IDs")] ProvidedNotSameRoomIds = 1015, - /// Room with provided URI already exists. + /// Room with provided fid already exists. /// /// Code: __1016__. - #[display(fmt = "Room with provided URI already exists.")] + #[display(fmt = "Room with provided FID already exists.")] RoomAlreadyExists = 1016, - /// Member with provided URI already exists. + /// Member with provided FID already exists. /// /// Code: __1017__. - #[display(fmt = "Member with provided URI already exists.")] + #[display(fmt = "Member with provided FID already exists.")] MemberAlreadyExists = 1017, - /// Endpoint with provided URI already exists. + /// Endpoint with provided FID already exists. /// /// Code: __1018__. - #[display(fmt = "Endpoint with provided URI already exists.")] + #[display(fmt = "Endpoint with provided FID already exists.")] EndpointAlreadyExists = 1018, + /// Missing path in some pointer to the Medea element. + /// + /// Code: __1019__. + #[display(fmt = "Missing path in some pointer to the Medea element.")] + MissingPath = 1019, + /// Unexpected server error. /// /// Use this [`ErrorCode`] only with [`ErrorResponse::unexpected`] @@ -303,7 +309,7 @@ impl From for ErrorResponse { ExpectedOtherElement(element, id) => Self::with_explanation( ErrorCode::ElementIdMismatch, format!( - "Provided uri can not point to element of type [{}]", + "Provided fid can not point to element of type [{}]", element ), Some(id), @@ -344,6 +350,7 @@ impl From for ErrorResponse { Self::new(ErrorCode::ElementIdIsTooLong, &text) } Empty => Self::without_id(ErrorCode::EmptyElementId), + MissingPath(text) => Self::new(ErrorCode::MissingPath, &text), } } } @@ -430,7 +437,7 @@ impl From for ErrorResponse { NotSameRoomIds(id1, id2) => Self::with_explanation( ErrorCode::ProvidedNotSameRoomIds, format!( - "All URI's must have equal room_id. Provided Id's are \ + "All FID's must have equal room_id. Provided Id's are \ different: [{}] != [{}]", id1, id2 ), diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index 101716ba9..ce6288c11 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -147,7 +147,11 @@ impl ControlApiService { sids.insert(id.to_string(), sid); self.room_service - .send(CreateMemberInRoom { id, uri, spec }) + .send(CreateMemberInRoom { + id, + parent_fid: uri, + spec, + }) .map_err(GrpcControlApiError::RoomServiceMailboxError) .and_then(|r| r.map_err(GrpcControlApiError::from).map(|_| sids)) } @@ -160,7 +164,11 @@ impl ControlApiService { spec: EndpointSpec, ) -> impl Future { self.room_service - .send(CreateEndpointInRoom { id, uri, spec }) + .send(CreateEndpointInRoom { + id, + parent_fid: uri, + spec, + }) .map_err(GrpcControlApiError::RoomServiceMailboxError) .and_then(|r| { r.map_err(GrpcControlApiError::from).map(|_| HashMap::new()) @@ -183,9 +191,7 @@ impl ControlApiService { }; let parent_fid = match StatefulFid::try_from(unparsed_parent_fid) { - Ok(parent_fid) => { - parent_fid - } + Ok(parent_fid) => parent_fid, Err(e) => { if let ParseFidError::Empty = e { return Box::new( @@ -267,7 +273,7 @@ impl ControlApiService { for id in req.take_fid().into_iter() { match StatefulFid::try_from(id) { Ok(uri) => { - delete_elements_msg.add_uri(uri); + delete_elements_msg.add_fid(uri); } Err(e) => { return future::Either::A(future::err(e.into())); diff --git a/src/api/control/refs/fid.rs b/src/api/control/refs/fid.rs index d4c681b3f..4db50eda9 100644 --- a/src/api/control/refs/fid.rs +++ b/src/api/control/refs/fid.rs @@ -1,4 +1,5 @@ -/// Implementation of Full ID (`fid` in dynamic Control API specs). +//! Implementation of Full ID (`fid` in dynamic Control API specs). + use std::{ convert::{From, TryFrom}, fmt::{Display, Error, Formatter}, @@ -16,8 +17,11 @@ pub enum ParseFidError { #[display(fmt = "Fid is empty.")] Empty, - #[display(fmt = "Too many paths [id = {}].", _0)] + #[display(fmt = "Too many paths [fid = {}].", _0)] TooManyPaths(String), + + #[display(fmt = "Missing paths [fid = {}]", _0)] + MissingPath(String), } /// Full ID (`fid` in dynamic Control API specs). @@ -95,19 +99,31 @@ impl TryFrom for StatefulFid { let mut splitted = value.split('/'); let room_id = if let Some(room_id) = splitted.next() { - room_id + if room_id.is_empty() { + return Err(ParseFidError::MissingPath(value)); + } else { + room_id + } } else { return Err(ParseFidError::Empty); }; let member_id = if let Some(member_id) = splitted.next() { - member_id + if member_id.is_empty() { + return Err(ParseFidError::MissingPath(value)); + } else { + member_id + } } else { return Ok(Fid::::new(room_id.to_string().into()).into()); }; let endpoint_id = if let Some(endpoint_id) = splitted.next() { - endpoint_id + if endpoint_id.is_empty() { + return Err(ParseFidError::MissingPath(value)); + } else { + endpoint_id + } } else { return Ok(Fid::::new( room_id.to_string().into(), @@ -128,3 +144,105 @@ impl TryFrom for StatefulFid { } } } + +#[cfg(test)] +mod specs { + use crate::api::control::{EndpointId, MemberId}; + + use super::*; + + #[test] + fn returns_error_on_missing_path() { + for fid_str in vec![ + "room_id//endpoint_id", + "//endpoint_id", + "//member_id/endpoint_id", + ] { + match StatefulFid::try_from(fid_str.to_string()) { + Ok(f) => unreachable!("Unexpected successful parse: {}", f), + Err(e) => match e { + ParseFidError::MissingPath(_) => (), + _ => unreachable!("Throwed some unexpected error {:?}.", e), + }, + } + } + } + + #[test] + fn returns_error_on_too_many_paths() { + for fid_str in vec![ + "room_id/member_id/endpoint_id/somethis_else", + "room_id/member_id/endpoint_id/", + "room_id/member_id/endpoint_id////", + ] { + match StatefulFid::try_from(fid_str.to_string()) { + Ok(f) => unreachable!("Unexpected successful parse: {}", f), + Err(e) => match e { + ParseFidError::TooManyPaths(_) => (), + _ => unreachable!("Throwed some unexpected error {:?}.", e), + }, + } + } + } + + #[test] + fn successful_parse_to_room() { + let room_id: RoomId = "room_id".to_string().into(); + let fid = StatefulFid::try_from(format!("{}", room_id)).unwrap(); + match fid { + StatefulFid::Room(room_fid) => { + assert_eq!(room_fid.room_id(), &room_id); + } + _ => unreachable!("Fid parsed not to Room. {}", fid), + } + } + + #[test] + fn successful_parse_to_member() { + let room_id: RoomId = "room_id".to_string().into(); + let member_id: MemberId = "member_id".to_string().into(); + let fid = StatefulFid::try_from(format!("{}/{}", room_id, member_id)) + .unwrap(); + + match fid { + StatefulFid::Member(member_fid) => { + assert_eq!(member_fid.room_id(), &room_id); + assert_eq!(member_fid.member_id(), &member_id); + } + _ => unreachable!("Fid parsed not to Member. {}", fid), + } + } + + #[test] + fn successful_parse_to_endpoint() { + let room_id: RoomId = "room_id".to_string().into(); + let member_id: MemberId = "member_id".to_string().into(); + let endpoint_id: EndpointId = "endpoint_id".to_string().into(); + let fid = StatefulFid::try_from(format!( + "{}/{}/{}", + room_id, member_id, endpoint_id + )) + .unwrap(); + + match fid { + StatefulFid::Endpoint(endpoint_fid) => { + assert_eq!(endpoint_fid.room_id(), &room_id); + assert_eq!(endpoint_fid.member_id(), &member_id); + assert_eq!(endpoint_fid.endpoint_id(), &endpoint_id); + } + _ => unreachable!("Fid parsed not to Member. {}", fid), + } + } + + #[test] + fn serializes_into_origin_fid() { + for fid_str in vec![ + "room_id", + "room_id/member_id", + "room_id/member_id/endpoint_id", + ] { + let fid = StatefulFid::try_from(fid_str.to_string()).unwrap(); + assert_eq!(fid_str.to_string(), fid.to_string()); + } + } +} diff --git a/src/api/control/refs/local_uri.rs b/src/api/control/refs/local_uri.rs index 6c1421abf..0ee7917bc 100644 --- a/src/api/control/refs/local_uri.rs +++ b/src/api/control/refs/local_uri.rs @@ -1,4 +1,4 @@ -//! URI for pointing to some Medea element. +//! URI for pointing to some Medea element in spec. // Fix clippy's wrong errors for `Self` in `LocalUri`s with states as generics. #![allow(clippy::use_self)] @@ -253,7 +253,7 @@ impl TryFrom for StatefulLocalUri { } #[cfg(test)] -mod tests { +mod specs { use super::*; #[test] @@ -352,12 +352,12 @@ mod tests { #[test] fn properly_serialize() { for local_uri_str in vec![ - String::from("local://room_id"), - String::from("local://room_id/member_id"), - String::from("local://room_id/member_id/endpoint_id"), + "local://room_id", + "local://room_id/member_id", + "local://room_id/member_id/endpoint_id", ] { let local_uri = - StatefulLocalUri::try_from(local_uri_str.clone()).unwrap(); + StatefulLocalUri::try_from(local_uri_str.to_string()).unwrap(); assert_eq!(local_uri_str.to_string(), local_uri.to_string()); } } @@ -365,11 +365,11 @@ mod tests { #[test] fn return_error_when_local_uri_not_full() { for local_uri_str in vec![ - String::from("local://room_id//endpoint_id"), - String::from("local:////endpoint_id"), - String::from("local:///member_id/endpoint_id"), + "local://room_id//endpoint_id", + "local:////endpoint_id", + "local:///member_id/endpoint_id", ] { - match StatefulLocalUri::try_from(local_uri_str) { + match StatefulLocalUri::try_from(local_uri_str.to_string()) { Ok(_) => unreachable!(), Err(e) => match e { LocalUriParseError::MissingPaths(_) => (), diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index c3dd827b1..d04f0dd8e 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -235,7 +235,7 @@ impl Member { /// /// __Note__ this function don't check presence of `Endpoint` in this /// [`Member`]. - pub fn get_local_uri_to_endpoint( + pub fn get_fid_to_endpoint( &self, endpoint_id: EndpointId, ) -> Fid { @@ -389,7 +389,7 @@ impl Member { } Err(MemberError::EndpointNotFound( - self.get_local_uri_to_endpoint(webrtc_play_id.into()), + self.get_fid_to_endpoint(webrtc_play_id.into()), )) } @@ -486,13 +486,13 @@ impl Into for Member { let mut member_pipeline = HashMap::new(); for (id, play) in self.sinks() { - let local_uri = self.get_local_uri_to_endpoint(id.into()); - member_pipeline.insert(local_uri.to_string(), play.into()); + let endpoint_fid = self.get_fid_to_endpoint(id.into()); + member_pipeline.insert(endpoint_fid.to_string(), play.into()); } for (id, publish) in self.srcs() { - let local_uri = self.get_local_uri_to_endpoint(id.into()); + let endpoint_fid = self.get_fid_to_endpoint(id.into()); - member_pipeline.insert(local_uri.to_string(), publish.into()); + member_pipeline.insert(endpoint_fid.to_string(), publish.into()); } member.set_pipeline(member_pipeline); diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 4b392de47..cb3d62bff 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -83,7 +83,7 @@ pub enum RoomError { ParticipantServiceErr(ParticipantServiceErr), #[display(fmt = "Client error:{}", _0)] ClientError(String), - #[display(fmt = "Given Fid [uri = {}] to wrong room [id = {}]", _0, _1)] + #[display(fmt = "Given Fid [fid = {}] to wrong Room [id = {}]", _0, _1)] WrongRoomId(StatefulFid, RoomId), /// Try to create [`Member`] with ID which already exists. #[display(fmt = "Member [id = {}] already exists.", _0)] @@ -694,7 +694,7 @@ impl Room { if is_member_have_this_sink_id || is_member_have_this_src_id { return Err(RoomError::EndpointAlreadyExists( - member.get_local_uri_to_endpoint(play_id.into()), + member.get_fid_to_endpoint(play_id.into()), )); } @@ -741,7 +741,7 @@ impl Room { member.get_src_by_id(&publish_id).is_some(); if is_member_have_this_sink_id || is_member_have_this_src_id { return Err(RoomError::EndpointAlreadyExists( - member.get_local_uri_to_endpoint(publish_id.into()), + member.get_fid_to_endpoint(publish_id.into()), )); } @@ -750,7 +750,7 @@ impl Room { .get_src_by_id(&spec.src.endpoint_id) .ok_or_else(|| { MemberError::EndpointNotFound( - partner_member.get_local_uri_to_endpoint( + partner_member.get_fid_to_endpoint( spec.src.endpoint_id.clone().into(), ), ) @@ -819,7 +819,7 @@ impl Room { .get_src_by_id(&play.src.endpoint_id) .ok_or_else(|| { MemberError::EndpointNotFound( - partner_member.get_local_uri_to_endpoint( + partner_member.get_fid_to_endpoint( play.src.endpoint_id.clone().into(), ), ) @@ -867,8 +867,8 @@ impl Into for &mut Room { .members() .into_iter() .map(|(id, member)| { - let local_uri = Fid::::new(self.get_id(), id); - (local_uri.to_string(), member.into()) + let member_fid = Fid::::new(self.get_id(), id); + (member_fid.to_string(), member.into()) }) .collect(); @@ -894,31 +894,31 @@ impl Handler for Room { _: &mut Self::Context, ) -> Self::Result { let mut serialized: HashMap = HashMap::new(); - for uri in msg.0 { - match &uri { - StatefulFid::Room(room_uri) => { - if room_uri.room_id() == &self.id { + for fid in msg.0 { + match &fid { + StatefulFid::Room(room_fid) => { + if room_fid.room_id() == &self.id { let current_room: ElementProto = self.into(); - serialized.insert(uri, current_room); + serialized.insert(fid, current_room); } else { return Err(RoomError::WrongRoomId( - uri, + fid, self.id.clone(), )); } } - StatefulFid::Member(member_uri) => { + StatefulFid::Member(member_fid) => { let member = - self.members.get_member(member_uri.member_id())?; - serialized.insert(uri, member.into()); + self.members.get_member(member_fid.member_id())?; + serialized.insert(fid, member.into()); } - StatefulFid::Endpoint(endpoint_uri) => { + StatefulFid::Endpoint(endpoint_fid) => { let member = - self.members.get_member(endpoint_uri.member_id())?; + self.members.get_member(endpoint_fid.member_id())?; let endpoint = member.get_endpoint_by_id( - endpoint_uri.endpoint_id().to_string(), + endpoint_fid.endpoint_id().to_string(), )?; - serialized.insert(uri, endpoint.into()); + serialized.insert(fid, endpoint.into()); } } } @@ -1118,20 +1118,20 @@ impl Handler for Room { let mut endpoint_ids = Vec::new(); for id in msg.0 { match id { - StatefulFid::Member(member_uri) => { - member_ids.push(member_uri); + StatefulFid::Member(member_fid) => { + member_ids.push(member_fid); } - StatefulFid::Endpoint(endpoint_uri) => { - endpoint_ids.push(endpoint_uri); + StatefulFid::Endpoint(endpoint_fid) => { + endpoint_ids.push(endpoint_fid); } _ => warn!("Found Fid while deleting __from__ Room."), } } - member_ids.into_iter().for_each(|uri| { - self.delete_member(&uri.member_id(), ctx); + member_ids.into_iter().for_each(|fid| { + self.delete_member(&fid.member_id(), ctx); }); - endpoint_ids.into_iter().for_each(|uri| { - let (_, member_id, endpoint_id) = uri.take_all(); + endpoint_ids.into_iter().for_each(|fid| { + let (_, member_id, endpoint_id) = fid.take_all(); self.delete_endpoint(&member_id, endpoint_id, ctx); }); } diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index 7a5825f40..3767e6791 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -240,7 +240,7 @@ impl Handler for RoomService { #[rtype(result = "Result<(), RoomServiceError>")] pub struct CreateMemberInRoom { pub id: MemberId, - pub uri: Fid, + pub parent_fid: Fid, pub spec: MemberSpec, } @@ -252,7 +252,7 @@ impl Handler for RoomService { msg: CreateMemberInRoom, _: &mut Self::Context, ) -> Self::Result { - let room_id = msg.uri.take_room_id(); + let room_id = msg.parent_fid.take_room_id(); if let Some(room) = self.room_repo.get(&room_id) { Box::new( @@ -261,8 +261,8 @@ impl Handler for RoomService { .and_then(|r| r.map_err(RoomServiceError::from)), ) } else { - let room_uri = Fid::::new(room_id); - Box::new(future::err(RoomServiceError::RoomNotFound(room_uri))) + let room_fid = Fid::::new(room_id); + Box::new(future::err(RoomServiceError::RoomNotFound(room_fid))) } } } @@ -274,7 +274,7 @@ impl Handler for RoomService { #[rtype(result = "Result<(), RoomServiceError>")] pub struct CreateEndpointInRoom { pub id: EndpointId, - pub uri: Fid, + pub parent_fid: Fid, pub spec: EndpointSpec, } @@ -286,7 +286,7 @@ impl Handler for RoomService { msg: CreateEndpointInRoom, _: &mut Self::Context, ) -> Self::Result { - let (room_id, member_id) = msg.uri.take_all(); + let (room_id, member_id) = msg.parent_fid.take_all(); let endpoint_id = msg.id; if let Some(room) = self.room_repo.get(&room_id) { @@ -300,8 +300,8 @@ impl Handler for RoomService { .and_then(|r| r.map_err(RoomServiceError::from)), ) } else { - let room_uri = Fid::::new(room_id); - Box::new(future::err(RoomServiceError::RoomNotFound(room_uri))) + let room_fid = Fid::::new(room_id); + Box::new(future::err(RoomServiceError::RoomNotFound(room_fid))) } } } @@ -322,28 +322,28 @@ impl DeleteElements { /// Creates new [`DeleteElements`] in [`Unvalidated`] state. pub fn new() -> Self { Self { - uris: Vec::new(), + fids: Vec::new(), _validation_state: PhantomData, } } /// Adds [`StatefulFid`] to request. - pub fn add_uri(&mut self, uri: StatefulFid) { - self.uris.push(uri) + pub fn add_fid(&mut self, fid: StatefulFid) { + self.fids.push(fid) } - /// Validates request. It must have at least one uri, all uris must share + /// Validates request. It must have at least one fid, all fids must share /// same [`RoomId`]. pub fn validate( self, ) -> Result, RoomServiceError> { - if self.uris.is_empty() { + if self.fids.is_empty() { return Err(RoomServiceError::EmptyUrisList); } - let first_room_id = self.uris[0].room_id(); + let first_room_id = self.fids[0].room_id(); - for id in &self.uris { + for id in &self.fids { if first_room_id != id.room_id() { return Err(RoomServiceError::NotSameRoomIds( first_room_id.clone(), @@ -353,7 +353,7 @@ impl DeleteElements { } Ok(DeleteElements { - uris: self.uris, + fids: self.fids, _validation_state: PhantomData, }) } @@ -376,7 +376,7 @@ impl DeleteElements { #[derive(Message, Default)] #[rtype(result = "Result<(), RoomServiceError>")] pub struct DeleteElements { - uris: Vec, + fids: Vec, _validation_state: PhantomData, } @@ -396,7 +396,7 @@ impl Handler> for RoomService { let room_messages_futs: Vec< Box>, > = msg - .uris + .fids .into_iter() .filter_map(|l| { if let StatefulFid::Room(room_id) = l { @@ -446,17 +446,17 @@ impl Handler for RoomService { fn handle(&mut self, msg: Get, _: &mut Self::Context) -> Self::Result { let mut rooms_elements = HashMap::new(); - for uri in msg.0 { - let room_id = uri.room_id(); + for fid in msg.0 { + let room_id = fid.room_id(); if let Some(room) = self.room_repo.get(room_id) { rooms_elements .entry(room) .or_insert_with(Vec::new) - .push(uri); + .push(fid); } else { return Box::new(future::err(RoomServiceError::RoomNotFound( - uri.into(), + fid.into(), ))); } } @@ -490,7 +490,7 @@ mod delete_elements_validation_specs { use super::*; #[test] - fn empty_uris_list() { + fn empty_fids_list() { let elements = DeleteElements::new(); match elements.validate() { Ok(_) => panic!( @@ -512,8 +512,8 @@ mod delete_elements_validation_specs { let mut elements = DeleteElements::new(); ["room_id/member", "another_room_id/member"] .iter() - .map(|uri| StatefulFid::try_from(uri.to_string()).unwrap()) - .for_each(|uri| elements.add_uri(uri)); + .map(|fid| StatefulFid::try_from(fid.to_string()).unwrap()) + .for_each(|fid| elements.add_fid(fid)); match elements.validate() { Ok(_) => panic!( @@ -542,8 +542,8 @@ mod delete_elements_validation_specs { "room_id/member_id/endpoint_id", ] .iter() - .map(|uri| StatefulFid::try_from(uri.to_string()).unwrap()) - .for_each(|uri| elements.add_uri(uri)); + .map(|fid| StatefulFid::try_from(fid.to_string()).unwrap()) + .for_each(|fid| elements.add_fid(fid)); assert!(elements.validate().is_ok()); } @@ -604,7 +604,7 @@ mod room_service_specs { /// /// `$create_msg` - [`actix::Message`] which will create `Element`, /// - /// `$element_uri` - [`StatefulFid`] to `Element` which you try to + /// `$element_fid` - [`StatefulFid`] to `Element` which you try to /// create, /// /// `$test` - closure in which will be provided created @@ -613,10 +613,10 @@ mod room_service_specs { ( $room_service:expr, $create_msg:expr, - $element_uri:expr, + $element_fid:expr, $test:expr ) => {{ - let get_msg = Get(vec![$element_uri.clone()]); + let get_msg = Get(vec![$element_fid.clone()]); $room_service .send($create_msg) .and_then(move |res| { @@ -625,7 +625,7 @@ mod room_service_specs { }) .map(move |r| { let mut resp = r.unwrap(); - resp.remove(&$element_uri).unwrap() + resp.remove(&$element_fid).unwrap() }) .map($test) .map(|_| actix::System::current().stop()) @@ -639,14 +639,14 @@ mod room_service_specs { let room_service = room_service(RoomRepository::new(HashMap::new())); let spec = room_spec(); - let caller_uri = + let caller_fid = StatefulFid::try_from("pub-sub-video-call/caller".to_string()) .unwrap(); actix::spawn(test_for_create!( room_service, CreateRoom { spec }, - caller_uri, + caller_fid, |member_el| { assert_eq!(member_el.get_member().get_pipeline().len(), 1); } @@ -672,19 +672,21 @@ mod room_service_specs { room_id.clone() => Room::new(&spec, &app_ctx()).unwrap().start(), ))); - let member_uri = Fid::::new(room_id); + let member_parent_fid = Fid::::new(room_id); let member_id: MemberId = "test-member".to_string().into(); - let stateful_member_uri: StatefulFid = - member_uri.clone().push_member_id(member_id.clone()).into(); + let member_fid: StatefulFid = member_parent_fid + .clone() + .push_member_id(member_id.clone()) + .into(); actix::spawn(test_for_create!( room_service, CreateMemberInRoom { id: member_id, spec: member_spec, - uri: member_uri, + parent_fid: member_parent_fid, }, - stateful_member_uri, + member_fid, |member_el| { assert_eq!(member_el.get_member().get_pipeline().len(), 1); } @@ -715,18 +717,22 @@ mod room_service_specs { room_id.clone() => Room::new(&spec, &app_ctx()).unwrap().start(), ))); - let endpoint_uri = + let endpoint_parent_fid = Fid::::new(room_id, "caller".to_string().into()); - let stateful_endpoint_uri: StatefulFid = endpoint_uri.clone().into(); + let endpoint_id: EndpointId = "test-publish".to_string().into(); + let endpoint_fid: StatefulFid = endpoint_parent_fid + .clone() + .push_endpoint_id(endpoint_id.clone()) + .into(); actix::spawn(test_for_create!( room_service, CreateEndpointInRoom { - id: "test-publish".to_string().into(), + id: endpoint_id, spec: endpoint_spec, - uri: endpoint_uri, + parent_fid: endpoint_parent_fid, }, - stateful_endpoint_uri, + endpoint_fid, |endpoint_el| { assert_eq!( endpoint_el.get_webrtc_pub().get_p2p(), @@ -748,17 +754,17 @@ mod room_service_specs { /// This function automatically stops [`actix::System`] when test completed. fn test_for_delete_and_get( room_service: Addr, - element_stateful_uri: StatefulFid, + element_fid: StatefulFid, ) -> impl Future { let mut delete_msg = DeleteElements::new(); - delete_msg.add_uri(element_stateful_uri.clone()); + delete_msg.add_fid(element_fid.clone()); let delete_msg = delete_msg.validate().unwrap(); room_service .send(delete_msg) .and_then(move |res| { res.unwrap(); - room_service.send(Get(vec![element_stateful_uri])) + room_service.send(Get(vec![element_fid])) }) .map(move |res| { assert!(res.is_err()); @@ -772,14 +778,13 @@ mod room_service_specs { let sys = actix::System::new("room-service-tests"); let room_id: RoomId = "pub-sub-video-call".to_string().into(); - let stateful_room_uri = - StatefulFid::from(Fid::::new(room_id.clone())); + let room_fid = StatefulFid::from(Fid::::new(room_id.clone())); let room_service = room_service(RoomRepository::new(hashmap!( room_id => Room::new(&room_spec(), &app_ctx()).unwrap().start(), ))); - actix::spawn(test_for_delete_and_get(room_service, stateful_room_uri)); + actix::spawn(test_for_delete_and_get(room_service, room_fid)); sys.run().unwrap(); } @@ -789,7 +794,7 @@ mod room_service_specs { let sys = actix::System::new("room-service-tests"); let room_id: RoomId = "pub-sub-video-call".to_string().into(); - let stateful_member_uri = StatefulFid::from(Fid::::new( + let member_fid = StatefulFid::from(Fid::::new( room_id.clone(), "caller".to_string().into(), )); @@ -798,10 +803,7 @@ mod room_service_specs { room_id => Room::new(&room_spec(), &app_ctx()).unwrap().start(), ))); - actix::spawn(test_for_delete_and_get( - room_service, - stateful_member_uri, - )); + actix::spawn(test_for_delete_and_get(room_service, member_fid)); sys.run().unwrap(); } @@ -811,7 +813,7 @@ mod room_service_specs { let sys = actix::System::new("room-service-tests"); let room_id: RoomId = "pub-sub-video-call".to_string().into(); - let stateful_endpoint_uri = StatefulFid::from(Fid::::new( + let endpoint_fid = StatefulFid::from(Fid::::new( room_id.clone(), "caller".to_string().into(), "publish".to_string().into(), @@ -821,10 +823,7 @@ mod room_service_specs { room_id => Room::new(&room_spec(), &app_ctx()).unwrap().start(), ))); - actix::spawn(test_for_delete_and_get( - room_service, - stateful_endpoint_uri, - )); + actix::spawn(test_for_delete_and_get(room_service, endpoint_fid)); sys.run().unwrap(); } From 87c8124ad34b11aa9c6851f324d2083ae75b5cd5 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 16 Oct 2019 14:14:29 +0300 Subject: [PATCH 716/735] Reread [run ci] --- config.toml | 2 +- jason/demo/chart/medea-demo/values.yaml | 2 +- jason/demo/minikube.vals.yaml | 2 +- jason/demo/staging.vals.yaml | 2 +- proto/control-api/src/grpc/api.proto | 8 +- .../control/endpoints/webrtc_play_endpoint.rs | 144 +---------------- src/api/control/error_codes.rs | 10 +- src/api/control/mod.rs | 4 +- src/api/control/refs/fid.rs | 12 +- src/api/control/refs/local_uri.rs | 8 +- src/api/control/refs/mod.rs | 23 ++- src/api/control/refs/src_uri.rs | 148 ++++++++++++++++++ src/bin/client.rs | 4 +- src/conf/server.rs | 2 +- .../endpoints/webrtc/play_endpoint.rs | 5 +- .../endpoints/webrtc/publish_endpoint.rs | 1 + src/signalling/elements/member.rs | 8 +- src/signalling/participants.rs | 2 +- src/signalling/room.rs | 8 +- tests/e2e/grpc_control_api/create.rs | 24 +-- 20 files changed, 221 insertions(+), 198 deletions(-) create mode 100644 src/api/control/refs/src_uri.rs diff --git a/config.toml b/config.toml index fcbb18d78..d874768ac 100644 --- a/config.toml +++ b/config.toml @@ -4,7 +4,7 @@ # # Env var: MEDEA_SERVER__CLIENT__HTTP__PUBLIC_URL # Default: -# public_url = "ws://127.0.0.1:8080" +# public_url = "ws://127.0.0.1:8080/ws" # IP address to bind Client API HTTP server to. # diff --git a/jason/demo/chart/medea-demo/values.yaml b/jason/demo/chart/medea-demo/values.yaml index 154d39a40..a7dbb200f 100644 --- a/jason/demo/chart/medea-demo/values.yaml +++ b/jason/demo/chart/medea-demo/values.yaml @@ -18,7 +18,7 @@ server: server: client: http: - public_url: ws://127.0.0.1:8080 + public_url: ws://127.0.0.1:8080/ws bind_port: 8080 turn: user: USER diff --git a/jason/demo/minikube.vals.yaml b/jason/demo/minikube.vals.yaml index ea3b32354..94b805556 100644 --- a/jason/demo/minikube.vals.yaml +++ b/jason/demo/minikube.vals.yaml @@ -11,7 +11,7 @@ server: server: client: http: - public_url: wss://medea-demo.test + public_url: wss://medea-demo.test/ws turn: host: medea-demo.test diff --git a/jason/demo/staging.vals.yaml b/jason/demo/staging.vals.yaml index e5775504b..86fbb2f62 100644 --- a/jason/demo/staging.vals.yaml +++ b/jason/demo/staging.vals.yaml @@ -11,7 +11,7 @@ server: server: client: http: - public_url: wss://demo.medea.stg.t11913.org + public_url: wss://demo.medea.stg.t11913.org/ws bind_port: 9980 turn: host: demo.medea.stg.t11913.org diff --git a/proto/control-api/src/grpc/api.proto b/proto/control-api/src/grpc/api.proto index ad4fa95c0..a18ac26ab 100644 --- a/proto/control-api/src/grpc/api.proto +++ b/proto/control-api/src/grpc/api.proto @@ -25,7 +25,7 @@ service ControlApi { // Request of creating new Element with a given ID. message CreateRequest { - // ID of the Element to be created.. + // ID of the Element in which will be created provided element. string parent_fid = 1; // Spec of the created Element. oneof el { @@ -38,7 +38,7 @@ message CreateRequest { // Request with many Elements IDs. message IdRequest { - // List of Elements IDs. + // List of Elements FIDs. repeated string fid = 1; } @@ -112,6 +112,7 @@ message Element { // Media element which represents a single space where multiple Members can // interact with each other. message Room { + // ID of this Room. string id = 1; // Pipeline of this Room. map pipeline = 2; @@ -129,6 +130,7 @@ message Room { // Media element which represents a client authorized to participate // in a some bigger media pipeline. message Member { + // ID of this Member. string id = 1; // Callback which fires when the Member establishes persistent connection // with a media server via Client API. @@ -153,6 +155,7 @@ message Member { // Media element which is able to receive media data from a client via WebRTC // (allows to publish media data). message WebRtcPublishEndpoint { + // ID of this WebRtcPublishEndpoint. string id = 1; // P2P mode for this element. P2P p2p = 2; @@ -175,6 +178,7 @@ message WebRtcPublishEndpoint { // Media element which is able to play media data for a client via WebRTC. message WebRtcPlayEndpoint { + // ID of this WebRtcPlayEndpoint. string id = 1; // The source to get media data from. string src = 2; diff --git a/src/api/control/endpoints/webrtc_play_endpoint.rs b/src/api/control/endpoints/webrtc_play_endpoint.rs index 94835edff..57be07b14 100644 --- a/src/api/control/endpoints/webrtc_play_endpoint.rs +++ b/src/api/control/endpoints/webrtc_play_endpoint.rs @@ -2,25 +2,14 @@ //! //! [Control API]: https://tinyurl.com/yxsqplq7 -use std::{convert::TryFrom, fmt}; +use std::convert::TryFrom; use derive_more::{Display, From, Into}; -use failure::Fail; use medea_control_api_proto::grpc::api as medea_grpc_control_api; use medea_grpc_control_api::WebRtcPlayEndpoint as WebRtcPlayEndpointProto; -use serde::{ - de::{self, Deserializer, Error, Visitor}, - Deserialize, -}; +use serde::Deserialize; -use crate::api::control::{ - endpoints::webrtc_publish_endpoint::WebRtcPublishId, - refs::{ - local_uri::{LocalUriParseError, StatefulLocalUri}, - LocalUri, ToEndpoint, - }, - MemberId, RoomId, TryFromProtobufError, -}; +use crate::api::control::{refs::SrcUri, TryFromProtobufError}; /// ID of [`WebRtcPlayEndpoint`]. #[derive( @@ -45,130 +34,3 @@ impl TryFrom<&WebRtcPlayEndpointProto> for WebRtcPlayEndpoint { }) } } - -/// Errors which can happen while parsing [`SrcUri`] from [Control API] specs. -/// -/// [Control API]: https://tinyurl.com/yxsqplq7 -#[derive(Debug, Fail, Display)] -pub enum SrcParseError { - /// Provided not source URI. - #[display(fmt = "Provided not src uri {}", _0)] - NotSrcUri(String), - - /// Error from [`LocalUri`] parser. This is general errors for [`SrcUri`] - /// parsing because [`SrcUri`] parses with [`LocalUri`] parser. - #[display(fmt = "Local URI parse error: {:?}", _0)] - LocalUriParseError(LocalUriParseError), -} - -/// Special URI with pattern `local://{room_id}/{member_id}/{endpoint_id}`. -/// This uri can pointing only to [`WebRtcPublishEndpoint`]. -/// -/// Note that [`SrcUri`] is parsing with [`LocalUri`] parser. -/// Actually difference between [`SrcUri`] and [`LocalUri`] -/// in endpoint ID's type. In [`SrcUri`] it [`WebRtcPublishId`], and in -/// [`LocalUri`] it [`EndpointId`]. Also [`SrcUri`] can be deserialized with -/// [`serde`]. -/// -/// Atm used only in [Control API] specs. -/// -/// [`WebRtcPublishEndpoint`]: -/// crate::api::control::endpoints::WebRtcPublishEndpoint -/// [Control API]: https://tinyurl.com/yxsqplq7 -/// [`EndpointId`]: crate::api::control::EndpointId -#[derive(Clone, Debug)] -pub struct SrcUri { - /// ID of [`Room`]. - /// - /// [`Room`]: crate::signalling::room::Room - pub room_id: RoomId, - - /// ID of [`MemberSpec`]. - /// - /// [`MemberSpec`]: crate::api::control::member::MemberSpec - pub member_id: MemberId, - - /// ID of [`WebRtcPublishEndpoint`]. - /// - /// [`WebRtcPublishEndpoint`]: - /// crate::api::control::endpoints::WebRtcPublishEndpoint - pub endpoint_id: WebRtcPublishId, -} - -impl TryFrom for SrcUri { - type Error = SrcParseError; - - fn try_from(value: String) -> Result { - let local_uri = StatefulLocalUri::try_from(value) - .map_err(SrcParseError::LocalUriParseError)?; - - match local_uri { - StatefulLocalUri::Room(uri) => { - Err(SrcParseError::NotSrcUri(uri.to_string())) - } - StatefulLocalUri::Member(uri) => { - Err(SrcParseError::NotSrcUri(uri.to_string())) - } - StatefulLocalUri::Endpoint(uri) => Ok(uri.into()), - } - } -} - -impl From> for SrcUri { - fn from(uri: LocalUri) -> Self { - let (room_id, member_id, endpoint_id) = uri.take_all(); - - Self { - room_id, - member_id, - endpoint_id: endpoint_id.into(), - } - } -} - -/// [Serde] deserializer for [`SrcUri`]. -/// -/// Deserializes URIs with pattern: -/// `local://room_id/member_id/publish_endpoint_id`. -/// -/// [Serde]: serde -impl<'de> Deserialize<'de> for SrcUri { - fn deserialize(deserializer: D) -> Result - where - D: Deserializer<'de>, - { - struct SrcUriVisitor; - - impl<'de> Visitor<'de> for SrcUriVisitor { - type Value = SrcUri; - - fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str( - "Uri in format local://room_id/member_id/endpoint_id", - ) - } - - fn visit_str(self, value: &str) -> Result - where - E: de::Error, - { - match SrcUri::try_from(value.to_owned()) { - Ok(src_uri) => Ok(src_uri), - Err(e) => Err(Error::custom(e)), - } - } - } - - deserializer.deserialize_identifier(SrcUriVisitor) - } -} - -impl fmt::Display for SrcUri { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!( - f, - "local://{}/{}/{}", - self.room_id, self.member_id, self.endpoint_id - ) - } -} diff --git a/src/api/control/error_codes.rs b/src/api/control/error_codes.rs index 468658a6e..71b5c0b59 100644 --- a/src/api/control/error_codes.rs +++ b/src/api/control/error_codes.rs @@ -11,9 +11,11 @@ use medea_control_api_proto::grpc::api::Error as ErrorProto; use crate::{ api::control::{ - endpoints::webrtc_play_endpoint::SrcParseError, grpc::server::GrpcControlApiError, - refs::{fid::ParseFidError, local_uri::LocalUriParseError}, + refs::{ + fid::ParseFidError, local_uri::LocalUriParseError, + src_uri::SrcParseError, + }, TryFromElementError, TryFromProtobufError, }, signalling::{ @@ -255,10 +257,10 @@ pub enum ErrorCode { #[display(fmt = "Endpoint with provided FID already exists.")] EndpointAlreadyExists = 1018, - /// Missing path in some pointer to the Medea element. + /// Missing path in some reference to the Medea element. /// /// Code: __1019__. - #[display(fmt = "Missing path in some pointer to the Medea element.")] + #[display(fmt = "Missing path in some reference to the Medea element.")] MissingPath = 1019, /// Unexpected server error. diff --git a/src/api/control/mod.rs b/src/api/control/mod.rs index 99a3f2507..41bb5cfbc 100644 --- a/src/api/control/mod.rs +++ b/src/api/control/mod.rs @@ -25,9 +25,7 @@ use crate::{ }, }; -use self::{ - endpoints::webrtc_play_endpoint::SrcParseError, pipeline::Pipeline, -}; +use self::{pipeline::Pipeline, refs::src_uri::SrcParseError}; #[doc(inline)] pub use self::{ diff --git a/src/api/control/refs/fid.rs b/src/api/control/refs/fid.rs index 4db50eda9..d3a1200bf 100644 --- a/src/api/control/refs/fid.rs +++ b/src/api/control/refs/fid.rs @@ -6,13 +6,14 @@ use std::{ }; use derive_more::{Display, From}; +use failure::Fail; -use crate::{api::control::RoomId, impl_uri}; +use crate::{api::control::RoomId, impls_for_stateful_refs}; use super::{ToEndpoint, ToMember, ToRoom}; /// Errors which can happen while parsing [`Fid`]. -#[derive(Display, Debug)] +#[derive(Display, Debug, Fail)] pub enum ParseFidError { #[display(fmt = "Fid is empty.")] Empty, @@ -30,7 +31,7 @@ pub struct Fid { state: T, } -impl_uri!(Fid); +impls_for_stateful_refs!(Fid); impl From for Fid { fn from(from: StatefulFid) -> Self { @@ -157,6 +158,7 @@ mod specs { "room_id//endpoint_id", "//endpoint_id", "//member_id/endpoint_id", + "/member_id", ] { match StatefulFid::try_from(fid_str.to_string()) { Ok(f) => unreachable!("Unexpected successful parse: {}", f), @@ -171,7 +173,7 @@ mod specs { #[test] fn returns_error_on_too_many_paths() { for fid_str in vec![ - "room_id/member_id/endpoint_id/somethis_else", + "room_id/member_id/endpoint_id/something_else", "room_id/member_id/endpoint_id/", "room_id/member_id/endpoint_id////", ] { @@ -235,7 +237,7 @@ mod specs { } #[test] - fn serializes_into_origin_fid() { + fn serializes_into_original_fid() { for fid_str in vec![ "room_id", "room_id/member_id", diff --git a/src/api/control/refs/local_uri.rs b/src/api/control/refs/local_uri.rs index 0ee7917bc..df097b0ab 100644 --- a/src/api/control/refs/local_uri.rs +++ b/src/api/control/refs/local_uri.rs @@ -10,11 +10,11 @@ use failure::Fail; use url::Url; use crate::{ - api::control::{endpoints::webrtc_play_endpoint::SrcUri, MemberId, RoomId}, - impl_uri, + api::control::{MemberId, RoomId}, + impls_for_stateful_refs, }; -use super::{ToEndpoint, ToMember, ToRoom}; +use super::{SrcUri, ToEndpoint, ToMember, ToRoom}; /// URI in format `local://room_id/member_id/endpoint_id`. /// @@ -80,7 +80,7 @@ pub struct LocalUri { state: T, } -impl_uri!(LocalUri); +impls_for_stateful_refs!(LocalUri); impl From for LocalUri { fn from(from: StatefulLocalUri) -> Self { diff --git a/src/api/control/refs/mod.rs b/src/api/control/refs/mod.rs index 829dbf254..a53eb7aad 100644 --- a/src/api/control/refs/mod.rs +++ b/src/api/control/refs/mod.rs @@ -1,10 +1,11 @@ //! Implementation of all kinds of references to some resource used in Medea's -//! Control API specs. +//! Control API. #![allow(clippy::use_self)] pub mod fid; pub mod local_uri; +pub mod src_uri; use super::{EndpointId, MemberId, RoomId}; @@ -12,6 +13,7 @@ use super::{EndpointId, MemberId, RoomId}; pub use self::{ fid::{Fid, StatefulFid}, local_uri::{LocalUri, StatefulLocalUri}, + src_uri::SrcUri, }; /// State of [`LocalUri`] which points to [`Room`]. @@ -32,9 +34,24 @@ pub struct ToMember(RoomId, MemberId); #[derive(Clone, Debug, Eq, Hash, PartialEq)] pub struct ToEndpoint(RoomId, MemberId, EndpointId); -// TODO: rename +/// Generates functions for transition between [`ToRoom`], +/// [`ToMember`] and [`ToEndpoint`] states of Medea references and handy getters +/// for data of this references. +/// +/// Supposed that container for which you want to implement all this methods +/// is something like: +/// +/// ```rust +/// pub struct SomeReference { +/// state: T +/// } +/// ``` +/// +/// This is necessary so that you can write different implementations of +/// serializing and deserializing for references, but at the same time have some +/// standard API for working with them. #[macro_export] -macro_rules! impl_uri { +macro_rules! impls_for_stateful_refs { ($container:tt) => { impl $container { /// Creates new [`LocalUri`] in [`ToRoom`] state. diff --git a/src/api/control/refs/src_uri.rs b/src/api/control/refs/src_uri.rs new file mode 100644 index 000000000..6708a315e --- /dev/null +++ b/src/api/control/refs/src_uri.rs @@ -0,0 +1,148 @@ +//! Implementation of special URI with pattern +//! `local://{room_id}/{member_id}/{endpoint_id}`. This URI can point only to +//! [`WebRtcPublishEndpoint`]. + +use std::{convert::TryFrom, fmt}; + +use derive_more::Display; +use failure::Fail; +use serde::{ + de::{self, Deserializer, Error, Visitor}, + Deserialize, +}; + +use crate::api::control::{ + endpoints::webrtc_publish_endpoint::WebRtcPublishId, + refs::{ + local_uri::{LocalUriParseError, StatefulLocalUri}, + LocalUri, ToEndpoint, + }, + MemberId, RoomId, +}; + +/// Errors which can happen while parsing [`SrcUri`] from [Control API] specs. +/// +/// [Control API]: https://tinyurl.com/yxsqplq7 +#[derive(Debug, Fail, Display)] +pub enum SrcParseError { + /// Provided not source URI. + #[display(fmt = "Provided not src uri {}", _0)] + NotSrcUri(String), + + /// Error from [`LocalUri`] parser. This is general errors for [`SrcUri`] + /// parsing because [`SrcUri`] parses with [`LocalUri`] parser. + #[display(fmt = "Local URI parse error: {:?}", _0)] + LocalUriParseError(LocalUriParseError), +} + +/// Special URI with pattern `local://{room_id}/{member_id}/{endpoint_id}`. +/// This uri can pointing only to [`WebRtcPublishEndpoint`]. +/// +/// Note that [`SrcUri`] is parsing with [`LocalUri`] parser. +/// Actually difference between [`SrcUri`] and [`LocalUri`] +/// in endpoint ID's type. In [`SrcUri`] it [`WebRtcPublishId`], and in +/// [`LocalUri`] it [`EndpointId`]. Also [`SrcUri`] can be deserialized with +/// [`serde`]. +/// +/// Atm used only in [Control API] specs. +/// +/// [`WebRtcPublishEndpoint`]: +/// crate::api::control::endpoints::WebRtcPublishEndpoint +/// [Control API]: https://tinyurl.com/yxsqplq7 +/// [`EndpointId`]: crate::api::control::EndpointId +#[derive(Clone, Debug)] +pub struct SrcUri { + /// ID of [`Room`]. + /// + /// [`Room`]: crate::signalling::room::Room + pub room_id: RoomId, + + /// ID of [`MemberSpec`]. + /// + /// [`MemberSpec`]: crate::api::control::member::MemberSpec + pub member_id: MemberId, + + /// ID of [`WebRtcPublishEndpoint`]. + /// + /// [`WebRtcPublishEndpoint`]: + /// crate::api::control::endpoints::WebRtcPublishEndpoint + pub endpoint_id: WebRtcPublishId, +} + +impl TryFrom for SrcUri { + type Error = SrcParseError; + + fn try_from(value: String) -> Result { + let local_uri = StatefulLocalUri::try_from(value) + .map_err(SrcParseError::LocalUriParseError)?; + + match local_uri { + StatefulLocalUri::Room(uri) => { + Err(SrcParseError::NotSrcUri(uri.to_string())) + } + StatefulLocalUri::Member(uri) => { + Err(SrcParseError::NotSrcUri(uri.to_string())) + } + StatefulLocalUri::Endpoint(uri) => Ok(uri.into()), + } + } +} + +impl From> for SrcUri { + fn from(uri: LocalUri) -> Self { + let (room_id, member_id, endpoint_id) = uri.take_all(); + + Self { + room_id, + member_id, + endpoint_id: endpoint_id.into(), + } + } +} + +/// [Serde] deserializer for [`SrcUri`]. +/// +/// Deserializes URIs with pattern: +/// `local://room_id/member_id/publish_endpoint_id`. +/// +/// [Serde]: serde +impl<'de> Deserialize<'de> for SrcUri { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct SrcUriVisitor; + + impl<'de> Visitor<'de> for SrcUriVisitor { + type Value = SrcUri; + + fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str( + "Uri in format local://room_id/member_id/endpoint_id", + ) + } + + fn visit_str(self, value: &str) -> Result + where + E: de::Error, + { + match SrcUri::try_from(value.to_owned()) { + Ok(src_uri) => Ok(src_uri), + Err(e) => Err(Error::custom(e)), + } + } + } + + deserializer.deserialize_identifier(SrcUriVisitor) + } +} + +impl fmt::Display for SrcUri { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!( + f, + "local://{}/{}/{}", + self.room_id, self.member_id, self.endpoint_id + ) + } +} diff --git a/src/bin/client.rs b/src/bin/client.rs index d3b1255aa..1672b3444 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -21,7 +21,7 @@ use protobuf::RepeatedField; fn main() { let env = Arc::new(EnvBuilder::new().build()); - let ch = ChannelBuilder::new(env).connect("localhost:50051"); + let ch = ChannelBuilder::new(env).connect("127.0.0.1:6565"); let client = ControlApiClient::new(ch); // unimplemented_apply(&client); @@ -31,7 +31,7 @@ fn main() { // delete_member(&client); create_member(&client); // create_endpoint(&client); - // get_room(&client); + get_room(&client); } fn create_room(client: &ControlApiClient) { diff --git a/src/conf/server.rs b/src/conf/server.rs index d03fb7b04..a621f89c6 100644 --- a/src/conf/server.rs +++ b/src/conf/server.rs @@ -36,7 +36,7 @@ pub struct ClientApiHttpServer { /// [Client API]: https://tinyurl.com/yx9thsnr /// [Control API]: https://tinyurl.com/yxsqplq7 /// [Jason]: https://github.com/instrumentisto/medea/tree/master/jason - #[default = "ws://127.0.0.1:8080"] + #[default = "ws://127.0.0.1:8080/ws"] pub public_url: String, /// IP address to bind HTTP server to. diff --git a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs index d014e566f..b6592143c 100644 --- a/src/signalling/elements/endpoints/webrtc/play_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/play_endpoint.rs @@ -12,8 +12,8 @@ use medea_control_api_proto::grpc::api::{ }; use crate::{ - api::control::endpoints::webrtc_play_endpoint::{ - SrcUri, WebRtcPlayId as Id, + api::control::{ + endpoints::webrtc_play_endpoint::WebRtcPlayId as Id, refs::SrcUri, }, signalling::elements::{ endpoints::webrtc::publish_endpoint::WeakWebRtcPublishEndpoint, @@ -202,6 +202,7 @@ impl Into for WebRtcPlayEndpoint { let mut element = ElementProto::new(); let mut play = WebRtcPlayEndpointProto::new(); play.set_src(self.src_uri().to_string()); + play.set_id(self.id().to_string()); element.set_webrtc_play(play); element diff --git a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs index 0b04a8891..596d540bb 100644 --- a/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs +++ b/src/signalling/elements/endpoints/webrtc/publish_endpoint.rs @@ -233,6 +233,7 @@ impl Into for WebRtcPublishEndpoint { let mut element = ElementProto::new(); let mut publish = WebRtcPublishEndpointProto::new(); publish.set_p2p(self.p2p().into()); + publish.set_id(self.id().to_string()); element.set_webrtc_pub(publish); element diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index d04f0dd8e..f496b216a 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -486,16 +486,14 @@ impl Into for Member { let mut member_pipeline = HashMap::new(); for (id, play) in self.sinks() { - let endpoint_fid = self.get_fid_to_endpoint(id.into()); - member_pipeline.insert(endpoint_fid.to_string(), play.into()); + member_pipeline.insert(id.to_string(), play.into()); } for (id, publish) in self.srcs() { - let endpoint_fid = self.get_fid_to_endpoint(id.into()); - - member_pipeline.insert(endpoint_fid.to_string(), publish.into()); + member_pipeline.insert(id.to_string(), publish.into()); } member.set_pipeline(member_pipeline); + member.set_id(self.id().to_string()); member.set_credentials(self.credentials()); element.set_member(member); diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 3900d0fd3..66a818d45 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -416,7 +416,7 @@ impl ParticipantService { } } - pub fn create_member(&mut self, id: MemberId, member: Member) { + pub fn insert_member(&mut self, id: MemberId, member: Member) { self.members.insert(id, member); } } diff --git a/src/signalling/room.rs b/src/signalling/room.rs index cb3d62bff..1477b859b 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -841,7 +841,7 @@ impl Room { src.add_sink(sink.downgrade()); } - self.members.create_member(id, signalling_member); + self.members.insert_member(id, signalling_member); Ok(()) } @@ -866,13 +866,11 @@ impl Into for &mut Room { .members .members() .into_iter() - .map(|(id, member)| { - let member_fid = Fid::::new(self.get_id(), id); - (member_fid.to_string(), member.into()) - }) + .map(|(id, member)| (id.to_string(), member.into())) .collect(); room.set_pipeline(pipeline); + room.set_id(self.id().to_string()); element.set_room(room); element diff --git a/tests/e2e/grpc_control_api/create.rs b/tests/e2e/grpc_control_api/create.rs index 6d691a3d9..2a9b37cf8 100644 --- a/tests/e2e/grpc_control_api/create.rs +++ b/tests/e2e/grpc_control_api/create.rs @@ -31,34 +31,26 @@ mod room { sids.get(&"responder".to_string()).unwrap().as_str(); assert_eq!( responder_sid, - &insert_str!("ws://127.0.0.1:8080/{}/responder/test") + &insert_str!("ws://127.0.0.1:8080/ws/{}/responder/test") ); let mut get_resp = client.get(&insert_str!("{}")); let room = get_resp.take_room(); - let responder = room - .get_pipeline() - .get(&insert_str!("{}/responder")) - .unwrap() - .get_member(); + let responder = + room.get_pipeline().get("responder").unwrap().get_member(); assert_eq!(responder.get_credentials(), "test"); let responder_pipeline = responder.get_pipeline(); assert_eq!(responder_pipeline.len(), 1); - let responder_play = responder_pipeline - .get(&insert_str!("{}/responder/play")) - .unwrap() - .get_webrtc_play(); + let responder_play = + responder_pipeline.get("play").unwrap().get_webrtc_play(); assert_eq!( responder_play.get_src(), insert_str!("local://{}/publisher/publish") ); - let publisher = room - .get_pipeline() - .get(&insert_str!("{}/publisher")) - .unwrap() - .get_member(); + let publisher = + room.get_pipeline().get("publisher").unwrap().get_member(); assert_ne!(publisher.get_credentials(), "test"); assert_ne!(publisher.get_credentials(), ""); let publisher_pipeline = responder.get_pipeline(); @@ -136,7 +128,7 @@ mod member { sids.get(&"test-member".to_string()).unwrap().as_str(); assert_eq!( e2e_test_member_sid, - insert_str!("ws://127.0.0.1:8080/{}/test-member/qwerty") + insert_str!("ws://127.0.0.1:8080/ws/{}/test-member/qwerty") ); let member = client.get(&insert_str!("{}/test-member")).take_member(); From b530ef801ffd33c6a95432d6f42afb85b162e739 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 16 Oct 2019 15:01:06 +0300 Subject: [PATCH 717/735] Remove rustup add component clippy and rustfmt [run ci] --- .travis.yml | 2 -- tests/e2e/grpc_control_api/create.rs | 3 +-- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index cf37ce64b..f5e94401b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,14 +29,12 @@ jobs: - name: Clippy stage: check rust: stable - before_script: rustup component add clippy script: make lint - name: rustfmt stage: check rust: nightly cache: false - before_script: rustup component add rustfmt script: make fmt check=yes - name: medea-jason (stable) diff --git a/tests/e2e/grpc_control_api/create.rs b/tests/e2e/grpc_control_api/create.rs index 2a9b37cf8..bbf82620b 100644 --- a/tests/e2e/grpc_control_api/create.rs +++ b/tests/e2e/grpc_control_api/create.rs @@ -6,11 +6,10 @@ //! [Control API]: https://tinyurl.com/yxsqplq7 use medea_control_api_proto::grpc::api::WebRtcPublishEndpoint_P2P; +use medea::api::control::error_codes::ErrorCode; use crate::gen_insert_str_macro; -use medea::api::control::error_codes::ErrorCode; - use super::{ create_room_req, ControlClient, MemberBuilder, RoomBuilder, WebRtcPlayEndpointBuilder, WebRtcPublishEndpointBuilder, From aff060fe1513f1a232611a4abceae025acf43a0f Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 16 Oct 2019 15:12:16 +0300 Subject: [PATCH 718/735] Fix lints [run ci] --- src/signalling/room_service.rs | 10 ++++++---- tests/e2e/grpc_control_api/create.rs | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index 3767e6791..7b0717e9a 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -261,8 +261,9 @@ impl Handler for RoomService { .and_then(|r| r.map_err(RoomServiceError::from)), ) } else { - let room_fid = Fid::::new(room_id); - Box::new(future::err(RoomServiceError::RoomNotFound(room_fid))) + Box::new(future::err(RoomServiceError::RoomNotFound( + Fid::::new(room_id), + ))) } } } @@ -300,8 +301,9 @@ impl Handler for RoomService { .and_then(|r| r.map_err(RoomServiceError::from)), ) } else { - let room_fid = Fid::::new(room_id); - Box::new(future::err(RoomServiceError::RoomNotFound(room_fid))) + Box::new(future::err(RoomServiceError::RoomNotFound( + Fid::::new(room_id), + ))) } } } diff --git a/tests/e2e/grpc_control_api/create.rs b/tests/e2e/grpc_control_api/create.rs index bbf82620b..c6d44fe04 100644 --- a/tests/e2e/grpc_control_api/create.rs +++ b/tests/e2e/grpc_control_api/create.rs @@ -5,8 +5,8 @@ //! //! [Control API]: https://tinyurl.com/yxsqplq7 -use medea_control_api_proto::grpc::api::WebRtcPublishEndpoint_P2P; use medea::api::control::error_codes::ErrorCode; +use medea_control_api_proto::grpc::api::WebRtcPublishEndpoint_P2P; use crate::gen_insert_str_macro; From b7c92fa3dc8cd1f256380a703024098b674304f8 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 16 Oct 2019 17:10:17 +0300 Subject: [PATCH 719/735] Fix docs --- proto/control-api/src/grpc/api.proto | 8 ++-- src/api/control/error_codes.rs | 3 ++ src/api/control/refs/fid.rs | 2 +- src/api/control/refs/mod.rs | 70 +++++++++++++++++++++------- src/api/control/refs/src_uri.rs | 3 ++ src/signalling/room.rs | 6 +-- 6 files changed, 68 insertions(+), 24 deletions(-) diff --git a/proto/control-api/src/grpc/api.proto b/proto/control-api/src/grpc/api.proto index a18ac26ab..9acf83263 100644 --- a/proto/control-api/src/grpc/api.proto +++ b/proto/control-api/src/grpc/api.proto @@ -23,9 +23,9 @@ service ControlApi { rpc Get (IdRequest) returns (GetResponse); } -// Request of creating new Element with a given ID. +// Request of creating new Element with in element with given Full ID (FID). message CreateRequest { - // ID of the Element in which will be created provided element. + // Full ID (FID) of the Element in which will be created provided element. string parent_fid = 1; // Spec of the created Element. oneof el { @@ -36,9 +36,9 @@ message CreateRequest { } } -// Request with many Elements IDs. +// Request with many Elements Full IDs (FIDs) elements. message IdRequest { - // List of Elements FIDs. + // List of elements Full IDs (FIDs). repeated string fid = 1; } diff --git a/src/api/control/error_codes.rs b/src/api/control/error_codes.rs index 71b5c0b59..4cd7bb9c8 100644 --- a/src/api/control/error_codes.rs +++ b/src/api/control/error_codes.rs @@ -184,6 +184,9 @@ pub enum ErrorCode { /// Invalid source URI in [`WebRtcPlayEndpoint`]. /// /// Code: __1008__. + /// + /// [`WebRtcPlayEndpoint`]: + /// crate::signalling::elements::endpoints::webrtc::WebRtcPlayEndpoint #[display(fmt = "Invalid source URI in 'WebRtcPlayEndpoint'.")] InvalidSrcUri = 1008, diff --git a/src/api/control/refs/fid.rs b/src/api/control/refs/fid.rs index d3a1200bf..b202b1e49 100644 --- a/src/api/control/refs/fid.rs +++ b/src/api/control/refs/fid.rs @@ -80,7 +80,7 @@ pub enum StatefulFid { impl StatefulFid { /// Returns reference to [`RoomId`]. /// - /// This is possible in any [`LocalUri`] state. + /// This is possible in any [`StatefulFid`] state. pub fn room_id(&self) -> &RoomId { match self { StatefulFid::Room(uri) => uri.room_id(), diff --git a/src/api/control/refs/mod.rs b/src/api/control/refs/mod.rs index a53eb7aad..111782674 100644 --- a/src/api/control/refs/mod.rs +++ b/src/api/control/refs/mod.rs @@ -16,19 +16,19 @@ pub use self::{ src_uri::SrcUri, }; -/// State of [`LocalUri`] which points to [`Room`]. +/// State of reference which points to [`Room`]. /// /// [`Room`]: crate::signalling::room::Room #[derive(Clone, Debug, Eq, Hash, PartialEq)] pub struct ToRoom(RoomId); -/// State of [`LocalUri`] which points to [`Member`]. +/// State of reference which points to [`Member`]. /// /// [`Member`]: crate::signalling::elements::member::Member #[derive(Clone, Debug, Eq, Hash, PartialEq)] pub struct ToMember(RoomId, MemberId); -/// State of [`LocalUri`] which points to [`Endpoint`]. +/// State of reference which points to [`Endpoint`]. /// /// [`Endpoint`]: crate::signalling::elements::endpoints::Endpoint #[derive(Clone, Debug, Eq, Hash, PartialEq)] @@ -50,29 +50,40 @@ pub struct ToEndpoint(RoomId, MemberId, EndpointId); /// This is necessary so that you can write different implementations of /// serializing and deserializing for references, but at the same time have some /// standard API for working with them. +/// +/// [`ToRoom`]: crate::api::control::refs::ToRoom +/// [`ToMember`]: crate::api::control::refs::ToMember +/// [`ToEndpoint`]: crate::api::control::refs::ToEndpoint #[macro_export] macro_rules! impls_for_stateful_refs { ($container:tt) => { impl $container { - /// Creates new [`LocalUri`] in [`ToRoom`] state. + #[doc = "Create new reference in [`ToRoom`] state."] pub fn new(room_id: $crate::api::control::RoomId) -> Self { Self { state: ToRoom(room_id), } } - /// Returns reference to [`RoomId`]. + /// Returns borrowed [`RoomId`]. + /// + /// [`RoomId`]: crate::api::control::RoomId pub fn room_id(&self) -> &$crate::api::control::RoomId { &self.state.0 } /// Returns [`RoomId`]. + /// + /// [`RoomId`]: crate::api::control::RoomId pub fn take_room_id(self) -> $crate::api::control::RoomId { self.state.0 } /// Pushes [`MemberId`] to the end of URI and returns - /// [`LocalUri`] in [`ToMember`] state. + /// reference in [`ToMember`] state. + /// + /// [`MemberId`]: crate::api::control::MemberId + /// [`ToMember`]: crate::api::control::refs::ToMember pub fn push_member_id( self, member_id: $crate::api::control::MemberId, @@ -85,7 +96,9 @@ macro_rules! impls_for_stateful_refs { } impl $container<$crate::api::control::refs::ToMember> { - /// Create new [`LocalUri`] in [`ToMember`] state. + /// Create new reference in [`ToMember`] state. + /// + /// [`ToMember`]: crate::api::control::refs::ToMember pub fn new( room_id: $crate::api::control::RoomId, member_id: $crate::api::control::MemberId, @@ -97,17 +110,24 @@ macro_rules! impls_for_stateful_refs { } } - /// Returns reference to [`RoomId`]. + /// Returns borrowed [`RoomId`]. + /// + /// [`RoomId`]: crate::api::control::RoomId pub fn room_id(&self) -> &$crate::api::control::RoomId { &self.state.0 } - /// Returns reference to [`MemberId`]. + /// Returns borrowed [`MemberId`]. + /// + /// [`MemberId`]: crate::api::control::MemberId pub fn member_id(&self) -> &$crate::api::control::MemberId { &self.state.1 } - /// Return [`MemberId`] and [`LocalUri`] in state [`ToRoom`]. + /// Return [`MemberId`] and reference in state [`ToRoom`]. + /// + /// [`MemberId`]: crate::api::control::MemberId + /// [`ToRoom`]: crate::api::control::refs::ToRoom pub fn take_member_id( self, ) -> ( @@ -123,7 +143,9 @@ macro_rules! impls_for_stateful_refs { } /// Push endpoint ID to the end of URI and returns - /// [`LocalUri`] in [`ToEndpoint`] state. + /// reference in [`ToEndpoint`] state. + /// + /// [`ToEndpoint`]: crate::api::control::refs::ToEndpoint pub fn push_endpoint_id( self, endpoint_id: $crate::api::control::EndpointId, @@ -138,6 +160,9 @@ macro_rules! impls_for_stateful_refs { } /// Returns [`RoomId`] and [`MemberId`]. + /// + /// [`RoomId`]: crate::api::control::RoomId + /// [`MemberId`]: crate::api::control::MemberId pub fn take_all( self, ) -> ($crate::api::control::RoomId, $crate::api::control::MemberId) @@ -149,7 +174,9 @@ macro_rules! impls_for_stateful_refs { } impl $container<$crate::api::control::refs::ToEndpoint> { - /// Creates new [`LocalUri`] in [`ToEndpoint`] state. + /// Creates new reference in [`ToEndpoint`] state. + /// + /// [`ToEndpoint`]: crate::api::control::refs::ToEndpoint pub fn new( room_id: $crate::api::control::RoomId, member_id: $crate::api::control::MemberId, @@ -164,24 +191,31 @@ macro_rules! impls_for_stateful_refs { } } - /// Returns reference to [`RoomId`]. + /// Returns borrowed [`RoomId`]. + /// + /// [`RoomId`]: crate::api::control::RoomId pub fn room_id(&self) -> &$crate::api::control::RoomId { &self.state.0 } - /// Returns reference to [`MemberId`]. + /// Returns borrowed [`MemberId`]. + /// + /// [`MemberId`]: crate::api::control::MemberId pub fn member_id(&self) -> &$crate::api::control::MemberId { &self.state.1 } - /// Returns reference to [`EndpointId`]. + /// Returns borrowed [`EndpointId`]. + /// + /// [`EndpointId`]: crate::api::control::EndpointId pub fn endpoint_id(&self) -> &$crate::api::control::EndpointId { &self.state.2 } - /// Returns [`Endpoint`] id and [`LocalUri`] in [`ToMember`] state. + /// Returns [`Endpoint`] id and reference in [`ToMember`] state. /// /// [`Endpoint`]: crate::signalling::elements::endpoints::Endpoint + /// [`ToMember`]: crate::api::control::refs::ToMember pub fn take_endpoint_id( self, ) -> ( @@ -198,6 +232,10 @@ macro_rules! impls_for_stateful_refs { } /// Returns [`EndpointId`], [`RoomId`] and [`MemberId`]. + /// + /// [`EndpointId`]: crate::api::control::EndpointId + /// [`RoomId`]: crate::api::control::RoomId + /// [`MemberId`]: crate::api::control::MemberId pub fn take_all( self, ) -> ( diff --git a/src/api/control/refs/src_uri.rs b/src/api/control/refs/src_uri.rs index 6708a315e..272825ffe 100644 --- a/src/api/control/refs/src_uri.rs +++ b/src/api/control/refs/src_uri.rs @@ -1,6 +1,9 @@ //! Implementation of special URI with pattern //! `local://{room_id}/{member_id}/{endpoint_id}`. This URI can point only to //! [`WebRtcPublishEndpoint`]. +//! +//! [`WebRtcPublishEndpoint`]: +//! crate::signalling::elements::endpoints::webrtc::WebRtcPublishEndpoint use std::{convert::TryFrom, fmt}; diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 1477b859b..b0507b717 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -675,7 +675,7 @@ impl Room { /// This function will check that new [`WebRtcPublishEndpoint`]'s ID is not /// present in [`ParticipantService`]. /// - /// Returns [`ParticipantServiceErr::EndpointAlreadyExists`] when + /// Returns [`RoomError::EndpointAlreadyExists`] when /// [`WebRtcPublishEndpoint`]'s ID already presented in [`Member`]. pub fn create_src_endpoint( &mut self, @@ -722,7 +722,7 @@ impl Room { /// This function will check that new [`WebRtcPlayEndpoint`]'s ID is not /// present in [`ParticipantService`]. /// - /// Returns [`ParticipantServiceErr::EndpointAlreadyExists`] when + /// Returns [`RoomError::EndpointAlreadyExists`] when /// [`WebRtcPlayEndpoint`]'s ID already presented in [`Member`]. pub fn create_sink_endpoint( &mut self, @@ -785,7 +785,7 @@ impl Room { /// This function will check that new [`Member`]'s ID is not present in /// [`ParticipantService`]. /// - /// Returns [`ParticipantServiceErr::ParticipantAlreadyExists`] when + /// Returns [`RoomError::MemberAlreadyExists`] when /// [`Member`]'s ID already presented in [`ParticipantService`]. pub fn create_member( &mut self, From 3886462d9a75b4ab620f5f37a70938ffe4ff28e8 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Wed, 16 Oct 2019 17:26:26 +0300 Subject: [PATCH 720/735] Small fix --- src/api/control/grpc/server.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index ce6288c11..7f7268691 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -225,8 +225,9 @@ impl ControlApiService { .and_then(|create_result| create_result), ) } - _ => Box::new(future::err(ErrorResponse::without_id( + _ => Box::new(future::err(ErrorResponse::new( ElementIdMismatch, + &uri, ))), }, StatefulFid::Member(uri) => { @@ -242,9 +243,10 @@ impl ControlApiService { publish.take_id().into(), ), _ => { - return Box::new(future::err( - ErrorResponse::without_id(ElementIdMismatch), - )) + return Box::new(future::err(ErrorResponse::new( + ElementIdMismatch, + &uri, + ))) } }; Box::new( @@ -259,7 +261,7 @@ impl ControlApiService { ) } StatefulFid::Endpoint(_) => Box::new(future::err( - ErrorResponse::without_id(ElementIdIsTooLong), + ErrorResponse::new(ElementIdIsTooLong, &parent_fid), )), } } From d20067d0549154ba30c792fd4d289126dbf17eb9 Mon Sep 17 00:00:00 2001 From: alexlapa Date: Thu, 17 Oct 2019 14:00:19 +0300 Subject: [PATCH 721/735] some fixes --- Cargo.lock | 44 +++++++++++------------- crates/medea-macro/src/dispatchable.rs | 1 + src/api/control/grpc/server.rs | 9 +++-- src/api/control/refs/fid.rs | 7 ++-- src/api/control/refs/local_uri.rs | 4 +-- src/signalling/room.rs | 46 ++++++++++++++------------ src/signalling/room_service.rs | 6 ++-- tests/e2e/signalling/three_pubs.rs | 1 + 8 files changed, 62 insertions(+), 56 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 17797df8d..9295d4ecb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -333,11 +333,6 @@ dependencies = [ "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "arc-swap" -version = "0.3.11" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "arc-swap" version = "0.4.3" @@ -399,10 +394,10 @@ dependencies = [ [[package]] name = "backtrace" -version = "0.3.38" +version = "0.3.40" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "backtrace-sys 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace-sys 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", @@ -410,10 +405,10 @@ dependencies = [ [[package]] name = "backtrace-sys" -version = "0.1.31" +version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.46 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -466,7 +461,7 @@ name = "brotli-sys" version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.46 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -509,7 +504,7 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.45" +version = "1.0.46" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -541,7 +536,7 @@ name = "cmake" version = "0.1.42" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.46 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -822,7 +817,7 @@ name = "failure" version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "backtrace 0.3.38 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace 0.3.40 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -934,7 +929,7 @@ name = "grpcio-sys" version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.46 (registry+https://github.com/rust-lang/crates.io-index)", "cmake 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1201,7 +1196,7 @@ dependencies = [ "slog-async 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "slog-envlogger 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "slog-json 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "slog-scope 4.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "slog-scope 4.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "slog-stdlog 4.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "smart-default 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1304,7 +1299,7 @@ name = "miniz-sys" version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.46 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2076,7 +2071,7 @@ dependencies = [ "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "slog-async 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "slog-scope 4.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "slog-scope 4.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "slog-stdlog 4.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "slog-term 2.4.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2094,10 +2089,10 @@ dependencies = [ [[package]] name = "slog-scope" -version = "4.1.2" +version = "4.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "arc-swap 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)", + "arc-swap 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2110,7 +2105,7 @@ dependencies = [ "crossbeam 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "slog-scope 4.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "slog-scope 4.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2821,7 +2816,6 @@ dependencies = [ "checksum actix_derive 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0bf5f6d7bf2d220ae8b4a7ae02a572bb35b7c4806b24049af905ab8110de156c" "checksum adler32 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5d2e7343e7fc9de883d1b0341e0b13970f764c14101234857d2ddafa1cb1cac2" "checksum aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "58fb5e95d83b38284460a5fda7d6470aa0b8844d283a0b614b8535e880800d2d" -"checksum arc-swap 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)" = "bc4662175ead9cd84451d5c35070517777949a2ed84551764129cedb88384841" "checksum arc-swap 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "f1a1eca3195b729bbd64e292ef2f5fff6b1c28504fed762ce2b1013dde4d8e92" "checksum arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0d382e583f07208808f6b1249e60848879ba3543f57c32277bf52d69c2f0f0ee" "checksum arrayvec 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "cd9fd44efafa8690358b7408d253adf110036b88f55672a933f01d616ad9b1b9" @@ -2829,8 +2823,8 @@ dependencies = [ "checksum atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1803c647a3ec87095e7ae7acfca019e98de5ec9a7d01343f611cf3152ed71a90" "checksum autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "b671c8fb71b457dd4ae18c4ba1e59aa81793daacc361d82fcd410cef0d491875" "checksum awc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "364537de6ac9f996780f9dd097d6c4ca7c91dd5735153e9fb545037479becd10" -"checksum backtrace 0.3.38 (registry+https://github.com/rust-lang/crates.io-index)" = "690a62be8920ccf773ee00ef0968649b0e724cda8bd5b12286302b4ae955fdf5" -"checksum backtrace-sys 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)" = "82a830b4ef2d1124a711c71d263c5abdc710ef8e907bd508c88be475cebc422b" +"checksum backtrace 0.3.40 (registry+https://github.com/rust-lang/crates.io-index)" = "924c76597f0d9ca25d762c25a4d369d51267536465dc5064bdf0eb073ed477ea" +"checksum backtrace-sys 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)" = "5d6575f128516de27e3ce99689419835fce9643a9b215a14d2b5b685be018491" "checksum base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" "checksum bb8 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0ac73ee3406f475415bba792942016291b87bac08839c38a032de56085a73b2c" "checksum bb8-redis 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "39945a33c03edfba8c353d330b921961e2137d4fc4215331c1b2397f32acff80" @@ -2842,7 +2836,7 @@ dependencies = [ "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" "checksum bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" "checksum c2-chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7d64d04786e0f528460fc884753cf8dddcc466be308f6026f8e355c41a0e4101" -"checksum cc 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)" = "4fc9a35e1f4290eb9e5fc54ba6cf40671ed2a2514c3eeb2b2a908dda2ea5a1be" +"checksum cc 1.0.46 (registry+https://github.com/rust-lang/crates.io-index)" = "0213d356d3c4ea2c18c40b037c3be23cd639825c18f25ee670ac7813beeef99c" "checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" "checksum chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e8493056968583b0193c1bb04d6f7684586f3726992d6c573261941a895dbd68" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" @@ -3017,7 +3011,7 @@ dependencies = [ "checksum slog-async 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e544d16c6b230d84c866662fe55e31aacfca6ae71e6fc49ae9a311cb379bfc2f" "checksum slog-envlogger 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "906a1a0bc43fed692df4b82a5e2fbfc3733db8dad8bb514ab27a4f23ad04f5c0" "checksum slog-json 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ddc0d2aff1f8f325ef660d9a0eb6e6dcd20b30b3f581a5897f58bf42d061c37a" -"checksum slog-scope 4.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d1d3ec6214d46e57a7ec87c1972bbca66c59172a0cfffa5233c54726afb946bf" +"checksum slog-scope 4.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "53a5819e0ab73a542e42b0d8ce8bf9e0a470c8f0a370e176a18855566332a120" "checksum slog-stdlog 4.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "be4d87903baf655da2d82bc3ac3f7ef43868c58bf712b3a661fda72009304c23" "checksum slog-term 2.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cb9b3fd9a3c2c86580fce3558a98ed7c69039da0288b08a3f15b371635254e08" "checksum smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "ab606a9c5e214920bb66c458cd7be8ef094f813f20fe77a54cc7dbfff220d4b7" diff --git a/crates/medea-macro/src/dispatchable.rs b/crates/medea-macro/src/dispatchable.rs index 6c7e92265..de99e5d2d 100644 --- a/crates/medea-macro/src/dispatchable.rs +++ b/crates/medea-macro/src/dispatchable.rs @@ -23,6 +23,7 @@ fn to_handler_fn_name(name: &str) -> String { /// from `camelCase` to `snake_case` and add `on_` prefix. /// 3. Generate trait `{enum_name}Handler` with generated methods from step 1. /// 4. Generate method `dispatch_with()` with a dispatching generated on step 2. +#[allow(clippy::too_many_lines)] pub fn derive(input: TokenStream) -> Result { let mut output = input.clone(); diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index 7f7268691..f115bf5f7 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -2,7 +2,11 @@ //! //! [Control API]: https://tinyurl.com/yxsqplq7 -use std::{collections::HashMap, convert::TryFrom, sync::Arc}; +use std::{ + collections::HashMap, + convert::{From, TryFrom}, + sync::Arc, +}; use actix::{ Actor, Addr, Arbiter, Context, Handler, MailboxError, ResponseFuture, @@ -39,7 +43,6 @@ use crate::{ }, AppContext, }; -use std::convert::From; /// Errors which can happen while processing requests to gRPC [Control API]. /// @@ -87,6 +90,8 @@ struct ControlApiService { } impl ControlApiService { + // TODO: move to room_service, grpc might not be the only ControlApi + // protocol, and this logic will should be shared /// Returns [Control API] sid based on provided arguments and /// `MEDEA_SERVER__CLIENT__HTTP__PUBLIC_URL` config value. fn get_sid( diff --git a/src/api/control/refs/fid.rs b/src/api/control/refs/fid.rs index b202b1e49..ca3186f83 100644 --- a/src/api/control/refs/fid.rs +++ b/src/api/control/refs/fid.rs @@ -95,6 +95,7 @@ impl TryFrom for StatefulFid { fn try_from(value: String) -> Result { if value.is_empty() { + // TODO: not an error but rather Fid return Err(ParseFidError::Empty); } @@ -154,7 +155,7 @@ mod specs { #[test] fn returns_error_on_missing_path() { - for fid_str in vec![ + for fid_str in &[ "room_id//endpoint_id", "//endpoint_id", "//member_id/endpoint_id", @@ -172,7 +173,7 @@ mod specs { #[test] fn returns_error_on_too_many_paths() { - for fid_str in vec![ + for fid_str in &[ "room_id/member_id/endpoint_id/something_else", "room_id/member_id/endpoint_id/", "room_id/member_id/endpoint_id////", @@ -238,7 +239,7 @@ mod specs { #[test] fn serializes_into_original_fid() { - for fid_str in vec![ + for fid_str in &[ "room_id", "room_id/member_id", "room_id/member_id/endpoint_id", diff --git a/src/api/control/refs/local_uri.rs b/src/api/control/refs/local_uri.rs index df097b0ab..490496c22 100644 --- a/src/api/control/refs/local_uri.rs +++ b/src/api/control/refs/local_uri.rs @@ -351,7 +351,7 @@ mod specs { #[test] fn properly_serialize() { - for local_uri_str in vec![ + for local_uri_str in &[ "local://room_id", "local://room_id/member_id", "local://room_id/member_id/endpoint_id", @@ -364,7 +364,7 @@ mod specs { #[test] fn return_error_when_local_uri_not_full() { - for local_uri_str in vec![ + for local_uri_str in &[ "local://room_id//endpoint_id", "local:////endpoint_id", "local:///member_id/endpoint_id", diff --git a/src/signalling/room.rs b/src/signalling/room.rs index b0507b717..a1c586896 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -478,31 +478,30 @@ impl Room { first_peer: PeerId, second_peer: PeerId, ) { - let fut: ActFuture<(), ()> = - match self.send_peer_created(first_peer, second_peer) { - Ok(res) => { - Box::new(res.then(|res, room, ctx| -> ActFuture<(), ()> { - if res.is_ok() { - return Box::new(future::ok(()).into_actor(room)); - } - error!( - "Failed connect peers, because {}. Room [id = {}] \ - will be stopped.", - res.unwrap_err(), - room.id, - ); - room.close_gracefully(ctx) - })) - } - Err(err) => { + let fut = match self.send_peer_created(first_peer, second_peer) { + Ok(res) => { + Box::new(res.then(|res, room, ctx| -> ActFuture<(), ()> { + if res.is_ok() { + return Box::new(future::ok(()).into_actor(room)); + } error!( "Failed connect peers, because {}. Room [id = {}] \ will be stopped.", - err, self.id, + res.unwrap_err(), + room.id, ); - self.close_gracefully(ctx) - } - }; + room.close_gracefully(ctx) + })) + } + Err(err) => { + error!( + "Failed connect peers, because {}. Room [id = {}] will be \ + stopped.", + err, self.id, + ); + self.close_gracefully(ctx) + } + }; ctx.spawn(fut); } @@ -877,6 +876,11 @@ impl Into for &mut Room { } } +// TODO: Tightly coupled with protobuf. +// We should name this method GetElements, that will return some +// intermediate DTO, that will be serialized at the caller side. +// But lets leave it as it is for now. + /// Message for serializing this [`Room`] and [`Room`]'s elements to protobuf /// spec. #[derive(Message)] diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index 7b0717e9a..ce394f153 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -400,11 +400,11 @@ impl Handler> for RoomService { > = msg .fids .into_iter() - .filter_map(|l| { - if let StatefulFid::Room(room_id) = l { + .filter_map(|fid| { + if let StatefulFid::Room(room_id) = fid { Some(self.close_room(room_id.take_room_id())) } else { - deletes_from_room.push(l); + deletes_from_room.push(fid); None } }) diff --git a/tests/e2e/signalling/three_pubs.rs b/tests/e2e/signalling/three_pubs.rs index 75c73a7c5..21562001f 100644 --- a/tests/e2e/signalling/three_pubs.rs +++ b/tests/e2e/signalling/three_pubs.rs @@ -6,6 +6,7 @@ use medea_client_api_proto::{Direction, Event, PeerId}; use crate::signalling::{CloseSocket, TestMember}; #[test] +#[allow(clippy::too_many_lines)] fn three_members_p2p_video_call() { System::run(|| { let base_url = "ws://127.0.0.1:8080/ws/three-members-conference"; From a15e47c632889019a111cb5a1ce57d07b2ac912e Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 18 Oct 2019 15:31:56 +0300 Subject: [PATCH 722/735] Move sids to room_service --- src/api/control/error_codes.rs | 10 ++--- src/api/control/grpc/server.rs | 75 +++++----------------------------- src/bin/client.rs | 6 +-- src/signalling/room_service.rs | 71 +++++++++++++++++++++++++++----- 4 files changed, 78 insertions(+), 84 deletions(-) diff --git a/src/api/control/error_codes.rs b/src/api/control/error_codes.rs index 4cd7bb9c8..61e675576 100644 --- a/src/api/control/error_codes.rs +++ b/src/api/control/error_codes.rs @@ -448,9 +448,9 @@ impl From for ErrorResponse { ), None, ), - RoomMailboxErr(_) | FailedToLoadStaticSpecs(_) => { - Self::unexpected(&err) - } + RoomMailboxErr(_) + | FailedToLoadStaticSpecs(_) + | TryFromElement(_) => Self::unexpected(&err), } } } @@ -463,9 +463,7 @@ impl From for ErrorResponse { Fid(e) => e.into(), TryFromProtobuf(e) => e.into(), RoomServiceError(e) => e.into(), - RoomServiceMailboxError(_) | TryFromElement(_) => { - Self::unexpected(&err) - } + RoomServiceMailboxError(_) => Self::unexpected(&err), } } } diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index f115bf5f7..3894fd25e 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -13,7 +13,7 @@ use actix::{ }; use derive_more::{Display, From}; use failure::Fail; -use futures::future::{self, Either, Future, IntoFuture}; +use futures::future::{self, Future, IntoFuture}; use grpcio::{Environment, RpcContext, Server, ServerBuilder, UnarySink}; use medea_control_api_proto::grpc::{ api::{ @@ -32,14 +32,14 @@ use crate::{ ErrorResponse, }, refs::{fid::ParseFidError, Fid, StatefulFid, ToMember, ToRoom}, - EndpointId, EndpointSpec, MemberId, MemberSpec, RoomId, RoomSpec, - TryFromElementError, TryFromProtobufError, + EndpointId, EndpointSpec, MemberId, MemberSpec, RoomSpec, + TryFromProtobufError, }, log::prelude::*, shutdown::ShutdownGracefully, signalling::room_service::{ CreateEndpointInRoom, CreateMemberInRoom, CreateRoom, DeleteElements, - Get, RoomService, RoomServiceError, + Get, RoomService, RoomServiceError, Sids, }, AppContext, }; @@ -59,13 +59,6 @@ pub enum GrpcControlApiError { /// [medea]: https://github.com/instrumentisto/medea TryFromProtobuf(TryFromProtobufError), - /// This is __unexpected error__ because this kind of errors - /// should be catched by `try_from_protobuf` function which returns - /// [`TryFromProtobufError`]. - /// - /// [Control API]: https://tinyurl.com/yxsqplq7 - TryFromElement(TryFromElementError), - /// [`MailboxError`] for [`RoomService`]. #[display(fmt = "Room service mailbox error: {:?}", _0)] RoomServiceMailboxError(MailboxError), @@ -74,9 +67,6 @@ pub enum GrpcControlApiError { RoomServiceError(RoomServiceError), } -/// Type alias for success [`CreateResponse`]'s sids. -type Sids = HashMap; - /// Service which provides gRPC [Control API] implementation. #[derive(Clone)] struct ControlApiService { @@ -90,54 +80,15 @@ struct ControlApiService { } impl ControlApiService { - // TODO: move to room_service, grpc might not be the only ControlApi - // protocol, and this logic will should be shared - /// Returns [Control API] sid based on provided arguments and - /// `MEDEA_SERVER__CLIENT__HTTP__PUBLIC_URL` config value. - fn get_sid( - &self, - room_id: &RoomId, - member_id: &MemberId, - credentials: &str, - ) -> String { - format!( - "{}/{}/{}/{}", - self.public_url, room_id, member_id, credentials - ) - } - /// Implementation of `Create` method for [`Room`]. fn create_room( &self, spec: RoomSpec, ) -> impl Future { - let sid = match spec.members() { - Ok(members) => members - .iter() - .map(|(member_id, member)| { - let uri = self.get_sid( - spec.id(), - &member_id, - member.credentials(), - ); - (member_id.clone().to_string(), uri) - }) - .collect(), - Err(e) => { - return Either::B(future::err( - GrpcControlApiError::TryFromElement(e), - )) - } - }; - - Either::A( - self.room_service - .send(CreateRoom { spec }) - .map_err(GrpcControlApiError::RoomServiceMailboxError) - .and_then(move |r| { - r.map_err(GrpcControlApiError::from).map(|_| sid) - }), - ) + self.room_service + .send(CreateRoom { spec }) + .map_err(GrpcControlApiError::RoomServiceMailboxError) + .and_then(move |r| r.map_err(GrpcControlApiError::from)) } /// Implementation of `Create` method for [`Member`] element. @@ -147,10 +98,6 @@ impl ControlApiService { uri: Fid, spec: MemberSpec, ) -> impl Future { - let sid = self.get_sid(uri.room_id(), &id, spec.credentials()); - let mut sids = HashMap::new(); - sids.insert(id.to_string(), sid); - self.room_service .send(CreateMemberInRoom { id, @@ -158,7 +105,7 @@ impl ControlApiService { spec, }) .map_err(GrpcControlApiError::RoomServiceMailboxError) - .and_then(|r| r.map_err(GrpcControlApiError::from).map(|_| sids)) + .and_then(|r| r.map_err(GrpcControlApiError::from)) } /// Implementation of `Create` method for [`Endpoint`] element. @@ -175,9 +122,7 @@ impl ControlApiService { spec, }) .map_err(GrpcControlApiError::RoomServiceMailboxError) - .and_then(|r| { - r.map_err(GrpcControlApiError::from).map(|_| HashMap::new()) - }) + .and_then(|r| r.map_err(GrpcControlApiError::from)) } /// Creates element based on provided [`CreateRequest`]. diff --git a/src/bin/client.rs b/src/bin/client.rs index 1672b3444..909f53b61 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -26,12 +26,12 @@ fn main() { // unimplemented_apply(&client); create_room(&client); + create_member(&client); + create_endpoint(&client); // delete_room(&client); // delete_endpoint(&client); // delete_member(&client); - create_member(&client); - // create_endpoint(&client); - get_room(&client); + // get_room(&client); } fn create_room(client: &ControlApiClient) { diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index ce394f153..b373ba757 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -16,7 +16,7 @@ use crate::{ load_static_specs_from_dir, refs::{Fid, StatefulFid, ToMember, ToRoom}, EndpointId, LoadStaticControlSpecsError, MemberId, MemberSpec, RoomId, - RoomSpec, + RoomSpec, TryFromElementError, }, log::prelude::*, shutdown::{self, GracefulShutdown}, @@ -54,6 +54,13 @@ pub enum RoomServiceError { #[display(fmt = "{}", _0)] RoomError(RoomError), + /// Error which can happen while converting protobuf objects into interior + /// [medea] [Control API] objects. + /// + /// [Control API]: https://tinyurl.com/yxsqplq7 + /// [medea]: https://github.com/instrumentisto/medea + TryFromElement(TryFromElementError), + /// Error which can happen while loading static [Control API] specs. /// /// [Control API]: https://tinyurl.com/yxsqplq7 @@ -107,6 +114,11 @@ pub struct RoomService { /// /// [Control API]: https://tinyurl.com/yxsqplq7 static_specs_dir: String, + + /// Public URL of server. Address for exposed [Client API]. + /// + /// [Client API]: https://tinyurl.com/yx9thsnr + public_url: String, } impl RoomService { @@ -118,6 +130,7 @@ impl RoomService { ) -> Self { Self { static_specs_dir: app.config.control.static_specs_dir.clone(), + public_url: app.config.server.client.http.public_url.clone(), room_repo, app, graceful_shutdown, @@ -148,6 +161,20 @@ impl RoomService { Box::new(futures::future::ok(())) } } + + /// Returns [Control API] sid based on provided arguments and + /// `MEDEA_SERVER__CLIENT__HTTP__PUBLIC_URL` config value. + fn get_sid( + &self, + room_id: &RoomId, + member_id: &MemberId, + credentials: &str, + ) -> String { + format!( + "{}/{}/{}/{}", + self.public_url, room_id, member_id, credentials + ) + } } impl Actor for RoomService { @@ -191,9 +218,12 @@ impl Handler for RoomService { } } +/// Type alias for success [`CreateResponse`]'s sids. +pub type Sids = HashMap; + /// Signal for creating new [`Room`]. #[derive(Message)] -#[rtype(result = "Result<(), RoomServiceError>")] +#[rtype(result = "Result")] pub struct CreateRoom { /// [Control API] spec for [`Room`]. /// @@ -202,7 +232,7 @@ pub struct CreateRoom { } impl Handler for RoomService { - type Result = Result<(), RoomServiceError>; + type Result = Result; fn handle( &mut self, @@ -210,6 +240,20 @@ impl Handler for RoomService { _: &mut Self::Context, ) -> Self::Result { let room_spec = msg.spec; + let sid = match room_spec.members() { + Ok(members) => members + .iter() + .map(|(member_id, member)| { + let uri = self.get_sid( + room_spec.id(), + &member_id, + member.credentials(), + ); + (member_id.clone().to_string(), uri) + }) + .collect(), + Err(e) => return Err(RoomServiceError::TryFromElement(e)), + }; if self.room_repo.get(&room_spec.id).is_some() { return Err(RoomServiceError::RoomAlreadyExists( @@ -229,7 +273,7 @@ impl Handler for RoomService { debug!("New Room [id = {}] started.", room_spec.id); self.room_repo.add(room_spec.id, room_addr); - Ok(()) + Ok(sid) } } @@ -237,7 +281,7 @@ impl Handler for RoomService { /// /// [`Member`]: crate::signalling::elements::member::Member #[derive(Message)] -#[rtype(result = "Result<(), RoomServiceError>")] +#[rtype(result = "Result")] pub struct CreateMemberInRoom { pub id: MemberId, pub parent_fid: Fid, @@ -245,7 +289,7 @@ pub struct CreateMemberInRoom { } impl Handler for RoomService { - type Result = ResponseFuture<(), RoomServiceError>; + type Result = ResponseFuture; fn handle( &mut self, @@ -253,12 +297,17 @@ impl Handler for RoomService { _: &mut Self::Context, ) -> Self::Result { let room_id = msg.parent_fid.take_room_id(); + let sid = self.get_sid(&room_id, &msg.id, msg.spec.credentials()); + let mut sids = HashMap::new(); + sids.insert(msg.id.to_string(), sid); if let Some(room) = self.room_repo.get(&room_id) { Box::new( room.send(CreateMember(msg.id, msg.spec)) .map_err(RoomServiceError::RoomMailboxErr) - .and_then(|r| r.map_err(RoomServiceError::from)), + .and_then(move |r| { + r.map_err(RoomServiceError::from).map(move |_| sids) + }), ) } else { Box::new(future::err(RoomServiceError::RoomNotFound( @@ -272,7 +321,7 @@ impl Handler for RoomService { /// /// [`Endpoint`]: crate::signalling::elements::endpoints::Endpoint #[derive(Message)] -#[rtype(result = "Result<(), RoomServiceError>")] +#[rtype(result = "Result")] pub struct CreateEndpointInRoom { pub id: EndpointId, pub parent_fid: Fid, @@ -280,7 +329,7 @@ pub struct CreateEndpointInRoom { } impl Handler for RoomService { - type Result = ResponseFuture<(), RoomServiceError>; + type Result = ResponseFuture; fn handle( &mut self, @@ -298,7 +347,9 @@ impl Handler for RoomService { spec: msg.spec, }) .map_err(RoomServiceError::RoomMailboxErr) - .and_then(|r| r.map_err(RoomServiceError::from)), + .and_then(|r| { + r.map_err(RoomServiceError::from).map(|_| HashMap::new()) + }), ) } else { Box::new(future::err(RoomServiceError::RoomNotFound( From 0da8c7af42ca8426e722cf29ad10797a649bc9ee Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 18 Oct 2019 15:41:11 +0300 Subject: [PATCH 723/735] Create Room on empty unparsed FID [run ci] --- src/api/control/grpc/server.rs | 27 +++++++++++++-------------- src/api/control/refs/fid.rs | 1 - 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index 3894fd25e..6c0cb2e85 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -140,23 +140,22 @@ impl ControlApiService { ))); }; + if unparsed_parent_fid.is_empty() { + return Box::new( + RoomSpec::try_from(elem) + .map_err(ErrorResponse::from) + .map(|spec| { + self.create_room(spec).map_err(ErrorResponse::from) + }) + .into_future() + .and_then(|create_result| create_result), + ); + } + let parent_fid = match StatefulFid::try_from(unparsed_parent_fid) { Ok(parent_fid) => parent_fid, Err(e) => { - if let ParseFidError::Empty = e { - return Box::new( - RoomSpec::try_from(elem) - .map_err(ErrorResponse::from) - .map(|spec| { - self.create_room(spec) - .map_err(ErrorResponse::from) - }) - .into_future() - .and_then(|create_result| create_result), - ); - } else { - return Box::new(future::err(e.into())); - } + return Box::new(future::err(e.into())); } }; diff --git a/src/api/control/refs/fid.rs b/src/api/control/refs/fid.rs index ca3186f83..ee5d873fa 100644 --- a/src/api/control/refs/fid.rs +++ b/src/api/control/refs/fid.rs @@ -95,7 +95,6 @@ impl TryFrom for StatefulFid { fn try_from(value: String) -> Result { if value.is_empty() { - // TODO: not an error but rather Fid return Err(ParseFidError::Empty); } From 48d7d8a0bdbe3bbba5e3e09ebbdaeeb165a1d015 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 18 Oct 2019 16:02:30 +0300 Subject: [PATCH 724/735] Use alexlapa in Jason Dockerfile [run ci] --- jason/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jason/Dockerfile b/jason/Dockerfile index 2b41211bc..35cb02f4f 100644 --- a/jason/Dockerfile +++ b/jason/Dockerfile @@ -8,7 +8,7 @@ # # https://hub.docker.com/_/rust -FROM rust:stretch AS dist +FROM alexlapa/rust-beta:1.39-beta.5 AS dist RUN cargo install wasm-pack \ && rustup target add wasm32-unknown-unknown From e6148b47939858e7a41a2d410d94f64ae44b0d19 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 18 Oct 2019 16:04:35 +0300 Subject: [PATCH 725/735] Fix log level in config [run ci] --- src/main.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index 474f9fdff..6ba2848c2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -15,13 +15,16 @@ use medea::{ fn main() -> Result<(), Error> { dotenv::dotenv().ok(); + let config = Conf::parse()?; + info!("{:?}", config); + if let Some(lvl) = config.log.level() { + std::env::set_var("RUST_LOG", lvl.as_str()); + } + let logger = log::new_dual_logger(std::io::stdout(), std::io::stderr()); let _scope_guard = slog_scope::set_global_logger(logger); slog_stdlog::init()?; - let config = Conf::parse()?; - info!("{:?}", config); - actix::run(move || { new_turn_auth_service(&config.turn) .map_err(move |e| error!("{:?}", e)) From 66d2e8448793c2822805265a37bdbb769354be10 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 18 Oct 2019 16:52:27 +0300 Subject: [PATCH 726/735] Run rustfmt on latests nightly [run ci] --- jason/src/api/room.rs | 12 ++++++------ jason/src/media/manager.rs | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/jason/src/api/room.rs b/jason/src/api/room.rs index 4905e1f08..1d994ae6d 100644 --- a/jason/src/api/room.rs +++ b/jason/src/api/room.rs @@ -286,12 +286,12 @@ impl EventHandler for InnerRoom { }; Result::<_, WasmErr>::Ok(()) } - .then(|result| { - if let Err(err) = result { - err.log_err(); - }; - future::ready(()) - }), + .then(|result| { + if let Err(err) = result { + err.log_err(); + }; + future::ready(()) + }), ); } diff --git a/jason/src/media/manager.rs b/jason/src/media/manager.rs index d9d1f2d0b..06a926ff7 100644 --- a/jason/src/media/manager.rs +++ b/jason/src/media/manager.rs @@ -194,12 +194,12 @@ impl MediaManager { Ok(stream) } - .await - .map(Rc::new) - .map_err(move |err: WasmErr| { - inner.on_local_stream.call2(err.clone()); - err - }) + .await + .map(Rc::new) + .map_err(move |err: WasmErr| { + inner.on_local_stream.call2(err.clone()); + err + }) } /// Obtains [MediaStream][1] basing on provided [`MediaStreamConstraints`]. From 2e68c9492649bf4347df668c24b5ee54f17bac3c Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 18 Oct 2019 16:54:12 +0300 Subject: [PATCH 727/735] Remove allow failure from rustfmt [run ci] --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6550d877c..224ff9b55 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,8 +20,6 @@ stages: jobs: allow_failures: - - rust: nightly - stage: check - rust: nightly stage: build From 45ed048620e5ca8361775a569844b1d9055ec5dd Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 18 Oct 2019 16:59:00 +0300 Subject: [PATCH 728/735] Small naming changes [run ci] --- src/api/control/grpc/server.rs | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/api/control/grpc/server.rs b/src/api/control/grpc/server.rs index 6c0cb2e85..034af56bc 100644 --- a/src/api/control/grpc/server.rs +++ b/src/api/control/grpc/server.rs @@ -95,13 +95,13 @@ impl ControlApiService { fn create_member( &self, id: MemberId, - uri: Fid, + parent_fid: Fid, spec: MemberSpec, ) -> impl Future { self.room_service .send(CreateMemberInRoom { id, - parent_fid: uri, + parent_fid, spec, }) .map_err(GrpcControlApiError::RoomServiceMailboxError) @@ -112,13 +112,13 @@ impl ControlApiService { fn create_endpoint( &self, id: EndpointId, - uri: Fid, + parent_fid: Fid, spec: EndpointSpec, ) -> impl Future { self.room_service .send(CreateEndpointInRoom { id, - parent_fid: uri, + parent_fid, spec, }) .map_err(GrpcControlApiError::RoomServiceMailboxError) @@ -160,14 +160,14 @@ impl ControlApiService { }; match parent_fid { - StatefulFid::Room(uri) => match elem { + StatefulFid::Room(parent_fid) => match elem { CreateRequestOneof::member(mut member) => { let id: MemberId = member.take_id().into(); Box::new( MemberSpec::try_from(member) .map_err(ErrorResponse::from) .map(|spec| { - self.create_member(id, uri, spec) + self.create_member(id, parent_fid, spec) .map_err(ErrorResponse::from) }) .into_future() @@ -176,10 +176,10 @@ impl ControlApiService { } _ => Box::new(future::err(ErrorResponse::new( ElementIdMismatch, - &uri, + &parent_fid, ))), }, - StatefulFid::Member(uri) => { + StatefulFid::Member(parent_fid) => { let (endpoint, id) = match elem { CreateRequestOneof::webrtc_play(mut play) => ( WebRtcPlayEndpoint::try_from(&play) @@ -194,7 +194,7 @@ impl ControlApiService { _ => { return Box::new(future::err(ErrorResponse::new( ElementIdMismatch, - &uri, + &parent_fid, ))) } }; @@ -202,7 +202,7 @@ impl ControlApiService { endpoint .map_err(ErrorResponse::from) .map(move |spec| { - self.create_endpoint(id, uri, spec) + self.create_endpoint(id, parent_fid, spec) .map_err(ErrorResponse::from) }) .into_future() @@ -223,8 +223,8 @@ impl ControlApiService { let mut delete_elements_msg = DeleteElements::new(); for id in req.take_fid().into_iter() { match StatefulFid::try_from(id) { - Ok(uri) => { - delete_elements_msg.add_fid(uri); + Ok(fid) => { + delete_elements_msg.add_fid(fid); } Err(e) => { return future::Either::A(future::err(e.into())); @@ -255,11 +255,11 @@ impl ControlApiService { mut req: IdRequest, ) -> impl Future, Error = ErrorResponse> { - let mut uris = Vec::new(); + let mut fids = Vec::new(); for id in req.take_fid().into_iter() { match StatefulFid::try_from(id) { - Ok(uri) => { - uris.push(uri); + Ok(fid) => { + fids.push(fid); } Err(e) => { return future::Either::A(future::err(e.into())); @@ -269,7 +269,7 @@ impl ControlApiService { future::Either::B( self.room_service - .send(Get(uris)) + .send(Get(fids)) .map_err(GrpcControlApiError::RoomServiceMailboxError) .and_then(|r| r.map_err(GrpcControlApiError::from)) .map(|elements: HashMap| { From f8f7cc95e72b2359d42516aef183b4809901d86b Mon Sep 17 00:00:00 2001 From: alexlapa Date: Mon, 21 Oct 2019 00:31:35 +0300 Subject: [PATCH 729/735] extend grpc e2e tests [run ci] --- Cargo.lock | 135 +++++++++++---------- tests/e2e/grpc_control_api/signaling.rs | 155 +++++++++++++++++++++--- 2 files changed, 210 insertions(+), 80 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 234f8af6d..9832cc1be 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -93,7 +93,7 @@ dependencies = [ "hashbrown 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "http 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", "httparse 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "indexmap 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -305,7 +305,7 @@ name = "actix-web-codegen" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -361,13 +361,13 @@ name = "atty" version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "autocfg" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -399,7 +399,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "backtrace-sys 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -409,7 +409,7 @@ version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.46 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -462,7 +462,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.46 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -471,7 +471,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "brotli-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -517,7 +517,7 @@ name = "chrono" version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", "num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", @@ -669,7 +669,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "ident_case 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "strsim 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -690,7 +690,7 @@ name = "derive-new" version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -702,7 +702,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "darling 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "derive_builder_core 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -713,7 +713,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "darling 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -752,7 +752,7 @@ name = "dirs" version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", "redox_users 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -826,7 +826,7 @@ name = "failure_derive" version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "synstructure 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -839,7 +839,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", "miniz-sys 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "miniz_oxide 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -958,7 +958,7 @@ version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", "wasi 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -969,7 +969,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "grpcio-sys 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.8.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -992,7 +992,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.46 (registry+https://github.com/rust-lang/crates.io-index)", "cmake 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1006,7 +1006,7 @@ dependencies = [ "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "http 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", - "indexmap 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "string 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1036,7 +1036,7 @@ name = "hostname" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", "winutil 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1099,15 +1099,18 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "iovec" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1160,7 +1163,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libc" -version = "0.2.64" +version = "0.2.65" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1316,7 +1319,7 @@ name = "medea-macro" version = "0.1.0" dependencies = [ "Inflector 0.11.4 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1361,7 +1364,7 @@ version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.46 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1381,7 +1384,7 @@ dependencies = [ "fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1395,7 +1398,7 @@ version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1430,7 +1433,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1441,7 +1444,7 @@ version = "0.2.33" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1477,7 +1480,7 @@ name = "num-integer" version = "0.1.41" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1494,7 +1497,7 @@ name = "num-traits" version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1502,7 +1505,7 @@ name = "num_cpus" version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1532,7 +1535,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1547,7 +1550,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1615,7 +1618,7 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.5" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1673,7 +1676,7 @@ name = "quote" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1681,7 +1684,7 @@ name = "rand" version = "0.3.23" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1691,7 +1694,7 @@ version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1702,8 +1705,8 @@ name = "rand" version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1721,7 +1724,7 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "getrandom 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1732,7 +1735,7 @@ name = "rand_chacha" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1795,7 +1798,7 @@ name = "rand_jitter" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1807,7 +1810,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1818,7 +1821,7 @@ name = "rand_pcg" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1923,7 +1926,7 @@ version = "0.2.36" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.23 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2023,7 +2026,7 @@ name = "serde_derive" version = "1.0.101" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2095,7 +2098,7 @@ name = "signal-hook" version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", "signal-hook-registry 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2105,7 +2108,7 @@ version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arc-swap 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2207,7 +2210,7 @@ version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2245,7 +2248,7 @@ name = "syn" version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2255,7 +2258,7 @@ name = "synstructure" version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2272,7 +2275,7 @@ version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", "remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2318,7 +2321,7 @@ name = "time" version = "0.1.42" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2418,7 +2421,7 @@ version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", "mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", "signal-hook 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2499,7 +2502,7 @@ dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", "mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2664,7 +2667,7 @@ dependencies = [ "bumpalo 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-shared 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2695,7 +2698,7 @@ name = "wasm-bindgen-macro-support" version = "0.2.51" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-backend 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2725,7 +2728,7 @@ name = "wasm-bindgen-test-macro" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2737,7 +2740,7 @@ dependencies = [ "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-backend 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2762,7 +2765,7 @@ version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", "memory_units 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2885,7 +2888,7 @@ dependencies = [ "checksum arrayvec 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "cd9fd44efafa8690358b7408d253adf110036b88f55672a933f01d616ad9b1b9" "checksum ascii 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "eab1c04a571841102f5345a8fc0f6bb3d31c315dec879b5c6e42e40ce7ffa34e" "checksum atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1803c647a3ec87095e7ae7acfca019e98de5ec9a7d01343f611cf3152ed71a90" -"checksum autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "b671c8fb71b457dd4ae18c4ba1e59aa81793daacc361d82fcd410cef0d491875" +"checksum autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" "checksum awc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "364537de6ac9f996780f9dd097d6c4ca7c91dd5735153e9fb545037479becd10" "checksum backtrace 0.3.40 (registry+https://github.com/rust-lang/crates.io-index)" = "924c76597f0d9ca25d762c25a4d369d51267536465dc5064bdf0eb073ed477ea" "checksum backtrace-sys 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)" = "5d6575f128516de27e3ce99689419835fce9643a9b215a14d2b5b685be018491" @@ -2968,7 +2971,7 @@ dependencies = [ "checksum ident_case 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" "checksum idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e" "checksum idna 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "02e2673c30ee86b5b96a9cb52ad15718aa1f966f5ab9ad54a8b95d5ca33120a9" -"checksum indexmap 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a61202fbe46c4a951e9404a720a0180bcf3212c750d735cb5c4ba4dc551299f3" +"checksum indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712d7b3ea5827fcb9d4fda14bf4da5f136f0db2ae9c8f4bd4e2d1c6fde4e6db2" "checksum iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" "checksum ipconfig 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "aa79fa216fbe60834a9c0737d7fcd30425b32d1c58854663e24d4c4b328ed83f" "checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" @@ -2977,7 +2980,7 @@ dependencies = [ "checksum language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a91d884b6667cd606bb5a69aa0c99ba811a115fc68915e7056ec08a46e93199a" "checksum lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "76f033c7ad61445c5b347c7382dd1237847eb1bce590fe50365dcb33d546be73" "checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" -"checksum libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)" = "74dfca3d9957906e8d1e6a0b641dc9a59848e793f1da2165889fd4f62d10d79c" +"checksum libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)" = "1a31a0627fdf1f6a39ec0dd577e101440b7db22672c0901fe00a9a6fbb5c24e8" "checksum linked-hash-map 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6d262045c5b87c0861b3f004610afd0e2c851e2908d08b6c870cbb9d5f494ecd" "checksum linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ae91b68aebc4ddb91978b11a1b02ddd8602a05ec19002801c5666000e05e0f83" "checksum lock_api 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ed946d4529956a20f2d63ebe1b69996d5a2137c91913fe3ebbeff957f5bca7ff" @@ -3020,7 +3023,7 @@ dependencies = [ "checksum predicates-core 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "06075c3a3e92559ff8929e7a280684489ea27fe44805174c3ebd9328dcb37178" "checksum predicates-tree 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8e63c4859013b38a76eca2414c64911fba30def9e3202ac461a2d22831220124" "checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" -"checksum proc-macro2 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "90cf5f418035b98e655e9cdb225047638296b862b42411c4e45bb88d700f7fc0" +"checksum proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "9c9e470a8dc4aeae2dee2f335e8f533e2d4b347e1434e5671afc49b054592f27" "checksum protobuf 2.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "40361836defdd5871ff7e84096c6f6444af7fc157f8ef1789f54f147687caa20" "checksum protobuf-codegen 2.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "12c6abd78435445fc86898ebbd0521a68438063d4a73e23527b7134e6bf58b4a" "checksum protoc 2.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3998c4bc0af8ccbd3cc68245ee9f72663c5ae2fb78bc48ff7719aef11562edea" diff --git a/tests/e2e/grpc_control_api/signaling.rs b/tests/e2e/grpc_control_api/signaling.rs index d8ecafc37..11c7e0131 100644 --- a/tests/e2e/grpc_control_api/signaling.rs +++ b/tests/e2e/grpc_control_api/signaling.rs @@ -19,6 +19,21 @@ use super::{ WebRtcPublishEndpointBuilder, }; +fn stop_on_peer_created( +) -> impl Fn(&Event, &mut Context, Vec<&Event>) + Clone { + let peers_created = Rc::new(Cell::new(0)); + move |event: &Event, ctx: &mut Context, _: Vec<&Event>| { + if let Event::PeerCreated { .. } = event { + peers_created.set(peers_created.get() + 1); + if peers_created.get() == 2 { + ctx.run_later(Duration::from_secs(1), |_, _| { + actix::System::current().stop(); + }); + } + } + } +} + #[test] fn signalling_starts_when_create_play_member_after_pub_member() { gen_insert_str_macro!("create-play-member-after-pub-member"); @@ -48,20 +63,9 @@ fn signalling_starts_when_create_play_member_after_pub_member() { control_client.create(&create_room); - let peers_created = Rc::new(Cell::new(0)); - let on_event = - move |event: &Event, ctx: &mut Context, _: Vec<&Event>| { - if let Event::PeerCreated { .. } = event { - peers_created.set(peers_created.get() + 1); - if peers_created.get() == 2 { - ctx.run_later(Duration::from_secs(1), |_, _| { - actix::System::current().stop(); - }); - } - } - }; + let on_event = stop_on_peer_created(); - let deadline = Some(std::time::Duration::from_secs(5)); + let deadline = Some(Duration::from_secs(5)); Arbiter::spawn( TestMember::connect( &insert_str!("ws://127.0.0.1:8080/ws/{}/publisher/test"), @@ -96,7 +100,130 @@ fn signalling_starts_when_create_play_member_after_pub_member() { sys.run().unwrap(); } -// TODO: add signalling_starts_when_create_play_endpoint_after_pub_endpoint +#[test] +fn signalling_starts_when_create_play_endpoint_after_pub_member() { + gen_insert_str_macro!( + "signalling_starts_when_create_play_endpoint_after_pub_member" + ); + let sys = System::new(insert_str!("{}")); + + let control_client = ControlClient::new(); + + let create_room = RoomBuilder::default() + .id(insert_str!("{}")) + .add_member( + MemberBuilder::default() + .id("publisher") + .credentials("test") + .add_endpoint( + WebRtcPublishEndpointBuilder::default() + .id("publish") + .p2p_mode(WebRtcPublishEndpoint_P2P::ALWAYS) + .build() + .unwrap(), + ) + .build() + .unwrap(), + ) + .build() + .unwrap() + .build_request(""); + + control_client.create(&create_room); + + let on_event = stop_on_peer_created(); + + let deadline = Some(Duration::from_secs(5)); + Arbiter::spawn( + TestMember::connect( + &insert_str!("ws://127.0.0.1:8080/ws/{}/publisher/test"), + Box::new(on_event.clone()), + deadline, + ) + .and_then(move |_| { + let create_second_member = MemberBuilder::default() + .id("responder") + .credentials("qwerty") + .build() + .unwrap() + .build_request(insert_str!("{}")); + control_client.create(&create_second_member); + + let create_play = WebRtcPlayEndpointBuilder::default() + .id("play") + .src(insert_str!("local://{}/publisher/publish")) + .build() + .unwrap() + .build_request(insert_str!("{}/responder")); + + control_client.create(&create_play); + + TestMember::connect( + &insert_str!("ws://127.0.0.1:8080/ws/{}/responder/qwerty"), + Box::new(on_event), + deadline, + ) + }) + .map(|_| ()), + ); + + sys.run().unwrap(); +} + +#[test] +fn signalling_starts_in_loopback_scenario() { + gen_insert_str_macro!("signalling_starts_in_loopback_scenario"); + let sys = System::new(insert_str!("{}")); + + let control_client = ControlClient::new(); + + let create_room = RoomBuilder::default() + .id(insert_str!("{}")) + .add_member( + MemberBuilder::default() + .id("publisher") + .credentials("test") + .add_endpoint( + WebRtcPublishEndpointBuilder::default() + .id("publish") + .p2p_mode(WebRtcPublishEndpoint_P2P::ALWAYS) + .build() + .unwrap(), + ) + .build() + .unwrap(), + ) + .build() + .unwrap() + .build_request(""); + + control_client.create(&create_room); + + let on_event = stop_on_peer_created(); + + let deadline = Some(Duration::from_secs(5)); + Arbiter::spawn( + TestMember::connect( + &insert_str!("ws://127.0.0.1:8080/ws/{}/publisher/test"), + Box::new(on_event.clone()), + deadline, + ) + .and_then(move |_| { + let create_play = WebRtcPlayEndpointBuilder::default() + .id("play") + .src(insert_str!("local://{}/publisher/publish")) + .build() + .unwrap() + .build_request(insert_str!("{}/publisher")); + + control_client.create(&create_play); + Ok(()) + }) + .map(|_| ()), + ); + + sys.run().unwrap(); +} #[test] fn peers_removed_on_delete_member() { From d748f637ad89d0668b8207dfb74472af4abcbc25 Mon Sep 17 00:00:00 2001 From: tyranron Date: Fri, 25 Oct 2019 09:31:16 +0200 Subject: [PATCH 730/735] Bump up chart version to 0.2.0 --- jason/demo/chart/medea-demo/Chart.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jason/demo/chart/medea-demo/Chart.yaml b/jason/demo/chart/medea-demo/Chart.yaml index 23dffdd0a..2e1caae1c 100644 --- a/jason/demo/chart/medea-demo/Chart.yaml +++ b/jason/demo/chart/medea-demo/Chart.yaml @@ -1,4 +1,4 @@ apiVersion: v1 name: medea-demo -version: 0.1.1 +version: 0.2.0 appVersion: 0.1.0 From 5a0a946e79e91cd6347e2742c2af7a63b059f5d7 Mon Sep 17 00:00:00 2001 From: tyranron Date: Fri, 25 Oct 2019 09:31:34 +0200 Subject: [PATCH 731/735] Correct docs in proto spec --- proto/control-api/src/grpc/api.proto | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/proto/control-api/src/grpc/api.proto b/proto/control-api/src/grpc/api.proto index 9acf83263..4bdf05bf8 100644 --- a/proto/control-api/src/grpc/api.proto +++ b/proto/control-api/src/grpc/api.proto @@ -23,9 +23,9 @@ service ControlApi { rpc Get (IdRequest) returns (GetResponse); } -// Request of creating new Element with in element with given Full ID (FID). +// Request of creating new Element with in element with a given FID (full ID). message CreateRequest { - // Full ID (FID) of the Element in which will be created provided element. + // FID (full ID) of the Element in which the provided Element will be created. string parent_fid = 1; // Spec of the created Element. oneof el { @@ -36,9 +36,9 @@ message CreateRequest { } } -// Request with many Elements Full IDs (FIDs) elements. +// Request with many FIDs (full IDs) of Elements. message IdRequest { - // List of elements Full IDs (FIDs). + // List of Elements FIDs. repeated string fid = 1; } @@ -113,7 +113,7 @@ message Element { // interact with each other. message Room { // ID of this Room. - string id = 1; + string id = 1; // Pipeline of this Room. map pipeline = 2; From a3db13d7278e8d2495829dfc8c6aef86085396dc Mon Sep 17 00:00:00 2001 From: tyranron Date: Fri, 25 Oct 2019 10:31:31 +0200 Subject: [PATCH 732/735] Docs and code style corrections --- .travis.yml | 2 ++ CHANGELOG.md | 2 +- src/api/client/session.rs | 2 +- src/api/control/endpoints/mod.rs | 4 ++-- src/api/control/refs/fid.rs | 4 +++- src/api/control/room.rs | 2 +- src/conf/server.rs | 2 +- src/lib.rs | 7 ++++--- src/main.rs | 2 ++ src/signalling/elements/member.rs | 6 +++--- src/signalling/participants.rs | 8 ++++---- src/signalling/room.rs | 28 ++++++++++++++++++++-------- src/signalling/room_service.rs | 3 +-- 13 files changed, 45 insertions(+), 27 deletions(-) diff --git a/.travis.yml b/.travis.yml index 224ff9b55..6550d877c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,6 +20,8 @@ stages: jobs: allow_failures: + - rust: nightly + stage: check - rust: nightly stage: build diff --git a/CHANGELOG.md b/CHANGELOG.md index 70b1735b1..73b87f9c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,7 +19,7 @@ All user visible changes to this project will be documented in this file. This p ### Added - Control API: - - Support for static Сontrol API specs ([#28]). + - Support for static Сontrol API specs ([#28]); - Dynamic Control API exposed via gRPC ([#33]): - `Create` method for `Room`, `Member`, `Endpoint`; - `Get` method for `Room`, `Member`, `Endpoint`; diff --git a/src/api/client/session.rs b/src/api/client/session.rs index 755f72d73..5a18e29a6 100644 --- a/src/api/client/session.rs +++ b/src/api/client/session.rs @@ -99,7 +99,7 @@ impl Actor for WsSession { /// Starts [`Heartbeat`] mechanism and sends [`RpcConnectionEstablished`] /// signal to the [`Room`]. fn started(&mut self, ctx: &mut Self::Context) { - debug!("Started WsSession for Member [id = {}]", self.member_id); + debug!("Started WsSession for member {}", self.member_id); self.start_watchdog(ctx); diff --git a/src/api/control/endpoints/mod.rs b/src/api/control/endpoints/mod.rs index 764e757ac..08f913ade 100644 --- a/src/api/control/endpoints/mod.rs +++ b/src/api/control/endpoints/mod.rs @@ -1,6 +1,6 @@ -//! Endpoint elements of [medea] spec. +//! Endpoint elements of [Medea] spec. //! -//! [medea]: https://github.com/instrumentisto/medea +//! [Medea]: https://github.com/instrumentisto/medea pub mod webrtc_play_endpoint; pub mod webrtc_publish_endpoint; diff --git a/src/api/control/refs/fid.rs b/src/api/control/refs/fid.rs index ee5d873fa..9071fec3a 100644 --- a/src/api/control/refs/fid.rs +++ b/src/api/control/refs/fid.rs @@ -25,7 +25,9 @@ pub enum ParseFidError { MissingPath(String), } -/// Full ID (`fid` in dynamic Control API specs). +/// FID (full ID, or `fid` in Control API specs) is a composition of +/// media elements IDs, which refers to some media element on a whole server +/// uniquely. #[derive(Clone, Debug, Eq, Hash, PartialEq)] pub struct Fid { state: T, diff --git a/src/api/control/room.rs b/src/api/control/room.rs index cca7366b4..b7f32079c 100644 --- a/src/api/control/room.rs +++ b/src/api/control/room.rs @@ -7,7 +7,7 @@ use std::{collections::HashMap, convert::TryFrom}; use derive_more::{Display, From}; #[rustfmt::skip] use medea_control_api_proto::grpc::api::{ - CreateRequest_oneof_el as ElementProto + CreateRequest_oneof_el as ElementProto, }; use serde::Deserialize; diff --git a/src/conf/server.rs b/src/conf/server.rs index a621f89c6..a88582bd8 100644 --- a/src/conf/server.rs +++ b/src/conf/server.rs @@ -111,7 +111,7 @@ pub struct Server { } #[cfg(test)] -mod server_spec { +mod client_http_spec { use std::net::Ipv4Addr; use serial_test_derive::serial; diff --git a/src/lib.rs b/src/lib.rs index f10016153..8e0085d48 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,4 @@ -//! Medea media server application. +//! Medea media server. #[macro_use] pub mod utils; @@ -14,8 +14,8 @@ use std::sync::Arc; use crate::{conf::Conf, turn::TurnAuthService}; -/// Global app context. -#[derive(Debug, Clone)] +/// Global application context. +#[derive(Clone, Debug)] pub struct AppContext { /// [Medea] configuration. /// @@ -28,6 +28,7 @@ pub struct AppContext { impl AppContext { /// Creates new [`AppContext`]. + #[inline] pub fn new(config: Conf, turn: Arc) -> Self { Self { config: Arc::new(config), diff --git a/src/main.rs b/src/main.rs index 6ba2848c2..73c9ef8f2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,5 @@ +//! Medea media server application. + use std::collections::HashMap; use actix::Actor; diff --git a/src/signalling/elements/member.rs b/src/signalling/elements/member.rs index f496b216a..9796ca869 100644 --- a/src/signalling/elements/member.rs +++ b/src/signalling/elements/member.rs @@ -41,7 +41,7 @@ pub enum MembersLoadError { TryFromError(TryFromElementError, StatefulFid), /// [`Member`] not found. - #[display(fmt = "Member [id = {}] not found.", _0)] + #[display(fmt = "Member [id = {}] not found", _0)] MemberNotFound(Fid), /// [`EndpointSpec`] not found. @@ -352,7 +352,7 @@ impl Member { /// Creates new [`WebRtcPlayEndpoint`] based on provided /// [`WebRtcPlayEndpointSpec`]. /// - /// This function will add created [`WebRtcPlayEndpoint`] to src's + /// This function will add created [`WebRtcPlayEndpoint`] to `src`s of /// [`WebRtcPublishEndpoint`] and to provided [`Member`]. pub fn create_sink( member: &Rc, @@ -419,7 +419,7 @@ impl WeakMember { Member(Weak::upgrade(&self.0).unwrap()) } - /// Safe upgrades to [`Member`]. + /// Safely upgrades to [`Member`]. pub fn safe_upgrade(&self) -> Option { Weak::upgrade(&self.0).map(Member) } diff --git a/src/signalling/participants.rs b/src/signalling/participants.rs index 66a818d45..6b7840eba 100644 --- a/src/signalling/participants.rs +++ b/src/signalling/participants.rs @@ -68,7 +68,6 @@ pub enum ParticipantServiceErr { EndpointNotFound(Fid), /// Some error happened in [`Member`]. - #[display(fmt = "{}", _0)] MemberError(MemberError), } @@ -168,10 +167,10 @@ impl ParticipantService { /// Lookups [`Member`] by provided [`MemberId`] and credentials. /// - /// Returns [`Err(AuthorizationError::MemberNotExists)`] if lookup by + /// Returns [`AuthorizationError::MemberNotExists`] if lookup by /// [`MemberId`] failed. /// - /// Returns [`Err(AuthorizationError::InvalidCredentials)`] if [`Member`] + /// Returns [`AuthorizationError::InvalidCredentials`] if [`Member`] /// was found, but incorrect credentials were provided. pub fn get_member_by_id_and_credentials( &self, @@ -385,7 +384,7 @@ impl ParticipantService { join_all(close_fut).map(|_| ()) } - /// Deletes [`Member`] from [`ParticipantService`], remove this user from + /// Deletes [`Member`] from [`ParticipantService`], removes this user from /// [`TurnAuthService`], closes RPC connection with him and removes drop /// connection task. /// @@ -416,6 +415,7 @@ impl ParticipantService { } } + /// Inserts given [`Member`] into [`ParticipantService`]. pub fn insert_member(&mut self, id: MemberId, member: Member) { self.members.insert(id, member); } diff --git a/src/signalling/room.rs b/src/signalling/room.rs index a1c586896..9dc07727a 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -61,33 +61,45 @@ pub type ActFuture = pub enum RoomError { #[display(fmt = "Couldn't find Peer with [id = {}]", _0)] PeerNotFound(PeerId), - #[display(fmt = "{}", _0)] + MemberError(MemberError), + #[display(fmt = "Member [id = {}] does not have Turn credentials", _0)] NoTurnCredentials(MemberId), + #[display(fmt = "Couldn't find RpcConnection with Member [id = {}]", _0)] ConnectionNotExists(MemberId), + #[display(fmt = "Unable to send event to Member [id = {}]", _0)] UnableToSendEvent(MemberId), + #[display(fmt = "PeerError: {}", _0)] PeerError(PeerError), + #[display(fmt = "{}", _0)] MembersLoadError(MembersLoadError), + #[display(fmt = "{}", _0)] TryFromElementError(TryFromElementError), + #[display(fmt = "Generic room error: {}", _0)] BadRoomSpec(String), + #[display(fmt = "Turn service error: {}", _0)] TurnServiceError(String), - #[display(fmt = "{}", _0)] + ParticipantServiceErr(ParticipantServiceErr), + #[display(fmt = "Client error:{}", _0)] ClientError(String), + #[display(fmt = "Given Fid [fid = {}] to wrong Room [id = {}]", _0, _1)] WrongRoomId(StatefulFid, RoomId), + /// Try to create [`Member`] with ID which already exists. #[display(fmt = "Member [id = {}] already exists.", _0)] MemberAlreadyExists(Fid), + /// Try to create [`Endpoint`] with ID which already exists. /// /// [`Endpoint`]: crate::signalling::elements::endpoints::Endpoint @@ -877,9 +889,9 @@ impl Into for &mut Room { } // TODO: Tightly coupled with protobuf. -// We should name this method GetElements, that will return some -// intermediate DTO, that will be serialized at the caller side. -// But lets leave it as it is for now. +// We should name this method GetElements, that will return some +// intermediate DTO, that will be serialized at the caller side. +// But lets leave it as it is for now. /// Message for serializing this [`Room`] and [`Room`]'s elements to protobuf /// spec. @@ -1107,7 +1119,7 @@ impl Handler for Room { } } -/// Signal for delete elements from this [`Room`]. +/// Signal for deleting elements from this [`Room`]. #[derive(Message, Debug)] #[rtype(result = "()")] pub struct Delete(pub Vec); @@ -1139,7 +1151,7 @@ impl Handler for Room { } } -/// Signal for create new [`Member`] in this [`Room`]. +/// Signal for creating new [`Member`] in this [`Room`]. #[derive(Message, Debug)] #[rtype(result = "Result<(), RoomError>")] pub struct CreateMember(pub MemberId, pub MemberSpec); @@ -1161,7 +1173,7 @@ impl Handler for Room { } } -/// Signal for create new `Endpoint` from [`EndpointSpec`]. +/// Signal for creating new `Endpoint` from [`EndpointSpec`]. #[derive(Message, Debug)] #[rtype(result = "Result<(), RoomError>")] pub struct CreateEndpoint { diff --git a/src/signalling/room_service.rs b/src/signalling/room_service.rs index b373ba757..0efdd5c38 100644 --- a/src/signalling/room_service.rs +++ b/src/signalling/room_service.rs @@ -43,7 +43,7 @@ pub enum RoomServiceError { #[display(fmt = "Room mailbox error: {:?}", _0)] RoomMailboxErr(MailboxError), - /// Try to create [`Room`] with [`RoomId`] which already exists in + /// Attempt to create [`Room`] with [`RoomId`] which already exists in /// [`RoomRepository`]. #[display(fmt = "Room [id = {}] already exists.", _0)] RoomAlreadyExists(Fid), @@ -51,7 +51,6 @@ pub enum RoomServiceError { /// Some error happened in [`Room`]. /// /// For more info read [`RoomError`] docs. - #[display(fmt = "{}", _0)] RoomError(RoomError), /// Error which can happen while converting protobuf objects into interior From 3d29f4471ef7662bdfd6e5c167c10b85e3488e00 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 25 Oct 2019 14:20:19 +0300 Subject: [PATCH 733/735] Fix sink creating [run ci] --- src/signalling/room.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/signalling/room.rs b/src/signalling/room.rs index 9dc07727a..4e89dff24 100644 --- a/src/signalling/room.rs +++ b/src/signalling/room.rs @@ -786,7 +786,9 @@ impl Room { member.insert_sink(sink); - self.init_member_connections(&member, ctx); + if self.members.member_has_connection(member_id) { + self.init_member_connections(&member, ctx); + } Ok(()) } From 483fa743f2fbae6b525c4158e8b82d945196b7b9 Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 25 Oct 2019 14:23:32 +0300 Subject: [PATCH 734/735] Fix rustfmt installation [run ci] --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 6550d877c..8149673ae 100644 --- a/.travis.yml +++ b/.travis.yml @@ -36,6 +36,7 @@ jobs: stage: check rust: nightly cache: false + before_script: rustup component add rustfmt --toolchain nightly-x86_64-unknown-linux-gnu script: make fmt check=yes - name: medea-jason (beta) From 2467eb0ee8919cf835462d629503835f6d0a00eb Mon Sep 17 00:00:00 2001 From: Semen Evdokimov Date: Fri, 25 Oct 2019 15:37:35 +0300 Subject: [PATCH 735/735] Update Cargo.lock [run ci] --- Cargo.lock | 111 ++++++++++++++++++++++++++--------------------------- 1 file changed, 55 insertions(+), 56 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9832cc1be..2dc55797a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -495,11 +495,10 @@ dependencies = [ [[package]] name = "c2-chacha" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ppv-lite86 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", + "ppv-lite86 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -572,7 +571,7 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.52 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -954,7 +953,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "getrandom" -version = "0.1.12" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1131,10 +1130,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "js-sys" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "wasm-bindgen 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.52 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1298,7 +1297,7 @@ dependencies = [ "downcast 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "fragile 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "js-sys 0.3.28 (registry+https://github.com/rust-lang/crates.io-index)", + "js-sys 0.3.29 (registry+https://github.com/rust-lang/crates.io-index)", "macro-attr 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "medea-client-api-proto 0.1.1-dev", "medea-macro 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1307,10 +1306,10 @@ dependencies = [ "predicates-tree 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-futures 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-test 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "web-sys 0.3.28 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.52 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-futures 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-test 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "web-sys 0.3.29 (registry+https://github.com/rust-lang/crates.io-index)", "wee_alloc 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1579,7 +1578,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "ppv-lite86" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1723,7 +1722,7 @@ name = "rand" version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "getrandom 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "getrandom 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1744,7 +1743,7 @@ name = "rand_chacha" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "c2-chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "c2-chacha 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1766,7 +1765,7 @@ name = "rand_core" version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "getrandom 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "getrandom 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2650,18 +2649,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "wasm-bindgen" -version = "0.2.51" +version = "0.2.52" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-macro 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-macro 0.2.52 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.51" +version = "0.2.52" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bumpalo 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2670,62 +2669,62 @@ dependencies = [ "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-shared 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-shared 0.2.52 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "js-sys 0.3.28 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", - "web-sys 0.3.28 (registry+https://github.com/rust-lang/crates.io-index)", + "js-sys 0.3.29 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.52 (registry+https://github.com/rust-lang/crates.io-index)", + "web-sys 0.3.29 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.51" +version = "0.2.52" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-macro-support 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-macro-support 0.2.52 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.51" +version = "0.2.52" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-backend 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-shared 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-backend 0.2.52 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-shared 0.2.52 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.51" +version = "0.2.52" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "wasm-bindgen-test" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "console_error_panic_hook 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "js-sys 0.3.28 (registry+https://github.com/rust-lang/crates.io-index)", + "js-sys 0.3.29 (registry+https://github.com/rust-lang/crates.io-index)", "scoped-tls 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-futures 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-test-macro 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.52 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-futures 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-test-macro 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-test-macro" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2734,7 +2733,7 @@ dependencies = [ [[package]] name = "wasm-bindgen-webidl" -version = "0.2.51" +version = "0.2.52" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2743,20 +2742,20 @@ dependencies = [ "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-backend 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-backend 0.2.52 (registry+https://github.com/rust-lang/crates.io-index)", "weedle 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "web-sys" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "js-sys 0.3.28 (registry+https://github.com/rust-lang/crates.io-index)", + "js-sys 0.3.29 (registry+https://github.com/rust-lang/crates.io-index)", "sourcefile 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-webidl 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.52 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-webidl 0.2.52 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2902,7 +2901,7 @@ dependencies = [ "checksum bumpalo 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ad807f2fc2bf185eeb98ff3a901bd46dc5ad58163d0fa4577ba0d25674d71708" "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" "checksum bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" -"checksum c2-chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7d64d04786e0f528460fc884753cf8dddcc466be308f6026f8e355c41a0e4101" +"checksum c2-chacha 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "214238caa1bf3a496ec3392968969cab8549f96ff30652c9e56885329315f6bb" "checksum cc 1.0.46 (registry+https://github.com/rust-lang/crates.io-index)" = "0213d356d3c4ea2c18c40b037c3be23cd639825c18f25ee670ac7813beeef99c" "checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" "checksum chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e8493056968583b0193c1bb04d6f7684586f3726992d6c573261941a895dbd68" @@ -2955,7 +2954,7 @@ dependencies = [ "checksum futures-sink-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)" = "86f148ef6b69f75bb610d4f9a2336d4fc88c4b5b67129d1a340dd0fd362efeec" "checksum futures-util-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)" = "5ce968633c17e5f97936bd2797b6e38fb56cf16a7422319f7ec2e30d3c470e8d" "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" -"checksum getrandom 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "473a1265acc8ff1e808cd0a1af8cee3c2ee5200916058a2ca113c29f2d903571" +"checksum getrandom 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "e7db7ca94ed4cd01190ceee0d8a8052f08a247aa1b469a7f68c6a3b71afcf407" "checksum grpcio 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "cf45c98940795d83354880f073f3a2a2a995f50d3a3e43247ea23eca978d6574" "checksum grpcio-compiler 0.5.0-alpha.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dd8b3213a332a2865a307e553f43d632bc4a81f0e0f5a90d194dee5b9c02d8a7" "checksum grpcio-sys 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f6a31d8b4769d18e20de167e3c0ccae6b7dd506dfff78d323c2166e76efbe408" @@ -2975,7 +2974,7 @@ dependencies = [ "checksum iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" "checksum ipconfig 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "aa79fa216fbe60834a9c0737d7fcd30425b32d1c58854663e24d4c4b328ed83f" "checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" -"checksum js-sys 0.3.28 (registry+https://github.com/rust-lang/crates.io-index)" = "2cc9a97d7cec30128fd8b28a7c1f9df1c001ceb9b441e2b755e24130a6b43c79" +"checksum js-sys 0.3.29 (registry+https://github.com/rust-lang/crates.io-index)" = "5061eb59a5afd4f6ff96dc565963e4e2737b915d070233cb26b88e3f58af41b4" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a91d884b6667cd606bb5a69aa0c99ba811a115fc68915e7056ec08a46e93199a" "checksum lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "76f033c7ad61445c5b347c7382dd1237847eb1bce590fe50365dcb33d546be73" @@ -3018,7 +3017,7 @@ dependencies = [ "checksum percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" "checksum pin-utils 0.1.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5894c618ce612a3fa23881b152b608bafb8c56cfc22f434a3ba3120b40f7b587" "checksum pkg-config 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)" = "72d5370d90f49f70bd033c3d75e87fc529fbfff9d6f7cccef07d6170079d91ea" -"checksum ppv-lite86 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e3cbf9f658cdb5000fcf6f362b8ea2ba154b9f146a61c7a20d647034c6b6561b" +"checksum ppv-lite86 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "74490b50b9fbe561ac330df47c08f3f33073d2d00c150f719147d7c54522fa1b" "checksum predicates 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "53e09015b0d3f5a0ec2d4428f7559bb7b3fff341b4e159fedd1d57fac8b939ff" "checksum predicates-core 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "06075c3a3e92559ff8929e7a280684489ea27fe44805174c3ebd9328dcb37178" "checksum predicates-tree 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8e63c4859013b38a76eca2414c64911fba30def9e3202ac461a2d22831220124" @@ -3135,16 +3134,16 @@ dependencies = [ "checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" "checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" "checksum wasi 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b89c3ce4ce14bdc6fb6beaf9ec7928ca331de5df7e5ea278375642a2f478570d" -"checksum wasm-bindgen 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)" = "cd34c5ba0d228317ce388e87724633c57edca3e7531feb4e25e35aaa07a656af" -"checksum wasm-bindgen-backend 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)" = "927196b315c23eed2748442ba675a4c54a1a079d90d9bdc5ad16ce31cf90b15b" -"checksum wasm-bindgen-futures 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8fb4410bcecc9a1c38c3021d95e2d99536cd6c426e2c424f307a3ff326edcb48" -"checksum wasm-bindgen-macro 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)" = "92c2442bf04d89792816650820c3fb407af8da987a9f10028d5317f5b04c2b4a" -"checksum wasm-bindgen-macro-support 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)" = "9c075d27b7991c68ca0f77fe628c3513e64f8c477d422b859e03f28751b46fc5" -"checksum wasm-bindgen-shared 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)" = "83d61fe986a7af038dd8b5ec660e5849cbd9f38e7492b9404cc48b2b4df731d1" -"checksum wasm-bindgen-test 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2c3d30c1e43ebb4c4835f8163456d16f83dd6c1831424cb22680c680ef5f8ea8" -"checksum wasm-bindgen-test-macro 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5f093012630c0c14be061ac7a8d99f82a94e2b1cfd74619fa71090705d2c91be" -"checksum wasm-bindgen-webidl 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)" = "9b979afb0535fe4749906a674082db1211de8aef466331d43232f63accb7c07c" -"checksum web-sys 0.3.28 (registry+https://github.com/rust-lang/crates.io-index)" = "c84440699cd02ca23bed6f045ffb1497bc18a3c2628bd13e2093186faaaacf6b" +"checksum wasm-bindgen 0.2.52 (registry+https://github.com/rust-lang/crates.io-index)" = "637353fd57864c20f1968dc21680fe03985ca3a7ef6a5ce027777513bdecc282" +"checksum wasm-bindgen-backend 0.2.52 (registry+https://github.com/rust-lang/crates.io-index)" = "c85481ca7d1aad8cf40e0140830b2197ce89184a80e54e307b55fd64d78ed63e" +"checksum wasm-bindgen-futures 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f6c2c779d3f8b19acb09a8ae1e7f3f6de309819dfb1333b7a0c0e6cc4de26b9d" +"checksum wasm-bindgen-macro 0.2.52 (registry+https://github.com/rust-lang/crates.io-index)" = "9f627667b5f4f8bd923c93107b96907c60e7e8eb2636802499fce468c87e3689" +"checksum wasm-bindgen-macro-support 0.2.52 (registry+https://github.com/rust-lang/crates.io-index)" = "a48f5147b0c049bc306d5b9e53c891056a1fd8c4e7311fffbce233e4f200d45e" +"checksum wasm-bindgen-shared 0.2.52 (registry+https://github.com/rust-lang/crates.io-index)" = "1e272b0d31b78cdcaf5ad440d28276546d99b059a953e5afb387aefce66c3c5a" +"checksum wasm-bindgen-test 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b255415d7471abc1633c00141d9ee90dfc306932dbdbc319bd8e23ba2eb7b01a" +"checksum wasm-bindgen-test-macro 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "93ae97a6a9f9a7fcb8c155b93048e60869e1dd17e5714b62f1e63ef0aa4539c5" +"checksum wasm-bindgen-webidl 0.2.52 (registry+https://github.com/rust-lang/crates.io-index)" = "6965845db6189148d8b26387aee0bbf1c84f3da78f57ac543f364fc8ff7ab6e9" +"checksum web-sys 0.3.29 (registry+https://github.com/rust-lang/crates.io-index)" = "0a8b4b06314fd2ce36977e9487607ccff4030779129813f89d0e618710910146" "checksum wee_alloc 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "dbb3b5a6b2bb17cb6ad44a2e68a43e8d2722c997da10e928665c72ec6c0a0b8e" "checksum weedle 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3bb43f70885151e629e2a19ce9e50bd730fd436cfd4b666894c9ce4de9141164" "checksum widestring 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "effc0e4ff8085673ea7b9b2e3c73f6bd4d118810c9009ed8f1e16bd96c331db6"